@ohos-ports/rsbuild-core 1.7.2-beta.1

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