WIP - add extractor, generate snippet_data
This commit is contained in:
21
node_modules/jest-haste-map/LICENSE
generated
vendored
Normal file
21
node_modules/jest-haste-map/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
28
node_modules/jest-haste-map/build/HasteFS.d.ts
generated
vendored
Normal file
28
node_modules/jest-haste-map/build/HasteFS.d.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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 { Config } from '@jest/types';
|
||||
import { FileData } from './types';
|
||||
export default class HasteFS {
|
||||
private readonly _rootDir;
|
||||
private readonly _files;
|
||||
constructor({ rootDir, files }: {
|
||||
rootDir: Config.Path;
|
||||
files: FileData;
|
||||
});
|
||||
getModuleName(file: Config.Path): string | null;
|
||||
getSize(file: Config.Path): number | null;
|
||||
getDependencies(file: Config.Path): Array<string> | null;
|
||||
getSha1(file: Config.Path): string | null;
|
||||
exists(file: Config.Path): boolean;
|
||||
getAllFiles(): Array<Config.Path>;
|
||||
getFileIterator(): Iterable<Config.Path>;
|
||||
getAbsoluteFileIterator(): Iterable<Config.Path>;
|
||||
matchFiles(pattern: RegExp | string): Array<Config.Path>;
|
||||
matchFilesWithGlob(globs: Array<Config.Glob>, root: Config.Path | null): Set<Config.Path>;
|
||||
private _getFileData;
|
||||
}
|
||||
//# sourceMappingURL=HasteFS.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/HasteFS.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/HasteFS.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"HasteFS.d.ts","sourceRoot":"","sources":["../src/HasteFS.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAIjC,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;gBAEtB,EAAC,OAAO,EAAE,KAAK,EAAC,EAAE;QAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAA;KAAC;IAKrE,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,IAAI;IAK/C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,IAAI;IAKzC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAYxD,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,IAAI;IAKzC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,OAAO;IAIlC,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAIjC,eAAe,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAIvC,uBAAuB,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAMjD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAaxD,kBAAkB,CAChB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EACzB,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,GACvB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAWnB,OAAO,CAAC,YAAY;CAIrB"}
|
||||
249
node_modules/jest-haste-map/build/HasteFS.js
generated
vendored
Normal file
249
node_modules/jest-haste-map/build/HasteFS.js
generated
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _micromatch() {
|
||||
const data = _interopRequireDefault(require('micromatch'));
|
||||
|
||||
_micromatch = function _micromatch() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('./lib/fast_path'));
|
||||
|
||||
var _constants = _interopRequireDefault(require('./constants'));
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
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 HasteFS {
|
||||
constructor({rootDir, files}) {
|
||||
_defineProperty(this, '_rootDir', void 0);
|
||||
|
||||
_defineProperty(this, '_files', void 0);
|
||||
|
||||
this._rootDir = rootDir;
|
||||
this._files = files;
|
||||
}
|
||||
|
||||
getModuleName(file) {
|
||||
const fileMetadata = this._getFileData(file);
|
||||
|
||||
return (fileMetadata && fileMetadata[_constants.default.ID]) || null;
|
||||
}
|
||||
|
||||
getSize(file) {
|
||||
const fileMetadata = this._getFileData(file);
|
||||
|
||||
return (fileMetadata && fileMetadata[_constants.default.SIZE]) || null;
|
||||
}
|
||||
|
||||
getDependencies(file) {
|
||||
const fileMetadata = this._getFileData(file);
|
||||
|
||||
if (fileMetadata) {
|
||||
return fileMetadata[_constants.default.DEPENDENCIES]
|
||||
? fileMetadata[_constants.default.DEPENDENCIES].split(
|
||||
_constants.default.DEPENDENCY_DELIM
|
||||
)
|
||||
: [];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
getSha1(file) {
|
||||
const fileMetadata = this._getFileData(file);
|
||||
|
||||
return (fileMetadata && fileMetadata[_constants.default.SHA1]) || null;
|
||||
}
|
||||
|
||||
exists(file) {
|
||||
return this._getFileData(file) != null;
|
||||
}
|
||||
|
||||
getAllFiles() {
|
||||
return Array.from(this.getAbsoluteFileIterator());
|
||||
}
|
||||
|
||||
getFileIterator() {
|
||||
return this._files.keys();
|
||||
}
|
||||
|
||||
*getAbsoluteFileIterator() {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = this.getFileIterator()[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const file = _step.value;
|
||||
yield fastPath.resolve(this._rootDir, file);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matchFiles(pattern) {
|
||||
if (!(pattern instanceof RegExp)) {
|
||||
pattern = new RegExp(pattern);
|
||||
}
|
||||
|
||||
const files = [];
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = this.getAbsoluteFileIterator()[Symbol.iterator](),
|
||||
_step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
) {
|
||||
const file = _step2.value;
|
||||
|
||||
if (pattern.test(file)) {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
matchFilesWithGlob(globs, root) {
|
||||
const files = new Set();
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator3 = this.getAbsoluteFileIterator()[Symbol.iterator](),
|
||||
_step3;
|
||||
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done);
|
||||
_iteratorNormalCompletion3 = true
|
||||
) {
|
||||
const file = _step3.value;
|
||||
const filePath = root ? fastPath.relative(root, file) : file;
|
||||
|
||||
if (
|
||||
_micromatch().default.some(
|
||||
(0, _jestUtil().replacePathSepForGlob)(filePath),
|
||||
globs
|
||||
)
|
||||
) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
_getFileData(file) {
|
||||
const relativePath = fastPath.relative(this._rootDir, file);
|
||||
return this._files.get(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = HasteFS;
|
||||
49
node_modules/jest-haste-map/build/ModuleMap.d.ts
generated
vendored
Normal file
49
node_modules/jest-haste-map/build/ModuleMap.d.ts
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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 { Config } from '@jest/types';
|
||||
import { DuplicatesSet, HTypeValue, RawModuleMap, ModuleMapData, MockData } from './types';
|
||||
declare type ValueType<T> = T extends Map<string, infer V> ? V : never;
|
||||
export declare type SerializableModuleMap = {
|
||||
duplicates: ReadonlyArray<[string, [string, [string, [string, number]]]]>;
|
||||
map: ReadonlyArray<[string, ValueType<ModuleMapData>]>;
|
||||
mocks: ReadonlyArray<[string, ValueType<MockData>]>;
|
||||
rootDir: Config.Path;
|
||||
};
|
||||
export default class ModuleMap {
|
||||
static DuplicateHasteCandidatesError: typeof DuplicateHasteCandidatesError;
|
||||
private readonly _raw;
|
||||
private json;
|
||||
private static mapToArrayRecursive;
|
||||
private static mapFromArrayRecursive;
|
||||
constructor(raw: RawModuleMap);
|
||||
getModule(name: string, platform?: string | null, supportsNativePlatform?: boolean | null, type?: HTypeValue | null): Config.Path | null;
|
||||
getPackage(name: string, platform: string | null | undefined, _supportsNativePlatform: boolean | null): Config.Path | null;
|
||||
getMockModule(name: string): Config.Path | undefined;
|
||||
getRawModuleMap(): RawModuleMap;
|
||||
toJSON(): SerializableModuleMap;
|
||||
static fromJSON(serializableModuleMap: SerializableModuleMap): ModuleMap;
|
||||
/**
|
||||
* When looking up a module's data, we walk through each eligible platform for
|
||||
* the query. For each platform, we want to check if there are known
|
||||
* duplicates for that name+platform pair. The duplication logic normally
|
||||
* removes elements from the `map` object, but we want to check upfront to be
|
||||
* extra sure. If metadata exists both in the `duplicates` object and the
|
||||
* `map`, this would be a bug.
|
||||
*/
|
||||
private _getModuleMetadata;
|
||||
private _assertNoDuplicates;
|
||||
static create(rootDir: Config.Path): ModuleMap;
|
||||
}
|
||||
declare class DuplicateHasteCandidatesError extends Error {
|
||||
hasteName: string;
|
||||
platform: string | null;
|
||||
supportsNativePlatform: boolean;
|
||||
duplicatesSet: DuplicatesSet;
|
||||
constructor(name: string, platform: string, supportsNativePlatform: boolean, duplicatesSet: DuplicatesSet);
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ModuleMap.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/ModuleMap.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/ModuleMap.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ModuleMap.d.ts","sourceRoot":"","sources":["../src/ModuleMap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,aAAa,EACb,UAAU,EAEV,YAAY,EACZ,aAAa,EACb,QAAQ,EACT,MAAM,SAAS,CAAC;AAQjB,aAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/D,oBAAY,qBAAqB,GAAG;IAClC,UAAU,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,GAAG,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvD,KAAK,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,MAAM,CAAC,6BAA6B,EAAE,OAAO,6BAA6B,CAAC;IAC3E,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAe;IACpC,OAAO,CAAC,IAAI,CAAoC;IAEhD,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC,OAAO,CAAC,MAAM,CAAC,qBAAqB;gBAYxB,GAAG,EAAE,YAAY;IAI7B,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,EACvC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,GACvB,MAAM,CAAC,IAAI,GAAG,IAAI;IAgBrB,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,uBAAuB,EAAE,OAAO,GAAG,IAAI,GACtC,MAAM,CAAC,IAAI,GAAG,IAAI;IAIrB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,SAAS;IAMpD,eAAe,IAAI,YAAY;IAS/B,MAAM,IAAI,qBAAqB;IAc/B,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IAW5D;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,mBAAmB;IA0B3B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI;CAQnC;AAED,cAAM,6BAA8B,SAAQ,KAAK;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;gBAG3B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,sBAAsB,EAAE,OAAO,EAC/B,aAAa,EAAE,aAAa;CAsB/B"}
|
||||
355
node_modules/jest-haste-map/build/ModuleMap.js
generated
vendored
Normal file
355
node_modules/jest-haste-map/build/ModuleMap.js
generated
vendored
Normal file
@ -0,0 +1,355 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('./lib/fast_path'));
|
||||
|
||||
var _constants = _interopRequireDefault(require('./constants'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
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 EMPTY_OBJ = {};
|
||||
const EMPTY_MAP = new Map();
|
||||
|
||||
class ModuleMap {
|
||||
static mapToArrayRecursive(map) {
|
||||
let arr = Array.from(map);
|
||||
|
||||
if (arr[0] && arr[0][1] instanceof Map) {
|
||||
arr = arr.map(el => [el[0], this.mapToArrayRecursive(el[1])]);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
static mapFromArrayRecursive(arr) {
|
||||
if (arr[0] && Array.isArray(arr[1])) {
|
||||
arr = arr.map(el => [el[0], this.mapFromArrayRecursive(el[1])]);
|
||||
}
|
||||
|
||||
return new Map(arr);
|
||||
}
|
||||
|
||||
constructor(raw) {
|
||||
_defineProperty(this, '_raw', void 0);
|
||||
|
||||
_defineProperty(this, 'json', void 0);
|
||||
|
||||
this._raw = raw;
|
||||
}
|
||||
|
||||
getModule(name, platform, supportsNativePlatform, type) {
|
||||
if (type == null) {
|
||||
type = _constants.default.MODULE;
|
||||
}
|
||||
|
||||
const module = this._getModuleMetadata(
|
||||
name,
|
||||
platform,
|
||||
!!supportsNativePlatform
|
||||
);
|
||||
|
||||
if (module && module[_constants.default.TYPE] === type) {
|
||||
const modulePath = module[_constants.default.PATH];
|
||||
return modulePath && fastPath.resolve(this._raw.rootDir, modulePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getPackage(name, platform, _supportsNativePlatform) {
|
||||
return this.getModule(name, platform, null, _constants.default.PACKAGE);
|
||||
}
|
||||
|
||||
getMockModule(name) {
|
||||
const mockPath =
|
||||
this._raw.mocks.get(name) || this._raw.mocks.get(name + '/index');
|
||||
|
||||
return mockPath && fastPath.resolve(this._raw.rootDir, mockPath);
|
||||
}
|
||||
|
||||
getRawModuleMap() {
|
||||
return {
|
||||
duplicates: this._raw.duplicates,
|
||||
map: this._raw.map,
|
||||
mocks: this._raw.mocks,
|
||||
rootDir: this._raw.rootDir
|
||||
};
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
if (!this.json) {
|
||||
this.json = {
|
||||
duplicates: ModuleMap.mapToArrayRecursive(this._raw.duplicates),
|
||||
map: Array.from(this._raw.map),
|
||||
mocks: Array.from(this._raw.mocks),
|
||||
rootDir: this._raw.rootDir
|
||||
};
|
||||
}
|
||||
|
||||
return this.json;
|
||||
}
|
||||
|
||||
static fromJSON(serializableModuleMap) {
|
||||
return new ModuleMap({
|
||||
duplicates: ModuleMap.mapFromArrayRecursive(
|
||||
serializableModuleMap.duplicates
|
||||
),
|
||||
map: new Map(serializableModuleMap.map),
|
||||
mocks: new Map(serializableModuleMap.mocks),
|
||||
rootDir: serializableModuleMap.rootDir
|
||||
});
|
||||
}
|
||||
/**
|
||||
* When looking up a module's data, we walk through each eligible platform for
|
||||
* the query. For each platform, we want to check if there are known
|
||||
* duplicates for that name+platform pair. The duplication logic normally
|
||||
* removes elements from the `map` object, but we want to check upfront to be
|
||||
* extra sure. If metadata exists both in the `duplicates` object and the
|
||||
* `map`, this would be a bug.
|
||||
*/
|
||||
|
||||
_getModuleMetadata(name, platform, supportsNativePlatform) {
|
||||
const map = this._raw.map.get(name) || EMPTY_OBJ;
|
||||
const dupMap = this._raw.duplicates.get(name) || EMPTY_MAP;
|
||||
|
||||
if (platform != null) {
|
||||
this._assertNoDuplicates(
|
||||
name,
|
||||
platform,
|
||||
supportsNativePlatform,
|
||||
dupMap.get(platform)
|
||||
);
|
||||
|
||||
if (map[platform] != null) {
|
||||
return map[platform];
|
||||
}
|
||||
}
|
||||
|
||||
if (supportsNativePlatform) {
|
||||
this._assertNoDuplicates(
|
||||
name,
|
||||
_constants.default.NATIVE_PLATFORM,
|
||||
supportsNativePlatform,
|
||||
dupMap.get(_constants.default.NATIVE_PLATFORM)
|
||||
);
|
||||
|
||||
if (map[_constants.default.NATIVE_PLATFORM]) {
|
||||
return map[_constants.default.NATIVE_PLATFORM];
|
||||
}
|
||||
}
|
||||
|
||||
this._assertNoDuplicates(
|
||||
name,
|
||||
_constants.default.GENERIC_PLATFORM,
|
||||
supportsNativePlatform,
|
||||
dupMap.get(_constants.default.GENERIC_PLATFORM)
|
||||
);
|
||||
|
||||
if (map[_constants.default.GENERIC_PLATFORM]) {
|
||||
return map[_constants.default.GENERIC_PLATFORM];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_assertNoDuplicates(name, platform, supportsNativePlatform, relativePathSet) {
|
||||
if (relativePathSet == null) {
|
||||
return;
|
||||
} // Force flow refinement
|
||||
|
||||
const previousSet = relativePathSet;
|
||||
const duplicates = new Map();
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = previousSet[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const _step$value = _slicedToArray(_step.value, 2),
|
||||
relativePath = _step$value[0],
|
||||
type = _step$value[1];
|
||||
|
||||
const duplicatePath = fastPath.resolve(this._raw.rootDir, relativePath);
|
||||
duplicates.set(duplicatePath, type);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new DuplicateHasteCandidatesError(
|
||||
name,
|
||||
platform,
|
||||
supportsNativePlatform,
|
||||
duplicates
|
||||
);
|
||||
}
|
||||
|
||||
static create(rootDir) {
|
||||
return new ModuleMap({
|
||||
duplicates: new Map(),
|
||||
map: new Map(),
|
||||
mocks: new Map(),
|
||||
rootDir
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = ModuleMap;
|
||||
|
||||
_defineProperty(ModuleMap, 'DuplicateHasteCandidatesError', void 0);
|
||||
|
||||
class DuplicateHasteCandidatesError extends Error {
|
||||
constructor(name, platform, supportsNativePlatform, duplicatesSet) {
|
||||
const platformMessage = getPlatformMessage(platform);
|
||||
super(
|
||||
`The name \`${name}\` was looked up in the Haste module map. It ` +
|
||||
`cannot be resolved, because there exists several different ` +
|
||||
`files, or packages, that provide a module for ` +
|
||||
`that particular name and platform. ${platformMessage} You must ` +
|
||||
`delete or blacklist files until there remains only one of these:\n\n` +
|
||||
Array.from(duplicatesSet)
|
||||
.map(
|
||||
([dupFilePath, dupFileType]) =>
|
||||
` * \`${dupFilePath}\` (${getTypeMessage(dupFileType)})\n`
|
||||
)
|
||||
.sort()
|
||||
.join('')
|
||||
);
|
||||
|
||||
_defineProperty(this, 'hasteName', void 0);
|
||||
|
||||
_defineProperty(this, 'platform', void 0);
|
||||
|
||||
_defineProperty(this, 'supportsNativePlatform', void 0);
|
||||
|
||||
_defineProperty(this, 'duplicatesSet', void 0);
|
||||
|
||||
this.hasteName = name;
|
||||
this.platform = platform;
|
||||
this.supportsNativePlatform = supportsNativePlatform;
|
||||
this.duplicatesSet = duplicatesSet;
|
||||
}
|
||||
}
|
||||
|
||||
function getPlatformMessage(platform) {
|
||||
if (platform === _constants.default.GENERIC_PLATFORM) {
|
||||
return 'The platform is generic (no extension).';
|
||||
}
|
||||
|
||||
return `The platform extension is \`${platform}\`.`;
|
||||
}
|
||||
|
||||
function getTypeMessage(type) {
|
||||
switch (type) {
|
||||
case _constants.default.MODULE:
|
||||
return 'module';
|
||||
|
||||
case _constants.default.PACKAGE:
|
||||
return 'package';
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
ModuleMap.DuplicateHasteCandidatesError = DuplicateHasteCandidatesError;
|
||||
9
node_modules/jest-haste-map/build/blacklist.d.ts
generated
vendored
Normal file
9
node_modules/jest-haste-map/build/blacklist.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
declare const extensions: Set<string>;
|
||||
export default extensions;
|
||||
//# sourceMappingURL=blacklist.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/blacklist.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/blacklist.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"blacklist.d.ts","sourceRoot":"","sources":["../src/blacklist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,QAAA,MAAM,UAAU,EAAE,GAAG,CAAC,MAAM,CA0C1B,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
||||
58
node_modules/jest-haste-map/build/blacklist.js
generated
vendored
Normal file
58
node_modules/jest-haste-map/build/blacklist.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// This list is compiled after the MDN list of the most common MIME types (see
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/
|
||||
// Complete_list_of_MIME_types).
|
||||
//
|
||||
// Only MIME types starting with "image/", "video/", "audio/" and "font/" are
|
||||
// reflected in the list. Adding "application/" is too risky since some text
|
||||
// file formats (like ".js" and ".json") have an "application/" MIME type.
|
||||
//
|
||||
const extensions = new Set([
|
||||
// JSONs are never haste modules, except for "package.json", which is handled.
|
||||
'.json', // Image extensions.
|
||||
'.bmp',
|
||||
'.gif',
|
||||
'.ico',
|
||||
'.jpeg',
|
||||
'.jpg',
|
||||
'.png',
|
||||
'.svg',
|
||||
'.tiff',
|
||||
'.tif',
|
||||
'.webp', // Video extensions.
|
||||
'.avi',
|
||||
'.mp4',
|
||||
'.mpeg',
|
||||
'.mpg',
|
||||
'.ogv',
|
||||
'.webm',
|
||||
'.3gp',
|
||||
'.3g2', // Audio extensions.
|
||||
'.aac',
|
||||
'.midi',
|
||||
'.mid',
|
||||
'.mp3',
|
||||
'.oga',
|
||||
'.wav',
|
||||
'.3gp',
|
||||
'.3g2', // Font extensions.
|
||||
'.eot',
|
||||
'.otf',
|
||||
'.ttf',
|
||||
'.woff',
|
||||
'.woff2'
|
||||
]);
|
||||
var _default = extensions;
|
||||
exports.default = _default;
|
||||
10
node_modules/jest-haste-map/build/constants.d.ts
generated
vendored
Normal file
10
node_modules/jest-haste-map/build/constants.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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 { HType } from './types';
|
||||
declare const constants: HType;
|
||||
export default constants;
|
||||
//# sourceMappingURL=constants.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/constants.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/constants.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,QAAA,MAAM,SAAS,EAAE,KAuBhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
||||
50
node_modules/jest-haste-map/build/constants.js
generated
vendored
Normal file
50
node_modules/jest-haste-map/build/constants.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
/*
|
||||
* This file exports a set of constants that are used for Jest's haste map
|
||||
* serialization. On very large repositories, the haste map cache becomes very
|
||||
* large to the point where it is the largest overhead in starting up Jest.
|
||||
*
|
||||
* This constant key map allows to keep the map smaller without having to build
|
||||
* a custom serialization library.
|
||||
*/
|
||||
const constants = {
|
||||
/* dependency serialization */
|
||||
DEPENDENCY_DELIM: '\0',
|
||||
|
||||
/* file map attributes */
|
||||
ID: 0,
|
||||
MTIME: 1,
|
||||
SIZE: 2,
|
||||
VISITED: 3,
|
||||
DEPENDENCIES: 4,
|
||||
SHA1: 5,
|
||||
|
||||
/* module map attributes */
|
||||
PATH: 0,
|
||||
TYPE: 1,
|
||||
|
||||
/* module types */
|
||||
MODULE: 0,
|
||||
PACKAGE: 1,
|
||||
|
||||
/* platforms */
|
||||
GENERIC_PLATFORM: 'g',
|
||||
NATIVE_PLATFORM: 'native'
|
||||
};
|
||||
var _default = constants;
|
||||
exports.default = _default;
|
||||
13
node_modules/jest-haste-map/build/crawlers/node.d.ts
generated
vendored
Normal file
13
node_modules/jest-haste-map/build/crawlers/node.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 { InternalHasteMap, CrawlerOptions } from '../types';
|
||||
declare const _default: (options: CrawlerOptions) => Promise<{
|
||||
removedFiles: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]>;
|
||||
hasteMap: InternalHasteMap;
|
||||
}>;
|
||||
export = _default;
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/crawlers/node.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/crawlers/node.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/crawlers/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAEL,gBAAgB,EAChB,cAAc,EAEf,MAAM,UAAU,CAAC;;;;;AAsHlB,kBA6CE"}
|
||||
267
node_modules/jest-haste-map/build/crawlers/node.js
generated
vendored
Normal file
267
node_modules/jest-haste-map/build/crawlers/node.js
generated
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
'use strict';
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require('fs'));
|
||||
|
||||
_fs = function _fs() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _child_process() {
|
||||
const data = require('child_process');
|
||||
|
||||
_child_process = function _child_process() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _constants = _interopRequireDefault(require('../constants'));
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function find(roots, extensions, ignore, callback) {
|
||||
const result = [];
|
||||
let activeCalls = 0;
|
||||
|
||||
function search(directory) {
|
||||
activeCalls++;
|
||||
|
||||
_fs().default.readdir(directory, (err, names) => {
|
||||
activeCalls--;
|
||||
|
||||
if (err) {
|
||||
callback(result);
|
||||
return;
|
||||
}
|
||||
|
||||
names.forEach(file => {
|
||||
file = _path().default.join(directory, file);
|
||||
|
||||
if (ignore(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
activeCalls++;
|
||||
|
||||
_fs().default.lstat(file, (err, stat) => {
|
||||
activeCalls--;
|
||||
|
||||
if (!err && stat && !stat.isSymbolicLink()) {
|
||||
if (stat.isDirectory()) {
|
||||
search(file);
|
||||
} else {
|
||||
const ext = _path()
|
||||
.default.extname(file)
|
||||
.substr(1);
|
||||
|
||||
if (extensions.indexOf(ext) !== -1) {
|
||||
result.push([file, stat.mtime.getTime(), stat.size]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (roots.length > 0) {
|
||||
roots.forEach(search);
|
||||
} else {
|
||||
callback(result);
|
||||
}
|
||||
}
|
||||
|
||||
function findNative(roots, extensions, ignore, callback) {
|
||||
const args = Array.from(roots);
|
||||
args.push('-type', 'f');
|
||||
|
||||
if (extensions.length) {
|
||||
args.push('(');
|
||||
}
|
||||
|
||||
extensions.forEach((ext, index) => {
|
||||
if (index) {
|
||||
args.push('-o');
|
||||
}
|
||||
|
||||
args.push('-iname');
|
||||
args.push('*.' + ext);
|
||||
});
|
||||
|
||||
if (extensions.length) {
|
||||
args.push(')');
|
||||
}
|
||||
|
||||
const child = (0, _child_process().spawn)('find', args);
|
||||
let stdout = '';
|
||||
|
||||
if (child.stdout === null) {
|
||||
throw new Error(
|
||||
'stdout is null - this should never happen. Please open up an issue at https://github.com/facebook/jest'
|
||||
);
|
||||
}
|
||||
|
||||
child.stdout.setEncoding('utf-8');
|
||||
child.stdout.on('data', data => (stdout += data));
|
||||
child.stdout.on('close', () => {
|
||||
const lines = stdout
|
||||
.trim()
|
||||
.split('\n')
|
||||
.filter(x => !ignore(x));
|
||||
const result = [];
|
||||
let count = lines.length;
|
||||
|
||||
if (!count) {
|
||||
callback([]);
|
||||
} else {
|
||||
lines.forEach(path => {
|
||||
_fs().default.stat(path, (err, stat) => {
|
||||
if (!err && stat) {
|
||||
result.push([path, stat.mtime.getTime(), stat.size]);
|
||||
}
|
||||
|
||||
if (--count === 0) {
|
||||
callback(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function nodeCrawl(options) {
|
||||
const data = options.data,
|
||||
extensions = options.extensions,
|
||||
forceNodeFilesystemAPI = options.forceNodeFilesystemAPI,
|
||||
ignore = options.ignore,
|
||||
rootDir = options.rootDir,
|
||||
roots = options.roots;
|
||||
return new Promise(resolve => {
|
||||
const callback = list => {
|
||||
const files = new Map();
|
||||
const removedFiles = new Map(data.files);
|
||||
list.forEach(fileData => {
|
||||
const _fileData = _slicedToArray(fileData, 3),
|
||||
filePath = _fileData[0],
|
||||
mtime = _fileData[1],
|
||||
size = _fileData[2];
|
||||
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const existingFile = data.files.get(relativeFilePath);
|
||||
|
||||
if (existingFile && existingFile[_constants.default.MTIME] === mtime) {
|
||||
files.set(relativeFilePath, existingFile);
|
||||
} else {
|
||||
// See ../constants.js; SHA-1 will always be null and fulfilled later.
|
||||
files.set(relativeFilePath, ['', mtime, size, 0, '', null]);
|
||||
}
|
||||
|
||||
removedFiles.delete(relativeFilePath);
|
||||
});
|
||||
data.files = files;
|
||||
resolve({
|
||||
hasteMap: data,
|
||||
removedFiles
|
||||
});
|
||||
};
|
||||
|
||||
if (forceNodeFilesystemAPI || process.platform === 'win32') {
|
||||
find(roots, extensions, ignore, callback);
|
||||
} else {
|
||||
findNative(roots, extensions, ignore, callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
14
node_modules/jest-haste-map/build/crawlers/watchman.d.ts
generated
vendored
Normal file
14
node_modules/jest-haste-map/build/crawlers/watchman.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 { InternalHasteMap, CrawlerOptions } from '../types';
|
||||
declare const _default: (options: CrawlerOptions) => Promise<{
|
||||
changedFiles?: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]> | undefined;
|
||||
removedFiles: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]>;
|
||||
hasteMap: InternalHasteMap;
|
||||
}>;
|
||||
export = _default;
|
||||
//# sourceMappingURL=watchman.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/crawlers/watchman.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/crawlers/watchman.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"watchman.d.ts","sourceRoot":"","sources":["../../src/crawlers/watchman.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EACL,gBAAgB,EAChB,cAAc,EAGf,MAAM,UAAU,CAAC;;;;;;AAclB,kBAwOE"}
|
||||
588
node_modules/jest-haste-map/build/crawlers/watchman.js
generated
vendored
Normal file
588
node_modules/jest-haste-map/build/crawlers/watchman.js
generated
vendored
Normal file
@ -0,0 +1,588 @@
|
||||
'use strict';
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fbWatchman() {
|
||||
const data = _interopRequireDefault(require('fb-watchman'));
|
||||
|
||||
_fbWatchman = function _fbWatchman() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
|
||||
var _normalizePathSep = _interopRequireDefault(
|
||||
require('../lib/normalizePathSep')
|
||||
);
|
||||
|
||||
var _constants = _interopRequireDefault(require('../constants'));
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const watchmanURL =
|
||||
'https://facebook.github.io/watchman/docs/troubleshooting.html';
|
||||
|
||||
function WatchmanError(error) {
|
||||
error.message =
|
||||
`Watchman error: ${error.message.trim()}. Make sure watchman ` +
|
||||
`is running for this project. See ${watchmanURL}.`;
|
||||
return error;
|
||||
}
|
||||
|
||||
module.exports =
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _watchmanCrawl = _asyncToGenerator(function*(options) {
|
||||
const fields = ['name', 'exists', 'mtime_ms', 'size'];
|
||||
const data = options.data,
|
||||
extensions = options.extensions,
|
||||
ignore = options.ignore,
|
||||
rootDir = options.rootDir,
|
||||
roots = options.roots;
|
||||
const defaultWatchExpression = [
|
||||
'allof',
|
||||
['type', 'f'],
|
||||
['anyof', ...extensions.map(extension => ['suffix', extension])]
|
||||
];
|
||||
const clocks = data.clocks;
|
||||
const client = new (_fbWatchman()).default.Client();
|
||||
let clientError;
|
||||
client.on('error', error => (clientError = WatchmanError(error))); // TODO: type better than `any`
|
||||
|
||||
const cmd = (...args) =>
|
||||
new Promise((resolve, reject) =>
|
||||
client.command(args, (error, result) =>
|
||||
error ? reject(WatchmanError(error)) : resolve(result)
|
||||
)
|
||||
);
|
||||
|
||||
if (options.computeSha1) {
|
||||
const _ref = yield cmd('list-capabilities'),
|
||||
capabilities = _ref.capabilities;
|
||||
|
||||
if (capabilities.indexOf('field-content.sha1hex') !== -1) {
|
||||
fields.push('content.sha1hex');
|
||||
}
|
||||
}
|
||||
|
||||
function getWatchmanRoots(_x2) {
|
||||
return _getWatchmanRoots.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getWatchmanRoots() {
|
||||
_getWatchmanRoots = _asyncToGenerator(function*(roots) {
|
||||
const watchmanRoots = new Map();
|
||||
yield Promise.all(
|
||||
roots.map(
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _ref2 = _asyncToGenerator(function*(root) {
|
||||
const response = yield cmd('watch-project', root);
|
||||
const existing = watchmanRoots.get(response.watch); // A root can only be filtered if it was never seen with a
|
||||
// relative_path before.
|
||||
|
||||
const canBeFiltered = !existing || existing.length > 0;
|
||||
|
||||
if (canBeFiltered) {
|
||||
if (response.relative_path) {
|
||||
watchmanRoots.set(
|
||||
response.watch,
|
||||
(existing || []).concat(response.relative_path)
|
||||
);
|
||||
} else {
|
||||
// Make the filter directories an empty array to signal that this
|
||||
// root was already seen and needs to be watched for all files or
|
||||
// directories.
|
||||
watchmanRoots.set(response.watch, []);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return function(_x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})()
|
||||
)
|
||||
);
|
||||
return watchmanRoots;
|
||||
});
|
||||
return _getWatchmanRoots.apply(this, arguments);
|
||||
}
|
||||
|
||||
function queryWatchmanForDirs(_x3) {
|
||||
return _queryWatchmanForDirs.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _queryWatchmanForDirs() {
|
||||
_queryWatchmanForDirs = _asyncToGenerator(function*(
|
||||
rootProjectDirMappings
|
||||
) {
|
||||
const files = new Map();
|
||||
let isFresh = false;
|
||||
yield Promise.all(
|
||||
Array.from(rootProjectDirMappings).map(
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _ref3 = _asyncToGenerator(function*([
|
||||
root,
|
||||
directoryFilters
|
||||
]) {
|
||||
const expression = Array.from(defaultWatchExpression);
|
||||
const glob = [];
|
||||
|
||||
if (directoryFilters.length > 0) {
|
||||
expression.push([
|
||||
'anyof',
|
||||
...directoryFilters.map(dir => ['dirname', dir])
|
||||
]);
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = directoryFilters[Symbol.iterator](),
|
||||
_step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
) {
|
||||
const directory = _step2.value;
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator3 = extensions[Symbol.iterator](),
|
||||
_step3;
|
||||
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion3 = true
|
||||
) {
|
||||
const extension = _step3.value;
|
||||
glob.push(`${directory}/**/*.${extension}`);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion3 &&
|
||||
_iterator3.return != null
|
||||
) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion2 &&
|
||||
_iterator2.return != null
|
||||
) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator4 = extensions[Symbol.iterator](), _step4;
|
||||
!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion4 = true
|
||||
) {
|
||||
const extension = _step4.value;
|
||||
glob.push(`**/*.${extension}`);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion4 &&
|
||||
_iterator4.return != null
|
||||
) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const relativeRoot = fastPath.relative(rootDir, root);
|
||||
const query = clocks.has(relativeRoot) // Use the `since` generator if we have a clock available
|
||||
? {
|
||||
expression,
|
||||
fields,
|
||||
since: clocks.get(relativeRoot)
|
||||
} // Otherwise use the `glob` filter
|
||||
: {
|
||||
expression,
|
||||
fields,
|
||||
glob
|
||||
};
|
||||
const response = yield cmd('query', root, query);
|
||||
|
||||
if ('warning' in response) {
|
||||
console.warn('watchman warning: ', response.warning);
|
||||
}
|
||||
|
||||
isFresh = isFresh || response.is_fresh_instance;
|
||||
files.set(root, response);
|
||||
});
|
||||
|
||||
return function(_x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})()
|
||||
)
|
||||
);
|
||||
return {
|
||||
files,
|
||||
isFresh
|
||||
};
|
||||
});
|
||||
return _queryWatchmanForDirs.apply(this, arguments);
|
||||
}
|
||||
|
||||
let files = data.files;
|
||||
let removedFiles = new Map();
|
||||
const changedFiles = new Map();
|
||||
let watchmanFiles;
|
||||
let isFresh = false;
|
||||
|
||||
try {
|
||||
const watchmanRoots = yield getWatchmanRoots(roots);
|
||||
const watchmanFileResults = yield queryWatchmanForDirs(watchmanRoots); // Reset the file map if watchman was restarted and sends us a list of
|
||||
// files.
|
||||
|
||||
if (watchmanFileResults.isFresh) {
|
||||
files = new Map();
|
||||
removedFiles = new Map(data.files);
|
||||
isFresh = true;
|
||||
}
|
||||
|
||||
watchmanFiles = watchmanFileResults.files;
|
||||
} finally {
|
||||
client.end();
|
||||
}
|
||||
|
||||
if (clientError) {
|
||||
throw clientError;
|
||||
} // TODO: remove non-null
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = watchmanFiles[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const _step$value = _slicedToArray(_step.value, 2),
|
||||
watchRoot = _step$value[0],
|
||||
response = _step$value[1];
|
||||
|
||||
const fsRoot = (0, _normalizePathSep.default)(watchRoot);
|
||||
const relativeFsRoot = fastPath.relative(rootDir, fsRoot);
|
||||
clocks.set(relativeFsRoot, response.clock);
|
||||
var _iteratorNormalCompletion5 = true;
|
||||
var _didIteratorError5 = false;
|
||||
var _iteratorError5 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator5 = response.files[Symbol.iterator](), _step5;
|
||||
!(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
|
||||
_iteratorNormalCompletion5 = true
|
||||
) {
|
||||
const fileData = _step5.value;
|
||||
const filePath =
|
||||
fsRoot +
|
||||
_path().default.sep +
|
||||
(0, _normalizePathSep.default)(fileData.name);
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const existingFileData = data.files.get(relativeFilePath); // If watchman is fresh, the removed files map starts with all files
|
||||
// and we remove them as we verify they still exist.
|
||||
|
||||
if (isFresh && existingFileData && fileData.exists) {
|
||||
removedFiles.delete(relativeFilePath);
|
||||
}
|
||||
|
||||
if (!fileData.exists) {
|
||||
// No need to act on files that do not exist and were not tracked.
|
||||
if (existingFileData) {
|
||||
files.delete(relativeFilePath); // If watchman is not fresh, we will know what specific files were
|
||||
// deleted since we last ran and can track only those files.
|
||||
|
||||
if (!isFresh) {
|
||||
removedFiles.set(relativeFilePath, existingFileData);
|
||||
}
|
||||
}
|
||||
} else if (!ignore(filePath)) {
|
||||
const mtime =
|
||||
typeof fileData.mtime_ms === 'number'
|
||||
? fileData.mtime_ms
|
||||
: fileData.mtime_ms.toNumber();
|
||||
const size = fileData.size;
|
||||
let sha1hex = fileData['content.sha1hex'];
|
||||
|
||||
if (typeof sha1hex !== 'string' || sha1hex.length !== 40) {
|
||||
sha1hex = null;
|
||||
}
|
||||
|
||||
let nextData;
|
||||
|
||||
if (
|
||||
existingFileData &&
|
||||
existingFileData[_constants.default.MTIME] === mtime
|
||||
) {
|
||||
nextData = existingFileData;
|
||||
} else if (
|
||||
existingFileData &&
|
||||
sha1hex &&
|
||||
existingFileData[_constants.default.SHA1] === sha1hex
|
||||
) {
|
||||
nextData = [
|
||||
existingFileData[0],
|
||||
mtime,
|
||||
existingFileData[2],
|
||||
existingFileData[3],
|
||||
existingFileData[4],
|
||||
existingFileData[5]
|
||||
];
|
||||
} else {
|
||||
// See ../constants.ts
|
||||
nextData = ['', mtime, size, 0, '', sha1hex];
|
||||
}
|
||||
|
||||
const mappings = options.mapper
|
||||
? options.mapper(filePath)
|
||||
: null;
|
||||
|
||||
if (mappings) {
|
||||
var _iteratorNormalCompletion6 = true;
|
||||
var _didIteratorError6 = false;
|
||||
var _iteratorError6 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator6 = mappings[Symbol.iterator](), _step6;
|
||||
!(_iteratorNormalCompletion6 = (_step6 = _iterator6.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion6 = true
|
||||
) {
|
||||
const absoluteVirtualFilePath = _step6.value;
|
||||
|
||||
if (!ignore(absoluteVirtualFilePath)) {
|
||||
const relativeVirtualFilePath = fastPath.relative(
|
||||
rootDir,
|
||||
absoluteVirtualFilePath
|
||||
);
|
||||
files.set(relativeVirtualFilePath, nextData);
|
||||
changedFiles.set(relativeVirtualFilePath, nextData);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError6 = true;
|
||||
_iteratorError6 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion6 &&
|
||||
_iterator6.return != null
|
||||
) {
|
||||
_iterator6.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError6) {
|
||||
throw _iteratorError6;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
files.set(relativeFilePath, nextData);
|
||||
changedFiles.set(relativeFilePath, nextData);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError5 = true;
|
||||
_iteratorError5 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
||||
_iterator5.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError5) {
|
||||
throw _iteratorError5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.files = files;
|
||||
return {
|
||||
changedFiles: isFresh ? undefined : changedFiles,
|
||||
hasteMap: data,
|
||||
removedFiles
|
||||
};
|
||||
});
|
||||
|
||||
function watchmanCrawl(_x) {
|
||||
return _watchmanCrawl.apply(this, arguments);
|
||||
}
|
||||
|
||||
return watchmanCrawl;
|
||||
})();
|
||||
9
node_modules/jest-haste-map/build/getMockName.d.ts
generated
vendored
Normal file
9
node_modules/jest-haste-map/build/getMockName.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
declare const getMockName: (filePath: string) => string;
|
||||
export default getMockName;
|
||||
//# sourceMappingURL=getMockName.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/getMockName.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/getMockName.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"getMockName.d.ts","sourceRoot":"","sources":["../src/getMockName.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,QAAA,MAAM,WAAW,8BAKhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
||||
38
node_modules/jest-haste-map/build/getMockName.js
generated
vendored
Normal file
38
node_modules/jest-haste-map/build/getMockName.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
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 MOCKS_PATTERN = _path().default.sep + '__mocks__' + _path().default.sep;
|
||||
|
||||
const getMockName = filePath => {
|
||||
const mockPath = filePath.split(MOCKS_PATTERN)[1];
|
||||
return mockPath
|
||||
.substring(0, mockPath.lastIndexOf(_path().default.extname(mockPath)))
|
||||
.replace(/\\/g, '/');
|
||||
};
|
||||
|
||||
var _default = getMockName;
|
||||
exports.default = _default;
|
||||
192
node_modules/jest-haste-map/build/index.d.ts
generated
vendored
Normal file
192
node_modules/jest-haste-map/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
/**
|
||||
* 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 { Config } from '@jest/types';
|
||||
import H from './constants';
|
||||
import HasteFS from './HasteFS';
|
||||
import HasteModuleMap, { SerializableModuleMap as HasteSerializableModuleMap } from './ModuleMap';
|
||||
import { ChangeEvent, HasteMap as InternalHasteMapObject, HasteRegExp, InternalHasteMap, Mapper } from './types';
|
||||
declare type HType = typeof H;
|
||||
declare type Options = {
|
||||
cacheDirectory?: string;
|
||||
computeDependencies?: boolean;
|
||||
computeSha1?: boolean;
|
||||
console?: Console;
|
||||
dependencyExtractor?: string;
|
||||
extensions: Array<string>;
|
||||
forceNodeFilesystemAPI?: boolean;
|
||||
hasteImplModulePath?: string;
|
||||
ignorePattern?: HasteRegExp;
|
||||
mapper?: Mapper;
|
||||
maxWorkers: number;
|
||||
mocksPattern?: string;
|
||||
name: string;
|
||||
platforms: Array<string>;
|
||||
providesModuleNodeModules?: Array<string>;
|
||||
resetCache?: boolean;
|
||||
retainAllFiles: boolean;
|
||||
rootDir: string;
|
||||
roots: Array<string>;
|
||||
skipPackageJson?: boolean;
|
||||
throwOnModuleCollision?: boolean;
|
||||
useWatchman?: boolean;
|
||||
watch?: boolean;
|
||||
};
|
||||
declare namespace HasteMap {
|
||||
type ModuleMap = HasteModuleMap;
|
||||
type SerializableModuleMap = HasteSerializableModuleMap;
|
||||
type FS = HasteFS;
|
||||
type HasteMapObject = InternalHasteMapObject;
|
||||
type HasteChangeEvent = ChangeEvent;
|
||||
}
|
||||
/**
|
||||
* HasteMap is a JavaScript implementation of Facebook's haste module system.
|
||||
*
|
||||
* This implementation is inspired by https://github.com/facebook/node-haste
|
||||
* and was built with for high-performance in large code repositories with
|
||||
* hundreds of thousands of files. This implementation is scalable and provides
|
||||
* predictable performance.
|
||||
*
|
||||
* Because the haste map creation and synchronization is critical to startup
|
||||
* performance and most tasks are blocked by I/O this class makes heavy use of
|
||||
* synchronous operations. It uses worker processes for parallelizing file
|
||||
* access and metadata extraction.
|
||||
*
|
||||
* The data structures created by `jest-haste-map` can be used directly from the
|
||||
* cache without further processing. The metadata objects in the `files` and
|
||||
* `map` objects contain cross-references: a metadata object from one can look
|
||||
* up the corresponding metadata object in the other map. Note that in most
|
||||
* projects, the number of files will be greater than the number of haste
|
||||
* modules one module can refer to many files based on platform extensions.
|
||||
*
|
||||
* type HasteMap = {
|
||||
* clocks: WatchmanClocks,
|
||||
* files: {[filepath: string]: FileMetaData},
|
||||
* map: {[id: string]: ModuleMapItem},
|
||||
* mocks: {[id: string]: string},
|
||||
* }
|
||||
*
|
||||
* // Watchman clocks are used for query synchronization and file system deltas.
|
||||
* type WatchmanClocks = {[filepath: string]: string};
|
||||
*
|
||||
* type FileMetaData = {
|
||||
* id: ?string, // used to look up module metadata objects in `map`.
|
||||
* mtime: number, // check for outdated files.
|
||||
* size: number, // size of the file in bytes.
|
||||
* visited: boolean, // whether the file has been parsed or not.
|
||||
* dependencies: Array<string>, // all relative dependencies of this file.
|
||||
* sha1: ?string, // SHA-1 of the file, if requested via options.
|
||||
* };
|
||||
*
|
||||
* // Modules can be targeted to a specific platform based on the file name.
|
||||
* // Example: platform.ios.js and Platform.android.js will both map to the same
|
||||
* // `Platform` module. The platform should be specified during resolution.
|
||||
* type ModuleMapItem = {[platform: string]: ModuleMetaData};
|
||||
*
|
||||
* //
|
||||
* type ModuleMetaData = {
|
||||
* path: string, // the path to look up the file object in `files`.
|
||||
* type: string, // the module type (either `package` or `module`).
|
||||
* };
|
||||
*
|
||||
* Note that the data structures described above are conceptual only. The actual
|
||||
* implementation uses arrays and constant keys for metadata storage. Instead of
|
||||
* `{id: 'flatMap', mtime: 3421, size: 42, visited: true, dependencies: []}` the real
|
||||
* representation is similar to `['flatMap', 3421, 42, 1, []]` to save storage space
|
||||
* and reduce parse and write time of a big JSON blob.
|
||||
*
|
||||
* The HasteMap is created as follows:
|
||||
* 1. read data from the cache or create an empty structure.
|
||||
*
|
||||
* 2. crawl the file system.
|
||||
* * empty cache: crawl the entire file system.
|
||||
* * cache available:
|
||||
* * if watchman is available: get file system delta changes.
|
||||
* * if watchman is unavailable: crawl the entire file system.
|
||||
* * build metadata objects for every file. This builds the `files` part of
|
||||
* the `HasteMap`.
|
||||
*
|
||||
* 3. parse and extract metadata from changed files.
|
||||
* * this is done in parallel over worker processes to improve performance.
|
||||
* * the worst case is to parse all files.
|
||||
* * the best case is no file system access and retrieving all data from
|
||||
* the cache.
|
||||
* * the average case is a small number of changed files.
|
||||
*
|
||||
* 4. serialize the new `HasteMap` in a cache file.
|
||||
* Worker processes can directly access the cache through `HasteMap.read()`.
|
||||
*
|
||||
*/
|
||||
declare class HasteMap extends EventEmitter {
|
||||
private _buildPromise;
|
||||
private _cachePath;
|
||||
private _changeInterval?;
|
||||
private _console;
|
||||
private _options;
|
||||
private _watchers;
|
||||
private _whitelist;
|
||||
private _worker;
|
||||
constructor(options: Options);
|
||||
static getCacheFilePath(tmpdir: Config.Path, name: string, ...extra: Array<string>): string;
|
||||
getCacheFilePath(): string;
|
||||
build(): Promise<InternalHasteMapObject>;
|
||||
/**
|
||||
* 1. read data from the cache or create an empty structure.
|
||||
*/
|
||||
read(): InternalHasteMap;
|
||||
readModuleMap(): HasteModuleMap;
|
||||
/**
|
||||
* 2. crawl the file system.
|
||||
*/
|
||||
private _buildFileMap;
|
||||
/**
|
||||
* 3. parse and extract metadata from changed files.
|
||||
*/
|
||||
private _processFile;
|
||||
private _buildHasteMap;
|
||||
private _cleanup;
|
||||
/**
|
||||
* 4. serialize the new `HasteMap` in a cache file.
|
||||
*/
|
||||
private _persist;
|
||||
/**
|
||||
* Creates workers or parses files and extracts metadata in-process.
|
||||
*/
|
||||
private _getWorker;
|
||||
private _crawl;
|
||||
/**
|
||||
* Watch mode
|
||||
*/
|
||||
private _watch;
|
||||
/**
|
||||
* This function should be called when the file under `filePath` is removed
|
||||
* or changed. When that happens, we want to figure out if that file was
|
||||
* part of a group of files that had the same ID. If it was, we want to
|
||||
* remove it from the group. Furthermore, if there is only one file
|
||||
* remaining in the group, then we want to restore that single file as the
|
||||
* correct resolution for its ID, and cleanup the duplicates index.
|
||||
*/
|
||||
private _recoverDuplicates;
|
||||
end(): Promise<void>;
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
private _ignore;
|
||||
private _isNodeModulesDir;
|
||||
private _createEmptyMap;
|
||||
static H: HType;
|
||||
static DuplicateError: typeof DuplicateError;
|
||||
static ModuleMap: typeof HasteModuleMap;
|
||||
}
|
||||
declare class DuplicateError extends Error {
|
||||
mockPath1: string;
|
||||
mockPath2: string;
|
||||
constructor(mockPath1: string, mockPath2: string);
|
||||
}
|
||||
export = HasteMap;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/index.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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;;AAIH,OAAO,YAAY,MAAM,QAAQ,CAAC;AAMlC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAMnC,OAAO,CAAC,MAAM,aAAa,CAAC;AAC5B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,cAAc,EAAE,EACrB,qBAAqB,IAAI,0BAA0B,EACpD,MAAM,aAAa,CAAC;AAQrB,OAAO,EACL,WAAW,EAGX,QAAQ,IAAI,sBAAsB,EAClC,WAAW,EACX,gBAAgB,EAChB,MAAM,EAOP,MAAM,SAAS,CAAC;AAEjB,aAAK,KAAK,GAAG,OAAO,CAAC,CAAC;AAEtB,aAAK,OAAO,GAAG;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,yBAAyB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAiCF,kBAAU,QAAQ,CAAC;IACjB,KAAY,SAAS,GAAG,cAAc,CAAC;IACvC,KAAY,qBAAqB,GAAG,0BAA0B,CAAC;IAC/D,KAAY,EAAE,GAAG,OAAO,CAAC;IACzB,KAAY,cAAc,GAAG,sBAAsB,CAAC;IACpD,KAAY,gBAAgB,GAAG,WAAW,CAAC;CAC5C;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAM,QAAS,SAAQ,YAAY;IACjC,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,eAAe,CAAC,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,OAAO,EAAE,OAAO;IAiF5B,MAAM,CAAC,gBAAgB,CACrB,MAAM,EAAE,MAAM,CAAC,IAAI,EACnB,IAAI,EAAE,MAAM,EACZ,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GACtB,MAAM;IAQT,gBAAgB,IAAI,MAAM;IAI1B,KAAK,IAAI,OAAO,CAAC,sBAAsB,CAAC;IA2CxC;;OAEG;IACH,IAAI,IAAI,gBAAgB;IAYxB,aAAa,IAAI,cAAc;IAU/B;;OAEG;YACW,aAAa;IAe3B;;OAEG;IACH,OAAO,CAAC,YAAY;IAsNpB,OAAO,CAAC,cAAc;IA2DtB,OAAO,CAAC,QAAQ;IAYhB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,MAAM;IA8Cd;;OAEG;IACH,OAAO,CAAC,MAAM;IA6Md;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAgD1B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBpB;;OAEG;IACH,OAAO,CAAC,OAAO;IAaf,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,eAAe;IAUvB,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,cAAc,EAAE,OAAO,cAAc,CAAC;IAC7C,MAAM,CAAC,SAAS,EAAE,OAAO,cAAc,CAAC;CACzC;AAED,cAAM,cAAe,SAAQ,KAAK;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;gBAEN,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAMjD;AAcD,SAAS,QAAQ,CAAC"}
|
||||
1390
node_modules/jest-haste-map/build/index.js
generated
vendored
Normal file
1390
node_modules/jest-haste-map/build/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
46
node_modules/jest-haste-map/build/lib/FSEventsWatcher.d.ts
generated
vendored
Normal file
46
node_modules/jest-haste-map/build/lib/FSEventsWatcher.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 { EventEmitter } from 'events';
|
||||
import anymatch from 'anymatch';
|
||||
import { Watcher } from 'fsevents';
|
||||
/**
|
||||
* Export `FSEventsWatcher` class.
|
||||
* Watches `dir`.
|
||||
*/
|
||||
declare class FSEventsWatcher extends EventEmitter {
|
||||
readonly root: string;
|
||||
readonly ignored?: anymatch.Matcher;
|
||||
readonly glob: Array<string>;
|
||||
readonly dot: boolean;
|
||||
readonly hasIgnore: boolean;
|
||||
readonly doIgnore: (path: string) => boolean;
|
||||
readonly watcher: Watcher;
|
||||
private _tracked;
|
||||
static isSupported(): boolean;
|
||||
private static normalizeProxy;
|
||||
private static recReaddir;
|
||||
constructor(dir: string, opts: {
|
||||
root: string;
|
||||
ignored?: anymatch.Matcher;
|
||||
glob: string | Array<string>;
|
||||
dot: boolean;
|
||||
});
|
||||
/**
|
||||
* End watching.
|
||||
*/
|
||||
close(callback?: () => void): void;
|
||||
private isFileIncluded;
|
||||
private handleEvent;
|
||||
/**
|
||||
* Emit events.
|
||||
*/
|
||||
private _emit;
|
||||
}
|
||||
export = FSEventsWatcher;
|
||||
//# sourceMappingURL=FSEventsWatcher.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/FSEventsWatcher.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/FSEventsWatcher.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"FSEventsWatcher.d.ts","sourceRoot":"","sources":["../../src/lib/FSEventsWatcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAIH,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAsBjC;;;GAGG;AACH,cAAM,eAAgB,SAAQ,YAAY;IACxC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC3C,SAAgB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,SAAgB,SAAS,EAAE,OAAO,CAAC;IACnC,SAAgB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,QAAQ,CAAc;IAE9B,MAAM,CAAC,WAAW;IAIlB,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,OAAO,CAAC,MAAM,CAAC,UAAU;gBAqBvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;QAC3B,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,GAAG,EAAE,OAAO,CAAC;KACd;IAqCH;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI;IAQ3B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,WAAW;IAgCnB;;OAEG;IACH,OAAO,CAAC,KAAK;CAId;AAED,SAAS,eAAe,CAAC"}
|
||||
248
node_modules/jest-haste-map/build/lib/FSEventsWatcher.js
generated
vendored
Normal file
248
node_modules/jest-haste-map/build/lib/FSEventsWatcher.js
generated
vendored
Normal file
@ -0,0 +1,248 @@
|
||||
'use strict';
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require('fs'));
|
||||
|
||||
_fs = function _fs() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _events() {
|
||||
const data = require('events');
|
||||
|
||||
_events = function _events() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _anymatch() {
|
||||
const data = _interopRequireDefault(require('anymatch'));
|
||||
|
||||
_anymatch = function _anymatch() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _micromatch() {
|
||||
const data = _interopRequireDefault(require('micromatch'));
|
||||
|
||||
_micromatch = function _micromatch() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _walker() {
|
||||
const data = _interopRequireDefault(require('walker'));
|
||||
|
||||
_walker = function _walker() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
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 fsevents;
|
||||
|
||||
try {
|
||||
fsevents = require('fsevents');
|
||||
} catch (e) {
|
||||
// Optional dependency, only supported on Darwin.
|
||||
}
|
||||
|
||||
const CHANGE_EVENT = 'change';
|
||||
const DELETE_EVENT = 'delete';
|
||||
const ADD_EVENT = 'add';
|
||||
const ALL_EVENT = 'all';
|
||||
|
||||
/**
|
||||
* Export `FSEventsWatcher` class.
|
||||
* Watches `dir`.
|
||||
*/
|
||||
class FSEventsWatcher extends _events().EventEmitter {
|
||||
static isSupported() {
|
||||
return fsevents !== undefined;
|
||||
}
|
||||
|
||||
static normalizeProxy(callback) {
|
||||
return (filepath, stats) =>
|
||||
callback(_path().default.normalize(filepath), stats);
|
||||
}
|
||||
|
||||
static recReaddir(
|
||||
dir,
|
||||
dirCallback,
|
||||
fileCallback,
|
||||
endCallback,
|
||||
errorCallback,
|
||||
ignored
|
||||
) {
|
||||
(0, _walker().default)(dir)
|
||||
.filterDir(
|
||||
currentDir => !ignored || !(0, _anymatch().default)(ignored, currentDir)
|
||||
)
|
||||
.on('dir', FSEventsWatcher.normalizeProxy(dirCallback))
|
||||
.on('file', FSEventsWatcher.normalizeProxy(fileCallback))
|
||||
.on('error', errorCallback)
|
||||
.on('end', () => {
|
||||
endCallback();
|
||||
});
|
||||
}
|
||||
|
||||
constructor(dir, opts) {
|
||||
if (!fsevents) {
|
||||
throw new Error(
|
||||
'`fsevents` unavailable (this watcher can only be used on Darwin)'
|
||||
);
|
||||
}
|
||||
|
||||
super();
|
||||
|
||||
_defineProperty(this, 'root', void 0);
|
||||
|
||||
_defineProperty(this, 'ignored', void 0);
|
||||
|
||||
_defineProperty(this, 'glob', void 0);
|
||||
|
||||
_defineProperty(this, 'dot', void 0);
|
||||
|
||||
_defineProperty(this, 'hasIgnore', void 0);
|
||||
|
||||
_defineProperty(this, 'doIgnore', void 0);
|
||||
|
||||
_defineProperty(this, 'watcher', void 0);
|
||||
|
||||
_defineProperty(this, '_tracked', void 0);
|
||||
|
||||
this.dot = opts.dot || false;
|
||||
this.ignored = opts.ignored;
|
||||
this.glob = Array.isArray(opts.glob) ? opts.glob : [opts.glob];
|
||||
this.hasIgnore =
|
||||
Boolean(opts.ignored) && !(Array.isArray(opts) && opts.length > 0);
|
||||
this.doIgnore = opts.ignored
|
||||
? (0, _anymatch().default)(opts.ignored)
|
||||
: () => false;
|
||||
this.root = _path().default.resolve(dir);
|
||||
this.watcher = fsevents(this.root);
|
||||
this.watcher.start().on('change', this.handleEvent.bind(this));
|
||||
this._tracked = new Set();
|
||||
FSEventsWatcher.recReaddir(
|
||||
this.root,
|
||||
filepath => {
|
||||
this._tracked.add(filepath);
|
||||
},
|
||||
filepath => {
|
||||
this._tracked.add(filepath);
|
||||
},
|
||||
this.emit.bind(this, 'ready'),
|
||||
this.emit.bind(this, 'error'),
|
||||
this.ignored
|
||||
);
|
||||
}
|
||||
/**
|
||||
* End watching.
|
||||
*/
|
||||
|
||||
close(callback) {
|
||||
this.watcher.stop();
|
||||
this.removeAllListeners();
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
process.nextTick(callback.bind(null, null, true));
|
||||
}
|
||||
}
|
||||
|
||||
isFileIncluded(relativePath) {
|
||||
if (this.doIgnore(relativePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.glob.length
|
||||
? _micromatch().default.some(relativePath, this.glob, {
|
||||
dot: this.dot
|
||||
})
|
||||
: this.dot || _micromatch().default.some(relativePath, '**/*');
|
||||
}
|
||||
|
||||
handleEvent(filepath) {
|
||||
const relativePath = _path().default.relative(this.root, filepath);
|
||||
|
||||
if (!this.isFileIncluded(relativePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_fs().default.lstat(filepath, (error, stat) => {
|
||||
if (error && error.code !== 'ENOENT') {
|
||||
this.emit('error', error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
// Ignore files that aren't tracked and don't exist.
|
||||
if (!this._tracked.has(filepath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._emit(DELETE_EVENT, relativePath);
|
||||
|
||||
this._tracked.delete(filepath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._tracked.has(filepath)) {
|
||||
this._emit(CHANGE_EVENT, relativePath, stat);
|
||||
} else {
|
||||
this._tracked.add(filepath);
|
||||
|
||||
this._emit(ADD_EVENT, relativePath, stat);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Emit events.
|
||||
*/
|
||||
|
||||
_emit(type, file, stat) {
|
||||
this.emit(type, file, this.root, stat);
|
||||
this.emit(ALL_EVENT, type, file, this.root, stat);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FSEventsWatcher;
|
||||
400
node_modules/jest-haste-map/build/lib/WatchmanWatcher.js
generated
vendored
Normal file
400
node_modules/jest-haste-map/build/lib/WatchmanWatcher.js
generated
vendored
Normal file
@ -0,0 +1,400 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = WatchmanWatcher;
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require('fs'));
|
||||
|
||||
_fs = function _fs() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _assert() {
|
||||
const data = _interopRequireDefault(require('assert'));
|
||||
|
||||
_assert = function _assert() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _events() {
|
||||
const data = require('events');
|
||||
|
||||
_events = function _events() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fbWatchman() {
|
||||
const data = _interopRequireDefault(require('fb-watchman'));
|
||||
|
||||
_fbWatchman = function _fbWatchman() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _common() {
|
||||
const data = _interopRequireDefault(require('sane/src/common'));
|
||||
|
||||
_common = function _common() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _recrawlWarningDedupe() {
|
||||
const data = _interopRequireDefault(
|
||||
require('sane/src/utils/recrawl-warning-dedupe')
|
||||
);
|
||||
|
||||
_recrawlWarningDedupe = function _recrawlWarningDedupe() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
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 CHANGE_EVENT = _common().default.CHANGE_EVENT;
|
||||
|
||||
const DELETE_EVENT = _common().default.DELETE_EVENT;
|
||||
|
||||
const ADD_EVENT = _common().default.ADD_EVENT;
|
||||
|
||||
const ALL_EVENT = _common().default.ALL_EVENT;
|
||||
|
||||
const SUB_NAME = 'sane-sub';
|
||||
/**
|
||||
* Watches `dir`.
|
||||
*
|
||||
* @class PollWatcher
|
||||
* @param String dir
|
||||
* @param {Object} opts
|
||||
* @public
|
||||
*/
|
||||
|
||||
function WatchmanWatcher(dir, opts) {
|
||||
_common().default.assignOptions(this, opts);
|
||||
|
||||
this.root = _path().default.resolve(dir);
|
||||
this.init();
|
||||
} // eslint-disable-next-line no-proto
|
||||
|
||||
WatchmanWatcher.prototype.__proto__ = _events().EventEmitter.prototype;
|
||||
/**
|
||||
* Run the watchman `watch` command on the root and subscribe to changes.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
WatchmanWatcher.prototype.init = function() {
|
||||
if (this.client) {
|
||||
this.client.removeAllListeners();
|
||||
}
|
||||
|
||||
const self = this;
|
||||
this.client = new (_fbWatchman()).default.Client();
|
||||
this.client.on('error', error => {
|
||||
self.emit('error', error);
|
||||
});
|
||||
this.client.on('subscription', this.handleChangeEvent.bind(this));
|
||||
this.client.on('end', () => {
|
||||
console.warn('[sane] Warning: Lost connection to watchman, reconnecting..');
|
||||
self.init();
|
||||
});
|
||||
this.watchProjectInfo = null;
|
||||
|
||||
function getWatchRoot() {
|
||||
return self.watchProjectInfo ? self.watchProjectInfo.root : self.root;
|
||||
}
|
||||
|
||||
function onCapability(error, resp) {
|
||||
if (handleError(self, error)) {
|
||||
// The Watchman watcher is unusable on this system, we cannot continue
|
||||
return;
|
||||
}
|
||||
|
||||
handleWarning(resp);
|
||||
self.capabilities = resp.capabilities;
|
||||
|
||||
if (self.capabilities.relative_root) {
|
||||
self.client.command(['watch-project', getWatchRoot()], onWatchProject);
|
||||
} else {
|
||||
self.client.command(['watch', getWatchRoot()], onWatch);
|
||||
}
|
||||
}
|
||||
|
||||
function onWatchProject(error, resp) {
|
||||
if (handleError(self, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleWarning(resp);
|
||||
self.watchProjectInfo = {
|
||||
relativePath: resp.relative_path ? resp.relative_path : '',
|
||||
root: resp.watch
|
||||
};
|
||||
self.client.command(['clock', getWatchRoot()], onClock);
|
||||
}
|
||||
|
||||
function onWatch(error, resp) {
|
||||
if (handleError(self, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleWarning(resp);
|
||||
self.client.command(['clock', getWatchRoot()], onClock);
|
||||
}
|
||||
|
||||
function onClock(error, resp) {
|
||||
if (handleError(self, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleWarning(resp);
|
||||
const options = {
|
||||
fields: ['name', 'exists', 'new'],
|
||||
since: resp.clock
|
||||
}; // If the server has the wildmatch capability available it supports
|
||||
// the recursive **/*.foo style match and we can offload our globs
|
||||
// to the watchman server. This saves both on data size to be
|
||||
// communicated back to us and compute for evaluating the globs
|
||||
// in our node process.
|
||||
|
||||
if (self.capabilities.wildmatch) {
|
||||
if (self.globs.length === 0) {
|
||||
if (!self.dot) {
|
||||
// Make sure we honor the dot option if even we're not using globs.
|
||||
options.expression = [
|
||||
'match',
|
||||
'**',
|
||||
'wholename',
|
||||
{
|
||||
includedotfiles: false
|
||||
}
|
||||
];
|
||||
}
|
||||
} else {
|
||||
options.expression = ['anyof'];
|
||||
|
||||
for (const i in self.globs) {
|
||||
options.expression.push([
|
||||
'match',
|
||||
self.globs[i],
|
||||
'wholename',
|
||||
{
|
||||
includedotfiles: self.dot
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self.capabilities.relative_root) {
|
||||
options.relative_root = self.watchProjectInfo.relativePath;
|
||||
}
|
||||
|
||||
self.client.command(
|
||||
['subscribe', getWatchRoot(), SUB_NAME, options],
|
||||
onSubscribe
|
||||
);
|
||||
}
|
||||
|
||||
function onSubscribe(error, resp) {
|
||||
if (handleError(self, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleWarning(resp);
|
||||
self.emit('ready');
|
||||
}
|
||||
|
||||
self.client.capabilityCheck(
|
||||
{
|
||||
optional: ['wildmatch', 'relative_root']
|
||||
},
|
||||
onCapability
|
||||
);
|
||||
};
|
||||
/**
|
||||
* Handles a change event coming from the subscription.
|
||||
*
|
||||
* @param {Object} resp
|
||||
* @private
|
||||
*/
|
||||
|
||||
WatchmanWatcher.prototype.handleChangeEvent = function(resp) {
|
||||
_assert().default.equal(
|
||||
resp.subscription,
|
||||
SUB_NAME,
|
||||
'Invalid subscription event.'
|
||||
);
|
||||
|
||||
if (resp.is_fresh_instance) {
|
||||
this.emit('fresh_instance');
|
||||
}
|
||||
|
||||
if (resp.is_fresh_instance) {
|
||||
this.emit('fresh_instance');
|
||||
}
|
||||
|
||||
if (Array.isArray(resp.files)) {
|
||||
resp.files.forEach(this.handleFileChange, this);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Handles a single change event record.
|
||||
*
|
||||
* @param {Object} changeDescriptor
|
||||
* @private
|
||||
*/
|
||||
|
||||
WatchmanWatcher.prototype.handleFileChange = function(changeDescriptor) {
|
||||
const self = this;
|
||||
let absPath;
|
||||
let relativePath;
|
||||
|
||||
if (this.capabilities.relative_root) {
|
||||
relativePath = changeDescriptor.name;
|
||||
absPath = _path().default.join(
|
||||
this.watchProjectInfo.root,
|
||||
this.watchProjectInfo.relativePath,
|
||||
relativePath
|
||||
);
|
||||
} else {
|
||||
absPath = _path().default.join(this.root, changeDescriptor.name);
|
||||
relativePath = changeDescriptor.name;
|
||||
}
|
||||
|
||||
if (
|
||||
!(self.capabilities.wildmatch && !this.hasIgnore) &&
|
||||
!_common().default.isFileIncluded(
|
||||
this.globs,
|
||||
this.dot,
|
||||
this.doIgnore,
|
||||
relativePath
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!changeDescriptor.exists) {
|
||||
self.emitEvent(DELETE_EVENT, relativePath, self.root);
|
||||
} else {
|
||||
_fs().default.lstat(absPath, (error, stat) => {
|
||||
// Files can be deleted between the event and the lstat call
|
||||
// the most reliable thing to do here is to ignore the event.
|
||||
if (error && error.code === 'ENOENT') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handleError(self, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventType = changeDescriptor.new ? ADD_EVENT : CHANGE_EVENT; // Change event on dirs are mostly useless.
|
||||
|
||||
if (!(eventType === CHANGE_EVENT && stat.isDirectory())) {
|
||||
self.emitEvent(eventType, relativePath, self.root, stat);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Dispatches the event.
|
||||
*
|
||||
* @param {string} eventType
|
||||
* @param {string} filepath
|
||||
* @param {string} root
|
||||
* @param {fs.Stat} stat
|
||||
* @private
|
||||
*/
|
||||
|
||||
WatchmanWatcher.prototype.emitEvent = function(
|
||||
eventType,
|
||||
filepath,
|
||||
root,
|
||||
stat
|
||||
) {
|
||||
this.emit(eventType, filepath, root, stat);
|
||||
this.emit(ALL_EVENT, eventType, filepath, root, stat);
|
||||
};
|
||||
/**
|
||||
* Closes the watcher.
|
||||
*
|
||||
* @param {function} callback
|
||||
* @private
|
||||
*/
|
||||
|
||||
WatchmanWatcher.prototype.close = function(callback) {
|
||||
this.client.removeAllListeners();
|
||||
this.client.end();
|
||||
callback && callback(null, true);
|
||||
};
|
||||
/**
|
||||
* Handles an error and returns true if exists.
|
||||
*
|
||||
* @param {WatchmanWatcher} self
|
||||
* @param {Error} error
|
||||
* @private
|
||||
*/
|
||||
|
||||
function handleError(self, error) {
|
||||
if (error != null) {
|
||||
self.emit('error', error);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handles a warning in the watchman resp object.
|
||||
*
|
||||
* @param {object} resp
|
||||
* @private
|
||||
*/
|
||||
|
||||
function handleWarning(resp) {
|
||||
if ('warning' in resp) {
|
||||
if (_recrawlWarningDedupe().default.isRecrawlWarningDupe(resp.warning)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
console.warn(resp.warning);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
8
node_modules/jest-haste-map/build/lib/dependencyExtractor.d.ts
generated
vendored
Normal file
8
node_modules/jest-haste-map/build/lib/dependencyExtractor.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 declare function extract(code: string): Set<string>;
|
||||
//# sourceMappingURL=dependencyExtractor.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/dependencyExtractor.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/dependencyExtractor.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"dependencyExtractor.d.ts","sourceRoot":"","sources":["../../src/lib/dependencyExtractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuEH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAgBjD"}
|
||||
100
node_modules/jest-haste-map/build/lib/dependencyExtractor.js
generated
vendored
Normal file
100
node_modules/jest-haste-map/build/lib/dependencyExtractor.js
generated
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.extract = extract;
|
||||
|
||||
var _isRegExpSupported = _interopRequireDefault(require('./isRegExpSupported'));
|
||||
|
||||
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.
|
||||
*/
|
||||
// Negative look behind is only supported in Node 9+
|
||||
const NOT_A_DOT = (0, _isRegExpSupported.default)('(?<!\\.\\s*)')
|
||||
? '(?<!\\.\\s*)'
|
||||
: '(?:^|[^.]\\s*)';
|
||||
|
||||
const CAPTURE_STRING_LITERAL = pos => `([\`'"])([^'"\`]*?)(?:\\${pos})`;
|
||||
|
||||
const WORD_SEPARATOR = '\\b';
|
||||
const LEFT_PARENTHESIS = '\\(';
|
||||
const RIGHT_PARENTHESIS = '\\)';
|
||||
const WHITESPACE = '\\s*';
|
||||
const OPTIONAL_COMMA = '(:?,\\s*)?';
|
||||
|
||||
function createRegExp(parts, flags) {
|
||||
return new RegExp(parts.join(''), flags);
|
||||
}
|
||||
|
||||
function alternatives(...parts) {
|
||||
return `(?:${parts.join('|')})`;
|
||||
}
|
||||
|
||||
function functionCallStart(...names) {
|
||||
return [
|
||||
NOT_A_DOT,
|
||||
WORD_SEPARATOR,
|
||||
alternatives(...names),
|
||||
WHITESPACE,
|
||||
LEFT_PARENTHESIS,
|
||||
WHITESPACE
|
||||
];
|
||||
}
|
||||
|
||||
const BLOCK_COMMENT_RE = /\/\*[^]*?\*\//g;
|
||||
const LINE_COMMENT_RE = /\/\/.*/g;
|
||||
const REQUIRE_OR_DYNAMIC_IMPORT_RE = createRegExp(
|
||||
[
|
||||
...functionCallStart('require', 'import'),
|
||||
CAPTURE_STRING_LITERAL(1),
|
||||
WHITESPACE,
|
||||
OPTIONAL_COMMA,
|
||||
RIGHT_PARENTHESIS
|
||||
],
|
||||
'g'
|
||||
);
|
||||
const IMPORT_OR_EXPORT_RE = createRegExp(
|
||||
[
|
||||
'\\b(?:import|export)\\s+(?!type(?:of)?\\s+)(?:[^\'"]+\\s+from\\s+)?',
|
||||
CAPTURE_STRING_LITERAL(1)
|
||||
],
|
||||
'g'
|
||||
);
|
||||
const JEST_EXTENSIONS_RE = createRegExp(
|
||||
[
|
||||
...functionCallStart(
|
||||
'require\\s*\\.\\s*(?:requireActual|requireMock)',
|
||||
'jest\\s*\\.\\s*(?:requireActual|requireMock|genMockFromModule)'
|
||||
),
|
||||
CAPTURE_STRING_LITERAL(1),
|
||||
WHITESPACE,
|
||||
OPTIONAL_COMMA,
|
||||
RIGHT_PARENTHESIS
|
||||
],
|
||||
'g'
|
||||
);
|
||||
|
||||
function extract(code) {
|
||||
const dependencies = new Set();
|
||||
|
||||
const addDependency = (match, _, dep) => {
|
||||
dependencies.add(dep);
|
||||
return match;
|
||||
};
|
||||
|
||||
code
|
||||
.replace(BLOCK_COMMENT_RE, '')
|
||||
.replace(LINE_COMMENT_RE, '')
|
||||
.replace(IMPORT_OR_EXPORT_RE, addDependency)
|
||||
.replace(REQUIRE_OR_DYNAMIC_IMPORT_RE, addDependency)
|
||||
.replace(JEST_EXTENSIONS_RE, addDependency);
|
||||
return dependencies;
|
||||
}
|
||||
9
node_modules/jest-haste-map/build/lib/fast_path.d.ts
generated
vendored
Normal file
9
node_modules/jest-haste-map/build/lib/fast_path.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 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 declare function relative(rootDir: string, filename: string): string;
|
||||
export declare function resolve(rootDir: string, relativeFilename: string): string;
|
||||
//# sourceMappingURL=fast_path.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/fast_path.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/fast_path.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"fast_path.d.ts","sourceRoot":"","sources":["../../src/lib/fast_path.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIlE;AAMD,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAIzE"}
|
||||
43
node_modules/jest-haste-map/build/lib/fast_path.js
generated
vendored
Normal file
43
node_modules/jest-haste-map/build/lib/fast_path.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.relative = relative;
|
||||
exports.resolve = resolve;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
// rootDir and filename must be absolute paths (resolved)
|
||||
function relative(rootDir, filename) {
|
||||
return filename.indexOf(rootDir + _path().default.sep) === 0
|
||||
? filename.substr(rootDir.length + 1)
|
||||
: _path().default.relative(rootDir, filename);
|
||||
}
|
||||
|
||||
const INDIRECTION_FRAGMENT = '..' + _path().default.sep; // rootDir must be an absolute path and relativeFilename must be simple
|
||||
// (e.g.: foo/bar or ../foo/bar, but never ./foo or foo/../bar)
|
||||
|
||||
function resolve(rootDir, relativeFilename) {
|
||||
return relativeFilename.indexOf(INDIRECTION_FRAGMENT) === 0
|
||||
? _path().default.resolve(rootDir, relativeFilename)
|
||||
: rootDir + _path().default.sep + relativeFilename;
|
||||
}
|
||||
8
node_modules/jest-haste-map/build/lib/getPlatformExtension.d.ts
generated
vendored
Normal file
8
node_modules/jest-haste-map/build/lib/getPlatformExtension.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 default function getPlatformExtension(file: string, platforms?: Array<string>): string | null;
|
||||
//# sourceMappingURL=getPlatformExtension.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/getPlatformExtension.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/getPlatformExtension.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"getPlatformExtension.d.ts","sourceRoot":"","sources":["../../src/lib/getPlatformExtension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GACxB,MAAM,GAAG,IAAI,CAaf"}
|
||||
31
node_modules/jest-haste-map/build/lib/getPlatformExtension.js
generated
vendored
Normal file
31
node_modules/jest-haste-map/build/lib/getPlatformExtension.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = getPlatformExtension;
|
||||
|
||||
/**
|
||||
* 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 SUPPORTED_PLATFORM_EXTS = new Set(['android', 'ios', 'native', 'web']); // Extract platform extension: index.ios.js -> ios
|
||||
|
||||
function getPlatformExtension(file, platforms) {
|
||||
const last = file.lastIndexOf('.');
|
||||
const secondToLast = file.lastIndexOf('.', last - 1);
|
||||
|
||||
if (secondToLast === -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const platform = file.substring(secondToLast + 1, last); // If an overriding platform array is passed, check that first
|
||||
|
||||
if (platforms && platforms.indexOf(platform) !== -1) {
|
||||
return platform;
|
||||
}
|
||||
|
||||
return SUPPORTED_PLATFORM_EXTS.has(platform) ? platform : null;
|
||||
}
|
||||
8
node_modules/jest-haste-map/build/lib/isRegExpSupported.d.ts
generated
vendored
Normal file
8
node_modules/jest-haste-map/build/lib/isRegExpSupported.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 default function isRegExpSupported(value: string): boolean;
|
||||
//# sourceMappingURL=isRegExpSupported.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/isRegExpSupported.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/isRegExpSupported.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"isRegExpSupported.d.ts","sourceRoot":"","sources":["../../src/lib/isRegExpSupported.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQhE"}
|
||||
22
node_modules/jest-haste-map/build/lib/isRegExpSupported.js
generated
vendored
Normal file
22
node_modules/jest-haste-map/build/lib/isRegExpSupported.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = isRegExpSupported;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function isRegExpSupported(value) {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new RegExp(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
9
node_modules/jest-haste-map/build/lib/normalizePathSep.d.ts
generated
vendored
Normal file
9
node_modules/jest-haste-map/build/lib/normalizePathSep.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
declare let normalizePathSep: (string: string) => string;
|
||||
export default normalizePathSep;
|
||||
//# sourceMappingURL=normalizePathSep.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/lib/normalizePathSep.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/lib/normalizePathSep.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"normalizePathSep.d.ts","sourceRoot":"","sources":["../../src/lib/normalizePathSep.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,QAAA,IAAI,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAOjD,eAAe,gBAAgB,CAAC"}
|
||||
37
node_modules/jest-haste-map/build/lib/normalizePathSep.js
generated
vendored
Normal file
37
node_modules/jest-haste-map/build/lib/normalizePathSep.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
let normalizePathSep;
|
||||
|
||||
if (_path().default.sep === '/') {
|
||||
normalizePathSep = filePath => filePath;
|
||||
} else {
|
||||
normalizePathSep = filePath => filePath.replace(/\//g, _path().default.sep);
|
||||
}
|
||||
|
||||
var _default = normalizePathSep;
|
||||
exports.default = _default;
|
||||
98
node_modules/jest-haste-map/build/types.d.ts
generated
vendored
Normal file
98
node_modules/jest-haste-map/build/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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 fs from 'fs';
|
||||
import { Config } from '@jest/types';
|
||||
import ModuleMap from './ModuleMap';
|
||||
import HasteFS from './HasteFS';
|
||||
export declare type IgnoreMatcher = (item: string) => boolean;
|
||||
export declare type Mapper = (item: string) => Array<string> | null;
|
||||
export declare type WorkerMessage = {
|
||||
computeDependencies: boolean;
|
||||
computeSha1: boolean;
|
||||
dependencyExtractor?: string;
|
||||
rootDir: string;
|
||||
filePath: string;
|
||||
hasteImplModulePath?: string;
|
||||
};
|
||||
export declare type WorkerMetadata = {
|
||||
dependencies: Array<string> | undefined | null;
|
||||
id: string | undefined | null;
|
||||
module: ModuleMetaData | undefined | null;
|
||||
sha1: string | undefined | null;
|
||||
};
|
||||
export declare type CrawlerOptions = {
|
||||
computeSha1: boolean;
|
||||
data: InternalHasteMap;
|
||||
extensions: Array<string>;
|
||||
forceNodeFilesystemAPI: boolean;
|
||||
ignore: IgnoreMatcher;
|
||||
mapper?: Mapper | null;
|
||||
rootDir: string;
|
||||
roots: Array<string>;
|
||||
};
|
||||
export declare type HasteImpl = {
|
||||
getHasteName(filePath: Config.Path): string | undefined;
|
||||
};
|
||||
export declare type FileData = Map<Config.Path, FileMetaData>;
|
||||
export declare type FileMetaData = [string, number, number, 0 | 1, string, string | null | undefined];
|
||||
export declare type MockData = Map<string, Config.Path>;
|
||||
export declare type ModuleMapData = Map<string, ModuleMapItem>;
|
||||
export declare type WatchmanClocks = Map<Config.Path, string>;
|
||||
export declare type HasteRegExp = RegExp | ((str: string) => boolean);
|
||||
export declare type DuplicatesSet = Map<string, /* type */ number>;
|
||||
export declare type DuplicatesIndex = Map<string, Map<string, DuplicatesSet>>;
|
||||
export declare type InternalHasteMap = {
|
||||
clocks: WatchmanClocks;
|
||||
duplicates: DuplicatesIndex;
|
||||
files: FileData;
|
||||
map: ModuleMapData;
|
||||
mocks: MockData;
|
||||
};
|
||||
export declare type HasteMap = {
|
||||
hasteFS: HasteFS;
|
||||
moduleMap: ModuleMap;
|
||||
__hasteMapForTest?: InternalHasteMap | null;
|
||||
};
|
||||
export declare type RawModuleMap = {
|
||||
rootDir: Config.Path;
|
||||
duplicates: DuplicatesIndex;
|
||||
map: ModuleMapData;
|
||||
mocks: MockData;
|
||||
};
|
||||
declare type ModuleMapItem = {
|
||||
[platform: string]: ModuleMetaData;
|
||||
};
|
||||
export declare type ModuleMetaData = [Config.Path, /* type */ number];
|
||||
export declare type HType = {
|
||||
ID: 0;
|
||||
MTIME: 1;
|
||||
SIZE: 2;
|
||||
VISITED: 3;
|
||||
DEPENDENCIES: 4;
|
||||
SHA1: 5;
|
||||
PATH: 0;
|
||||
TYPE: 1;
|
||||
MODULE: 0;
|
||||
PACKAGE: 1;
|
||||
GENERIC_PLATFORM: 'g';
|
||||
NATIVE_PLATFORM: 'native';
|
||||
DEPENDENCY_DELIM: '\0';
|
||||
};
|
||||
export declare type HTypeValue = HType[keyof HType];
|
||||
export declare type EventsQueue = Array<{
|
||||
filePath: Config.Path;
|
||||
stat: fs.Stats | undefined;
|
||||
type: string;
|
||||
}>;
|
||||
export declare type ChangeEvent = {
|
||||
eventsQueue: EventsQueue;
|
||||
hasteFS: HasteFS;
|
||||
moduleMap: ModuleMap;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/types.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,oBAAY,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AACtD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAE5D,oBAAY,aAAa,GAAG;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/C,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9B,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;CACzD,CAAC;AAEF,oBAAY,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AAEtD,oBAAY,YAAY,GAAG,CAChB,MAAM,EACH,MAAM,EACP,MAAM,EACH,CAAC,GAAG,CAAC,EACA,MAAM,EACd,MAAM,GAAG,IAAI,GAAG,SAAS,CACrC,CAAC;AAEF,oBAAY,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAChD,oBAAY,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACvD,oBAAY,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,oBAAY,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;AAE9D,oBAAY,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3D,oBAAY,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAEtE,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,aAAa,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC7C,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IACrB,UAAU,EAAE,eAAe,CAAC;IAC5B,GAAG,EAAE,aAAa,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEF,aAAK,aAAa,GAAG;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAA;CAAC,CAAC;AAC1D,oBAAY,cAAc,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;AAE9D,oBAAY,KAAK,GAAG;IAClB,EAAE,EAAE,CAAC,CAAC;IACN,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE,CAAC,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,CAAC,CAAC;IACV,OAAO,EAAE,CAAC,CAAC;IACX,gBAAgB,EAAE,GAAG,CAAC;IACtB,eAAe,EAAE,QAAQ,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC;CACxB,CAAC;AAEF,oBAAY,UAAU,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAE5C,oBAAY,WAAW,GAAG,KAAK,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC;IACtB,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,oBAAY,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC"}
|
||||
1
node_modules/jest-haste-map/build/types.js
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
||||
10
node_modules/jest-haste-map/build/worker.d.ts
generated
vendored
Normal file
10
node_modules/jest-haste-map/build/worker.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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 { WorkerMessage, WorkerMetadata } from './types';
|
||||
export declare function worker(data: WorkerMessage): Promise<WorkerMetadata>;
|
||||
export declare function getSha1(data: WorkerMessage): Promise<WorkerMetadata>;
|
||||
//# sourceMappingURL=worker.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/worker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/build/worker.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAY,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAiBjE,wBAAsB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAwEzE;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1E"}
|
||||
230
node_modules/jest-haste-map/build/worker.js
generated
vendored
Normal file
230
node_modules/jest-haste-map/build/worker.js
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.worker = worker;
|
||||
exports.getSha1 = getSha1;
|
||||
|
||||
function _crypto() {
|
||||
const data = _interopRequireDefault(require('crypto'));
|
||||
|
||||
_crypto = function _crypto() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gracefulFs() {
|
||||
const data = _interopRequireDefault(require('graceful-fs'));
|
||||
|
||||
_gracefulFs = function _gracefulFs() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _blacklist = _interopRequireDefault(require('./blacklist'));
|
||||
|
||||
var _constants = _interopRequireDefault(require('./constants'));
|
||||
|
||||
var dependencyExtractor = _interopRequireWildcard(
|
||||
require('./lib/dependencyExtractor')
|
||||
);
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const PACKAGE_JSON = _path().default.sep + 'package.json';
|
||||
let hasteImpl = null;
|
||||
let hasteImplModulePath = null;
|
||||
|
||||
function sha1hex(content) {
|
||||
return _crypto()
|
||||
.default.createHash('sha1')
|
||||
.update(content)
|
||||
.digest('hex');
|
||||
}
|
||||
|
||||
function worker(_x) {
|
||||
return _worker.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _worker() {
|
||||
_worker = _asyncToGenerator(function*(data) {
|
||||
if (
|
||||
data.hasteImplModulePath &&
|
||||
data.hasteImplModulePath !== hasteImplModulePath
|
||||
) {
|
||||
if (hasteImpl) {
|
||||
throw new Error('jest-haste-map: hasteImplModulePath changed');
|
||||
}
|
||||
|
||||
hasteImplModulePath = data.hasteImplModulePath;
|
||||
hasteImpl = require(hasteImplModulePath);
|
||||
}
|
||||
|
||||
let content;
|
||||
let dependencies;
|
||||
let id;
|
||||
let module;
|
||||
let sha1;
|
||||
const computeDependencies = data.computeDependencies,
|
||||
computeSha1 = data.computeSha1,
|
||||
rootDir = data.rootDir,
|
||||
filePath = data.filePath;
|
||||
|
||||
const getContent = () => {
|
||||
if (content === undefined) {
|
||||
content = _gracefulFs().default.readFileSync(filePath, 'utf8');
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
if (filePath.endsWith(PACKAGE_JSON)) {
|
||||
// Process a package.json that is returned as a PACKAGE type with its name.
|
||||
try {
|
||||
const fileData = JSON.parse(getContent());
|
||||
|
||||
if (fileData.name) {
|
||||
const relativeFilePath = _path().default.relative(rootDir, filePath);
|
||||
|
||||
id = fileData.name;
|
||||
module = [relativeFilePath, _constants.default.PACKAGE];
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
|
||||
}
|
||||
} else if (
|
||||
!_blacklist.default.has(filePath.substr(filePath.lastIndexOf('.')))
|
||||
) {
|
||||
// Process a random file that is returned as a MODULE.
|
||||
if (hasteImpl) {
|
||||
id = hasteImpl.getHasteName(filePath);
|
||||
}
|
||||
|
||||
if (computeDependencies) {
|
||||
const content = getContent();
|
||||
dependencies = Array.from(
|
||||
data.dependencyExtractor
|
||||
? require(data.dependencyExtractor).extract(
|
||||
content,
|
||||
filePath,
|
||||
dependencyExtractor.extract
|
||||
)
|
||||
: dependencyExtractor.extract(content)
|
||||
);
|
||||
}
|
||||
|
||||
if (id) {
|
||||
const relativeFilePath = _path().default.relative(rootDir, filePath);
|
||||
|
||||
module = [relativeFilePath, _constants.default.MODULE];
|
||||
}
|
||||
} // If a SHA-1 is requested on update, compute it.
|
||||
|
||||
if (computeSha1) {
|
||||
sha1 = sha1hex(
|
||||
getContent() || _gracefulFs().default.readFileSync(filePath)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
dependencies,
|
||||
id,
|
||||
module,
|
||||
sha1
|
||||
};
|
||||
});
|
||||
return _worker.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getSha1(_x2) {
|
||||
return _getSha.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getSha() {
|
||||
_getSha = _asyncToGenerator(function*(data) {
|
||||
const sha1 = data.computeSha1
|
||||
? sha1hex(_gracefulFs().default.readFileSync(data.filePath))
|
||||
: null;
|
||||
return {
|
||||
dependencies: undefined,
|
||||
id: undefined,
|
||||
module: undefined,
|
||||
sha1
|
||||
};
|
||||
});
|
||||
return _getSha.apply(this, arguments);
|
||||
}
|
||||
21
node_modules/jest-haste-map/node_modules/jest-worker/LICENSE
generated
vendored
Normal file
21
node_modules/jest-haste-map/node_modules/jest-worker/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
215
node_modules/jest-haste-map/node_modules/jest-worker/README.md
generated
vendored
Normal file
215
node_modules/jest-haste-map/node_modules/jest-worker/README.md
generated
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
# jest-worker
|
||||
|
||||
Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.
|
||||
|
||||
The module works by providing an absolute path of the module to be loaded in all forked processes. Files relative to a node module are also accepted. All methods are exposed on the parent process as promises, so they can be `await`'ed. Child (worker) methods can either be synchronous or asynchronous.
|
||||
|
||||
The module also implements support for bound workers. Binding a worker means that, based on certain parameters, the same task will always be executed by the same worker. The way bound workers work is by using the returned string of the `computeWorkerKey` method. If the string was used before for a task, the call will be queued to the related worker that processed the task earlier; if not, it will be executed by the first available worker, then sticked to the worker that executed it; so the next time it will be processed by the same worker. If you have no preference on the worker executing the task, but you have defined a `computeWorkerKey` method because you want _some_ of the tasks to be sticked, you can return `null` from it.
|
||||
|
||||
The list of exposed methods can be explicitly provided via the `exposedMethods` option. If it is not provided, it will be obtained by requiring the child module into the main process, and analyzed via reflection. Check the "minimal example" section for a valid one.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ yarn add jest-worker
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
This example covers the minimal usage:
|
||||
|
||||
### File `parent.js`
|
||||
|
||||
```javascript
|
||||
import Worker from 'jest-worker';
|
||||
|
||||
async function main() {
|
||||
const worker = new Worker(require.resolve('./Worker'));
|
||||
const result = await worker.hello('Alice'); // "Hello, Alice"
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### File `worker.js`
|
||||
|
||||
```javascript
|
||||
export function hello(param) {
|
||||
return 'Hello, ' + param;
|
||||
}
|
||||
```
|
||||
|
||||
## Experimental worker
|
||||
|
||||
Node 10 shipped with [worker-threads](https://nodejs.org/api/worker_threads.html), a "threading API" that uses SharedArrayBuffers to communicate between the main process and its child threads. This experimental Node feature can significantly improve the communication time between parent and child processes in `jest-worker`.
|
||||
|
||||
Since `worker_threads` are considered experimental in Node, you have to opt-in to this behavior by passing `enableWorkerThreads: true` when instantiating the worker. While the feature was unflagged in Node 11.7.0, you'll need to run the Node process with the `--experimental-worker` flag for Node 10.
|
||||
|
||||
## API
|
||||
|
||||
The only exposed method is a constructor (`Worker`) that is initialized by passing the worker path, plus an options object.
|
||||
|
||||
### `workerPath: string` (required)
|
||||
|
||||
Node module name or absolute path of the file to be loaded in the child processes. Use `require.resolve` to transform a relative path into an absolute one.
|
||||
|
||||
### `options: Object` (optional)
|
||||
|
||||
#### `exposedMethods: $ReadOnlyArray<string>` (optional)
|
||||
|
||||
List of method names that can be called on the child processes from the parent process. You cannot expose any method named like a public `Worker` method, or starting with `_`. If you use method auto-discovery, then these methods will not be exposed, even if they exist.
|
||||
|
||||
#### `numWorkers: number` (optional)
|
||||
|
||||
Amount of workers to spawn. Defaults to the number of CPUs minus 1.
|
||||
|
||||
#### `maxRetries: number` (optional)
|
||||
|
||||
Maximum amount of times that a dead child can be re-spawned, per call. Defaults to `3`, pass `Infinity` to allow endless retries.
|
||||
|
||||
#### `forkOptions: Object` (optional)
|
||||
|
||||
Allow customizing all options passed to `childProcess.fork`. By default, some values are set (`cwd`, `env` and `execArgv`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).
|
||||
|
||||
#### `computeWorkerKey: (method: string, ...args: Array<any>) => ?string` (optional)
|
||||
|
||||
Every time a method exposed via the API is called, `computeWorkerKey` is also called in order to bound the call to a worker. This is useful for workers that are able to cache the result or part of it. You bound calls to a worker by making `computeWorkerKey` return the same identifier for all different calls. If you do not want to bind the call to any worker, return `null`.
|
||||
|
||||
The callback you provide is called with the method name, plus all the rest of the arguments of the call. Thus, you have full control to decide what to return. Check a practical example on bound workers under the "bound worker usage" section.
|
||||
|
||||
By default, no process is bound to any worker.
|
||||
|
||||
#### `setupArgs: Array<mixed>` (optional)
|
||||
|
||||
The arguments that will be passed to the `setup` method during initialization.
|
||||
|
||||
#### `workerPool: (workerPath: string, options?: WorkerPoolOptions) => WorkerPoolInterface` (optional)
|
||||
|
||||
Provide a custom worker pool to be used for spawning child processes. By default, Jest will use a node thread pool if available and fall back to child process threads.
|
||||
|
||||
The arguments that will be passed to the `setup` method during initialization.
|
||||
|
||||
#### `enableWorkerThreads: boolean` (optional)
|
||||
|
||||
`jest-worker` will automatically detect if `worker_threads` are available, but will not use them unless passed `enableWorkerThreads: true`.
|
||||
|
||||
## Worker
|
||||
|
||||
The returned `Worker` instance has all the exposed methods, plus some additional ones to interact with the workers itself:
|
||||
|
||||
### `getStdout(): Readable`
|
||||
|
||||
Returns a `ReadableStream` where the standard output of all workers is piped. Note that the `silent` option of the child workers must be set to `true` to make it work. This is the default set by `jest-worker`, but keep it in mind when overriding options through `forkOptions`.
|
||||
|
||||
### `getStderr(): Readable`
|
||||
|
||||
Returns a `ReadableStream` where the standard error of all workers is piped. Note that the `silent` option of the child workers must be set to `true` to make it work. This is the default set by `jest-worker`, but keep it in mind when overriding options through `forkOptions`.
|
||||
|
||||
### `end()`
|
||||
|
||||
Finishes the workers by killing all workers. No further calls can be done to the `Worker` instance.
|
||||
|
||||
**Note:** Each worker has a unique id (index that starts with `1`) which is available on `process.env.JEST_WORKER_ID`
|
||||
|
||||
## Setting up and tearing down the child process
|
||||
|
||||
The child process can define two special methods (both of them can be asynchronous):
|
||||
|
||||
- `setup()`: If defined, it's executed before the first call to any method in the child.
|
||||
- `teardown()`: If defined, it's executed when the farm ends.
|
||||
|
||||
# More examples
|
||||
|
||||
## Standard usage
|
||||
|
||||
This example covers the standard usage:
|
||||
|
||||
### File `parent.js`
|
||||
|
||||
```javascript
|
||||
import Worker from 'jest-worker';
|
||||
|
||||
async function main() {
|
||||
const myWorker = new Worker(require.resolve('./Worker'), {
|
||||
exposedMethods: ['foo', 'bar', 'getWorkerId'],
|
||||
numWorkers: 4,
|
||||
});
|
||||
|
||||
console.log(await myWorker.foo('Alice')); // "Hello from foo: Alice"
|
||||
console.log(await myWorker.bar('Bob')); // "Hello from bar: Bob"
|
||||
console.log(await myWorker.getWorkerId()); // "3" -> this message has sent from the 3rd worker
|
||||
|
||||
myWorker.end();
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### File `worker.js`
|
||||
|
||||
```javascript
|
||||
export function foo(param) {
|
||||
return 'Hello from foo: ' + param;
|
||||
}
|
||||
|
||||
export function bar(param) {
|
||||
return 'Hello from bar: ' + param;
|
||||
}
|
||||
|
||||
export function getWorkerId() {
|
||||
return process.env.JEST_WORKER_ID;
|
||||
}
|
||||
```
|
||||
|
||||
## Bound worker usage:
|
||||
|
||||
This example covers the usage with a `computeWorkerKey` method:
|
||||
|
||||
### File `parent.js`
|
||||
|
||||
```javascript
|
||||
import Worker from 'jest-worker';
|
||||
|
||||
async function main() {
|
||||
const myWorker = new Worker(require.resolve('./Worker'), {
|
||||
computeWorkerKey: (method, filename) => filename,
|
||||
});
|
||||
|
||||
// Transform the given file, within the first available worker.
|
||||
console.log(await myWorker.transform('/tmp/foo.js'));
|
||||
|
||||
// Wait a bit.
|
||||
await sleep(10000);
|
||||
|
||||
// Transform the same file again. Will immediately return because the
|
||||
// transformed file is cached in the worker, and `computeWorkerKey` ensures
|
||||
// the same worker that processed the file the first time will process it now.
|
||||
console.log(await myWorker.transform('/tmp/foo.js'));
|
||||
|
||||
myWorker.end();
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### File `worker.js`
|
||||
|
||||
```javascript
|
||||
import babel from '@babel/core';
|
||||
|
||||
const cache = Object.create(null);
|
||||
|
||||
export function transform(filename) {
|
||||
if (cache[filename]) {
|
||||
return cache[filename];
|
||||
}
|
||||
|
||||
// jest-worker can handle both immediate results and thenables. If a
|
||||
// thenable is returned, it will be await'ed until it resolves.
|
||||
return babel.transformFileAsync(filename).then(result => {
|
||||
cache[filename] = result;
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
```
|
||||
27
node_modules/jest-haste-map/node_modules/jest-worker/build/Farm.d.ts
generated
vendored
Normal file
27
node_modules/jest-haste-map/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-haste-map/node_modules/jest-worker/build/Farm.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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,EAEL,WAAW,EAOZ,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-haste-map/node_modules/jest-worker/build/Farm.js
generated
vendored
Normal file
179
node_modules/jest-haste-map/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-haste-map/node_modules/jest-worker/build/WorkerPool.d.ts
generated
vendored
Normal file
14
node_modules/jest-haste-map/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, WorkerOptions, OnStart, OnEnd, WorkerPoolInterface, WorkerInterface } 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-haste-map/node_modules/jest-worker/build/WorkerPool.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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,aAAa,EACb,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,eAAe,EAChB,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-haste-map/node_modules/jest-worker/build/WorkerPool.js
generated
vendored
Normal file
49
node_modules/jest-haste-map/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-haste-map/node_modules/jest-worker/build/base/BaseWorkerPool.d.ts
generated
vendored
Normal file
22
node_modules/jest-haste-map/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 { WorkerPoolOptions, WorkerOptions, WorkerInterface } 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(): void;
|
||||
}
|
||||
//# sourceMappingURL=BaseWorkerPool.d.ts.map
|
||||
1
node_modules/jest-haste-map/node_modules/jest-worker/build/base/BaseWorkerPool.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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,iBAAiB,EACjB,aAAa,EACb,eAAe,EAChB,MAAM,UAAU,CAAC;AAKlB,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;IAI5D,GAAG,IAAI,IAAI;CAWZ"}
|
||||
134
node_modules/jest-haste-map/node_modules/jest-worker/build/base/BaseWorkerPool.js
generated
vendored
Normal file
134
node_modules/jest-haste-map/node_modules/jest-worker/build/base/BaseWorkerPool.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function _mergeStream() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _types = require('../types');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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().default.isAbsolute(workerPath)) {
|
||||
workerPath = require.resolve(workerPath);
|
||||
}
|
||||
|
||||
const stdout = (0, _mergeStream().default)();
|
||||
const stderr = (0, _mergeStream().default)();
|
||||
const forkOptions = options.forkOptions,
|
||||
maxRetries = options.maxRetries,
|
||||
setupArgs = options.setupArgs;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
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.
|
||||
for (let i = 0; i < this._workers.length; i++) {
|
||||
this._workers[i].send(
|
||||
[_types.CHILD_MESSAGE_END, false],
|
||||
emptyMethod,
|
||||
emptyMethod
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = BaseWorkerPool;
|
||||
46
node_modules/jest-haste-map/node_modules/jest-worker/build/index.d.ts
generated
vendored
Normal file
46
node_modules/jest-haste-map/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 } 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(): void;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/jest-haste-map/node_modules/jest-worker/build/index.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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,EAAyC,WAAW,EAAC,MAAM,SAAS,CAAC;AAyB5E;;;;;;;;;;;;;;;;;;;;;;;;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;IAIlC,GAAG,IAAI,IAAI;CASZ"}
|
||||
184
node_modules/jest-haste-map/node_modules/jest-worker/build/index.js
generated
vendored
Normal file
184
node_modules/jest-haste-map/node_modules/jest-worker/build/index.js
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _os() {
|
||||
const data = _interopRequireDefault(require('os'));
|
||||
|
||||
_os = function _os() {
|
||||
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 _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, 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(_os().default.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();
|
||||
}
|
||||
|
||||
end() {
|
||||
if (this._ending) {
|
||||
throw new Error('Farm is ended, no more calls can be done to it');
|
||||
}
|
||||
|
||||
this._workerPool.end();
|
||||
|
||||
this._ending = true;
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = JestWorker;
|
||||
98
node_modules/jest-haste-map/node_modules/jest-worker/build/types.d.ts
generated
vendored
Normal file
98
node_modules/jest-haste-map/node_modules/jest-worker/build/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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 { ForkOptions };
|
||||
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(): void;
|
||||
}
|
||||
export interface WorkerInterface {
|
||||
send(request: ChildMessage, onProcessStart: OnStart, onProcessEnd: OnEnd): void;
|
||||
getWorkerId(): number;
|
||||
getStderr(): NodeJS.ReadableStream | null;
|
||||
getStdout(): NodeJS.ReadableStream | null;
|
||||
onExit(exitCode: number): void;
|
||||
onMessage(message: ParentMessage): void;
|
||||
}
|
||||
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-haste-map/node_modules/jest-worker/build/types.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAM1C,eAAO,MAAM,wBAAwB,EAAE,CAAK,CAAC;AAC7C,eAAO,MAAM,kBAAkB,EAAE,CAAK,CAAC;AACvC,eAAO,MAAM,iBAAiB,EAAE,CAAK,CAAC;AAEtC,eAAO,MAAM,iBAAiB,EAAE,CAAK,CAAC;AACtC,eAAO,MAAM,2BAA2B,EAAE,CAAK,CAAC;AAChD,eAAO,MAAM,0BAA0B,EAAE,CAAK,CAAC;AAE/C,oBAAY,oBAAoB,GAC5B,OAAO,2BAA2B,GAClC,OAAO,0BAA0B,CAAC;AAItC,OAAO,EAAC,WAAW,EAAC,CAAC;AAErB,MAAM,WAAW,mBAAmB;IAClC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC;IACnC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC;IACnC,UAAU,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,eAAe,CAAC;IACtD,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GACX,IAAI,CAAC;IACR,GAAG,IAAI,IAAI,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CACF,OAAO,EAAE,YAAY,EACrB,cAAc,EAAE,OAAO,EACvB,YAAY,EAAE,KAAK,GAClB,IAAI,CAAC;IACR,WAAW,IAAI,MAAM,CAAC;IACtB,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAC1C,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAC1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;CACzC;AAED,oBAAY,WAAW,GAAG;IACxB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9E,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CACX,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,KACxB,mBAAmB,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,oBAAY,WAAW,GAAG,OAAO,YAAY,GAAG;IAC9C,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,oBAAY,sBAAsB,GAAG,CACnC,OAAO,wBAAwB,EAAE,OAAO;AACxC,OAAO,EAAE,YAAY;AACrB,MAAM,EAAE,OAAO;AACf,AADQ,OAAO;AACf,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,YAAY;AACxC,AAD4B,YAAY;AACxC,WAAW,GAAG,SAAS,CACxB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,CAC7B,OAAO,kBAAkB,EAAE,OAAO;AAClC,OAAO,EAAE,YAAY;AACrB,MAAM,EAAE,SAAS;AACjB,KAAK,CAAC,OAAO,CAAC,CACf,CAAC;AAEF,oBAAY,eAAe,GAAG,CAC5B,OAAO,iBAAiB,EAAE,OAAO;AACjC,OAAO,CACR,CAAC;AAEF,oBAAY,YAAY,GACpB,sBAAsB,GACtB,gBAAgB,GAChB,eAAe,CAAC;AAIpB,oBAAY,eAAe,GAAG,CAC5B,OAAO,iBAAiB,EAAE,OAAO;AACjC,OAAO,CACR,CAAC;AAEF,oBAAY,kBAAkB,GAAG,CAC/B,oBAAoB,EAAE,OAAO;AAC7B,MAAM,EAAE,cAAc;AACtB,MAAM,EAAE,UAAU;AAClB,MAAM,EAAE,QAAQ;AAChB,OAAO,CACR,CAAC;AAEF,oBAAY,aAAa,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAIjE,oBAAY,OAAO,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;AACxD,oBAAY,KAAK,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,oBAAY,iBAAiB,GAAG;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;CACxB,CAAC"}
|
||||
43
node_modules/jest-haste-map/node_modules/jest-worker/build/types.js
generated
vendored
Normal file
43
node_modules/jest-haste-map/node_modules/jest-worker/build/types.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'ForkOptions', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
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 _child_process() {
|
||||
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
|
||||
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;
|
||||
47
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts
generated
vendored
Normal file
47
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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 { WorkerInterface, ChildMessage, OnEnd, OnStart, WorkerOptions, ParentMessage } 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 _onProcessEnd;
|
||||
private _fakeStream;
|
||||
private _request;
|
||||
private _retries;
|
||||
private _stderr;
|
||||
private _stdout;
|
||||
constructor(options: WorkerOptions);
|
||||
initialize(): void;
|
||||
private _shutdown;
|
||||
onMessage(response: ParentMessage): void;
|
||||
onExit(exitCode: number): void;
|
||||
send(request: ChildMessage, onProcessStart: OnStart, onProcessEnd: OnEnd): void;
|
||||
getWorkerId(): number;
|
||||
getStdout(): NodeJS.ReadableStream | null;
|
||||
getStderr(): NodeJS.ReadableStream | null;
|
||||
private _getFakeStream;
|
||||
}
|
||||
//# sourceMappingURL=ChildProcessWorker.d.ts.map
|
||||
1
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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,EAKL,eAAe,EACf,YAAY,EACZ,KAAK,EACL,OAAO,EACP,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,eAAe;IAChE,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,OAAO,CAAwC;gBAE3C,OAAO,EAAE,aAAa;IAUlC,UAAU;IAiEV,OAAO,CAAC,SAAS;IAQjB,SAAS,CAAC,QAAQ,EAAE,aAAa;IA6CjC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAYvB,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;IAcxE,WAAW;IAIX,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,OAAO,CAAC,cAAc;CAMvB"}
|
||||
310
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/ChildProcessWorker.js
generated
vendored
Normal file
310
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/ChildProcessWorker.js
generated
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _child_process() {
|
||||
const data = _interopRequireDefault(require('child_process'));
|
||||
|
||||
_child_process = function _child_process() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _stream() {
|
||||
const data = require('stream');
|
||||
|
||||
_stream = function _stream() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function _mergeStream() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _supportsColor() {
|
||||
const data = _interopRequireDefault(require('supports-color'));
|
||||
|
||||
_supportsColor = function _supportsColor() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _types = require('../types');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, '_onProcessEnd', void 0);
|
||||
|
||||
_defineProperty(this, '_fakeStream', void 0);
|
||||
|
||||
_defineProperty(this, '_request', void 0);
|
||||
|
||||
_defineProperty(this, '_retries', void 0);
|
||||
|
||||
_defineProperty(this, '_stderr', void 0);
|
||||
|
||||
_defineProperty(this, '_stdout', void 0);
|
||||
|
||||
this._options = options;
|
||||
this._fakeStream = null;
|
||||
this._request = null;
|
||||
this._stderr = null;
|
||||
this._stdout = null;
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
const forceColor = _supportsColor().default.stdout
|
||||
? {
|
||||
FORCE_COLOR: '1'
|
||||
}
|
||||
: {};
|
||||
|
||||
const child = _child_process().default.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;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
29
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts
generated
vendored
Normal file
29
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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, WorkerOptions, WorkerInterface, ParentMessage } from '../types';
|
||||
export default class ExperimentalWorker implements WorkerInterface {
|
||||
private _worker;
|
||||
private _options;
|
||||
private _onProcessEnd;
|
||||
private _request;
|
||||
private _retries;
|
||||
private _stderr;
|
||||
private _stdout;
|
||||
private _fakeStream;
|
||||
constructor(options: WorkerOptions);
|
||||
initialize(): void;
|
||||
private _shutdown;
|
||||
onMessage(response: ParentMessage): void;
|
||||
onExit(exitCode: number): 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-haste-map/node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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;;AASH,OAAO,EAKL,YAAY,EACZ,KAAK,EACL,OAAO,EACP,aAAa,EACb,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;IAChC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,WAAW,CAAqB;gBAE5B,OAAO,EAAE,aAAa;IAUlC,UAAU;IAkEV,OAAO,CAAC,SAAS;IAQjB,SAAS,CAAC,QAAQ,EAAE,aAAa;IA2CjC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAYvB,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"}
|
||||
289
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/NodeThreadsWorker.js
generated
vendored
Normal file
289
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/NodeThreadsWorker.js
generated
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _stream() {
|
||||
const data = require('stream');
|
||||
|
||||
_stream = function _stream() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _worker_threads() {
|
||||
const data = require('worker_threads');
|
||||
|
||||
_worker_threads = function _worker_threads() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function _mergeStream() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _types = require('../types');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, 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, '_onProcessEnd', void 0);
|
||||
|
||||
_defineProperty(this, '_request', void 0);
|
||||
|
||||
_defineProperty(this, '_retries', void 0);
|
||||
|
||||
_defineProperty(this, '_stderr', void 0);
|
||||
|
||||
_defineProperty(this, '_stdout', void 0);
|
||||
|
||||
_defineProperty(this, '_fakeStream', void 0);
|
||||
|
||||
this._options = options;
|
||||
this._request = null;
|
||||
this._stderr = null;
|
||||
this._stdout = null;
|
||||
this._fakeStream = null;
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this._worker = new (_worker_threads()).Worker(
|
||||
_path().default.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;
|
||||
}
|
||||
}
|
||||
|
||||
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.initialize();
|
||||
|
||||
if (this._request) {
|
||||
this._worker.postMessage(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._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-haste-map/node_modules/jest-worker/build/workers/processChild.d.ts
generated
vendored
Normal file
8
node_modules/jest-haste-map/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-haste-map/node_modules/jest-worker/build/workers/processChild.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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"}
|
||||
166
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/processChild.js
generated
vendored
Normal file
166
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/processChild.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
'use strict';
|
||||
|
||||
var _types = require('../types');
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, 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.
|
||||
*/
|
||||
|
||||
process.on('message', 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]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
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() {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
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-haste-map/node_modules/jest-worker/build/workers/threadChild.d.ts
generated
vendored
Normal file
8
node_modules/jest-haste-map/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-haste-map/node_modules/jest-worker/build/workers/threadChild.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-haste-map/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"}
|
||||
176
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/threadChild.js
generated
vendored
Normal file
176
node_modules/jest-haste-map/node_modules/jest-worker/build/workers/threadChild.js
generated
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
function _worker_threads() {
|
||||
const data = require('worker_threads');
|
||||
|
||||
_worker_threads = function _worker_threads() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _types = require('../types');
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, 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.
|
||||
*/
|
||||
|
||||
_worker_threads().parentPort.on('message', 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]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
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() {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
59
node_modules/jest-haste-map/node_modules/jest-worker/package.json
generated
vendored
Normal file
59
node_modules/jest-haste-map/node_modules/jest-worker/package.json
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"_from": "jest-worker@^24.9.0",
|
||||
"_id": "jest-worker@24.9.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==",
|
||||
"_location": "/jest-haste-map/jest-worker",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "jest-worker@^24.9.0",
|
||||
"name": "jest-worker",
|
||||
"escapedName": "jest-worker",
|
||||
"rawSpec": "^24.9.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^24.9.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jest-haste-map"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz",
|
||||
"_shasum": "5dbfdb5b2d322e98567898238a9697bcce67b3e5",
|
||||
"_spec": "jest-worker@^24.9.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/jest-haste-map",
|
||||
"bugs": {
|
||||
"url": "https://github.com/facebook/jest/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"merge-stream": "^2.0.0",
|
||||
"supports-color": "^6.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.",
|
||||
"devDependencies": {
|
||||
"@types/merge-stream": "^1.1.2",
|
||||
"@types/supports-color": "^5.3.0",
|
||||
"get-stream": "^4.1.0",
|
||||
"worker-farm": "^1.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"gitHead": "9ad0f4bc6b8bdd94989804226c28c9960d9da7d1",
|
||||
"homepage": "https://github.com/facebook/jest#readme",
|
||||
"license": "MIT",
|
||||
"main": "build/index.js",
|
||||
"name": "jest-worker",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/facebook/jest.git",
|
||||
"directory": "packages/jest-worker"
|
||||
},
|
||||
"types": "build/index.d.ts",
|
||||
"version": "24.9.0"
|
||||
}
|
||||
21
node_modules/jest-haste-map/node_modules/merge-stream/LICENSE
generated
vendored
Normal file
21
node_modules/jest-haste-map/node_modules/merge-stream/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Stephen Sugden <me@stephensugden.com> (stephensugden.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
78
node_modules/jest-haste-map/node_modules/merge-stream/README.md
generated
vendored
Normal file
78
node_modules/jest-haste-map/node_modules/merge-stream/README.md
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
# merge-stream
|
||||
|
||||
Merge (interleave) a bunch of streams.
|
||||
|
||||
[](http://travis-ci.org/grncdr/merge-stream)
|
||||
|
||||
## Synopsis
|
||||
|
||||
```javascript
|
||||
var stream1 = new Stream();
|
||||
var stream2 = new Stream();
|
||||
|
||||
var merged = mergeStream(stream1, stream2);
|
||||
|
||||
var stream3 = new Stream();
|
||||
merged.add(stream3);
|
||||
merged.isEmpty();
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
This is adapted from [event-stream](https://github.com/dominictarr/event-stream) separated into a new module, using Streams3.
|
||||
|
||||
## API
|
||||
|
||||
### `mergeStream`
|
||||
|
||||
Type: `function`
|
||||
|
||||
Merges an arbitrary number of streams. Returns a merged stream.
|
||||
|
||||
#### `merged.add`
|
||||
|
||||
A method to dynamically add more sources to the stream. The argument supplied to `add` can be either a source or an array of sources.
|
||||
|
||||
#### `merged.isEmpty`
|
||||
|
||||
A method that tells you if the merged stream is empty.
|
||||
|
||||
When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task.
|
||||
|
||||
So, we could do something like this:
|
||||
|
||||
```js
|
||||
stream = require('merge-stream')();
|
||||
// Something like a loop to add some streams to the merge stream
|
||||
// stream.add(streamA);
|
||||
// stream.add(streamB);
|
||||
return stream.isEmpty() ? null : stream;
|
||||
```
|
||||
|
||||
## Gulp example
|
||||
|
||||
An example use case for **merge-stream** is to combine parts of a task in a project's **gulpfile.js** like this:
|
||||
|
||||
```js
|
||||
const gulp = require('gulp');
|
||||
const htmlValidator = require('gulp-w3c-html-validator');
|
||||
const jsHint = require('gulp-jshint');
|
||||
const mergeStream = require('merge-stream');
|
||||
|
||||
function lint() {
|
||||
return mergeStream(
|
||||
gulp.src('src/*.html')
|
||||
.pipe(htmlValidator())
|
||||
.pipe(htmlValidator.reporter()),
|
||||
gulp.src('src/*.js')
|
||||
.pipe(jsHint())
|
||||
.pipe(jsHint.reporter())
|
||||
);
|
||||
}
|
||||
gulp.task('lint', lint);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
41
node_modules/jest-haste-map/node_modules/merge-stream/index.js
generated
vendored
Normal file
41
node_modules/jest-haste-map/node_modules/merge-stream/index.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const { PassThrough } = require('stream');
|
||||
|
||||
module.exports = function (/*streams...*/) {
|
||||
var sources = []
|
||||
var output = new PassThrough({objectMode: true})
|
||||
|
||||
output.setMaxListeners(0)
|
||||
|
||||
output.add = add
|
||||
output.isEmpty = isEmpty
|
||||
|
||||
output.on('unpipe', remove)
|
||||
|
||||
Array.prototype.slice.call(arguments).forEach(add)
|
||||
|
||||
return output
|
||||
|
||||
function add (source) {
|
||||
if (Array.isArray(source)) {
|
||||
source.forEach(add)
|
||||
return this
|
||||
}
|
||||
|
||||
sources.push(source);
|
||||
source.once('end', remove.bind(null, source))
|
||||
source.once('error', output.emit.bind(output, 'error'))
|
||||
source.pipe(output, {end: false})
|
||||
return this
|
||||
}
|
||||
|
||||
function isEmpty () {
|
||||
return sources.length == 0;
|
||||
}
|
||||
|
||||
function remove (source) {
|
||||
sources = sources.filter(function (it) { return it !== source })
|
||||
if (!sources.length && output.readable) { output.end() }
|
||||
}
|
||||
}
|
||||
54
node_modules/jest-haste-map/node_modules/merge-stream/package.json
generated
vendored
Normal file
54
node_modules/jest-haste-map/node_modules/merge-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"_from": "merge-stream@^2.0.0",
|
||||
"_id": "merge-stream@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
|
||||
"_location": "/jest-haste-map/merge-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "merge-stream@^2.0.0",
|
||||
"name": "merge-stream",
|
||||
"escapedName": "merge-stream",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jest-haste-map/jest-worker"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||
"_shasum": "52823629a14dd00c9770fb6ad47dc6310f2c1f60",
|
||||
"_spec": "merge-stream@^2.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/jest-haste-map/node_modules/jest-worker",
|
||||
"author": {
|
||||
"name": "Stephen Sugden",
|
||||
"email": "me@stephensugden.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/grncdr/merge-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Create a stream that emits events from multiple other streams",
|
||||
"devDependencies": {
|
||||
"from2": "^2.0.3",
|
||||
"istanbul": "^0.4.5"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/grncdr/merge-stream#readme",
|
||||
"license": "MIT",
|
||||
"name": "merge-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/grncdr/merge-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "istanbul cover test.js && istanbul check-cover --statements 100 --branches 100"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
5
node_modules/jest-haste-map/node_modules/supports-color/browser.js
generated
vendored
Normal file
5
node_modules/jest-haste-map/node_modules/supports-color/browser.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
stdout: false,
|
||||
stderr: false
|
||||
};
|
||||
138
node_modules/jest-haste-map/node_modules/supports-color/index.js
generated
vendored
Normal file
138
node_modules/jest-haste-map/node_modules/supports-color/index.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let forceColor;
|
||||
if (hasFlag('no-color') ||
|
||||
hasFlag('no-colors') ||
|
||||
hasFlag('color=false') ||
|
||||
hasFlag('color=never')) {
|
||||
forceColor = 0;
|
||||
} else if (hasFlag('color') ||
|
||||
hasFlag('colors') ||
|
||||
hasFlag('color=true') ||
|
||||
hasFlag('color=always')) {
|
||||
forceColor = 1;
|
||||
}
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') {
|
||||
forceColor = 1;
|
||||
} else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') {
|
||||
forceColor = 0;
|
||||
} else {
|
||||
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(stream) {
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') ||
|
||||
hasFlag('color=full') ||
|
||||
hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (stream && !stream.isTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
||||
// libuv that enables 256 color output on Windows. Anything earlier and it
|
||||
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
||||
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
|
||||
// release that supports 256 colors. Windows 10 build 14931 is the first release
|
||||
// that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(process.versions.node.split('.')[0]) >= 8 &&
|
||||
Number(osRelease[0]) >= 10 &&
|
||||
Number(osRelease[2]) >= 10586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
const level = supportsColor(stream);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: getSupportLevel(process.stdout),
|
||||
stderr: getSupportLevel(process.stderr)
|
||||
};
|
||||
9
node_modules/jest-haste-map/node_modules/supports-color/license
generated
vendored
Normal file
9
node_modules/jest-haste-map/node_modules/supports-color/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
85
node_modules/jest-haste-map/node_modules/supports-color/package.json
generated
vendored
Normal file
85
node_modules/jest-haste-map/node_modules/supports-color/package.json
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
"_from": "supports-color@^6.1.0",
|
||||
"_id": "supports-color@6.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==",
|
||||
"_location": "/jest-haste-map/supports-color",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "supports-color@^6.1.0",
|
||||
"name": "supports-color",
|
||||
"escapedName": "supports-color",
|
||||
"rawSpec": "^6.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^6.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jest-haste-map/jest-worker"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz",
|
||||
"_shasum": "0764abc69c63d5ac842dd4867e8d025e880df8f3",
|
||||
"_spec": "supports-color@^6.1.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/jest-haste-map/node_modules/jest-worker",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"browser": "browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/supports-color/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"has-flag": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Detect whether a terminal supports color",
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"import-fresh": "^2.0.0",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"browser.js"
|
||||
],
|
||||
"homepage": "https://github.com/chalk/supports-color#readme",
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"ansi",
|
||||
"styles",
|
||||
"tty",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"support",
|
||||
"supports",
|
||||
"capability",
|
||||
"detect",
|
||||
"truecolor",
|
||||
"16m"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "supports-color",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/supports-color.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "6.1.0"
|
||||
}
|
||||
85
node_modules/jest-haste-map/node_modules/supports-color/readme.md
generated
vendored
Normal file
85
node_modules/jest-haste-map/node_modules/supports-color/readme.md
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
||||
|
||||
> Detect whether a terminal supports color
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install supports-color
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor.stdout) {
|
||||
console.log('Terminal stdout supports color');
|
||||
}
|
||||
|
||||
if (supportsColor.stdout.has256) {
|
||||
console.log('Terminal stdout supports 256 colors');
|
||||
}
|
||||
|
||||
if (supportsColor.stderr.has16m) {
|
||||
console.log('Terminal stderr supports 16 million colors (truecolor)');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
|
||||
|
||||
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
|
||||
|
||||
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
|
||||
- `.level = 2` and `.has256 = true`: 256 color support
|
||||
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
|
||||
|
||||
|
||||
## Info
|
||||
|
||||
It obeys the `--color` and `--no-color` CLI flags.
|
||||
|
||||
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
81
node_modules/jest-haste-map/package.json
generated
vendored
Normal file
81
node_modules/jest-haste-map/package.json
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
"_from": "jest-haste-map@^24.9.0",
|
||||
"_id": "jest-haste-map@24.9.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-kfVFmsuWui2Sj1Rp1AJ4D9HqJwE4uwTlS/vO+eRUaMmd54BFpli2XhMQnPC2k4cHFVbB2Q2C+jtI1AGLgEnCjQ==",
|
||||
"_location": "/jest-haste-map",
|
||||
"_phantomChildren": {
|
||||
"has-flag": "3.0.0"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "jest-haste-map@^24.9.0",
|
||||
"name": "jest-haste-map",
|
||||
"escapedName": "jest-haste-map",
|
||||
"rawSpec": "^24.9.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^24.9.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@jest/core",
|
||||
"/@jest/reporters",
|
||||
"/@jest/test-sequencer",
|
||||
"/@jest/transform",
|
||||
"/jest-runner",
|
||||
"/jest-runtime"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.9.0.tgz",
|
||||
"_shasum": "b38a5d64274934e21fa417ae9a9fbeb77ceaac7d",
|
||||
"_spec": "jest-haste-map@^24.9.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/@jest/core",
|
||||
"bugs": {
|
||||
"url": "https://github.com/facebook/jest/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@jest/types": "^24.9.0",
|
||||
"anymatch": "^2.0.0",
|
||||
"fb-watchman": "^2.0.0",
|
||||
"fsevents": "^1.2.7",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"invariant": "^2.2.4",
|
||||
"jest-serializer": "^24.9.0",
|
||||
"jest-util": "^24.9.0",
|
||||
"jest-worker": "^24.9.0",
|
||||
"micromatch": "^3.1.10",
|
||||
"sane": "^4.0.3",
|
||||
"walker": "^1.0.7"
|
||||
},
|
||||
"deprecated": false,
|
||||
"devDependencies": {
|
||||
"@types/anymatch": "^1.3.1",
|
||||
"@types/fb-watchman": "^2.0.0",
|
||||
"@types/fsevents": "^1.1.0",
|
||||
"@types/graceful-fs": "^4.1.2",
|
||||
"@types/invariant": "^2.2.29",
|
||||
"@types/micromatch": "^3.1.0",
|
||||
"@types/sane": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"gitHead": "9ad0f4bc6b8bdd94989804226c28c9960d9da7d1",
|
||||
"homepage": "https://github.com/facebook/jest#readme",
|
||||
"license": "MIT",
|
||||
"main": "build/index.js",
|
||||
"name": "jest-haste-map",
|
||||
"optionalDependencies": {
|
||||
"fsevents": "^1.2.7"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/facebook/jest.git",
|
||||
"directory": "packages/jest-haste-map"
|
||||
},
|
||||
"types": "build/index.d.ts",
|
||||
"version": "24.9.0"
|
||||
}
|
||||
Reference in New Issue
Block a user