aboutsummaryrefslogtreecommitdiff
path: root/node_modules/jest-haste-map/build/watchers
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/jest-haste-map/build/watchers
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/jest-haste-map/build/watchers')
-rw-r--r--node_modules/jest-haste-map/build/watchers/FSEventsWatcher.d.ts44
-rw-r--r--node_modules/jest-haste-map/build/watchers/FSEventsWatcher.js294
-rw-r--r--node_modules/jest-haste-map/build/watchers/NodeWatcher.js375
-rw-r--r--node_modules/jest-haste-map/build/watchers/RecrawlWarning.js57
-rw-r--r--node_modules/jest-haste-map/build/watchers/WatchmanWatcher.js418
-rw-r--r--node_modules/jest-haste-map/build/watchers/common.js114
6 files changed, 1302 insertions, 0 deletions
diff --git a/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.d.ts b/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.d.ts
new file mode 100644
index 0000000..2c63ee9
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.d.ts
@@ -0,0 +1,44 @@
+/**
+ * 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 { Matcher } from 'anymatch';
+/**
+ * Export `FSEventsWatcher` class.
+ * Watches `dir`.
+ */
+declare class FSEventsWatcher extends EventEmitter {
+ readonly root: string;
+ readonly ignored?: Matcher;
+ readonly glob: Array<string>;
+ readonly dot: boolean;
+ readonly hasIgnore: boolean;
+ readonly doIgnore: (path: string) => boolean;
+ readonly fsEventsWatchStopper: () => Promise<void>;
+ private _tracked;
+ static isSupported(): boolean;
+ private static normalizeProxy;
+ private static recReaddir;
+ constructor(dir: string, opts: {
+ root: string;
+ ignored?: Matcher;
+ glob: string | Array<string>;
+ dot: boolean;
+ });
+ /**
+ * End watching.
+ */
+ close(callback?: () => void): Promise<void>;
+ private isFileIncluded;
+ private handleEvent;
+ /**
+ * Emit events.
+ */
+ private _emit;
+}
+export = FSEventsWatcher;
diff --git a/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.js b/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.js
new file mode 100644
index 0000000..fb97ac8
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/FSEventsWatcher.js
@@ -0,0 +1,294 @@
+'use strict';
+
+function _events() {
+ const data = require('events');
+
+ _events = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function path() {
+ const data = _interopRequireWildcard(require('path'));
+
+ path = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _anymatch() {
+ const data = _interopRequireDefault(require('anymatch'));
+
+ _anymatch = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function fs() {
+ const data = _interopRequireWildcard(require('graceful-fs'));
+
+ fs = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _micromatch() {
+ const data = _interopRequireDefault(require('micromatch'));
+
+ _micromatch = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _walker() {
+ const data = _interopRequireDefault(require('walker'));
+
+ _walker = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : {default: obj};
+}
+
+function _getRequireWildcardCache(nodeInterop) {
+ if (typeof WeakMap !== 'function') return null;
+ var cacheBabelInterop = new WeakMap();
+ var cacheNodeInterop = new WeakMap();
+ return (_getRequireWildcardCache = function (nodeInterop) {
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
+ })(nodeInterop);
+}
+
+function _interopRequireWildcard(obj, nodeInterop) {
+ if (!nodeInterop && obj && obj.__esModule) {
+ return obj;
+ }
+ if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
+ return {default: obj};
+ }
+ var cache = _getRequireWildcardCache(nodeInterop);
+ if (cache && cache.has(obj)) {
+ return cache.get(obj);
+ }
+ var newObj = {};
+ var hasPropertyDescriptor =
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
+ for (var key in obj) {
+ if (key !== 'default' && 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;
+}
+
+// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
+// @ts-ignore: this is for CI which runs linux and might not have this
+let fsevents = null;
+
+try {
+ fsevents = require('fsevents');
+} catch {
+ // 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 !== null;
+ }
+
+ static normalizeProxy(callback) {
+ return (filepath, stats) => callback(path().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, 'fsEventsWatchStopper', 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().resolve(dir);
+ this.fsEventsWatchStopper = fsevents.watch(
+ this.root,
+ 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.
+ */
+
+ async close(callback) {
+ await this.fsEventsWatchStopper();
+ 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
+ ? (0, _micromatch().default)([relativePath], this.glob, {
+ dot: this.dot
+ }).length > 0
+ : this.dot ||
+ (0, _micromatch().default)([relativePath], '**/*').length > 0;
+ }
+
+ handleEvent(filepath) {
+ const relativePath = path().relative(this.root, filepath);
+
+ if (!this.isFileIncluded(relativePath)) {
+ return;
+ }
+
+ fs().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;
diff --git a/node_modules/jest-haste-map/build/watchers/NodeWatcher.js b/node_modules/jest-haste-map/build/watchers/NodeWatcher.js
new file mode 100644
index 0000000..8ae1bc4
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/NodeWatcher.js
@@ -0,0 +1,375 @@
+// vendored from https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/node_watcher.js
+'use strict';
+
+const EventEmitter = require('events').EventEmitter;
+
+const fs = require('fs');
+
+const platform = require('os').platform();
+
+const path = require('path');
+
+const common = require('./common');
+/**
+ * Constants
+ */
+
+const DEFAULT_DELAY = common.DEFAULT_DELAY;
+const CHANGE_EVENT = common.CHANGE_EVENT;
+const DELETE_EVENT = common.DELETE_EVENT;
+const ADD_EVENT = common.ADD_EVENT;
+const ALL_EVENT = common.ALL_EVENT;
+/**
+ * Export `NodeWatcher` class.
+ * Watches `dir`.
+ *
+ * @class NodeWatcher
+ * @param {String} dir
+ * @param {Object} opts
+ * @public
+ */
+
+module.exports = class NodeWatcher extends EventEmitter {
+ constructor(dir, opts) {
+ super();
+ common.assignOptions(this, opts);
+ this.watched = Object.create(null);
+ this.changeTimers = Object.create(null);
+ this.dirRegistery = Object.create(null);
+ this.root = path.resolve(dir);
+ this.watchdir = this.watchdir.bind(this);
+ this.register = this.register.bind(this);
+ this.checkedEmitError = this.checkedEmitError.bind(this);
+ this.watchdir(this.root);
+ common.recReaddir(
+ this.root,
+ this.watchdir,
+ this.register,
+ this.emit.bind(this, 'ready'),
+ this.checkedEmitError,
+ this.ignored
+ );
+ }
+ /**
+ * Register files that matches our globs to know what to type of event to
+ * emit in the future.
+ *
+ * Registery looks like the following:
+ *
+ * dirRegister => Map {
+ * dirpath => Map {
+ * filename => true
+ * }
+ * }
+ *
+ * @param {string} filepath
+ * @return {boolean} whether or not we have registered the file.
+ * @private
+ */
+
+ register(filepath) {
+ const relativePath = path.relative(this.root, filepath);
+
+ if (
+ !common.isFileIncluded(this.globs, this.dot, this.doIgnore, relativePath)
+ ) {
+ return false;
+ }
+
+ const dir = path.dirname(filepath);
+
+ if (!this.dirRegistery[dir]) {
+ this.dirRegistery[dir] = Object.create(null);
+ }
+
+ const filename = path.basename(filepath);
+ this.dirRegistery[dir][filename] = true;
+ return true;
+ }
+ /**
+ * Removes a file from the registery.
+ *
+ * @param {string} filepath
+ * @private
+ */
+
+ unregister(filepath) {
+ const dir = path.dirname(filepath);
+
+ if (this.dirRegistery[dir]) {
+ const filename = path.basename(filepath);
+ delete this.dirRegistery[dir][filename];
+ }
+ }
+ /**
+ * Removes a dir from the registery.
+ *
+ * @param {string} dirpath
+ * @private
+ */
+
+ unregisterDir(dirpath) {
+ if (this.dirRegistery[dirpath]) {
+ delete this.dirRegistery[dirpath];
+ }
+ }
+ /**
+ * Checks if a file or directory exists in the registery.
+ *
+ * @param {string} fullpath
+ * @return {boolean}
+ * @private
+ */
+
+ registered(fullpath) {
+ const dir = path.dirname(fullpath);
+ return (
+ this.dirRegistery[fullpath] ||
+ (this.dirRegistery[dir] &&
+ this.dirRegistery[dir][path.basename(fullpath)])
+ );
+ }
+ /**
+ * Emit "error" event if it's not an ignorable event
+ *
+ * @param error
+ * @private
+ */
+
+ checkedEmitError(error) {
+ if (!isIgnorableFileError(error)) {
+ this.emit('error', error);
+ }
+ }
+ /**
+ * Watch a directory.
+ *
+ * @param {string} dir
+ * @private
+ */
+
+ watchdir(dir) {
+ if (this.watched[dir]) {
+ return;
+ }
+
+ const watcher = fs.watch(
+ dir,
+ {
+ persistent: true
+ },
+ this.normalizeChange.bind(this, dir)
+ );
+ this.watched[dir] = watcher;
+ watcher.on('error', this.checkedEmitError);
+
+ if (this.root !== dir) {
+ this.register(dir);
+ }
+ }
+ /**
+ * Stop watching a directory.
+ *
+ * @param {string} dir
+ * @private
+ */
+
+ stopWatching(dir) {
+ if (this.watched[dir]) {
+ this.watched[dir].close();
+ delete this.watched[dir];
+ }
+ }
+ /**
+ * End watching.
+ *
+ * @public
+ */
+
+ close() {
+ Object.keys(this.watched).forEach(this.stopWatching, this);
+ this.removeAllListeners();
+ return Promise.resolve();
+ }
+ /**
+ * On some platforms, as pointed out on the fs docs (most likely just win32)
+ * the file argument might be missing from the fs event. Try to detect what
+ * change by detecting if something was deleted or the most recent file change.
+ *
+ * @param {string} dir
+ * @param {string} event
+ * @param {string} file
+ * @public
+ */
+
+ detectChangedFile(dir, event, callback) {
+ if (!this.dirRegistery[dir]) {
+ return;
+ }
+
+ let found = false;
+ let closest = {
+ mtime: 0
+ };
+ let c = 0;
+ Object.keys(this.dirRegistery[dir]).forEach(function (file, i, arr) {
+ fs.lstat(path.join(dir, file), (error, stat) => {
+ if (found) {
+ return;
+ }
+
+ if (error) {
+ if (isIgnorableFileError(error)) {
+ found = true;
+ callback(file);
+ } else {
+ this.emit('error', error);
+ }
+ } else {
+ if (stat.mtime > closest.mtime) {
+ stat.file = file;
+ closest = stat;
+ }
+
+ if (arr.length === ++c) {
+ callback(closest.file);
+ }
+ }
+ });
+ }, this);
+ }
+ /**
+ * Normalize fs events and pass it on to be processed.
+ *
+ * @param {string} dir
+ * @param {string} event
+ * @param {string} file
+ * @public
+ */
+
+ normalizeChange(dir, event, file) {
+ if (!file) {
+ this.detectChangedFile(dir, event, actualFile => {
+ if (actualFile) {
+ this.processChange(dir, event, actualFile);
+ }
+ });
+ } else {
+ this.processChange(dir, event, path.normalize(file));
+ }
+ }
+ /**
+ * Process changes.
+ *
+ * @param {string} dir
+ * @param {string} event
+ * @param {string} file
+ * @public
+ */
+
+ processChange(dir, event, file) {
+ const fullPath = path.join(dir, file);
+ const relativePath = path.join(path.relative(this.root, dir), file);
+ fs.lstat(fullPath, (error, stat) => {
+ if (error && error.code !== 'ENOENT') {
+ this.emit('error', error);
+ } else if (!error && stat.isDirectory()) {
+ // win32 emits usless change events on dirs.
+ if (event !== 'change') {
+ this.watchdir(fullPath);
+
+ if (
+ common.isFileIncluded(
+ this.globs,
+ this.dot,
+ this.doIgnore,
+ relativePath
+ )
+ ) {
+ this.emitEvent(ADD_EVENT, relativePath, stat);
+ }
+ }
+ } else {
+ const registered = this.registered(fullPath);
+
+ if (error && error.code === 'ENOENT') {
+ this.unregister(fullPath);
+ this.stopWatching(fullPath);
+ this.unregisterDir(fullPath);
+
+ if (registered) {
+ this.emitEvent(DELETE_EVENT, relativePath);
+ }
+ } else if (registered) {
+ this.emitEvent(CHANGE_EVENT, relativePath, stat);
+ } else {
+ if (this.register(fullPath)) {
+ this.emitEvent(ADD_EVENT, relativePath, stat);
+ }
+ }
+ }
+ });
+ }
+ /**
+ * Triggers a 'change' event after debounding it to take care of duplicate
+ * events on os x.
+ *
+ * @private
+ */
+
+ emitEvent(type, file, stat) {
+ const key = type + '-' + file;
+ const addKey = ADD_EVENT + '-' + file;
+
+ if (type === CHANGE_EVENT && this.changeTimers[addKey]) {
+ // Ignore the change event that is immediately fired after an add event.
+ // (This happens on Linux).
+ return;
+ }
+
+ clearTimeout(this.changeTimers[key]);
+ this.changeTimers[key] = setTimeout(() => {
+ delete this.changeTimers[key];
+
+ if (type === ADD_EVENT && stat.isDirectory()) {
+ // Recursively emit add events and watch for sub-files/folders
+ common.recReaddir(
+ path.resolve(this.root, file),
+ function emitAddDir(dir, stats) {
+ this.watchdir(dir);
+ this.rawEmitEvent(ADD_EVENT, path.relative(this.root, dir), stats);
+ }.bind(this),
+ function emitAddFile(file, stats) {
+ this.register(file);
+ this.rawEmitEvent(ADD_EVENT, path.relative(this.root, file), stats);
+ }.bind(this),
+ function endCallback() {},
+ this.checkedEmitError,
+ this.ignored
+ );
+ } else {
+ this.rawEmitEvent(type, file, stat);
+ }
+ }, DEFAULT_DELAY);
+ }
+ /**
+ * Actually emit the events
+ */
+
+ rawEmitEvent(type, file, stat) {
+ this.emit(type, file, this.root, stat);
+ this.emit(ALL_EVENT, type, file, this.root, stat);
+ }
+};
+/**
+ * Determine if a given FS error can be ignored
+ *
+ * @private
+ */
+
+function isIgnorableFileError(error) {
+ return (
+ error.code === 'ENOENT' || // Workaround Windows node issue #4337.
+ (error.code === 'EPERM' && platform === 'win32')
+ );
+}
diff --git a/node_modules/jest-haste-map/build/watchers/RecrawlWarning.js b/node_modules/jest-haste-map/build/watchers/RecrawlWarning.js
new file mode 100644
index 0000000..a89af20
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/RecrawlWarning.js
@@ -0,0 +1,57 @@
+// vendored from https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/utils/recrawl-warning-dedupe.js
+'use strict';
+
+class RecrawlWarning {
+ constructor(root, count) {
+ this.root = root;
+ this.count = count;
+ }
+
+ static findByRoot(root) {
+ for (let i = 0; i < this.RECRAWL_WARNINGS.length; i++) {
+ const warning = this.RECRAWL_WARNINGS[i];
+
+ if (warning.root === root) {
+ return warning;
+ }
+ }
+
+ return undefined;
+ }
+
+ static isRecrawlWarningDupe(warningMessage) {
+ if (typeof warningMessage !== 'string') {
+ return false;
+ }
+
+ const match = warningMessage.match(this.REGEXP);
+
+ if (!match) {
+ return false;
+ }
+
+ const count = Number(match[1]);
+ const root = match[2];
+ const warning = this.findByRoot(root);
+
+ if (warning) {
+ // only keep the highest count, assume count to either stay the same or
+ // increase.
+ if (warning.count >= count) {
+ return true;
+ } else {
+ // update the existing warning to the latest (highest) count
+ warning.count = count;
+ return false;
+ }
+ } else {
+ this.RECRAWL_WARNINGS.push(new RecrawlWarning(root, count));
+ return false;
+ }
+ }
+}
+
+RecrawlWarning.RECRAWL_WARNINGS = [];
+RecrawlWarning.REGEXP =
+ /Recrawled this watch (\d+) times, most recently because:\n([^:]+)/;
+module.exports = RecrawlWarning;
diff --git a/node_modules/jest-haste-map/build/watchers/WatchmanWatcher.js b/node_modules/jest-haste-map/build/watchers/WatchmanWatcher.js
new file mode 100644
index 0000000..86db538
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/WatchmanWatcher.js
@@ -0,0 +1,418 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.default = WatchmanWatcher;
+
+function _assert() {
+ const data = _interopRequireDefault(require('assert'));
+
+ _assert = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _events() {
+ const data = require('events');
+
+ _events = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _path() {
+ const data = _interopRequireDefault(require('path'));
+
+ _path = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _fbWatchman() {
+ const data = _interopRequireDefault(require('fb-watchman'));
+
+ _fbWatchman = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function fs() {
+ const data = _interopRequireWildcard(require('graceful-fs'));
+
+ fs = function () {
+ return data;
+ };
+
+ return data;
+}
+
+var _RecrawlWarning = _interopRequireDefault(require('./RecrawlWarning'));
+
+var _common = _interopRequireDefault(require('./common'));
+
+function _getRequireWildcardCache(nodeInterop) {
+ if (typeof WeakMap !== 'function') return null;
+ var cacheBabelInterop = new WeakMap();
+ var cacheNodeInterop = new WeakMap();
+ return (_getRequireWildcardCache = function (nodeInterop) {
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
+ })(nodeInterop);
+}
+
+function _interopRequireWildcard(obj, nodeInterop) {
+ if (!nodeInterop && obj && obj.__esModule) {
+ return obj;
+ }
+ if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
+ return {default: obj};
+ }
+ var cache = _getRequireWildcardCache(nodeInterop);
+ if (cache && cache.has(obj)) {
+ return cache.get(obj);
+ }
+ var newObj = {};
+ var hasPropertyDescriptor =
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
+ for (var key in obj) {
+ if (key !== 'default' && 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 _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().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.
+ *
+ */
+
+WatchmanWatcher.prototype.close = function () {
+ this.client.removeAllListeners();
+ this.client.end();
+ return Promise.resolve();
+};
+/**
+ * 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 (_RecrawlWarning.default.isRecrawlWarningDupe(resp.warning)) {
+ return true;
+ }
+
+ console.warn(resp.warning);
+ return true;
+ } else {
+ return false;
+ }
+}
diff --git a/node_modules/jest-haste-map/build/watchers/common.js b/node_modules/jest-haste-map/build/watchers/common.js
new file mode 100644
index 0000000..6372744
--- /dev/null
+++ b/node_modules/jest-haste-map/build/watchers/common.js
@@ -0,0 +1,114 @@
+// vendored from https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/common.js
+'use strict';
+
+const platform = require('os').platform();
+
+const path = require('path');
+
+const anymatch = require('anymatch');
+
+const micromatch = require('micromatch');
+
+const walker = require('walker');
+/**
+ * Constants
+ */
+
+exports.DEFAULT_DELAY = 100;
+exports.CHANGE_EVENT = 'change';
+exports.DELETE_EVENT = 'delete';
+exports.ADD_EVENT = 'add';
+exports.ALL_EVENT = 'all';
+/**
+ * Assigns options to the watcher.
+ *
+ * @param {NodeWatcher|PollWatcher|WatchmanWatcher} watcher
+ * @param {?object} opts
+ * @return {boolean}
+ * @public
+ */
+
+exports.assignOptions = function (watcher, opts) {
+ opts = opts || {};
+ watcher.globs = opts.glob || [];
+ watcher.dot = opts.dot || false;
+ watcher.ignored = opts.ignored || false;
+
+ if (!Array.isArray(watcher.globs)) {
+ watcher.globs = [watcher.globs];
+ }
+
+ watcher.hasIgnore =
+ Boolean(opts.ignored) && !(Array.isArray(opts) && opts.length > 0);
+ watcher.doIgnore = opts.ignored ? anymatch(opts.ignored) : () => false;
+
+ if (opts.watchman && opts.watchmanPath) {
+ watcher.watchmanPath = opts.watchmanPath;
+ }
+
+ return opts;
+};
+/**
+ * Checks a file relative path against the globs array.
+ *
+ * @param {array} globs
+ * @param {string} relativePath
+ * @return {boolean}
+ * @public
+ */
+
+exports.isFileIncluded = function (globs, dot, doIgnore, relativePath) {
+ if (doIgnore(relativePath)) {
+ return false;
+ }
+
+ return globs.length
+ ? micromatch.some(relativePath, globs, {
+ dot
+ })
+ : dot || micromatch.some(relativePath, '**/*');
+};
+/**
+ * Traverse a directory recursively calling `callback` on every directory.
+ *
+ * @param {string} dir
+ * @param {function} dirCallback
+ * @param {function} fileCallback
+ * @param {function} endCallback
+ * @param {*} ignored
+ * @public
+ */
+
+exports.recReaddir = function (
+ dir,
+ dirCallback,
+ fileCallback,
+ endCallback,
+ errorCallback,
+ ignored
+) {
+ walker(dir)
+ .filterDir(currentDir => !anymatch(ignored, currentDir))
+ .on('dir', normalizeProxy(dirCallback))
+ .on('file', normalizeProxy(fileCallback))
+ .on('error', errorCallback)
+ .on('end', () => {
+ if (platform === 'win32') {
+ setTimeout(endCallback, 1000);
+ } else {
+ endCallback();
+ }
+ });
+};
+/**
+ * Returns a callback that when called will normalize a path and call the
+ * original callback
+ *
+ * @param {function} callback
+ * @return {function}
+ * @private
+ */
+
+function normalizeProxy(callback) {
+ return (filepath, stats) => callback(path.normalize(filepath), stats);
+}