nitro-nightly 3.0.1-20260124-165031-9c6abf17 → 3.0.1-20260127-164246-ef01b092
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/dist/_build/common.mjs +2084 -3212
- package/dist/_build/rolldown.mjs +12 -25
- package/dist/_build/rollup.mjs +11 -27
- package/dist/_build/vite.build.mjs +7 -11
- package/dist/_chunks/dev.mjs +20 -42
- package/dist/_chunks/nitro.mjs +13 -92
- package/dist/_chunks/nitro2.mjs +1 -5
- package/dist/_chunks/utils.mjs +10 -24
- package/dist/_common.mjs +12 -24
- package/dist/_libs/citty.mjs +1 -13
- package/dist/_libs/commondir+is-reference.mjs +12 -22
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/confbox.mjs +363 -376
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/hasown+resolve+deepmerge.mjs +144 -230
- package/dist/_libs/httpxy.mjs +5 -21
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/nypm+giget+tinyexec.mjs +874 -926
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -5
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +2 -2
- package/dist/_libs/pluginutils.mjs +1 -31
- package/dist/_libs/rc9+c12+dotenv.mjs +43 -83
- package/dist/_libs/readdirp+chokidar.mjs +184 -360
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +12 -48
- package/dist/_libs/rou3.mjs +1 -32
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +15 -75
- package/dist/_presets.mjs +260 -445
- package/dist/builder.mjs +1 -2
- package/dist/cli/_chunks/build.mjs +1 -5
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/dev.mjs +1 -5
- package/dist/cli/_chunks/list.mjs +1 -5
- package/dist/cli/_chunks/prepare.mjs +1 -5
- package/dist/cli/_chunks/run.mjs +1 -5
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +1 -5
- package/dist/types/index.d.mts +5 -5
- package/dist/types/index.mjs +1 -2
- package/dist/vite.mjs +44 -63
- package/package.json +21 -21
|
@@ -6,8 +6,6 @@ import * as sp from "node:path";
|
|
|
6
6
|
import { join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { EventEmitter } from "node:events";
|
|
8
8
|
import { Readable } from "node:stream";
|
|
9
|
-
|
|
10
|
-
//#region node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js
|
|
11
9
|
const EntryTypes = {
|
|
12
10
|
FILE_TYPE: "files",
|
|
13
11
|
DIR_TYPE: "directories",
|
|
@@ -65,7 +63,6 @@ const normalizeFilter = (filter) => {
|
|
|
65
63
|
}
|
|
66
64
|
return emptyFn;
|
|
67
65
|
};
|
|
68
|
-
/** Readable readdir stream, emitting new files as they're being listed. */
|
|
69
66
|
var ReaddirpStream = class extends Readable {
|
|
70
67
|
parents;
|
|
71
68
|
reading;
|
|
@@ -91,16 +88,16 @@ var ReaddirpStream = class extends Readable {
|
|
|
91
88
|
...defaultOptions,
|
|
92
89
|
...options
|
|
93
90
|
};
|
|
94
|
-
const { root, type
|
|
91
|
+
const { root, type } = opts;
|
|
95
92
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
96
93
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
97
94
|
const statMethod = opts.lstat ? lstat : stat$1;
|
|
98
|
-
if (wantBigintFsStats) this._stat = (path
|
|
95
|
+
if (wantBigintFsStats) this._stat = (path) => statMethod(path, { bigint: true });
|
|
99
96
|
else this._stat = statMethod;
|
|
100
97
|
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
101
|
-
this._wantsDir = type
|
|
102
|
-
this._wantsFile = type
|
|
103
|
-
this._wantsEverything = type
|
|
98
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
99
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
100
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
104
101
|
this._root = resolve(root);
|
|
105
102
|
this._isDirent = !opts.alwaysStat;
|
|
106
103
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
@@ -120,8 +117,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
120
117
|
const par = this.parent;
|
|
121
118
|
const fil = par && par.files;
|
|
122
119
|
if (fil && fil.length > 0) {
|
|
123
|
-
const { path
|
|
124
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path
|
|
120
|
+
const { path, depth } = par;
|
|
121
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
|
|
125
122
|
const awaited = await Promise.all(slice);
|
|
126
123
|
for (const entry of awaited) {
|
|
127
124
|
if (!entry) continue;
|
|
@@ -156,28 +153,28 @@ var ReaddirpStream = class extends Readable {
|
|
|
156
153
|
this.reading = false;
|
|
157
154
|
}
|
|
158
155
|
}
|
|
159
|
-
async _exploreDir(path
|
|
156
|
+
async _exploreDir(path, depth) {
|
|
160
157
|
let files;
|
|
161
158
|
try {
|
|
162
|
-
files = await readdir(path
|
|
159
|
+
files = await readdir(path, this._rdOptions);
|
|
163
160
|
} catch (error) {
|
|
164
161
|
this._onError(error);
|
|
165
162
|
}
|
|
166
163
|
return {
|
|
167
164
|
files,
|
|
168
165
|
depth,
|
|
169
|
-
path
|
|
166
|
+
path
|
|
170
167
|
};
|
|
171
168
|
}
|
|
172
|
-
async _formatEntry(dirent, path
|
|
169
|
+
async _formatEntry(dirent, path) {
|
|
173
170
|
let entry;
|
|
174
|
-
const basename
|
|
171
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
175
172
|
try {
|
|
176
|
-
const fullPath = resolve(join(path
|
|
173
|
+
const fullPath = resolve(join(path, basename));
|
|
177
174
|
entry = {
|
|
178
175
|
path: relative(this._root, fullPath),
|
|
179
176
|
fullPath,
|
|
180
|
-
basename
|
|
177
|
+
basename
|
|
181
178
|
};
|
|
182
179
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
183
180
|
} catch (err) {
|
|
@@ -221,25 +218,16 @@ var ReaddirpStream = class extends Readable {
|
|
|
221
218
|
return stats && this._wantsEverything && !stats.isDirectory();
|
|
222
219
|
}
|
|
223
220
|
};
|
|
224
|
-
/**
|
|
225
|
-
* Streaming version: Reads all files and directories in given root recursively.
|
|
226
|
-
* Consumes ~constant small amount of RAM.
|
|
227
|
-
* @param root Root directory
|
|
228
|
-
* @param options Options to specify root (start directory), filters and recursion depth
|
|
229
|
-
*/
|
|
230
221
|
function readdirp(root, options = {}) {
|
|
231
|
-
let type
|
|
232
|
-
if (type
|
|
233
|
-
if (type
|
|
222
|
+
let type = options.entryType || options.type;
|
|
223
|
+
if (type === "both") type = EntryTypes.FILE_DIR_TYPE;
|
|
224
|
+
if (type) options.type = type;
|
|
234
225
|
if (!root) throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
235
226
|
else if (typeof root !== "string") throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
236
|
-
else if (type
|
|
227
|
+
else if (type && !ALL_TYPES.includes(type)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
237
228
|
options.root = root;
|
|
238
229
|
return new ReaddirpStream(options);
|
|
239
230
|
}
|
|
240
|
-
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js
|
|
243
231
|
const STR_DATA = "data";
|
|
244
232
|
const STR_END = "end";
|
|
245
233
|
const STR_CLOSE = "close";
|
|
@@ -560,32 +548,19 @@ const delFromSet = (main, prop, item) => {
|
|
|
560
548
|
};
|
|
561
549
|
const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
562
550
|
const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
563
|
-
|
|
564
|
-
* Instantiates the fs_watch interface
|
|
565
|
-
* @param path to be watched
|
|
566
|
-
* @param options to be passed to fs_watch
|
|
567
|
-
* @param listener main event handler
|
|
568
|
-
* @param errHandler emits info about errors
|
|
569
|
-
* @param emitRaw emits raw event data
|
|
570
|
-
* @returns {NativeFsWatcher}
|
|
571
|
-
*/
|
|
572
|
-
function createFsWatchInstance(path$1, options, listener, errHandler, emitRaw) {
|
|
551
|
+
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
573
552
|
const handleEvent = (rawEvent, evPath) => {
|
|
574
|
-
listener(path
|
|
575
|
-
emitRaw(rawEvent, evPath, { watchedPath: path
|
|
576
|
-
if (evPath && path
|
|
553
|
+
listener(path);
|
|
554
|
+
emitRaw(rawEvent, evPath, { watchedPath: path });
|
|
555
|
+
if (evPath && path !== evPath) fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
|
|
577
556
|
};
|
|
578
557
|
try {
|
|
579
|
-
return watch(path
|
|
558
|
+
return watch(path, { persistent: options.persistent }, handleEvent);
|
|
580
559
|
} catch (error) {
|
|
581
560
|
errHandler(error);
|
|
582
561
|
return;
|
|
583
562
|
}
|
|
584
563
|
}
|
|
585
|
-
/**
|
|
586
|
-
* Helper for passing fs_watch event data to a collection of listeners
|
|
587
|
-
* @param fullPath absolute path bound to fs_watch instance
|
|
588
|
-
*/
|
|
589
564
|
const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
590
565
|
const cont = FsWatchInstances.get(fullPath);
|
|
591
566
|
if (!cont) return;
|
|
@@ -593,20 +568,12 @@ const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
593
568
|
listener(val1, val2, val3);
|
|
594
569
|
});
|
|
595
570
|
};
|
|
596
|
-
|
|
597
|
-
* Instantiates the fs_watch interface or binds listeners
|
|
598
|
-
* to an existing one covering the same file system entry
|
|
599
|
-
* @param path
|
|
600
|
-
* @param fullPath absolute path
|
|
601
|
-
* @param options to be passed to fs_watch
|
|
602
|
-
* @param handlers container for event listener functions
|
|
603
|
-
*/
|
|
604
|
-
const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
571
|
+
const setFsWatchListener = (path, fullPath, options, handlers) => {
|
|
605
572
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
606
573
|
let cont = FsWatchInstances.get(fullPath);
|
|
607
574
|
let watcher;
|
|
608
575
|
if (!options.persistent) {
|
|
609
|
-
watcher = createFsWatchInstance(path
|
|
576
|
+
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
|
610
577
|
if (!watcher) return;
|
|
611
578
|
return watcher.close.bind(watcher);
|
|
612
579
|
}
|
|
@@ -615,13 +582,13 @@ const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
|
615
582
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
616
583
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
617
584
|
} else {
|
|
618
|
-
watcher = createFsWatchInstance(path
|
|
585
|
+
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
619
586
|
if (!watcher) return;
|
|
620
587
|
watcher.on(EV.ERROR, async (error) => {
|
|
621
588
|
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
622
589
|
if (cont) cont.watcherUnusable = true;
|
|
623
590
|
if (isWindows && error.code === "EPERM") try {
|
|
624
|
-
await (await open(path
|
|
591
|
+
await (await open(path, "r")).close();
|
|
625
592
|
broadcastErr(error);
|
|
626
593
|
} catch (err) {}
|
|
627
594
|
else broadcastErr(error);
|
|
@@ -648,16 +615,7 @@ const setFsWatchListener = (path$1, fullPath, options, handlers) => {
|
|
|
648
615
|
};
|
|
649
616
|
};
|
|
650
617
|
const FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
651
|
-
|
|
652
|
-
* Instantiates the fs_watchFile interface or binds listeners
|
|
653
|
-
* to an existing one covering the same file system entry
|
|
654
|
-
* @param path to be watched
|
|
655
|
-
* @param fullPath absolute path
|
|
656
|
-
* @param options options to be passed to fs_watchFile
|
|
657
|
-
* @param handlers container for event listener functions
|
|
658
|
-
* @returns closer
|
|
659
|
-
*/
|
|
660
|
-
const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
618
|
+
const setFsWatchFileListener = (path, fullPath, options, handlers) => {
|
|
661
619
|
const { listener, rawEmitter } = handlers;
|
|
662
620
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
663
621
|
const copts = cont && cont.options;
|
|
@@ -674,14 +632,14 @@ const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
|
674
632
|
rawEmitters: rawEmitter,
|
|
675
633
|
options,
|
|
676
634
|
watcher: watchFile(fullPath, options, (curr, prev) => {
|
|
677
|
-
foreach(cont.rawEmitters, (rawEmitter
|
|
678
|
-
rawEmitter
|
|
635
|
+
foreach(cont.rawEmitters, (rawEmitter) => {
|
|
636
|
+
rawEmitter(EV.CHANGE, fullPath, {
|
|
679
637
|
curr,
|
|
680
638
|
prev
|
|
681
639
|
});
|
|
682
640
|
});
|
|
683
641
|
const currmtime = curr.mtimeMs;
|
|
684
|
-
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener
|
|
642
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener) => listener(path, curr));
|
|
685
643
|
})
|
|
686
644
|
};
|
|
687
645
|
FsWatchFileInstances.set(fullPath, cont);
|
|
@@ -697,9 +655,6 @@ const setFsWatchFileListener = (path$1, fullPath, options, handlers) => {
|
|
|
697
655
|
}
|
|
698
656
|
};
|
|
699
657
|
};
|
|
700
|
-
/**
|
|
701
|
-
* @mixin
|
|
702
|
-
*/
|
|
703
658
|
var NodeFsHandler = class {
|
|
704
659
|
fsw;
|
|
705
660
|
_boundHandleError;
|
|
@@ -707,63 +662,53 @@ var NodeFsHandler = class {
|
|
|
707
662
|
this.fsw = fsW;
|
|
708
663
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
709
664
|
}
|
|
710
|
-
|
|
711
|
-
* Watch file for changes with fs_watchFile or fs_watch.
|
|
712
|
-
* @param path to file or dir
|
|
713
|
-
* @param listener on fs change
|
|
714
|
-
* @returns closer for the watcher instance
|
|
715
|
-
*/
|
|
716
|
-
_watchWithNodeFs(path$1, listener) {
|
|
665
|
+
_watchWithNodeFs(path, listener) {
|
|
717
666
|
const opts = this.fsw.options;
|
|
718
|
-
const directory = sp.dirname(path
|
|
719
|
-
const basename
|
|
720
|
-
this.fsw._getWatchedDir(directory).add(basename
|
|
721
|
-
const absolutePath = sp.resolve(path
|
|
667
|
+
const directory = sp.dirname(path);
|
|
668
|
+
const basename = sp.basename(path);
|
|
669
|
+
this.fsw._getWatchedDir(directory).add(basename);
|
|
670
|
+
const absolutePath = sp.resolve(path);
|
|
722
671
|
const options = { persistent: opts.persistent };
|
|
723
672
|
if (!listener) listener = EMPTY_FN;
|
|
724
673
|
let closer;
|
|
725
674
|
if (opts.usePolling) {
|
|
726
|
-
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename
|
|
727
|
-
closer = setFsWatchFileListener(path
|
|
675
|
+
options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
|
676
|
+
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
728
677
|
listener,
|
|
729
678
|
rawEmitter: this.fsw._emitRaw
|
|
730
679
|
});
|
|
731
|
-
} else closer = setFsWatchListener(path
|
|
680
|
+
} else closer = setFsWatchListener(path, absolutePath, options, {
|
|
732
681
|
listener,
|
|
733
682
|
errHandler: this._boundHandleError,
|
|
734
683
|
rawEmitter: this.fsw._emitRaw
|
|
735
684
|
});
|
|
736
685
|
return closer;
|
|
737
686
|
}
|
|
738
|
-
/**
|
|
739
|
-
* Watch a file and emit add event if warranted.
|
|
740
|
-
* @returns closer for the watcher instance
|
|
741
|
-
*/
|
|
742
687
|
_handleFile(file, stats, initialAdd) {
|
|
743
688
|
if (this.fsw.closed) return;
|
|
744
|
-
const dirname
|
|
745
|
-
const basename
|
|
746
|
-
const parent = this.fsw._getWatchedDir(dirname
|
|
689
|
+
const dirname = sp.dirname(file);
|
|
690
|
+
const basename = sp.basename(file);
|
|
691
|
+
const parent = this.fsw._getWatchedDir(dirname);
|
|
747
692
|
let prevStats = stats;
|
|
748
|
-
if (parent.has(basename
|
|
749
|
-
const listener = async (path
|
|
693
|
+
if (parent.has(basename)) return;
|
|
694
|
+
const listener = async (path, newStats) => {
|
|
750
695
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
|
|
751
696
|
if (!newStats || newStats.mtimeMs === 0) try {
|
|
752
|
-
const newStats
|
|
697
|
+
const newStats = await stat$1(file);
|
|
753
698
|
if (this.fsw.closed) return;
|
|
754
|
-
const at = newStats
|
|
755
|
-
const mt = newStats
|
|
756
|
-
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats
|
|
757
|
-
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats
|
|
758
|
-
this.fsw._closeFile(path
|
|
759
|
-
prevStats = newStats
|
|
760
|
-
const closer
|
|
761
|
-
if (closer
|
|
762
|
-
} else prevStats = newStats
|
|
699
|
+
const at = newStats.atimeMs;
|
|
700
|
+
const mt = newStats.mtimeMs;
|
|
701
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
702
|
+
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
|
|
703
|
+
this.fsw._closeFile(path);
|
|
704
|
+
prevStats = newStats;
|
|
705
|
+
const closer = this._watchWithNodeFs(file, listener);
|
|
706
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
707
|
+
} else prevStats = newStats;
|
|
763
708
|
} catch (error) {
|
|
764
|
-
this.fsw._remove(dirname
|
|
709
|
+
this.fsw._remove(dirname, basename);
|
|
765
710
|
}
|
|
766
|
-
else if (parent.has(basename
|
|
711
|
+
else if (parent.has(basename)) {
|
|
767
712
|
const at = newStats.atimeMs;
|
|
768
713
|
const mt = newStats.mtimeMs;
|
|
769
714
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
|
|
@@ -777,15 +722,7 @@ var NodeFsHandler = class {
|
|
|
777
722
|
}
|
|
778
723
|
return closer;
|
|
779
724
|
}
|
|
780
|
-
|
|
781
|
-
* Handle symlinks encountered while reading a dir.
|
|
782
|
-
* @param entry returned by readdirp
|
|
783
|
-
* @param directory path of dir being read
|
|
784
|
-
* @param path of this item
|
|
785
|
-
* @param item basename of this item
|
|
786
|
-
* @returns true if no more processing is needed for this entry.
|
|
787
|
-
*/
|
|
788
|
-
async _handleSymlink(entry, directory, path$1, item) {
|
|
725
|
+
async _handleSymlink(entry, directory, path, item) {
|
|
789
726
|
if (this.fsw.closed) return;
|
|
790
727
|
const full = entry.fullPath;
|
|
791
728
|
const dir = this.fsw._getWatchedDir(directory);
|
|
@@ -793,7 +730,7 @@ var NodeFsHandler = class {
|
|
|
793
730
|
this.fsw._incrReadyCount();
|
|
794
731
|
let linkPath;
|
|
795
732
|
try {
|
|
796
|
-
linkPath = await realpath(path
|
|
733
|
+
linkPath = await realpath(path);
|
|
797
734
|
} catch (e) {
|
|
798
735
|
this.fsw._emitReady();
|
|
799
736
|
return true;
|
|
@@ -802,12 +739,12 @@ var NodeFsHandler = class {
|
|
|
802
739
|
if (dir.has(item)) {
|
|
803
740
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
804
741
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
805
|
-
this.fsw._emit(EV.CHANGE, path
|
|
742
|
+
this.fsw._emit(EV.CHANGE, path, entry.stats);
|
|
806
743
|
}
|
|
807
744
|
} else {
|
|
808
745
|
dir.add(item);
|
|
809
746
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
810
|
-
this.fsw._emit(EV.ADD, path
|
|
747
|
+
this.fsw._emit(EV.ADD, path, entry.stats);
|
|
811
748
|
}
|
|
812
749
|
this.fsw._emitReady();
|
|
813
750
|
return true;
|
|
@@ -833,20 +770,20 @@ var NodeFsHandler = class {
|
|
|
833
770
|
return;
|
|
834
771
|
}
|
|
835
772
|
const item = entry.path;
|
|
836
|
-
let path
|
|
773
|
+
let path = sp.join(directory, item);
|
|
837
774
|
current.add(item);
|
|
838
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path
|
|
775
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) return;
|
|
839
776
|
if (this.fsw.closed) {
|
|
840
777
|
stream = void 0;
|
|
841
778
|
return;
|
|
842
779
|
}
|
|
843
780
|
if (item === target || !target && !previous.has(item)) {
|
|
844
781
|
this.fsw._incrReadyCount();
|
|
845
|
-
path
|
|
846
|
-
this._addToNodeFs(path
|
|
782
|
+
path = sp.join(dir, sp.relative(dir, path));
|
|
783
|
+
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
847
784
|
}
|
|
848
785
|
}).on(EV.ERROR, this._boundHandleError);
|
|
849
|
-
return new Promise((resolve
|
|
786
|
+
return new Promise((resolve, reject) => {
|
|
850
787
|
if (!stream) return reject();
|
|
851
788
|
stream.once(STR_END, () => {
|
|
852
789
|
if (this.fsw.closed) {
|
|
@@ -854,7 +791,7 @@ var NodeFsHandler = class {
|
|
|
854
791
|
return;
|
|
855
792
|
}
|
|
856
793
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
857
|
-
resolve
|
|
794
|
+
resolve(void 0);
|
|
858
795
|
previous.getChildren().filter((item) => {
|
|
859
796
|
return item !== directory && !current.has(item);
|
|
860
797
|
}).forEach((item) => {
|
|
@@ -865,18 +802,7 @@ var NodeFsHandler = class {
|
|
|
865
802
|
});
|
|
866
803
|
});
|
|
867
804
|
}
|
|
868
|
-
|
|
869
|
-
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
|
870
|
-
* @param dir fs path
|
|
871
|
-
* @param stats
|
|
872
|
-
* @param initialAdd
|
|
873
|
-
* @param depth relative to user-supplied path
|
|
874
|
-
* @param target child path targeted for watch
|
|
875
|
-
* @param wh Common watch helpers for this path
|
|
876
|
-
* @param realpath
|
|
877
|
-
* @returns closer for the watcher instance.
|
|
878
|
-
*/
|
|
879
|
-
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath$1) {
|
|
805
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
880
806
|
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
881
807
|
const tracked = parentDir.has(sp.basename(dir));
|
|
882
808
|
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
@@ -885,34 +811,25 @@ var NodeFsHandler = class {
|
|
|
885
811
|
let throttler;
|
|
886
812
|
let closer;
|
|
887
813
|
const oDepth = this.fsw.options.depth;
|
|
888
|
-
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath
|
|
814
|
+
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
|
889
815
|
if (!target) {
|
|
890
816
|
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
891
817
|
if (this.fsw.closed) return;
|
|
892
818
|
}
|
|
893
|
-
closer = this._watchWithNodeFs(dir, (dirPath, stats
|
|
894
|
-
if (stats
|
|
819
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
|
|
820
|
+
if (stats && stats.mtimeMs === 0) return;
|
|
895
821
|
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
896
822
|
});
|
|
897
823
|
}
|
|
898
824
|
return closer;
|
|
899
825
|
}
|
|
900
|
-
|
|
901
|
-
* Handle added file, directory, or glob pattern.
|
|
902
|
-
* Delegates call to _handleFile / _handleDir after checks.
|
|
903
|
-
* @param path to file or ir
|
|
904
|
-
* @param initialAdd was the file added at watch instantiation?
|
|
905
|
-
* @param priorWh depth relative to user-supplied path
|
|
906
|
-
* @param depth Child path actually targeted for watch
|
|
907
|
-
* @param target Child path actually targeted for watch
|
|
908
|
-
*/
|
|
909
|
-
async _addToNodeFs(path$1, initialAdd, priorWh, depth, target) {
|
|
826
|
+
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
|
910
827
|
const ready = this.fsw._emitReady;
|
|
911
|
-
if (this.fsw._isIgnored(path
|
|
828
|
+
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
|
912
829
|
ready();
|
|
913
830
|
return false;
|
|
914
831
|
}
|
|
915
|
-
const wh = this.fsw._getWatchHelpers(path
|
|
832
|
+
const wh = this.fsw._getWatchHelpers(path);
|
|
916
833
|
if (priorWh) {
|
|
917
834
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
918
835
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -927,36 +844,33 @@ var NodeFsHandler = class {
|
|
|
927
844
|
const follow = this.fsw.options.followSymlinks;
|
|
928
845
|
let closer;
|
|
929
846
|
if (stats.isDirectory()) {
|
|
930
|
-
const absPath = sp.resolve(path
|
|
931
|
-
const targetPath = follow ? await realpath(path
|
|
847
|
+
const absPath = sp.resolve(path);
|
|
848
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
932
849
|
if (this.fsw.closed) return;
|
|
933
850
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
934
851
|
if (this.fsw.closed) return;
|
|
935
852
|
if (absPath !== targetPath && targetPath !== void 0) this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
936
853
|
} else if (stats.isSymbolicLink()) {
|
|
937
|
-
const targetPath = follow ? await realpath(path
|
|
854
|
+
const targetPath = follow ? await realpath(path) : path;
|
|
938
855
|
if (this.fsw.closed) return;
|
|
939
856
|
const parent = sp.dirname(wh.watchPath);
|
|
940
857
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
941
858
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
942
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth, path
|
|
859
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
943
860
|
if (this.fsw.closed) return;
|
|
944
|
-
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path
|
|
861
|
+
if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
|
|
945
862
|
} else closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
946
863
|
ready();
|
|
947
|
-
if (closer) this.fsw._addPathCloser(path
|
|
864
|
+
if (closer) this.fsw._addPathCloser(path, closer);
|
|
948
865
|
return false;
|
|
949
866
|
} catch (error) {
|
|
950
867
|
if (this.fsw._handleError(error)) {
|
|
951
868
|
ready();
|
|
952
|
-
return path
|
|
869
|
+
return path;
|
|
953
870
|
}
|
|
954
871
|
}
|
|
955
872
|
}
|
|
956
873
|
};
|
|
957
|
-
|
|
958
|
-
//#endregion
|
|
959
|
-
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js
|
|
960
874
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
961
875
|
var chokidar_exports = /* @__PURE__ */ __exportAll({
|
|
962
876
|
FSWatcher: () => FSWatcher,
|
|
@@ -984,37 +898,37 @@ function createPattern(matcher) {
|
|
|
984
898
|
if (typeof matcher === "object" && matcher !== null) return (string) => {
|
|
985
899
|
if (matcher.path === string) return true;
|
|
986
900
|
if (matcher.recursive) {
|
|
987
|
-
const relative
|
|
988
|
-
if (!relative
|
|
989
|
-
return !relative
|
|
901
|
+
const relative = sp.relative(matcher.path, string);
|
|
902
|
+
if (!relative) return false;
|
|
903
|
+
return !relative.startsWith("..") && !sp.isAbsolute(relative);
|
|
990
904
|
}
|
|
991
905
|
return false;
|
|
992
906
|
};
|
|
993
907
|
return () => false;
|
|
994
908
|
}
|
|
995
|
-
function normalizePath(path
|
|
996
|
-
if (typeof path
|
|
997
|
-
path
|
|
998
|
-
path
|
|
909
|
+
function normalizePath(path) {
|
|
910
|
+
if (typeof path !== "string") throw new Error("string expected");
|
|
911
|
+
path = sp.normalize(path);
|
|
912
|
+
path = path.replace(/\\/g, "/");
|
|
999
913
|
let prepend = false;
|
|
1000
|
-
if (path
|
|
1001
|
-
path
|
|
1002
|
-
if (prepend) path
|
|
1003
|
-
return path
|
|
914
|
+
if (path.startsWith("//")) prepend = true;
|
|
915
|
+
path = path.replace(DOUBLE_SLASH_RE, "/");
|
|
916
|
+
if (prepend) path = "/" + path;
|
|
917
|
+
return path;
|
|
1004
918
|
}
|
|
1005
919
|
function matchPatterns(patterns, testString, stats) {
|
|
1006
|
-
const path
|
|
920
|
+
const path = normalizePath(testString);
|
|
1007
921
|
for (let index = 0; index < patterns.length; index++) {
|
|
1008
922
|
const pattern = patterns[index];
|
|
1009
|
-
if (pattern(path
|
|
923
|
+
if (pattern(path, stats)) return true;
|
|
1010
924
|
}
|
|
1011
925
|
return false;
|
|
1012
926
|
}
|
|
1013
927
|
function anymatch(matchers, testString) {
|
|
1014
928
|
if (matchers == null) throw new TypeError("anymatch: specify first argument");
|
|
1015
929
|
const patterns = arrify(matchers).map((matcher) => createPattern(matcher));
|
|
1016
|
-
if (testString == null) return (testString
|
|
1017
|
-
return matchPatterns(patterns, testString
|
|
930
|
+
if (testString == null) return (testString, stats) => {
|
|
931
|
+
return matchPatterns(patterns, testString, stats);
|
|
1018
932
|
};
|
|
1019
933
|
return matchPatterns(patterns, testString);
|
|
1020
934
|
}
|
|
@@ -1031,19 +945,16 @@ const toUnix = (string) => {
|
|
|
1031
945
|
if (prepend) str = SLASH + str;
|
|
1032
946
|
return str;
|
|
1033
947
|
};
|
|
1034
|
-
const normalizePathToUnix = (path
|
|
1035
|
-
const normalizeIgnored = (cwd = "") => (path
|
|
1036
|
-
if (typeof path
|
|
1037
|
-
else return path
|
|
948
|
+
const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
|
|
949
|
+
const normalizeIgnored = (cwd = "") => (path) => {
|
|
950
|
+
if (typeof path === "string") return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
|
|
951
|
+
else return path;
|
|
1038
952
|
};
|
|
1039
|
-
const getAbsolutePath = (path
|
|
1040
|
-
if (sp.isAbsolute(path
|
|
1041
|
-
return sp.join(cwd, path
|
|
953
|
+
const getAbsolutePath = (path, cwd) => {
|
|
954
|
+
if (sp.isAbsolute(path)) return path;
|
|
955
|
+
return sp.join(cwd, path);
|
|
1042
956
|
};
|
|
1043
957
|
const EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
1044
|
-
/**
|
|
1045
|
-
* Directory entry.
|
|
1046
|
-
*/
|
|
1047
958
|
var DirEntry = class {
|
|
1048
959
|
path;
|
|
1049
960
|
_removeWatcher;
|
|
@@ -1098,10 +1009,10 @@ var WatchHelper = class {
|
|
|
1098
1009
|
dirParts;
|
|
1099
1010
|
followSymlinks;
|
|
1100
1011
|
statMethod;
|
|
1101
|
-
constructor(path
|
|
1012
|
+
constructor(path, follow, fsw) {
|
|
1102
1013
|
this.fsw = fsw;
|
|
1103
|
-
const watchPath = path
|
|
1104
|
-
this.path = path
|
|
1014
|
+
const watchPath = path;
|
|
1015
|
+
this.path = path = path.replace(REPLACER_RE, "");
|
|
1105
1016
|
this.watchPath = watchPath;
|
|
1106
1017
|
this.fullWatchPath = sp.resolve(watchPath);
|
|
1107
1018
|
this.dirParts = [];
|
|
@@ -1124,14 +1035,6 @@ var WatchHelper = class {
|
|
|
1124
1035
|
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
1125
1036
|
}
|
|
1126
1037
|
};
|
|
1127
|
-
/**
|
|
1128
|
-
* Watches files & directories for changes. Emitted events:
|
|
1129
|
-
* `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
|
|
1130
|
-
*
|
|
1131
|
-
* new FSWatcher()
|
|
1132
|
-
* .add(directories)
|
|
1133
|
-
* .on('add', path => log('File', path, 'was added'))
|
|
1134
|
-
*/
|
|
1135
1038
|
var FSWatcher = class extends EventEmitter {
|
|
1136
1039
|
closed;
|
|
1137
1040
|
options;
|
|
@@ -1223,26 +1126,22 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1223
1126
|
for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher) this._ignoredPaths.delete(ignored);
|
|
1224
1127
|
}
|
|
1225
1128
|
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Adds paths to be watched on an existing FSWatcher instance.
|
|
1228
|
-
* @param paths_ file or file list. Other arguments are unused
|
|
1229
|
-
*/
|
|
1230
1129
|
add(paths_, _origAdd, _internal) {
|
|
1231
1130
|
const { cwd } = this.options;
|
|
1232
1131
|
this.closed = false;
|
|
1233
1132
|
this._closePromise = void 0;
|
|
1234
1133
|
let paths = unifyPaths(paths_);
|
|
1235
|
-
if (cwd) paths = paths.map((path
|
|
1236
|
-
return getAbsolutePath(path
|
|
1134
|
+
if (cwd) paths = paths.map((path) => {
|
|
1135
|
+
return getAbsolutePath(path, cwd);
|
|
1237
1136
|
});
|
|
1238
|
-
paths.forEach((path
|
|
1239
|
-
this._removeIgnoredPath(path
|
|
1137
|
+
paths.forEach((path) => {
|
|
1138
|
+
this._removeIgnoredPath(path);
|
|
1240
1139
|
});
|
|
1241
1140
|
this._userIgnored = void 0;
|
|
1242
1141
|
if (!this._readyCount) this._readyCount = 0;
|
|
1243
1142
|
this._readyCount += paths.length;
|
|
1244
|
-
Promise.all(paths.map(async (path
|
|
1245
|
-
const res = await this._nodeFsHandler._addToNodeFs(path
|
|
1143
|
+
Promise.all(paths.map(async (path) => {
|
|
1144
|
+
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
|
|
1246
1145
|
if (res) this._emitReady();
|
|
1247
1146
|
return res;
|
|
1248
1147
|
})).then((results) => {
|
|
@@ -1253,31 +1152,25 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1253
1152
|
});
|
|
1254
1153
|
return this;
|
|
1255
1154
|
}
|
|
1256
|
-
/**
|
|
1257
|
-
* Close watchers or start ignoring events from specified paths.
|
|
1258
|
-
*/
|
|
1259
1155
|
unwatch(paths_) {
|
|
1260
1156
|
if (this.closed) return this;
|
|
1261
1157
|
const paths = unifyPaths(paths_);
|
|
1262
1158
|
const { cwd } = this.options;
|
|
1263
|
-
paths.forEach((path
|
|
1264
|
-
if (!sp.isAbsolute(path
|
|
1265
|
-
if (cwd) path
|
|
1266
|
-
path
|
|
1159
|
+
paths.forEach((path) => {
|
|
1160
|
+
if (!sp.isAbsolute(path) && !this._closers.has(path)) {
|
|
1161
|
+
if (cwd) path = sp.join(cwd, path);
|
|
1162
|
+
path = sp.resolve(path);
|
|
1267
1163
|
}
|
|
1268
|
-
this._closePath(path
|
|
1269
|
-
this._addIgnoredPath(path
|
|
1270
|
-
if (this._watched.has(path
|
|
1271
|
-
path
|
|
1164
|
+
this._closePath(path);
|
|
1165
|
+
this._addIgnoredPath(path);
|
|
1166
|
+
if (this._watched.has(path)) this._addIgnoredPath({
|
|
1167
|
+
path,
|
|
1272
1168
|
recursive: true
|
|
1273
1169
|
});
|
|
1274
1170
|
this._userIgnored = void 0;
|
|
1275
1171
|
});
|
|
1276
1172
|
return this;
|
|
1277
1173
|
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Close watchers and remove all listeners from watched paths.
|
|
1280
|
-
*/
|
|
1281
1174
|
close() {
|
|
1282
1175
|
if (this._closePromise) return this._closePromise;
|
|
1283
1176
|
this.closed = true;
|
|
@@ -1300,10 +1193,6 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1300
1193
|
this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
|
|
1301
1194
|
return this._closePromise;
|
|
1302
1195
|
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Expose list of watched paths
|
|
1305
|
-
* @returns for chaining
|
|
1306
|
-
*/
|
|
1307
1196
|
getWatched() {
|
|
1308
1197
|
const watchList = {};
|
|
1309
1198
|
this._watched.forEach((entry, dir) => {
|
|
@@ -1316,104 +1205,85 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1316
1205
|
this.emit(event, ...args);
|
|
1317
1206
|
if (event !== EVENTS.ERROR) this.emit(EVENTS.ALL, event, ...args);
|
|
1318
1207
|
}
|
|
1319
|
-
|
|
1320
|
-
* Normalize and emit events.
|
|
1321
|
-
* Calling _emit DOES NOT MEAN emit() would be called!
|
|
1322
|
-
* @param event Type of event
|
|
1323
|
-
* @param path File or directory path
|
|
1324
|
-
* @param stats arguments to be passed with event
|
|
1325
|
-
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1326
|
-
*/
|
|
1327
|
-
async _emit(event, path$1, stats) {
|
|
1208
|
+
async _emit(event, path, stats) {
|
|
1328
1209
|
if (this.closed) return;
|
|
1329
1210
|
const opts = this.options;
|
|
1330
|
-
if (isWindows) path
|
|
1331
|
-
if (opts.cwd) path
|
|
1332
|
-
const args = [path
|
|
1211
|
+
if (isWindows) path = sp.normalize(path);
|
|
1212
|
+
if (opts.cwd) path = sp.relative(opts.cwd, path);
|
|
1213
|
+
const args = [path];
|
|
1333
1214
|
if (stats != null) args.push(stats);
|
|
1334
1215
|
const awf = opts.awaitWriteFinish;
|
|
1335
1216
|
let pw;
|
|
1336
|
-
if (awf && (pw = this._pendingWrites.get(path
|
|
1217
|
+
if (awf && (pw = this._pendingWrites.get(path))) {
|
|
1337
1218
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
1338
1219
|
return this;
|
|
1339
1220
|
}
|
|
1340
1221
|
if (opts.atomic) {
|
|
1341
1222
|
if (event === EVENTS.UNLINK) {
|
|
1342
|
-
this._pendingUnlinks.set(path
|
|
1223
|
+
this._pendingUnlinks.set(path, [event, ...args]);
|
|
1343
1224
|
setTimeout(() => {
|
|
1344
|
-
this._pendingUnlinks.forEach((entry, path
|
|
1225
|
+
this._pendingUnlinks.forEach((entry, path) => {
|
|
1345
1226
|
this.emit(...entry);
|
|
1346
1227
|
this.emit(EVENTS.ALL, ...entry);
|
|
1347
|
-
this._pendingUnlinks.delete(path
|
|
1228
|
+
this._pendingUnlinks.delete(path);
|
|
1348
1229
|
});
|
|
1349
1230
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
1350
1231
|
return this;
|
|
1351
1232
|
}
|
|
1352
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(path
|
|
1233
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
|
|
1353
1234
|
event = EVENTS.CHANGE;
|
|
1354
|
-
this._pendingUnlinks.delete(path
|
|
1235
|
+
this._pendingUnlinks.delete(path);
|
|
1355
1236
|
}
|
|
1356
1237
|
}
|
|
1357
1238
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
1358
|
-
const awfEmit = (err, stats
|
|
1239
|
+
const awfEmit = (err, stats) => {
|
|
1359
1240
|
if (err) {
|
|
1360
1241
|
event = EVENTS.ERROR;
|
|
1361
1242
|
args[0] = err;
|
|
1362
1243
|
this.emitWithAll(event, args);
|
|
1363
|
-
} else if (stats
|
|
1364
|
-
if (args.length > 1) args[1] = stats
|
|
1365
|
-
else args.push(stats
|
|
1244
|
+
} else if (stats) {
|
|
1245
|
+
if (args.length > 1) args[1] = stats;
|
|
1246
|
+
else args.push(stats);
|
|
1366
1247
|
this.emitWithAll(event, args);
|
|
1367
1248
|
}
|
|
1368
1249
|
};
|
|
1369
|
-
this._awaitWriteFinish(path
|
|
1250
|
+
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
|
1370
1251
|
return this;
|
|
1371
1252
|
}
|
|
1372
1253
|
if (event === EVENTS.CHANGE) {
|
|
1373
|
-
if (!this._throttle(EVENTS.CHANGE, path
|
|
1254
|
+
if (!this._throttle(EVENTS.CHANGE, path, 50)) return this;
|
|
1374
1255
|
}
|
|
1375
1256
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
1376
|
-
const fullPath = opts.cwd ? sp.join(opts.cwd, path
|
|
1377
|
-
let stats
|
|
1257
|
+
const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
|
|
1258
|
+
let stats;
|
|
1378
1259
|
try {
|
|
1379
|
-
stats
|
|
1260
|
+
stats = await stat$1(fullPath);
|
|
1380
1261
|
} catch (err) {}
|
|
1381
|
-
if (!stats
|
|
1382
|
-
args.push(stats
|
|
1262
|
+
if (!stats || this.closed) return;
|
|
1263
|
+
args.push(stats);
|
|
1383
1264
|
}
|
|
1384
1265
|
this.emitWithAll(event, args);
|
|
1385
1266
|
return this;
|
|
1386
1267
|
}
|
|
1387
|
-
/**
|
|
1388
|
-
* Common handler for errors
|
|
1389
|
-
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
1390
|
-
*/
|
|
1391
1268
|
_handleError(error) {
|
|
1392
1269
|
const code = error && error.code;
|
|
1393
1270
|
if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) this.emit(EVENTS.ERROR, error);
|
|
1394
1271
|
return error || this.closed;
|
|
1395
1272
|
}
|
|
1396
|
-
|
|
1397
|
-
* Helper utility for throttling
|
|
1398
|
-
* @param actionType type being throttled
|
|
1399
|
-
* @param path being acted upon
|
|
1400
|
-
* @param timeout duration of time to suppress duplicate actions
|
|
1401
|
-
* @returns tracking object or false if action should be suppressed
|
|
1402
|
-
*/
|
|
1403
|
-
_throttle(actionType, path$1, timeout) {
|
|
1273
|
+
_throttle(actionType, path, timeout) {
|
|
1404
1274
|
if (!this._throttled.has(actionType)) this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
1405
1275
|
const action = this._throttled.get(actionType);
|
|
1406
1276
|
if (!action) throw new Error("invalid throttle");
|
|
1407
|
-
const actionPath = action.get(path
|
|
1277
|
+
const actionPath = action.get(path);
|
|
1408
1278
|
if (actionPath) {
|
|
1409
1279
|
actionPath.count++;
|
|
1410
1280
|
return false;
|
|
1411
1281
|
}
|
|
1412
1282
|
let timeoutObject;
|
|
1413
1283
|
const clear = () => {
|
|
1414
|
-
const item = action.get(path
|
|
1284
|
+
const item = action.get(path);
|
|
1415
1285
|
const count = item ? item.count : 0;
|
|
1416
|
-
action.delete(path
|
|
1286
|
+
action.delete(path);
|
|
1417
1287
|
clearTimeout(timeoutObject);
|
|
1418
1288
|
if (item) clearTimeout(item.timeoutObject);
|
|
1419
1289
|
return count;
|
|
@@ -1424,48 +1294,40 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1424
1294
|
clear,
|
|
1425
1295
|
count: 0
|
|
1426
1296
|
};
|
|
1427
|
-
action.set(path
|
|
1297
|
+
action.set(path, thr);
|
|
1428
1298
|
return thr;
|
|
1429
1299
|
}
|
|
1430
1300
|
_incrReadyCount() {
|
|
1431
1301
|
return this._readyCount++;
|
|
1432
1302
|
}
|
|
1433
|
-
|
|
1434
|
-
* Awaits write operation to finish.
|
|
1435
|
-
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
|
1436
|
-
* @param path being acted upon
|
|
1437
|
-
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
|
1438
|
-
* @param event
|
|
1439
|
-
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
1440
|
-
*/
|
|
1441
|
-
_awaitWriteFinish(path$1, threshold, event, awfEmit) {
|
|
1303
|
+
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
|
1442
1304
|
const awf = this.options.awaitWriteFinish;
|
|
1443
1305
|
if (typeof awf !== "object") return;
|
|
1444
1306
|
const pollInterval = awf.pollInterval;
|
|
1445
1307
|
let timeoutHandler;
|
|
1446
|
-
let fullPath = path
|
|
1447
|
-
if (this.options.cwd && !sp.isAbsolute(path
|
|
1308
|
+
let fullPath = path;
|
|
1309
|
+
if (this.options.cwd && !sp.isAbsolute(path)) fullPath = sp.join(this.options.cwd, path);
|
|
1448
1310
|
const now = /* @__PURE__ */ new Date();
|
|
1449
1311
|
const writes = this._pendingWrites;
|
|
1450
1312
|
function awaitWriteFinishFn(prevStat) {
|
|
1451
1313
|
stat(fullPath, (err, curStat) => {
|
|
1452
|
-
if (err || !writes.has(path
|
|
1314
|
+
if (err || !writes.has(path)) {
|
|
1453
1315
|
if (err && err.code !== "ENOENT") awfEmit(err);
|
|
1454
1316
|
return;
|
|
1455
1317
|
}
|
|
1456
|
-
const now
|
|
1457
|
-
if (prevStat && curStat.size !== prevStat.size) writes.get(path
|
|
1458
|
-
if (now
|
|
1459
|
-
writes.delete(path
|
|
1318
|
+
const now = Number(/* @__PURE__ */ new Date());
|
|
1319
|
+
if (prevStat && curStat.size !== prevStat.size) writes.get(path).lastChange = now;
|
|
1320
|
+
if (now - writes.get(path).lastChange >= threshold) {
|
|
1321
|
+
writes.delete(path);
|
|
1460
1322
|
awfEmit(void 0, curStat);
|
|
1461
1323
|
} else timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
1462
1324
|
});
|
|
1463
1325
|
}
|
|
1464
|
-
if (!writes.has(path
|
|
1465
|
-
writes.set(path
|
|
1326
|
+
if (!writes.has(path)) {
|
|
1327
|
+
writes.set(path, {
|
|
1466
1328
|
lastChange: now,
|
|
1467
1329
|
cancelWait: () => {
|
|
1468
|
-
writes.delete(path
|
|
1330
|
+
writes.delete(path);
|
|
1469
1331
|
clearTimeout(timeoutHandler);
|
|
1470
1332
|
return event;
|
|
1471
1333
|
}
|
|
@@ -1473,96 +1335,69 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1473
1335
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
1474
1336
|
}
|
|
1475
1337
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
*/
|
|
1479
|
-
_isIgnored(path$1, stats) {
|
|
1480
|
-
if (this.options.atomic && DOT_RE.test(path$1)) return true;
|
|
1338
|
+
_isIgnored(path, stats) {
|
|
1339
|
+
if (this.options.atomic && DOT_RE.test(path)) return true;
|
|
1481
1340
|
if (!this._userIgnored) {
|
|
1482
1341
|
const { cwd } = this.options;
|
|
1483
1342
|
const ignored = (this.options.ignored || []).map(normalizeIgnored(cwd));
|
|
1484
1343
|
this._userIgnored = anymatch([...[...this._ignoredPaths].map(normalizeIgnored(cwd)), ...ignored], void 0);
|
|
1485
1344
|
}
|
|
1486
|
-
return this._userIgnored(path
|
|
1345
|
+
return this._userIgnored(path, stats);
|
|
1487
1346
|
}
|
|
1488
|
-
_isntIgnored(path
|
|
1489
|
-
return !this._isIgnored(path
|
|
1347
|
+
_isntIgnored(path, stat) {
|
|
1348
|
+
return !this._isIgnored(path, stat);
|
|
1490
1349
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
* @param path file or directory pattern being watched
|
|
1494
|
-
*/
|
|
1495
|
-
_getWatchHelpers(path$1) {
|
|
1496
|
-
return new WatchHelper(path$1, this.options.followSymlinks, this);
|
|
1350
|
+
_getWatchHelpers(path) {
|
|
1351
|
+
return new WatchHelper(path, this.options.followSymlinks, this);
|
|
1497
1352
|
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Provides directory tracking objects
|
|
1500
|
-
* @param directory path of the directory
|
|
1501
|
-
*/
|
|
1502
1353
|
_getWatchedDir(directory) {
|
|
1503
1354
|
const dir = sp.resolve(directory);
|
|
1504
1355
|
if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
1505
1356
|
return this._watched.get(dir);
|
|
1506
1357
|
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
|
1509
|
-
*/
|
|
1510
1358
|
_hasReadPermissions(stats) {
|
|
1511
1359
|
if (this.options.ignorePermissionErrors) return true;
|
|
1512
1360
|
return Boolean(Number(stats.mode) & 256);
|
|
1513
1361
|
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Handles emitting unlink events for
|
|
1516
|
-
* files and directories, and via recursion, for
|
|
1517
|
-
* files and directories within directories that are unlinked
|
|
1518
|
-
* @param directory within which the following item is located
|
|
1519
|
-
* @param item base path of item/directory
|
|
1520
|
-
*/
|
|
1521
1362
|
_remove(directory, item, isDirectory) {
|
|
1522
|
-
const path
|
|
1523
|
-
const fullPath = sp.resolve(path
|
|
1524
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path
|
|
1525
|
-
if (!this._throttle("remove", path
|
|
1363
|
+
const path = sp.join(directory, item);
|
|
1364
|
+
const fullPath = sp.resolve(path);
|
|
1365
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
1366
|
+
if (!this._throttle("remove", path, 100)) return;
|
|
1526
1367
|
if (!isDirectory && this._watched.size === 1) this.add(directory, item, true);
|
|
1527
|
-
this._getWatchedDir(path
|
|
1368
|
+
this._getWatchedDir(path).getChildren().forEach((nested) => this._remove(path, nested));
|
|
1528
1369
|
const parent = this._getWatchedDir(directory);
|
|
1529
1370
|
const wasTracked = parent.has(item);
|
|
1530
1371
|
parent.remove(item);
|
|
1531
1372
|
if (this._symlinkPaths.has(fullPath)) this._symlinkPaths.delete(fullPath);
|
|
1532
|
-
let relPath = path
|
|
1533
|
-
if (this.options.cwd) relPath = sp.relative(this.options.cwd, path
|
|
1373
|
+
let relPath = path;
|
|
1374
|
+
if (this.options.cwd) relPath = sp.relative(this.options.cwd, path);
|
|
1534
1375
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1535
1376
|
if (this._pendingWrites.get(relPath).cancelWait() === EVENTS.ADD) return;
|
|
1536
1377
|
}
|
|
1537
|
-
this._watched.delete(path
|
|
1378
|
+
this._watched.delete(path);
|
|
1538
1379
|
this._watched.delete(fullPath);
|
|
1539
1380
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
1540
|
-
if (wasTracked && !this._isIgnored(path
|
|
1541
|
-
this._closePath(path
|
|
1381
|
+
if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
|
|
1382
|
+
this._closePath(path);
|
|
1542
1383
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
this._closeFile(path$1);
|
|
1548
|
-
const dir = sp.dirname(path$1);
|
|
1549
|
-
this._getWatchedDir(dir).remove(sp.basename(path$1));
|
|
1384
|
+
_closePath(path) {
|
|
1385
|
+
this._closeFile(path);
|
|
1386
|
+
const dir = sp.dirname(path);
|
|
1387
|
+
this._getWatchedDir(dir).remove(sp.basename(path));
|
|
1550
1388
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
*/
|
|
1554
|
-
_closeFile(path$1) {
|
|
1555
|
-
const closers = this._closers.get(path$1);
|
|
1389
|
+
_closeFile(path) {
|
|
1390
|
+
const closers = this._closers.get(path);
|
|
1556
1391
|
if (!closers) return;
|
|
1557
1392
|
closers.forEach((closer) => closer());
|
|
1558
|
-
this._closers.delete(path
|
|
1393
|
+
this._closers.delete(path);
|
|
1559
1394
|
}
|
|
1560
|
-
_addPathCloser(path
|
|
1395
|
+
_addPathCloser(path, closer) {
|
|
1561
1396
|
if (!closer) return;
|
|
1562
|
-
let list = this._closers.get(path
|
|
1397
|
+
let list = this._closers.get(path);
|
|
1563
1398
|
if (!list) {
|
|
1564
1399
|
list = [];
|
|
1565
|
-
this._closers.set(path
|
|
1400
|
+
this._closers.set(path, list);
|
|
1566
1401
|
}
|
|
1567
1402
|
list.push(closer);
|
|
1568
1403
|
}
|
|
@@ -1588,15 +1423,6 @@ var FSWatcher = class extends EventEmitter {
|
|
|
1588
1423
|
return stream;
|
|
1589
1424
|
}
|
|
1590
1425
|
};
|
|
1591
|
-
/**
|
|
1592
|
-
* Instantiates watcher with paths to be tracked.
|
|
1593
|
-
* @param paths file / directory paths
|
|
1594
|
-
* @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
|
|
1595
|
-
* @returns an instance of FSWatcher for chaining.
|
|
1596
|
-
* @example
|
|
1597
|
-
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
|
1598
|
-
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
|
1599
|
-
*/
|
|
1600
1426
|
function watch$1(paths, options = {}) {
|
|
1601
1427
|
const watcher = new FSWatcher(options);
|
|
1602
1428
|
watcher.add(paths);
|
|
@@ -1606,6 +1432,4 @@ var chokidar_default = {
|
|
|
1606
1432
|
watch: watch$1,
|
|
1607
1433
|
FSWatcher
|
|
1608
1434
|
};
|
|
1609
|
-
|
|
1610
|
-
//#endregion
|
|
1611
|
-
export { watch$1 as n, chokidar_exports as t };
|
|
1435
|
+
export { watch$1 as n, chokidar_exports as t };
|