@unpackjs/core 1.5.4 → 1.6.0

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