@olegkuibar/plunk 0.2.3 → 0.3.0-canary.0807dec

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