Update node_modules

This commit is contained in:
crazy-max
2020-01-23 08:49:02 +00:00
parent 80426e98c8
commit c8a47ad4bb
9923 changed files with 950627 additions and 38 deletions

View 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.
*/
export default class ModuleNotFoundError extends Error {
code: string;
}
//# sourceMappingURL=ModuleNotFoundError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ModuleNotFoundError.d.ts","sourceRoot":"","sources":["../src/ModuleNotFoundError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,KAAK;IACpD,IAAI,SAAsB;CAC3B"}

36
node_modules/jest-resolve/build/ModuleNotFoundError.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
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;
}
/**
* 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.
*/
class ModuleNotFoundError extends Error {
constructor(...args) {
super(...args);
_defineProperty(this, 'code', 'MODULE_NOT_FOUND');
}
}
exports.default = ModuleNotFoundError;

20
node_modules/jest-resolve/build/defaultResolver.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* 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';
declare type ResolverOptions = {
basedir: Config.Path;
browser?: boolean;
defaultResolver: typeof defaultResolver;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
rootDir?: Config.Path;
};
export default function defaultResolver(path: Config.Path, options: ResolverOptions): Config.Path;
export declare const clearDefaultResolverCache: () => void;
export {};
//# sourceMappingURL=defaultResolver.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultResolver.d.ts","sourceRoot":"","sources":["../src/defaultResolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAKnC,aAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,eAAe,CAAC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC,IAAI,CAgBb;AAED,eAAO,MAAM,yBAAyB,YAErC,CAAC"}

289
node_modules/jest-resolve/build/defaultResolver.js generated vendored Normal file
View File

@@ -0,0 +1,289 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = defaultResolver;
exports.clearDefaultResolverCache = void 0;
function fs() {
const data = _interopRequireWildcard(require('fs'));
fs = function() {
return data;
};
return data;
}
function path() {
const data = _interopRequireWildcard(require('path'));
path = function() {
return data;
};
return data;
}
function _browserResolve() {
const data = require('browser-resolve');
_browserResolve = function() {
return data;
};
return data;
}
function _jestPnpResolver() {
const data = _interopRequireDefault(require('jest-pnp-resolver'));
_jestPnpResolver = function() {
return data;
};
return data;
}
var _isBuiltinModule = _interopRequireDefault(require('./isBuiltinModule'));
var _nodeModulesPaths = _interopRequireDefault(require('./nodeModulesPaths'));
var _ModuleNotFoundError = _interopRequireDefault(
require('./ModuleNotFoundError')
);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
/**
* 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 defaultResolver(path, options) {
// @ts-ignore: the "pnp" version named isn't in DefinitelyTyped
if (process.versions.pnp) {
return (0, _jestPnpResolver().default)(path, options);
}
const resolve = options.browser ? _browserResolve().sync : resolveSync;
return resolve(path, {
basedir: options.basedir,
defaultResolver,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: options.paths,
rootDir: options.rootDir
});
}
const clearDefaultResolverCache = () => {
checkedPaths.clear();
};
exports.clearDefaultResolverCache = clearDefaultResolverCache;
const REGEX_RELATIVE_IMPORT = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\\/])/;
function resolveSync(target, options) {
const basedir = options.basedir;
const extensions = options.extensions || ['.js'];
const paths = options.paths || [];
if (REGEX_RELATIVE_IMPORT.test(target)) {
// resolve relative import
const resolveTarget = path().resolve(basedir, target);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
} else {
// otherwise search for node_modules
const dirs = (0, _nodeModulesPaths.default)(basedir, {
moduleDirectory: options.moduleDirectory,
paths
});
for (let i = 0; i < dirs.length; i++) {
const resolveTarget = path().join(dirs[i], target);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
}
}
if ((0, _isBuiltinModule.default)(target)) {
return target;
}
throw new _ModuleNotFoundError.default(
"Cannot find module '" + target + "' from '" + basedir + "'"
);
/*
* contextual helper functions
*/
function tryResolve(name) {
const dir = path().dirname(name);
let result;
if (isDirectory(dir)) {
result = resolveAsFile(name) || resolveAsDirectory(name);
}
if (result) {
// Dereference symlinks to ensure we don't create a separate
// module instance depending on how it was referenced.
result = fs().realpathSync(result);
}
return result;
}
function resolveAsFile(name) {
if (isFile(name)) {
return name;
}
for (let i = 0; i < extensions.length; i++) {
const file = name + extensions[i];
if (isFile(file)) {
return file;
}
}
return undefined;
}
function resolveAsDirectory(name) {
if (!isDirectory(name)) {
return undefined;
}
const pkgfile = path().join(name, 'package.json');
let pkgmain;
try {
const body = fs().readFileSync(pkgfile, 'utf8');
pkgmain = JSON.parse(body).main;
} catch (e) {}
if (pkgmain && !isCurrentDirectory(pkgmain)) {
const resolveTarget = path().resolve(name, pkgmain);
const result = tryResolve(resolveTarget);
if (result) {
return result;
}
}
return resolveAsFile(path().join(name, 'index'));
}
}
var IPathType;
(function(IPathType) {
IPathType[(IPathType['FILE'] = 1)] = 'FILE';
IPathType[(IPathType['DIRECTORY'] = 2)] = 'DIRECTORY';
IPathType[(IPathType['OTHER'] = 3)] = 'OTHER';
})(IPathType || (IPathType = {}));
const checkedPaths = new Map();
function statSyncCached(path) {
const result = checkedPaths.get(path);
if (result !== undefined) {
return result;
}
let stat;
try {
stat = fs().statSync(path);
} catch (e) {
if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
throw e;
}
}
if (stat) {
if (stat.isFile() || stat.isFIFO()) {
checkedPaths.set(path, IPathType.FILE);
return IPathType.FILE;
} else if (stat.isDirectory()) {
checkedPaths.set(path, IPathType.DIRECTORY);
return IPathType.DIRECTORY;
}
}
checkedPaths.set(path, IPathType.OTHER);
return IPathType.OTHER;
}
/*
* helper functions
*/
function isFile(file) {
return statSyncCached(file) === IPathType.FILE;
}
function isDirectory(dir) {
return statSyncCached(dir) === IPathType.DIRECTORY;
}
const CURRENT_DIRECTORY = path().resolve('.');
function isCurrentDirectory(testPath) {
return CURRENT_DIRECTORY === path().resolve(testPath);
}

55
node_modules/jest-resolve/build/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,55 @@
/**
* 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 { ModuleMap } from 'jest-haste-map';
import { ResolverConfig } from './types';
import ModuleNotFoundError from './ModuleNotFoundError';
declare type FindNodeModuleConfig = {
basedir: Config.Path;
browser?: boolean;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
resolver?: Config.Path | null;
rootDir?: Config.Path;
};
declare type BooleanObject = Record<string, boolean>;
declare namespace Resolver {
type ResolveModuleConfig = {
skipNodeResolution?: boolean;
paths?: Array<Config.Path>;
};
}
declare class Resolver {
private readonly _options;
private readonly _moduleMap;
private readonly _moduleIDCache;
private readonly _moduleNameCache;
private readonly _modulePathCache;
private readonly _supportsNativePlatform;
constructor(moduleMap: ModuleMap, options: ResolverConfig);
static ModuleNotFoundError: typeof ModuleNotFoundError;
static clearDefaultResolverCache(): void;
static findNodeModule(path: Config.Path, options: FindNodeModuleConfig): Config.Path | null;
resolveModuleFromDirIfExists(dirname: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path | null;
resolveModule(from: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path;
isCoreModule(moduleName: string): boolean;
getModule(name: string): Config.Path | null;
getModulePath(from: Config.Path, moduleName: string): string;
getPackage(name: string): Config.Path | null;
getMockModule(from: Config.Path, name: string): Config.Path | null;
getModulePaths(from: Config.Path): Array<Config.Path>;
getModuleID(virtualMocks: BooleanObject, from: Config.Path, _moduleName?: string): string;
private _getModuleType;
private _getAbsolutePath;
private _getMockPath;
private _getVirtualMockPath;
private _isModuleResolved;
resolveStubModuleName(from: Config.Path, moduleName: string): Config.Path | null;
}
export = Resolver;
//# sourceMappingURL=index.d.ts.map

1
node_modules/jest-resolve/build/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}

505
node_modules/jest-resolve/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,505 @@
'use strict';
function path() {
const data = _interopRequireWildcard(require('path'));
path = function() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function() {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function() {
return data;
};
return data;
}
var _nodeModulesPaths = _interopRequireDefault(require('./nodeModulesPaths'));
var _isBuiltinModule = _interopRequireDefault(require('./isBuiltinModule'));
var _defaultResolver = _interopRequireWildcard(require('./defaultResolver'));
var _ModuleNotFoundError = _interopRequireDefault(
require('./ModuleNotFoundError')
);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
const NATIVE_PLATFORM = 'native'; // We might be inside a symlink.
const cwd = process.cwd();
const resolvedCwd = (0, _realpathNative().sync)(cwd) || cwd;
const {NODE_PATH} = process.env;
const nodePaths = NODE_PATH
? NODE_PATH.split(path().delimiter)
.filter(Boolean) // The resolver expects absolute paths.
.map(p => path().resolve(resolvedCwd, p))
: undefined;
/* eslint-disable-next-line no-redeclare */
class Resolver {
constructor(moduleMap, options) {
_defineProperty(this, '_options', void 0);
_defineProperty(this, '_moduleMap', void 0);
_defineProperty(this, '_moduleIDCache', void 0);
_defineProperty(this, '_moduleNameCache', void 0);
_defineProperty(this, '_modulePathCache', void 0);
_defineProperty(this, '_supportsNativePlatform', void 0);
this._options = {
browser: options.browser,
defaultPlatform: options.defaultPlatform,
extensions: options.extensions,
hasCoreModules:
options.hasCoreModules === undefined ? true : options.hasCoreModules,
moduleDirectories: options.moduleDirectories || ['node_modules'],
moduleNameMapper: options.moduleNameMapper,
modulePaths: options.modulePaths,
platforms: options.platforms,
resolver: options.resolver,
rootDir: options.rootDir
};
this._supportsNativePlatform = options.platforms
? options.platforms.includes(NATIVE_PLATFORM)
: false;
this._moduleMap = moduleMap;
this._moduleIDCache = new Map();
this._moduleNameCache = new Map();
this._modulePathCache = new Map();
}
static clearDefaultResolverCache() {
(0, _defaultResolver.clearDefaultResolverCache)();
}
static findNodeModule(path, options) {
const resolver = options.resolver
? require(options.resolver)
: _defaultResolver.default;
const paths = options.paths;
try {
return resolver(path, {
basedir: options.basedir,
browser: options.browser,
defaultResolver: _defaultResolver.default,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: paths ? (nodePaths || []).concat(paths) : nodePaths,
rootDir: options.rootDir
});
} catch (e) {}
return null;
}
resolveModuleFromDirIfExists(dirname, moduleName, options) {
const paths = (options && options.paths) || this._options.modulePaths;
const moduleDirectory = this._options.moduleDirectories;
const key = dirname + path().delimiter + moduleName;
const defaultPlatform = this._options.defaultPlatform;
const extensions = this._options.extensions.slice();
let module;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
} // 1. If we have already resolved this module for this directory name,
// return a value from the cache.
const cacheResult = this._moduleNameCache.get(key);
if (cacheResult) {
return cacheResult;
} // 2. Check if the module is a haste module.
module = this.getModule(moduleName);
if (module) {
this._moduleNameCache.set(key, module);
return module;
} // 3. Check if the module is a node module and resolve it based on
// the node module resolution algorithm. If skipNodeResolution is given we
// ignore all modules that look like node modules (ie. are not relative
// requires). This enables us to speed up resolution when we build a
// dependency graph because we don't have to look at modules that may not
// exist and aren't mocked.
const skipResolution =
options && options.skipNodeResolution && !moduleName.includes(path().sep);
const resolveNodeModule = name =>
Resolver.findNodeModule(name, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver: this._options.resolver,
rootDir: this._options.rootDir
});
if (!skipResolution) {
module = resolveNodeModule(moduleName);
if (module) {
this._moduleNameCache.set(key, module);
return module;
}
} // 4. Resolve "haste packages" which are `package.json` files outside of
// `node_modules` folders anywhere in the file system.
const parts = moduleName.split('/');
const hastePackage = this.getPackage(parts.shift());
if (hastePackage) {
try {
const module = path().join.apply(
path(),
[path().dirname(hastePackage)].concat(parts)
); // try resolving with custom resolver first to support extensions,
// then fallback to require.resolve
const resolvedModule =
resolveNodeModule(module) || require.resolve(module);
this._moduleNameCache.set(key, resolvedModule);
return resolvedModule;
} catch (ignoredError) {}
}
return null;
}
resolveModule(from, moduleName, options) {
const dirname = path().dirname(from);
const module =
this.resolveStubModuleName(from, moduleName) ||
this.resolveModuleFromDirIfExists(dirname, moduleName, options);
if (module) return module; // 5. Throw an error if the module could not be found. `resolve.sync` only
// produces an error based on the dirname but we have the actual current
// module name available.
const relativePath = path().relative(dirname, from);
throw new _ModuleNotFoundError.default(
`Cannot find module '${moduleName}' from '${relativePath || '.'}'`
);
}
isCoreModule(moduleName) {
return (
this._options.hasCoreModules && (0, _isBuiltinModule.default)(moduleName)
);
}
getModule(name) {
return this._moduleMap.getModule(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getModulePath(from, moduleName) {
if (moduleName[0] !== '.' || path().isAbsolute(moduleName)) {
return moduleName;
}
return path().normalize(path().dirname(from) + '/' + moduleName);
}
getPackage(name) {
return this._moduleMap.getPackage(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getMockModule(from, name) {
const mock = this._moduleMap.getMockModule(name);
if (mock) {
return mock;
} else {
const moduleName = this.resolveStubModuleName(from, name);
if (moduleName) {
return this.getModule(moduleName) || moduleName;
}
}
return null;
}
getModulePaths(from) {
const cachedModule = this._modulePathCache.get(from);
if (cachedModule) {
return cachedModule;
}
const moduleDirectory = this._options.moduleDirectories;
const paths = (0, _nodeModulesPaths.default)(from, {
moduleDirectory
});
if (paths[paths.length - 1] === undefined) {
// circumvent node-resolve bug that adds `undefined` as last item.
paths.pop();
}
this._modulePathCache.set(from, paths);
return paths;
}
getModuleID(virtualMocks, from, _moduleName) {
const moduleName = _moduleName || '';
const key = from + path().delimiter + moduleName;
const cachedModuleID = this._moduleIDCache.get(key);
if (cachedModuleID) {
return cachedModuleID;
}
const moduleType = this._getModuleType(moduleName);
const absolutePath = this._getAbsolutePath(virtualMocks, from, moduleName);
const mockPath = this._getMockPath(from, moduleName);
const sep = path().delimiter;
const id =
moduleType +
sep +
(absolutePath ? absolutePath + sep : '') +
(mockPath ? mockPath + sep : '');
this._moduleIDCache.set(key, id);
return id;
}
_getModuleType(moduleName) {
return this.isCoreModule(moduleName) ? 'node' : 'user';
}
_getAbsolutePath(virtualMocks, from, moduleName) {
if (this.isCoreModule(moduleName)) {
return moduleName;
}
return this._isModuleResolved(from, moduleName)
? this.getModule(moduleName)
: this._getVirtualMockPath(virtualMocks, from, moduleName);
}
_getMockPath(from, moduleName) {
return !this.isCoreModule(moduleName)
? this.getMockModule(from, moduleName)
: null;
}
_getVirtualMockPath(virtualMocks, from, moduleName) {
const virtualMockPath = this.getModulePath(from, moduleName);
return virtualMocks[virtualMockPath]
? virtualMockPath
: moduleName
? this.resolveModule(from, moduleName)
: from;
}
_isModuleResolved(from, moduleName) {
return !!(
this.getModule(moduleName) || this.getMockModule(from, moduleName)
);
}
resolveStubModuleName(from, moduleName) {
const dirname = path().dirname(from);
const paths = this._options.modulePaths;
const extensions = this._options.extensions.slice();
const moduleDirectory = this._options.moduleDirectories;
const moduleNameMapper = this._options.moduleNameMapper;
const resolver = this._options.resolver;
const defaultPlatform = this._options.defaultPlatform;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
}
if (moduleNameMapper) {
for (const {moduleName: mappedModuleName, regex} of moduleNameMapper) {
if (regex.test(moduleName)) {
// Note: once a moduleNameMapper matches the name, it must result
// in a module, or else an error is thrown.
const matches = moduleName.match(regex);
const updatedName = matches
? mappedModuleName.replace(
/\$([0-9]+)/g,
(_, index) => matches[parseInt(index, 10)]
)
: mappedModuleName;
const module =
this.getModule(updatedName) ||
Resolver.findNodeModule(updatedName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths,
resolver,
rootDir: this._options.rootDir
});
if (!module) {
throw createNoMappedModuleFoundError(
moduleName,
updatedName,
mappedModuleName,
regex,
resolver
);
}
return module;
}
}
}
return null;
}
}
_defineProperty(Resolver, 'ModuleNotFoundError', _ModuleNotFoundError.default);
const createNoMappedModuleFoundError = (
moduleName,
updatedName,
mappedModuleName,
regex,
resolver
) => {
const error = new Error(
_chalk().default.red(`${_chalk().default.bold('Configuration error')}:
Could not locate module ${_chalk().default.bold(moduleName)} mapped as:
${_chalk().default.bold(updatedName)}.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"${regex.toString()}": "${_chalk().default.bold(mappedModuleName)}"
},
"resolver": ${_chalk().default.bold(String(resolver))}
}`)
);
error.name = '';
return error;
};
module.exports = Resolver;

8
node_modules/jest-resolve/build/isBuiltinModule.d.ts generated vendored Normal file
View 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 isBuiltinModule(module: string): boolean;
//# sourceMappingURL=isBuiltinModule.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isBuiltinModule.d.ts","sourceRoot":"","sources":["../src/isBuiltinModule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/D"}

39
node_modules/jest-resolve/build/isBuiltinModule.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = isBuiltinModule;
function _module() {
const data = _interopRequireDefault(require('module'));
_module = function() {
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 EXPERIMENTAL_MODULES = ['worker_threads'];
const BUILTIN_MODULES = new Set(
_module().default.builtinModules
? _module().default.builtinModules.concat(EXPERIMENTAL_MODULES)
: Object.keys(process.binding('natives'))
.filter(module => !/^internal\//.test(module))
.concat(EXPERIMENTAL_MODULES)
);
function isBuiltinModule(module) {
return BUILTIN_MODULES.has(module);
}

16
node_modules/jest-resolve/build/nodeModulesPaths.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* 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.
*
* Adapted from: https://github.com/substack/node-resolve
*/
import { Config } from '@jest/types';
declare type NodeModulesPathsOptions = {
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
};
export default function nodeModulesPaths(basedir: Config.Path, options: NodeModulesPathsOptions): Array<Config.Path>;
export {};
//# sourceMappingURL=nodeModulesPaths.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"nodeModulesPaths.d.ts","sourceRoot":"","sources":["../src/nodeModulesPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGnC,aAAK,uBAAuB,GAAG;IAC7B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,OAAO,EAAE,MAAM,CAAC,IAAI,EACpB,OAAO,EAAE,uBAAuB,GAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAmDpB"}

128
node_modules/jest-resolve/build/nodeModulesPaths.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = nodeModulesPaths;
function path() {
const data = _interopRequireWildcard(require('path'));
path = function() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function() {
return data;
};
return data;
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
/**
* 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.
*
* Adapted from: https://github.com/substack/node-resolve
*/
function nodeModulesPaths(basedir, options) {
const modules =
options && options.moduleDirectory
? Array.from(options.moduleDirectory)
: ['node_modules']; // ensure that `basedir` is an absolute path at this point,
// resolving against the process' current working directory
const basedirAbs = path().resolve(basedir);
let prefix = '/';
if (/^([A-Za-z]:)/.test(basedirAbs)) {
prefix = '';
} else if (/^\\\\/.test(basedirAbs)) {
prefix = '\\\\';
} // The node resolution algorithm (as implemented by NodeJS and TypeScript)
// traverses parents of the physical path, not the symlinked path
let physicalBasedir;
try {
physicalBasedir = (0, _realpathNative().sync)(basedirAbs);
} catch (err) {
// realpath can throw, e.g. on mapped drives
physicalBasedir = basedirAbs;
}
const paths = [physicalBasedir];
let parsed = path().parse(physicalBasedir);
while (parsed.dir !== paths[paths.length - 1]) {
paths.push(parsed.dir);
parsed = path().parse(parsed.dir);
}
const dirs = paths
.reduce(
(dirs, aPath) =>
dirs.concat(
modules.map(moduleDir =>
path().isAbsolute(moduleDir)
? aPath === basedirAbs
? moduleDir
: ''
: path().join(prefix, aPath, moduleDir)
)
),
[]
)
.filter(dir => dir !== '');
return options.paths ? dirs.concat(options.paths) : dirs;
}

25
node_modules/jest-resolve/build/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/**
* 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';
export declare type ResolverConfig = {
browser?: boolean;
defaultPlatform?: string | null;
extensions: Array<string>;
hasCoreModules: boolean;
moduleDirectories: Array<string>;
moduleNameMapper?: Array<ModuleNameMapperConfig> | null;
modulePaths?: Array<Config.Path>;
platforms?: Array<string>;
resolver?: Config.Path | null;
rootDir: Config.Path;
};
declare type ModuleNameMapperConfig = {
regex: RegExp;
moduleName: string;
};
export {};
//# sourceMappingURL=types.d.ts.map

1
node_modules/jest-resolve/build/types.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,oBAAY,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;CACtB,CAAC;AAEF,aAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}

1
node_modules/jest-resolve/build/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
'use strict';