overwatch-api-server
Version:
An Unoffical Overwatch HTTP API
41 lines (33 loc) • 802 kB
JavaScript
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./chokidar/index.js":
/*!***************************!*\
!*** ./chokidar/index.js ***!
\***************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
eval("\nvar EventEmitter = __webpack_require__(/*! events */ \"events\").EventEmitter;\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nvar sysPath = __webpack_require__(/*! path */ \"path\");\nvar asyncEach = __webpack_require__(/*! async-each */ \"./node_modules/async-each/index.js\");\nvar anymatch = __webpack_require__(/*! anymatch */ \"./node_modules/anymatch/index.js\");\nvar globParent = __webpack_require__(/*! glob-parent */ \"./node_modules/glob-parent/index.js\");\nvar isGlob = __webpack_require__(/*! is-glob */ \"./node_modules/is-glob/index.js\");\nvar isAbsolute = __webpack_require__(/*! path-is-absolute */ \"./node_modules/path-is-absolute/index.js\");\nvar inherits = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits.js\");\nvar braces = __webpack_require__(/*! braces */ \"./node_modules/braces/index.js\");\nvar normalizePath = __webpack_require__(/*! normalize-path */ \"./node_modules/normalize-path/index.js\");\nvar upath = __webpack_require__(/*! upath */ \"./node_modules/upath/build/code/upath.js\");\n\nvar NodeFsHandler = __webpack_require__(/*! ./lib/nodefs-handler */ \"./chokidar/lib/nodefs-handler.js\");\nvar FsEventsHandler = __webpack_require__(/*! ./lib/fsevents-handler */ \"./chokidar/lib/fsevents-handler.js\");\n\nvar arrify = function(value) {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n};\n\nvar flatten = function(list, result) {\n if (result == null) result = [];\n list.forEach(function(item) {\n if (Array.isArray(item)) {\n flatten(item, result);\n } else {\n result.push(item);\n }\n });\n return result;\n};\n\n// Little isString util for use in Array#every.\nvar isString = function(thing) {\n return typeof thing === 'string';\n};\n\n// Public: Main class.\n// Watches files & directories for changes.\n//\n// * _opts - object, chokidar options hash\n//\n// Emitted events:\n// `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`\n//\n// Examples\n//\n// var watcher = new FSWatcher()\n// .add(directories)\n// .on('add', path => console.log('File', path, 'was added'))\n// .on('change', path => console.log('File', path, 'was changed'))\n// .on('unlink', path => console.log('File', path, 'was removed'))\n// .on('all', (event, path) => console.log(path, ' emitted ', event))\n//\nfunction FSWatcher(_opts) {\n EventEmitter.call(this);\n var opts = {};\n // in case _opts that is passed in is a frozen object\n if (_opts) for (var opt in _opts) opts[opt] = _opts[opt];\n this._watched = Object.create(null);\n this._closers = Object.create(null);\n this._ignoredPaths = Object.create(null);\n Object.defineProperty(this, '_globIgnored', {\n get: function() { return Object.keys(this._ignoredPaths); }\n });\n this.closed = false;\n this._throttled = Object.create(null);\n this._symlinkPaths = Object.create(null);\n\n function undef(key) {\n return opts[key] === undefined;\n }\n\n // Set up default options.\n if (undef('persistent')) opts.persistent = true;\n if (undef('ignoreInitial')) opts.ignoreInitial = false;\n if (undef('ignorePermissionErrors')) opts.ignorePermissionErrors = false;\n if (undef('interval')) opts.interval = 100;\n if (undef('binaryInterval')) opts.binaryInterval = 300;\n if (undef('disableGlobbing')) opts.disableGlobbing = false;\n this.enableBinaryInterval = opts.binaryInterval !== opts.interval;\n\n // Enable fsevents on OS X when polling isn't explicitly enabled.\n if (undef('useFsEvents')) opts.useFsEvents = !opts.usePolling;\n\n // If we can't use fsevents, ensure the options reflect it's disabled.\n if (!FsEventsHandler.canUse()) opts.useFsEvents = false;\n\n // Use polling on Mac if not using fsevents.\n // Other platforms use non-polling fs.watch.\n if (undef('usePolling') && !opts.useFsEvents) {\n opts.usePolling = process.platform === 'darwin';\n }\n\n // Global override (useful for end-developers that need to force polling for all\n // instances of chokidar, regardless of usage/dependency depth)\n var envPoll = process.env.CHOKIDAR_USEPOLLING;\n if (envPoll !== undefined) {\n var envLower = envPoll.toLowerCase();\n\n if (envLower === 'false' || envLower === '0') {\n opts.usePolling = false;\n } else if (envLower === 'true' || envLower === '1') {\n opts.usePolling = true;\n } else {\n opts.usePolling = !!envLower\n }\n }\n var envInterval = process.env.CHOKIDAR_INTERVAL;\n if (envInterval) {\n opts.interval = parseInt(envInterval);\n }\n\n // Editor atomic write normalization enabled by default with fs.watch\n if (undef('atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents;\n if (opts.atomic) this._pendingUnlinks = Object.create(null);\n\n if (undef('followSymlinks')) opts.followSymlinks = true;\n\n if (undef('awaitWriteFinish')) opts.awaitWriteFinish = false;\n if (opts.awaitWriteFinish === true) opts.awaitWriteFinish = {};\n var awf = opts.awaitWriteFinish;\n if (awf) {\n if (!awf.stabilityThreshold) awf.stabilityThreshold = 2000;\n if (!awf.pollInterval) awf.pollInterval = 100;\n\n this._pendingWrites = Object.create(null);\n }\n if (opts.ignored) opts.ignored = arrify(opts.ignored);\n\n this._isntIgnored = function(path, stat) {\n return !this._isIgnored(path, stat);\n }.bind(this);\n\n var readyCalls = 0;\n this._emitReady = function() {\n if (++readyCalls >= this._readyCount) {\n this._emitReady = Function.prototype;\n this._readyEmitted = true;\n // use process.nextTick to allow time for listener to be bound\n process.nextTick(this.emit.bind(this, 'ready'));\n }\n }.bind(this);\n\n this.options = opts;\n\n // You’re frozen when your heart’s not open.\n Object.freeze(opts);\n}\n\ninherits(FSWatcher, EventEmitter);\n\n// Common helpers\n// --------------\n\n// Private method: Normalize and emit events\n//\n// * event - string, type of event\n// * path - string, file or directory path\n// * val[1..3] - arguments to be passed with event\n//\n// Returns the error if defined, otherwise the value of the\n// FSWatcher instance's `closed` flag\nFSWatcher.prototype._emit = function(event, path, val1, val2, val3) {\n if (this.options.cwd) path = sysPath.relative(this.options.cwd, path);\n var args = [event, path];\n if (val3 !== undefined) args.push(val1, val2, val3);\n else if (val2 !== undefined) args.push(val1, val2);\n else if (val1 !== undefined) args.push(val1);\n\n var awf = this.options.awaitWriteFinish;\n if (awf && this._pendingWrites[path]) {\n this._pendingWrites[path].lastChange = new Date();\n return this;\n }\n\n if (this.options.atomic) {\n if (event === 'unlink') {\n this._pendingUnlinks[path] = args;\n setTimeout(function() {\n Object.keys(this._pendingUnlinks).forEach(function(path) {\n this.emit.apply(this, this._pendingUnlinks[path]);\n this.emit.apply(this, ['all'].concat(this._pendingUnlinks[path]));\n delete this._pendingUnlinks[path];\n }.bind(this));\n }.bind(this), typeof this.options.atomic === \"number\"\n ? this.options.atomic\n : 100);\n return this;\n } else if (event === 'add' && this._pendingUnlinks[path]) {\n event = args[0] = 'change';\n delete this._pendingUnlinks[path];\n }\n }\n\n var emitEvent = function() {\n this.emit.apply(this, args);\n if (event !== 'error') this.emit.apply(this, ['all'].concat(args));\n }.bind(this);\n\n if (awf && (event === 'add' || event === 'change') && this._readyEmitted) {\n var awfEmit = function(err, stats) {\n if (err) {\n event = args[0] = 'error';\n args[1] = err;\n emitEvent();\n } else if (stats) {\n // if stats doesn't exist the file must have been deleted\n if (args.length > 2) {\n args[2] = stats;\n } else {\n args.push(stats);\n }\n emitEvent();\n }\n };\n\n this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);\n return this;\n }\n\n if (event === 'change') {\n if (!this._throttle('change', path, 50)) return this;\n }\n\n if (\n this.options.alwaysStat && val1 === undefined &&\n (event === 'add' || event === 'addDir' || event === 'change')\n ) {\n var fullPath = this.options.cwd ? sysPath.join(this.options.cwd, path) : path;\n fs.stat(fullPath, function(error, stats) {\n // Suppress event when fs.stat fails, to avoid sending undefined 'stat'\n if (error || !stats) return;\n\n args.push(stats);\n emitEvent();\n });\n } else {\n emitEvent();\n }\n\n return this;\n};\n\n// Private method: Common handler for errors\n//\n// * error - object, Error instance\n//\n// Returns the error if defined, otherwise the value of the\n// FSWatcher instance's `closed` flag\nFSWatcher.prototype._handleError = function(error) {\n var code = error && error.code;\n var ipe = this.options.ignorePermissionErrors;\n if (error &&\n code !== 'ENOENT' &&\n code !== 'ENOTDIR' &&\n (!ipe || (code !== 'EPERM' && code !== 'EACCES'))\n ) this.emit('error', error);\n return error || this.closed;\n};\n\n// Private method: Helper utility for throttling\n//\n// * action - string, type of action being throttled\n// * path - string, path being acted upon\n// * timeout - int, duration of time to suppress duplicate actions\n//\n// Returns throttle tracking object or false if action should be suppressed\nFSWatcher.prototype._throttle = function(action, path, timeout) {\n if (!(action in this._throttled)) {\n this._throttled[action] = Object.create(null);\n }\n var throttled = this._throttled[action];\n if (path in throttled) {\n throttled[path].count++;\n return false;\n }\n function clear() {\n var count = throttled[path] ? throttled[path].count : 0;\n delete throttled[path];\n clearTimeout(timeoutObject);\n return count;\n }\n var timeoutObject = setTimeout(clear, timeout);\n throttled[path] = {timeoutObject: timeoutObject, clear: clear, count: 0};\n return throttled[path];\n};\n\n// Private method: Awaits write operation to finish\n//\n// * path - string, path being acted upon\n// * threshold - int, time in milliseconds a file size must be fixed before\n// acknowledging write operation is finished\n// * awfEmit - function, to be called when ready for event to be emitted\n// Polls a newly created file for size variations. When files size does not\n// change for 'threshold' milliseconds calls callback.\nFSWatcher.prototype._awaitWriteFinish = function(path, threshold, event, awfEmit) {\n var timeoutHandler;\n\n var fullPath = path;\n if (this.options.cwd && !isAbsolute(path)) {\n fullPath = sysPath.join(this.options.cwd, path);\n }\n\n var now = new Date();\n\n var awaitWriteFinish = (function (prevStat) {\n fs.stat(fullPath, function(err, curStat) {\n if (err || !(path in this._pendingWrites)) {\n if (err && err.code !== 'ENOENT') awfEmit(err);\n return;\n }\n\n var now = new Date();\n\n if (prevStat && curStat.size != prevStat.size) {\n this._pendingWrites[path].lastChange = now;\n }\n\n if (now - this._pendingWrites[path].lastChange >= threshold) {\n delete this._pendingWrites[path];\n awfEmit(null, curStat);\n } else {\n timeoutHandler = setTimeout(\n awaitWriteFinish.bind(this, curStat),\n this.options.awaitWriteFinish.pollInterval\n );\n }\n }.bind(this));\n }.bind(this));\n\n if (!(path in this._pendingWrites)) {\n this._pendingWrites[path] = {\n lastChange: now,\n cancelWait: function() {\n delete this._pendingWrites[path];\n clearTimeout(timeoutHandler);\n return event;\n }.bind(this)\n };\n timeoutHandler = setTimeout(\n awaitWriteFinish.bind(this),\n this.options.awaitWriteFinish.pollInterval\n );\n }\n};\n\n// Private method: Determines whether user has asked to ignore this path\n//\n// * path - string, path to file or directory\n// * stats - object, result of fs.stat\n//\n// Returns boolean\nvar dotRe = /\\..*\\.(sw[px])$|\\~$|\\.subl.*\\.tmp/;\nFSWatcher.prototype._isIgnored = function(path, stats) {\n if (this.options.atomic && dotRe.test(path)) return true;\n\n if (!this._userIgnored) {\n var cwd = this.options.cwd;\n var ignored = this.options.ignored;\n if (cwd && ignored) {\n ignored = ignored.map(function (path) {\n if (typeof path !== 'string') return path;\n return upath.normalize(isAbsolute(path) ? path : sysPath.join(cwd, path));\n });\n }\n var paths = arrify(ignored)\n .filter(function(path) {\n return typeof path === 'string' && !isGlob(path);\n }).map(function(path) {\n return path + '/**';\n });\n this._userIgnored = anymatch(\n this._globIgnored.concat(ignored).concat(paths)\n );\n }\n\n return this._userIgnored([path, stats]);\n};\n\n// Private method: Provides a set of common helpers and properties relating to\n// symlink and glob handling\n//\n// * path - string, file, directory, or glob pattern being watched\n// * depth - int, at any depth > 0, this isn't a glob\n//\n// Returns object containing helpers for this path\nvar replacerRe = /^\\.[\\/\\\\]/;\nFSWatcher.prototype._getWatchHelpers = function(path, depth) {\n path = path.replace(replacerRe, '');\n var watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path);\n var fullWatchPath = sysPath.resolve(watchPath);\n var hasGlob = watchPath !== path;\n var globFilter = hasGlob ? anymatch(path) : false;\n var follow = this.options.followSymlinks;\n var globSymlink = hasGlob && follow ? null : false;\n\n var checkGlobSymlink = function(entry) {\n // only need to resolve once\n // first entry should always have entry.parentDir === ''\n if (globSymlink == null) {\n globSymlink = entry.fullParentDir === fullWatchPath ? false : {\n realPath: entry.fullParentDir,\n linkPath: fullWatchPath\n };\n }\n\n if (globSymlink) {\n return entry.fullPath.replace(globSymlink.realPath, globSymlink.linkPath);\n }\n\n return entry.fullPath;\n };\n\n var entryPath = function(entry) {\n return sysPath.join(watchPath,\n sysPath.relative(watchPath, checkGlobSymlink(entry))\n );\n };\n\n var filterPath = function(entry) {\n if (entry.stat && entry.stat.isSymbolicLink()) return filterDir(entry);\n var resolvedPath = entryPath(entry);\n return (!hasGlob || globFilter(resolvedPath)) &&\n this._isntIgnored(resolvedPath, entry.stat) &&\n (this.options.ignorePermissionErrors ||\n this._hasReadPermissions(entry.stat));\n }.bind(this);\n\n var getDirParts = function(path) {\n if (!hasGlob) return false;\n var parts = [];\n var expandedPath = braces.expand(path);\n expandedPath.forEach(function(path) {\n parts.push(sysPath.relative(watchPath, path).split(/[\\/\\\\]/));\n });\n return parts;\n };\n\n var dirParts = getDirParts(path);\n if (dirParts) {\n dirParts.forEach(function(parts) {\n if (parts.length > 1) parts.pop();\n });\n }\n var unmatchedGlob;\n\n var filterDir = function(entry) {\n if (hasGlob) {\n var entryParts = getDirParts(checkGlobSymlink(entry));\n var globstar = false;\n unmatchedGlob = !dirParts.some(function(parts) {\n return parts.every(function(part, i) {\n if (part === '**') globstar = true;\n return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i]);\n });\n });\n }\n return !unmatchedGlob && this._isntIgnored(entryPath(entry), entry.stat);\n }.bind(this);\n\n return {\n followSymlinks: follow,\n statMethod: follow ? 'stat' : 'lstat',\n path: path,\n watchPath: watchPath,\n entryPath: entryPath,\n hasGlob: hasGlob,\n globFilter: globFilter,\n filterPath: filterPath,\n filterDir: filterDir\n };\n};\n\n// Directory helpers\n// -----------------\n\n// Private method: Provides directory tracking objects\n//\n// * directory - string, path of the directory\n//\n// Returns the directory's tracking object\nFSWatcher.prototype._getWatchedDir = function(directory) {\n var dir = sysPath.resolve(directory);\n var watcherRemove = this._remove.bind(this);\n if (!(dir in this._watched)) this._watched[dir] = {\n _items: Object.create(null),\n add: function(item) {\n if (item !== '.' && item !== '..') this._items[item] = true;\n },\n remove: function(item) {\n delete this._items[item];\n if (!this.children().length) {\n fs.readdir(dir, function(err) {\n if (err) watcherRemove(sysPath.dirname(dir), sysPath.basename(dir));\n });\n }\n },\n has: function(item) {return item in this._items;},\n children: function() {return Object.keys(this._items);}\n };\n return this._watched[dir];\n};\n\n// File helpers\n// ------------\n\n// Private method: Check for read permissions\n// Based on this answer on SO: http://stackoverflow.com/a/11781404/1358405\n//\n// * stats - object, result of fs.stat\n//\n// Returns boolean\nFSWatcher.prototype._hasReadPermissions = function(stats) {\n return Boolean(4 & parseInt(((stats && stats.mode) & 0x1ff).toString(8)[0], 10));\n};\n\n// Private method: Handles emitting unlink events for\n// files and directories, and via recursion, for\n// files and directories within directories that are unlinked\n//\n// * directory - string, directory within which the following item is located\n// * item - string, base path of item/directory\n//\n// Returns nothing\nFSWatcher.prototype._remove = function(directory, item) {\n // if what is being deleted is a directory, get that directory's paths\n // for recursive deleting and cleaning of watched object\n // if it is not a directory, nestedDirectoryChildren will be empty array\n var path = sysPath.join(directory, item);\n var fullPath = sysPath.resolve(path);\n var isDirectory = this._watched[path] || this._watched[fullPath];\n\n // prevent duplicate handling in case of arriving here nearly simultaneously\n // via multiple paths (such as _handleFile and _handleDir)\n if (!this._throttle('remove', path, 100)) return;\n\n // if the only watched file is removed, watch for its return\n var watchedDirs = Object.keys(this._watched);\n if (!isDirectory && !this.options.useFsEvents && watchedDirs.length === 1) {\n this.add(directory, item, true);\n }\n\n // This will create a new entry in the watched object in either case\n // so we got to do the directory check beforehand\n var nestedDirectoryChildren = this._getWatchedDir(path).children();\n\n // Recursively remove children directories / files.\n nestedDirectoryChildren.forEach(function(nestedItem) {\n this._remove(path, nestedItem);\n }, this);\n\n // Check if item was on the watched list and remove it\n var parent = this._getWatchedDir(directory);\n var wasTracked = parent.has(item);\n parent.remove(item);\n\n // If we wait for this file to be fully written, cancel the wait.\n var relPath = path;\n if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path);\n if (this.options.awaitWriteFinish && this._pendingWrites[relPath]) {\n var event = this._pendingWrites[relPath].cancelWait();\n if (event === 'add') return;\n }\n\n // The Entry will either be a directory that just got removed\n // or a bogus entry to a file, in either case we have to remove it\n delete this._watched[path];\n delete this._watched[fullPath];\n var eventName = isDirectory ? 'unlinkDir' : 'unlink';\n if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);\n\n // Avoid conflicts if we later create another file with the same name\n if (!this.options.useFsEvents) {\n this._closePath(path);\n }\n};\n\nFSWatcher.prototype._closePath = function(path) {\n if (!this._closers[path]) return;\n this._closers[path].forEach(function(closer) {\n closer();\n });\n delete this._closers[path];\n this._getWatchedDir(sysPath.dirname(path)).remove(sysPath.basename(path));\n}\n\n// Public method: Adds paths to be watched on an existing FSWatcher instance\n\n// * paths - string or array of strings, file/directory paths and/or globs\n// * _origAdd - private boolean, for handling non-existent paths to be watched\n// * _internal - private boolean, indicates a non-user add\n\n// Returns an instance of FSWatcher for chaining.\nFSWatcher.prototype.add = function(paths, _origAdd, _internal) {\n var disableGlobbing = this.options.disableGlobbing;\n var cwd = this.options.cwd;\n this.closed = false;\n paths = flatten(arrify(paths));\n\n if (!paths.every(isString)) {\n throw new TypeError('Non-string provided as watch path: ' + paths);\n }\n\n if (cwd) paths = paths.map(function(path) {\n var absPath;\n if (isAbsolute(path)) {\n absPath = path;\n } else if (path[0] === '!') {\n absPath = '!' + sysPath.join(cwd, path.substring(1));\n } else {\n absPath = sysPath.join(cwd, path);\n }\n\n // Check `path` instead of `absPath` because the cwd portion can't be a glob\n if (disableGlobbing || !isGlob(path)) {\n return absPath;\n } else {\n return normalizePath(absPath);\n }\n });\n\n // set aside negated glob strings\n paths = paths.filter(function(path) {\n if (path[0] === '!') {\n this._ignoredPaths[path.substring(1)] = true;\n } else {\n // if a path is being added that was previously ignored, stop ignoring it\n delete this._ignoredPaths[path];\n delete this._ignoredPaths[path + '/**'];\n\n // reset the cached userIgnored anymatch fn\n // to make ignoredPaths changes effective\n this._userIgnored = null;\n\n return true;\n }\n }, this);\n\n if (this.options.useFsEvents && FsEventsHandler.canUse()) {\n if (!this._readyCount) this._readyCount = paths.length;\n if (this.options.persistent) this._readyCount *= 2;\n paths.forEach(this._addToFsEvents, this);\n } else {\n if (!this._readyCount) this._readyCount = 0;\n this._readyCount += paths.length;\n asyncEach(paths, function(path, next) {\n this._addToNodeFs(path, !_internal, 0, 0, _origAdd, function(err, res) {\n if (res) this._emitReady();\n next(err, res);\n }.bind(this));\n }.bind(this), function(error, results) {\n results.forEach(function(item) {\n if (!item || this.closed) return;\n this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));\n }, this);\n }.bind(this));\n }\n\n return this;\n};\n\n// Public method: Close watchers or start ignoring events from specified paths.\n\n// * paths - string or array of strings, file/directory paths and/or globs\n\n// Returns instance of FSWatcher for chaining.\nFSWatcher.prototype.unwatch = function(paths) {\n if (this.closed) return this;\n paths = flatten(arrify(paths));\n\n paths.forEach(function(path) {\n // convert to absolute path unless relative path already matches\n if (!isAbsolute(path) && !this._closers[path]) {\n if (this.options.cwd) path = sysPath.join(this.options.cwd, path);\n path = sysPath.resolve(path);\n }\n\n this._closePath(path);\n\n this._ignoredPaths[path] = true;\n if (path in this._watched) {\n this._ignoredPaths[path + '/**'] = true;\n }\n\n // reset the cached userIgnored anymatch fn\n // to make ignoredPaths changes effective\n this._userIgnored = null;\n }, this);\n\n return this;\n};\n\n// Public method: Close watchers and remove all listeners from watched paths.\n\n// Returns instance of FSWatcher for chaining.\nFSWatcher.prototype.close = function() {\n if (this.closed) return this;\n\n this.closed = true;\n Object.keys(this._closers).forEach(function(watchPath) {\n this._closers[watchPath].forEach(function(closer) {\n closer();\n });\n delete this._closers[watchPath];\n }, this);\n this._watched = Object.create(null);\n\n this.removeAllListeners();\n return this;\n};\n\n// Public method: Expose list of watched paths\n\n// Returns object w/ dir paths as keys and arrays of contained paths as values.\nFSWatcher.prototype.getWatched = function() {\n var watchList = {};\n Object.keys(this._watched).forEach(function(dir) {\n var key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;\n watchList[key || '.'] = Object.keys(this._watched[dir]._items).sort();\n }.bind(this));\n return watchList;\n};\n\n// Attach watch handler prototype methods\nfunction importHandler(handler) {\n Object.keys(handler.prototype).forEach(function(method) {\n FSWatcher.prototype[method] = handler.prototype[method];\n });\n}\nimportHandler(NodeFsHandler);\nif (FsEventsHandler.canUse()) importHandler(FsEventsHandler);\n\n// Export FSWatcher class\nexports.FSWatcher = FSWatcher;\n\n// Public function: Instantiates watcher with paths to be tracked.\n\n// * paths - string or array of strings, file/directory paths and/or globs\n// * options - object, chokidar options\n\n// Returns an instance of FSWatcher for chaining.\nexports.watch = function(paths, options) {\n return new FSWatcher(options).add(paths);\n};\n\n\n//# sourceURL=webpack://@nicolo-ribaudo/chokidar-2/./chokidar/index.js?");
/***/ }),
/***/ "./chokidar/lib/fsevents-handler.js":
/*!******************************************!*\
!*** ./chokidar/lib/fsevents-handler.js ***!
\******************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
eval("\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nvar sysPath = __webpack_require__(/*! path */ \"path\");\nvar readdirp = __webpack_require__(/*! readdirp */ \"./node_modules/readdirp/readdirp.js\");\nvar fsevents;\ntry { fsevents = __webpack_require__(Object(function webpackMissingModule() { var e = new Error(\"Cannot find module 'fsevents'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }())); } catch (error) {\n if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error)\n}\n\n// fsevents instance helper functions\n\n// object to hold per-process fsevents instances\n// (may be shared across chokidar FSWatcher instances)\nvar FSEventsWatchers = Object.create(null);\n\n// Threshold of duplicate path prefixes at which to start\n// consolidating going forward\nvar consolidateThreshhold = 10;\n\n// Private function: Instantiates the fsevents interface\n\n// * path - string, path to be watched\n// * callback - function, called when fsevents is bound and ready\n\n// Returns new fsevents instance\nfunction createFSEventsInstance(path, callback) {\n return (new fsevents(path)).on('fsevent', callback).start();\n}\n\n// Private function: Instantiates the fsevents interface or binds listeners\n// to an existing one covering the same file tree\n\n// * path - string, path to be watched\n// * realPath - string, real path (in case of symlinks)\n// * listener - function, called when fsevents emits events\n// * rawEmitter - function, passes data to listeners of the 'raw' event\n\n// Returns close function\nfunction setFSEventsListener(path, realPath, listener, rawEmitter) {\n var watchPath = sysPath.extname(path) ? sysPath.dirname(path) : path;\n var watchContainer;\n var parentPath = sysPath.dirname(watchPath);\n\n // If we've accumulated a substantial number of paths that\n // could have been consolidated by watching one directory\n // above the current one, create a watcher on the parent\n // path instead, so that we do consolidate going forward.\n if (couldConsolidate(parentPath)) {\n watchPath = parentPath;\n }\n\n var resolvedPath = sysPath.resolve(path);\n var hasSymlink = resolvedPath !== realPath;\n function filteredListener(fullPath, flags, info) {\n if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath);\n if (\n fullPath === resolvedPath ||\n !fullPath.indexOf(resolvedPath + sysPath.sep)\n ) listener(fullPath, flags, info);\n }\n\n // check if there is already a watcher on a parent path\n // modifies `watchPath` to the parent path when it finds a match\n function watchedParent() {\n return Object.keys(FSEventsWatchers).some(function(watchedPath) {\n // condition is met when indexOf returns 0\n if (!realPath.indexOf(sysPath.resolve(watchedPath) + sysPath.sep)) {\n watchPath = watchedPath;\n return true;\n }\n });\n }\n\n if (watchPath in FSEventsWatchers || watchedParent()) {\n watchContainer = FSEventsWatchers[watchPath];\n watchContainer.listeners.push(filteredListener);\n } else {\n watchContainer = FSEventsWatchers[watchPath] = {\n listeners: [filteredListener],\n rawEmitters: [rawEmitter],\n watcher: createFSEventsInstance(watchPath, function(fullPath, flags) {\n var info = fsevents.getInfo(fullPath, flags);\n watchContainer.listeners.forEach(function(listener) {\n listener(fullPath, flags, info);\n });\n watchContainer.rawEmitters.forEach(function(emitter) {\n emitter(info.event, fullPath, info);\n });\n })\n };\n }\n var listenerIndex = watchContainer.listeners.length - 1;\n\n // removes this instance's listeners and closes the underlying fsevents\n // instance if there are no more listeners left\n return function close() {\n delete watchContainer.listeners[listenerIndex];\n delete watchContainer.rawEmitters[listenerIndex];\n if (!Object.keys(watchContainer.listeners).length) {\n watchContainer.watcher.stop();\n delete FSEventsWatchers[watchPath];\n }\n };\n}\n\n// Decide whether or not we should start a new higher-level\n// parent watcher\nfunction couldConsolidate(path) {\n var keys = Object.keys(FSEventsWatchers);\n var count = 0;\n\n for (var i = 0, len = keys.length; i < len; ++i) {\n var watchPath = keys[i];\n if (watchPath.indexOf(path) === 0) {\n count++;\n if (count >= consolidateThreshhold) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction isConstructor(obj) {\n return obj.prototype !== undefined && obj.prototype.constructor !== undefined;\n}\n\n// returns boolean indicating whether fsevents can be used\nfunction canUse() {\n return fsevents && Object.keys(FSEventsWatchers).length < 128 && isConstructor(fsevents);\n}\n\n// determines subdirectory traversal levels from root to path\nfunction depth(path, root) {\n var i = 0;\n while (!path.indexOf(root) && (path = sysPath.dirname(path)) !== root) i++;\n return i;\n}\n\n// fake constructor for attaching fsevents-specific prototype methods that\n// will be copied to FSWatcher's prototype\nfunction FsEventsHandler() {}\n\n// Private method: Handle symlinks encountered during directory scan\n\n// * watchPath - string, file/dir path to be watched with fsevents\n// * realPath - string, real path (in case of symlinks)\n// * transform - function, path transformer\n// * globFilter - function, path filter in case a glob pattern was provided\n\n// Returns close function for the watcher instance\nFsEventsHandler.prototype._watchWithFsEvents =\nfunction(watchPath, realPath, transform, globFilter) {\n if (this._isIgnored(watchPath)) return;\n var watchCallback = function(fullPath, flags, info) {\n if (\n this.options.depth !== undefined &&\n depth(fullPath, realPath) > this.options.depth\n ) return;\n var path = transform(sysPath.join(\n watchPath, sysPath.relative(watchPath, fullPath)\n ));\n if (globFilter && !globFilter(path)) return;\n // ensure directories are tracked\n var parent = sysPath.dirname(path);\n var item = sysPath.basename(path);\n var watchedDir = this._getWatchedDir(\n info.type === 'directory' ? path : parent\n );\n var checkIgnored = function(stats) {\n if (this._isIgnored(path, stats)) {\n this._ignoredPaths[path] = true;\n if (stats && stats.isDirectory()) {\n this._ignoredPaths[path + '/**/*'] = true;\n }\n return true;\n } else {\n delete this._ignoredPaths[path];\n delete this._ignoredPaths[path + '/**/*'];\n }\n }.bind(this);\n\n var handleEvent = function(event) {\n if (checkIgnored()) return;\n\n if (event === 'unlink') {\n // suppress unlink events on never before seen files\n if (info.type === 'directory' || watchedDir.has(item)) {\n this._remove(parent, item);\n }\n } else {\n if (event === 'add') {\n // track new directories\n if (info.type === 'directory') this._getWatchedDir(path);\n\n if (info.type === 'symlink' && this.options.followSymlinks) {\n // push symlinks back to the top of the stack to get handled\n var curDepth = this.options.depth === undefined ?\n undefined : depth(fullPath, realPath) + 1;\n return this._addToFsEvents(path, false, true, curDepth);\n } else {\n // track new paths\n // (other than symlinks being followed, which will be tracked soon)\n this._getWatchedDir(parent).add(item);\n }\n }\n var eventName = info.type === 'directory' ? event + 'Dir' : event;\n this._emit(eventName, path);\n if (eventName === 'addDir') this._addToFsEvents(path, false, true);\n }\n }.bind(this);\n\n function addOrChange() {\n handleEvent(watchedDir.has(item) ? 'change' : 'add');\n }\n function checkFd() {\n fs.open(path, 'r', function(error, fd) {\n if (error) {\n error.code !== 'EACCES' ?\n handleEvent('unlink') : addOrChange();\n } else {\n fs.close(fd, function(err) {\n err && err.code !== 'EACCES' ?\n handleEvent('unlink') : addOrChange();\n });\n }\n });\n }\n // correct for wrong events emitted\n var wrongEventFlags = [\n 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912\n ];\n if (wrongEventFlags.indexOf(flags) !== -1 || info.event === 'unknown') {\n if (typeof this.options.ignored === 'function') {\n fs.stat(path, function(error, stats) {\n if (checkIgnored(stats)) return;\n stats ? addOrChange() : handleEvent('unlink');\n });\n } else {\n checkFd();\n }\n } else {\n switch (info.event) {\n case 'created':\n case 'modified':\n return addOrChange();\n case 'deleted':\n case 'moved':\n return checkFd();\n }\n }\n }.bind(this);\n\n var closer = setFSEventsListener(\n watchPath,\n realPath,\n watchCallback,\n this.emit.bind(this, 'raw')\n );\n\n this._emitReady();\n return closer;\n};\n\n// Private method: Handle symlinks encountered during directory scan\n\n// * linkPath - string, path to symlink\n// * fullPath - string, absolute path to the symlink\n// * transform - function, pre-existing path transformer\n// * curDepth - int, level of subdirectories traversed to where symlink is\n\n// Returns nothing\nFsEventsHandler.prototype._handleFsEventsSymlink =\nfunction(linkPath, fullPath, transform, curDepth) {\n // don't follow the same symlink more than once\n if (this._symlinkPaths[fullPath]) return;\n else this._symlinkPaths[fullPath] = true;\n\n this._readyCount++;\n\n fs.realpath(linkPath, function(error, linkTarget) {\n if (this._handleError(error) || this._isIgnored(linkTarget)) {\n return this._emitReady();\n }\n\n this._readyCount++;\n\n // add the linkTarget for watching with a wrapper for transform\n // that causes emitted paths to incorporate the link's path\n this._addToFsEvents(linkTarget || linkPath, function(path) {\n var dotSlash = '.' + sysPath.sep;\n var aliasedPath = linkPath;\n if (linkTarget && linkTarget !== dotSlash) {\n aliasedPath = path.replace(linkTarget, linkPath);\n } else if (path !== dotSlash) {\n aliasedPath = sysPath.join(linkPath, path);\n }\n return transform(aliasedPath);\n }, false, curDepth);\n }.bind(this));\n};\n\n// Private method: Handle added path with fsevents\n\n// * path - string, file/directory path or glob pattern\n// * transform - function, converts working path to what the user expects\n// * forceAdd - boolean, ensure add is emitted\n// * priorDepth - int, level of subdirectories already traversed\n\n// Returns nothing\nFsEventsHandler.prototype._addToFsEvents =\nfunction(path, transform, forceAdd, priorDepth) {\n\n // applies transform if provided, otherwise returns same value\n var processPath = typeof transform === 'function' ?\n transform : function(val) { return val; };\n\n var emitAdd = function(newPath, stats) {\n var pp = processPath(newPath);\n var isDir = stats.isDirectory();\n var dirObj = this._getWatchedDir(sysPath.dirname(pp));\n var base = sysPath.basename(pp);\n\n // ensure empty dirs get tracked\n if (isDir) this._getWatchedDir(pp);\n\n if (dirObj.has(base)) return;\n dirObj.add(base);\n\n if (!this.options.ignoreInitial || forceAdd === true) {\n this._emit(isDir ? 'addDir' : 'add', pp, stats);\n }\n }.bind(this);\n\n var wh = this._getWatchHelpers(path);\n\n // evaluate what is at the path we're being asked to watch\n fs[wh.statMethod](wh.watchPath, function(error, stats) {\n if (this._handleError(error) || this._isIgnored(wh.watchPath, stats)) {\n this._emitReady();\n return this._emitReady();\n }\n\n if (stats.isDirectory()) {\n // emit addDir unless this is a glob parent\n if (!wh.globFilter) emitAdd(processPath(path), stats);\n\n // don't recurse further if it would exceed depth setting\n if (priorDepth && priorDepth > this.options.depth) return;\n\n // scan the contents of the dir\n readdirp({\n root: wh.watchPath,\n entryType: 'all',\n fileFilter: wh.filterPath,\n directoryFilter: wh.filterDir,\n lstat: true,\n depth: this.options.depth - (priorDepth || 0)\n }).on('data', function(entry) {\n // need to check filterPath on dirs b/c filterDir is less restrictive\n if (entry.stat.isDirectory() && !wh.filterPath(entry)) return;\n\n var joinedPath = sysPath.join(wh.watchPath, entry.path);\n var fullPath = entry.fullPath;\n\n if (wh.followSymlinks && entry.stat.isSymbolicLink()) {\n // preserve the current depth here since it can't be derived from\n // real paths past the symlink\n var curDepth = this.options.depth === undefined ?\n undefined : depth(joinedPath, sysPath.resolve(wh.watchPath)) + 1;\n\n this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth);\n } else {\n emitAdd(joinedPath, entry.stat);\n }\n }.bind(this)).on('error', function() {\n // Ignore readdirp errors\n }).on('end', this._emitReady);\n } else {\n emitAdd(wh.watchPath, stats);\n this._emitReady();\n }\n }.bind(this));\n\n if (this.options.persistent && forceAdd !== true) {\n var initWatch = function(error, realPath) {\n if (this.closed) return;\n var closer = this._watchWithFsEvents(\n wh.watchPath,\n sysPath.resolve(realPath || wh.watchPath),\n processPath,\n wh.globFilter\n );\n if (closer) {\n this._closers[path] = this._closers[path] || [];\n this._closers[path].push(closer);\n }\n }.bind(this);\n\n if (typeof transform === 'function') {\n // realpath has already been resolved\n initWatch();\n } else {\n fs.realpath(wh.watchPath, initWatch);\n }\n }\n};\n\nmodule.exports = FsEventsHandler;\nmodule.exports.canUse = canUse;\n\n\n//# sourceURL=webpack://@nicolo-ribaudo/chokidar-2/./chokidar/lib/fsevents-handler.js?");
/***/ }),
/***/ "./chokidar/lib/nodefs-handler.js":
/*!****************************************!*\
!*** ./chokidar/lib/nodefs-handler.js ***!
\****************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
eval("\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\nvar sysPath = __webpack_require__(/*! path */ \"path\");\nvar readdirp = __webpack_require__(/*! readdirp */ \"./node_modules/readdirp/readdirp.js\");\nvar isBinaryPath = __webpack_require__(/*! is-binary-path */ \"./node_modules/is-binary-path/index.js\");\n\n// fs.watch helpers\n\n// object to hold per-process fs.watch instances\n// (may be shared across chokidar FSWatcher instances)\nvar FsWatchInstances = Object.create(null);\n\n\n// Private function: Instantiates the fs.watch interface\n\n// * path - string, path to be watched\n// * options - object, options to be passed to fs.watch\n// * listener - function, main event handler\n// * errHandler - function, handler which emits info about errors\n// * emitRaw - function, handler which emits raw event data\n\n// Returns new fsevents instance\nfunction createFsWatchInstance(path, options, listener, errHandler, emitRaw) {\n var handleEvent = function(rawEvent, evPath) {\n listener(path);\n emitRaw(rawEvent, evPath, {watchedPath: path});\n\n // emit based on events occurring for files from a directory's watcher in\n // case the file's watcher misses it (and rely on throttling to de-dupe)\n if (evPath && path !== evPath) {\n fsWatchBroadcast(\n sysPath.resolve(path, evPath), 'listeners', sysPath.join(path, evPath)\n );\n }\n };\n try {\n return fs.watch(path, options, handleEvent);\n } catch (error) {\n errHandler(error);\n }\n}\n\n// Private function: Helper for passing fs.watch event data to a\n// collection of listeners\n\n// * fullPath - string, absolute path bound to the fs.watch instance\n// * type - string, listener type\n// * val[1..3] - arguments to be passed to listeners\n\n// Returns nothing\nfunction fsWatchBroadcast(fullPath, type, val1, val2, val3) {\n if (!FsWatchInstances[fullPath]) return;\n FsWatchInstances[fullPath][type].forEach(function(listener) {\n listener(val1, val2, val3);\n });\n}\n\n// Private function: Instantiates the fs.watch interface or binds listeners\n// to an existing one covering the same file system entry\n\n// * path - string, path to be watched\n// * fullPath - string, absolute path\n// * options - object, options to be passed to fs.watch\n// * handlers - object, container for event listener functions\n\n// Returns close function\nfunction setFsWatchListener(path, fullPath, options, handlers) {\n var listener = handlers.listener;\n var errHandler = handlers.errHandler;\n var rawEmitter = handlers.rawEmitter;\n var container = FsWatchInstances[fullPath];\n var watcher;\n if (!options.persistent) {\n watcher = createFsWatchInstance(\n path, options, listener, errHandler, rawEmitter\n );\n return watcher.close.bind(watcher);\n }\n if (!container) {\n watcher = createFsWatchInstance(\n path,\n options,\n fsWatchBroadcast.bind(null, fullPath, 'listeners'),\n errHandler, // no need to use broadcast here\n fsWatchBroadcast.bind(null, fullPath, 'rawEmitters')\n );\n if (!watcher) return;\n var broadcastErr = fsWatchBroadcast.bind(null, fullPath, 'errHandlers');\n watcher.on('error', function(error) {\n container.watcherUnusable = true; // documented since Node 10.4.1\n // Workaround for https://github.com/joyent/node/issues/4337\n if (process.platform === 'win32' && error.code === 'EPERM') {\n fs.open(path, 'r', function(err, fd) {\n if (!err) fs.close(fd, function(err) {\n if (!err) broadcastErr(error);\n });\n });\n } else {\n broadcastErr(error);\n }\n });\n container = FsWatchInstances[fullPath] = {\n listeners: [listener],\n errHandlers: [errHandler],\n rawEmitters: [rawEmitter],\n watcher: watcher\n };\n } else {\n container.listeners.push(listener);\n container.errHandlers.push(errHandler);\n container.rawEmitters.push(rawEmitter);\n }\n var listenerIndex = container.listeners.length - 1;\n\n // removes this instance's listeners and closes the underlying fs.watch\n // instance if there are no more listeners left\n return function close() {\n delete container.listeners[listenerIndex];\n delete container.errHandlers[listenerIndex];\n delete container.rawEmitters[listenerIndex];\n if (!Object.keys(container.listeners).length) {\n if (!container.watcherUnusable) { // check to protect against issue #730\n container.watcher.close();\n }\n delete FsWatchInstances[fullPath];\n }\n };\n}\n\n// fs.watchFile helpers\n\n// object to hold per-process fs.watchFile instances\n// (may be shared across chokidar FSWatcher instances)\nvar FsWatchFileInstances = Object.create(null);\n\n// Private function: Instantiates the fs.watchFile interface or binds listeners\n// to an existing one covering the same file system entry\n\n// * path - string, path to be watched\n// * fullPath - string, absolute path\n// * options - object, options to be passed to fs.watchFile\n// * handlers - object, container for event listener functions\n\n// Returns close function\nfunction setFsWatchFileListener(path, fullPath, options, handlers) {\n var listener = handlers.listener;\n var rawEmitter = handlers.rawEmitter;\n var container = FsWatchFileInstances[fullPath];\n var listeners = [];\n var rawEmitters = [];\n if (\n container && (\n container.options.persistent < options.persistent ||\n container.options.interval > options.interval\n )\n ) {\n // \"Upgrade\" the watcher to persistence or a quicker interval.\n // This creates some unlikely edge case issues if the user mixes\n // settings in a very weird way, but solving for those cases\n // doesn't seem worthwhile for the added complexity.\n listeners = container.listeners;\n rawEmitters = container.rawEmitters;\n fs.unwatchFile(fullPath);\n container = false;\n }\n if (!container) {\n listeners.push(listener);\n rawEmitters.push(rawEmitter);\n container = FsWatchFileInstances[fullPath] = {\n listeners: listeners,\n rawEmitters: rawEmitters,\n options: options,\n watcher: fs.watchFile(fullPath, options, function(curr, prev) {\n container.rawEmitters.forEach(function(rawEmitter) {\n rawEmitter('change', fullPath, {curr: curr, prev: prev});\n });\n var currmtime = curr.mtime.getTime();\n if (curr.size !== prev.size || currmtime > prev.mtime.getTime() || currmtime === 0) {\n container.listeners.forEach(function(listener) {\n listener(path, curr);\n });\n }\n })\n };\n } else {\n container.listeners.push(listener);\n container.rawEmitters.push(rawEmitter);\n }\n var listenerIndex = container.listeners.length - 1;\n\n // removes this instance's listeners and closes the underlying fs.watchFile\n // instance if there are no more listeners left\n return function close() {\n delete container.listeners[listenerIndex];\n delete container.rawEmitters[listenerIndex];\n if (!Object.keys(container.listeners).length) {\n fs.unwatchFile(fullPath);\n delete FsWatchFileInstances[fullPath];\n }\n };\n}\n\n// fake constructor for attaching nodefs-specific prototype methods that\n// will be copied to FSWatcher's prototype\nfunction NodeFsHandler() {}\n\n// Private method: Watch file for changes with fs.watchFile or fs.watch.\n\n// * path - string, path to file or directory.\n// * listener - function, to be executed on fs change.\n\n// Returns close function for the watcher instance\nNodeFsHandler.prototype._watchWithNodeFs =\nfunction(path, listener) {\n var directory = sysPath.dirname(path);\n var basename = sysPath.basename(path);\n var parent = this._getWatchedDir(directory);\n parent.add(basename);\n var absolutePath = sysPath.resolve(path);\n var options = {persistent: this.options.persistent};\n if (!listener) listener = Function.prototype; // empty function\n\n var closer;\n if (this.options.usePolling) {\n options.interval = this.enableBinaryInterval && isBinaryPath(basename) ?\n this.options.binaryInterval : this.options.interval;\n closer = setFsWatchFileListener(path, absolutePath, options, {\n listener: listener,\n rawEmitter: this.emit.bind(this, 'raw')\n });\n } else {\n closer = setFsWatchListener(path, absolutePath, options, {\n listener: listener,\n errHandler: this._handleError.bind(this),\n rawEmitter: this.emit.bind(this, 'raw')\n });\n }\n return closer;\n};\n\n// Private method: Watch a file and emit add event if warranted\n\n// * file - string, the file's path\n/