@igstack/app-catalog-frontend-build-vite 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/esm/frontendViteConfig.d.ts +36 -0
- package/dist/esm/frontendViteConfig.js +151 -0
- package/dist/esm/frontendViteConfig.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js +774 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js +746 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js +241 -0
- package/dist/esm/node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js.map +1 -0
- package/dist/esm/watchExternalSource.d.ts +69 -0
- package/dist/esm/watchExternalSource.js +85 -0
- package/dist/esm/watchExternalSource.js.map +1 -0
- package/package.json +64 -0
- package/src/frontendViteConfig.ts +178 -0
- package/src/index.ts +7 -0
- package/src/watchExternalSource.ts +177 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js"],"sourcesContent":["/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */\nimport { EventEmitter } from 'node:events';\nimport { stat as statcb, Stats } from 'node:fs';\nimport { readdir, stat } from 'node:fs/promises';\nimport * as sp from 'node:path';\nimport { readdirp, ReaddirpStream } from 'readdirp';\nimport { EMPTY_FN, EVENTS as EV, isIBMi, isWindows, NodeFsHandler, STR_CLOSE, STR_END, } from './handler.js';\nconst SLASH = '/';\nconst SLASH_SLASH = '//';\nconst ONE_DOT = '.';\nconst TWO_DOTS = '..';\nconst STRING_TYPE = 'string';\nconst BACK_SLASH_RE = /\\\\/g;\nconst DOUBLE_SLASH_RE = /\\/\\//g;\nconst DOT_RE = /\\..*\\.(sw[px])$|~$|\\.subl.*\\.tmp/;\nconst REPLACER_RE = /^\\.[/\\\\]/;\nfunction arrify(item) {\n return Array.isArray(item) ? item : [item];\n}\nconst isMatcherObject = (matcher) => typeof matcher === 'object' && matcher !== null && !(matcher instanceof RegExp);\nfunction createPattern(matcher) {\n if (typeof matcher === 'function')\n return matcher;\n if (typeof matcher === 'string')\n return (string) => matcher === string;\n if (matcher instanceof RegExp)\n return (string) => matcher.test(string);\n if (typeof matcher === 'object' && matcher !== null) {\n return (string) => {\n if (matcher.path === string)\n return true;\n if (matcher.recursive) {\n const relative = sp.relative(matcher.path, string);\n if (!relative) {\n return false;\n }\n return !relative.startsWith('..') && !sp.isAbsolute(relative);\n }\n return false;\n };\n }\n return () => false;\n}\nfunction normalizePath(path) {\n if (typeof path !== 'string')\n throw new Error('string expected');\n path = sp.normalize(path);\n path = path.replace(/\\\\/g, '/');\n let prepend = false;\n if (path.startsWith('//'))\n prepend = true;\n path = path.replace(DOUBLE_SLASH_RE, '/');\n if (prepend)\n path = '/' + path;\n return path;\n}\nfunction matchPatterns(patterns, testString, stats) {\n const path = normalizePath(testString);\n for (let index = 0; index < patterns.length; index++) {\n const pattern = patterns[index];\n if (pattern(path, stats)) {\n return true;\n }\n }\n return false;\n}\nfunction anymatch(matchers, testString) {\n if (matchers == null) {\n throw new TypeError('anymatch: specify first argument');\n }\n // Early cache for matchers.\n const matchersArray = arrify(matchers);\n const patterns = matchersArray.map((matcher) => createPattern(matcher));\n if (testString == null) {\n return (testString, stats) => {\n return matchPatterns(patterns, testString, stats);\n };\n }\n return matchPatterns(patterns, testString);\n}\nconst unifyPaths = (paths_) => {\n const paths = arrify(paths_).flat();\n if (!paths.every((p) => typeof p === STRING_TYPE)) {\n throw new TypeError(`Non-string provided as watch path: ${paths}`);\n }\n return paths.map(normalizePathToUnix);\n};\n// If SLASH_SLASH occurs at the beginning of path, it is not replaced\n// because \"//StoragePC/DrivePool/Movies\" is a valid network path\nconst toUnix = (string) => {\n let str = string.replace(BACK_SLASH_RE, SLASH);\n let prepend = false;\n if (str.startsWith(SLASH_SLASH)) {\n prepend = true;\n }\n str = str.replace(DOUBLE_SLASH_RE, SLASH);\n if (prepend) {\n str = SLASH + str;\n }\n return str;\n};\n// Our version of upath.normalize\n// TODO: this is not equal to path-normalize module - investigate why\nconst normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));\n// TODO: refactor\nconst normalizeIgnored = (cwd = '') => (path) => {\n if (typeof path === 'string') {\n return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));\n }\n else {\n return path;\n }\n};\nconst getAbsolutePath = (path, cwd) => {\n if (sp.isAbsolute(path)) {\n return path;\n }\n return sp.join(cwd, path);\n};\nconst EMPTY_SET = Object.freeze(new Set());\n/**\n * Directory entry.\n */\nclass DirEntry {\n path;\n _removeWatcher;\n items;\n constructor(dir, removeWatcher) {\n this.path = dir;\n this._removeWatcher = removeWatcher;\n this.items = new Set();\n }\n add(item) {\n const { items } = this;\n if (!items)\n return;\n if (item !== ONE_DOT && item !== TWO_DOTS)\n items.add(item);\n }\n async remove(item) {\n const { items } = this;\n if (!items)\n return;\n items.delete(item);\n if (items.size > 0)\n return;\n const dir = this.path;\n try {\n await readdir(dir);\n }\n catch (err) {\n if (this._removeWatcher) {\n this._removeWatcher(sp.dirname(dir), sp.basename(dir));\n }\n }\n }\n has(item) {\n const { items } = this;\n if (!items)\n return;\n return items.has(item);\n }\n getChildren() {\n const { items } = this;\n if (!items)\n return [];\n return [...items.values()];\n }\n dispose() {\n this.items.clear();\n this.path = '';\n this._removeWatcher = EMPTY_FN;\n this.items = EMPTY_SET;\n Object.freeze(this);\n }\n}\nconst STAT_METHOD_F = 'stat';\nconst STAT_METHOD_L = 'lstat';\nexport class WatchHelper {\n fsw;\n path;\n watchPath;\n fullWatchPath;\n dirParts;\n followSymlinks;\n statMethod;\n constructor(path, follow, fsw) {\n this.fsw = fsw;\n const watchPath = path;\n this.path = path = path.replace(REPLACER_RE, '');\n this.watchPath = watchPath;\n this.fullWatchPath = sp.resolve(watchPath);\n this.dirParts = [];\n this.dirParts.forEach((parts) => {\n if (parts.length > 1)\n parts.pop();\n });\n this.followSymlinks = follow;\n this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;\n }\n entryPath(entry) {\n return sp.join(this.watchPath, sp.relative(this.watchPath, entry.fullPath));\n }\n filterPath(entry) {\n const { stats } = entry;\n if (stats && stats.isSymbolicLink())\n return this.filterDir(entry);\n const resolvedPath = this.entryPath(entry);\n // TODO: what if stats is undefined? remove !\n return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);\n }\n filterDir(entry) {\n return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);\n }\n}\n/**\n * Watches files & directories for changes. Emitted events:\n * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`\n *\n * new FSWatcher()\n * .add(directories)\n * .on('add', path => log('File', path, 'was added'))\n */\nexport class FSWatcher extends EventEmitter {\n closed;\n options;\n _closers;\n _ignoredPaths;\n _throttled;\n _streams;\n _symlinkPaths;\n _watched;\n _pendingWrites;\n _pendingUnlinks;\n _readyCount;\n _emitReady;\n _closePromise;\n _userIgnored;\n _readyEmitted;\n _emitRaw;\n _boundRemove;\n _nodeFsHandler;\n // Not indenting methods for history sake; for now.\n constructor(_opts = {}) {\n super();\n this.closed = false;\n this._closers = new Map();\n this._ignoredPaths = new Set();\n this._throttled = new Map();\n this._streams = new Set();\n this._symlinkPaths = new Map();\n this._watched = new Map();\n this._pendingWrites = new Map();\n this._pendingUnlinks = new Map();\n this._readyCount = 0;\n this._readyEmitted = false;\n const awf = _opts.awaitWriteFinish;\n const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };\n const opts = {\n // Defaults\n persistent: true,\n ignoreInitial: false,\n ignorePermissionErrors: false,\n interval: 100,\n binaryInterval: 300,\n followSymlinks: true,\n usePolling: false,\n // useAsync: false,\n atomic: true, // NOTE: overwritten later (depends on usePolling)\n ..._opts,\n // Change format\n ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),\n awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === 'object' ? { ...DEF_AWF, ...awf } : false,\n };\n // Always default to polling on IBM i because fs.watch() is not available on IBM i.\n if (isIBMi)\n opts.usePolling = true;\n // Editor atomic write normalization enabled by default with fs.watch\n if (opts.atomic === undefined)\n opts.atomic = !opts.usePolling;\n // opts.atomic = typeof _opts.atomic === 'number' ? _opts.atomic : 100;\n // Global override. Useful for developers, who need to force polling for all\n // instances of chokidar, regardless of usage / dependency depth\n const envPoll = process.env.CHOKIDAR_USEPOLLING;\n if (envPoll !== undefined) {\n const envLower = envPoll.toLowerCase();\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 const envInterval = process.env.CHOKIDAR_INTERVAL;\n if (envInterval)\n opts.interval = Number.parseInt(envInterval, 10);\n // This is done to emit ready only once, but each 'add' will increase that?\n let readyCalls = 0;\n this._emitReady = () => {\n readyCalls++;\n if (readyCalls >= this._readyCount) {\n this._emitReady = EMPTY_FN;\n this._readyEmitted = true;\n // use process.nextTick to allow time for listener to be bound\n process.nextTick(() => this.emit(EV.READY));\n }\n };\n this._emitRaw = (...args) => this.emit(EV.RAW, ...args);\n this._boundRemove = this._remove.bind(this);\n this.options = opts;\n this._nodeFsHandler = new NodeFsHandler(this);\n // You’re frozen when your heart’s not open.\n Object.freeze(opts);\n }\n _addIgnoredPath(matcher) {\n if (isMatcherObject(matcher)) {\n // return early if we already have a deeply equal matcher object\n for (const ignored of this._ignoredPaths) {\n if (isMatcherObject(ignored) &&\n ignored.path === matcher.path &&\n ignored.recursive === matcher.recursive) {\n return;\n }\n }\n }\n this._ignoredPaths.add(matcher);\n }\n _removeIgnoredPath(matcher) {\n this._ignoredPaths.delete(matcher);\n // now find any matcher objects with the matcher as path\n if (typeof matcher === 'string') {\n for (const ignored of this._ignoredPaths) {\n // TODO (43081j): make this more efficient.\n // probably just make a `this._ignoredDirectories` or some\n // such thing.\n if (isMatcherObject(ignored) && ignored.path === matcher) {\n this._ignoredPaths.delete(ignored);\n }\n }\n }\n }\n // Public methods\n /**\n * Adds paths to be watched on an existing FSWatcher instance.\n * @param paths_ file or file list. Other arguments are unused\n */\n add(paths_, _origAdd, _internal) {\n const { cwd } = this.options;\n this.closed = false;\n this._closePromise = undefined;\n let paths = unifyPaths(paths_);\n if (cwd) {\n paths = paths.map((path) => {\n const absPath = getAbsolutePath(path, cwd);\n // Check `path` instead of `absPath` because the cwd portion can't be a glob\n return absPath;\n });\n }\n paths.forEach((path) => {\n this._removeIgnoredPath(path);\n });\n this._userIgnored = undefined;\n if (!this._readyCount)\n this._readyCount = 0;\n this._readyCount += paths.length;\n Promise.all(paths.map(async (path) => {\n const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, undefined, 0, _origAdd);\n if (res)\n this._emitReady();\n return res;\n })).then((results) => {\n if (this.closed)\n return;\n results.forEach((item) => {\n if (item)\n this.add(sp.dirname(item), sp.basename(_origAdd || item));\n });\n });\n return this;\n }\n /**\n * Close watchers or start ignoring events from specified paths.\n */\n unwatch(paths_) {\n if (this.closed)\n return this;\n const paths = unifyPaths(paths_);\n const { cwd } = this.options;\n paths.forEach((path) => {\n // convert to absolute path unless relative path already matches\n if (!sp.isAbsolute(path) && !this._closers.has(path)) {\n if (cwd)\n path = sp.join(cwd, path);\n path = sp.resolve(path);\n }\n this._closePath(path);\n this._addIgnoredPath(path);\n if (this._watched.has(path)) {\n this._addIgnoredPath({\n path,\n recursive: true,\n });\n }\n // reset the cached userIgnored anymatch fn\n // to make ignoredPaths changes effective\n this._userIgnored = undefined;\n });\n return this;\n }\n /**\n * Close watchers and remove all listeners from watched paths.\n */\n close() {\n if (this._closePromise) {\n return this._closePromise;\n }\n this.closed = true;\n // Memory management.\n this.removeAllListeners();\n const closers = [];\n this._closers.forEach((closerList) => closerList.forEach((closer) => {\n const promise = closer();\n if (promise instanceof Promise)\n closers.push(promise);\n }));\n this._streams.forEach((stream) => stream.destroy());\n this._userIgnored = undefined;\n this._readyCount = 0;\n this._readyEmitted = false;\n this._watched.forEach((dirent) => dirent.dispose());\n this._closers.clear();\n this._watched.clear();\n this._streams.clear();\n this._symlinkPaths.clear();\n this._throttled.clear();\n this._closePromise = closers.length\n ? Promise.all(closers).then(() => undefined)\n : Promise.resolve();\n return this._closePromise;\n }\n /**\n * Expose list of watched paths\n * @returns for chaining\n */\n getWatched() {\n const watchList = {};\n this._watched.forEach((entry, dir) => {\n const key = this.options.cwd ? sp.relative(this.options.cwd, dir) : dir;\n const index = key || ONE_DOT;\n watchList[index] = entry.getChildren().sort();\n });\n return watchList;\n }\n emitWithAll(event, args) {\n this.emit(event, ...args);\n if (event !== EV.ERROR)\n this.emit(EV.ALL, event, ...args);\n }\n // Common helpers\n // --------------\n /**\n * Normalize and emit events.\n * Calling _emit DOES NOT MEAN emit() would be called!\n * @param event Type of event\n * @param path File or directory path\n * @param stats arguments to be passed with event\n * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag\n */\n async _emit(event, path, stats) {\n if (this.closed)\n return;\n const opts = this.options;\n if (isWindows)\n path = sp.normalize(path);\n if (opts.cwd)\n path = sp.relative(opts.cwd, path);\n const args = [path];\n if (stats != null)\n args.push(stats);\n const awf = opts.awaitWriteFinish;\n let pw;\n if (awf && (pw = this._pendingWrites.get(path))) {\n pw.lastChange = new Date();\n return this;\n }\n if (opts.atomic) {\n if (event === EV.UNLINK) {\n this._pendingUnlinks.set(path, [event, ...args]);\n setTimeout(() => {\n this._pendingUnlinks.forEach((entry, path) => {\n this.emit(...entry);\n this.emit(EV.ALL, ...entry);\n this._pendingUnlinks.delete(path);\n });\n }, typeof opts.atomic === 'number' ? opts.atomic : 100);\n return this;\n }\n if (event === EV.ADD && this._pendingUnlinks.has(path)) {\n event = EV.CHANGE;\n this._pendingUnlinks.delete(path);\n }\n }\n if (awf && (event === EV.ADD || event === EV.CHANGE) && this._readyEmitted) {\n const awfEmit = (err, stats) => {\n if (err) {\n event = EV.ERROR;\n args[0] = err;\n this.emitWithAll(event, args);\n }\n else if (stats) {\n // if stats doesn't exist the file must have been deleted\n if (args.length > 1) {\n args[1] = stats;\n }\n else {\n args.push(stats);\n }\n this.emitWithAll(event, args);\n }\n };\n this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);\n return this;\n }\n if (event === EV.CHANGE) {\n const isThrottled = !this._throttle(EV.CHANGE, path, 50);\n if (isThrottled)\n return this;\n }\n if (opts.alwaysStat &&\n stats === undefined &&\n (event === EV.ADD || event === EV.ADD_DIR || event === EV.CHANGE)) {\n const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;\n let stats;\n try {\n stats = await stat(fullPath);\n }\n catch (err) {\n // do nothing\n }\n // Suppress event when fs_stat fails, to avoid sending undefined 'stat'\n if (!stats || this.closed)\n return;\n args.push(stats);\n }\n this.emitWithAll(event, args);\n return this;\n }\n /**\n * Common handler for errors\n * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag\n */\n _handleError(error) {\n const code = error && error.code;\n if (error &&\n code !== 'ENOENT' &&\n code !== 'ENOTDIR' &&\n (!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES'))) {\n this.emit(EV.ERROR, error);\n }\n return error || this.closed;\n }\n /**\n * Helper utility for throttling\n * @param actionType type being throttled\n * @param path being acted upon\n * @param timeout duration of time to suppress duplicate actions\n * @returns tracking object or false if action should be suppressed\n */\n _throttle(actionType, path, timeout) {\n if (!this._throttled.has(actionType)) {\n this._throttled.set(actionType, new Map());\n }\n const action = this._throttled.get(actionType);\n if (!action)\n throw new Error('invalid throttle');\n const actionPath = action.get(path);\n if (actionPath) {\n actionPath.count++;\n return false;\n }\n // eslint-disable-next-line prefer-const\n let timeoutObject;\n const clear = () => {\n const item = action.get(path);\n const count = item ? item.count : 0;\n action.delete(path);\n clearTimeout(timeoutObject);\n if (item)\n clearTimeout(item.timeoutObject);\n return count;\n };\n timeoutObject = setTimeout(clear, timeout);\n const thr = { timeoutObject, clear, count: 0 };\n action.set(path, thr);\n return thr;\n }\n _incrReadyCount() {\n return this._readyCount++;\n }\n /**\n * Awaits write operation to finish.\n * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.\n * @param path being acted upon\n * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished\n * @param event\n * @param awfEmit Callback to be called when ready for event to be emitted.\n */\n _awaitWriteFinish(path, threshold, event, awfEmit) {\n const awf = this.options.awaitWriteFinish;\n if (typeof awf !== 'object')\n return;\n const pollInterval = awf.pollInterval;\n let timeoutHandler;\n let fullPath = path;\n if (this.options.cwd && !sp.isAbsolute(path)) {\n fullPath = sp.join(this.options.cwd, path);\n }\n const now = new Date();\n const writes = this._pendingWrites;\n function awaitWriteFinishFn(prevStat) {\n statcb(fullPath, (err, curStat) => {\n if (err || !writes.has(path)) {\n if (err && err.code !== 'ENOENT')\n awfEmit(err);\n return;\n }\n const now = Number(new Date());\n if (prevStat && curStat.size !== prevStat.size) {\n writes.get(path).lastChange = now;\n }\n const pw = writes.get(path);\n const df = now - pw.lastChange;\n if (df >= threshold) {\n writes.delete(path);\n awfEmit(undefined, curStat);\n }\n else {\n timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);\n }\n });\n }\n if (!writes.has(path)) {\n writes.set(path, {\n lastChange: now,\n cancelWait: () => {\n writes.delete(path);\n clearTimeout(timeoutHandler);\n return event;\n },\n });\n timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);\n }\n }\n /**\n * Determines whether user has asked to ignore this path.\n */\n _isIgnored(path, stats) {\n if (this.options.atomic && DOT_RE.test(path))\n return true;\n if (!this._userIgnored) {\n const { cwd } = this.options;\n const ign = this.options.ignored;\n const ignored = (ign || []).map(normalizeIgnored(cwd));\n const ignoredPaths = [...this._ignoredPaths];\n const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];\n this._userIgnored = anymatch(list, undefined);\n }\n return this._userIgnored(path, stats);\n }\n _isntIgnored(path, stat) {\n return !this._isIgnored(path, stat);\n }\n /**\n * Provides a set of common helpers and properties relating to symlink handling.\n * @param path file or directory pattern being watched\n */\n _getWatchHelpers(path) {\n return new WatchHelper(path, this.options.followSymlinks, this);\n }\n // Directory helpers\n // -----------------\n /**\n * Provides directory tracking objects\n * @param directory path of the directory\n */\n _getWatchedDir(directory) {\n const dir = sp.resolve(directory);\n if (!this._watched.has(dir))\n this._watched.set(dir, new DirEntry(dir, this._boundRemove));\n return this._watched.get(dir);\n }\n // File helpers\n // ------------\n /**\n * Check for read permissions: https://stackoverflow.com/a/11781404/1358405\n */\n _hasReadPermissions(stats) {\n if (this.options.ignorePermissionErrors)\n return true;\n return Boolean(Number(stats.mode) & 0o400);\n }\n /**\n * Handles emitting unlink events for\n * files and directories, and via recursion, for\n * files and directories within directories that are unlinked\n * @param directory within which the following item is located\n * @param item base path of item/directory\n */\n _remove(directory, item, isDirectory) {\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 const path = sp.join(directory, item);\n const fullPath = sp.resolve(path);\n isDirectory =\n isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);\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))\n return;\n // if the only watched file is removed, watch for its return\n if (!isDirectory && this._watched.size === 1) {\n this.add(directory, item, true);\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 const wp = this._getWatchedDir(path);\n const nestedDirectoryChildren = wp.getChildren();\n // Recursively remove children directories / files.\n nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));\n // Check if item was on the watched list and remove it\n const parent = this._getWatchedDir(directory);\n const wasTracked = parent.has(item);\n parent.remove(item);\n // Fixes issue #1042 -> Relative paths were detected and added as symlinks\n // (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612),\n // but never removed from the map in case the path was deleted.\n // This leads to an incorrect state if the path was recreated:\n // https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553\n if (this._symlinkPaths.has(fullPath)) {\n this._symlinkPaths.delete(fullPath);\n }\n // If we wait for this file to be fully written, cancel the wait.\n let relPath = path;\n if (this.options.cwd)\n relPath = sp.relative(this.options.cwd, path);\n if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {\n const event = this._pendingWrites.get(relPath).cancelWait();\n if (event === EV.ADD)\n return;\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 this._watched.delete(path);\n this._watched.delete(fullPath);\n const eventName = isDirectory ? EV.UNLINK_DIR : EV.UNLINK;\n if (wasTracked && !this._isIgnored(path))\n this._emit(eventName, path);\n // Avoid conflicts if we later create another file with the same name\n this._closePath(path);\n }\n /**\n * Closes all watchers for a path\n */\n _closePath(path) {\n this._closeFile(path);\n const dir = sp.dirname(path);\n this._getWatchedDir(dir).remove(sp.basename(path));\n }\n /**\n * Closes only file-specific watchers\n */\n _closeFile(path) {\n const closers = this._closers.get(path);\n if (!closers)\n return;\n closers.forEach((closer) => closer());\n this._closers.delete(path);\n }\n _addPathCloser(path, closer) {\n if (!closer)\n return;\n let list = this._closers.get(path);\n if (!list) {\n list = [];\n this._closers.set(path, list);\n }\n list.push(closer);\n }\n _readdirp(root, opts) {\n if (this.closed)\n return;\n const options = { type: EV.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };\n let stream = readdirp(root, options);\n this._streams.add(stream);\n stream.once(STR_CLOSE, () => {\n stream = undefined;\n });\n stream.once(STR_END, () => {\n if (stream) {\n this._streams.delete(stream);\n stream = undefined;\n }\n });\n return stream;\n }\n}\n/**\n * Instantiates watcher with paths to be tracked.\n * @param paths file / directory paths\n * @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others\n * @returns an instance of FSWatcher for chaining.\n * @example\n * const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });\n * watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })\n */\nexport function watch(paths, options = {}) {\n const watcher = new FSWatcher(options);\n watcher.add(paths);\n return watcher;\n}\nexport default { watch: watch, FSWatcher: FSWatcher };\n"],"names":["testString","EV","path","stats","statcb","now","stat"],"mappings":";;;;;;;;;AAAA;AAOA,MAAM,QAAQ;AACd,MAAM,cAAc;AACpB,MAAM,UAAU;AAChB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,SAAS;AACf,MAAM,cAAc;AACpB,SAAS,OAAO,MAAM;AAClB,SAAO,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAC7C;AACA,MAAM,kBAAkB,CAAC,YAAY,OAAO,YAAY,YAAY,YAAY,QAAQ,EAAE,mBAAmB;AAC7G,SAAS,cAAc,SAAS;AAC5B,MAAI,OAAO,YAAY;AACnB,WAAO;AACX,MAAI,OAAO,YAAY;AACnB,WAAO,CAAC,WAAW,YAAY;AACnC,MAAI,mBAAmB;AACnB,WAAO,CAAC,WAAW,QAAQ,KAAK,MAAM;AAC1C,MAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AACjD,WAAO,CAAC,WAAW;AACf,UAAI,QAAQ,SAAS;AACjB,eAAO;AACX,UAAI,QAAQ,WAAW;AACnB,cAAM,WAAW,GAAG,SAAS,QAAQ,MAAM,MAAM;AACjD,YAAI,CAAC,UAAU;AACX,iBAA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AAO,KAAK,WAAW,MAAM;AACzB,eAAS;AAAA,IACb,CAAC;AACD,WAAO,KAAK,SAAS,MAAM;AACvB,UAAI,QAAQ;AACR,aAAK,SAAS,OAAO,MAAM;AAC3B,iBAAS;AAAA,MACb;AAAA,IACJ,CAAC;AACD,WAAO;AAAA,EACX;AACJ;AAUO,SAAS,MAAM,OAAO,UAAU,IAAI;AACvC,QAAM,UAAU,IAAI,UAAU,OAAO;AACrC,UAAQ,IAAI,KAAK;AACjB,SAAO;AACX;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { lstat, stat, readdir, realpath } from "node:fs/promises";
|
|
5
|
+
import { resolve, join, relative, sep } from "node:path";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
const EntryTypes = {
|
|
8
|
+
FILE_TYPE: "files",
|
|
9
|
+
DIR_TYPE: "directories",
|
|
10
|
+
FILE_DIR_TYPE: "files_directories",
|
|
11
|
+
EVERYTHING_TYPE: "all"
|
|
12
|
+
};
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
root: ".",
|
|
15
|
+
fileFilter: (_entryInfo) => true,
|
|
16
|
+
directoryFilter: (_entryInfo) => true,
|
|
17
|
+
type: EntryTypes.FILE_TYPE,
|
|
18
|
+
lstat: false,
|
|
19
|
+
depth: 2147483648,
|
|
20
|
+
alwaysStat: false,
|
|
21
|
+
highWaterMark: 4096
|
|
22
|
+
};
|
|
23
|
+
Object.freeze(defaultOptions);
|
|
24
|
+
const RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
25
|
+
const NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
|
|
26
|
+
const ALL_TYPES = [
|
|
27
|
+
EntryTypes.DIR_TYPE,
|
|
28
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
29
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
30
|
+
EntryTypes.FILE_TYPE
|
|
31
|
+
];
|
|
32
|
+
const DIR_TYPES = /* @__PURE__ */ new Set([
|
|
33
|
+
EntryTypes.DIR_TYPE,
|
|
34
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
35
|
+
EntryTypes.FILE_DIR_TYPE
|
|
36
|
+
]);
|
|
37
|
+
const FILE_TYPES = /* @__PURE__ */ new Set([
|
|
38
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
39
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
40
|
+
EntryTypes.FILE_TYPE
|
|
41
|
+
]);
|
|
42
|
+
const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
|
|
43
|
+
const wantBigintFsStats = process.platform === "win32";
|
|
44
|
+
const emptyFn = (_entryInfo) => true;
|
|
45
|
+
const normalizeFilter = (filter) => {
|
|
46
|
+
if (filter === void 0)
|
|
47
|
+
return emptyFn;
|
|
48
|
+
if (typeof filter === "function")
|
|
49
|
+
return filter;
|
|
50
|
+
if (typeof filter === "string") {
|
|
51
|
+
const fl = filter.trim();
|
|
52
|
+
return (entry) => entry.basename === fl;
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(filter)) {
|
|
55
|
+
const trItems = filter.map((item) => item.trim());
|
|
56
|
+
return (entry) => trItems.some((f) => entry.basename === f);
|
|
57
|
+
}
|
|
58
|
+
return emptyFn;
|
|
59
|
+
};
|
|
60
|
+
class ReaddirpStream extends Readable {
|
|
61
|
+
constructor(options = {}) {
|
|
62
|
+
super({
|
|
63
|
+
objectMode: true,
|
|
64
|
+
autoDestroy: true,
|
|
65
|
+
highWaterMark: options.highWaterMark
|
|
66
|
+
});
|
|
67
|
+
__publicField(this, "parents");
|
|
68
|
+
__publicField(this, "reading");
|
|
69
|
+
__publicField(this, "parent");
|
|
70
|
+
__publicField(this, "_stat");
|
|
71
|
+
__publicField(this, "_maxDepth");
|
|
72
|
+
__publicField(this, "_wantsDir");
|
|
73
|
+
__publicField(this, "_wantsFile");
|
|
74
|
+
__publicField(this, "_wantsEverything");
|
|
75
|
+
__publicField(this, "_root");
|
|
76
|
+
__publicField(this, "_isDirent");
|
|
77
|
+
__publicField(this, "_statsProp");
|
|
78
|
+
__publicField(this, "_rdOptions");
|
|
79
|
+
__publicField(this, "_fileFilter");
|
|
80
|
+
__publicField(this, "_directoryFilter");
|
|
81
|
+
const opts = { ...defaultOptions, ...options };
|
|
82
|
+
const { root, type } = opts;
|
|
83
|
+
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
84
|
+
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
85
|
+
const statMethod = opts.lstat ? lstat : stat;
|
|
86
|
+
if (wantBigintFsStats) {
|
|
87
|
+
this._stat = (path) => statMethod(path, { bigint: true });
|
|
88
|
+
} else {
|
|
89
|
+
this._stat = statMethod;
|
|
90
|
+
}
|
|
91
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
92
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
93
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
94
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
95
|
+
this._root = resolve(root);
|
|
96
|
+
this._isDirent = !opts.alwaysStat;
|
|
97
|
+
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
98
|
+
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
99
|
+
this.parents = [this._exploreDir(root, 1)];
|
|
100
|
+
this.reading = false;
|
|
101
|
+
this.parent = void 0;
|
|
102
|
+
}
|
|
103
|
+
async _read(batch) {
|
|
104
|
+
if (this.reading)
|
|
105
|
+
return;
|
|
106
|
+
this.reading = true;
|
|
107
|
+
try {
|
|
108
|
+
while (!this.destroyed && batch > 0) {
|
|
109
|
+
const par = this.parent;
|
|
110
|
+
const fil = par && par.files;
|
|
111
|
+
if (fil && fil.length > 0) {
|
|
112
|
+
const { path, depth } = par;
|
|
113
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
|
114
|
+
const awaited = await Promise.all(slice);
|
|
115
|
+
for (const entry of awaited) {
|
|
116
|
+
if (!entry)
|
|
117
|
+
continue;
|
|
118
|
+
if (this.destroyed)
|
|
119
|
+
return;
|
|
120
|
+
const entryType = await this._getEntryType(entry);
|
|
121
|
+
if (entryType === "directory" && this._directoryFilter(entry)) {
|
|
122
|
+
if (depth <= this._maxDepth) {
|
|
123
|
+
this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
|
124
|
+
}
|
|
125
|
+
if (this._wantsDir) {
|
|
126
|
+
this.push(entry);
|
|
127
|
+
batch--;
|
|
128
|
+
}
|
|
129
|
+
} else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
|
|
130
|
+
if (this._wantsFile) {
|
|
131
|
+
this.push(entry);
|
|
132
|
+
batch--;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const parent = this.parents.pop();
|
|
138
|
+
if (!parent) {
|
|
139
|
+
this.push(null);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
this.parent = await parent;
|
|
143
|
+
if (this.destroyed)
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch (error) {
|
|
148
|
+
this.destroy(error);
|
|
149
|
+
} finally {
|
|
150
|
+
this.reading = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async _exploreDir(path, depth) {
|
|
154
|
+
let files;
|
|
155
|
+
try {
|
|
156
|
+
files = await readdir(path, this._rdOptions);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
this._onError(error);
|
|
159
|
+
}
|
|
160
|
+
return { files, depth, path };
|
|
161
|
+
}
|
|
162
|
+
async _formatEntry(dirent, path) {
|
|
163
|
+
let entry;
|
|
164
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
165
|
+
try {
|
|
166
|
+
const fullPath = resolve(join(path, basename));
|
|
167
|
+
entry = { path: relative(this._root, fullPath), fullPath, basename };
|
|
168
|
+
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
this._onError(err);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
return entry;
|
|
174
|
+
}
|
|
175
|
+
_onError(err) {
|
|
176
|
+
if (isNormalFlowError(err) && !this.destroyed) {
|
|
177
|
+
this.emit("warn", err);
|
|
178
|
+
} else {
|
|
179
|
+
this.destroy(err);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async _getEntryType(entry) {
|
|
183
|
+
if (!entry && this._statsProp in entry) {
|
|
184
|
+
return "";
|
|
185
|
+
}
|
|
186
|
+
const stats = entry[this._statsProp];
|
|
187
|
+
if (stats.isFile())
|
|
188
|
+
return "file";
|
|
189
|
+
if (stats.isDirectory())
|
|
190
|
+
return "directory";
|
|
191
|
+
if (stats && stats.isSymbolicLink()) {
|
|
192
|
+
const full = entry.fullPath;
|
|
193
|
+
try {
|
|
194
|
+
const entryRealPath = await realpath(full);
|
|
195
|
+
const entryRealPathStats = await lstat(entryRealPath);
|
|
196
|
+
if (entryRealPathStats.isFile()) {
|
|
197
|
+
return "file";
|
|
198
|
+
}
|
|
199
|
+
if (entryRealPathStats.isDirectory()) {
|
|
200
|
+
const len = entryRealPath.length;
|
|
201
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sep) {
|
|
202
|
+
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
203
|
+
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
204
|
+
return this._onError(recursiveError);
|
|
205
|
+
}
|
|
206
|
+
return "directory";
|
|
207
|
+
}
|
|
208
|
+
} catch (error) {
|
|
209
|
+
this._onError(error);
|
|
210
|
+
return "";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
_includeAsFile(entry) {
|
|
215
|
+
const stats = entry && entry[this._statsProp];
|
|
216
|
+
return stats && this._wantsEverything && !stats.isDirectory();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function readdirp(root, options = {}) {
|
|
220
|
+
let type = options.entryType || options.type;
|
|
221
|
+
if (type === "both")
|
|
222
|
+
type = EntryTypes.FILE_DIR_TYPE;
|
|
223
|
+
if (type)
|
|
224
|
+
options.type = type;
|
|
225
|
+
if (!root) {
|
|
226
|
+
throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
227
|
+
} else if (typeof root !== "string") {
|
|
228
|
+
throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
229
|
+
} else if (type && !ALL_TYPES.includes(type)) {
|
|
230
|
+
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
231
|
+
}
|
|
232
|
+
options.root = root;
|
|
233
|
+
return new ReaddirpStream(options);
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
EntryTypes,
|
|
237
|
+
ReaddirpStream,
|
|
238
|
+
readdirp as default,
|
|
239
|
+
readdirp
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../../node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js"],"sourcesContent":["import { lstat, readdir, realpath, stat } from 'node:fs/promises';\nimport { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from 'node:path';\nimport { Readable } from 'node:stream';\nexport const EntryTypes = {\n FILE_TYPE: 'files',\n DIR_TYPE: 'directories',\n FILE_DIR_TYPE: 'files_directories',\n EVERYTHING_TYPE: 'all',\n};\nconst defaultOptions = {\n root: '.',\n fileFilter: (_entryInfo) => true,\n directoryFilter: (_entryInfo) => true,\n type: EntryTypes.FILE_TYPE,\n lstat: false,\n depth: 2147483648,\n alwaysStat: false,\n highWaterMark: 4096,\n};\nObject.freeze(defaultOptions);\nconst RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';\nconst NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]);\nconst ALL_TYPES = [\n EntryTypes.DIR_TYPE,\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n EntryTypes.FILE_TYPE,\n];\nconst DIR_TYPES = new Set([\n EntryTypes.DIR_TYPE,\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n]);\nconst FILE_TYPES = new Set([\n EntryTypes.EVERYTHING_TYPE,\n EntryTypes.FILE_DIR_TYPE,\n EntryTypes.FILE_TYPE,\n]);\nconst isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);\nconst wantBigintFsStats = process.platform === 'win32';\nconst emptyFn = (_entryInfo) => true;\nconst normalizeFilter = (filter) => {\n if (filter === undefined)\n return emptyFn;\n if (typeof filter === 'function')\n return filter;\n if (typeof filter === 'string') {\n const fl = filter.trim();\n return (entry) => entry.basename === fl;\n }\n if (Array.isArray(filter)) {\n const trItems = filter.map((item) => item.trim());\n return (entry) => trItems.some((f) => entry.basename === f);\n }\n return emptyFn;\n};\n/** Readable readdir stream, emitting new files as they're being listed. */\nexport class ReaddirpStream extends Readable {\n parents;\n reading;\n parent;\n _stat;\n _maxDepth;\n _wantsDir;\n _wantsFile;\n _wantsEverything;\n _root;\n _isDirent;\n _statsProp;\n _rdOptions;\n _fileFilter;\n _directoryFilter;\n constructor(options = {}) {\n super({\n objectMode: true,\n autoDestroy: true,\n highWaterMark: options.highWaterMark,\n });\n const opts = { ...defaultOptions, ...options };\n const { root, type } = opts;\n this._fileFilter = normalizeFilter(opts.fileFilter);\n this._directoryFilter = normalizeFilter(opts.directoryFilter);\n const statMethod = opts.lstat ? lstat : stat;\n // Use bigint stats if it's windows and stat() supports options (node 10+).\n if (wantBigintFsStats) {\n this._stat = (path) => statMethod(path, { bigint: true });\n }\n else {\n this._stat = statMethod;\n }\n this._maxDepth =\n opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;\n this._wantsDir = type ? DIR_TYPES.has(type) : false;\n this._wantsFile = type ? FILE_TYPES.has(type) : false;\n this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;\n this._root = presolve(root);\n this._isDirent = !opts.alwaysStat;\n this._statsProp = this._isDirent ? 'dirent' : 'stats';\n this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };\n // Launch stream with one parent, the root dir.\n this.parents = [this._exploreDir(root, 1)];\n this.reading = false;\n this.parent = undefined;\n }\n async _read(batch) {\n if (this.reading)\n return;\n this.reading = true;\n try {\n while (!this.destroyed && batch > 0) {\n const par = this.parent;\n const fil = par && par.files;\n if (fil && fil.length > 0) {\n const { path, depth } = par;\n const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));\n const awaited = await Promise.all(slice);\n for (const entry of awaited) {\n if (!entry)\n continue;\n if (this.destroyed)\n return;\n const entryType = await this._getEntryType(entry);\n if (entryType === 'directory' && this._directoryFilter(entry)) {\n if (depth <= this._maxDepth) {\n this.parents.push(this._exploreDir(entry.fullPath, depth + 1));\n }\n if (this._wantsDir) {\n this.push(entry);\n batch--;\n }\n }\n else if ((entryType === 'file' || this._includeAsFile(entry)) &&\n this._fileFilter(entry)) {\n if (this._wantsFile) {\n this.push(entry);\n batch--;\n }\n }\n }\n }\n else {\n const parent = this.parents.pop();\n if (!parent) {\n this.push(null);\n break;\n }\n this.parent = await parent;\n if (this.destroyed)\n return;\n }\n }\n }\n catch (error) {\n this.destroy(error);\n }\n finally {\n this.reading = false;\n }\n }\n async _exploreDir(path, depth) {\n let files;\n try {\n files = await readdir(path, this._rdOptions);\n }\n catch (error) {\n this._onError(error);\n }\n return { files, depth, path };\n }\n async _formatEntry(dirent, path) {\n let entry;\n const basename = this._isDirent ? dirent.name : dirent;\n try {\n const fullPath = presolve(pjoin(path, basename));\n entry = { path: prelative(this._root, fullPath), fullPath, basename };\n entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);\n }\n catch (err) {\n this._onError(err);\n return;\n }\n return entry;\n }\n _onError(err) {\n if (isNormalFlowError(err) && !this.destroyed) {\n this.emit('warn', err);\n }\n else {\n this.destroy(err);\n }\n }\n async _getEntryType(entry) {\n // entry may be undefined, because a warning or an error were emitted\n // and the statsProp is undefined\n if (!entry && this._statsProp in entry) {\n return '';\n }\n const stats = entry[this._statsProp];\n if (stats.isFile())\n return 'file';\n if (stats.isDirectory())\n return 'directory';\n if (stats && stats.isSymbolicLink()) {\n const full = entry.fullPath;\n try {\n const entryRealPath = await realpath(full);\n const entryRealPathStats = await lstat(entryRealPath);\n if (entryRealPathStats.isFile()) {\n return 'file';\n }\n if (entryRealPathStats.isDirectory()) {\n const len = entryRealPath.length;\n if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {\n const recursiveError = new Error(`Circular symlink detected: \"${full}\" points to \"${entryRealPath}\"`);\n // @ts-ignore\n recursiveError.code = RECURSIVE_ERROR_CODE;\n return this._onError(recursiveError);\n }\n return 'directory';\n }\n }\n catch (error) {\n this._onError(error);\n return '';\n }\n }\n }\n _includeAsFile(entry) {\n const stats = entry && entry[this._statsProp];\n return stats && this._wantsEverything && !stats.isDirectory();\n }\n}\n/**\n * Streaming version: Reads all files and directories in given root recursively.\n * Consumes ~constant small amount of RAM.\n * @param root Root directory\n * @param options Options to specify root (start directory), filters and recursion depth\n */\nexport function readdirp(root, options = {}) {\n // @ts-ignore\n let type = options.entryType || options.type;\n if (type === 'both')\n type = EntryTypes.FILE_DIR_TYPE; // backwards-compatibility\n if (type)\n options.type = type;\n if (!root) {\n throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');\n }\n else if (typeof root !== 'string') {\n throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');\n }\n else if (type && !ALL_TYPES.includes(type)) {\n throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);\n }\n options.root = root;\n return new ReaddirpStream(options);\n}\n/**\n * Promise version: Reads all files and directories in given root recursively.\n * Compared to streaming version, will consume a lot of RAM e.g. when 1 million files are listed.\n * @returns array of paths and their entry infos\n */\nexport function readdirpPromise(root, options = {}) {\n return new Promise((resolve, reject) => {\n const files = [];\n readdirp(root, options)\n .on('data', (entry) => files.push(entry))\n .on('end', () => resolve(files))\n .on('error', (error) => reject(error));\n });\n}\nexport default readdirp;\n"],"names":["presolve","pjoin","prelative","psep"],"mappings":";;;;;;AAGY,MAAC,aAAa;AAAA,EACtB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA,EACf,iBAAiB;AACrB;AACA,MAAM,iBAAiB;AAAA,EACnB,MAAM;AAAA,EACN,YAAY,CAAC,eAAe;AAAA,EAC5B,iBAAiB,CAAC,eAAe;AAAA,EACjC,MAAM,WAAW;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,eAAe;AACnB;AACA,OAAO,OAAO,cAAc;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,oBAAI,IAAI,CAAC,UAAU,SAAS,UAAU,SAAS,oBAAoB,CAAC;AAC/F,MAAM,YAAY;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACf;AACA,MAAM,YAAY,oBAAI,IAAI;AAAA,EACtB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACf,CAAC;AACD,MAAM,aAAa,oBAAI,IAAI;AAAA,EACvB,WAAW;AAAA,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 -0,0 +1,69 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
export interface WatchExternalSourceOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Name to display in console logs (e.g., '@igstack/app-catalog-frontend-core')
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Absolute path to the source directory to watch
|
|
9
|
+
*/
|
|
10
|
+
srcPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* Polling interval in ms (default: 500)
|
|
13
|
+
* Polling is required for cross-monorepo watching
|
|
14
|
+
*/
|
|
15
|
+
interval?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a Vite plugin that watches an external source directory for changes
|
|
19
|
+
* and triggers HMR updates or full reloads.
|
|
20
|
+
*
|
|
21
|
+
* This is useful when developing with linked packages from another monorepo
|
|
22
|
+
* where Vite's default file watcher doesn't detect changes.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // In vite.config.ts
|
|
27
|
+
* import { watchExternalSource } from '@igstack/app-catalog-frontend-build-vite'
|
|
28
|
+
* import path from 'node:path'
|
|
29
|
+
*
|
|
30
|
+
* export default defineConfig({
|
|
31
|
+
* plugins: [
|
|
32
|
+
* watchExternalSource({
|
|
33
|
+
* name: '@igstack/app-catalog-frontend-core',
|
|
34
|
+
* srcPath: path.resolve(__dirname, '../../../app-catalog/packages/frontend-core/src'),
|
|
35
|
+
* }),
|
|
36
|
+
* ],
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function watchExternalSource(options: WatchExternalSourceOptions): Plugin;
|
|
41
|
+
/**
|
|
42
|
+
* Creates resolve aliases for pointing to source files instead of dist.
|
|
43
|
+
* Use this with watchExternalSource for full HMR support.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // In vite.config.ts
|
|
48
|
+
* import { createSourceAliases } from '@igstack/app-catalog-frontend-build-vite'
|
|
49
|
+
* import path from 'node:path'
|
|
50
|
+
*
|
|
51
|
+
* const frontendCoreSrc = path.resolve(__dirname, '../../../app-catalog/packages/frontend-core/src')
|
|
52
|
+
*
|
|
53
|
+
* export default defineConfig({
|
|
54
|
+
* resolve: {
|
|
55
|
+
* alias: createSourceAliases({
|
|
56
|
+
* '@igstack/app-catalog-frontend-core': `${frontendCoreSrc}/index.tsx`,
|
|
57
|
+
* '~': frontendCoreSrc, // Internal path alias used by frontend-core
|
|
58
|
+
* }),
|
|
59
|
+
* },
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function createSourceAliases(aliases: Record<string, string>): Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates fs.allow paths for serving files from external directories.
|
|
66
|
+
*
|
|
67
|
+
* @param paths - Array of absolute paths to allow
|
|
68
|
+
*/
|
|
69
|
+
export declare function createFsAllowPaths(paths: Array<string>): Array<string>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function watchExternalSource(options) {
|
|
2
|
+
const { name, srcPath, interval = 500 } = options;
|
|
3
|
+
let watcher = null;
|
|
4
|
+
return {
|
|
5
|
+
name: `watch-external-source:${name}`,
|
|
6
|
+
configureServer(server) {
|
|
7
|
+
import("./node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js").then(({ watch }) => {
|
|
8
|
+
watcher = watch(srcPath, {
|
|
9
|
+
ignoreInitial: true,
|
|
10
|
+
usePolling: true,
|
|
11
|
+
// Required for cross-monorepo watching
|
|
12
|
+
interval
|
|
13
|
+
});
|
|
14
|
+
watcher.on("ready", () => {
|
|
15
|
+
console.log(`[HMR] Watching ${name} for changes`);
|
|
16
|
+
});
|
|
17
|
+
watcher.on("change", async (file) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const shortPath = file.replace(srcPath, `${name}/src`);
|
|
20
|
+
console.log(`[HMR] ${shortPath} changed`);
|
|
21
|
+
let modules = server.moduleGraph.getModulesByFile(file);
|
|
22
|
+
if (!modules || modules.size === 0) {
|
|
23
|
+
const allModules = [...server.moduleGraph.idToModuleMap.values()];
|
|
24
|
+
const fileName = file.split("/").pop() || "";
|
|
25
|
+
const matchingModules = allModules.filter((mod) => {
|
|
26
|
+
if (!mod.file) return false;
|
|
27
|
+
return mod.file === file || mod.file.endsWith(fileName) || mod.url.includes(fileName);
|
|
28
|
+
});
|
|
29
|
+
if (matchingModules.length > 0) {
|
|
30
|
+
modules = new Set(matchingModules);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (modules && modules.size > 0) {
|
|
34
|
+
const updates = [];
|
|
35
|
+
for (const mod of modules) {
|
|
36
|
+
server.moduleGraph.invalidateModule(mod);
|
|
37
|
+
const isCss = (_a = mod.file) == null ? void 0 : _a.endsWith(".css");
|
|
38
|
+
updates.push({
|
|
39
|
+
type: isCss ? "css-update" : "js-update",
|
|
40
|
+
path: mod.url,
|
|
41
|
+
acceptedPath: mod.url,
|
|
42
|
+
timestamp: Date.now()
|
|
43
|
+
});
|
|
44
|
+
console.log(`[HMR] Sending update for: ${mod.url}`);
|
|
45
|
+
}
|
|
46
|
+
if (updates.length > 0) {
|
|
47
|
+
server.ws.send({
|
|
48
|
+
type: "update",
|
|
49
|
+
updates
|
|
50
|
+
});
|
|
51
|
+
console.log(`[HMR] Sent ${updates.length} HMR update(s)`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
console.log(`[HMR] Module not tracked, triggering full reload`);
|
|
56
|
+
server.moduleGraph.invalidateAll();
|
|
57
|
+
server.ws.send({
|
|
58
|
+
type: "full-reload",
|
|
59
|
+
path: "*"
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
watcher.on("error", (error) => {
|
|
63
|
+
console.error(`[HMR] Watcher error for ${name}:`, error);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
closeBundle() {
|
|
68
|
+
if (watcher) {
|
|
69
|
+
watcher.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function createSourceAliases(aliases) {
|
|
75
|
+
return aliases;
|
|
76
|
+
}
|
|
77
|
+
function createFsAllowPaths(paths) {
|
|
78
|
+
return paths;
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
createFsAllowPaths,
|
|
82
|
+
createSourceAliases,
|
|
83
|
+
watchExternalSource
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=watchExternalSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchExternalSource.js","sources":["../../src/watchExternalSource.ts"],"sourcesContent":["import type { Plugin, ViteDevServer } from 'vite'\n\nexport interface WatchExternalSourceOptions {\n /**\n * Name to display in console logs (e.g., '@igstack/app-catalog-frontend-core')\n */\n name: string\n /**\n * Absolute path to the source directory to watch\n */\n srcPath: string\n /**\n * Polling interval in ms (default: 500)\n * Polling is required for cross-monorepo watching\n */\n interval?: number\n}\n\n/**\n * Creates a Vite plugin that watches an external source directory for changes\n * and triggers HMR updates or full reloads.\n *\n * This is useful when developing with linked packages from another monorepo\n * where Vite's default file watcher doesn't detect changes.\n *\n * @example\n * ```ts\n * // In vite.config.ts\n * import { watchExternalSource } from '@igstack/app-catalog-frontend-build-vite'\n * import path from 'node:path'\n *\n * export default defineConfig({\n * plugins: [\n * watchExternalSource({\n * name: '@igstack/app-catalog-frontend-core',\n * srcPath: path.resolve(__dirname, '../../../app-catalog/packages/frontend-core/src'),\n * }),\n * ],\n * })\n * ```\n */\nexport function watchExternalSource(\n options: WatchExternalSourceOptions,\n): Plugin {\n const { name, srcPath, interval = 500 } = options\n let watcher: import('chokidar').FSWatcher | null = null // eslint-disable-line @typescript-eslint/consistent-type-imports\n\n return {\n name: `watch-external-source:${name}`,\n configureServer(server: ViteDevServer) {\n \n import('chokidar').then(({ watch }) => {\n watcher = watch(srcPath, {\n ignoreInitial: true,\n usePolling: true, // Required for cross-monorepo watching\n interval,\n })\n\n watcher.on('ready', () => {\n console.log(`[HMR] Watching ${name} for changes`)\n })\n\n watcher.on('change', async (file: string) => {\n const shortPath = file.replace(srcPath, `${name}/src`)\n console.log(`[HMR] ${shortPath} changed`)\n\n // Try multiple ways to find the module in Vite's graph\n let modules = server.moduleGraph.getModulesByFile(file)\n\n // If not found, try searching by URL patterns\n if (!modules || modules.size === 0) {\n const allModules = [...server.moduleGraph.idToModuleMap.values()]\n const fileName = file.split('/').pop() || ''\n const matchingModules = allModules.filter((mod) => {\n if (!mod.file) return false\n return (\n mod.file === file ||\n mod.file.endsWith(fileName) ||\n mod.url.includes(fileName)\n )\n })\n if (matchingModules.length > 0) {\n modules = new Set(matchingModules)\n }\n }\n\n if (modules && modules.size > 0) {\n // Module is tracked - try true HMR\n const updates: Array<{\n type: 'js-update' | 'css-update'\n path: string\n acceptedPath: string\n timestamp: number\n }> = []\n\n for (const mod of modules) {\n server.moduleGraph.invalidateModule(mod)\n const isCss = mod.file?.endsWith('.css')\n\n updates.push({\n type: isCss ? 'css-update' : 'js-update',\n path: mod.url,\n acceptedPath: mod.url,\n timestamp: Date.now(),\n })\n\n console.log(`[HMR] Sending update for: ${mod.url}`)\n }\n\n if (updates.length > 0) {\n server.ws.send({\n type: 'update',\n updates,\n })\n console.log(`[HMR] Sent ${updates.length} HMR update(s)`)\n return\n }\n }\n\n // Module not in graph - fall back to full reload\n console.log(`[HMR] Module not tracked, triggering full reload`)\n server.moduleGraph.invalidateAll()\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n })\n\n watcher.on('error', (error: unknown) => {\n console.error(`[HMR] Watcher error for ${name}:`, error)\n })\n })\n },\n closeBundle() {\n if (watcher) {\n watcher.close()\n }\n },\n }\n}\n\n/**\n * Creates resolve aliases for pointing to source files instead of dist.\n * Use this with watchExternalSource for full HMR support.\n *\n * @example\n * ```ts\n * // In vite.config.ts\n * import { createSourceAliases } from '@igstack/app-catalog-frontend-build-vite'\n * import path from 'node:path'\n *\n * const frontendCoreSrc = path.resolve(__dirname, '../../../app-catalog/packages/frontend-core/src')\n *\n * export default defineConfig({\n * resolve: {\n * alias: createSourceAliases({\n * '@igstack/app-catalog-frontend-core': `${frontendCoreSrc}/index.tsx`,\n * '~': frontendCoreSrc, // Internal path alias used by frontend-core\n * }),\n * },\n * })\n * ```\n */\nexport function createSourceAliases(\n aliases: Record<string, string>,\n): Record<string, string> {\n return aliases\n}\n\n/**\n * Creates fs.allow paths for serving files from external directories.\n *\n * @param paths - Array of absolute paths to allow\n */\nexport function createFsAllowPaths(paths: Array<string>): Array<string> {\n return paths\n}\n"],"names":[],"mappings":"AAyCO,SAAS,oBACd,SACQ;AACR,QAAM,EAAE,MAAM,SAAS,WAAW,QAAQ;AAC1C,MAAI,UAA+C;AAEnD,SAAO;AAAA,IACL,MAAM,yBAAyB,IAAI;AAAA,IACnC,gBAAgB,QAAuB;AAErC,aAAO,oEAAU,EAAE,KAAK,CAAC,EAAE,YAAY;AACrC,kBAAU,MAAM,SAAS;AAAA,UACvB,eAAe;AAAA,UACf,YAAY;AAAA;AAAA,UACZ;AAAA,QAAA,CACD;AAED,gBAAQ,GAAG,SAAS,MAAM;AACxB,kBAAQ,IAAI,kBAAkB,IAAI,cAAc;AAAA,QAClD,CAAC;AAED,gBAAQ,GAAG,UAAU,OAAO,SAAiB;AArB9C;AAsBG,gBAAM,YAAY,KAAK,QAAQ,SAAS,GAAG,IAAI,MAAM;AACrD,kBAAQ,IAAI,SAAS,SAAS,UAAU;AAGxC,cAAI,UAAU,OAAO,YAAY,iBAAiB,IAAI;AAGtD,cAAI,CAAC,WAAW,QAAQ,SAAS,GAAG;AAClC,kBAAM,aAAa,CAAC,GAAG,OAAO,YAAY,cAAc,QAAQ;AAChE,kBAAM,WAAW,KAAK,MAAM,GAAG,EAAE,SAAS;AAC1C,kBAAM,kBAAkB,WAAW,OAAO,CAAC,QAAQ;AACjD,kBAAI,CAAC,I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}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@igstack/app-catalog-frontend-build-vite",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vite build config for App Catalog frontend",
|
|
5
|
+
"homepage": "https://github.com/lislon/app-catalog",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lislon/app-catalog.git",
|
|
9
|
+
"directory": "packages/frontend-build-vite"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Igor Golovin",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"my-custom-condition": "./src/index.ts",
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/esm/index.d.ts",
|
|
20
|
+
"default": "./dist/esm/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"module": "dist/esm/index.js",
|
|
26
|
+
"types": "dist/esm/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@tailwindcss/vite": "^4.0.5",
|
|
33
|
+
"@tanstack/react-router-devtools": "^1.151.6",
|
|
34
|
+
"@tanstack/router-plugin": "^1.151.6",
|
|
35
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
36
|
+
"vite-plugin-pwa": "^1.0.0",
|
|
37
|
+
"vite-plugin-static-copy": "^3.1.4",
|
|
38
|
+
"vite-plugin-svgr": "^4.2.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@tanstack/vite-config": "^0.4.3",
|
|
42
|
+
"@types/node": "^24.3.0",
|
|
43
|
+
"chokidar": "^5.0.0",
|
|
44
|
+
"esbuild": "^0.25.5",
|
|
45
|
+
"tsx": "^4.19.4",
|
|
46
|
+
"typescript": "5.9.2",
|
|
47
|
+
"vite": "^6.3.5",
|
|
48
|
+
"@igstack/app-catalog-shared-core": "0.0.1"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"vite": "^6.3.5",
|
|
52
|
+
"vite-plugin-svgr": "^4.2.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=16"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "vite build",
|
|
59
|
+
"build:lenient": "vite build --mode lenient",
|
|
60
|
+
"clean": "premove ./dist ./coverage ./dist-ts",
|
|
61
|
+
"compile": "tsc --build",
|
|
62
|
+
"test:eslint": "eslint ./src"
|
|
63
|
+
}
|
|
64
|
+
}
|