@storm-software/git-tools 2.113.14 → 2.113.17

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.
Files changed (66) hide show
  1. package/README.md +2 -1
  2. package/bin/{chunk-TOALWLBQ.js → chunk-54Q5U5WW.js} +2 -8
  3. package/bin/chunk-AMSZ7DVW.js +17 -0
  4. package/bin/chunk-CIJVSMK2.cjs +23 -0
  5. package/bin/chunk-DDGJVTT5.cjs +1622 -0
  6. package/bin/chunk-NRQQ6RND.js +1581 -0
  7. package/bin/{chunk-TDO6B2H4.js → chunk-SWXHQXUT.cjs} +3 -8
  8. package/bin/git.cjs +3013 -81697
  9. package/bin/git.js +2825 -91795
  10. package/bin/post-checkout.cjs +16 -36
  11. package/bin/post-checkout.js +3 -25
  12. package/bin/post-commit.cjs +16 -36
  13. package/bin/post-commit.js +3 -25
  14. package/bin/post-merge.cjs +16 -36
  15. package/bin/post-merge.js +3 -25
  16. package/bin/pre-commit.cjs +13 -32
  17. package/bin/pre-commit.js +2 -23
  18. package/bin/pre-install.cjs +12 -29
  19. package/bin/pre-install.js +2 -21
  20. package/bin/pre-push.cjs +33 -50
  21. package/bin/pre-push.js +6 -30
  22. package/bin/prepare.cjs +10 -27
  23. package/bin/prepare.js +2 -21
  24. package/bin/version-warning.cjs +8 -23
  25. package/bin/version-warning.js +2 -19
  26. package/package.json +7 -10
  27. package/bin/chunk-2EJN2ZIP.cjs +0 -3631
  28. package/bin/chunk-2FWQQ2X4.js +0 -35624
  29. package/bin/chunk-335YPSVH.cjs +0 -111
  30. package/bin/chunk-5OLGPOTK.js +0 -1003
  31. package/bin/chunk-5QFXXGFE.js +0 -7427
  32. package/bin/chunk-D2AN4H4B.js +0 -111
  33. package/bin/chunk-DTYNP6HG.js +0 -3634
  34. package/bin/chunk-FMYKTN2Z.cjs +0 -7427
  35. package/bin/chunk-GSZ2Y7H4.cjs +0 -1003
  36. package/bin/chunk-GWDOCACN.cjs +0 -27
  37. package/bin/chunk-H4MEIOPL.cjs +0 -476
  38. package/bin/chunk-HTVOKCRJ.cjs +0 -25
  39. package/bin/chunk-IG6EXAQU.cjs +0 -59
  40. package/bin/chunk-JHBHEVIE.js +0 -55
  41. package/bin/chunk-MXO7CLUN.cjs +0 -739
  42. package/bin/chunk-OKG5KNKQ.js +0 -419
  43. package/bin/chunk-QWTKUQL3.js +0 -739
  44. package/bin/chunk-R7ZVOQ5D.js +0 -476
  45. package/bin/chunk-TVPM4C6Y.cjs +0 -419
  46. package/bin/chunk-UQFYXF6V.cjs +0 -74
  47. package/bin/chunk-VU7MBHMN.js +0 -74
  48. package/bin/chunk-WOADGD4X.cjs +0 -35563
  49. package/bin/dist-GTHSKIW6.cjs +0 -16571
  50. package/bin/dist-JFDTSOSQ.js +0 -33
  51. package/bin/dist-JIPEOSES.js +0 -16736
  52. package/bin/dist-S2SQNR26.cjs +0 -33
  53. package/bin/esm-MJTK2O7U.js +0 -1708
  54. package/bin/esm-NOFJXYSW.cjs +0 -1708
  55. package/bin/json5-PMDKQHWU.js +0 -10
  56. package/bin/json5-XWK64HEF.cjs +0 -10
  57. package/bin/jsonc-GWY6R4PV.js +0 -15
  58. package/bin/jsonc-SBYIKOG2.cjs +0 -15
  59. package/bin/multipart-parser-HT3QRMAQ.cjs +0 -181
  60. package/bin/multipart-parser-LDIDKHXR.js +0 -185
  61. package/bin/toml-CWI7LORJ.cjs +0 -10
  62. package/bin/toml-KVVESQIU.js +0 -10
  63. package/bin/utils-EKXINDVD.js +0 -101
  64. package/bin/utils-P2DNOMLG.cjs +0 -101
  65. package/bin/yaml-WPTJ2ZU5.cjs +0 -10
  66. package/bin/yaml-XEVR3LQS.js +0 -10
@@ -1,1708 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunkIG6EXAQUcjs = require('./chunk-IG6EXAQU.cjs');
4
-
5
- // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
6
- _chunkIG6EXAQUcjs.init_cjs_shims.call(void 0, );
7
- var _fs = require('fs');
8
- var _promises = require('fs/promises');
9
- var _events = require('events');
10
- var _path = require('path'); var sysPath2 = _interopRequireWildcard(_path); var sysPath = _interopRequireWildcard(_path);
11
-
12
- // ../../node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js
13
- _chunkIG6EXAQUcjs.init_cjs_shims.call(void 0, );
14
-
15
- var _stream = require('stream');
16
-
17
- var EntryTypes = {
18
- FILE_TYPE: "files",
19
- DIR_TYPE: "directories",
20
- FILE_DIR_TYPE: "files_directories",
21
- EVERYTHING_TYPE: "all"
22
- };
23
- var defaultOptions = {
24
- root: ".",
25
- fileFilter: (_entryInfo) => true,
26
- directoryFilter: (_entryInfo) => true,
27
- type: EntryTypes.FILE_TYPE,
28
- lstat: false,
29
- depth: 2147483648,
30
- alwaysStat: false,
31
- highWaterMark: 4096
32
- };
33
- Object.freeze(defaultOptions);
34
- var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
35
- var NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
36
- var ALL_TYPES = [
37
- EntryTypes.DIR_TYPE,
38
- EntryTypes.EVERYTHING_TYPE,
39
- EntryTypes.FILE_DIR_TYPE,
40
- EntryTypes.FILE_TYPE
41
- ];
42
- var DIR_TYPES = /* @__PURE__ */ new Set([
43
- EntryTypes.DIR_TYPE,
44
- EntryTypes.EVERYTHING_TYPE,
45
- EntryTypes.FILE_DIR_TYPE
46
- ]);
47
- var FILE_TYPES = /* @__PURE__ */ new Set([
48
- EntryTypes.EVERYTHING_TYPE,
49
- EntryTypes.FILE_DIR_TYPE,
50
- EntryTypes.FILE_TYPE
51
- ]);
52
- var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
53
- var wantBigintFsStats = process.platform === "win32";
54
- var emptyFn = (_entryInfo) => true;
55
- var normalizeFilter = (filter) => {
56
- if (filter === void 0)
57
- return emptyFn;
58
- if (typeof filter === "function")
59
- return filter;
60
- if (typeof filter === "string") {
61
- const fl = filter.trim();
62
- return (entry) => entry.basename === fl;
63
- }
64
- if (Array.isArray(filter)) {
65
- const trItems = filter.map((item) => item.trim());
66
- return (entry) => trItems.some((f) => entry.basename === f);
67
- }
68
- return emptyFn;
69
- };
70
- var ReaddirpStream = class extends _stream.Readable {
71
- constructor(options = {}) {
72
- super({
73
- objectMode: true,
74
- autoDestroy: true,
75
- highWaterMark: options.highWaterMark
76
- });
77
- const opts = { ...defaultOptions, ...options };
78
- const { root, type } = opts;
79
- this._fileFilter = normalizeFilter(opts.fileFilter);
80
- this._directoryFilter = normalizeFilter(opts.directoryFilter);
81
- const statMethod = opts.lstat ? _promises.lstat : _promises.stat;
82
- if (wantBigintFsStats) {
83
- this._stat = (path) => statMethod(path, { bigint: true });
84
- } else {
85
- this._stat = statMethod;
86
- }
87
- this._maxDepth = _nullishCoalesce(opts.depth, () => ( defaultOptions.depth));
88
- this._wantsDir = type ? DIR_TYPES.has(type) : false;
89
- this._wantsFile = type ? FILE_TYPES.has(type) : false;
90
- this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
91
- this._root = _path.resolve.call(void 0, root);
92
- this._isDirent = !opts.alwaysStat;
93
- this._statsProp = this._isDirent ? "dirent" : "stats";
94
- this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
95
- this.parents = [this._exploreDir(root, 1)];
96
- this.reading = false;
97
- this.parent = void 0;
98
- }
99
- async _read(batch) {
100
- if (this.reading)
101
- return;
102
- this.reading = true;
103
- try {
104
- while (!this.destroyed && batch > 0) {
105
- const par = this.parent;
106
- const fil = par && par.files;
107
- if (fil && fil.length > 0) {
108
- const { path, depth } = par;
109
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
110
- const awaited = await Promise.all(slice);
111
- for (const entry of awaited) {
112
- if (!entry)
113
- continue;
114
- if (this.destroyed)
115
- return;
116
- const entryType = await this._getEntryType(entry);
117
- if (entryType === "directory" && this._directoryFilter(entry)) {
118
- if (depth <= this._maxDepth) {
119
- this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
120
- }
121
- if (this._wantsDir) {
122
- this.push(entry);
123
- batch--;
124
- }
125
- } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
126
- if (this._wantsFile) {
127
- this.push(entry);
128
- batch--;
129
- }
130
- }
131
- }
132
- } else {
133
- const parent = this.parents.pop();
134
- if (!parent) {
135
- this.push(null);
136
- break;
137
- }
138
- this.parent = await parent;
139
- if (this.destroyed)
140
- return;
141
- }
142
- }
143
- } catch (error) {
144
- this.destroy(error);
145
- } finally {
146
- this.reading = false;
147
- }
148
- }
149
- async _exploreDir(path, depth) {
150
- let files;
151
- try {
152
- files = await _promises.readdir.call(void 0, path, this._rdOptions);
153
- } catch (error) {
154
- this._onError(error);
155
- }
156
- return { files, depth, path };
157
- }
158
- async _formatEntry(dirent, path) {
159
- let entry;
160
- const basename3 = this._isDirent ? dirent.name : dirent;
161
- try {
162
- const fullPath = _path.resolve.call(void 0, _path.join.call(void 0, path, basename3));
163
- entry = { path: _path.relative.call(void 0, this._root, fullPath), fullPath, basename: basename3 };
164
- entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
165
- } catch (err) {
166
- this._onError(err);
167
- return;
168
- }
169
- return entry;
170
- }
171
- _onError(err) {
172
- if (isNormalFlowError(err) && !this.destroyed) {
173
- this.emit("warn", err);
174
- } else {
175
- this.destroy(err);
176
- }
177
- }
178
- async _getEntryType(entry) {
179
- if (!entry && this._statsProp in entry) {
180
- return "";
181
- }
182
- const stats = entry[this._statsProp];
183
- if (stats.isFile())
184
- return "file";
185
- if (stats.isDirectory())
186
- return "directory";
187
- if (stats && stats.isSymbolicLink()) {
188
- const full = entry.fullPath;
189
- try {
190
- const entryRealPath = await _promises.realpath.call(void 0, full);
191
- const entryRealPathStats = await _promises.lstat.call(void 0, entryRealPath);
192
- if (entryRealPathStats.isFile()) {
193
- return "file";
194
- }
195
- if (entryRealPathStats.isDirectory()) {
196
- const len = entryRealPath.length;
197
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === _path.sep) {
198
- const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
199
- recursiveError.code = RECURSIVE_ERROR_CODE;
200
- return this._onError(recursiveError);
201
- }
202
- return "directory";
203
- }
204
- } catch (error) {
205
- this._onError(error);
206
- return "";
207
- }
208
- }
209
- }
210
- _includeAsFile(entry) {
211
- const stats = entry && entry[this._statsProp];
212
- return stats && this._wantsEverything && !stats.isDirectory();
213
- }
214
- };
215
- function readdirp(root, options = {}) {
216
- let type = options.entryType || options.type;
217
- if (type === "both")
218
- type = EntryTypes.FILE_DIR_TYPE;
219
- if (type)
220
- options.type = type;
221
- if (!root) {
222
- throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
223
- } else if (typeof root !== "string") {
224
- throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
225
- } else if (type && !ALL_TYPES.includes(type)) {
226
- throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
227
- }
228
- options.root = root;
229
- return new ReaddirpStream(options);
230
- }
231
-
232
- // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
233
- _chunkIG6EXAQUcjs.init_cjs_shims.call(void 0, );
234
-
235
-
236
-
237
- var _os = require('os');
238
- var STR_DATA = "data";
239
- var STR_END = "end";
240
- var STR_CLOSE = "close";
241
- var EMPTY_FN = () => {
242
- };
243
- var pl = process.platform;
244
- var isWindows = pl === "win32";
245
- var isMacos = pl === "darwin";
246
- var isLinux = pl === "linux";
247
- var isFreeBSD = pl === "freebsd";
248
- var isIBMi = _os.type.call(void 0, ) === "OS400";
249
- var EVENTS = {
250
- ALL: "all",
251
- READY: "ready",
252
- ADD: "add",
253
- CHANGE: "change",
254
- ADD_DIR: "addDir",
255
- UNLINK: "unlink",
256
- UNLINK_DIR: "unlinkDir",
257
- RAW: "raw",
258
- ERROR: "error"
259
- };
260
- var EV = EVENTS;
261
- var THROTTLE_MODE_WATCH = "watch";
262
- var statMethods = { lstat: _promises.lstat, stat: _promises.stat };
263
- var KEY_LISTENERS = "listeners";
264
- var KEY_ERR = "errHandlers";
265
- var KEY_RAW = "rawEmitters";
266
- var HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
267
- var binaryExtensions = /* @__PURE__ */ new Set([
268
- "3dm",
269
- "3ds",
270
- "3g2",
271
- "3gp",
272
- "7z",
273
- "a",
274
- "aac",
275
- "adp",
276
- "afdesign",
277
- "afphoto",
278
- "afpub",
279
- "ai",
280
- "aif",
281
- "aiff",
282
- "alz",
283
- "ape",
284
- "apk",
285
- "appimage",
286
- "ar",
287
- "arj",
288
- "asf",
289
- "au",
290
- "avi",
291
- "bak",
292
- "baml",
293
- "bh",
294
- "bin",
295
- "bk",
296
- "bmp",
297
- "btif",
298
- "bz2",
299
- "bzip2",
300
- "cab",
301
- "caf",
302
- "cgm",
303
- "class",
304
- "cmx",
305
- "cpio",
306
- "cr2",
307
- "cur",
308
- "dat",
309
- "dcm",
310
- "deb",
311
- "dex",
312
- "djvu",
313
- "dll",
314
- "dmg",
315
- "dng",
316
- "doc",
317
- "docm",
318
- "docx",
319
- "dot",
320
- "dotm",
321
- "dra",
322
- "DS_Store",
323
- "dsk",
324
- "dts",
325
- "dtshd",
326
- "dvb",
327
- "dwg",
328
- "dxf",
329
- "ecelp4800",
330
- "ecelp7470",
331
- "ecelp9600",
332
- "egg",
333
- "eol",
334
- "eot",
335
- "epub",
336
- "exe",
337
- "f4v",
338
- "fbs",
339
- "fh",
340
- "fla",
341
- "flac",
342
- "flatpak",
343
- "fli",
344
- "flv",
345
- "fpx",
346
- "fst",
347
- "fvt",
348
- "g3",
349
- "gh",
350
- "gif",
351
- "graffle",
352
- "gz",
353
- "gzip",
354
- "h261",
355
- "h263",
356
- "h264",
357
- "icns",
358
- "ico",
359
- "ief",
360
- "img",
361
- "ipa",
362
- "iso",
363
- "jar",
364
- "jpeg",
365
- "jpg",
366
- "jpgv",
367
- "jpm",
368
- "jxr",
369
- "key",
370
- "ktx",
371
- "lha",
372
- "lib",
373
- "lvp",
374
- "lz",
375
- "lzh",
376
- "lzma",
377
- "lzo",
378
- "m3u",
379
- "m4a",
380
- "m4v",
381
- "mar",
382
- "mdi",
383
- "mht",
384
- "mid",
385
- "midi",
386
- "mj2",
387
- "mka",
388
- "mkv",
389
- "mmr",
390
- "mng",
391
- "mobi",
392
- "mov",
393
- "movie",
394
- "mp3",
395
- "mp4",
396
- "mp4a",
397
- "mpeg",
398
- "mpg",
399
- "mpga",
400
- "mxu",
401
- "nef",
402
- "npx",
403
- "numbers",
404
- "nupkg",
405
- "o",
406
- "odp",
407
- "ods",
408
- "odt",
409
- "oga",
410
- "ogg",
411
- "ogv",
412
- "otf",
413
- "ott",
414
- "pages",
415
- "pbm",
416
- "pcx",
417
- "pdb",
418
- "pdf",
419
- "pea",
420
- "pgm",
421
- "pic",
422
- "png",
423
- "pnm",
424
- "pot",
425
- "potm",
426
- "potx",
427
- "ppa",
428
- "ppam",
429
- "ppm",
430
- "pps",
431
- "ppsm",
432
- "ppsx",
433
- "ppt",
434
- "pptm",
435
- "pptx",
436
- "psd",
437
- "pya",
438
- "pyc",
439
- "pyo",
440
- "pyv",
441
- "qt",
442
- "rar",
443
- "ras",
444
- "raw",
445
- "resources",
446
- "rgb",
447
- "rip",
448
- "rlc",
449
- "rmf",
450
- "rmvb",
451
- "rpm",
452
- "rtf",
453
- "rz",
454
- "s3m",
455
- "s7z",
456
- "scpt",
457
- "sgi",
458
- "shar",
459
- "snap",
460
- "sil",
461
- "sketch",
462
- "slk",
463
- "smv",
464
- "snk",
465
- "so",
466
- "stl",
467
- "suo",
468
- "sub",
469
- "swf",
470
- "tar",
471
- "tbz",
472
- "tbz2",
473
- "tga",
474
- "tgz",
475
- "thmx",
476
- "tif",
477
- "tiff",
478
- "tlz",
479
- "ttc",
480
- "ttf",
481
- "txz",
482
- "udf",
483
- "uvh",
484
- "uvi",
485
- "uvm",
486
- "uvp",
487
- "uvs",
488
- "uvu",
489
- "viv",
490
- "vob",
491
- "war",
492
- "wav",
493
- "wax",
494
- "wbmp",
495
- "wdp",
496
- "weba",
497
- "webm",
498
- "webp",
499
- "whl",
500
- "wim",
501
- "wm",
502
- "wma",
503
- "wmv",
504
- "wmx",
505
- "woff",
506
- "woff2",
507
- "wrm",
508
- "wvx",
509
- "xbm",
510
- "xif",
511
- "xla",
512
- "xlam",
513
- "xls",
514
- "xlsb",
515
- "xlsm",
516
- "xlsx",
517
- "xlt",
518
- "xltm",
519
- "xltx",
520
- "xm",
521
- "xmind",
522
- "xpi",
523
- "xpm",
524
- "xwd",
525
- "xz",
526
- "z",
527
- "zip",
528
- "zipx"
529
- ]);
530
- var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
531
- var foreach = (val, fn) => {
532
- if (val instanceof Set) {
533
- val.forEach(fn);
534
- } else {
535
- fn(val);
536
- }
537
- };
538
- var addAndConvert = (main, prop, item) => {
539
- let container = main[prop];
540
- if (!(container instanceof Set)) {
541
- main[prop] = container = /* @__PURE__ */ new Set([container]);
542
- }
543
- container.add(item);
544
- };
545
- var clearItem = (cont) => (key) => {
546
- const set = cont[key];
547
- if (set instanceof Set) {
548
- set.clear();
549
- } else {
550
- delete cont[key];
551
- }
552
- };
553
- var delFromSet = (main, prop, item) => {
554
- const container = main[prop];
555
- if (container instanceof Set) {
556
- container.delete(item);
557
- } else if (container === item) {
558
- delete main[prop];
559
- }
560
- };
561
- var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
562
- var FsWatchInstances = /* @__PURE__ */ new Map();
563
- function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
564
- const handleEvent = (rawEvent, evPath) => {
565
- listener(path);
566
- emitRaw(rawEvent, evPath, { watchedPath: path });
567
- if (evPath && path !== evPath) {
568
- fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
569
- }
570
- };
571
- try {
572
- return _fs.watch.call(void 0, path, {
573
- persistent: options.persistent
574
- }, handleEvent);
575
- } catch (error) {
576
- errHandler(error);
577
- return void 0;
578
- }
579
- }
580
- var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
581
- const cont = FsWatchInstances.get(fullPath);
582
- if (!cont)
583
- return;
584
- foreach(cont[listenerType], (listener) => {
585
- listener(val1, val2, val3);
586
- });
587
- };
588
- var setFsWatchListener = (path, fullPath, options, handlers) => {
589
- const { listener, errHandler, rawEmitter } = handlers;
590
- let cont = FsWatchInstances.get(fullPath);
591
- let watcher;
592
- if (!options.persistent) {
593
- watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
594
- if (!watcher)
595
- return;
596
- return watcher.close.bind(watcher);
597
- }
598
- if (cont) {
599
- addAndConvert(cont, KEY_LISTENERS, listener);
600
- addAndConvert(cont, KEY_ERR, errHandler);
601
- addAndConvert(cont, KEY_RAW, rawEmitter);
602
- } else {
603
- watcher = createFsWatchInstance(
604
- path,
605
- options,
606
- fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
607
- errHandler,
608
- // no need to use broadcast here
609
- fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
610
- );
611
- if (!watcher)
612
- return;
613
- watcher.on(EV.ERROR, async (error) => {
614
- const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
615
- if (cont)
616
- cont.watcherUnusable = true;
617
- if (isWindows && error.code === "EPERM") {
618
- try {
619
- const fd = await _promises.open.call(void 0, path, "r");
620
- await fd.close();
621
- broadcastErr(error);
622
- } catch (err) {
623
- }
624
- } else {
625
- broadcastErr(error);
626
- }
627
- });
628
- cont = {
629
- listeners: listener,
630
- errHandlers: errHandler,
631
- rawEmitters: rawEmitter,
632
- watcher
633
- };
634
- FsWatchInstances.set(fullPath, cont);
635
- }
636
- return () => {
637
- delFromSet(cont, KEY_LISTENERS, listener);
638
- delFromSet(cont, KEY_ERR, errHandler);
639
- delFromSet(cont, KEY_RAW, rawEmitter);
640
- if (isEmptySet(cont.listeners)) {
641
- cont.watcher.close();
642
- FsWatchInstances.delete(fullPath);
643
- HANDLER_KEYS.forEach(clearItem(cont));
644
- cont.watcher = void 0;
645
- Object.freeze(cont);
646
- }
647
- };
648
- };
649
- var FsWatchFileInstances = /* @__PURE__ */ new Map();
650
- var setFsWatchFileListener = (path, fullPath, options, handlers) => {
651
- const { listener, rawEmitter } = handlers;
652
- let cont = FsWatchFileInstances.get(fullPath);
653
- const copts = cont && cont.options;
654
- if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
655
- _fs.unwatchFile.call(void 0, fullPath);
656
- cont = void 0;
657
- }
658
- if (cont) {
659
- addAndConvert(cont, KEY_LISTENERS, listener);
660
- addAndConvert(cont, KEY_RAW, rawEmitter);
661
- } else {
662
- cont = {
663
- listeners: listener,
664
- rawEmitters: rawEmitter,
665
- options,
666
- watcher: _fs.watchFile.call(void 0, fullPath, options, (curr, prev) => {
667
- foreach(cont.rawEmitters, (rawEmitter2) => {
668
- rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
669
- });
670
- const currmtime = curr.mtimeMs;
671
- if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
672
- foreach(cont.listeners, (listener2) => listener2(path, curr));
673
- }
674
- })
675
- };
676
- FsWatchFileInstances.set(fullPath, cont);
677
- }
678
- return () => {
679
- delFromSet(cont, KEY_LISTENERS, listener);
680
- delFromSet(cont, KEY_RAW, rawEmitter);
681
- if (isEmptySet(cont.listeners)) {
682
- FsWatchFileInstances.delete(fullPath);
683
- _fs.unwatchFile.call(void 0, fullPath);
684
- cont.options = cont.watcher = void 0;
685
- Object.freeze(cont);
686
- }
687
- };
688
- };
689
- var NodeFsHandler = class {
690
- constructor(fsW) {
691
- this.fsw = fsW;
692
- this._boundHandleError = (error) => fsW._handleError(error);
693
- }
694
- /**
695
- * Watch file for changes with fs_watchFile or fs_watch.
696
- * @param path to file or dir
697
- * @param listener on fs change
698
- * @returns closer for the watcher instance
699
- */
700
- _watchWithNodeFs(path, listener) {
701
- const opts = this.fsw.options;
702
- const directory = sysPath.dirname(path);
703
- const basename3 = sysPath.basename(path);
704
- const parent = this.fsw._getWatchedDir(directory);
705
- parent.add(basename3);
706
- const absolutePath = sysPath.resolve(path);
707
- const options = {
708
- persistent: opts.persistent
709
- };
710
- if (!listener)
711
- listener = EMPTY_FN;
712
- let closer;
713
- if (opts.usePolling) {
714
- const enableBin = opts.interval !== opts.binaryInterval;
715
- options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
716
- closer = setFsWatchFileListener(path, absolutePath, options, {
717
- listener,
718
- rawEmitter: this.fsw._emitRaw
719
- });
720
- } else {
721
- closer = setFsWatchListener(path, absolutePath, options, {
722
- listener,
723
- errHandler: this._boundHandleError,
724
- rawEmitter: this.fsw._emitRaw
725
- });
726
- }
727
- return closer;
728
- }
729
- /**
730
- * Watch a file and emit add event if warranted.
731
- * @returns closer for the watcher instance
732
- */
733
- _handleFile(file, stats, initialAdd) {
734
- if (this.fsw.closed) {
735
- return;
736
- }
737
- const dirname3 = sysPath.dirname(file);
738
- const basename3 = sysPath.basename(file);
739
- const parent = this.fsw._getWatchedDir(dirname3);
740
- let prevStats = stats;
741
- if (parent.has(basename3))
742
- return;
743
- const listener = async (path, newStats) => {
744
- if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
745
- return;
746
- if (!newStats || newStats.mtimeMs === 0) {
747
- try {
748
- const newStats2 = await _promises.stat.call(void 0, file);
749
- if (this.fsw.closed)
750
- return;
751
- const at = newStats2.atimeMs;
752
- const mt = newStats2.mtimeMs;
753
- if (!at || at <= mt || mt !== prevStats.mtimeMs) {
754
- this.fsw._emit(EV.CHANGE, file, newStats2);
755
- }
756
- if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
757
- this.fsw._closeFile(path);
758
- prevStats = newStats2;
759
- const closer2 = this._watchWithNodeFs(file, listener);
760
- if (closer2)
761
- this.fsw._addPathCloser(path, closer2);
762
- } else {
763
- prevStats = newStats2;
764
- }
765
- } catch (error) {
766
- this.fsw._remove(dirname3, basename3);
767
- }
768
- } else if (parent.has(basename3)) {
769
- const at = newStats.atimeMs;
770
- const mt = newStats.mtimeMs;
771
- if (!at || at <= mt || mt !== prevStats.mtimeMs) {
772
- this.fsw._emit(EV.CHANGE, file, newStats);
773
- }
774
- prevStats = newStats;
775
- }
776
- };
777
- const closer = this._watchWithNodeFs(file, listener);
778
- if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
779
- if (!this.fsw._throttle(EV.ADD, file, 0))
780
- return;
781
- this.fsw._emit(EV.ADD, file, stats);
782
- }
783
- return closer;
784
- }
785
- /**
786
- * Handle symlinks encountered while reading a dir.
787
- * @param entry returned by readdirp
788
- * @param directory path of dir being read
789
- * @param path of this item
790
- * @param item basename of this item
791
- * @returns true if no more processing is needed for this entry.
792
- */
793
- async _handleSymlink(entry, directory, path, item) {
794
- if (this.fsw.closed) {
795
- return;
796
- }
797
- const full = entry.fullPath;
798
- const dir = this.fsw._getWatchedDir(directory);
799
- if (!this.fsw.options.followSymlinks) {
800
- this.fsw._incrReadyCount();
801
- let linkPath;
802
- try {
803
- linkPath = await _promises.realpath.call(void 0, path);
804
- } catch (e) {
805
- this.fsw._emitReady();
806
- return true;
807
- }
808
- if (this.fsw.closed)
809
- return;
810
- if (dir.has(item)) {
811
- if (this.fsw._symlinkPaths.get(full) !== linkPath) {
812
- this.fsw._symlinkPaths.set(full, linkPath);
813
- this.fsw._emit(EV.CHANGE, path, entry.stats);
814
- }
815
- } else {
816
- dir.add(item);
817
- this.fsw._symlinkPaths.set(full, linkPath);
818
- this.fsw._emit(EV.ADD, path, entry.stats);
819
- }
820
- this.fsw._emitReady();
821
- return true;
822
- }
823
- if (this.fsw._symlinkPaths.has(full)) {
824
- return true;
825
- }
826
- this.fsw._symlinkPaths.set(full, true);
827
- }
828
- _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
829
- directory = sysPath.join(directory, "");
830
- throttler = this.fsw._throttle("readdir", directory, 1e3);
831
- if (!throttler)
832
- return;
833
- const previous = this.fsw._getWatchedDir(wh.path);
834
- const current = /* @__PURE__ */ new Set();
835
- let stream = this.fsw._readdirp(directory, {
836
- fileFilter: (entry) => wh.filterPath(entry),
837
- directoryFilter: (entry) => wh.filterDir(entry)
838
- });
839
- if (!stream)
840
- return;
841
- stream.on(STR_DATA, async (entry) => {
842
- if (this.fsw.closed) {
843
- stream = void 0;
844
- return;
845
- }
846
- const item = entry.path;
847
- let path = sysPath.join(directory, item);
848
- current.add(item);
849
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
850
- return;
851
- }
852
- if (this.fsw.closed) {
853
- stream = void 0;
854
- return;
855
- }
856
- if (item === target || !target && !previous.has(item)) {
857
- this.fsw._incrReadyCount();
858
- path = sysPath.join(dir, sysPath.relative(dir, path));
859
- this._addToNodeFs(path, initialAdd, wh, depth + 1);
860
- }
861
- }).on(EV.ERROR, this._boundHandleError);
862
- return new Promise((resolve3, reject) => {
863
- if (!stream)
864
- return reject();
865
- stream.once(STR_END, () => {
866
- if (this.fsw.closed) {
867
- stream = void 0;
868
- return;
869
- }
870
- const wasThrottled = throttler ? throttler.clear() : false;
871
- resolve3(void 0);
872
- previous.getChildren().filter((item) => {
873
- return item !== directory && !current.has(item);
874
- }).forEach((item) => {
875
- this.fsw._remove(directory, item);
876
- });
877
- stream = void 0;
878
- if (wasThrottled)
879
- this._handleRead(directory, false, wh, target, dir, depth, throttler);
880
- });
881
- });
882
- }
883
- /**
884
- * Read directory to add / remove files from `@watched` list and re-read it on change.
885
- * @param dir fs path
886
- * @param stats
887
- * @param initialAdd
888
- * @param depth relative to user-supplied path
889
- * @param target child path targeted for watch
890
- * @param wh Common watch helpers for this path
891
- * @param realpath
892
- * @returns closer for the watcher instance.
893
- */
894
- async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
895
- const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
896
- const tracked = parentDir.has(sysPath.basename(dir));
897
- if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
898
- this.fsw._emit(EV.ADD_DIR, dir, stats);
899
- }
900
- parentDir.add(sysPath.basename(dir));
901
- this.fsw._getWatchedDir(dir);
902
- let throttler;
903
- let closer;
904
- const oDepth = this.fsw.options.depth;
905
- if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
906
- if (!target) {
907
- await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
908
- if (this.fsw.closed)
909
- return;
910
- }
911
- closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
912
- if (stats2 && stats2.mtimeMs === 0)
913
- return;
914
- this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
915
- });
916
- }
917
- return closer;
918
- }
919
- /**
920
- * Handle added file, directory, or glob pattern.
921
- * Delegates call to _handleFile / _handleDir after checks.
922
- * @param path to file or ir
923
- * @param initialAdd was the file added at watch instantiation?
924
- * @param priorWh depth relative to user-supplied path
925
- * @param depth Child path actually targeted for watch
926
- * @param target Child path actually targeted for watch
927
- */
928
- async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
929
- const ready = this.fsw._emitReady;
930
- if (this.fsw._isIgnored(path) || this.fsw.closed) {
931
- ready();
932
- return false;
933
- }
934
- const wh = this.fsw._getWatchHelpers(path);
935
- if (priorWh) {
936
- wh.filterPath = (entry) => priorWh.filterPath(entry);
937
- wh.filterDir = (entry) => priorWh.filterDir(entry);
938
- }
939
- try {
940
- const stats = await statMethods[wh.statMethod](wh.watchPath);
941
- if (this.fsw.closed)
942
- return;
943
- if (this.fsw._isIgnored(wh.watchPath, stats)) {
944
- ready();
945
- return false;
946
- }
947
- const follow = this.fsw.options.followSymlinks;
948
- let closer;
949
- if (stats.isDirectory()) {
950
- const absPath = sysPath.resolve(path);
951
- const targetPath = follow ? await _promises.realpath.call(void 0, path) : path;
952
- if (this.fsw.closed)
953
- return;
954
- closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
955
- if (this.fsw.closed)
956
- return;
957
- if (absPath !== targetPath && targetPath !== void 0) {
958
- this.fsw._symlinkPaths.set(absPath, targetPath);
959
- }
960
- } else if (stats.isSymbolicLink()) {
961
- const targetPath = follow ? await _promises.realpath.call(void 0, path) : path;
962
- if (this.fsw.closed)
963
- return;
964
- const parent = sysPath.dirname(wh.watchPath);
965
- this.fsw._getWatchedDir(parent).add(wh.watchPath);
966
- this.fsw._emit(EV.ADD, wh.watchPath, stats);
967
- closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
968
- if (this.fsw.closed)
969
- return;
970
- if (targetPath !== void 0) {
971
- this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
972
- }
973
- } else {
974
- closer = this._handleFile(wh.watchPath, stats, initialAdd);
975
- }
976
- ready();
977
- if (closer)
978
- this.fsw._addPathCloser(path, closer);
979
- return false;
980
- } catch (error) {
981
- if (this.fsw._handleError(error)) {
982
- ready();
983
- return path;
984
- }
985
- }
986
- }
987
- };
988
-
989
- // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
990
- var SLASH = "/";
991
- var SLASH_SLASH = "//";
992
- var ONE_DOT = ".";
993
- var TWO_DOTS = "..";
994
- var STRING_TYPE = "string";
995
- var BACK_SLASH_RE = /\\/g;
996
- var DOUBLE_SLASH_RE = /\/\//;
997
- var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
998
- var REPLACER_RE = /^\.[/\\]/;
999
- function arrify(item) {
1000
- return Array.isArray(item) ? item : [item];
1001
- }
1002
- var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
1003
- function createPattern(matcher) {
1004
- if (typeof matcher === "function")
1005
- return matcher;
1006
- if (typeof matcher === "string")
1007
- return (string) => matcher === string;
1008
- if (matcher instanceof RegExp)
1009
- return (string) => matcher.test(string);
1010
- if (typeof matcher === "object" && matcher !== null) {
1011
- return (string) => {
1012
- if (matcher.path === string)
1013
- return true;
1014
- if (matcher.recursive) {
1015
- const relative3 = sysPath2.relative(matcher.path, string);
1016
- if (!relative3) {
1017
- return false;
1018
- }
1019
- return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
1020
- }
1021
- return false;
1022
- };
1023
- }
1024
- return () => false;
1025
- }
1026
- function normalizePath(path) {
1027
- if (typeof path !== "string")
1028
- throw new Error("string expected");
1029
- path = sysPath2.normalize(path);
1030
- path = path.replace(/\\/g, "/");
1031
- let prepend = false;
1032
- if (path.startsWith("//"))
1033
- prepend = true;
1034
- const DOUBLE_SLASH_RE2 = /\/\//;
1035
- while (path.match(DOUBLE_SLASH_RE2))
1036
- path = path.replace(DOUBLE_SLASH_RE2, "/");
1037
- if (prepend)
1038
- path = "/" + path;
1039
- return path;
1040
- }
1041
- function matchPatterns(patterns, testString, stats) {
1042
- const path = normalizePath(testString);
1043
- for (let index = 0; index < patterns.length; index++) {
1044
- const pattern = patterns[index];
1045
- if (pattern(path, stats)) {
1046
- return true;
1047
- }
1048
- }
1049
- return false;
1050
- }
1051
- function anymatch(matchers, testString) {
1052
- if (matchers == null) {
1053
- throw new TypeError("anymatch: specify first argument");
1054
- }
1055
- const matchersArray = arrify(matchers);
1056
- const patterns = matchersArray.map((matcher) => createPattern(matcher));
1057
- if (testString == null) {
1058
- return (testString2, stats) => {
1059
- return matchPatterns(patterns, testString2, stats);
1060
- };
1061
- }
1062
- return matchPatterns(patterns, testString);
1063
- }
1064
- var unifyPaths = (paths_) => {
1065
- const paths = arrify(paths_).flat();
1066
- if (!paths.every((p) => typeof p === STRING_TYPE)) {
1067
- throw new TypeError(`Non-string provided as watch path: ${paths}`);
1068
- }
1069
- return paths.map(normalizePathToUnix);
1070
- };
1071
- var toUnix = (string) => {
1072
- let str = string.replace(BACK_SLASH_RE, SLASH);
1073
- let prepend = false;
1074
- if (str.startsWith(SLASH_SLASH)) {
1075
- prepend = true;
1076
- }
1077
- while (str.match(DOUBLE_SLASH_RE)) {
1078
- str = str.replace(DOUBLE_SLASH_RE, SLASH);
1079
- }
1080
- if (prepend) {
1081
- str = SLASH + str;
1082
- }
1083
- return str;
1084
- };
1085
- var normalizePathToUnix = (path) => toUnix(sysPath2.normalize(toUnix(path)));
1086
- var normalizeIgnored = (cwd = "") => (path) => {
1087
- if (typeof path === "string") {
1088
- return normalizePathToUnix(sysPath2.isAbsolute(path) ? path : sysPath2.join(cwd, path));
1089
- } else {
1090
- return path;
1091
- }
1092
- };
1093
- var getAbsolutePath = (path, cwd) => {
1094
- if (sysPath2.isAbsolute(path)) {
1095
- return path;
1096
- }
1097
- return sysPath2.join(cwd, path);
1098
- };
1099
- var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
1100
- var DirEntry = class {
1101
- constructor(dir, removeWatcher) {
1102
- this.path = dir;
1103
- this._removeWatcher = removeWatcher;
1104
- this.items = /* @__PURE__ */ new Set();
1105
- }
1106
- add(item) {
1107
- const { items } = this;
1108
- if (!items)
1109
- return;
1110
- if (item !== ONE_DOT && item !== TWO_DOTS)
1111
- items.add(item);
1112
- }
1113
- async remove(item) {
1114
- const { items } = this;
1115
- if (!items)
1116
- return;
1117
- items.delete(item);
1118
- if (items.size > 0)
1119
- return;
1120
- const dir = this.path;
1121
- try {
1122
- await _promises.readdir.call(void 0, dir);
1123
- } catch (err) {
1124
- if (this._removeWatcher) {
1125
- this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
1126
- }
1127
- }
1128
- }
1129
- has(item) {
1130
- const { items } = this;
1131
- if (!items)
1132
- return;
1133
- return items.has(item);
1134
- }
1135
- getChildren() {
1136
- const { items } = this;
1137
- if (!items)
1138
- return [];
1139
- return [...items.values()];
1140
- }
1141
- dispose() {
1142
- this.items.clear();
1143
- this.path = "";
1144
- this._removeWatcher = EMPTY_FN;
1145
- this.items = EMPTY_SET;
1146
- Object.freeze(this);
1147
- }
1148
- };
1149
- var STAT_METHOD_F = "stat";
1150
- var STAT_METHOD_L = "lstat";
1151
- var WatchHelper = class {
1152
- constructor(path, follow, fsw) {
1153
- this.fsw = fsw;
1154
- const watchPath = path;
1155
- this.path = path = path.replace(REPLACER_RE, "");
1156
- this.watchPath = watchPath;
1157
- this.fullWatchPath = sysPath2.resolve(watchPath);
1158
- this.dirParts = [];
1159
- this.dirParts.forEach((parts) => {
1160
- if (parts.length > 1)
1161
- parts.pop();
1162
- });
1163
- this.followSymlinks = follow;
1164
- this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
1165
- }
1166
- entryPath(entry) {
1167
- return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
1168
- }
1169
- filterPath(entry) {
1170
- const { stats } = entry;
1171
- if (stats && stats.isSymbolicLink())
1172
- return this.filterDir(entry);
1173
- const resolvedPath = this.entryPath(entry);
1174
- return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
1175
- }
1176
- filterDir(entry) {
1177
- return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
1178
- }
1179
- };
1180
- var FSWatcher = class extends _events.EventEmitter {
1181
- // Not indenting methods for history sake; for now.
1182
- constructor(_opts = {}) {
1183
- super();
1184
- this.closed = false;
1185
- this._closers = /* @__PURE__ */ new Map();
1186
- this._ignoredPaths = /* @__PURE__ */ new Set();
1187
- this._throttled = /* @__PURE__ */ new Map();
1188
- this._streams = /* @__PURE__ */ new Set();
1189
- this._symlinkPaths = /* @__PURE__ */ new Map();
1190
- this._watched = /* @__PURE__ */ new Map();
1191
- this._pendingWrites = /* @__PURE__ */ new Map();
1192
- this._pendingUnlinks = /* @__PURE__ */ new Map();
1193
- this._readyCount = 0;
1194
- this._readyEmitted = false;
1195
- const awf = _opts.awaitWriteFinish;
1196
- const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
1197
- const opts = {
1198
- // Defaults
1199
- persistent: true,
1200
- ignoreInitial: false,
1201
- ignorePermissionErrors: false,
1202
- interval: 100,
1203
- binaryInterval: 300,
1204
- followSymlinks: true,
1205
- usePolling: false,
1206
- // useAsync: false,
1207
- atomic: true,
1208
- // NOTE: overwritten later (depends on usePolling)
1209
- ..._opts,
1210
- // Change format
1211
- ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
1212
- awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
1213
- };
1214
- if (isIBMi)
1215
- opts.usePolling = true;
1216
- if (opts.atomic === void 0)
1217
- opts.atomic = !opts.usePolling;
1218
- const envPoll = process.env.CHOKIDAR_USEPOLLING;
1219
- if (envPoll !== void 0) {
1220
- const envLower = envPoll.toLowerCase();
1221
- if (envLower === "false" || envLower === "0")
1222
- opts.usePolling = false;
1223
- else if (envLower === "true" || envLower === "1")
1224
- opts.usePolling = true;
1225
- else
1226
- opts.usePolling = !!envLower;
1227
- }
1228
- const envInterval = process.env.CHOKIDAR_INTERVAL;
1229
- if (envInterval)
1230
- opts.interval = Number.parseInt(envInterval, 10);
1231
- let readyCalls = 0;
1232
- this._emitReady = () => {
1233
- readyCalls++;
1234
- if (readyCalls >= this._readyCount) {
1235
- this._emitReady = EMPTY_FN;
1236
- this._readyEmitted = true;
1237
- process.nextTick(() => this.emit(EVENTS.READY));
1238
- }
1239
- };
1240
- this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
1241
- this._boundRemove = this._remove.bind(this);
1242
- this.options = opts;
1243
- this._nodeFsHandler = new NodeFsHandler(this);
1244
- Object.freeze(opts);
1245
- }
1246
- _addIgnoredPath(matcher) {
1247
- if (isMatcherObject(matcher)) {
1248
- for (const ignored of this._ignoredPaths) {
1249
- if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
1250
- return;
1251
- }
1252
- }
1253
- }
1254
- this._ignoredPaths.add(matcher);
1255
- }
1256
- _removeIgnoredPath(matcher) {
1257
- this._ignoredPaths.delete(matcher);
1258
- if (typeof matcher === "string") {
1259
- for (const ignored of this._ignoredPaths) {
1260
- if (isMatcherObject(ignored) && ignored.path === matcher) {
1261
- this._ignoredPaths.delete(ignored);
1262
- }
1263
- }
1264
- }
1265
- }
1266
- // Public methods
1267
- /**
1268
- * Adds paths to be watched on an existing FSWatcher instance.
1269
- * @param paths_ file or file list. Other arguments are unused
1270
- */
1271
- add(paths_, _origAdd, _internal) {
1272
- const { cwd } = this.options;
1273
- this.closed = false;
1274
- this._closePromise = void 0;
1275
- let paths = unifyPaths(paths_);
1276
- if (cwd) {
1277
- paths = paths.map((path) => {
1278
- const absPath = getAbsolutePath(path, cwd);
1279
- return absPath;
1280
- });
1281
- }
1282
- paths.forEach((path) => {
1283
- this._removeIgnoredPath(path);
1284
- });
1285
- this._userIgnored = void 0;
1286
- if (!this._readyCount)
1287
- this._readyCount = 0;
1288
- this._readyCount += paths.length;
1289
- Promise.all(paths.map(async (path) => {
1290
- const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
1291
- if (res)
1292
- this._emitReady();
1293
- return res;
1294
- })).then((results) => {
1295
- if (this.closed)
1296
- return;
1297
- results.forEach((item) => {
1298
- if (item)
1299
- this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
1300
- });
1301
- });
1302
- return this;
1303
- }
1304
- /**
1305
- * Close watchers or start ignoring events from specified paths.
1306
- */
1307
- unwatch(paths_) {
1308
- if (this.closed)
1309
- return this;
1310
- const paths = unifyPaths(paths_);
1311
- const { cwd } = this.options;
1312
- paths.forEach((path) => {
1313
- if (!sysPath2.isAbsolute(path) && !this._closers.has(path)) {
1314
- if (cwd)
1315
- path = sysPath2.join(cwd, path);
1316
- path = sysPath2.resolve(path);
1317
- }
1318
- this._closePath(path);
1319
- this._addIgnoredPath(path);
1320
- if (this._watched.has(path)) {
1321
- this._addIgnoredPath({
1322
- path,
1323
- recursive: true
1324
- });
1325
- }
1326
- this._userIgnored = void 0;
1327
- });
1328
- return this;
1329
- }
1330
- /**
1331
- * Close watchers and remove all listeners from watched paths.
1332
- */
1333
- close() {
1334
- if (this._closePromise) {
1335
- return this._closePromise;
1336
- }
1337
- this.closed = true;
1338
- this.removeAllListeners();
1339
- const closers = [];
1340
- this._closers.forEach((closerList) => closerList.forEach((closer) => {
1341
- const promise = closer();
1342
- if (promise instanceof Promise)
1343
- closers.push(promise);
1344
- }));
1345
- this._streams.forEach((stream) => stream.destroy());
1346
- this._userIgnored = void 0;
1347
- this._readyCount = 0;
1348
- this._readyEmitted = false;
1349
- this._watched.forEach((dirent) => dirent.dispose());
1350
- this._closers.clear();
1351
- this._watched.clear();
1352
- this._streams.clear();
1353
- this._symlinkPaths.clear();
1354
- this._throttled.clear();
1355
- this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
1356
- return this._closePromise;
1357
- }
1358
- /**
1359
- * Expose list of watched paths
1360
- * @returns for chaining
1361
- */
1362
- getWatched() {
1363
- const watchList = {};
1364
- this._watched.forEach((entry, dir) => {
1365
- const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
1366
- const index = key || ONE_DOT;
1367
- watchList[index] = entry.getChildren().sort();
1368
- });
1369
- return watchList;
1370
- }
1371
- emitWithAll(event, args) {
1372
- this.emit(event, ...args);
1373
- if (event !== EVENTS.ERROR)
1374
- this.emit(EVENTS.ALL, event, ...args);
1375
- }
1376
- // Common helpers
1377
- // --------------
1378
- /**
1379
- * Normalize and emit events.
1380
- * Calling _emit DOES NOT MEAN emit() would be called!
1381
- * @param event Type of event
1382
- * @param path File or directory path
1383
- * @param stats arguments to be passed with event
1384
- * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1385
- */
1386
- async _emit(event, path, stats) {
1387
- if (this.closed)
1388
- return;
1389
- const opts = this.options;
1390
- if (isWindows)
1391
- path = sysPath2.normalize(path);
1392
- if (opts.cwd)
1393
- path = sysPath2.relative(opts.cwd, path);
1394
- const args = [path];
1395
- if (stats != null)
1396
- args.push(stats);
1397
- const awf = opts.awaitWriteFinish;
1398
- let pw;
1399
- if (awf && (pw = this._pendingWrites.get(path))) {
1400
- pw.lastChange = /* @__PURE__ */ new Date();
1401
- return this;
1402
- }
1403
- if (opts.atomic) {
1404
- if (event === EVENTS.UNLINK) {
1405
- this._pendingUnlinks.set(path, [event, ...args]);
1406
- setTimeout(() => {
1407
- this._pendingUnlinks.forEach((entry, path2) => {
1408
- this.emit(...entry);
1409
- this.emit(EVENTS.ALL, ...entry);
1410
- this._pendingUnlinks.delete(path2);
1411
- });
1412
- }, typeof opts.atomic === "number" ? opts.atomic : 100);
1413
- return this;
1414
- }
1415
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
1416
- event = EVENTS.CHANGE;
1417
- this._pendingUnlinks.delete(path);
1418
- }
1419
- }
1420
- if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
1421
- const awfEmit = (err, stats2) => {
1422
- if (err) {
1423
- event = EVENTS.ERROR;
1424
- args[0] = err;
1425
- this.emitWithAll(event, args);
1426
- } else if (stats2) {
1427
- if (args.length > 1) {
1428
- args[1] = stats2;
1429
- } else {
1430
- args.push(stats2);
1431
- }
1432
- this.emitWithAll(event, args);
1433
- }
1434
- };
1435
- this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
1436
- return this;
1437
- }
1438
- if (event === EVENTS.CHANGE) {
1439
- const isThrottled = !this._throttle(EVENTS.CHANGE, path, 50);
1440
- if (isThrottled)
1441
- return this;
1442
- }
1443
- if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
1444
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
1445
- let stats2;
1446
- try {
1447
- stats2 = await _promises.stat.call(void 0, fullPath);
1448
- } catch (err) {
1449
- }
1450
- if (!stats2 || this.closed)
1451
- return;
1452
- args.push(stats2);
1453
- }
1454
- this.emitWithAll(event, args);
1455
- return this;
1456
- }
1457
- /**
1458
- * Common handler for errors
1459
- * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1460
- */
1461
- _handleError(error) {
1462
- const code = error && error.code;
1463
- if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
1464
- this.emit(EVENTS.ERROR, error);
1465
- }
1466
- return error || this.closed;
1467
- }
1468
- /**
1469
- * Helper utility for throttling
1470
- * @param actionType type being throttled
1471
- * @param path being acted upon
1472
- * @param timeout duration of time to suppress duplicate actions
1473
- * @returns tracking object or false if action should be suppressed
1474
- */
1475
- _throttle(actionType, path, timeout) {
1476
- if (!this._throttled.has(actionType)) {
1477
- this._throttled.set(actionType, /* @__PURE__ */ new Map());
1478
- }
1479
- const action = this._throttled.get(actionType);
1480
- if (!action)
1481
- throw new Error("invalid throttle");
1482
- const actionPath = action.get(path);
1483
- if (actionPath) {
1484
- actionPath.count++;
1485
- return false;
1486
- }
1487
- let timeoutObject;
1488
- const clear = () => {
1489
- const item = action.get(path);
1490
- const count = item ? item.count : 0;
1491
- action.delete(path);
1492
- clearTimeout(timeoutObject);
1493
- if (item)
1494
- clearTimeout(item.timeoutObject);
1495
- return count;
1496
- };
1497
- timeoutObject = setTimeout(clear, timeout);
1498
- const thr = { timeoutObject, clear, count: 0 };
1499
- action.set(path, thr);
1500
- return thr;
1501
- }
1502
- _incrReadyCount() {
1503
- return this._readyCount++;
1504
- }
1505
- /**
1506
- * Awaits write operation to finish.
1507
- * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
1508
- * @param path being acted upon
1509
- * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
1510
- * @param event
1511
- * @param awfEmit Callback to be called when ready for event to be emitted.
1512
- */
1513
- _awaitWriteFinish(path, threshold, event, awfEmit) {
1514
- const awf = this.options.awaitWriteFinish;
1515
- if (typeof awf !== "object")
1516
- return;
1517
- const pollInterval = awf.pollInterval;
1518
- let timeoutHandler;
1519
- let fullPath = path;
1520
- if (this.options.cwd && !sysPath2.isAbsolute(path)) {
1521
- fullPath = sysPath2.join(this.options.cwd, path);
1522
- }
1523
- const now = /* @__PURE__ */ new Date();
1524
- const writes = this._pendingWrites;
1525
- function awaitWriteFinishFn(prevStat) {
1526
- _fs.stat.call(void 0, fullPath, (err, curStat) => {
1527
- if (err || !writes.has(path)) {
1528
- if (err && err.code !== "ENOENT")
1529
- awfEmit(err);
1530
- return;
1531
- }
1532
- const now2 = Number(/* @__PURE__ */ new Date());
1533
- if (prevStat && curStat.size !== prevStat.size) {
1534
- writes.get(path).lastChange = now2;
1535
- }
1536
- const pw = writes.get(path);
1537
- const df = now2 - pw.lastChange;
1538
- if (df >= threshold) {
1539
- writes.delete(path);
1540
- awfEmit(void 0, curStat);
1541
- } else {
1542
- timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
1543
- }
1544
- });
1545
- }
1546
- if (!writes.has(path)) {
1547
- writes.set(path, {
1548
- lastChange: now,
1549
- cancelWait: () => {
1550
- writes.delete(path);
1551
- clearTimeout(timeoutHandler);
1552
- return event;
1553
- }
1554
- });
1555
- timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
1556
- }
1557
- }
1558
- /**
1559
- * Determines whether user has asked to ignore this path.
1560
- */
1561
- _isIgnored(path, stats) {
1562
- if (this.options.atomic && DOT_RE.test(path))
1563
- return true;
1564
- if (!this._userIgnored) {
1565
- const { cwd } = this.options;
1566
- const ign = this.options.ignored;
1567
- const ignored = (ign || []).map(normalizeIgnored(cwd));
1568
- const ignoredPaths = [...this._ignoredPaths];
1569
- const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
1570
- this._userIgnored = anymatch(list, void 0);
1571
- }
1572
- return this._userIgnored(path, stats);
1573
- }
1574
- _isntIgnored(path, stat4) {
1575
- return !this._isIgnored(path, stat4);
1576
- }
1577
- /**
1578
- * Provides a set of common helpers and properties relating to symlink handling.
1579
- * @param path file or directory pattern being watched
1580
- */
1581
- _getWatchHelpers(path) {
1582
- return new WatchHelper(path, this.options.followSymlinks, this);
1583
- }
1584
- // Directory helpers
1585
- // -----------------
1586
- /**
1587
- * Provides directory tracking objects
1588
- * @param directory path of the directory
1589
- */
1590
- _getWatchedDir(directory) {
1591
- const dir = sysPath2.resolve(directory);
1592
- if (!this._watched.has(dir))
1593
- this._watched.set(dir, new DirEntry(dir, this._boundRemove));
1594
- return this._watched.get(dir);
1595
- }
1596
- // File helpers
1597
- // ------------
1598
- /**
1599
- * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
1600
- */
1601
- _hasReadPermissions(stats) {
1602
- if (this.options.ignorePermissionErrors)
1603
- return true;
1604
- return Boolean(Number(stats.mode) & 256);
1605
- }
1606
- /**
1607
- * Handles emitting unlink events for
1608
- * files and directories, and via recursion, for
1609
- * files and directories within directories that are unlinked
1610
- * @param directory within which the following item is located
1611
- * @param item base path of item/directory
1612
- */
1613
- _remove(directory, item, isDirectory) {
1614
- const path = sysPath2.join(directory, item);
1615
- const fullPath = sysPath2.resolve(path);
1616
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
1617
- if (!this._throttle("remove", path, 100))
1618
- return;
1619
- if (!isDirectory && this._watched.size === 1) {
1620
- this.add(directory, item, true);
1621
- }
1622
- const wp = this._getWatchedDir(path);
1623
- const nestedDirectoryChildren = wp.getChildren();
1624
- nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
1625
- const parent = this._getWatchedDir(directory);
1626
- const wasTracked = parent.has(item);
1627
- parent.remove(item);
1628
- if (this._symlinkPaths.has(fullPath)) {
1629
- this._symlinkPaths.delete(fullPath);
1630
- }
1631
- let relPath = path;
1632
- if (this.options.cwd)
1633
- relPath = sysPath2.relative(this.options.cwd, path);
1634
- if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
1635
- const event = this._pendingWrites.get(relPath).cancelWait();
1636
- if (event === EVENTS.ADD)
1637
- return;
1638
- }
1639
- this._watched.delete(path);
1640
- this._watched.delete(fullPath);
1641
- const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
1642
- if (wasTracked && !this._isIgnored(path))
1643
- this._emit(eventName, path);
1644
- this._closePath(path);
1645
- }
1646
- /**
1647
- * Closes all watchers for a path
1648
- */
1649
- _closePath(path) {
1650
- this._closeFile(path);
1651
- const dir = sysPath2.dirname(path);
1652
- this._getWatchedDir(dir).remove(sysPath2.basename(path));
1653
- }
1654
- /**
1655
- * Closes only file-specific watchers
1656
- */
1657
- _closeFile(path) {
1658
- const closers = this._closers.get(path);
1659
- if (!closers)
1660
- return;
1661
- closers.forEach((closer) => closer());
1662
- this._closers.delete(path);
1663
- }
1664
- _addPathCloser(path, closer) {
1665
- if (!closer)
1666
- return;
1667
- let list = this._closers.get(path);
1668
- if (!list) {
1669
- list = [];
1670
- this._closers.set(path, list);
1671
- }
1672
- list.push(closer);
1673
- }
1674
- _readdirp(root, opts) {
1675
- if (this.closed)
1676
- return;
1677
- const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
1678
- let stream = readdirp(root, options);
1679
- this._streams.add(stream);
1680
- stream.once(STR_CLOSE, () => {
1681
- stream = void 0;
1682
- });
1683
- stream.once(STR_END, () => {
1684
- if (stream) {
1685
- this._streams.delete(stream);
1686
- stream = void 0;
1687
- }
1688
- });
1689
- return stream;
1690
- }
1691
- };
1692
- function watch(paths, options = {}) {
1693
- const watcher = new FSWatcher(options);
1694
- watcher.add(paths);
1695
- return watcher;
1696
- }
1697
- var esm_default = { watch, FSWatcher };
1698
-
1699
-
1700
-
1701
-
1702
-
1703
- exports.FSWatcher = FSWatcher; exports.WatchHelper = WatchHelper; exports.default = esm_default; exports.watch = watch;
1704
- /*! Bundled license information:
1705
-
1706
- chokidar/esm/index.js:
1707
- (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
1708
- */