@ohos-ports/rspack-core 1.7.11-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 (284) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +15 -0
  3. package/compiled/@swc/types/index.d.ts +2134 -0
  4. package/compiled/@swc/types/index.js +19 -0
  5. package/compiled/@swc/types/license +201 -0
  6. package/compiled/@swc/types/package.json +1 -0
  7. package/compiled/browserslist-load-config/index.d.ts +21 -0
  8. package/compiled/browserslist-load-config/index.js +252 -0
  9. package/compiled/browserslist-load-config/license +21 -0
  10. package/compiled/browserslist-load-config/package.json +1 -0
  11. package/compiled/tinypool/LICENSE +24 -0
  12. package/compiled/tinypool/README.md +20 -0
  13. package/compiled/tinypool/dist/common-Qw-RoVFD.js +28 -0
  14. package/compiled/tinypool/dist/entry/process.d.ts +1 -0
  15. package/compiled/tinypool/dist/entry/process.js +72 -0
  16. package/compiled/tinypool/dist/entry/utils.d.ts +7 -0
  17. package/compiled/tinypool/dist/entry/utils.js +3 -0
  18. package/compiled/tinypool/dist/entry/worker.d.ts +1 -0
  19. package/compiled/tinypool/dist/entry/worker.js +76 -0
  20. package/compiled/tinypool/dist/index.d.ts +195 -0
  21. package/compiled/tinypool/dist/index.js +820 -0
  22. package/compiled/tinypool/dist/utils-B--2TaWv.js +38 -0
  23. package/compiled/tinypool/dist/utils-De75vAgL.js +10 -0
  24. package/compiled/tinypool/package.json +39 -0
  25. package/compiled/watchpack/index.d.ts +217 -0
  26. package/compiled/watchpack/index.js +3124 -0
  27. package/compiled/watchpack/license +20 -0
  28. package/compiled/watchpack/package.json +1 -0
  29. package/compiled/webpack-sources/index.js +4675 -0
  30. package/compiled/webpack-sources/license +21 -0
  31. package/compiled/webpack-sources/package.json +1 -0
  32. package/compiled/webpack-sources/types.d.ts +458 -0
  33. package/dist/BuildInfo.d.ts +17 -0
  34. package/dist/Chunk.d.ts +16 -0
  35. package/dist/ChunkGraph.d.ts +9 -0
  36. package/dist/Chunks.d.ts +12 -0
  37. package/dist/CodeGenerationResults.d.ts +1 -0
  38. package/dist/Compilation.d.ts +438 -0
  39. package/dist/Compiler.d.ts +226 -0
  40. package/dist/ConcatenatedModule.d.ts +1 -0
  41. package/dist/ContextModule.d.ts +1 -0
  42. package/dist/ContextModuleFactory.d.ts +13 -0
  43. package/dist/Diagnostics.d.ts +7 -0
  44. package/dist/Entrypoint.d.ts +2 -0
  45. package/dist/ErrorHelpers.d.ts +3 -0
  46. package/dist/ExecuteModulePlugin.d.ts +4 -0
  47. package/dist/ExportsInfo.d.ts +20 -0
  48. package/dist/ExternalModule.d.ts +1 -0
  49. package/dist/FileSystem.d.ts +54 -0
  50. package/dist/FileSystemInfo.d.ts +5 -0
  51. package/dist/Module.d.ts +42 -0
  52. package/dist/ModuleGraph.d.ts +19 -0
  53. package/dist/ModuleTypeConstants.d.ts +8 -0
  54. package/dist/MultiCompiler.d.ts +82 -0
  55. package/dist/MultiStats.d.ts +23 -0
  56. package/dist/MultiWatching.d.ts +27 -0
  57. package/dist/NativeWatchFileSystem.d.ts +23 -0
  58. package/dist/NormalModule.d.ts +15 -0
  59. package/dist/NormalModuleFactory.d.ts +23 -0
  60. package/dist/Resolver.d.ts +30 -0
  61. package/dist/ResolverFactory.d.ts +17 -0
  62. package/dist/RspackError.d.ts +12 -0
  63. package/dist/RuleSetCompiler.d.ts +9 -0
  64. package/dist/RuntimeGlobals.d.ts +356 -0
  65. package/dist/RuntimeModule.d.ts +34 -0
  66. package/dist/Stats.d.ts +17 -0
  67. package/dist/Template.d.ts +77 -0
  68. package/dist/VirtualModulesPlugin.d.ts +12 -0
  69. package/dist/Watching.d.ts +56 -0
  70. package/dist/builtin-loader/index.d.ts +1 -0
  71. package/dist/builtin-loader/lightningcss/index.d.ts +117 -0
  72. package/dist/builtin-loader/swc/collectTypeScriptInfo.d.ts +21 -0
  73. package/dist/builtin-loader/swc/index.d.ts +5 -0
  74. package/dist/builtin-loader/swc/pluginImport.d.ts +33 -0
  75. package/dist/builtin-loader/swc/types.d.ts +89 -0
  76. package/dist/builtin-plugin/APIPlugin.d.ts +9 -0
  77. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +9 -0
  78. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +9 -0
  79. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +9 -0
  80. package/dist/builtin-plugin/BannerPlugin.d.ts +40 -0
  81. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +14 -0
  82. package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +9 -0
  83. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +9 -0
  84. package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +54 -0
  85. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +9 -0
  86. package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +9 -0
  87. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +14 -0
  88. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +21 -0
  89. package/dist/builtin-plugin/CssModulesPlugin.d.ts +9 -0
  90. package/dist/builtin-plugin/DataUriPlugin.d.ts +9 -0
  91. package/dist/builtin-plugin/DefinePlugin.d.ts +16 -0
  92. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +7 -0
  93. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +7 -0
  94. package/dist/builtin-plugin/DllEntryPlugin.d.ts +12 -0
  95. package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +11 -0
  96. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +12 -0
  97. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +9 -0
  98. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +25 -0
  99. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +11 -0
  100. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +9 -0
  101. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +9 -0
  102. package/dist/builtin-plugin/EntryPlugin.d.ts +32 -0
  103. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +11 -0
  104. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +11 -0
  105. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +10 -0
  106. package/dist/builtin-plugin/ExternalsPlugin.d.ts +12 -0
  107. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +9 -0
  108. package/dist/builtin-plugin/FileUriPlugin.d.ts +9 -0
  109. package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +9 -0
  110. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +9 -0
  111. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +9 -0
  112. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +7 -0
  113. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +9 -0
  114. package/dist/builtin-plugin/HttpUriPlugin.d.ts +36 -0
  115. package/dist/builtin-plugin/IgnorePlugin.d.ts +19 -0
  116. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +9 -0
  117. package/dist/builtin-plugin/InlineExportsPlugin.d.ts +9 -0
  118. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +15 -0
  119. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +10 -0
  120. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +9 -0
  121. package/dist/builtin-plugin/LibManifestPlugin.d.ts +17 -0
  122. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +32 -0
  123. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +14 -0
  124. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +9 -0
  125. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +9 -0
  126. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +9 -0
  127. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +7 -0
  128. package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +9 -0
  129. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +9 -0
  130. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +9 -0
  131. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +7 -0
  132. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +7 -0
  133. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +9 -0
  134. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +9 -0
  135. package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +10 -0
  136. package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +10 -0
  137. package/dist/builtin-plugin/ProgressPlugin.d.ts +11 -0
  138. package/dist/builtin-plugin/ProvidePlugin.d.ts +10 -0
  139. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +9 -0
  140. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +9 -0
  141. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +9 -0
  142. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +49 -0
  143. package/dist/builtin-plugin/RslibPlugin.d.ts +11 -0
  144. package/dist/builtin-plugin/RstestPlugin.d.ts +11 -0
  145. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +11 -0
  146. package/dist/builtin-plugin/RuntimePlugin.d.ts +29 -0
  147. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +9 -0
  148. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +19 -0
  149. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +11 -0
  150. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +11 -0
  151. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +39 -0
  152. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +215 -0
  153. package/dist/builtin-plugin/URLPlugin.d.ts +9 -0
  154. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +7 -0
  155. package/dist/builtin-plugin/WorkerPlugin.d.ts +14 -0
  156. package/dist/builtin-plugin/base.d.ts +45 -0
  157. package/dist/builtin-plugin/css-extract/index.d.ts +24 -0
  158. package/dist/builtin-plugin/css-extract/loader.d.ts +21 -0
  159. package/dist/builtin-plugin/css-extract/utils.d.ts +6 -0
  160. package/dist/builtin-plugin/html-plugin/hooks.d.ts +32 -0
  161. package/dist/builtin-plugin/html-plugin/index.d.ts +2 -0
  162. package/dist/builtin-plugin/html-plugin/options.d.ts +82 -0
  163. package/dist/builtin-plugin/html-plugin/plugin.d.ts +24 -0
  164. package/dist/builtin-plugin/html-plugin/taps.d.ts +2 -0
  165. package/dist/builtin-plugin/index.d.ts +84 -0
  166. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +10 -0
  167. package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +12 -0
  168. package/dist/config/adapter.d.ts +8 -0
  169. package/dist/config/adapterRuleUse.d.ts +391 -0
  170. package/dist/config/browserslistTargetHandler.d.ts +15 -0
  171. package/dist/config/defaults.d.ts +13 -0
  172. package/dist/config/devServer.d.ts +314 -0
  173. package/dist/config/index.d.ts +5 -0
  174. package/dist/config/normalization.d.ts +174 -0
  175. package/dist/config/target.d.ts +93 -0
  176. package/dist/config/types.d.ts +2432 -0
  177. package/dist/container/ContainerPlugin.d.ts +41 -0
  178. package/dist/container/ContainerReferencePlugin.d.ts +34 -0
  179. package/dist/container/ModuleFederationManifestPlugin.d.ts +37 -0
  180. package/dist/container/ModuleFederationPlugin.d.ts +17 -0
  181. package/dist/container/ModuleFederationPluginV1.d.ts +22 -0
  182. package/dist/container/ModuleFederationRuntimePlugin.d.ts +16 -0
  183. package/dist/container/index.d.ts +4 -0
  184. package/dist/container/options.d.ts +3 -0
  185. package/dist/cssExtractHmr.js +124 -0
  186. package/dist/cssExtractLoader.js +160 -0
  187. package/dist/error/ConcurrentCompilationError.d.ts +14 -0
  188. package/dist/exports.d.ts +178 -0
  189. package/dist/index.d.ts +10 -0
  190. package/dist/index.js +12638 -0
  191. package/dist/lib/AbstractMethodError.d.ts +23 -0
  192. package/dist/lib/Cache.d.ts +65 -0
  193. package/dist/lib/CacheFacade.d.ts +139 -0
  194. package/dist/lib/DllPlugin.d.ts +42 -0
  195. package/dist/lib/DllReferencePlugin.d.ts +119 -0
  196. package/dist/lib/EntryOptionPlugin.d.ts +33 -0
  197. package/dist/lib/EnvironmentPlugin.d.ts +22 -0
  198. package/dist/lib/HookWebpackError.d.ts +40 -0
  199. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  200. package/dist/lib/LoaderOptionsPlugin.d.ts +28 -0
  201. package/dist/lib/LoaderTargetPlugin.d.ts +24 -0
  202. package/dist/lib/ModuleFilenameHelpers.d.ts +53 -0
  203. package/dist/lib/WebpackError.d.ts +21 -0
  204. package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
  205. package/dist/lib/cache/getLazyHashedEtag.d.ts +35 -0
  206. package/dist/lib/cache/mergeEtags.d.ts +17 -0
  207. package/dist/loader-runner/LoaderLoadingError.d.ts +13 -0
  208. package/dist/loader-runner/ModuleError.d.ts +13 -0
  209. package/dist/loader-runner/index.d.ts +36 -0
  210. package/dist/loader-runner/loadLoader.d.ts +12 -0
  211. package/dist/loader-runner/service.d.ts +73 -0
  212. package/dist/loader-runner/utils.d.ts +7 -0
  213. package/dist/loader-runner/worker.d.ts +14 -0
  214. package/dist/logging/Logger.d.ts +61 -0
  215. package/dist/logging/createConsoleLogger.d.ts +35 -0
  216. package/dist/logging/truncateArgs.d.ts +16 -0
  217. package/dist/moduleFederationDefaultRuntime.js +1 -0
  218. package/dist/node/NodeEnvironmentPlugin.d.ts +10 -0
  219. package/dist/node/NodeTemplatePlugin.d.ts +18 -0
  220. package/dist/node/NodeWatchFileSystem.d.ts +18 -0
  221. package/dist/node/nodeConsole.d.ts +15 -0
  222. package/dist/rspack.d.ts +25 -0
  223. package/dist/rspackOptionsApply.d.ts +4 -0
  224. package/dist/runtime/cssExtractHmr.d.ts +4 -0
  225. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  226. package/dist/sharing/ConsumeSharedPlugin.d.ts +42 -0
  227. package/dist/sharing/ProvideSharedPlugin.d.ts +35 -0
  228. package/dist/sharing/SharePlugin.d.ts +53 -0
  229. package/dist/sharing/ShareRuntimePlugin.d.ts +9 -0
  230. package/dist/sharing/utils.d.ts +1 -0
  231. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +20 -0
  232. package/dist/stats/DefaultStatsPresetPlugin.d.ts +4 -0
  233. package/dist/stats/DefaultStatsPrinterPlugin.d.ts +13 -0
  234. package/dist/stats/StatsFactory.d.ts +57 -0
  235. package/dist/stats/StatsPrinter.d.ts +57 -0
  236. package/dist/stats/statsFactoryUtils.d.ts +341 -0
  237. package/dist/swc.d.ts +7 -0
  238. package/dist/taps/compilation.d.ts +8 -0
  239. package/dist/taps/compiler.d.ts +2 -0
  240. package/dist/taps/contextModuleFactory.d.ts +2 -0
  241. package/dist/taps/index.d.ts +6 -0
  242. package/dist/taps/javascriptModules.d.ts +2 -0
  243. package/dist/taps/normalModuleFactory.d.ts +2 -0
  244. package/dist/taps/types.d.ts +11 -0
  245. package/dist/trace/index.d.ts +46 -0
  246. package/dist/trace/traceHookPlugin.d.ts +5 -0
  247. package/dist/util/ArrayQueue.d.ts +45 -0
  248. package/dist/util/AsyncTask.d.ts +7 -0
  249. package/dist/util/MergeCaller.d.ts +10 -0
  250. package/dist/util/SizeFormatHelpers.d.ts +10 -0
  251. package/dist/util/SplitChunkSize.d.ts +5 -0
  252. package/dist/util/assertNotNil.d.ts +1 -0
  253. package/dist/util/assetCondition.d.ts +2 -0
  254. package/dist/util/asyncLib.d.ts +54 -0
  255. package/dist/util/bindingVersionCheck.d.ts +5 -0
  256. package/dist/util/cleverMerge.d.ts +24 -0
  257. package/dist/util/comparators.d.ts +16 -0
  258. package/dist/util/createHash.d.ts +16 -0
  259. package/dist/util/createReadonlyMap.d.ts +1 -0
  260. package/dist/util/fake.d.ts +14 -0
  261. package/dist/util/fs.d.ts +375 -0
  262. package/dist/util/hash/index.d.ts +26 -0
  263. package/dist/util/hash/md4.d.ts +11 -0
  264. package/dist/util/hash/wasm-hash.d.ts +51 -0
  265. package/dist/util/hash/xxhash64.d.ts +11 -0
  266. package/dist/util/identifier.d.ts +31 -0
  267. package/dist/util/index.d.ts +9 -0
  268. package/dist/util/memoize.d.ts +2 -0
  269. package/dist/util/runtime.d.ts +2 -0
  270. package/dist/util/smartGrouping.d.ts +21 -0
  271. package/dist/util/source.d.ts +6 -0
  272. package/dist/util/validateConfig.d.ts +5 -0
  273. package/dist/worker.js +978 -0
  274. package/hot/dev-server.js +75 -0
  275. package/hot/emitter.js +21 -0
  276. package/hot/lazy-compilation-node.js +106 -0
  277. package/hot/lazy-compilation-web.js +98 -0
  278. package/hot/log-apply-result.js +49 -0
  279. package/hot/log.js +79 -0
  280. package/hot/only-dev-server.js +103 -0
  281. package/hot/poll.js +40 -0
  282. package/hot/signal.js +66 -0
  283. package/module.d.ts +273 -0
  284. package/package.json +79 -0
@@ -0,0 +1,3124 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 428:
5
+ /***/ ((module) => {
6
+
7
+ module.exports = function (glob, opts) {
8
+ if (typeof glob !== 'string') {
9
+ throw new TypeError('Expected a string');
10
+ }
11
+
12
+ var str = String(glob);
13
+
14
+ // The regexp we are building, as a string.
15
+ var reStr = "";
16
+
17
+ // Whether we are matching so called "extended" globs (like bash) and should
18
+ // support single character matching, matching ranges of characters, group
19
+ // matching, etc.
20
+ var extended = opts ? !!opts.extended : false;
21
+
22
+ // When globstar is _false_ (default), '/foo/*' is translated a regexp like
23
+ // '^\/foo\/.*$' which will match any string beginning with '/foo/'
24
+ // When globstar is _true_, '/foo/*' is translated to regexp like
25
+ // '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
26
+ // which does not have a '/' to the right of it.
27
+ // E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
28
+ // these will not '/foo/bar/baz', '/foo/bar/baz.txt'
29
+ // Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
30
+ // globstar is _false_
31
+ var globstar = opts ? !!opts.globstar : false;
32
+
33
+ // If we are doing extended matching, this boolean is true when we are inside
34
+ // a group (eg {*.html,*.js}), and false otherwise.
35
+ var inGroup = false;
36
+
37
+ // RegExp flags (eg "i" ) to pass in to RegExp constructor.
38
+ var flags = opts && typeof( opts.flags ) === "string" ? opts.flags : "";
39
+
40
+ var c;
41
+ for (var i = 0, len = str.length; i < len; i++) {
42
+ c = str[i];
43
+
44
+ switch (c) {
45
+ case "/":
46
+ case "$":
47
+ case "^":
48
+ case "+":
49
+ case ".":
50
+ case "(":
51
+ case ")":
52
+ case "=":
53
+ case "!":
54
+ case "|":
55
+ reStr += "\\" + c;
56
+ break;
57
+
58
+ case "?":
59
+ if (extended) {
60
+ reStr += ".";
61
+ break;
62
+ }
63
+
64
+ case "[":
65
+ case "]":
66
+ if (extended) {
67
+ reStr += c;
68
+ break;
69
+ }
70
+
71
+ case "{":
72
+ if (extended) {
73
+ inGroup = true;
74
+ reStr += "(";
75
+ break;
76
+ }
77
+
78
+ case "}":
79
+ if (extended) {
80
+ inGroup = false;
81
+ reStr += ")";
82
+ break;
83
+ }
84
+
85
+ case ",":
86
+ if (inGroup) {
87
+ reStr += "|";
88
+ break;
89
+ }
90
+ reStr += "\\" + c;
91
+ break;
92
+
93
+ case "*":
94
+ // Move over all consecutive "*"'s.
95
+ // Also store the previous and next characters
96
+ var prevChar = str[i - 1];
97
+ var starCount = 1;
98
+ while(str[i + 1] === "*") {
99
+ starCount++;
100
+ i++;
101
+ }
102
+ var nextChar = str[i + 1];
103
+
104
+ if (!globstar) {
105
+ // globstar is disabled, so treat any number of "*" as one
106
+ reStr += ".*";
107
+ } else {
108
+ // globstar is enabled, so determine if this is a globstar segment
109
+ var isGlobstar = starCount > 1 // multiple "*"'s
110
+ && (prevChar === "/" || prevChar === undefined) // from the start of the segment
111
+ && (nextChar === "/" || nextChar === undefined) // to the end of the segment
112
+
113
+ if (isGlobstar) {
114
+ // it's a globstar, so match zero or more path segments
115
+ reStr += "((?:[^/]*(?:\/|$))*)";
116
+ i++; // move over the "/"
117
+ } else {
118
+ // it's not a globstar, so only match one path segment
119
+ reStr += "([^/]*)";
120
+ }
121
+ }
122
+ break;
123
+
124
+ default:
125
+ reStr += c;
126
+ }
127
+ }
128
+
129
+ // When regexp 'g' flag is specified don't
130
+ // constrain the regular expression with ^ & $
131
+ if (!flags || !~flags.indexOf('g')) {
132
+ reStr = "^" + reStr + "$";
133
+ }
134
+
135
+ return new RegExp(reStr, flags);
136
+ };
137
+
138
+
139
+ /***/ }),
140
+
141
+ /***/ 648:
142
+ /***/ ((module) => {
143
+
144
+ "use strict";
145
+
146
+
147
+ module.exports = clone
148
+
149
+ var getPrototypeOf = Object.getPrototypeOf || function (obj) {
150
+ return obj.__proto__
151
+ }
152
+
153
+ function clone (obj) {
154
+ if (obj === null || typeof obj !== 'object')
155
+ return obj
156
+
157
+ if (obj instanceof Object)
158
+ var copy = { __proto__: getPrototypeOf(obj) }
159
+ else
160
+ var copy = Object.create(null)
161
+
162
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
163
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
164
+ })
165
+
166
+ return copy
167
+ }
168
+
169
+
170
+ /***/ }),
171
+
172
+ /***/ 692:
173
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
174
+
175
+ var fs = __nccwpck_require__(896)
176
+ var polyfills = __nccwpck_require__(161)
177
+ var legacy = __nccwpck_require__(50)
178
+ var clone = __nccwpck_require__(648)
179
+
180
+ var util = __nccwpck_require__(23)
181
+
182
+ /* istanbul ignore next - node 0.x polyfill */
183
+ var gracefulQueue
184
+ var previousSymbol
185
+
186
+ /* istanbul ignore else - node 0.x polyfill */
187
+ if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
188
+ gracefulQueue = Symbol.for('graceful-fs.queue')
189
+ // This is used in testing by future versions
190
+ previousSymbol = Symbol.for('graceful-fs.previous')
191
+ } else {
192
+ gracefulQueue = '___graceful-fs.queue'
193
+ previousSymbol = '___graceful-fs.previous'
194
+ }
195
+
196
+ function noop () {}
197
+
198
+ function publishQueue(context, queue) {
199
+ Object.defineProperty(context, gracefulQueue, {
200
+ get: function() {
201
+ return queue
202
+ }
203
+ })
204
+ }
205
+
206
+ var debug = noop
207
+ if (util.debuglog)
208
+ debug = util.debuglog('gfs4')
209
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
210
+ debug = function() {
211
+ var m = util.format.apply(util, arguments)
212
+ m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
213
+ console.error(m)
214
+ }
215
+
216
+ // Once time initialization
217
+ if (!fs[gracefulQueue]) {
218
+ // This queue can be shared by multiple loaded instances
219
+ var queue = global[gracefulQueue] || []
220
+ publishQueue(fs, queue)
221
+
222
+ // Patch fs.close/closeSync to shared queue version, because we need
223
+ // to retry() whenever a close happens *anywhere* in the program.
224
+ // This is essential when multiple graceful-fs instances are
225
+ // in play at the same time.
226
+ fs.close = (function (fs$close) {
227
+ function close (fd, cb) {
228
+ return fs$close.call(fs, fd, function (err) {
229
+ // This function uses the graceful-fs shared queue
230
+ if (!err) {
231
+ resetQueue()
232
+ }
233
+
234
+ if (typeof cb === 'function')
235
+ cb.apply(this, arguments)
236
+ })
237
+ }
238
+
239
+ Object.defineProperty(close, previousSymbol, {
240
+ value: fs$close
241
+ })
242
+ return close
243
+ })(fs.close)
244
+
245
+ fs.closeSync = (function (fs$closeSync) {
246
+ function closeSync (fd) {
247
+ // This function uses the graceful-fs shared queue
248
+ fs$closeSync.apply(fs, arguments)
249
+ resetQueue()
250
+ }
251
+
252
+ Object.defineProperty(closeSync, previousSymbol, {
253
+ value: fs$closeSync
254
+ })
255
+ return closeSync
256
+ })(fs.closeSync)
257
+
258
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
259
+ process.on('exit', function() {
260
+ debug(fs[gracefulQueue])
261
+ __nccwpck_require__(613).equal(fs[gracefulQueue].length, 0)
262
+ })
263
+ }
264
+ }
265
+
266
+ if (!global[gracefulQueue]) {
267
+ publishQueue(global, fs[gracefulQueue]);
268
+ }
269
+
270
+ module.exports = patch(clone(fs))
271
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
272
+ module.exports = patch(fs)
273
+ fs.__patched = true;
274
+ }
275
+
276
+ function patch (fs) {
277
+ // Everything that references the open() function needs to be in here
278
+ polyfills(fs)
279
+ fs.gracefulify = patch
280
+
281
+ fs.createReadStream = createReadStream
282
+ fs.createWriteStream = createWriteStream
283
+ var fs$readFile = fs.readFile
284
+ fs.readFile = readFile
285
+ function readFile (path, options, cb) {
286
+ if (typeof options === 'function')
287
+ cb = options, options = null
288
+
289
+ return go$readFile(path, options, cb)
290
+
291
+ function go$readFile (path, options, cb, startTime) {
292
+ return fs$readFile(path, options, function (err) {
293
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
294
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])
295
+ else {
296
+ if (typeof cb === 'function')
297
+ cb.apply(this, arguments)
298
+ }
299
+ })
300
+ }
301
+ }
302
+
303
+ var fs$writeFile = fs.writeFile
304
+ fs.writeFile = writeFile
305
+ function writeFile (path, data, options, cb) {
306
+ if (typeof options === 'function')
307
+ cb = options, options = null
308
+
309
+ return go$writeFile(path, data, options, cb)
310
+
311
+ function go$writeFile (path, data, options, cb, startTime) {
312
+ return fs$writeFile(path, data, options, function (err) {
313
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
314
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
315
+ else {
316
+ if (typeof cb === 'function')
317
+ cb.apply(this, arguments)
318
+ }
319
+ })
320
+ }
321
+ }
322
+
323
+ var fs$appendFile = fs.appendFile
324
+ if (fs$appendFile)
325
+ fs.appendFile = appendFile
326
+ function appendFile (path, data, options, cb) {
327
+ if (typeof options === 'function')
328
+ cb = options, options = null
329
+
330
+ return go$appendFile(path, data, options, cb)
331
+
332
+ function go$appendFile (path, data, options, cb, startTime) {
333
+ return fs$appendFile(path, data, options, function (err) {
334
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
335
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
336
+ else {
337
+ if (typeof cb === 'function')
338
+ cb.apply(this, arguments)
339
+ }
340
+ })
341
+ }
342
+ }
343
+
344
+ var fs$copyFile = fs.copyFile
345
+ if (fs$copyFile)
346
+ fs.copyFile = copyFile
347
+ function copyFile (src, dest, flags, cb) {
348
+ if (typeof flags === 'function') {
349
+ cb = flags
350
+ flags = 0
351
+ }
352
+ return go$copyFile(src, dest, flags, cb)
353
+
354
+ function go$copyFile (src, dest, flags, cb, startTime) {
355
+ return fs$copyFile(src, dest, flags, function (err) {
356
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
357
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
358
+ else {
359
+ if (typeof cb === 'function')
360
+ cb.apply(this, arguments)
361
+ }
362
+ })
363
+ }
364
+ }
365
+
366
+ var fs$readdir = fs.readdir
367
+ fs.readdir = readdir
368
+ var noReaddirOptionVersions = /^v[0-5]\./
369
+ function readdir (path, options, cb) {
370
+ if (typeof options === 'function')
371
+ cb = options, options = null
372
+
373
+ var go$readdir = noReaddirOptionVersions.test(process.version)
374
+ ? function go$readdir (path, options, cb, startTime) {
375
+ return fs$readdir(path, fs$readdirCallback(
376
+ path, options, cb, startTime
377
+ ))
378
+ }
379
+ : function go$readdir (path, options, cb, startTime) {
380
+ return fs$readdir(path, options, fs$readdirCallback(
381
+ path, options, cb, startTime
382
+ ))
383
+ }
384
+
385
+ return go$readdir(path, options, cb)
386
+
387
+ function fs$readdirCallback (path, options, cb, startTime) {
388
+ return function (err, files) {
389
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
390
+ enqueue([
391
+ go$readdir,
392
+ [path, options, cb],
393
+ err,
394
+ startTime || Date.now(),
395
+ Date.now()
396
+ ])
397
+ else {
398
+ if (files && files.sort)
399
+ files.sort()
400
+
401
+ if (typeof cb === 'function')
402
+ cb.call(this, err, files)
403
+ }
404
+ }
405
+ }
406
+ }
407
+
408
+ if (process.version.substr(0, 4) === 'v0.8') {
409
+ var legStreams = legacy(fs)
410
+ ReadStream = legStreams.ReadStream
411
+ WriteStream = legStreams.WriteStream
412
+ }
413
+
414
+ var fs$ReadStream = fs.ReadStream
415
+ if (fs$ReadStream) {
416
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype)
417
+ ReadStream.prototype.open = ReadStream$open
418
+ }
419
+
420
+ var fs$WriteStream = fs.WriteStream
421
+ if (fs$WriteStream) {
422
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype)
423
+ WriteStream.prototype.open = WriteStream$open
424
+ }
425
+
426
+ Object.defineProperty(fs, 'ReadStream', {
427
+ get: function () {
428
+ return ReadStream
429
+ },
430
+ set: function (val) {
431
+ ReadStream = val
432
+ },
433
+ enumerable: true,
434
+ configurable: true
435
+ })
436
+ Object.defineProperty(fs, 'WriteStream', {
437
+ get: function () {
438
+ return WriteStream
439
+ },
440
+ set: function (val) {
441
+ WriteStream = val
442
+ },
443
+ enumerable: true,
444
+ configurable: true
445
+ })
446
+
447
+ // legacy names
448
+ var FileReadStream = ReadStream
449
+ Object.defineProperty(fs, 'FileReadStream', {
450
+ get: function () {
451
+ return FileReadStream
452
+ },
453
+ set: function (val) {
454
+ FileReadStream = val
455
+ },
456
+ enumerable: true,
457
+ configurable: true
458
+ })
459
+ var FileWriteStream = WriteStream
460
+ Object.defineProperty(fs, 'FileWriteStream', {
461
+ get: function () {
462
+ return FileWriteStream
463
+ },
464
+ set: function (val) {
465
+ FileWriteStream = val
466
+ },
467
+ enumerable: true,
468
+ configurable: true
469
+ })
470
+
471
+ function ReadStream (path, options) {
472
+ if (this instanceof ReadStream)
473
+ return fs$ReadStream.apply(this, arguments), this
474
+ else
475
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
476
+ }
477
+
478
+ function ReadStream$open () {
479
+ var that = this
480
+ open(that.path, that.flags, that.mode, function (err, fd) {
481
+ if (err) {
482
+ if (that.autoClose)
483
+ that.destroy()
484
+
485
+ that.emit('error', err)
486
+ } else {
487
+ that.fd = fd
488
+ that.emit('open', fd)
489
+ that.read()
490
+ }
491
+ })
492
+ }
493
+
494
+ function WriteStream (path, options) {
495
+ if (this instanceof WriteStream)
496
+ return fs$WriteStream.apply(this, arguments), this
497
+ else
498
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
499
+ }
500
+
501
+ function WriteStream$open () {
502
+ var that = this
503
+ open(that.path, that.flags, that.mode, function (err, fd) {
504
+ if (err) {
505
+ that.destroy()
506
+ that.emit('error', err)
507
+ } else {
508
+ that.fd = fd
509
+ that.emit('open', fd)
510
+ }
511
+ })
512
+ }
513
+
514
+ function createReadStream (path, options) {
515
+ return new fs.ReadStream(path, options)
516
+ }
517
+
518
+ function createWriteStream (path, options) {
519
+ return new fs.WriteStream(path, options)
520
+ }
521
+
522
+ var fs$open = fs.open
523
+ fs.open = open
524
+ function open (path, flags, mode, cb) {
525
+ if (typeof mode === 'function')
526
+ cb = mode, mode = null
527
+
528
+ return go$open(path, flags, mode, cb)
529
+
530
+ function go$open (path, flags, mode, cb, startTime) {
531
+ return fs$open(path, flags, mode, function (err, fd) {
532
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
533
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])
534
+ else {
535
+ if (typeof cb === 'function')
536
+ cb.apply(this, arguments)
537
+ }
538
+ })
539
+ }
540
+ }
541
+
542
+ return fs
543
+ }
544
+
545
+ function enqueue (elem) {
546
+ debug('ENQUEUE', elem[0].name, elem[1])
547
+ fs[gracefulQueue].push(elem)
548
+ retry()
549
+ }
550
+
551
+ // keep track of the timeout between retry() calls
552
+ var retryTimer
553
+
554
+ // reset the startTime and lastTime to now
555
+ // this resets the start of the 60 second overall timeout as well as the
556
+ // delay between attempts so that we'll retry these jobs sooner
557
+ function resetQueue () {
558
+ var now = Date.now()
559
+ for (var i = 0; i < fs[gracefulQueue].length; ++i) {
560
+ // entries that are only a length of 2 are from an older version, don't
561
+ // bother modifying those since they'll be retried anyway.
562
+ if (fs[gracefulQueue][i].length > 2) {
563
+ fs[gracefulQueue][i][3] = now // startTime
564
+ fs[gracefulQueue][i][4] = now // lastTime
565
+ }
566
+ }
567
+ // call retry to make sure we're actively processing the queue
568
+ retry()
569
+ }
570
+
571
+ function retry () {
572
+ // clear the timer and remove it to help prevent unintended concurrency
573
+ clearTimeout(retryTimer)
574
+ retryTimer = undefined
575
+
576
+ if (fs[gracefulQueue].length === 0)
577
+ return
578
+
579
+ var elem = fs[gracefulQueue].shift()
580
+ var fn = elem[0]
581
+ var args = elem[1]
582
+ // these items may be unset if they were added by an older graceful-fs
583
+ var err = elem[2]
584
+ var startTime = elem[3]
585
+ var lastTime = elem[4]
586
+
587
+ // if we don't have a startTime we have no way of knowing if we've waited
588
+ // long enough, so go ahead and retry this item now
589
+ if (startTime === undefined) {
590
+ debug('RETRY', fn.name, args)
591
+ fn.apply(null, args)
592
+ } else if (Date.now() - startTime >= 60000) {
593
+ // it's been more than 60 seconds total, bail now
594
+ debug('TIMEOUT', fn.name, args)
595
+ var cb = args.pop()
596
+ if (typeof cb === 'function')
597
+ cb.call(null, err)
598
+ } else {
599
+ // the amount of time between the last attempt and right now
600
+ var sinceAttempt = Date.now() - lastTime
601
+ // the amount of time between when we first tried, and when we last tried
602
+ // rounded up to at least 1
603
+ var sinceStart = Math.max(lastTime - startTime, 1)
604
+ // backoff. wait longer than the total time we've been retrying, but only
605
+ // up to a maximum of 100ms
606
+ var desiredDelay = Math.min(sinceStart * 1.2, 100)
607
+ // it's been long enough since the last retry, do it again
608
+ if (sinceAttempt >= desiredDelay) {
609
+ debug('RETRY', fn.name, args)
610
+ fn.apply(null, args.concat([startTime]))
611
+ } else {
612
+ // if we can't do this job yet, push it to the end of the queue
613
+ // and let the next iteration check again
614
+ fs[gracefulQueue].push(elem)
615
+ }
616
+ }
617
+
618
+ // schedule our next run if one isn't already scheduled
619
+ if (retryTimer === undefined) {
620
+ retryTimer = setTimeout(retry, 0)
621
+ }
622
+ }
623
+
624
+
625
+ /***/ }),
626
+
627
+ /***/ 50:
628
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
629
+
630
+ var Stream = (__nccwpck_require__(203).Stream)
631
+
632
+ module.exports = legacy
633
+
634
+ function legacy (fs) {
635
+ return {
636
+ ReadStream: ReadStream,
637
+ WriteStream: WriteStream
638
+ }
639
+
640
+ function ReadStream (path, options) {
641
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
642
+
643
+ Stream.call(this);
644
+
645
+ var self = this;
646
+
647
+ this.path = path;
648
+ this.fd = null;
649
+ this.readable = true;
650
+ this.paused = false;
651
+
652
+ this.flags = 'r';
653
+ this.mode = 438; /*=0666*/
654
+ this.bufferSize = 64 * 1024;
655
+
656
+ options = options || {};
657
+
658
+ // Mixin options into this
659
+ var keys = Object.keys(options);
660
+ for (var index = 0, length = keys.length; index < length; index++) {
661
+ var key = keys[index];
662
+ this[key] = options[key];
663
+ }
664
+
665
+ if (this.encoding) this.setEncoding(this.encoding);
666
+
667
+ if (this.start !== undefined) {
668
+ if ('number' !== typeof this.start) {
669
+ throw TypeError('start must be a Number');
670
+ }
671
+ if (this.end === undefined) {
672
+ this.end = Infinity;
673
+ } else if ('number' !== typeof this.end) {
674
+ throw TypeError('end must be a Number');
675
+ }
676
+
677
+ if (this.start > this.end) {
678
+ throw new Error('start must be <= end');
679
+ }
680
+
681
+ this.pos = this.start;
682
+ }
683
+
684
+ if (this.fd !== null) {
685
+ process.nextTick(function() {
686
+ self._read();
687
+ });
688
+ return;
689
+ }
690
+
691
+ fs.open(this.path, this.flags, this.mode, function (err, fd) {
692
+ if (err) {
693
+ self.emit('error', err);
694
+ self.readable = false;
695
+ return;
696
+ }
697
+
698
+ self.fd = fd;
699
+ self.emit('open', fd);
700
+ self._read();
701
+ })
702
+ }
703
+
704
+ function WriteStream (path, options) {
705
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
706
+
707
+ Stream.call(this);
708
+
709
+ this.path = path;
710
+ this.fd = null;
711
+ this.writable = true;
712
+
713
+ this.flags = 'w';
714
+ this.encoding = 'binary';
715
+ this.mode = 438; /*=0666*/
716
+ this.bytesWritten = 0;
717
+
718
+ options = options || {};
719
+
720
+ // Mixin options into this
721
+ var keys = Object.keys(options);
722
+ for (var index = 0, length = keys.length; index < length; index++) {
723
+ var key = keys[index];
724
+ this[key] = options[key];
725
+ }
726
+
727
+ if (this.start !== undefined) {
728
+ if ('number' !== typeof this.start) {
729
+ throw TypeError('start must be a Number');
730
+ }
731
+ if (this.start < 0) {
732
+ throw new Error('start must be >= zero');
733
+ }
734
+
735
+ this.pos = this.start;
736
+ }
737
+
738
+ this.busy = false;
739
+ this._queue = [];
740
+
741
+ if (this.fd === null) {
742
+ this._open = fs.open;
743
+ this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
744
+ this.flush();
745
+ }
746
+ }
747
+ }
748
+
749
+
750
+ /***/ }),
751
+
752
+ /***/ 161:
753
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
754
+
755
+ var constants = __nccwpck_require__(140)
756
+
757
+ var origCwd = process.cwd
758
+ var cwd = null
759
+
760
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
761
+
762
+ process.cwd = function() {
763
+ if (!cwd)
764
+ cwd = origCwd.call(process)
765
+ return cwd
766
+ }
767
+ try {
768
+ process.cwd()
769
+ } catch (er) {}
770
+
771
+ // This check is needed until node.js 12 is required
772
+ if (typeof process.chdir === 'function') {
773
+ var chdir = process.chdir
774
+ process.chdir = function (d) {
775
+ cwd = null
776
+ chdir.call(process, d)
777
+ }
778
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)
779
+ }
780
+
781
+ module.exports = patch
782
+
783
+ function patch (fs) {
784
+ // (re-)implement some things that are known busted or missing.
785
+
786
+ // lchmod, broken prior to 0.6.2
787
+ // back-port the fix here.
788
+ if (constants.hasOwnProperty('O_SYMLINK') &&
789
+ process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
790
+ patchLchmod(fs)
791
+ }
792
+
793
+ // lutimes implementation, or no-op
794
+ if (!fs.lutimes) {
795
+ patchLutimes(fs)
796
+ }
797
+
798
+ // https://github.com/isaacs/node-graceful-fs/issues/4
799
+ // Chown should not fail on einval or eperm if non-root.
800
+ // It should not fail on enosys ever, as this just indicates
801
+ // that a fs doesn't support the intended operation.
802
+
803
+ fs.chown = chownFix(fs.chown)
804
+ fs.fchown = chownFix(fs.fchown)
805
+ fs.lchown = chownFix(fs.lchown)
806
+
807
+ fs.chmod = chmodFix(fs.chmod)
808
+ fs.fchmod = chmodFix(fs.fchmod)
809
+ fs.lchmod = chmodFix(fs.lchmod)
810
+
811
+ fs.chownSync = chownFixSync(fs.chownSync)
812
+ fs.fchownSync = chownFixSync(fs.fchownSync)
813
+ fs.lchownSync = chownFixSync(fs.lchownSync)
814
+
815
+ fs.chmodSync = chmodFixSync(fs.chmodSync)
816
+ fs.fchmodSync = chmodFixSync(fs.fchmodSync)
817
+ fs.lchmodSync = chmodFixSync(fs.lchmodSync)
818
+
819
+ fs.stat = statFix(fs.stat)
820
+ fs.fstat = statFix(fs.fstat)
821
+ fs.lstat = statFix(fs.lstat)
822
+
823
+ fs.statSync = statFixSync(fs.statSync)
824
+ fs.fstatSync = statFixSync(fs.fstatSync)
825
+ fs.lstatSync = statFixSync(fs.lstatSync)
826
+
827
+ // if lchmod/lchown do not exist, then make them no-ops
828
+ if (fs.chmod && !fs.lchmod) {
829
+ fs.lchmod = function (path, mode, cb) {
830
+ if (cb) process.nextTick(cb)
831
+ }
832
+ fs.lchmodSync = function () {}
833
+ }
834
+ if (fs.chown && !fs.lchown) {
835
+ fs.lchown = function (path, uid, gid, cb) {
836
+ if (cb) process.nextTick(cb)
837
+ }
838
+ fs.lchownSync = function () {}
839
+ }
840
+
841
+ // on Windows, A/V software can lock the directory, causing this
842
+ // to fail with an EACCES or EPERM if the directory contains newly
843
+ // created files. Try again on failure, for up to 60 seconds.
844
+
845
+ // Set the timeout this long because some Windows Anti-Virus, such as Parity
846
+ // bit9, may lock files for up to a minute, causing npm package install
847
+ // failures. Also, take care to yield the scheduler. Windows scheduling gives
848
+ // CPU to a busy looping process, which can cause the program causing the lock
849
+ // contention to be starved of CPU by node, so the contention doesn't resolve.
850
+ if (platform === "win32") {
851
+ fs.rename = typeof fs.rename !== 'function' ? fs.rename
852
+ : (function (fs$rename) {
853
+ function rename (from, to, cb) {
854
+ var start = Date.now()
855
+ var backoff = 0;
856
+ fs$rename(from, to, function CB (er) {
857
+ if (er
858
+ && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
859
+ && Date.now() - start < 60000) {
860
+ setTimeout(function() {
861
+ fs.stat(to, function (stater, st) {
862
+ if (stater && stater.code === "ENOENT")
863
+ fs$rename(from, to, CB);
864
+ else
865
+ cb(er)
866
+ })
867
+ }, backoff)
868
+ if (backoff < 100)
869
+ backoff += 10;
870
+ return;
871
+ }
872
+ if (cb) cb(er)
873
+ })
874
+ }
875
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)
876
+ return rename
877
+ })(fs.rename)
878
+ }
879
+
880
+ // if read() returns EAGAIN, then just try it again.
881
+ fs.read = typeof fs.read !== 'function' ? fs.read
882
+ : (function (fs$read) {
883
+ function read (fd, buffer, offset, length, position, callback_) {
884
+ var callback
885
+ if (callback_ && typeof callback_ === 'function') {
886
+ var eagCounter = 0
887
+ callback = function (er, _, __) {
888
+ if (er && er.code === 'EAGAIN' && eagCounter < 10) {
889
+ eagCounter ++
890
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
891
+ }
892
+ callback_.apply(this, arguments)
893
+ }
894
+ }
895
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
896
+ }
897
+
898
+ // This ensures `util.promisify` works as it does for native `fs.read`.
899
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)
900
+ return read
901
+ })(fs.read)
902
+
903
+ fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
904
+ : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
905
+ var eagCounter = 0
906
+ while (true) {
907
+ try {
908
+ return fs$readSync.call(fs, fd, buffer, offset, length, position)
909
+ } catch (er) {
910
+ if (er.code === 'EAGAIN' && eagCounter < 10) {
911
+ eagCounter ++
912
+ continue
913
+ }
914
+ throw er
915
+ }
916
+ }
917
+ }})(fs.readSync)
918
+
919
+ function patchLchmod (fs) {
920
+ fs.lchmod = function (path, mode, callback) {
921
+ fs.open( path
922
+ , constants.O_WRONLY | constants.O_SYMLINK
923
+ , mode
924
+ , function (err, fd) {
925
+ if (err) {
926
+ if (callback) callback(err)
927
+ return
928
+ }
929
+ // prefer to return the chmod error, if one occurs,
930
+ // but still try to close, and report closing errors if they occur.
931
+ fs.fchmod(fd, mode, function (err) {
932
+ fs.close(fd, function(err2) {
933
+ if (callback) callback(err || err2)
934
+ })
935
+ })
936
+ })
937
+ }
938
+
939
+ fs.lchmodSync = function (path, mode) {
940
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
941
+
942
+ // prefer to return the chmod error, if one occurs,
943
+ // but still try to close, and report closing errors if they occur.
944
+ var threw = true
945
+ var ret
946
+ try {
947
+ ret = fs.fchmodSync(fd, mode)
948
+ threw = false
949
+ } finally {
950
+ if (threw) {
951
+ try {
952
+ fs.closeSync(fd)
953
+ } catch (er) {}
954
+ } else {
955
+ fs.closeSync(fd)
956
+ }
957
+ }
958
+ return ret
959
+ }
960
+ }
961
+
962
+ function patchLutimes (fs) {
963
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
964
+ fs.lutimes = function (path, at, mt, cb) {
965
+ fs.open(path, constants.O_SYMLINK, function (er, fd) {
966
+ if (er) {
967
+ if (cb) cb(er)
968
+ return
969
+ }
970
+ fs.futimes(fd, at, mt, function (er) {
971
+ fs.close(fd, function (er2) {
972
+ if (cb) cb(er || er2)
973
+ })
974
+ })
975
+ })
976
+ }
977
+
978
+ fs.lutimesSync = function (path, at, mt) {
979
+ var fd = fs.openSync(path, constants.O_SYMLINK)
980
+ var ret
981
+ var threw = true
982
+ try {
983
+ ret = fs.futimesSync(fd, at, mt)
984
+ threw = false
985
+ } finally {
986
+ if (threw) {
987
+ try {
988
+ fs.closeSync(fd)
989
+ } catch (er) {}
990
+ } else {
991
+ fs.closeSync(fd)
992
+ }
993
+ }
994
+ return ret
995
+ }
996
+
997
+ } else if (fs.futimes) {
998
+ fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
999
+ fs.lutimesSync = function () {}
1000
+ }
1001
+ }
1002
+
1003
+ function chmodFix (orig) {
1004
+ if (!orig) return orig
1005
+ return function (target, mode, cb) {
1006
+ return orig.call(fs, target, mode, function (er) {
1007
+ if (chownErOk(er)) er = null
1008
+ if (cb) cb.apply(this, arguments)
1009
+ })
1010
+ }
1011
+ }
1012
+
1013
+ function chmodFixSync (orig) {
1014
+ if (!orig) return orig
1015
+ return function (target, mode) {
1016
+ try {
1017
+ return orig.call(fs, target, mode)
1018
+ } catch (er) {
1019
+ if (!chownErOk(er)) throw er
1020
+ }
1021
+ }
1022
+ }
1023
+
1024
+
1025
+ function chownFix (orig) {
1026
+ if (!orig) return orig
1027
+ return function (target, uid, gid, cb) {
1028
+ return orig.call(fs, target, uid, gid, function (er) {
1029
+ if (chownErOk(er)) er = null
1030
+ if (cb) cb.apply(this, arguments)
1031
+ })
1032
+ }
1033
+ }
1034
+
1035
+ function chownFixSync (orig) {
1036
+ if (!orig) return orig
1037
+ return function (target, uid, gid) {
1038
+ try {
1039
+ return orig.call(fs, target, uid, gid)
1040
+ } catch (er) {
1041
+ if (!chownErOk(er)) throw er
1042
+ }
1043
+ }
1044
+ }
1045
+
1046
+ function statFix (orig) {
1047
+ if (!orig) return orig
1048
+ // Older versions of Node erroneously returned signed integers for
1049
+ // uid + gid.
1050
+ return function (target, options, cb) {
1051
+ if (typeof options === 'function') {
1052
+ cb = options
1053
+ options = null
1054
+ }
1055
+ function callback (er, stats) {
1056
+ if (stats) {
1057
+ if (stats.uid < 0) stats.uid += 0x100000000
1058
+ if (stats.gid < 0) stats.gid += 0x100000000
1059
+ }
1060
+ if (cb) cb.apply(this, arguments)
1061
+ }
1062
+ return options ? orig.call(fs, target, options, callback)
1063
+ : orig.call(fs, target, callback)
1064
+ }
1065
+ }
1066
+
1067
+ function statFixSync (orig) {
1068
+ if (!orig) return orig
1069
+ // Older versions of Node erroneously returned signed integers for
1070
+ // uid + gid.
1071
+ return function (target, options) {
1072
+ var stats = options ? orig.call(fs, target, options)
1073
+ : orig.call(fs, target)
1074
+ if (stats) {
1075
+ if (stats.uid < 0) stats.uid += 0x100000000
1076
+ if (stats.gid < 0) stats.gid += 0x100000000
1077
+ }
1078
+ return stats;
1079
+ }
1080
+ }
1081
+
1082
+ // ENOSYS means that the fs doesn't support the op. Just ignore
1083
+ // that, because it doesn't matter.
1084
+ //
1085
+ // if there's no getuid, or if getuid() is something other
1086
+ // than 0, and the error is EINVAL or EPERM, then just ignore
1087
+ // it.
1088
+ //
1089
+ // This specific case is a silent failure in cp, install, tar,
1090
+ // and most other unix tools that manage permissions.
1091
+ //
1092
+ // When running as root, or if other types of errors are
1093
+ // encountered, then it's strict.
1094
+ function chownErOk (er) {
1095
+ if (!er)
1096
+ return true
1097
+
1098
+ if (er.code === "ENOSYS")
1099
+ return true
1100
+
1101
+ var nonroot = !process.getuid || process.getuid() !== 0
1102
+ if (nonroot) {
1103
+ if (er.code === "EINVAL" || er.code === "EPERM")
1104
+ return true
1105
+ }
1106
+
1107
+ return false
1108
+ }
1109
+ }
1110
+
1111
+
1112
+ /***/ }),
1113
+
1114
+ /***/ 40:
1115
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1116
+
1117
+ "use strict";
1118
+ /*
1119
+ MIT License http://www.opensource.org/licenses/mit-license.php
1120
+ Author Tobias Koppers @sokra
1121
+ */
1122
+
1123
+
1124
+ const EventEmitter = (__nccwpck_require__(434).EventEmitter);
1125
+ const fs = __nccwpck_require__(692);
1126
+ const path = __nccwpck_require__(928);
1127
+
1128
+ const watchEventSource = __nccwpck_require__(729);
1129
+
1130
+ const EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({});
1131
+
1132
+ let FS_ACCURACY = 2000;
1133
+
1134
+ const IS_OSX = (__nccwpck_require__(857).platform)() === "darwin";
1135
+ const IS_WIN = (__nccwpck_require__(857).platform)() === "win32";
1136
+
1137
+ const WATCHPACK_POLLING = process.env.WATCHPACK_POLLING;
1138
+ const FORCE_POLLING =
1139
+ `${+WATCHPACK_POLLING}` === WATCHPACK_POLLING
1140
+ ? +WATCHPACK_POLLING
1141
+ : !!WATCHPACK_POLLING && WATCHPACK_POLLING !== "false";
1142
+
1143
+ function withoutCase(str) {
1144
+ return str.toLowerCase();
1145
+ }
1146
+
1147
+ function needCalls(times, callback) {
1148
+ return function() {
1149
+ if (--times === 0) {
1150
+ return callback();
1151
+ }
1152
+ };
1153
+ }
1154
+
1155
+ class Watcher extends EventEmitter {
1156
+ constructor(directoryWatcher, filePath, startTime) {
1157
+ super();
1158
+ this.directoryWatcher = directoryWatcher;
1159
+ this.path = filePath;
1160
+ this.startTime = startTime && +startTime;
1161
+ }
1162
+
1163
+ checkStartTime(mtime, initial) {
1164
+ const startTime = this.startTime;
1165
+ if (typeof startTime !== "number") return !initial;
1166
+ return startTime <= mtime;
1167
+ }
1168
+
1169
+ close() {
1170
+ this.emit("closed");
1171
+ }
1172
+ }
1173
+
1174
+ class DirectoryWatcher extends EventEmitter {
1175
+ constructor(watcherManager, directoryPath, options) {
1176
+ super();
1177
+ if (FORCE_POLLING) {
1178
+ options.poll = FORCE_POLLING;
1179
+ }
1180
+ this.watcherManager = watcherManager;
1181
+ this.options = options;
1182
+ this.path = directoryPath;
1183
+ // safeTime is the point in time after which reading is safe to be unchanged
1184
+ // timestamp is a value that should be compared with another timestamp (mtime)
1185
+ /** @type {Map<string, { safeTime: number, timestamp: number }} */
1186
+ this.files = new Map();
1187
+ /** @type {Map<string, number>} */
1188
+ this.filesWithoutCase = new Map();
1189
+ this.directories = new Map();
1190
+ this.lastWatchEvent = 0;
1191
+ this.initialScan = true;
1192
+ this.ignored = options.ignored || (() => false);
1193
+ this.nestedWatching = false;
1194
+ this.polledWatching =
1195
+ typeof options.poll === "number"
1196
+ ? options.poll
1197
+ : options.poll
1198
+ ? 5007
1199
+ : false;
1200
+ this.timeout = undefined;
1201
+ this.initialScanRemoved = new Set();
1202
+ this.initialScanFinished = undefined;
1203
+ /** @type {Map<string, Set<Watcher>>} */
1204
+ this.watchers = new Map();
1205
+ this.parentWatcher = null;
1206
+ this.refs = 0;
1207
+ this._activeEvents = new Map();
1208
+ this.closed = false;
1209
+ this.scanning = false;
1210
+ this.scanAgain = false;
1211
+ this.scanAgainInitial = false;
1212
+
1213
+ this.createWatcher();
1214
+ this.doScan(true);
1215
+ }
1216
+
1217
+ createWatcher() {
1218
+ try {
1219
+ if (this.polledWatching) {
1220
+ this.watcher = {
1221
+ close: () => {
1222
+ if (this.timeout) {
1223
+ clearTimeout(this.timeout);
1224
+ this.timeout = undefined;
1225
+ }
1226
+ }
1227
+ };
1228
+ } else {
1229
+ if (IS_OSX) {
1230
+ this.watchInParentDirectory();
1231
+ }
1232
+ this.watcher = watchEventSource.watch(this.path);
1233
+ this.watcher.on("change", this.onWatchEvent.bind(this));
1234
+ this.watcher.on("error", this.onWatcherError.bind(this));
1235
+ }
1236
+ } catch (err) {
1237
+ this.onWatcherError(err);
1238
+ }
1239
+ }
1240
+
1241
+ forEachWatcher(path, fn) {
1242
+ const watchers = this.watchers.get(withoutCase(path));
1243
+ if (watchers !== undefined) {
1244
+ for (const w of watchers) {
1245
+ fn(w);
1246
+ }
1247
+ }
1248
+ }
1249
+
1250
+ setMissing(itemPath, initial, type) {
1251
+ if (this.initialScan) {
1252
+ this.initialScanRemoved.add(itemPath);
1253
+ }
1254
+
1255
+ const oldDirectory = this.directories.get(itemPath);
1256
+ if (oldDirectory) {
1257
+ if (this.nestedWatching) oldDirectory.close();
1258
+ this.directories.delete(itemPath);
1259
+
1260
+ this.forEachWatcher(itemPath, w => w.emit("remove", type));
1261
+ if (!initial) {
1262
+ this.forEachWatcher(this.path, w =>
1263
+ w.emit("change", itemPath, null, type, initial)
1264
+ );
1265
+ }
1266
+ }
1267
+
1268
+ const oldFile = this.files.get(itemPath);
1269
+ if (oldFile) {
1270
+ this.files.delete(itemPath);
1271
+ const key = withoutCase(itemPath);
1272
+ const count = this.filesWithoutCase.get(key) - 1;
1273
+ if (count <= 0) {
1274
+ this.filesWithoutCase.delete(key);
1275
+ this.forEachWatcher(itemPath, w => w.emit("remove", type));
1276
+ } else {
1277
+ this.filesWithoutCase.set(key, count);
1278
+ }
1279
+
1280
+ if (!initial) {
1281
+ this.forEachWatcher(this.path, w =>
1282
+ w.emit("change", itemPath, null, type, initial)
1283
+ );
1284
+ }
1285
+ }
1286
+ }
1287
+
1288
+ setFileTime(filePath, mtime, initial, ignoreWhenEqual, type) {
1289
+ const now = Date.now();
1290
+
1291
+ if (this.ignored(filePath)) return;
1292
+
1293
+ const old = this.files.get(filePath);
1294
+
1295
+ let safeTime, accuracy;
1296
+ if (initial) {
1297
+ safeTime = Math.min(now, mtime) + FS_ACCURACY;
1298
+ accuracy = FS_ACCURACY;
1299
+ } else {
1300
+ safeTime = now;
1301
+ accuracy = 0;
1302
+
1303
+ if (old && old.timestamp === mtime && mtime + FS_ACCURACY < now) {
1304
+ // We are sure that mtime is untouched
1305
+ // This can be caused by some file attribute change
1306
+ // e. g. when access time has been changed
1307
+ // but the file content is untouched
1308
+ return;
1309
+ }
1310
+ }
1311
+
1312
+ if (ignoreWhenEqual && old && old.timestamp === mtime) return;
1313
+
1314
+ this.files.set(filePath, {
1315
+ safeTime,
1316
+ accuracy,
1317
+ timestamp: mtime
1318
+ });
1319
+
1320
+ if (!old) {
1321
+ const key = withoutCase(filePath);
1322
+ const count = this.filesWithoutCase.get(key);
1323
+ this.filesWithoutCase.set(key, (count || 0) + 1);
1324
+ if (count !== undefined) {
1325
+ // There is already a file with case-insensitive-equal name
1326
+ // On a case-insensitive filesystem we may miss the renaming
1327
+ // when only casing is changed.
1328
+ // To be sure that our information is correct
1329
+ // we trigger a rescan here
1330
+ this.doScan(false);
1331
+ }
1332
+
1333
+ this.forEachWatcher(filePath, w => {
1334
+ if (!initial || w.checkStartTime(safeTime, initial)) {
1335
+ w.emit("change", mtime, type);
1336
+ }
1337
+ });
1338
+ } else if (!initial) {
1339
+ this.forEachWatcher(filePath, w => w.emit("change", mtime, type));
1340
+ }
1341
+ this.forEachWatcher(this.path, w => {
1342
+ if (!initial || w.checkStartTime(safeTime, initial)) {
1343
+ w.emit("change", filePath, safeTime, type, initial);
1344
+ }
1345
+ });
1346
+ }
1347
+
1348
+ setDirectory(directoryPath, birthtime, initial, type) {
1349
+ if (this.ignored(directoryPath)) return;
1350
+ if (directoryPath === this.path) {
1351
+ if (!initial) {
1352
+ this.forEachWatcher(this.path, w =>
1353
+ w.emit("change", directoryPath, birthtime, type, initial)
1354
+ );
1355
+ }
1356
+ } else {
1357
+ const old = this.directories.get(directoryPath);
1358
+ if (!old) {
1359
+ const now = Date.now();
1360
+
1361
+ if (this.nestedWatching) {
1362
+ this.createNestedWatcher(directoryPath);
1363
+ } else {
1364
+ this.directories.set(directoryPath, true);
1365
+ }
1366
+
1367
+ let safeTime;
1368
+ if (initial) {
1369
+ safeTime = Math.min(now, birthtime) + FS_ACCURACY;
1370
+ } else {
1371
+ safeTime = now;
1372
+ }
1373
+
1374
+ this.forEachWatcher(directoryPath, w => {
1375
+ if (!initial || w.checkStartTime(safeTime, false)) {
1376
+ w.emit("change", birthtime, type);
1377
+ }
1378
+ });
1379
+ this.forEachWatcher(this.path, w => {
1380
+ if (!initial || w.checkStartTime(safeTime, initial)) {
1381
+ w.emit("change", directoryPath, safeTime, type, initial);
1382
+ }
1383
+ });
1384
+ }
1385
+ }
1386
+ }
1387
+
1388
+ createNestedWatcher(directoryPath) {
1389
+ const watcher = this.watcherManager.watchDirectory(directoryPath, 1);
1390
+ watcher.on("change", (filePath, mtime, type, initial) => {
1391
+ this.forEachWatcher(this.path, w => {
1392
+ if (!initial || w.checkStartTime(mtime, initial)) {
1393
+ w.emit("change", filePath, mtime, type, initial);
1394
+ }
1395
+ });
1396
+ });
1397
+ this.directories.set(directoryPath, watcher);
1398
+ }
1399
+
1400
+ setNestedWatching(flag) {
1401
+ if (this.nestedWatching !== !!flag) {
1402
+ this.nestedWatching = !!flag;
1403
+ if (this.nestedWatching) {
1404
+ for (const directory of this.directories.keys()) {
1405
+ this.createNestedWatcher(directory);
1406
+ }
1407
+ } else {
1408
+ for (const [directory, watcher] of this.directories) {
1409
+ watcher.close();
1410
+ this.directories.set(directory, true);
1411
+ }
1412
+ }
1413
+ }
1414
+ }
1415
+
1416
+ watch(filePath, startTime) {
1417
+ const key = withoutCase(filePath);
1418
+ let watchers = this.watchers.get(key);
1419
+ if (watchers === undefined) {
1420
+ watchers = new Set();
1421
+ this.watchers.set(key, watchers);
1422
+ }
1423
+ this.refs++;
1424
+ const watcher = new Watcher(this, filePath, startTime);
1425
+ watcher.on("closed", () => {
1426
+ if (--this.refs <= 0) {
1427
+ this.close();
1428
+ return;
1429
+ }
1430
+ watchers.delete(watcher);
1431
+ if (watchers.size === 0) {
1432
+ this.watchers.delete(key);
1433
+ if (this.path === filePath) this.setNestedWatching(false);
1434
+ }
1435
+ });
1436
+ watchers.add(watcher);
1437
+ let safeTime;
1438
+ if (filePath === this.path) {
1439
+ this.setNestedWatching(true);
1440
+ safeTime = this.lastWatchEvent;
1441
+ for (const entry of this.files.values()) {
1442
+ fixupEntryAccuracy(entry);
1443
+ safeTime = Math.max(safeTime, entry.safeTime);
1444
+ }
1445
+ } else {
1446
+ const entry = this.files.get(filePath);
1447
+ if (entry) {
1448
+ fixupEntryAccuracy(entry);
1449
+ safeTime = entry.safeTime;
1450
+ } else {
1451
+ safeTime = 0;
1452
+ }
1453
+ }
1454
+ if (safeTime) {
1455
+ if (safeTime >= startTime) {
1456
+ process.nextTick(() => {
1457
+ if (this.closed) return;
1458
+ if (filePath === this.path) {
1459
+ watcher.emit(
1460
+ "change",
1461
+ filePath,
1462
+ safeTime,
1463
+ "watch (outdated on attach)",
1464
+ true
1465
+ );
1466
+ } else {
1467
+ watcher.emit(
1468
+ "change",
1469
+ safeTime,
1470
+ "watch (outdated on attach)",
1471
+ true
1472
+ );
1473
+ }
1474
+ });
1475
+ }
1476
+ } else if (this.initialScan) {
1477
+ if (this.initialScanRemoved.has(filePath)) {
1478
+ process.nextTick(() => {
1479
+ if (this.closed) return;
1480
+ watcher.emit("remove");
1481
+ });
1482
+ }
1483
+ } else if (
1484
+ filePath !== this.path &&
1485
+ !this.directories.has(filePath) &&
1486
+ watcher.checkStartTime(this.initialScanFinished, false)
1487
+ ) {
1488
+ process.nextTick(() => {
1489
+ if (this.closed) return;
1490
+ watcher.emit("initial-missing", "watch (missing on attach)");
1491
+ });
1492
+ }
1493
+ return watcher;
1494
+ }
1495
+
1496
+ onWatchEvent(eventType, filename) {
1497
+ if (this.closed) return;
1498
+ if (!filename) {
1499
+ // In some cases no filename is provided
1500
+ // This seem to happen on windows
1501
+ // So some event happened but we don't know which file is affected
1502
+ // We have to do a full scan of the directory
1503
+ this.doScan(false);
1504
+ return;
1505
+ }
1506
+
1507
+ const filePath = path.join(this.path, filename);
1508
+ if (this.ignored(filePath)) return;
1509
+
1510
+ if (this._activeEvents.get(filename) === undefined) {
1511
+ this._activeEvents.set(filename, false);
1512
+ const checkStats = () => {
1513
+ if (this.closed) return;
1514
+ this._activeEvents.set(filename, false);
1515
+ fs.lstat(filePath, (err, stats) => {
1516
+ if (this.closed) return;
1517
+ if (this._activeEvents.get(filename) === true) {
1518
+ process.nextTick(checkStats);
1519
+ return;
1520
+ }
1521
+ this._activeEvents.delete(filename);
1522
+ // ENOENT happens when the file/directory doesn't exist
1523
+ // EPERM happens when the containing directory doesn't exist
1524
+ if (err) {
1525
+ if (
1526
+ err.code !== "ENOENT" &&
1527
+ err.code !== "EPERM" &&
1528
+ err.code !== "EBUSY"
1529
+ ) {
1530
+ this.onStatsError(err);
1531
+ } else {
1532
+ if (filename === path.basename(this.path)) {
1533
+ // This may indicate that the directory itself was removed
1534
+ if (!fs.existsSync(this.path)) {
1535
+ this.onDirectoryRemoved("stat failed");
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+ this.lastWatchEvent = Date.now();
1541
+ if (!stats) {
1542
+ this.setMissing(filePath, false, eventType);
1543
+ } else if (stats.isDirectory()) {
1544
+ this.setDirectory(
1545
+ filePath,
1546
+ +stats.birthtime || 1,
1547
+ false,
1548
+ eventType
1549
+ );
1550
+ } else if (stats.isFile() || stats.isSymbolicLink()) {
1551
+ if (stats.mtime) {
1552
+ ensureFsAccuracy(stats.mtime);
1553
+ }
1554
+ this.setFileTime(
1555
+ filePath,
1556
+ +stats.mtime || +stats.ctime || 1,
1557
+ false,
1558
+ false,
1559
+ eventType
1560
+ );
1561
+ }
1562
+ });
1563
+ };
1564
+ process.nextTick(checkStats);
1565
+ } else {
1566
+ this._activeEvents.set(filename, true);
1567
+ }
1568
+ }
1569
+
1570
+ onWatcherError(err) {
1571
+ if (this.closed) return;
1572
+ if (err) {
1573
+ if (err.code !== "EPERM" && err.code !== "ENOENT") {
1574
+ console.error("Watchpack Error (watcher): " + err);
1575
+ }
1576
+ this.onDirectoryRemoved("watch error");
1577
+ }
1578
+ }
1579
+
1580
+ onStatsError(err) {
1581
+ if (err) {
1582
+ console.error("Watchpack Error (stats): " + err);
1583
+ }
1584
+ }
1585
+
1586
+ onScanError(err) {
1587
+ if (err) {
1588
+ console.error("Watchpack Error (initial scan): " + err);
1589
+ }
1590
+ this.onScanFinished();
1591
+ }
1592
+
1593
+ onScanFinished() {
1594
+ if (this.polledWatching) {
1595
+ this.timeout = setTimeout(() => {
1596
+ if (this.closed) return;
1597
+ this.doScan(false);
1598
+ }, this.polledWatching);
1599
+ }
1600
+ }
1601
+
1602
+ onDirectoryRemoved(reason) {
1603
+ if (this.watcher) {
1604
+ this.watcher.close();
1605
+ this.watcher = null;
1606
+ }
1607
+ this.watchInParentDirectory();
1608
+ const type = `directory-removed (${reason})`;
1609
+ for (const directory of this.directories.keys()) {
1610
+ this.setMissing(directory, null, type);
1611
+ }
1612
+ for (const file of this.files.keys()) {
1613
+ this.setMissing(file, null, type);
1614
+ }
1615
+ }
1616
+
1617
+ watchInParentDirectory() {
1618
+ if (!this.parentWatcher) {
1619
+ const parentDir = path.dirname(this.path);
1620
+ // avoid watching in the root directory
1621
+ // removing directories in the root directory is not supported
1622
+ if (path.dirname(parentDir) === parentDir) return;
1623
+
1624
+ this.parentWatcher = this.watcherManager.watchFile(this.path, 1);
1625
+ this.parentWatcher.on("change", (mtime, type) => {
1626
+ if (this.closed) return;
1627
+
1628
+ // On non-osx platforms we don't need this watcher to detect
1629
+ // directory removal, as an EPERM error indicates that
1630
+ if ((!IS_OSX || this.polledWatching) && this.parentWatcher) {
1631
+ this.parentWatcher.close();
1632
+ this.parentWatcher = null;
1633
+ }
1634
+ // Try to create the watcher when parent directory is found
1635
+ if (!this.watcher) {
1636
+ this.createWatcher();
1637
+ this.doScan(false);
1638
+
1639
+ // directory was created so we emit an event
1640
+ this.forEachWatcher(this.path, w =>
1641
+ w.emit("change", this.path, mtime, type, false)
1642
+ );
1643
+ }
1644
+ });
1645
+ this.parentWatcher.on("remove", () => {
1646
+ this.onDirectoryRemoved("parent directory removed");
1647
+ });
1648
+ }
1649
+ }
1650
+
1651
+ doScan(initial) {
1652
+ if (this.scanning) {
1653
+ if (this.scanAgain) {
1654
+ if (!initial) this.scanAgainInitial = false;
1655
+ } else {
1656
+ this.scanAgain = true;
1657
+ this.scanAgainInitial = initial;
1658
+ }
1659
+ return;
1660
+ }
1661
+ this.scanning = true;
1662
+ if (this.timeout) {
1663
+ clearTimeout(this.timeout);
1664
+ this.timeout = undefined;
1665
+ }
1666
+ process.nextTick(() => {
1667
+ if (this.closed) return;
1668
+ fs.readdir(this.path, (err, items) => {
1669
+ if (this.closed) return;
1670
+ if (err) {
1671
+ if (err.code === "ENOENT" || err.code === "EPERM") {
1672
+ this.onDirectoryRemoved("scan readdir failed");
1673
+ } else {
1674
+ this.onScanError(err);
1675
+ }
1676
+ this.initialScan = false;
1677
+ this.initialScanFinished = Date.now();
1678
+ if (initial) {
1679
+ for (const watchers of this.watchers.values()) {
1680
+ for (const watcher of watchers) {
1681
+ if (watcher.checkStartTime(this.initialScanFinished, false)) {
1682
+ watcher.emit(
1683
+ "initial-missing",
1684
+ "scan (parent directory missing in initial scan)"
1685
+ );
1686
+ }
1687
+ }
1688
+ }
1689
+ }
1690
+ if (this.scanAgain) {
1691
+ this.scanAgain = false;
1692
+ this.doScan(this.scanAgainInitial);
1693
+ } else {
1694
+ this.scanning = false;
1695
+ }
1696
+ return;
1697
+ }
1698
+ const itemPaths = new Set(
1699
+ items.map(item => path.join(this.path, item.normalize("NFC")))
1700
+ );
1701
+ for (const file of this.files.keys()) {
1702
+ if (!itemPaths.has(file)) {
1703
+ this.setMissing(file, initial, "scan (missing)");
1704
+ }
1705
+ }
1706
+ for (const directory of this.directories.keys()) {
1707
+ if (!itemPaths.has(directory)) {
1708
+ this.setMissing(directory, initial, "scan (missing)");
1709
+ }
1710
+ }
1711
+ if (this.scanAgain) {
1712
+ // Early repeat of scan
1713
+ this.scanAgain = false;
1714
+ this.doScan(initial);
1715
+ return;
1716
+ }
1717
+ const itemFinished = needCalls(itemPaths.size + 1, () => {
1718
+ if (this.closed) return;
1719
+ this.initialScan = false;
1720
+ this.initialScanRemoved = null;
1721
+ this.initialScanFinished = Date.now();
1722
+ if (initial) {
1723
+ const missingWatchers = new Map(this.watchers);
1724
+ missingWatchers.delete(withoutCase(this.path));
1725
+ for (const item of itemPaths) {
1726
+ missingWatchers.delete(withoutCase(item));
1727
+ }
1728
+ for (const watchers of missingWatchers.values()) {
1729
+ for (const watcher of watchers) {
1730
+ if (watcher.checkStartTime(this.initialScanFinished, false)) {
1731
+ watcher.emit(
1732
+ "initial-missing",
1733
+ "scan (missing in initial scan)"
1734
+ );
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ if (this.scanAgain) {
1740
+ this.scanAgain = false;
1741
+ this.doScan(this.scanAgainInitial);
1742
+ } else {
1743
+ this.scanning = false;
1744
+ this.onScanFinished();
1745
+ }
1746
+ });
1747
+ for (const itemPath of itemPaths) {
1748
+ fs.lstat(itemPath, (err2, stats) => {
1749
+ if (this.closed) return;
1750
+ if (err2) {
1751
+ if (
1752
+ err2.code === "ENOENT" ||
1753
+ err2.code === "EPERM" ||
1754
+ err2.code === "EACCES" ||
1755
+ err2.code === "EBUSY" ||
1756
+ // TODO https://github.com/libuv/libuv/pull/4566
1757
+ (err2.code === "EINVAL" && IS_WIN)
1758
+ ) {
1759
+ this.setMissing(itemPath, initial, "scan (" + err2.code + ")");
1760
+ } else {
1761
+ this.onScanError(err2);
1762
+ }
1763
+ itemFinished();
1764
+ return;
1765
+ }
1766
+ if (stats.isFile() || stats.isSymbolicLink()) {
1767
+ if (stats.mtime) {
1768
+ ensureFsAccuracy(stats.mtime);
1769
+ }
1770
+ this.setFileTime(
1771
+ itemPath,
1772
+ +stats.mtime || +stats.ctime || 1,
1773
+ initial,
1774
+ true,
1775
+ "scan (file)"
1776
+ );
1777
+ } else if (stats.isDirectory()) {
1778
+ if (!initial || !this.directories.has(itemPath))
1779
+ this.setDirectory(
1780
+ itemPath,
1781
+ +stats.birthtime || 1,
1782
+ initial,
1783
+ "scan (dir)"
1784
+ );
1785
+ }
1786
+ itemFinished();
1787
+ });
1788
+ }
1789
+ itemFinished();
1790
+ });
1791
+ });
1792
+ }
1793
+
1794
+ getTimes() {
1795
+ const obj = Object.create(null);
1796
+ let safeTime = this.lastWatchEvent;
1797
+ for (const [file, entry] of this.files) {
1798
+ fixupEntryAccuracy(entry);
1799
+ safeTime = Math.max(safeTime, entry.safeTime);
1800
+ obj[file] = Math.max(entry.safeTime, entry.timestamp);
1801
+ }
1802
+ if (this.nestedWatching) {
1803
+ for (const w of this.directories.values()) {
1804
+ const times = w.directoryWatcher.getTimes();
1805
+ for (const file of Object.keys(times)) {
1806
+ const time = times[file];
1807
+ safeTime = Math.max(safeTime, time);
1808
+ obj[file] = time;
1809
+ }
1810
+ }
1811
+ obj[this.path] = safeTime;
1812
+ }
1813
+ if (!this.initialScan) {
1814
+ for (const watchers of this.watchers.values()) {
1815
+ for (const watcher of watchers) {
1816
+ const path = watcher.path;
1817
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) {
1818
+ obj[path] = null;
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ return obj;
1824
+ }
1825
+
1826
+ collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
1827
+ let safeTime = this.lastWatchEvent;
1828
+ for (const [file, entry] of this.files) {
1829
+ fixupEntryAccuracy(entry);
1830
+ safeTime = Math.max(safeTime, entry.safeTime);
1831
+ fileTimestamps.set(file, entry);
1832
+ }
1833
+ if (this.nestedWatching) {
1834
+ for (const w of this.directories.values()) {
1835
+ safeTime = Math.max(
1836
+ safeTime,
1837
+ w.directoryWatcher.collectTimeInfoEntries(
1838
+ fileTimestamps,
1839
+ directoryTimestamps
1840
+ )
1841
+ );
1842
+ }
1843
+ fileTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
1844
+ directoryTimestamps.set(this.path, {
1845
+ safeTime
1846
+ });
1847
+ } else {
1848
+ for (const dir of this.directories.keys()) {
1849
+ // No additional info about this directory
1850
+ // but maybe another DirectoryWatcher has info
1851
+ fileTimestamps.set(dir, EXISTANCE_ONLY_TIME_ENTRY);
1852
+ if (!directoryTimestamps.has(dir))
1853
+ directoryTimestamps.set(dir, EXISTANCE_ONLY_TIME_ENTRY);
1854
+ }
1855
+ fileTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
1856
+ directoryTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
1857
+ }
1858
+ if (!this.initialScan) {
1859
+ for (const watchers of this.watchers.values()) {
1860
+ for (const watcher of watchers) {
1861
+ const path = watcher.path;
1862
+ if (!fileTimestamps.has(path)) {
1863
+ fileTimestamps.set(path, null);
1864
+ }
1865
+ }
1866
+ }
1867
+ }
1868
+ return safeTime;
1869
+ }
1870
+
1871
+ close() {
1872
+ this.closed = true;
1873
+ this.initialScan = false;
1874
+ if (this.watcher) {
1875
+ this.watcher.close();
1876
+ this.watcher = null;
1877
+ }
1878
+ if (this.nestedWatching) {
1879
+ for (const w of this.directories.values()) {
1880
+ w.close();
1881
+ }
1882
+ this.directories.clear();
1883
+ }
1884
+ if (this.parentWatcher) {
1885
+ this.parentWatcher.close();
1886
+ this.parentWatcher = null;
1887
+ }
1888
+ this.emit("closed");
1889
+ }
1890
+ }
1891
+
1892
+ module.exports = DirectoryWatcher;
1893
+ module.exports.EXISTANCE_ONLY_TIME_ENTRY = EXISTANCE_ONLY_TIME_ENTRY;
1894
+
1895
+ function fixupEntryAccuracy(entry) {
1896
+ if (entry.accuracy > FS_ACCURACY) {
1897
+ entry.safeTime = entry.safeTime - entry.accuracy + FS_ACCURACY;
1898
+ entry.accuracy = FS_ACCURACY;
1899
+ }
1900
+ }
1901
+
1902
+ function ensureFsAccuracy(mtime) {
1903
+ if (!mtime) return;
1904
+ if (FS_ACCURACY > 1 && mtime % 1 !== 0) FS_ACCURACY = 1;
1905
+ else if (FS_ACCURACY > 10 && mtime % 10 !== 0) FS_ACCURACY = 10;
1906
+ else if (FS_ACCURACY > 100 && mtime % 100 !== 0) FS_ACCURACY = 100;
1907
+ else if (FS_ACCURACY > 1000 && mtime % 1000 !== 0) FS_ACCURACY = 1000;
1908
+ }
1909
+
1910
+
1911
+ /***/ }),
1912
+
1913
+ /***/ 751:
1914
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1915
+
1916
+ "use strict";
1917
+ /*
1918
+ MIT License http://www.opensource.org/licenses/mit-license.php
1919
+ Author Tobias Koppers @sokra
1920
+ */
1921
+
1922
+
1923
+ const fs = __nccwpck_require__(896);
1924
+ const path = __nccwpck_require__(928);
1925
+
1926
+ // macOS, Linux, and Windows all rely on these errors
1927
+ const EXPECTED_ERRORS = new Set(["EINVAL", "ENOENT"]);
1928
+
1929
+ // On Windows there is also this error in some cases
1930
+ if (process.platform === "win32") EXPECTED_ERRORS.add("UNKNOWN");
1931
+
1932
+ class LinkResolver {
1933
+ constructor() {
1934
+ this.cache = new Map();
1935
+ }
1936
+
1937
+ /**
1938
+ * @param {string} file path to file or directory
1939
+ * @returns {string[]} array of file and all symlinks contributed in the resolving process (first item is the resolved file)
1940
+ */
1941
+ resolve(file) {
1942
+ const cacheEntry = this.cache.get(file);
1943
+ if (cacheEntry !== undefined) {
1944
+ return cacheEntry;
1945
+ }
1946
+ const parent = path.dirname(file);
1947
+ if (parent === file) {
1948
+ // At root of filesystem there can't be a link
1949
+ const result = Object.freeze([file]);
1950
+ this.cache.set(file, result);
1951
+ return result;
1952
+ }
1953
+ // resolve the parent directory to find links there and get the real path
1954
+ const parentResolved = this.resolve(parent);
1955
+ let realFile = file;
1956
+
1957
+ // is the parent directory really somewhere else?
1958
+ if (parentResolved[0] !== parent) {
1959
+ // get the real location of file
1960
+ const basename = path.basename(file);
1961
+ realFile = path.resolve(parentResolved[0], basename);
1962
+ }
1963
+ // try to read the link content
1964
+ try {
1965
+ const linkContent = fs.readlinkSync(realFile);
1966
+
1967
+ // resolve the link content relative to the parent directory
1968
+ const resolvedLink = path.resolve(parentResolved[0], linkContent);
1969
+
1970
+ // recursive resolve the link content for more links in the structure
1971
+ const linkResolved = this.resolve(resolvedLink);
1972
+
1973
+ // merge parent and link resolve results
1974
+ let result;
1975
+ if (linkResolved.length > 1 && parentResolved.length > 1) {
1976
+ // when both contain links we need to duplicate them with a Set
1977
+ const resultSet = new Set(linkResolved);
1978
+ // add the link
1979
+ resultSet.add(realFile);
1980
+ // add all symlinks of the parent
1981
+ for (let i = 1; i < parentResolved.length; i++) {
1982
+ resultSet.add(parentResolved[i]);
1983
+ }
1984
+ result = Object.freeze(Array.from(resultSet));
1985
+ } else if (parentResolved.length > 1) {
1986
+ // we have links in the parent but not for the link content location
1987
+ result = parentResolved.slice();
1988
+ result[0] = linkResolved[0];
1989
+ // add the link
1990
+ result.push(realFile);
1991
+ Object.freeze(result);
1992
+ } else if (linkResolved.length > 1) {
1993
+ // we can return the link content location result
1994
+ result = linkResolved.slice();
1995
+ // add the link
1996
+ result.push(realFile);
1997
+ Object.freeze(result);
1998
+ } else {
1999
+ // neither link content location nor parent have links
2000
+ // this link is the only link here
2001
+ result = Object.freeze([
2002
+ // the resolve real location
2003
+ linkResolved[0],
2004
+ // add the link
2005
+ realFile
2006
+ ]);
2007
+ }
2008
+ this.cache.set(file, result);
2009
+ return result;
2010
+ } catch (e) {
2011
+ if (!EXPECTED_ERRORS.has(e.code)) {
2012
+ throw e;
2013
+ }
2014
+ // no link
2015
+ const result = parentResolved.slice();
2016
+ result[0] = realFile;
2017
+ Object.freeze(result);
2018
+ this.cache.set(file, result);
2019
+ return result;
2020
+ }
2021
+ }
2022
+ }
2023
+ module.exports = LinkResolver;
2024
+
2025
+
2026
+ /***/ }),
2027
+
2028
+ /***/ 510:
2029
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2030
+
2031
+ "use strict";
2032
+ /*
2033
+ MIT License http://www.opensource.org/licenses/mit-license.php
2034
+ Author Tobias Koppers @sokra
2035
+ */
2036
+
2037
+
2038
+ const path = __nccwpck_require__(928);
2039
+ const DirectoryWatcher = __nccwpck_require__(40);
2040
+
2041
+ class WatcherManager {
2042
+ constructor(options) {
2043
+ this.options = options;
2044
+ this.directoryWatchers = new Map();
2045
+ }
2046
+
2047
+ getDirectoryWatcher(directory) {
2048
+ const watcher = this.directoryWatchers.get(directory);
2049
+ if (watcher === undefined) {
2050
+ const newWatcher = new DirectoryWatcher(this, directory, this.options);
2051
+ this.directoryWatchers.set(directory, newWatcher);
2052
+ newWatcher.on("closed", () => {
2053
+ this.directoryWatchers.delete(directory);
2054
+ });
2055
+ return newWatcher;
2056
+ }
2057
+ return watcher;
2058
+ }
2059
+
2060
+ watchFile(p, startTime) {
2061
+ const directory = path.dirname(p);
2062
+ if (directory === p) return null;
2063
+ return this.getDirectoryWatcher(directory).watch(p, startTime);
2064
+ }
2065
+
2066
+ watchDirectory(directory, startTime) {
2067
+ return this.getDirectoryWatcher(directory).watch(directory, startTime);
2068
+ }
2069
+ }
2070
+
2071
+ const watcherManagers = new WeakMap();
2072
+ /**
2073
+ * @param {object} options options
2074
+ * @returns {WatcherManager} the watcher manager
2075
+ */
2076
+ module.exports = options => {
2077
+ const watcherManager = watcherManagers.get(options);
2078
+ if (watcherManager !== undefined) return watcherManager;
2079
+ const newWatcherManager = new WatcherManager(options);
2080
+ watcherManagers.set(options, newWatcherManager);
2081
+ return newWatcherManager;
2082
+ };
2083
+ module.exports.WatcherManager = WatcherManager;
2084
+
2085
+
2086
+ /***/ }),
2087
+
2088
+ /***/ 864:
2089
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2090
+
2091
+ "use strict";
2092
+ /*
2093
+ MIT License http://www.opensource.org/licenses/mit-license.php
2094
+ Author Tobias Koppers @sokra
2095
+ */
2096
+
2097
+
2098
+ const path = __nccwpck_require__(928);
2099
+
2100
+ /**
2101
+ * @template T
2102
+ * @typedef {Object} TreeNode
2103
+ * @property {string} filePath
2104
+ * @property {TreeNode} parent
2105
+ * @property {TreeNode[]} children
2106
+ * @property {number} entries
2107
+ * @property {boolean} active
2108
+ * @property {T[] | T | undefined} value
2109
+ */
2110
+
2111
+ /**
2112
+ * @template T
2113
+ * @param {Map<string, T[] | T} plan
2114
+ * @param {number} limit
2115
+ * @returns {Map<string, Map<T, string>>} the new plan
2116
+ */
2117
+ module.exports = (plan, limit) => {
2118
+ const treeMap = new Map();
2119
+ // Convert to tree
2120
+ for (const [filePath, value] of plan) {
2121
+ treeMap.set(filePath, {
2122
+ filePath,
2123
+ parent: undefined,
2124
+ children: undefined,
2125
+ entries: 1,
2126
+ active: true,
2127
+ value
2128
+ });
2129
+ }
2130
+ let currentCount = treeMap.size;
2131
+ // Create parents and calculate sum of entries
2132
+ for (const node of treeMap.values()) {
2133
+ const parentPath = path.dirname(node.filePath);
2134
+ if (parentPath !== node.filePath) {
2135
+ let parent = treeMap.get(parentPath);
2136
+ if (parent === undefined) {
2137
+ parent = {
2138
+ filePath: parentPath,
2139
+ parent: undefined,
2140
+ children: [node],
2141
+ entries: node.entries,
2142
+ active: false,
2143
+ value: undefined
2144
+ };
2145
+ treeMap.set(parentPath, parent);
2146
+ node.parent = parent;
2147
+ } else {
2148
+ node.parent = parent;
2149
+ if (parent.children === undefined) {
2150
+ parent.children = [node];
2151
+ } else {
2152
+ parent.children.push(node);
2153
+ }
2154
+ do {
2155
+ parent.entries += node.entries;
2156
+ parent = parent.parent;
2157
+ } while (parent);
2158
+ }
2159
+ }
2160
+ }
2161
+ // Reduce until limit reached
2162
+ while (currentCount > limit) {
2163
+ // Select node that helps reaching the limit most effectively without overmerging
2164
+ const overLimit = currentCount - limit;
2165
+ let bestNode = undefined;
2166
+ let bestCost = Infinity;
2167
+ for (const node of treeMap.values()) {
2168
+ if (node.entries <= 1 || !node.children || !node.parent) continue;
2169
+ if (node.children.length === 0) continue;
2170
+ if (node.children.length === 1 && !node.value) continue;
2171
+ // Try to select the node with has just a bit more entries than we need to reduce
2172
+ // When just a bit more is over 30% over the limit,
2173
+ // also consider just a bit less entries then we need to reduce
2174
+ const cost =
2175
+ node.entries - 1 >= overLimit
2176
+ ? node.entries - 1 - overLimit
2177
+ : overLimit - node.entries + 1 + limit * 0.3;
2178
+ if (cost < bestCost) {
2179
+ bestNode = node;
2180
+ bestCost = cost;
2181
+ }
2182
+ }
2183
+ if (!bestNode) break;
2184
+ // Merge all children
2185
+ const reduction = bestNode.entries - 1;
2186
+ bestNode.active = true;
2187
+ bestNode.entries = 1;
2188
+ currentCount -= reduction;
2189
+ let parent = bestNode.parent;
2190
+ while (parent) {
2191
+ parent.entries -= reduction;
2192
+ parent = parent.parent;
2193
+ }
2194
+ const queue = new Set(bestNode.children);
2195
+ for (const node of queue) {
2196
+ node.active = false;
2197
+ node.entries = 0;
2198
+ if (node.children) {
2199
+ for (const child of node.children) queue.add(child);
2200
+ }
2201
+ }
2202
+ }
2203
+ // Write down new plan
2204
+ const newPlan = new Map();
2205
+ for (const rootNode of treeMap.values()) {
2206
+ if (!rootNode.active) continue;
2207
+ const map = new Map();
2208
+ const queue = new Set([rootNode]);
2209
+ for (const node of queue) {
2210
+ if (node.active && node !== rootNode) continue;
2211
+ if (node.value) {
2212
+ if (Array.isArray(node.value)) {
2213
+ for (const item of node.value) {
2214
+ map.set(item, node.filePath);
2215
+ }
2216
+ } else {
2217
+ map.set(node.value, node.filePath);
2218
+ }
2219
+ }
2220
+ if (node.children) {
2221
+ for (const child of node.children) {
2222
+ queue.add(child);
2223
+ }
2224
+ }
2225
+ }
2226
+ newPlan.set(rootNode.filePath, map);
2227
+ }
2228
+ return newPlan;
2229
+ };
2230
+
2231
+
2232
+ /***/ }),
2233
+
2234
+ /***/ 729:
2235
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2236
+
2237
+ "use strict";
2238
+ /*
2239
+ MIT License http://www.opensource.org/licenses/mit-license.php
2240
+ Author Tobias Koppers @sokra
2241
+ */
2242
+
2243
+
2244
+ const fs = __nccwpck_require__(896);
2245
+ const path = __nccwpck_require__(928);
2246
+ const { EventEmitter } = __nccwpck_require__(434);
2247
+ const reducePlan = __nccwpck_require__(864);
2248
+
2249
+ const IS_OSX = (__nccwpck_require__(857).platform)() === "darwin";
2250
+ const IS_WIN = (__nccwpck_require__(857).platform)() === "win32";
2251
+ const SUPPORTS_RECURSIVE_WATCHING = IS_OSX || IS_WIN;
2252
+
2253
+ // Use 20 for OSX to make `FSWatcher.close` faster
2254
+ // https://github.com/nodejs/node/issues/29949
2255
+ const watcherLimit =
2256
+ +process.env.WATCHPACK_WATCHER_LIMIT || (IS_OSX ? 20 : 10000);
2257
+
2258
+ const recursiveWatcherLogging = !!process.env
2259
+ .WATCHPACK_RECURSIVE_WATCHER_LOGGING;
2260
+
2261
+ let isBatch = false;
2262
+ let watcherCount = 0;
2263
+
2264
+ /** @type {Map<Watcher, string>} */
2265
+ const pendingWatchers = new Map();
2266
+
2267
+ /** @type {Map<string, RecursiveWatcher>} */
2268
+ const recursiveWatchers = new Map();
2269
+
2270
+ /** @type {Map<string, DirectWatcher>} */
2271
+ const directWatchers = new Map();
2272
+
2273
+ /** @type {Map<Watcher, RecursiveWatcher | DirectWatcher>} */
2274
+ const underlyingWatcher = new Map();
2275
+
2276
+ function createEPERMError(filePath) {
2277
+ const error = new Error(`Operation not permitted: ${filePath}`);
2278
+ error.code = "EPERM";
2279
+ return error;
2280
+ }
2281
+
2282
+ function createHandleChangeEvent(watcher, filePath, handleChangeEvent) {
2283
+ return (type, filename) => {
2284
+ // TODO: After Node.js v22, fs.watch(dir) and deleting a dir will trigger the rename change event.
2285
+ // Here we just ignore it and keep the same behavior as before v22
2286
+ // https://github.com/libuv/libuv/pull/4376
2287
+ if (
2288
+ type === "rename" &&
2289
+ path.isAbsolute(filename) &&
2290
+ path.basename(filename) === path.basename(filePath)
2291
+ ) {
2292
+ if (!IS_OSX) {
2293
+ // Before v22, windows will throw EPERM error
2294
+ watcher.emit("error", createEPERMError(filename));
2295
+ }
2296
+ // Before v22, macos nothing to do
2297
+ return;
2298
+ }
2299
+ handleChangeEvent(type, filename);
2300
+ };
2301
+ }
2302
+
2303
+ class DirectWatcher {
2304
+ constructor(filePath) {
2305
+ this.filePath = filePath;
2306
+ this.watchers = new Set();
2307
+ this.watcher = undefined;
2308
+ try {
2309
+ const watcher = fs.watch(filePath);
2310
+
2311
+ this.watcher = watcher;
2312
+ const handleChangeEvent = createHandleChangeEvent(
2313
+ watcher,
2314
+ filePath,
2315
+ (type, filename) => {
2316
+ for (const w of this.watchers) {
2317
+ w.emit("change", type, filename);
2318
+ }
2319
+ }
2320
+ );
2321
+ watcher.on("change", handleChangeEvent);
2322
+ watcher.on("error", error => {
2323
+ for (const w of this.watchers) {
2324
+ w.emit("error", error);
2325
+ }
2326
+ });
2327
+ } catch (err) {
2328
+ process.nextTick(() => {
2329
+ for (const w of this.watchers) {
2330
+ w.emit("error", err);
2331
+ }
2332
+ });
2333
+ }
2334
+ watcherCount++;
2335
+ }
2336
+
2337
+ add(watcher) {
2338
+ underlyingWatcher.set(watcher, this);
2339
+ this.watchers.add(watcher);
2340
+ }
2341
+
2342
+ remove(watcher) {
2343
+ this.watchers.delete(watcher);
2344
+ if (this.watchers.size === 0) {
2345
+ directWatchers.delete(this.filePath);
2346
+ watcherCount--;
2347
+ if (this.watcher) this.watcher.close();
2348
+ }
2349
+ }
2350
+
2351
+ getWatchers() {
2352
+ return this.watchers;
2353
+ }
2354
+ }
2355
+
2356
+ class RecursiveWatcher {
2357
+ constructor(rootPath) {
2358
+ this.rootPath = rootPath;
2359
+ /** @type {Map<Watcher, string>} */
2360
+ this.mapWatcherToPath = new Map();
2361
+ /** @type {Map<string, Set<Watcher>>} */
2362
+ this.mapPathToWatchers = new Map();
2363
+ this.watcher = undefined;
2364
+ try {
2365
+ const watcher = fs.watch(rootPath, {
2366
+ recursive: true
2367
+ });
2368
+ this.watcher = watcher;
2369
+ watcher.on("change", (type, filename) => {
2370
+ if (!filename) {
2371
+ if (recursiveWatcherLogging) {
2372
+ process.stderr.write(
2373
+ `[watchpack] dispatch ${type} event in recursive watcher (${this.rootPath}) to all watchers\n`
2374
+ );
2375
+ }
2376
+ for (const w of this.mapWatcherToPath.keys()) {
2377
+ w.emit("change", type);
2378
+ }
2379
+ } else {
2380
+ const dir = path.dirname(filename);
2381
+ const watchers = this.mapPathToWatchers.get(dir);
2382
+ if (recursiveWatcherLogging) {
2383
+ process.stderr.write(
2384
+ `[watchpack] dispatch ${type} event in recursive watcher (${
2385
+ this.rootPath
2386
+ }) for '${filename}' to ${
2387
+ watchers ? watchers.size : 0
2388
+ } watchers\n`
2389
+ );
2390
+ }
2391
+ if (watchers === undefined) return;
2392
+ for (const w of watchers) {
2393
+ w.emit("change", type, path.basename(filename));
2394
+ }
2395
+ }
2396
+ });
2397
+ watcher.on("error", error => {
2398
+ for (const w of this.mapWatcherToPath.keys()) {
2399
+ w.emit("error", error);
2400
+ }
2401
+ });
2402
+ } catch (err) {
2403
+ process.nextTick(() => {
2404
+ for (const w of this.mapWatcherToPath.keys()) {
2405
+ w.emit("error", err);
2406
+ }
2407
+ });
2408
+ }
2409
+ watcherCount++;
2410
+ if (recursiveWatcherLogging) {
2411
+ process.stderr.write(
2412
+ `[watchpack] created recursive watcher at ${rootPath}\n`
2413
+ );
2414
+ }
2415
+ }
2416
+
2417
+ add(filePath, watcher) {
2418
+ underlyingWatcher.set(watcher, this);
2419
+ const subpath = filePath.slice(this.rootPath.length + 1) || ".";
2420
+ this.mapWatcherToPath.set(watcher, subpath);
2421
+ const set = this.mapPathToWatchers.get(subpath);
2422
+ if (set === undefined) {
2423
+ const newSet = new Set();
2424
+ newSet.add(watcher);
2425
+ this.mapPathToWatchers.set(subpath, newSet);
2426
+ } else {
2427
+ set.add(watcher);
2428
+ }
2429
+ }
2430
+
2431
+ remove(watcher) {
2432
+ const subpath = this.mapWatcherToPath.get(watcher);
2433
+ if (!subpath) return;
2434
+ this.mapWatcherToPath.delete(watcher);
2435
+ const set = this.mapPathToWatchers.get(subpath);
2436
+ set.delete(watcher);
2437
+ if (set.size === 0) {
2438
+ this.mapPathToWatchers.delete(subpath);
2439
+ }
2440
+ if (this.mapWatcherToPath.size === 0) {
2441
+ recursiveWatchers.delete(this.rootPath);
2442
+ watcherCount--;
2443
+ if (this.watcher) this.watcher.close();
2444
+ if (recursiveWatcherLogging) {
2445
+ process.stderr.write(
2446
+ `[watchpack] closed recursive watcher at ${this.rootPath}\n`
2447
+ );
2448
+ }
2449
+ }
2450
+ }
2451
+
2452
+ getWatchers() {
2453
+ return this.mapWatcherToPath;
2454
+ }
2455
+ }
2456
+
2457
+ class Watcher extends EventEmitter {
2458
+ close() {
2459
+ if (pendingWatchers.has(this)) {
2460
+ pendingWatchers.delete(this);
2461
+ return;
2462
+ }
2463
+ const watcher = underlyingWatcher.get(this);
2464
+ watcher.remove(this);
2465
+ underlyingWatcher.delete(this);
2466
+ }
2467
+ }
2468
+
2469
+ const createDirectWatcher = filePath => {
2470
+ const existing = directWatchers.get(filePath);
2471
+ if (existing !== undefined) return existing;
2472
+ const w = new DirectWatcher(filePath);
2473
+ directWatchers.set(filePath, w);
2474
+ return w;
2475
+ };
2476
+
2477
+ const createRecursiveWatcher = rootPath => {
2478
+ const existing = recursiveWatchers.get(rootPath);
2479
+ if (existing !== undefined) return existing;
2480
+ const w = new RecursiveWatcher(rootPath);
2481
+ recursiveWatchers.set(rootPath, w);
2482
+ return w;
2483
+ };
2484
+
2485
+ const execute = () => {
2486
+ /** @type {Map<string, Watcher[] | Watcher>} */
2487
+ const map = new Map();
2488
+ const addWatcher = (watcher, filePath) => {
2489
+ const entry = map.get(filePath);
2490
+ if (entry === undefined) {
2491
+ map.set(filePath, watcher);
2492
+ } else if (Array.isArray(entry)) {
2493
+ entry.push(watcher);
2494
+ } else {
2495
+ map.set(filePath, [entry, watcher]);
2496
+ }
2497
+ };
2498
+ for (const [watcher, filePath] of pendingWatchers) {
2499
+ addWatcher(watcher, filePath);
2500
+ }
2501
+ pendingWatchers.clear();
2502
+
2503
+ // Fast case when we are not reaching the limit
2504
+ if (!SUPPORTS_RECURSIVE_WATCHING || watcherLimit - watcherCount >= map.size) {
2505
+ // Create watchers for all entries in the map
2506
+ for (const [filePath, entry] of map) {
2507
+ const w = createDirectWatcher(filePath);
2508
+ if (Array.isArray(entry)) {
2509
+ for (const item of entry) w.add(item);
2510
+ } else {
2511
+ w.add(entry);
2512
+ }
2513
+ }
2514
+ return;
2515
+ }
2516
+
2517
+ // Reconsider existing watchers to improving watch plan
2518
+ for (const watcher of recursiveWatchers.values()) {
2519
+ for (const [w, subpath] of watcher.getWatchers()) {
2520
+ addWatcher(w, path.join(watcher.rootPath, subpath));
2521
+ }
2522
+ }
2523
+ for (const watcher of directWatchers.values()) {
2524
+ for (const w of watcher.getWatchers()) {
2525
+ addWatcher(w, watcher.filePath);
2526
+ }
2527
+ }
2528
+
2529
+ // Merge map entries to keep watcher limit
2530
+ // Create a 10% buffer to be able to enter fast case more often
2531
+ const plan = reducePlan(map, watcherLimit * 0.9);
2532
+
2533
+ // Update watchers for all entries in the map
2534
+ for (const [filePath, entry] of plan) {
2535
+ if (entry.size === 1) {
2536
+ for (const [watcher, filePath] of entry) {
2537
+ const w = createDirectWatcher(filePath);
2538
+ const old = underlyingWatcher.get(watcher);
2539
+ if (old === w) continue;
2540
+ w.add(watcher);
2541
+ if (old !== undefined) old.remove(watcher);
2542
+ }
2543
+ } else {
2544
+ const filePaths = new Set(entry.values());
2545
+ if (filePaths.size > 1) {
2546
+ const w = createRecursiveWatcher(filePath);
2547
+ for (const [watcher, watcherPath] of entry) {
2548
+ const old = underlyingWatcher.get(watcher);
2549
+ if (old === w) continue;
2550
+ w.add(watcherPath, watcher);
2551
+ if (old !== undefined) old.remove(watcher);
2552
+ }
2553
+ } else {
2554
+ for (const filePath of filePaths) {
2555
+ const w = createDirectWatcher(filePath);
2556
+ for (const watcher of entry.keys()) {
2557
+ const old = underlyingWatcher.get(watcher);
2558
+ if (old === w) continue;
2559
+ w.add(watcher);
2560
+ if (old !== undefined) old.remove(watcher);
2561
+ }
2562
+ }
2563
+ }
2564
+ }
2565
+ }
2566
+ };
2567
+
2568
+ exports.watch = filePath => {
2569
+ const watcher = new Watcher();
2570
+ // Find an existing watcher
2571
+ const directWatcher = directWatchers.get(filePath);
2572
+ if (directWatcher !== undefined) {
2573
+ directWatcher.add(watcher);
2574
+ return watcher;
2575
+ }
2576
+ let current = filePath;
2577
+ for (;;) {
2578
+ const recursiveWatcher = recursiveWatchers.get(current);
2579
+ if (recursiveWatcher !== undefined) {
2580
+ recursiveWatcher.add(filePath, watcher);
2581
+ return watcher;
2582
+ }
2583
+ const parent = path.dirname(current);
2584
+ if (parent === current) break;
2585
+ current = parent;
2586
+ }
2587
+ // Queue up watcher for creation
2588
+ pendingWatchers.set(watcher, filePath);
2589
+ if (!isBatch) execute();
2590
+ return watcher;
2591
+ };
2592
+
2593
+ exports.batch = fn => {
2594
+ isBatch = true;
2595
+ try {
2596
+ fn();
2597
+ } finally {
2598
+ isBatch = false;
2599
+ execute();
2600
+ }
2601
+ };
2602
+
2603
+ exports.getNumberOfWatchers = () => {
2604
+ return watcherCount;
2605
+ };
2606
+
2607
+ exports.createHandleChangeEvent = createHandleChangeEvent;
2608
+ exports.watcherLimit = watcherLimit;
2609
+
2610
+
2611
+ /***/ }),
2612
+
2613
+ /***/ 851:
2614
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2615
+
2616
+ "use strict";
2617
+ /*
2618
+ MIT License http://www.opensource.org/licenses/mit-license.php
2619
+ Author Tobias Koppers @sokra
2620
+ */
2621
+
2622
+
2623
+ const getWatcherManager = __nccwpck_require__(510);
2624
+ const LinkResolver = __nccwpck_require__(751);
2625
+ const EventEmitter = (__nccwpck_require__(434).EventEmitter);
2626
+ const globToRegExp = __nccwpck_require__(428);
2627
+ const watchEventSource = __nccwpck_require__(729);
2628
+
2629
+ const EMPTY_ARRAY = [];
2630
+ const EMPTY_OPTIONS = {};
2631
+
2632
+ function addWatchersToSet(watchers, set) {
2633
+ for (const ww of watchers) {
2634
+ const w = ww.watcher;
2635
+ if (!set.has(w.directoryWatcher)) {
2636
+ set.add(w.directoryWatcher);
2637
+ }
2638
+ }
2639
+ }
2640
+
2641
+ const stringToRegexp = ignored => {
2642
+ if (ignored.length === 0) {
2643
+ return;
2644
+ }
2645
+ const source = globToRegExp(ignored, { globstar: true, extended: true })
2646
+ .source;
2647
+ return source.slice(0, source.length - 1) + "(?:$|\\/)";
2648
+ };
2649
+
2650
+ const ignoredToFunction = ignored => {
2651
+ if (Array.isArray(ignored)) {
2652
+ const stringRegexps = ignored.map(i => stringToRegexp(i)).filter(Boolean);
2653
+ if (stringRegexps.length === 0) {
2654
+ return () => false;
2655
+ }
2656
+ const regexp = new RegExp(stringRegexps.join("|"));
2657
+ return x => regexp.test(x.replace(/\\/g, "/"));
2658
+ } else if (typeof ignored === "string") {
2659
+ const stringRegexp = stringToRegexp(ignored);
2660
+ if (!stringRegexp) {
2661
+ return () => false;
2662
+ }
2663
+ const regexp = new RegExp(stringRegexp);
2664
+ return x => regexp.test(x.replace(/\\/g, "/"));
2665
+ } else if (ignored instanceof RegExp) {
2666
+ return x => ignored.test(x.replace(/\\/g, "/"));
2667
+ } else if (ignored instanceof Function) {
2668
+ return ignored;
2669
+ } else if (ignored) {
2670
+ throw new Error(`Invalid option for 'ignored': ${ignored}`);
2671
+ } else {
2672
+ return () => false;
2673
+ }
2674
+ };
2675
+
2676
+ const normalizeOptions = options => {
2677
+ return {
2678
+ followSymlinks: !!options.followSymlinks,
2679
+ ignored: ignoredToFunction(options.ignored),
2680
+ poll: options.poll
2681
+ };
2682
+ };
2683
+
2684
+ const normalizeCache = new WeakMap();
2685
+ const cachedNormalizeOptions = options => {
2686
+ const cacheEntry = normalizeCache.get(options);
2687
+ if (cacheEntry !== undefined) return cacheEntry;
2688
+ const normalized = normalizeOptions(options);
2689
+ normalizeCache.set(options, normalized);
2690
+ return normalized;
2691
+ };
2692
+
2693
+ class WatchpackFileWatcher {
2694
+ constructor(watchpack, watcher, files) {
2695
+ this.files = Array.isArray(files) ? files : [files];
2696
+ this.watcher = watcher;
2697
+ watcher.on("initial-missing", type => {
2698
+ for (const file of this.files) {
2699
+ if (!watchpack._missing.has(file))
2700
+ watchpack._onRemove(file, file, type);
2701
+ }
2702
+ });
2703
+ watcher.on("change", (mtime, type) => {
2704
+ for (const file of this.files) {
2705
+ watchpack._onChange(file, mtime, file, type);
2706
+ }
2707
+ });
2708
+ watcher.on("remove", type => {
2709
+ for (const file of this.files) {
2710
+ watchpack._onRemove(file, file, type);
2711
+ }
2712
+ });
2713
+ }
2714
+
2715
+ update(files) {
2716
+ if (!Array.isArray(files)) {
2717
+ if (this.files.length !== 1) {
2718
+ this.files = [files];
2719
+ } else if (this.files[0] !== files) {
2720
+ this.files[0] = files;
2721
+ }
2722
+ } else {
2723
+ this.files = files;
2724
+ }
2725
+ }
2726
+
2727
+ close() {
2728
+ this.watcher.close();
2729
+ }
2730
+ }
2731
+
2732
+ class WatchpackDirectoryWatcher {
2733
+ constructor(watchpack, watcher, directories) {
2734
+ this.directories = Array.isArray(directories) ? directories : [directories];
2735
+ this.watcher = watcher;
2736
+ watcher.on("initial-missing", type => {
2737
+ for (const item of this.directories) {
2738
+ watchpack._onRemove(item, item, type);
2739
+ }
2740
+ });
2741
+ watcher.on("change", (file, mtime, type) => {
2742
+ for (const item of this.directories) {
2743
+ watchpack._onChange(item, mtime, file, type);
2744
+ }
2745
+ });
2746
+ watcher.on("remove", type => {
2747
+ for (const item of this.directories) {
2748
+ watchpack._onRemove(item, item, type);
2749
+ }
2750
+ });
2751
+ }
2752
+
2753
+ update(directories) {
2754
+ if (!Array.isArray(directories)) {
2755
+ if (this.directories.length !== 1) {
2756
+ this.directories = [directories];
2757
+ } else if (this.directories[0] !== directories) {
2758
+ this.directories[0] = directories;
2759
+ }
2760
+ } else {
2761
+ this.directories = directories;
2762
+ }
2763
+ }
2764
+
2765
+ close() {
2766
+ this.watcher.close();
2767
+ }
2768
+ }
2769
+
2770
+ class Watchpack extends EventEmitter {
2771
+ constructor(options) {
2772
+ super();
2773
+ if (!options) options = EMPTY_OPTIONS;
2774
+ this.options = options;
2775
+ this.aggregateTimeout =
2776
+ typeof options.aggregateTimeout === "number"
2777
+ ? options.aggregateTimeout
2778
+ : 200;
2779
+ this.watcherOptions = cachedNormalizeOptions(options);
2780
+ this.watcherManager = getWatcherManager(this.watcherOptions);
2781
+ this.fileWatchers = new Map();
2782
+ this.directoryWatchers = new Map();
2783
+ this._missing = new Set();
2784
+ this.startTime = undefined;
2785
+ this.paused = false;
2786
+ this.aggregatedChanges = new Set();
2787
+ this.aggregatedRemovals = new Set();
2788
+ this.aggregateTimer = undefined;
2789
+ this._onTimeout = this._onTimeout.bind(this);
2790
+ }
2791
+
2792
+ watch(arg1, arg2, arg3) {
2793
+ let files, directories, missing, startTime;
2794
+ if (!arg2) {
2795
+ ({
2796
+ files = EMPTY_ARRAY,
2797
+ directories = EMPTY_ARRAY,
2798
+ missing = EMPTY_ARRAY,
2799
+ startTime
2800
+ } = arg1);
2801
+ } else {
2802
+ files = arg1;
2803
+ directories = arg2;
2804
+ missing = EMPTY_ARRAY;
2805
+ startTime = arg3;
2806
+ }
2807
+ this.paused = false;
2808
+ const fileWatchers = this.fileWatchers;
2809
+ const directoryWatchers = this.directoryWatchers;
2810
+ const ignored = this.watcherOptions.ignored;
2811
+ const filter = path => !ignored(path);
2812
+ const addToMap = (map, key, item) => {
2813
+ const list = map.get(key);
2814
+ if (list === undefined) {
2815
+ map.set(key, item);
2816
+ } else if (Array.isArray(list)) {
2817
+ list.push(item);
2818
+ } else {
2819
+ map.set(key, [list, item]);
2820
+ }
2821
+ };
2822
+ const fileWatchersNeeded = new Map();
2823
+ const directoryWatchersNeeded = new Map();
2824
+ const missingFiles = new Set();
2825
+ if (this.watcherOptions.followSymlinks) {
2826
+ const resolver = new LinkResolver();
2827
+ for (const file of files) {
2828
+ if (filter(file)) {
2829
+ for (const innerFile of resolver.resolve(file)) {
2830
+ if (file === innerFile || filter(innerFile)) {
2831
+ addToMap(fileWatchersNeeded, innerFile, file);
2832
+ }
2833
+ }
2834
+ }
2835
+ }
2836
+ for (const file of missing) {
2837
+ if (filter(file)) {
2838
+ for (const innerFile of resolver.resolve(file)) {
2839
+ if (file === innerFile || filter(innerFile)) {
2840
+ missingFiles.add(file);
2841
+ addToMap(fileWatchersNeeded, innerFile, file);
2842
+ }
2843
+ }
2844
+ }
2845
+ }
2846
+ for (const dir of directories) {
2847
+ if (filter(dir)) {
2848
+ let first = true;
2849
+ for (const innerItem of resolver.resolve(dir)) {
2850
+ if (filter(innerItem)) {
2851
+ addToMap(
2852
+ first ? directoryWatchersNeeded : fileWatchersNeeded,
2853
+ innerItem,
2854
+ dir
2855
+ );
2856
+ }
2857
+ first = false;
2858
+ }
2859
+ }
2860
+ }
2861
+ } else {
2862
+ for (const file of files) {
2863
+ if (filter(file)) {
2864
+ addToMap(fileWatchersNeeded, file, file);
2865
+ }
2866
+ }
2867
+ for (const file of missing) {
2868
+ if (filter(file)) {
2869
+ missingFiles.add(file);
2870
+ addToMap(fileWatchersNeeded, file, file);
2871
+ }
2872
+ }
2873
+ for (const dir of directories) {
2874
+ if (filter(dir)) {
2875
+ addToMap(directoryWatchersNeeded, dir, dir);
2876
+ }
2877
+ }
2878
+ }
2879
+ // Close unneeded old watchers
2880
+ // and update existing watchers
2881
+ for (const [key, w] of fileWatchers) {
2882
+ const needed = fileWatchersNeeded.get(key);
2883
+ if (needed === undefined) {
2884
+ w.close();
2885
+ fileWatchers.delete(key);
2886
+ } else {
2887
+ w.update(needed);
2888
+ fileWatchersNeeded.delete(key);
2889
+ }
2890
+ }
2891
+ for (const [key, w] of directoryWatchers) {
2892
+ const needed = directoryWatchersNeeded.get(key);
2893
+ if (needed === undefined) {
2894
+ w.close();
2895
+ directoryWatchers.delete(key);
2896
+ } else {
2897
+ w.update(needed);
2898
+ directoryWatchersNeeded.delete(key);
2899
+ }
2900
+ }
2901
+ // Create new watchers and install handlers on these watchers
2902
+ watchEventSource.batch(() => {
2903
+ for (const [key, files] of fileWatchersNeeded) {
2904
+ const watcher = this.watcherManager.watchFile(key, startTime);
2905
+ if (watcher) {
2906
+ fileWatchers.set(key, new WatchpackFileWatcher(this, watcher, files));
2907
+ }
2908
+ }
2909
+ for (const [key, directories] of directoryWatchersNeeded) {
2910
+ const watcher = this.watcherManager.watchDirectory(key, startTime);
2911
+ if (watcher) {
2912
+ directoryWatchers.set(
2913
+ key,
2914
+ new WatchpackDirectoryWatcher(this, watcher, directories)
2915
+ );
2916
+ }
2917
+ }
2918
+ });
2919
+ this._missing = missingFiles;
2920
+ this.startTime = startTime;
2921
+ }
2922
+
2923
+ close() {
2924
+ this.paused = true;
2925
+ if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
2926
+ for (const w of this.fileWatchers.values()) w.close();
2927
+ for (const w of this.directoryWatchers.values()) w.close();
2928
+ this.fileWatchers.clear();
2929
+ this.directoryWatchers.clear();
2930
+ }
2931
+
2932
+ pause() {
2933
+ this.paused = true;
2934
+ if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
2935
+ }
2936
+
2937
+ getTimes() {
2938
+ const directoryWatchers = new Set();
2939
+ addWatchersToSet(this.fileWatchers.values(), directoryWatchers);
2940
+ addWatchersToSet(this.directoryWatchers.values(), directoryWatchers);
2941
+ const obj = Object.create(null);
2942
+ for (const w of directoryWatchers) {
2943
+ const times = w.getTimes();
2944
+ for (const file of Object.keys(times)) obj[file] = times[file];
2945
+ }
2946
+ return obj;
2947
+ }
2948
+
2949
+ getTimeInfoEntries() {
2950
+ const map = new Map();
2951
+ this.collectTimeInfoEntries(map, map);
2952
+ return map;
2953
+ }
2954
+
2955
+ collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
2956
+ const allWatchers = new Set();
2957
+ addWatchersToSet(this.fileWatchers.values(), allWatchers);
2958
+ addWatchersToSet(this.directoryWatchers.values(), allWatchers);
2959
+ const safeTime = { value: 0 };
2960
+ for (const w of allWatchers) {
2961
+ w.collectTimeInfoEntries(fileTimestamps, directoryTimestamps, safeTime);
2962
+ }
2963
+ }
2964
+
2965
+ getAggregated() {
2966
+ if (this.aggregateTimer) {
2967
+ clearTimeout(this.aggregateTimer);
2968
+ this.aggregateTimer = undefined;
2969
+ }
2970
+ const changes = this.aggregatedChanges;
2971
+ const removals = this.aggregatedRemovals;
2972
+ this.aggregatedChanges = new Set();
2973
+ this.aggregatedRemovals = new Set();
2974
+ return { changes, removals };
2975
+ }
2976
+
2977
+ _onChange(item, mtime, file, type) {
2978
+ file = file || item;
2979
+ if (!this.paused) {
2980
+ this.emit("change", file, mtime, type);
2981
+ if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
2982
+ this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout);
2983
+ }
2984
+ this.aggregatedRemovals.delete(item);
2985
+ this.aggregatedChanges.add(item);
2986
+ }
2987
+
2988
+ _onRemove(item, file, type) {
2989
+ file = file || item;
2990
+ if (!this.paused) {
2991
+ this.emit("remove", file, type);
2992
+ if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
2993
+ this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout);
2994
+ }
2995
+ this.aggregatedChanges.delete(item);
2996
+ this.aggregatedRemovals.add(item);
2997
+ }
2998
+
2999
+ _onTimeout() {
3000
+ this.aggregateTimer = undefined;
3001
+ const changes = this.aggregatedChanges;
3002
+ const removals = this.aggregatedRemovals;
3003
+ this.aggregatedChanges = new Set();
3004
+ this.aggregatedRemovals = new Set();
3005
+ this.emit("aggregated", changes, removals);
3006
+ }
3007
+ }
3008
+
3009
+ module.exports = Watchpack;
3010
+
3011
+
3012
+ /***/ }),
3013
+
3014
+ /***/ 613:
3015
+ /***/ ((module) => {
3016
+
3017
+ "use strict";
3018
+ module.exports = require("assert");
3019
+
3020
+ /***/ }),
3021
+
3022
+ /***/ 140:
3023
+ /***/ ((module) => {
3024
+
3025
+ "use strict";
3026
+ module.exports = require("constants");
3027
+
3028
+ /***/ }),
3029
+
3030
+ /***/ 434:
3031
+ /***/ ((module) => {
3032
+
3033
+ "use strict";
3034
+ module.exports = require("events");
3035
+
3036
+ /***/ }),
3037
+
3038
+ /***/ 896:
3039
+ /***/ ((module) => {
3040
+
3041
+ "use strict";
3042
+ module.exports = require("fs");
3043
+
3044
+ /***/ }),
3045
+
3046
+ /***/ 857:
3047
+ /***/ ((module) => {
3048
+
3049
+ "use strict";
3050
+ module.exports = require("os");
3051
+
3052
+ /***/ }),
3053
+
3054
+ /***/ 928:
3055
+ /***/ ((module) => {
3056
+
3057
+ "use strict";
3058
+ module.exports = require("path");
3059
+
3060
+ /***/ }),
3061
+
3062
+ /***/ 203:
3063
+ /***/ ((module) => {
3064
+
3065
+ "use strict";
3066
+ module.exports = require("stream");
3067
+
3068
+ /***/ }),
3069
+
3070
+ /***/ 23:
3071
+ /***/ ((module) => {
3072
+
3073
+ "use strict";
3074
+ module.exports = require("util");
3075
+
3076
+ /***/ })
3077
+
3078
+ /******/ });
3079
+ /************************************************************************/
3080
+ /******/ // The module cache
3081
+ /******/ var __webpack_module_cache__ = {};
3082
+ /******/
3083
+ /******/ // The require function
3084
+ /******/ function __nccwpck_require__(moduleId) {
3085
+ /******/ // Check if module is in cache
3086
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
3087
+ /******/ if (cachedModule !== undefined) {
3088
+ /******/ return cachedModule.exports;
3089
+ /******/ }
3090
+ /******/ // Create a new module (and put it into the cache)
3091
+ /******/ var module = __webpack_module_cache__[moduleId] = {
3092
+ /******/ // no module.id needed
3093
+ /******/ // no module.loaded needed
3094
+ /******/ exports: {}
3095
+ /******/ };
3096
+ /******/
3097
+ /******/ // Execute the module function
3098
+ /******/ var threw = true;
3099
+ /******/ try {
3100
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
3101
+ /******/ threw = false;
3102
+ /******/ } finally {
3103
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
3104
+ /******/ }
3105
+ /******/
3106
+ /******/ // Return the exports of the module
3107
+ /******/ return module.exports;
3108
+ /******/ }
3109
+ /******/
3110
+ /************************************************************************/
3111
+ /******/ /* webpack/runtime/compat */
3112
+ /******/
3113
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
3114
+ /******/
3115
+ /************************************************************************/
3116
+ /******/
3117
+ /******/ // startup
3118
+ /******/ // Load entry module and return exports
3119
+ /******/ // This entry module is referenced by other modules so it can't be inlined
3120
+ /******/ var __webpack_exports__ = __nccwpck_require__(851);
3121
+ /******/ module.exports = __webpack_exports__;
3122
+ /******/
3123
+ /******/ })()
3124
+ ;