@ohos-ports/rsbuild-core 2.2.9-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/bin/rsbuild.js +20 -0
  4. package/compiled/@rstackjs/load-config/index.d.ts +87 -0
  5. package/compiled/@rstackjs/load-config/license +21 -0
  6. package/compiled/@rstackjs/load-config/package.json +1 -0
  7. package/compiled/chokidar/index.d.ts +385 -0
  8. package/compiled/chokidar/license +21 -0
  9. package/compiled/chokidar/package.json +1 -0
  10. package/compiled/connect-next/index.d.ts +57 -0
  11. package/compiled/connect-next/license +26 -0
  12. package/compiled/connect-next/package.json +1 -0
  13. package/compiled/cors/index.d.ts +56 -0
  14. package/compiled/cors/license +22 -0
  15. package/compiled/cors/package.json +1 -0
  16. package/compiled/css-loader/api.js +85 -0
  17. package/compiled/css-loader/getUrl.js +26 -0
  18. package/compiled/css-loader/index.d.ts +1 -0
  19. package/compiled/css-loader/index.js +2 -0
  20. package/compiled/css-loader/license +20 -0
  21. package/compiled/css-loader/noSourceMaps.js +5 -0
  22. package/compiled/css-loader/package.json +1 -0
  23. package/compiled/css-loader/sourceMaps.js +16 -0
  24. package/compiled/html-rspack-plugin/default_index.ejs +9 -0
  25. package/compiled/html-rspack-plugin/htmlLoader.js +157 -0
  26. package/compiled/html-rspack-plugin/index.d.ts +395 -0
  27. package/compiled/html-rspack-plugin/index.js +2400 -0
  28. package/compiled/html-rspack-plugin/license +20 -0
  29. package/compiled/html-rspack-plugin/package.json +1 -0
  30. package/compiled/http-proxy-middleware/index.d.ts +455 -0
  31. package/compiled/http-proxy-middleware/license +22 -0
  32. package/compiled/http-proxy-middleware/package.json +1 -0
  33. package/compiled/jiti/LICENSE +21 -0
  34. package/compiled/jiti/README.md +258 -0
  35. package/compiled/jiti/dist/babel.cjs +47446 -0
  36. package/compiled/jiti/dist/jiti.cjs +5990 -0
  37. package/compiled/jiti/lib/jiti-cli.mjs +19 -0
  38. package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
  39. package/compiled/jiti/lib/jiti-native.mjs +76 -0
  40. package/compiled/jiti/lib/jiti-register.d.mts +1 -0
  41. package/compiled/jiti/lib/jiti-register.mjs +2 -0
  42. package/compiled/jiti/lib/jiti-static.mjs +19 -0
  43. package/compiled/jiti/lib/jiti.cjs +24 -0
  44. package/compiled/jiti/lib/jiti.d.cts +8 -0
  45. package/compiled/jiti/lib/jiti.d.mts +8 -0
  46. package/compiled/jiti/lib/jiti.mjs +23 -0
  47. package/compiled/jiti/lib/types.d.ts +420 -0
  48. package/compiled/jiti/package.json +146 -0
  49. package/compiled/postcss/index.js +1 -0
  50. package/compiled/postcss/lib/at-rule.d.ts +139 -0
  51. package/compiled/postcss/lib/comment.d.ts +67 -0
  52. package/compiled/postcss/lib/container.d.ts +474 -0
  53. package/compiled/postcss/lib/css-syntax-error.d.ts +247 -0
  54. package/compiled/postcss/lib/declaration.d.ts +150 -0
  55. package/compiled/postcss/lib/document.d.ts +68 -0
  56. package/compiled/postcss/lib/fromJSON.d.ts +9 -0
  57. package/compiled/postcss/lib/input.d.ts +226 -0
  58. package/compiled/postcss/lib/lazy-result.d.ts +189 -0
  59. package/compiled/postcss/lib/list.d.ts +60 -0
  60. package/compiled/postcss/lib/no-work-result.d.ts +45 -0
  61. package/compiled/postcss/lib/node.d.ts +555 -0
  62. package/compiled/postcss/lib/parse.d.ts +9 -0
  63. package/compiled/postcss/lib/postcss.d.ts +464 -0
  64. package/compiled/postcss/lib/previous-map.d.ts +80 -0
  65. package/compiled/postcss/lib/processor.d.ts +114 -0
  66. package/compiled/postcss/lib/result.d.ts +204 -0
  67. package/compiled/postcss/lib/root.d.ts +86 -0
  68. package/compiled/postcss/lib/rule.d.ts +126 -0
  69. package/compiled/postcss/lib/source-map-js.d.ts +4 -0
  70. package/compiled/postcss/lib/stringifier.d.ts +45 -0
  71. package/compiled/postcss/lib/stringify.d.ts +9 -0
  72. package/compiled/postcss/lib/warning.d.ts +146 -0
  73. package/compiled/postcss/license +20 -0
  74. package/compiled/postcss/package.json +1 -0
  75. package/compiled/postcss-loader/index.d.ts +1 -0
  76. package/compiled/postcss-loader/index.js +721 -0
  77. package/compiled/postcss-loader/license +20 -0
  78. package/compiled/postcss-loader/package.json +1 -0
  79. package/compiled/rslog/index.d.ts +98 -0
  80. package/compiled/rslog/license +21 -0
  81. package/compiled/rslog/package.json +1 -0
  82. package/compiled/rspack-chain/license +22 -0
  83. package/compiled/rspack-chain/package.json +1 -0
  84. package/compiled/rspack-chain/types/index.d.ts +515 -0
  85. package/compiled/rspack-manifest-plugin/index.d.ts +52 -0
  86. package/compiled/rspack-manifest-plugin/license +21 -0
  87. package/compiled/rspack-manifest-plugin/package.json +1 -0
  88. package/compiled/style-loader/index.d.ts +1 -0
  89. package/compiled/style-loader/index.js +370 -0
  90. package/compiled/style-loader/license +20 -0
  91. package/compiled/style-loader/package.json +1 -0
  92. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  93. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  94. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  95. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  96. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  97. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  98. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  99. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  100. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  101. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  102. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  103. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  104. package/compiled/ws/index.d.ts +445 -0
  105. package/compiled/ws/license +21 -0
  106. package/compiled/ws/package.json +1 -0
  107. package/dist/build.d.ts +4 -0
  108. package/dist/c.js +10 -0
  109. package/dist/chokidar.js +2 -0
  110. package/dist/chokidar.js.LICENSE.txt +1 -0
  111. package/dist/cli/commands.d.ts +31 -0
  112. package/dist/cli/index.d.ts +7 -0
  113. package/dist/cli/init.d.ts +7 -0
  114. package/dist/client/f~0.js +22 -0
  115. package/dist/client/hmr.js +267 -0
  116. package/dist/client/overlay.js +214 -0
  117. package/dist/configChain.d.ts +84 -0
  118. package/dist/connect-next.js +2 -0
  119. package/dist/connect-next.js.LICENSE.txt +57 -0
  120. package/dist/constants.d.ts +67 -0
  121. package/dist/cors.js +188 -0
  122. package/dist/cors.js.LICENSE.txt +11 -0
  123. package/dist/createCompiler.d.ts +6 -0
  124. package/dist/createContext.d.ts +12 -0
  125. package/dist/createRsbuild.d.ts +4 -0
  126. package/dist/cssUrlLoader.mjs +34 -0
  127. package/dist/defaultConfig.d.ts +23 -0
  128. package/dist/freshImport.js +90 -0
  129. package/dist/helpers/cachedImport.d.ts +2 -0
  130. package/dist/helpers/compiler.d.ts +5 -0
  131. package/dist/helpers/css.d.ts +3 -0
  132. package/dist/helpers/exitHook.d.ts +3 -0
  133. package/dist/helpers/format.d.ts +4 -0
  134. package/dist/helpers/fs.d.ts +16 -0
  135. package/dist/helpers/html.d.ts +2 -0
  136. package/dist/helpers/index.d.ts +29 -0
  137. package/dist/helpers/overlayConfig.d.ts +4 -0
  138. package/dist/helpers/packageJson.d.ts +9 -0
  139. package/dist/helpers/path.d.ts +22 -0
  140. package/dist/helpers/restartManager.d.ts +15 -0
  141. package/dist/helpers/stats.d.ts +17 -0
  142. package/dist/helpers/url.d.ts +11 -0
  143. package/dist/helpers/vendors.d.ts +12 -0
  144. package/dist/helpers/version.d.ts +7 -0
  145. package/dist/hooks.d.ts +41 -0
  146. package/dist/http-proxy-middleware.js +14 -0
  147. package/dist/http-proxy-middleware.js.LICENSE.txt +34 -0
  148. package/dist/ignoreCssLoader.mjs +9 -0
  149. package/dist/index.d.ts +28 -0
  150. package/dist/index.js +1 -0
  151. package/dist/initConfigs.d.ts +18 -0
  152. package/dist/initPlugins.d.ts +7 -0
  153. package/dist/inspectConfig.d.ts +7 -0
  154. package/dist/launch-editor-middleware.js +1 -0
  155. package/dist/loadConfig.d.ts +31 -0
  156. package/dist/loadEnv.d.ts +54 -0
  157. package/dist/loader/cssUrlLoader.d.ts +9 -0
  158. package/dist/loader/ignoreCssLoader.d.ts +10 -0
  159. package/dist/loader/transformLoader.d.ts +8 -0
  160. package/dist/loader/transformRawLoader.d.ts +4 -0
  161. package/dist/loader/workerLoader.d.ts +6 -0
  162. package/dist/logger.d.ts +24 -0
  163. package/dist/m.js +10348 -0
  164. package/dist/m.js.LICENSE.txt +26 -0
  165. package/dist/manifest-plugin.js +1 -0
  166. package/dist/memfs.js +1 -0
  167. package/dist/mergeConfig.d.ts +7 -0
  168. package/dist/open.js +2 -0
  169. package/dist/pluginHelper.d.ts +4 -0
  170. package/dist/pluginManager.d.ts +19 -0
  171. package/dist/plugins/appIcon.d.ts +2 -0
  172. package/dist/plugins/asset.d.ts +3 -0
  173. package/dist/plugins/basic.d.ts +4 -0
  174. package/dist/plugins/cache.d.ts +2 -0
  175. package/dist/plugins/cleanOutput.d.ts +2 -0
  176. package/dist/plugins/css.d.ts +8 -0
  177. package/dist/plugins/define.d.ts +2 -0
  178. package/dist/plugins/entry.d.ts +2 -0
  179. package/dist/plugins/externals.d.ts +9 -0
  180. package/dist/plugins/fileSize.d.ts +7 -0
  181. package/dist/plugins/html.d.ts +9 -0
  182. package/dist/plugins/inlineChunk.d.ts +6 -0
  183. package/dist/plugins/lazyCompilation.d.ts +2 -0
  184. package/dist/plugins/manifest.d.ts +2 -0
  185. package/dist/plugins/minimize.d.ts +10 -0
  186. package/dist/plugins/moduleFederation.d.ts +2 -0
  187. package/dist/plugins/nodeAddons.d.ts +2 -0
  188. package/dist/plugins/nonce.d.ts +2 -0
  189. package/dist/plugins/output.d.ts +2 -0
  190. package/dist/plugins/progress.d.ts +2 -0
  191. package/dist/plugins/resolve.d.ts +2 -0
  192. package/dist/plugins/resourceHints.d.ts +2 -0
  193. package/dist/plugins/rsdoctor.d.ts +2 -0
  194. package/dist/plugins/rspackProfile.d.ts +4 -0
  195. package/dist/plugins/server.d.ts +3 -0
  196. package/dist/plugins/sourceMap.d.ts +2 -0
  197. package/dist/plugins/splitChunks.d.ts +4 -0
  198. package/dist/plugins/sri.d.ts +2 -0
  199. package/dist/plugins/swc.d.ts +4 -0
  200. package/dist/plugins/target.d.ts +2 -0
  201. package/dist/plugins/wasm.d.ts +2 -0
  202. package/dist/plugins/worker.d.ts +2 -0
  203. package/dist/r.js +7 -0
  204. package/dist/range-parser.js +55 -0
  205. package/dist/range-parser.js.LICENSE.txt +6 -0
  206. package/dist/remapping.js +201 -0
  207. package/dist/restart.d.ts +15 -0
  208. package/dist/rslib-runtime.js +49 -0
  209. package/dist/rspack-plugins/RsbuildHtmlPlugin.d.ts +37 -0
  210. package/dist/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +36 -0
  211. package/dist/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +27 -0
  212. package/dist/rspack-plugins/resource-hints/extractChunks.d.ts +22 -0
  213. package/dist/rspack-plugins/resource-hints/getResourceType.d.ts +21 -0
  214. package/dist/rspackConfig.d.ts +8 -0
  215. package/dist/server/ansiHTML.d.ts +3 -0
  216. package/dist/server/assets-middleware/getFileFromUrl.d.ts +11 -0
  217. package/dist/server/assets-middleware/index.d.ts +35 -0
  218. package/dist/server/assets-middleware/memoryFileSystem.d.ts +2 -0
  219. package/dist/server/assets-middleware/middleware.d.ts +7 -0
  220. package/dist/server/assets-middleware/parseTokenList.d.ts +1 -0
  221. package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
  222. package/dist/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
  223. package/dist/server/browserLogs.d.ts +8 -0
  224. package/dist/server/buildManager.d.ts +32 -0
  225. package/dist/server/cliShortcuts.d.ts +19 -0
  226. package/dist/server/compileState.d.ts +5 -0
  227. package/dist/server/devMiddlewares.d.ts +18 -0
  228. package/dist/server/devServer.d.ts +47 -0
  229. package/dist/server/environment.d.ts +8 -0
  230. package/dist/server/gracefulShutdown.d.ts +8 -0
  231. package/dist/server/gzipMiddleware.d.ts +2 -0
  232. package/dist/server/helper.d.ts +118 -0
  233. package/dist/server/historyApiFallback.d.ts +10 -0
  234. package/dist/server/hmrFallback.d.ts +1 -0
  235. package/dist/server/httpServer.d.ts +7 -0
  236. package/dist/server/middlewares.d.ts +31 -0
  237. package/dist/server/open.d.ts +12 -0
  238. package/dist/server/overlay.d.ts +3 -0
  239. package/dist/server/previewServer.d.ts +4 -0
  240. package/dist/server/proxy.d.ts +7 -0
  241. package/dist/server/publicPathnames.d.ts +2 -0
  242. package/dist/server/runner/asModule.d.ts +2 -0
  243. package/dist/server/runner/basic.d.ts +25 -0
  244. package/dist/server/runner/cjs.d.ts +10 -0
  245. package/dist/server/runner/esm.d.ts +6 -0
  246. package/dist/server/runner/index.d.ts +6 -0
  247. package/dist/server/runner/type.d.ts +42 -0
  248. package/dist/server/serverSetup.d.ts +2 -0
  249. package/dist/server/socketServer.d.ts +113 -0
  250. package/dist/server/watchFiles.d.ts +15 -0
  251. package/dist/sirv.js +122 -0
  252. package/dist/tinyglobby.js +1 -0
  253. package/dist/trace-mapping.js +548 -0
  254. package/dist/transformLoader.mjs +36 -0
  255. package/dist/transformRawLoader.mjs +4 -0
  256. package/dist/types/config.d.ts +1796 -0
  257. package/dist/types/context.d.ts +89 -0
  258. package/dist/types/hooks.d.ts +261 -0
  259. package/dist/types/index.d.ts +8 -0
  260. package/dist/types/plugin.d.ts +479 -0
  261. package/dist/types/rsbuild.d.ts +241 -0
  262. package/dist/types/rspack.d.ts +10 -0
  263. package/dist/types/thirdParty.d.ts +161 -0
  264. package/dist/types/utils.d.ts +16 -0
  265. package/dist/workerLoader.mjs +94 -0
  266. package/dist/ws.js +2 -0
  267. package/package.json +107 -0
  268. package/static/openChrome.applescript +95 -0
  269. package/types.d.ts +422 -0
@@ -0,0 +1,2400 @@
1
+ (() => {
2
+ var __webpack_modules__ = {
3
+ 535: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
+ "use strict";
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(284);
6
+ const compilerMap = new WeakMap();
7
+ class CachedChildCompilation {
8
+ constructor(compiler) {
9
+ this.compiler = compiler;
10
+ if (compilerMap.has(compiler)) {
11
+ return;
12
+ }
13
+ const persistentChildCompilerSingletonPlugin =
14
+ new PersistentChildCompilerSingletonPlugin();
15
+ compilerMap.set(compiler, persistentChildCompilerSingletonPlugin);
16
+ persistentChildCompilerSingletonPlugin.apply(compiler);
17
+ }
18
+ addEntry(entry) {
19
+ const persistentChildCompilerSingletonPlugin = compilerMap.get(
20
+ this.compiler,
21
+ );
22
+ if (!persistentChildCompilerSingletonPlugin) {
23
+ throw new Error(
24
+ "PersistentChildCompilerSingletonPlugin instance not found.",
25
+ );
26
+ }
27
+ persistentChildCompilerSingletonPlugin.addEntry(entry);
28
+ }
29
+ getCompilationResult() {
30
+ const persistentChildCompilerSingletonPlugin = compilerMap.get(
31
+ this.compiler,
32
+ );
33
+ if (!persistentChildCompilerSingletonPlugin) {
34
+ throw new Error(
35
+ "PersistentChildCompilerSingletonPlugin instance not found.",
36
+ );
37
+ }
38
+ return persistentChildCompilerSingletonPlugin.getLatestResult();
39
+ }
40
+ getCompilationEntryResult(entry) {
41
+ const latestResult = this.getCompilationResult();
42
+ const compilationResult = latestResult.compilationResult;
43
+ return "error" in compilationResult
44
+ ? {
45
+ mainCompilationHash: latestResult.mainCompilationHash,
46
+ error: compilationResult.error,
47
+ }
48
+ : {
49
+ mainCompilationHash: latestResult.mainCompilationHash,
50
+ compiledEntry: compilationResult.compiledEntries[entry],
51
+ };
52
+ }
53
+ }
54
+ class PersistentChildCompilerSingletonPlugin {
55
+ static createSnapshot(fileDependencies, mainCompilation) {
56
+ const timestamps = {};
57
+ const fs = mainCompilation.inputFileSystem;
58
+ return Promise.all(
59
+ fileDependencies.map(
60
+ (file) =>
61
+ new Promise((resolve) => {
62
+ fs.stat(file, (err, stat) => {
63
+ if (!err && stat) {
64
+ timestamps[file] = stat.mtime.getTime();
65
+ } else {
66
+ timestamps[file] = null;
67
+ }
68
+ resolve(undefined);
69
+ });
70
+ }),
71
+ ),
72
+ ).then(() => timestamps);
73
+ }
74
+ static isSnapshotValid(snapshot, mainCompilation) {
75
+ const fs = mainCompilation.inputFileSystem;
76
+ return Promise.all(
77
+ Object.keys(snapshot).map(
78
+ (file) =>
79
+ new Promise((resolve) => {
80
+ fs.stat(file, (err, stat) => {
81
+ if (!err && stat && snapshot[file] !== null) {
82
+ resolve(stat.mtime.getTime() === snapshot[file]);
83
+ } else if (err && snapshot[file] === null) {
84
+ resolve(true);
85
+ } else {
86
+ resolve(false);
87
+ }
88
+ });
89
+ }),
90
+ ),
91
+ ).then((results) => !results.includes(false));
92
+ }
93
+ static watchFiles(mainCompilation, fileDependencies) {
94
+ Object.keys(fileDependencies).forEach((depencyTypes) => {
95
+ fileDependencies[depencyTypes].forEach((fileDependency) => {
96
+ mainCompilation[depencyTypes].add(fileDependency);
97
+ });
98
+ });
99
+ }
100
+ constructor() {
101
+ this.compilationState = {
102
+ isCompiling: false,
103
+ isVerifyingCache: false,
104
+ entries: [],
105
+ compiledEntries: [],
106
+ mainCompilationHash: "initial",
107
+ compilationResult: {
108
+ dependencies: {
109
+ fileDependencies: [],
110
+ contextDependencies: [],
111
+ missingDependencies: [],
112
+ },
113
+ compiledEntries: {},
114
+ },
115
+ };
116
+ }
117
+ apply(compiler) {
118
+ let childCompilationResultPromise = Promise.resolve({
119
+ dependencies: {
120
+ fileDependencies: [],
121
+ contextDependencies: [],
122
+ missingDependencies: [],
123
+ },
124
+ compiledEntries: {},
125
+ });
126
+ let mainCompilationHashOfLastChildRecompile = "";
127
+ let previousFileSystemSnapshot;
128
+ compiler.hooks.make.tapAsync(
129
+ "PersistentChildCompilerSingletonPlugin",
130
+ (mainCompilation, callback) => {
131
+ if (
132
+ this.compilationState.isCompiling ||
133
+ this.compilationState.isVerifyingCache
134
+ ) {
135
+ return callback(
136
+ new Error("Child compilation has already started"),
137
+ );
138
+ }
139
+ this.compilationState = {
140
+ isCompiling: false,
141
+ isVerifyingCache: true,
142
+ previousEntries: this.compilationState.compiledEntries,
143
+ previousResult: this.compilationState.compilationResult,
144
+ entries: this.compilationState.entries,
145
+ };
146
+ const isCacheValidPromise = this.isCacheValid(
147
+ previousFileSystemSnapshot,
148
+ mainCompilation,
149
+ );
150
+ let cachedResult = childCompilationResultPromise;
151
+ childCompilationResultPromise = isCacheValidPromise.then(
152
+ (isCacheValid) => {
153
+ if (isCacheValid) {
154
+ return cachedResult;
155
+ }
156
+ const compiledEntriesPromise = this.compileEntries(
157
+ mainCompilation,
158
+ this.compilationState.entries,
159
+ );
160
+ compiledEntriesPromise
161
+ .then((childCompilationResult) =>
162
+ PersistentChildCompilerSingletonPlugin.createSnapshot(
163
+ childCompilationResult.dependencies.fileDependencies,
164
+ mainCompilation,
165
+ ),
166
+ )
167
+ .then((snapshot) => {
168
+ previousFileSystemSnapshot = snapshot;
169
+ });
170
+ return compiledEntriesPromise;
171
+ },
172
+ );
173
+ mainCompilation.hooks.additionalAssets.tapAsync(
174
+ "PersistentChildCompilerSingletonPlugin",
175
+ (callback) => {
176
+ const didRecompilePromise = Promise.all([
177
+ childCompilationResultPromise,
178
+ cachedResult,
179
+ ]).then(
180
+ ([childCompilationResult, cachedResult]) =>
181
+ cachedResult !== childCompilationResult,
182
+ );
183
+ const handleCompilationDonePromise = Promise.all([
184
+ childCompilationResultPromise,
185
+ didRecompilePromise,
186
+ ]).then(([childCompilationResult, didRecompile]) => {
187
+ if (didRecompile) {
188
+ mainCompilationHashOfLastChildRecompile =
189
+ mainCompilation.hash;
190
+ }
191
+ this.compilationState = {
192
+ isCompiling: false,
193
+ isVerifyingCache: false,
194
+ entries: this.compilationState.entries,
195
+ compiledEntries: this.compilationState.entries,
196
+ compilationResult: childCompilationResult,
197
+ mainCompilationHash:
198
+ mainCompilationHashOfLastChildRecompile,
199
+ };
200
+ });
201
+ handleCompilationDonePromise.then(
202
+ () => callback(null),
203
+ callback,
204
+ );
205
+ },
206
+ );
207
+ callback(null);
208
+ },
209
+ );
210
+ compiler.hooks.finishMake.tapAsync(
211
+ "PersistentChildCompilerSingletonPlugin",
212
+ (mainCompilation, callback) => {
213
+ if (mainCompilation.compiler !== compiler) {
214
+ return callback(null);
215
+ }
216
+ const handleCompilationDonePromise =
217
+ childCompilationResultPromise.then((childCompilationResult) => {
218
+ this.watchFiles(
219
+ mainCompilation,
220
+ childCompilationResult.dependencies,
221
+ );
222
+ });
223
+ handleCompilationDonePromise.then(() => callback(null), callback);
224
+ },
225
+ );
226
+ }
227
+ addEntry(entry) {
228
+ if (
229
+ this.compilationState.isCompiling ||
230
+ this.compilationState.isVerifyingCache
231
+ ) {
232
+ throw new Error(
233
+ "The child compiler has already started to compile. " +
234
+ "Please add entries before the main compiler 'make' phase has started or " +
235
+ "after the compilation is done.",
236
+ );
237
+ }
238
+ if (this.compilationState.entries.indexOf(entry) === -1) {
239
+ this.compilationState.entries = [
240
+ ...this.compilationState.entries,
241
+ entry,
242
+ ];
243
+ }
244
+ }
245
+ getLatestResult() {
246
+ if (
247
+ this.compilationState.isCompiling ||
248
+ this.compilationState.isVerifyingCache
249
+ ) {
250
+ throw new Error(
251
+ "The child compiler is not done compiling. " +
252
+ "Please access the result after the compiler 'make' phase has started or " +
253
+ "after the compilation is done.",
254
+ );
255
+ }
256
+ return {
257
+ mainCompilationHash: this.compilationState.mainCompilationHash,
258
+ compilationResult: this.compilationState.compilationResult,
259
+ };
260
+ }
261
+ isCacheValid(snapshot, mainCompilation) {
262
+ if (!this.compilationState.isVerifyingCache) {
263
+ return Promise.reject(
264
+ new Error(
265
+ "Cache validation can only be done right before the compilation starts",
266
+ ),
267
+ );
268
+ }
269
+ if (this.compilationState.entries.length === 0) {
270
+ return Promise.resolve(true);
271
+ }
272
+ if (
273
+ this.compilationState.entries !==
274
+ this.compilationState.previousEntries
275
+ ) {
276
+ return Promise.resolve(false);
277
+ }
278
+ if (!snapshot) {
279
+ return Promise.resolve(false);
280
+ }
281
+ return PersistentChildCompilerSingletonPlugin.isSnapshotValid(
282
+ snapshot,
283
+ mainCompilation,
284
+ );
285
+ }
286
+ compileEntries(mainCompilation, entries) {
287
+ const compiler = new HtmlWebpackChildCompiler(entries);
288
+ return compiler.compileTemplates(mainCompilation).then(
289
+ (result) => ({
290
+ compiledEntries: result,
291
+ dependencies: compiler.fileDependencies,
292
+ mainCompilationHash: mainCompilation.hash,
293
+ }),
294
+ (error) => ({
295
+ error,
296
+ dependencies: compiler.fileDependencies,
297
+ mainCompilationHash: mainCompilation.hash,
298
+ }),
299
+ );
300
+ }
301
+ watchFiles(mainCompilation, files) {
302
+ PersistentChildCompilerSingletonPlugin.watchFiles(
303
+ mainCompilation,
304
+ files,
305
+ );
306
+ }
307
+ }
308
+ module.exports = { CachedChildCompilation };
309
+ },
310
+ 284: (module) => {
311
+ "use strict";
312
+ class HtmlWebpackChildCompiler {
313
+ compilationPromise;
314
+ constructor(templates) {
315
+ this.templates = templates;
316
+ this.compilationStartedTimestamp;
317
+ this.compilationEndedTimestamp;
318
+ this.fileDependencies = {
319
+ fileDependencies: [],
320
+ contextDependencies: [],
321
+ missingDependencies: [],
322
+ };
323
+ }
324
+ isCompiling() {
325
+ return (
326
+ !this.didCompile() && this.compilationStartedTimestamp !== undefined
327
+ );
328
+ }
329
+ didCompile() {
330
+ return this.compilationEndedTimestamp !== undefined;
331
+ }
332
+ compileTemplates(mainCompilation) {
333
+ const webpack = mainCompilation.compiler.webpack;
334
+ const Compilation = webpack.Compilation;
335
+ const NodeTemplatePlugin = webpack.node.NodeTemplatePlugin;
336
+ const NodeTargetPlugin = webpack.node.NodeTargetPlugin;
337
+ const LoaderTargetPlugin = webpack.LoaderTargetPlugin;
338
+ const EntryPlugin = webpack.EntryPlugin;
339
+ if (this.compilationPromise) {
340
+ return this.compilationPromise;
341
+ }
342
+ const outputOptions = {
343
+ filename: "__child-[name]",
344
+ publicPath: "",
345
+ library: { type: "var", name: "HTML_WEBPACK_PLUGIN_RESULT" },
346
+ scriptType: "text/javascript",
347
+ iife: true,
348
+ };
349
+ const compilerName = "HtmlRspackCompiler";
350
+ const childCompiler = mainCompilation.createChildCompiler(
351
+ compilerName,
352
+ outputOptions,
353
+ [
354
+ new NodeTargetPlugin(),
355
+ new NodeTemplatePlugin(),
356
+ new LoaderTargetPlugin("node"),
357
+ new webpack.library.EnableLibraryPlugin("var"),
358
+ ],
359
+ );
360
+ childCompiler.context = mainCompilation.compiler.context;
361
+ const temporaryTemplateNames = this.templates.map(
362
+ (template, index) =>
363
+ `__child-HtmlRspackPlugin_${index}-${template}`,
364
+ );
365
+ this.templates.forEach((template, index) => {
366
+ new EntryPlugin(
367
+ childCompiler.context,
368
+ "data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;",
369
+ `HtmlRspackPlugin_${index}-${template}`,
370
+ ).apply(childCompiler);
371
+ new EntryPlugin(
372
+ childCompiler.context,
373
+ template,
374
+ `HtmlRspackPlugin_${index}-${template}`,
375
+ ).apply(childCompiler);
376
+ });
377
+ childCompiler.options.module = { ...childCompiler.options.module };
378
+ childCompiler.options.module.parser = {
379
+ ...childCompiler.options.module.parser,
380
+ };
381
+ const javascriptModules = [
382
+ "javascript",
383
+ "javascript/auto",
384
+ "javascript/dynamic",
385
+ "javascript/esm",
386
+ ];
387
+ for (const moduleType of javascriptModules) {
388
+ childCompiler.options.module.parser[moduleType] = {
389
+ ...childCompiler.options.module.parser[moduleType],
390
+ url: "relative",
391
+ };
392
+ }
393
+ this.compilationStartedTimestamp = Date.now();
394
+ this.compilationPromise = new Promise((resolve, reject) => {
395
+ const extractedAssets = [];
396
+ childCompiler.hooks.thisCompilation.tap(
397
+ "HtmlRspackPlugin",
398
+ (compilation) => {
399
+ compilation.hooks.processAssets.tap(
400
+ {
401
+ name: "HtmlRspackPlugin",
402
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
403
+ },
404
+ (assets) => {
405
+ temporaryTemplateNames.forEach((temporaryTemplateName) => {
406
+ if (assets[temporaryTemplateName]) {
407
+ extractedAssets.push(assets[temporaryTemplateName]);
408
+ compilation.deleteAsset(temporaryTemplateName);
409
+ }
410
+ });
411
+ },
412
+ );
413
+ },
414
+ );
415
+ childCompiler.runAsChild((err, entries, childCompilation) => {
416
+ const compiledTemplates = entries
417
+ ? extractedAssets.map((asset) => asset.source())
418
+ : [];
419
+ if (entries && childCompilation) {
420
+ this.fileDependencies = {
421
+ fileDependencies: Array.from(
422
+ childCompilation.fileDependencies,
423
+ ),
424
+ contextDependencies: Array.from(
425
+ childCompilation.contextDependencies,
426
+ ),
427
+ missingDependencies: Array.from(
428
+ childCompilation.missingDependencies,
429
+ ),
430
+ };
431
+ }
432
+ if (
433
+ childCompilation &&
434
+ childCompilation.errors &&
435
+ childCompilation.errors.length
436
+ ) {
437
+ const errorDetails = childCompilation.errors
438
+ .map((error) => {
439
+ let message = error.message;
440
+ if (error.stack) {
441
+ message += "\n" + error.stack;
442
+ }
443
+ return message;
444
+ })
445
+ .join("\n");
446
+ reject(new Error("Child compilation failed:\n" + errorDetails));
447
+ return;
448
+ }
449
+ if (err) {
450
+ reject(err);
451
+ return;
452
+ }
453
+ if (!childCompilation || !entries) {
454
+ reject(new Error("Empty child compilation"));
455
+ return;
456
+ }
457
+ const result = {};
458
+ const assets = {};
459
+ for (const asset of childCompilation.getAssets()) {
460
+ assets[asset.name] = { source: asset.source, info: asset.info };
461
+ }
462
+ compiledTemplates.forEach((templateSource, entryIndex) => {
463
+ result[this.templates[entryIndex]] = {
464
+ content: templateSource,
465
+ hash: childCompilation.hash || "XXXX",
466
+ entry: entries[entryIndex],
467
+ assets,
468
+ };
469
+ });
470
+ this.compilationEndedTimestamp = Date.now();
471
+ resolve(result);
472
+ });
473
+ });
474
+ return this.compilationPromise;
475
+ }
476
+ }
477
+ module.exports = { HtmlWebpackChildCompiler };
478
+ },
479
+ 876: (module) => {
480
+ "use strict";
481
+ function none(chunks) {
482
+ return chunks;
483
+ }
484
+ function manual(entryPointNames, compilation, htmlRspackPluginOptions) {
485
+ const chunks = htmlRspackPluginOptions.chunks;
486
+ if (!Array.isArray(chunks)) {
487
+ return entryPointNames;
488
+ }
489
+ return chunks.filter((entryPointName) =>
490
+ compilation.entrypoints.has(entryPointName),
491
+ );
492
+ }
493
+ module.exports = { auto: none, manual, none };
494
+ },
495
+ 123: (module) => {
496
+ "use strict";
497
+ module.exports = function (err) {
498
+ return {
499
+ toHtml: function () {
500
+ return (
501
+ "[html-rspack-plugin]:\n<pre>\n" + this.toString() + "</pre>"
502
+ );
503
+ },
504
+ toJsonHtml: function () {
505
+ return JSON.stringify(this.toHtml());
506
+ },
507
+ toString: function () {
508
+ if (err.message) {
509
+ return (
510
+ `[html-rspack-plugin]: ` +
511
+ (err.stack || `${err.name}: ${err.message}`)
512
+ );
513
+ }
514
+ return err;
515
+ },
516
+ };
517
+ };
518
+ },
519
+ 90: (module, __unused_webpack_exports, __nccwpck_require__) => {
520
+ "use strict";
521
+ const { AsyncSeriesWaterfallHook } = __nccwpck_require__(176);
522
+ const htmlWebpackPluginHooksMap = new WeakMap();
523
+ function getHtmlRspackPluginHooks(compilation) {
524
+ let hooks = htmlWebpackPluginHooksMap.get(compilation);
525
+ if (hooks === undefined) {
526
+ hooks = createHtmlRspackPluginHooks();
527
+ htmlWebpackPluginHooksMap.set(compilation, hooks);
528
+ }
529
+ return hooks;
530
+ }
531
+ function createHtmlRspackPluginHooks() {
532
+ return {
533
+ beforeAssetTagGeneration: new AsyncSeriesWaterfallHook([
534
+ "pluginArgs",
535
+ ]),
536
+ alterAssetTags: new AsyncSeriesWaterfallHook(["pluginArgs"]),
537
+ alterAssetTagGroups: new AsyncSeriesWaterfallHook(["pluginArgs"]),
538
+ afterTemplateExecution: new AsyncSeriesWaterfallHook(["pluginArgs"]),
539
+ beforeEmit: new AsyncSeriesWaterfallHook(["pluginArgs"]),
540
+ afterEmit: new AsyncSeriesWaterfallHook(["pluginArgs"]),
541
+ };
542
+ }
543
+ module.exports = { getHtmlRspackPluginHooks };
544
+ },
545
+ 527: (module) => {
546
+ const voidTags = [
547
+ "area",
548
+ "base",
549
+ "br",
550
+ "col",
551
+ "embed",
552
+ "hr",
553
+ "img",
554
+ "input",
555
+ "keygen",
556
+ "link",
557
+ "meta",
558
+ "param",
559
+ "source",
560
+ "track",
561
+ "wbr",
562
+ ];
563
+ function htmlTagObjectToString(tagDefinition, xhtml) {
564
+ const attributes = Object.keys(tagDefinition.attributes || {})
565
+ .filter(function (attributeName) {
566
+ return (
567
+ tagDefinition.attributes[attributeName] === "" ||
568
+ tagDefinition.attributes[attributeName]
569
+ );
570
+ })
571
+ .map(function (attributeName) {
572
+ if (tagDefinition.attributes[attributeName] === true) {
573
+ return xhtml
574
+ ? attributeName + '="' + attributeName + '"'
575
+ : attributeName;
576
+ }
577
+ return (
578
+ attributeName +
579
+ '="' +
580
+ tagDefinition.attributes[attributeName] +
581
+ '"'
582
+ );
583
+ });
584
+ return (
585
+ "<" +
586
+ [tagDefinition.tagName].concat(attributes).join(" ") +
587
+ (tagDefinition.voidTag && xhtml ? "/" : "") +
588
+ ">" +
589
+ (tagDefinition.innerHTML || "") +
590
+ (tagDefinition.voidTag ? "" : "</" + tagDefinition.tagName + ">")
591
+ );
592
+ }
593
+ function createHtmlTagObject(tagName, attributes, innerHTML, meta) {
594
+ return {
595
+ tagName,
596
+ voidTag: voidTags.indexOf(tagName) !== -1,
597
+ attributes: attributes || {},
598
+ meta: meta || {},
599
+ innerHTML,
600
+ };
601
+ }
602
+ class HtmlTagArray extends Array {
603
+ toString() {
604
+ return this.join("");
605
+ }
606
+ }
607
+ module.exports = {
608
+ HtmlTagArray,
609
+ createHtmlTagObject,
610
+ htmlTagObjectToString,
611
+ };
612
+ },
613
+ 718: (module, __unused_webpack_exports, __nccwpck_require__) => {
614
+ "use strict";
615
+ const promisify = __nccwpck_require__(23).promisify;
616
+ const vm = __nccwpck_require__(154);
617
+ const fs = __nccwpck_require__(896);
618
+ const path = __nccwpck_require__(928);
619
+ const { CachedChildCompilation } = __nccwpck_require__(535);
620
+ const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
621
+ __nccwpck_require__(527);
622
+ const prettyError = __nccwpck_require__(123);
623
+ const chunkSorter = __nccwpck_require__(876);
624
+ const getHtmlRspackPluginHooks =
625
+ __nccwpck_require__(90).getHtmlRspackPluginHooks;
626
+ const WITH_PLACEHOLDER = "function __with_placeholder__";
627
+ class HtmlRspackPlugin {
628
+ constructor(userOptions = {}) {
629
+ this.version = HtmlRspackPlugin.version;
630
+ const defaultOptions = {
631
+ template: "auto",
632
+ templateContent: false,
633
+ templateParameters: templateParametersGenerator,
634
+ filename:
635
+ userOptions.filename === undefined
636
+ ? "index.html"
637
+ : userOptions.filename,
638
+ publicPath:
639
+ userOptions.publicPath === undefined
640
+ ? "auto"
641
+ : userOptions.publicPath,
642
+ hash: false,
643
+ inject: userOptions.scriptLoading === "blocking" ? "body" : "head",
644
+ scriptLoading: "defer",
645
+ compile: true,
646
+ favicon: false,
647
+ cache: true,
648
+ showErrors: true,
649
+ chunks: "all",
650
+ excludeChunks: [],
651
+ chunksSortMode: "auto",
652
+ meta: {},
653
+ base: false,
654
+ title: "Rspack App",
655
+ xhtml: false,
656
+ };
657
+ this.options = Object.assign(defaultOptions, userOptions);
658
+ }
659
+ apply(compiler) {
660
+ this.logger = compiler.getInfrastructureLogger("HtmlRspackPlugin");
661
+ compiler.hooks.initialize.tap("HtmlRspackPlugin", () => {
662
+ const options = this.options;
663
+ options.template = this.getTemplatePath(
664
+ this.options.template,
665
+ compiler.context,
666
+ );
667
+ if (
668
+ options.scriptLoading !== "defer" &&
669
+ options.scriptLoading !== "blocking" &&
670
+ options.scriptLoading !== "module" &&
671
+ options.scriptLoading !== "systemjs-module"
672
+ ) {
673
+ this.logger.error(
674
+ 'The "scriptLoading" option need to be set to "defer", "blocking" or "module" or "systemjs-module"',
675
+ );
676
+ }
677
+ if (
678
+ options.inject !== true &&
679
+ options.inject !== false &&
680
+ options.inject !== "head" &&
681
+ options.inject !== "body"
682
+ ) {
683
+ this.logger.error(
684
+ 'The `inject` option needs to be set to true, false, "head" or "body',
685
+ );
686
+ }
687
+ if (
688
+ this.options.templateParameters !== false &&
689
+ typeof this.options.templateParameters !== "function" &&
690
+ typeof this.options.templateParameters !== "object"
691
+ ) {
692
+ this.logger.error(
693
+ "The `templateParameters` has to be either a function or an object or false",
694
+ );
695
+ }
696
+ const userOptionFilename = this.options.filename;
697
+ const filenameFunction =
698
+ typeof userOptionFilename === "function"
699
+ ? userOptionFilename
700
+ : (entryName) =>
701
+ userOptionFilename.replace(/\[name\]/g, entryName);
702
+ const entryNames = Object.keys(compiler.options.entry);
703
+ const outputFileNames = new Set(
704
+ (entryNames.length ? entryNames : ["main"]).map(filenameFunction),
705
+ );
706
+ outputFileNames.forEach((outputFileName) => {
707
+ const assetJson = { value: undefined };
708
+ const previousEmittedAssets = [];
709
+ let childCompilerPlugin;
710
+ if (!this.options.templateContent) {
711
+ childCompilerPlugin = new CachedChildCompilation(compiler);
712
+ childCompilerPlugin.addEntry(this.options.template);
713
+ }
714
+ let filename = outputFileName;
715
+ if (path.resolve(filename) === path.normalize(filename)) {
716
+ const outputPath = compiler.options.output.path;
717
+ filename = path.relative(outputPath, filename);
718
+ }
719
+ compiler.hooks.thisCompilation.tap(
720
+ "HtmlRspackPlugin",
721
+ (compilation) => {
722
+ compilation.hooks.processAssets.tapAsync(
723
+ {
724
+ name: "HtmlRspackPlugin",
725
+ stage:
726
+ compiler.webpack.Compilation
727
+ .PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE,
728
+ },
729
+ (_, callback) => {
730
+ this.generateHTML(
731
+ compiler,
732
+ compilation,
733
+ filename,
734
+ childCompilerPlugin,
735
+ previousEmittedAssets,
736
+ assetJson,
737
+ callback,
738
+ );
739
+ },
740
+ );
741
+ },
742
+ );
743
+ });
744
+ });
745
+ }
746
+ getTemplatePath(template, context) {
747
+ if (template === "auto") {
748
+ template = path.resolve(context, "src/index.ejs");
749
+ if (!fs.existsSync(template)) {
750
+ template = __nccwpck_require__.ab + "default_index.ejs";
751
+ }
752
+ }
753
+ if (template.indexOf("!") === -1) {
754
+ const loader = __nccwpck_require__.ab + "htmlLoader.js";
755
+ template = loader + "!" + path.resolve(context, template);
756
+ }
757
+ return template.replace(
758
+ /([!])([^/\\][^!?]+|[^/\\!?])($|\?[^!?\n]+$)/,
759
+ (match, prefix, filepath, postfix) =>
760
+ prefix + path.resolve(filepath) + postfix,
761
+ );
762
+ }
763
+ filterEntryChunks(chunks, includedChunks, excludedChunks) {
764
+ return chunks.filter((chunkName) => {
765
+ if (
766
+ Array.isArray(includedChunks) &&
767
+ includedChunks.indexOf(chunkName) === -1
768
+ ) {
769
+ return false;
770
+ }
771
+ if (
772
+ Array.isArray(excludedChunks) &&
773
+ excludedChunks.indexOf(chunkName) !== -1
774
+ ) {
775
+ return false;
776
+ }
777
+ return true;
778
+ });
779
+ }
780
+ sortEntryChunks(entryNames, sortMode, compilation) {
781
+ if (typeof sortMode === "function") {
782
+ return entryNames.sort(sortMode);
783
+ }
784
+ if (typeof chunkSorter[sortMode] !== "undefined") {
785
+ return chunkSorter[sortMode](entryNames, compilation, this.options);
786
+ }
787
+ throw new Error('"' + sortMode + '" is not a valid chunk sort mode');
788
+ }
789
+ urlencodePath(filePath) {
790
+ const queryStringStart = filePath.indexOf("?");
791
+ const urlPath =
792
+ queryStringStart === -1
793
+ ? filePath
794
+ : filePath.substr(0, queryStringStart);
795
+ const queryString = filePath.substr(urlPath.length);
796
+ const encodedUrlPath = urlPath
797
+ .split("/")
798
+ .map(encodeURIComponent)
799
+ .join("/");
800
+ return encodedUrlPath + queryString;
801
+ }
802
+ appendHash(url, hash) {
803
+ if (!url) {
804
+ return url;
805
+ }
806
+ return url + (url.indexOf("?") === -1 ? "?" : "&") + hash;
807
+ }
808
+ getPublicPath(compilation, filename, customPublicPath) {
809
+ const webpackPublicPath = compilation.getAssetPath(
810
+ compilation.outputOptions.publicPath,
811
+ { hash: compilation.hash },
812
+ );
813
+ const isPublicPathDefined = webpackPublicPath !== "auto";
814
+ const outputPath = compilation.options.output.path;
815
+ let publicPath =
816
+ customPublicPath !== "auto"
817
+ ? customPublicPath
818
+ : isPublicPathDefined
819
+ ? webpackPublicPath
820
+ : path
821
+ .relative(
822
+ path.resolve(outputPath, path.dirname(filename)),
823
+ outputPath,
824
+ )
825
+ .split(path.sep)
826
+ .join("/");
827
+ if (publicPath.length && publicPath.substr(-1, 1) !== "/") {
828
+ publicPath += "/";
829
+ }
830
+ return publicPath;
831
+ }
832
+ getAssetsInformationByGroups(
833
+ compilation,
834
+ outputName,
835
+ entryNames,
836
+ entrypoints,
837
+ ) {
838
+ const publicPath = this.getPublicPath(
839
+ compilation,
840
+ outputName,
841
+ this.options.publicPath,
842
+ );
843
+ const assets = { publicPath, js: [], css: [], favicon: undefined };
844
+ const entryPointPublicPathMap = {};
845
+ const extensionRegexp = /\.(css|js|mjs)(\?|$)/;
846
+ for (let i = 0; i < entryNames.length; i++) {
847
+ const entryName = entryNames[i];
848
+ const entryPointUnfilteredFiles = entrypoints
849
+ .get(entryName)
850
+ .getFiles();
851
+ const entryPointFiles = entryPointUnfilteredFiles.filter(
852
+ (chunkFile) => {
853
+ const asset = compilation.getAsset(chunkFile);
854
+ if (!asset) {
855
+ return true;
856
+ }
857
+ const assetMetaInformation = asset.info || {};
858
+ return !(
859
+ assetMetaInformation.hotModuleReplacement ||
860
+ assetMetaInformation.development
861
+ );
862
+ },
863
+ );
864
+ const entryPointPublicPaths = entryPointFiles.map((chunkFile) => {
865
+ const entryPointPublicPath =
866
+ publicPath + this.urlencodePath(chunkFile);
867
+ return this.options.hash
868
+ ? this.appendHash(entryPointPublicPath, compilation.hash)
869
+ : entryPointPublicPath;
870
+ });
871
+ entryPointPublicPaths.forEach((entryPointPublicPath) => {
872
+ const extMatch = extensionRegexp.exec(entryPointPublicPath);
873
+ if (!extMatch) {
874
+ return;
875
+ }
876
+ if (entryPointPublicPathMap[entryPointPublicPath]) {
877
+ return;
878
+ }
879
+ entryPointPublicPathMap[entryPointPublicPath] = true;
880
+ const ext = extMatch[1] === "mjs" ? "js" : extMatch[1];
881
+ assets[ext].push(entryPointPublicPath);
882
+ });
883
+ }
884
+ return assets;
885
+ }
886
+ evaluateCompilationResult(source, publicPath, templateFilename) {
887
+ if (!source) {
888
+ return Promise.reject(
889
+ new Error("The child compilation didn't provide a result"),
890
+ );
891
+ }
892
+ if (source.indexOf(WITH_PLACEHOLDER) >= 0) {
893
+ source = source.replace(WITH_PLACEHOLDER, "with");
894
+ }
895
+ if (source.indexOf("HTML_WEBPACK_PLUGIN_RESULT") >= 0) {
896
+ source += ";\nHTML_WEBPACK_PLUGIN_RESULT";
897
+ }
898
+ const templateWithoutLoaders = templateFilename
899
+ .replace(/^.+!/, "")
900
+ .replace(/\?.+$/, "");
901
+ const globalClone = Object.create(
902
+ Object.getPrototypeOf(global),
903
+ Object.getOwnPropertyDescriptors(global),
904
+ );
905
+ delete globalClone.eval;
906
+ const vmContext = vm.createContext(
907
+ Object.assign(globalClone, {
908
+ HTML_WEBPACK_PLUGIN: true,
909
+ require,
910
+ htmlWebpackPluginPublicPath: publicPath,
911
+ __filename: templateWithoutLoaders,
912
+ __dirname: path.dirname(templateWithoutLoaders),
913
+ }),
914
+ );
915
+ const vmScript = new vm.Script(source, {
916
+ filename: templateWithoutLoaders,
917
+ });
918
+ let newSource;
919
+ try {
920
+ newSource = vmScript.runInContext(vmContext);
921
+ } catch (e) {
922
+ return Promise.reject(e);
923
+ }
924
+ if (
925
+ typeof newSource === "object" &&
926
+ newSource.__esModule &&
927
+ newSource.default
928
+ ) {
929
+ newSource = newSource.default;
930
+ }
931
+ return typeof newSource === "string" ||
932
+ typeof newSource === "function"
933
+ ? Promise.resolve(newSource)
934
+ : Promise.reject(
935
+ new Error(
936
+ 'The loader "' +
937
+ templateWithoutLoaders +
938
+ "\" didn't return html.",
939
+ ),
940
+ );
941
+ }
942
+ prepareAssetTagGroupForRendering(assetTagGroup) {
943
+ const xhtml = this.options.xhtml;
944
+ return HtmlTagArray.from(
945
+ assetTagGroup.map((assetTag) => {
946
+ const copiedAssetTag = Object.assign({}, assetTag);
947
+ copiedAssetTag.toString = function () {
948
+ return htmlTagObjectToString(this, xhtml);
949
+ };
950
+ return copiedAssetTag;
951
+ }),
952
+ );
953
+ }
954
+ getTemplateParameters(
955
+ compilation,
956
+ assetsInformationByGroups,
957
+ assetTags,
958
+ ) {
959
+ const templateParameters = this.options.templateParameters;
960
+ if (templateParameters === false) {
961
+ return Promise.resolve({});
962
+ }
963
+ if (
964
+ typeof templateParameters !== "function" &&
965
+ typeof templateParameters !== "object"
966
+ ) {
967
+ throw new Error(
968
+ "templateParameters has to be either a function or an object",
969
+ );
970
+ }
971
+ const templateParameterFunction =
972
+ typeof templateParameters === "function"
973
+ ? templateParameters
974
+ : (compilation, assetsInformationByGroups, assetTags, options) =>
975
+ Object.assign(
976
+ {},
977
+ templateParametersGenerator(
978
+ compilation,
979
+ assetsInformationByGroups,
980
+ assetTags,
981
+ options,
982
+ ),
983
+ templateParameters,
984
+ );
985
+ const preparedAssetTags = {
986
+ headTags: this.prepareAssetTagGroupForRendering(assetTags.headTags),
987
+ bodyTags: this.prepareAssetTagGroupForRendering(assetTags.bodyTags),
988
+ };
989
+ return Promise.resolve().then(() =>
990
+ templateParameterFunction(
991
+ compilation,
992
+ assetsInformationByGroups,
993
+ preparedAssetTags,
994
+ this.options,
995
+ ),
996
+ );
997
+ }
998
+ executeTemplate(
999
+ templateFunction,
1000
+ assetsInformationByGroups,
1001
+ assetTags,
1002
+ compilation,
1003
+ ) {
1004
+ const templateParamsPromise = this.getTemplateParameters(
1005
+ compilation,
1006
+ assetsInformationByGroups,
1007
+ assetTags,
1008
+ );
1009
+ return templateParamsPromise.then((templateParams) => {
1010
+ try {
1011
+ return templateFunction(templateParams);
1012
+ } catch (e) {
1013
+ compilation.errors.push(
1014
+ new Error("Template execution failed: " + e),
1015
+ );
1016
+ return Promise.reject(e);
1017
+ }
1018
+ });
1019
+ }
1020
+ postProcessHtml(
1021
+ compiler,
1022
+ originalHtml,
1023
+ assetsInformationByGroups,
1024
+ assetTags,
1025
+ ) {
1026
+ let html = originalHtml;
1027
+ if (typeof html !== "string") {
1028
+ return Promise.reject(
1029
+ new Error(
1030
+ "Expected html to be a string but got " + JSON.stringify(html),
1031
+ ),
1032
+ );
1033
+ }
1034
+ if (this.options.inject) {
1035
+ const htmlRegExp = /(<html[^>]*>)/i;
1036
+ const headRegExp = /(<\/head\s*>)/i;
1037
+ const bodyRegExp = /(<\/body\s*>)/i;
1038
+ const doctypeRegExp = /<!doctype html>/i;
1039
+ const metaViewportRegExp = /<meta[^>]+name=["']viewport["'][^>]*>/i;
1040
+ const body = assetTags.bodyTags.map((assetTagObject) =>
1041
+ htmlTagObjectToString(assetTagObject, this.options.xhtml),
1042
+ );
1043
+ const head = assetTags.headTags
1044
+ .filter((item) => {
1045
+ if (
1046
+ item.tagName === "meta" &&
1047
+ item.attributes &&
1048
+ item.attributes.name === "viewport" &&
1049
+ metaViewportRegExp.test(html)
1050
+ ) {
1051
+ return false;
1052
+ }
1053
+ return true;
1054
+ })
1055
+ .map((assetTagObject) =>
1056
+ htmlTagObjectToString(assetTagObject, this.options.xhtml),
1057
+ );
1058
+ if (body.length) {
1059
+ if (bodyRegExp.test(html)) {
1060
+ html = html.replace(
1061
+ bodyRegExp,
1062
+ (match) => body.join("") + match,
1063
+ );
1064
+ } else {
1065
+ html += body.join("");
1066
+ }
1067
+ }
1068
+ if (head.length) {
1069
+ if (!headRegExp.test(html)) {
1070
+ if (!htmlRegExp.test(html)) {
1071
+ if (doctypeRegExp.test(html)) {
1072
+ html = html.replace(
1073
+ doctypeRegExp,
1074
+ (match) => match + "<head></head>",
1075
+ );
1076
+ } else {
1077
+ html = "<head></head>" + html;
1078
+ }
1079
+ } else {
1080
+ html = html.replace(
1081
+ htmlRegExp,
1082
+ (match) => match + "<head></head>",
1083
+ );
1084
+ }
1085
+ }
1086
+ html = html.replace(headRegExp, (match) => head.join("") + match);
1087
+ }
1088
+ }
1089
+ const isProductionLikeMode =
1090
+ compiler.options.mode === "production" || !compiler.options.mode;
1091
+ const minify = this.options.minify;
1092
+ const needMinify =
1093
+ typeof minify === "function" && isProductionLikeMode;
1094
+ if (!needMinify) {
1095
+ return Promise.resolve(html);
1096
+ }
1097
+ return Promise.resolve(minify(html));
1098
+ }
1099
+ getAssetFiles(assets) {
1100
+ const uniq = (arr) => Array.from(new Set(arr));
1101
+ const files = uniq(
1102
+ Object.keys(assets)
1103
+ .filter(
1104
+ (assetType) => assetType !== "chunks" && assets[assetType],
1105
+ )
1106
+ .reduce(
1107
+ (files, assetType) => files.concat(assets[assetType]),
1108
+ [],
1109
+ ),
1110
+ );
1111
+ files.sort();
1112
+ return files;
1113
+ }
1114
+ generateFavicon(
1115
+ compiler,
1116
+ favicon,
1117
+ compilation,
1118
+ publicPath,
1119
+ previousEmittedAssets,
1120
+ ) {
1121
+ if (!favicon) {
1122
+ return Promise.resolve(undefined);
1123
+ }
1124
+ const filename = path.resolve(compilation.compiler.context, favicon);
1125
+ const inputFileSystem = compilation.inputFileSystem;
1126
+ return promisify(inputFileSystem.readFile)(filename)
1127
+ .then((buf) => {
1128
+ const source = new compiler.webpack.sources.RawSource(buf, false);
1129
+ const name = path.basename(filename);
1130
+ compilation.fileDependencies.add(filename);
1131
+ compilation.emitAsset(name, source);
1132
+ previousEmittedAssets.push({ name, source });
1133
+ const faviconPath = publicPath + name;
1134
+ if (this.options.hash) {
1135
+ return this.appendHash(faviconPath, compilation.hash);
1136
+ }
1137
+ return faviconPath;
1138
+ })
1139
+ .catch(() =>
1140
+ Promise.reject(
1141
+ new Error("HtmlRspackPlugin: could not load file " + filename),
1142
+ ),
1143
+ );
1144
+ }
1145
+ generatedScriptTags(jsAssets) {
1146
+ return jsAssets.map((src) => {
1147
+ const attributes = {};
1148
+ if (this.options.scriptLoading === "defer") {
1149
+ attributes.defer = true;
1150
+ } else if (this.options.scriptLoading === "module") {
1151
+ attributes.type = "module";
1152
+ } else if (this.options.scriptLoading === "systemjs-module") {
1153
+ attributes.type = "systemjs-module";
1154
+ }
1155
+ attributes.src = src;
1156
+ return {
1157
+ tagName: "script",
1158
+ voidTag: false,
1159
+ meta: { plugin: "html-webpack-plugin" },
1160
+ attributes,
1161
+ };
1162
+ });
1163
+ }
1164
+ generateStyleTags(cssAssets) {
1165
+ return cssAssets.map((styleAsset) => ({
1166
+ tagName: "link",
1167
+ voidTag: true,
1168
+ meta: { plugin: "html-webpack-plugin" },
1169
+ attributes: { href: styleAsset, rel: "stylesheet" },
1170
+ }));
1171
+ }
1172
+ generateBaseTag(base) {
1173
+ return [
1174
+ {
1175
+ tagName: "base",
1176
+ voidTag: true,
1177
+ meta: { plugin: "html-webpack-plugin" },
1178
+ attributes: typeof base === "string" ? { href: base } : base,
1179
+ },
1180
+ ];
1181
+ }
1182
+ generatedMetaTags(metaOptions) {
1183
+ if (metaOptions === false) {
1184
+ return [];
1185
+ }
1186
+ const metaTagAttributeObjects = Object.keys(metaOptions)
1187
+ .map((metaName) => {
1188
+ const metaTagContent = metaOptions[metaName];
1189
+ return typeof metaTagContent === "string"
1190
+ ? { name: metaName, content: metaTagContent }
1191
+ : metaTagContent;
1192
+ })
1193
+ .filter((attribute) => attribute !== false);
1194
+ return metaTagAttributeObjects.map((metaTagAttributes) => ({
1195
+ tagName: "meta",
1196
+ voidTag: true,
1197
+ meta: { plugin: "html-webpack-plugin" },
1198
+ attributes: metaTagAttributes,
1199
+ }));
1200
+ }
1201
+ generateFaviconTag(favicon) {
1202
+ return [
1203
+ {
1204
+ tagName: "link",
1205
+ voidTag: true,
1206
+ meta: { plugin: "html-webpack-plugin" },
1207
+ attributes: { rel: "icon", href: favicon },
1208
+ },
1209
+ ];
1210
+ }
1211
+ groupAssetsByElements(assetTags, scriptTarget) {
1212
+ const result = {
1213
+ headTags: [...assetTags.meta, ...assetTags.styles],
1214
+ bodyTags: [],
1215
+ };
1216
+ if (scriptTarget === "body") {
1217
+ result.bodyTags.push(...assetTags.scripts);
1218
+ } else {
1219
+ const insertPosition =
1220
+ this.options.scriptLoading === "blocking"
1221
+ ? result.headTags.length
1222
+ : assetTags.meta.length;
1223
+ result.headTags.splice(insertPosition, 0, ...assetTags.scripts);
1224
+ }
1225
+ return result;
1226
+ }
1227
+ replacePlaceholdersInFilename(
1228
+ compiler,
1229
+ filename,
1230
+ fileContent,
1231
+ compilation,
1232
+ ) {
1233
+ if (/\[(?:[\w:]+)\]/.test(filename) === false) {
1234
+ return { path: filename, info: {} };
1235
+ }
1236
+ const hash = compiler.webpack.util.createHash(
1237
+ compilation.outputOptions.hashFunction,
1238
+ );
1239
+ if (typeof fileContent === "string") {
1240
+ hash.update(fileContent, "utf8");
1241
+ } else {
1242
+ hash.update(fileContent);
1243
+ }
1244
+ if (compilation.outputOptions.hashSalt) {
1245
+ hash.update(compilation.outputOptions.hashSalt, "utf8");
1246
+ }
1247
+ const contentHash = hash
1248
+ .digest(compilation.outputOptions.hashDigest)
1249
+ .slice(0, compilation.outputOptions.hashDigestLength);
1250
+ return compilation.getPathWithInfo(filename, {
1251
+ contentHash,
1252
+ chunk: { hash: contentHash, contentHash },
1253
+ });
1254
+ }
1255
+ generateHTML(
1256
+ compiler,
1257
+ compilation,
1258
+ outputName,
1259
+ childCompilerPlugin,
1260
+ previousEmittedAssets,
1261
+ assetJson,
1262
+ callback,
1263
+ ) {
1264
+ const { entrypoints } = compilation;
1265
+ const entryNames = Array.from(entrypoints.keys());
1266
+ const filteredEntryNames = this.filterEntryChunks(
1267
+ entryNames,
1268
+ this.options.chunks,
1269
+ this.options.excludeChunks,
1270
+ );
1271
+ const sortedEntryNames = this.sortEntryChunks(
1272
+ filteredEntryNames,
1273
+ this.options.chunksSortMode,
1274
+ compilation,
1275
+ );
1276
+ const templateResult = this.options.templateContent
1277
+ ? { mainCompilationHash: compilation.hash }
1278
+ : childCompilerPlugin.getCompilationEntryResult(
1279
+ this.options.template,
1280
+ );
1281
+ if ("error" in templateResult) {
1282
+ compilation.errors.push(
1283
+ prettyError(templateResult.error).toString(),
1284
+ );
1285
+ }
1286
+ const isCompilationCached =
1287
+ templateResult.mainCompilationHash !== compilation.hash;
1288
+ const assetsInformationByGroups = this.getAssetsInformationByGroups(
1289
+ compilation,
1290
+ outputName,
1291
+ sortedEntryNames,
1292
+ entrypoints,
1293
+ );
1294
+ const newAssetJson = JSON.stringify(
1295
+ this.getAssetFiles(assetsInformationByGroups),
1296
+ );
1297
+ if (
1298
+ isCompilationCached &&
1299
+ this.options.cache &&
1300
+ assetJson.value === newAssetJson
1301
+ ) {
1302
+ previousEmittedAssets.forEach(({ name, source, info }) => {
1303
+ compilation.emitAsset(name, source, info);
1304
+ });
1305
+ return callback();
1306
+ } else {
1307
+ previousEmittedAssets.length = 0;
1308
+ assetJson.value = newAssetJson;
1309
+ }
1310
+ const assetsPromise = this.generateFavicon(
1311
+ compiler,
1312
+ this.options.favicon,
1313
+ compilation,
1314
+ assetsInformationByGroups.publicPath,
1315
+ previousEmittedAssets,
1316
+ ).then((faviconPath) => {
1317
+ assetsInformationByGroups.favicon = faviconPath;
1318
+ return getHtmlRspackPluginHooks(
1319
+ compilation,
1320
+ ).beforeAssetTagGeneration.promise({
1321
+ assets: assetsInformationByGroups,
1322
+ outputName,
1323
+ plugin: this,
1324
+ });
1325
+ });
1326
+ const assetTagGroupsPromise = assetsPromise
1327
+ .then(({ assets }) =>
1328
+ getHtmlRspackPluginHooks(compilation).alterAssetTags.promise({
1329
+ assetTags: {
1330
+ scripts: this.generatedScriptTags(assets.js),
1331
+ styles: this.generateStyleTags(assets.css),
1332
+ meta: [
1333
+ ...(this.options.base !== false
1334
+ ? this.generateBaseTag(this.options.base)
1335
+ : []),
1336
+ ...this.generatedMetaTags(this.options.meta),
1337
+ ...(assets.favicon
1338
+ ? this.generateFaviconTag(assets.favicon)
1339
+ : []),
1340
+ ],
1341
+ },
1342
+ outputName,
1343
+ publicPath: assetsInformationByGroups.publicPath,
1344
+ plugin: this,
1345
+ }),
1346
+ )
1347
+ .then(({ assetTags }) => {
1348
+ const scriptTarget =
1349
+ this.options.inject === "head" ||
1350
+ (this.options.inject !== "body" &&
1351
+ this.options.scriptLoading !== "blocking")
1352
+ ? "head"
1353
+ : "body";
1354
+ const assetGroups = this.groupAssetsByElements(
1355
+ assetTags,
1356
+ scriptTarget,
1357
+ );
1358
+ return getHtmlRspackPluginHooks(
1359
+ compilation,
1360
+ ).alterAssetTagGroups.promise({
1361
+ headTags: assetGroups.headTags,
1362
+ bodyTags: assetGroups.bodyTags,
1363
+ outputName,
1364
+ publicPath: assetsInformationByGroups.publicPath,
1365
+ plugin: this,
1366
+ });
1367
+ });
1368
+ const templateEvaluationPromise = Promise.resolve().then(() => {
1369
+ if ("error" in templateResult) {
1370
+ return this.options.showErrors
1371
+ ? prettyError(templateResult.error).toHtml()
1372
+ : "ERROR";
1373
+ }
1374
+ if (this.options.templateContent !== false) {
1375
+ return this.options.templateContent;
1376
+ }
1377
+ if ("compiledEntry" in templateResult) {
1378
+ const compiledEntry = templateResult.compiledEntry;
1379
+ const assets = compiledEntry.assets;
1380
+ for (const name in assets) {
1381
+ previousEmittedAssets.push({
1382
+ name,
1383
+ source: assets[name].source,
1384
+ info: assets[name].info,
1385
+ });
1386
+ }
1387
+ return this.evaluateCompilationResult(
1388
+ compiledEntry.content,
1389
+ assetsInformationByGroups.publicPath,
1390
+ this.options.template,
1391
+ );
1392
+ }
1393
+ return Promise.reject(
1394
+ new Error("Child compilation contained no compiledEntry"),
1395
+ );
1396
+ });
1397
+ const templateExectutionPromise = Promise.all([
1398
+ assetsPromise,
1399
+ assetTagGroupsPromise,
1400
+ templateEvaluationPromise,
1401
+ ]).then(([assetsHookResult, assetTags, compilationResult]) =>
1402
+ typeof compilationResult !== "function"
1403
+ ? compilationResult
1404
+ : this.executeTemplate(
1405
+ compilationResult,
1406
+ assetsHookResult.assets,
1407
+ {
1408
+ headTags: assetTags.headTags,
1409
+ bodyTags: assetTags.bodyTags,
1410
+ },
1411
+ compilation,
1412
+ ),
1413
+ );
1414
+ const injectedHtmlPromise = Promise.all([
1415
+ assetTagGroupsPromise,
1416
+ templateExectutionPromise,
1417
+ ])
1418
+ .then(([assetTags, html]) => {
1419
+ const pluginArgs = {
1420
+ html,
1421
+ headTags: assetTags.headTags,
1422
+ bodyTags: assetTags.bodyTags,
1423
+ plugin: this,
1424
+ outputName,
1425
+ };
1426
+ return getHtmlRspackPluginHooks(
1427
+ compilation,
1428
+ ).afterTemplateExecution.promise(pluginArgs);
1429
+ })
1430
+ .then(({ html, headTags, bodyTags }) =>
1431
+ this.postProcessHtml(compiler, html, assetsInformationByGroups, {
1432
+ headTags,
1433
+ bodyTags,
1434
+ }),
1435
+ );
1436
+ const emitHtmlPromise = injectedHtmlPromise
1437
+ .then((html) => {
1438
+ const pluginArgs = { html, plugin: this, outputName };
1439
+ return getHtmlRspackPluginHooks(compilation)
1440
+ .beforeEmit.promise(pluginArgs)
1441
+ .then((result) => result.html);
1442
+ })
1443
+ .catch((err) => {
1444
+ compilation.errors.push(prettyError(err).toString());
1445
+ return this.options.showErrors
1446
+ ? prettyError(err).toHtml()
1447
+ : "ERROR";
1448
+ })
1449
+ .then((html) => {
1450
+ const filename = outputName;
1451
+ const replacedFilename = this.replacePlaceholdersInFilename(
1452
+ compiler,
1453
+ filename,
1454
+ html,
1455
+ compilation,
1456
+ );
1457
+ const source = new compiler.webpack.sources.RawSource(
1458
+ html,
1459
+ false,
1460
+ );
1461
+ compilation.emitAsset(
1462
+ replacedFilename.path,
1463
+ source,
1464
+ replacedFilename.info,
1465
+ );
1466
+ previousEmittedAssets.push({
1467
+ name: replacedFilename.path,
1468
+ source,
1469
+ });
1470
+ return replacedFilename.path;
1471
+ })
1472
+ .then((finalOutputName) =>
1473
+ getHtmlRspackPluginHooks(compilation)
1474
+ .afterEmit.promise({
1475
+ outputName: finalOutputName,
1476
+ plugin: this,
1477
+ })
1478
+ .catch((err) => {
1479
+ this.logger.error(err);
1480
+ return null;
1481
+ })
1482
+ .then(() => null),
1483
+ );
1484
+ emitHtmlPromise.then(() => {
1485
+ callback();
1486
+ });
1487
+ }
1488
+ }
1489
+ function templateParametersGenerator(
1490
+ compilation,
1491
+ assets,
1492
+ assetTags,
1493
+ options,
1494
+ ) {
1495
+ return {
1496
+ compilation,
1497
+ webpackConfig: compilation.options,
1498
+ htmlWebpackPlugin: { tags: assetTags, files: assets, options },
1499
+ };
1500
+ }
1501
+ HtmlRspackPlugin.version = 6;
1502
+ HtmlRspackPlugin.getCompilationHooks = getHtmlRspackPluginHooks;
1503
+ HtmlRspackPlugin.getHooks = getHtmlRspackPluginHooks;
1504
+ HtmlRspackPlugin.createHtmlTagObject = createHtmlTagObject;
1505
+ module.exports = HtmlRspackPlugin;
1506
+ },
1507
+ 896: (module) => {
1508
+ "use strict";
1509
+ module.exports = require("fs");
1510
+ },
1511
+ 928: (module) => {
1512
+ "use strict";
1513
+ module.exports = require("path");
1514
+ },
1515
+ 23: (module) => {
1516
+ "use strict";
1517
+ module.exports = require("util");
1518
+ },
1519
+ 154: (module) => {
1520
+ "use strict";
1521
+ module.exports = require("vm");
1522
+ },
1523
+ 176: (__unused_webpack_module, exports) => {
1524
+ "use strict";
1525
+ var __nested_webpack_require_18__ = {};
1526
+ (() => {
1527
+ __nested_webpack_require_18__.d = (exports1, getters, values) => {
1528
+ var define = (defs, kind) => {
1529
+ for (var key in defs)
1530
+ if (
1531
+ __nested_webpack_require_18__.o(defs, key) &&
1532
+ !__nested_webpack_require_18__.o(exports1, key)
1533
+ )
1534
+ Object.defineProperty(exports1, key, {
1535
+ enumerable: true,
1536
+ [kind]: defs[key],
1537
+ });
1538
+ };
1539
+ define(getters, "get");
1540
+ define(values, "value");
1541
+ };
1542
+ })();
1543
+ (() => {
1544
+ __nested_webpack_require_18__.o = (obj, prop) =>
1545
+ Object.prototype.hasOwnProperty.call(obj, prop);
1546
+ })();
1547
+ (() => {
1548
+ __nested_webpack_require_18__.r = (exports1) => {
1549
+ if ("u" > typeof Symbol && Symbol.toStringTag)
1550
+ Object.defineProperty(exports1, Symbol.toStringTag, {
1551
+ value: "Module",
1552
+ });
1553
+ Object.defineProperty(exports1, "__esModule", { value: true });
1554
+ };
1555
+ })();
1556
+ var __nested_webpack_exports__ = {};
1557
+ __nested_webpack_require_18__.r(__nested_webpack_exports__);
1558
+ function _define_property(obj, key, value) {
1559
+ if (key in obj)
1560
+ Object.defineProperty(obj, key, {
1561
+ value,
1562
+ enumerable: true,
1563
+ configurable: true,
1564
+ writable: true,
1565
+ });
1566
+ else obj[key] = value;
1567
+ return obj;
1568
+ }
1569
+ class HookBase {
1570
+ intercept(interceptor) {
1571
+ this.interceptors.push(Object.assign({}, interceptor));
1572
+ if (interceptor.register)
1573
+ for (let i = 0; i < this.taps.length; i++)
1574
+ this.taps[i] = interceptor.register(this.taps[i]);
1575
+ }
1576
+ _runRegisterInterceptors(options) {
1577
+ return this.interceptors.reduce(
1578
+ (options, interceptor) =>
1579
+ interceptor.register?.(options) ?? options,
1580
+ options,
1581
+ );
1582
+ }
1583
+ _runCallInterceptors(...args) {
1584
+ for (const interceptor of this.interceptors)
1585
+ if (interceptor.call) interceptor.call(...args);
1586
+ }
1587
+ _runErrorInterceptors(e) {
1588
+ for (const interceptor of this.interceptors)
1589
+ if (interceptor.error) interceptor.error(e);
1590
+ }
1591
+ _runTapInterceptors(tap) {
1592
+ for (const interceptor of this.interceptors)
1593
+ if (interceptor.tap) interceptor.tap(tap);
1594
+ }
1595
+ _runDoneInterceptors() {
1596
+ for (const interceptor of this.interceptors)
1597
+ if (interceptor.done) interceptor.done();
1598
+ }
1599
+ _runResultInterceptors(r) {
1600
+ for (const interceptor of this.interceptors)
1601
+ if (interceptor.result) interceptor.result(r);
1602
+ }
1603
+ withOptions(options) {
1604
+ const mergeOptions = (opt) =>
1605
+ Object.assign(
1606
+ {},
1607
+ options,
1608
+ "string" == typeof opt ? { name: opt } : opt,
1609
+ );
1610
+ return {
1611
+ name: this.name,
1612
+ tap: (opt, fn) => this.tap(mergeOptions(opt), fn),
1613
+ tapAsync: (opt, fn) => this.tapAsync(mergeOptions(opt), fn),
1614
+ tapPromise: (opt, fn) => this.tapPromise(mergeOptions(opt), fn),
1615
+ intercept: (interceptor) => this.intercept(interceptor),
1616
+ isUsed: () => this.isUsed(),
1617
+ withOptions: (opt) => this.withOptions(mergeOptions(opt)),
1618
+ queryStageRange: (stageRange) => this.queryStageRange(stageRange),
1619
+ };
1620
+ }
1621
+ isUsed() {
1622
+ return this.taps.length > 0 || this.interceptors.length > 0;
1623
+ }
1624
+ queryStageRange(stageRange) {
1625
+ return new QueriedHook(stageRange, this);
1626
+ }
1627
+ callAsyncStageRange(_queried) {
1628
+ throw new Error(
1629
+ "Hook should implement there own _callAsyncStageRange",
1630
+ );
1631
+ }
1632
+ callAsync(...args) {
1633
+ return this.callAsyncStageRange(
1634
+ this.queryStageRange(allStageRange),
1635
+ ...args,
1636
+ );
1637
+ }
1638
+ promiseStageRange(queried, ...args) {
1639
+ return new Promise((resolve, reject) => {
1640
+ this.callAsyncStageRange(queried, ...args, (e, r) => {
1641
+ if (e) return reject(e);
1642
+ return resolve(r);
1643
+ });
1644
+ });
1645
+ }
1646
+ promise(...args) {
1647
+ return this.promiseStageRange(
1648
+ this.queryStageRange(allStageRange),
1649
+ ...args,
1650
+ );
1651
+ }
1652
+ tap(options, fn) {
1653
+ this._tap("sync", options, fn);
1654
+ }
1655
+ tapAsync(options, fn) {
1656
+ this._tap("async", options, fn);
1657
+ }
1658
+ tapPromise(options, fn) {
1659
+ this._tap("promise", options, fn);
1660
+ }
1661
+ _tap(type, options, fn) {
1662
+ let normalizedOptions = options;
1663
+ if ("string" == typeof options)
1664
+ normalizedOptions = { name: options.trim() };
1665
+ else if ("object" != typeof options || null === options)
1666
+ throw new Error("Invalid tap options");
1667
+ if (
1668
+ "string" != typeof normalizedOptions.name ||
1669
+ "" === normalizedOptions.name
1670
+ )
1671
+ throw new Error("Missing name for tap");
1672
+ this._insert(
1673
+ this._runRegisterInterceptors(
1674
+ Object.assign({ type, fn }, normalizedOptions),
1675
+ ),
1676
+ );
1677
+ }
1678
+ _insert(item) {
1679
+ let before;
1680
+ if ("string" == typeof item.before) before = new Set([item.before]);
1681
+ else if (Array.isArray(item.before)) before = new Set(item.before);
1682
+ let stage = 0;
1683
+ if ("number" == typeof item.stage) stage = item.stage;
1684
+ let i = this.taps.length;
1685
+ while (i > 0) {
1686
+ i--;
1687
+ const x = this.taps[i];
1688
+ this.taps[i + 1] = x;
1689
+ const xStage = x.stage || 0;
1690
+ if (before) {
1691
+ if (before.has(x.name)) {
1692
+ before.delete(x.name);
1693
+ continue;
1694
+ }
1695
+ if (before.size > 0) continue;
1696
+ }
1697
+ if (xStage > stage) continue;
1698
+ i++;
1699
+ break;
1700
+ }
1701
+ this.taps[i] = item;
1702
+ }
1703
+ _prepareArgs(args) {
1704
+ const len = this.args.length;
1705
+ if (args.length < len) {
1706
+ args.length = len;
1707
+ return args.fill(void 0, args.length, len);
1708
+ }
1709
+ if (args.length > len) args.length = len;
1710
+ return args;
1711
+ }
1712
+ constructor(args = [], name) {
1713
+ _define_property(this, "args", void 0);
1714
+ _define_property(this, "name", void 0);
1715
+ _define_property(this, "taps", void 0);
1716
+ _define_property(this, "interceptors", void 0);
1717
+ this.args = args;
1718
+ this.name = name;
1719
+ this.taps = [];
1720
+ this.interceptors = [];
1721
+ }
1722
+ }
1723
+ const minStage = -1 / 0;
1724
+ const maxStage = 1 / 0;
1725
+ const allStageRange = [minStage, maxStage];
1726
+ const i32MIN = -(2 ** 31);
1727
+ const i32MAX = 2 ** 31 - 1;
1728
+ const safeStage = (stage) => {
1729
+ if (stage < i32MIN) return i32MIN;
1730
+ if (stage > i32MAX) return i32MAX;
1731
+ return stage;
1732
+ };
1733
+ class QueriedHook {
1734
+ isUsed() {
1735
+ if (this.tapsInRange.length > 0) return true;
1736
+ if (
1737
+ this.stageRange[0] === minStage &&
1738
+ this.hook.interceptors.some((i) => i.call)
1739
+ )
1740
+ return true;
1741
+ if (
1742
+ this.stageRange[1] === maxStage &&
1743
+ this.hook.interceptors.some((i) => i.done)
1744
+ )
1745
+ return true;
1746
+ return false;
1747
+ }
1748
+ call(...args) {
1749
+ if ("function" != typeof this.hook.callStageRange)
1750
+ throw new Error(
1751
+ "hook is not a SyncHook, call methods only exists on SyncHook",
1752
+ );
1753
+ return this.hook.callStageRange(this, ...args);
1754
+ }
1755
+ callAsync(...args) {
1756
+ return this.hook.callAsyncStageRange(this, ...args);
1757
+ }
1758
+ promise(...args) {
1759
+ return this.hook.promiseStageRange(this, ...args);
1760
+ }
1761
+ constructor(stageRange, hook) {
1762
+ _define_property(this, "stageRange", void 0);
1763
+ _define_property(this, "hook", void 0);
1764
+ _define_property(this, "tapsInRange", void 0);
1765
+ const tapsInRange = [];
1766
+ const [from, to] = stageRange;
1767
+ for (const tap of hook.taps) {
1768
+ const stage = tap.stage ?? 0;
1769
+ if (from <= stage && stage < to) tapsInRange.push(tap);
1770
+ else if (to === maxStage && stage === maxStage)
1771
+ tapsInRange.push(tap);
1772
+ }
1773
+ this.stageRange = stageRange;
1774
+ this.hook = hook;
1775
+ this.tapsInRange = tapsInRange;
1776
+ }
1777
+ }
1778
+ class SyncHook extends HookBase {
1779
+ callAsyncStageRange(queried, ...args) {
1780
+ const {
1781
+ stageRange: [from, to],
1782
+ tapsInRange,
1783
+ } = queried;
1784
+ const argsWithoutCb = args.slice(0, args.length - 1);
1785
+ const cb = args[args.length - 1];
1786
+ const args2 = this._prepareArgs(argsWithoutCb);
1787
+ if (from === minStage) this._runCallInterceptors(...args2);
1788
+ for (const tap of tapsInRange) {
1789
+ this._runTapInterceptors(tap);
1790
+ try {
1791
+ tap.fn(...args2);
1792
+ } catch (e) {
1793
+ const err = e;
1794
+ this._runErrorInterceptors(err);
1795
+ return cb(err);
1796
+ }
1797
+ }
1798
+ if (to === maxStage) {
1799
+ this._runDoneInterceptors();
1800
+ cb(null);
1801
+ }
1802
+ }
1803
+ call(...args) {
1804
+ return this.callStageRange(
1805
+ this.queryStageRange(allStageRange),
1806
+ ...args,
1807
+ );
1808
+ }
1809
+ callStageRange(queried, ...args) {
1810
+ let result;
1811
+ let error;
1812
+ this.callAsyncStageRange(queried, ...args, (e, r) => {
1813
+ error = e;
1814
+ result = r;
1815
+ });
1816
+ if (error) throw error;
1817
+ return result;
1818
+ }
1819
+ tapAsync() {
1820
+ throw new Error("tapAsync is not supported on a SyncHook");
1821
+ }
1822
+ tapPromise() {
1823
+ throw new Error("tapPromise is not supported on a SyncHook");
1824
+ }
1825
+ }
1826
+ class SyncBailHook extends HookBase {
1827
+ callAsyncStageRange(queried, ...args) {
1828
+ const {
1829
+ stageRange: [from, to],
1830
+ tapsInRange,
1831
+ } = queried;
1832
+ const argsWithoutCb = args.slice(0, args.length - 1);
1833
+ const cb = args[args.length - 1];
1834
+ const args2 = this._prepareArgs(argsWithoutCb);
1835
+ if (from === minStage) this._runCallInterceptors(...args2);
1836
+ for (const tap of tapsInRange) {
1837
+ this._runTapInterceptors(tap);
1838
+ let r;
1839
+ try {
1840
+ r = tap.fn(...args2);
1841
+ } catch (e) {
1842
+ const err = e;
1843
+ this._runErrorInterceptors(err);
1844
+ return cb(err);
1845
+ }
1846
+ if (void 0 !== r) {
1847
+ this._runResultInterceptors(r);
1848
+ return cb(null, r);
1849
+ }
1850
+ }
1851
+ if (to === maxStage) {
1852
+ this._runDoneInterceptors();
1853
+ cb(null);
1854
+ }
1855
+ }
1856
+ call(...args) {
1857
+ return this.callStageRange(
1858
+ this.queryStageRange(allStageRange),
1859
+ ...args,
1860
+ );
1861
+ }
1862
+ callStageRange(queried, ...args) {
1863
+ let result;
1864
+ let error;
1865
+ this.callAsyncStageRange(queried, ...args, (e, r) => {
1866
+ error = e;
1867
+ result = r;
1868
+ });
1869
+ if (error) throw error;
1870
+ return result;
1871
+ }
1872
+ tapAsync() {
1873
+ throw new Error("tapAsync is not supported on a SyncBailHook");
1874
+ }
1875
+ tapPromise() {
1876
+ throw new Error("tapPromise is not supported on a SyncBailHook");
1877
+ }
1878
+ }
1879
+ class SyncWaterfallHook extends HookBase {
1880
+ callAsyncStageRange(queried, ...args) {
1881
+ const {
1882
+ stageRange: [from, to],
1883
+ tapsInRange,
1884
+ } = queried;
1885
+ const argsWithoutCb = args.slice(0, args.length - 1);
1886
+ const cb = args[args.length - 1];
1887
+ const args2 = this._prepareArgs(argsWithoutCb);
1888
+ if (from === minStage) this._runCallInterceptors(...args2);
1889
+ for (const tap of tapsInRange) {
1890
+ this._runTapInterceptors(tap);
1891
+ try {
1892
+ const r = tap.fn(...args2);
1893
+ if (void 0 !== r) args2[0] = r;
1894
+ } catch (e) {
1895
+ const err = e;
1896
+ this._runErrorInterceptors(err);
1897
+ return cb(err);
1898
+ }
1899
+ }
1900
+ if (to === maxStage) {
1901
+ this._runDoneInterceptors();
1902
+ cb(null, args2[0]);
1903
+ }
1904
+ }
1905
+ call(...args) {
1906
+ return this.callStageRange(
1907
+ this.queryStageRange(allStageRange),
1908
+ ...args,
1909
+ );
1910
+ }
1911
+ callStageRange(queried, ...args) {
1912
+ let result;
1913
+ let error;
1914
+ this.callAsyncStageRange(queried, ...args, (e, r) => {
1915
+ error = e;
1916
+ result = r;
1917
+ });
1918
+ if (error) throw error;
1919
+ return result;
1920
+ }
1921
+ tapAsync() {
1922
+ throw new Error("tapAsync is not supported on a SyncWaterfallHook");
1923
+ }
1924
+ tapPromise() {
1925
+ throw new Error("tapPromise is not supported on a SyncWaterfallHook");
1926
+ }
1927
+ constructor(args = [], name) {
1928
+ if (args.length < 1)
1929
+ throw new Error("Waterfall hooks must have at least one argument");
1930
+ super(args, name);
1931
+ }
1932
+ }
1933
+ class AsyncParallelHook extends HookBase {
1934
+ callAsyncStageRange(queried, ...args) {
1935
+ const {
1936
+ stageRange: [from],
1937
+ tapsInRange,
1938
+ } = queried;
1939
+ const argsWithoutCb = args.slice(0, args.length - 1);
1940
+ const cb = args[args.length - 1];
1941
+ const args2 = this._prepareArgs(argsWithoutCb);
1942
+ if (from === minStage) this._runCallInterceptors(...args2);
1943
+ const done = () => {
1944
+ this._runDoneInterceptors();
1945
+ cb(null);
1946
+ };
1947
+ const error = (e) => {
1948
+ this._runErrorInterceptors(e);
1949
+ cb(e);
1950
+ };
1951
+ if (0 === tapsInRange.length) return done();
1952
+ let counter = tapsInRange.length;
1953
+ for (const tap of tapsInRange) {
1954
+ this._runTapInterceptors(tap);
1955
+ if ("promise" === tap.type) {
1956
+ const promise = tap.fn(...args2);
1957
+ if (!promise || !promise.then)
1958
+ throw new Error(
1959
+ `Tap function (tapPromise) did not return promise (returned ${promise})`,
1960
+ );
1961
+ promise.then(
1962
+ () => {
1963
+ counter -= 1;
1964
+ if (0 === counter) done();
1965
+ },
1966
+ (e) => {
1967
+ counter = 0;
1968
+ error(e);
1969
+ },
1970
+ );
1971
+ } else if ("async" === tap.type)
1972
+ tap.fn(...args2, (e) => {
1973
+ if (e) {
1974
+ counter = 0;
1975
+ error(e);
1976
+ } else {
1977
+ counter -= 1;
1978
+ if (0 === counter) done();
1979
+ }
1980
+ });
1981
+ else {
1982
+ let hasError = false;
1983
+ try {
1984
+ tap.fn(...args2);
1985
+ } catch (e) {
1986
+ hasError = true;
1987
+ counter = 0;
1988
+ error(e);
1989
+ }
1990
+ if (!hasError && 0 === --counter) done();
1991
+ }
1992
+ if (counter <= 0) return;
1993
+ }
1994
+ }
1995
+ }
1996
+ class AsyncSeriesHook extends HookBase {
1997
+ callAsyncStageRange(queried, ...args) {
1998
+ const {
1999
+ stageRange: [from],
2000
+ tapsInRange,
2001
+ } = queried;
2002
+ const argsWithoutCb = args.slice(0, args.length - 1);
2003
+ const cb = args[args.length - 1];
2004
+ const args2 = this._prepareArgs(argsWithoutCb);
2005
+ if (from === minStage) this._runCallInterceptors(...args2);
2006
+ const done = () => {
2007
+ this._runDoneInterceptors();
2008
+ cb(null);
2009
+ };
2010
+ const error = (e) => {
2011
+ this._runErrorInterceptors(e);
2012
+ cb(e);
2013
+ };
2014
+ if (0 === tapsInRange.length) return done();
2015
+ let index = 0;
2016
+ const next = () => {
2017
+ const tap = tapsInRange[index];
2018
+ this._runTapInterceptors(tap);
2019
+ if ("promise" === tap.type) {
2020
+ const promise = tap.fn(...args2);
2021
+ if (!promise || !promise.then)
2022
+ throw new Error(
2023
+ `Tap function (tapPromise) did not return promise (returned ${promise})`,
2024
+ );
2025
+ promise.then(
2026
+ () => {
2027
+ index += 1;
2028
+ if (index === tapsInRange.length) done();
2029
+ else next();
2030
+ },
2031
+ (e) => {
2032
+ index = tapsInRange.length;
2033
+ error(e);
2034
+ },
2035
+ );
2036
+ } else if ("async" === tap.type)
2037
+ tap.fn(...args2, (e) => {
2038
+ if (e) {
2039
+ index = tapsInRange.length;
2040
+ error(e);
2041
+ } else {
2042
+ index += 1;
2043
+ if (index === tapsInRange.length) done();
2044
+ else next();
2045
+ }
2046
+ });
2047
+ else {
2048
+ let hasError = false;
2049
+ try {
2050
+ tap.fn(...args2);
2051
+ } catch (e) {
2052
+ hasError = true;
2053
+ index = tapsInRange.length;
2054
+ error(e);
2055
+ }
2056
+ if (!hasError) {
2057
+ index += 1;
2058
+ if (index === tapsInRange.length) done();
2059
+ else next();
2060
+ }
2061
+ }
2062
+ if (index === tapsInRange.length) return;
2063
+ };
2064
+ next();
2065
+ }
2066
+ }
2067
+ class AsyncSeriesBailHook extends HookBase {
2068
+ callAsyncStageRange(queried, ...args) {
2069
+ const {
2070
+ stageRange: [from],
2071
+ tapsInRange,
2072
+ } = queried;
2073
+ const argsWithoutCb = args.slice(0, args.length - 1);
2074
+ const cb = args[args.length - 1];
2075
+ const args2 = this._prepareArgs(argsWithoutCb);
2076
+ if (from === minStage) this._runCallInterceptors(...args2);
2077
+ const done = () => {
2078
+ this._runDoneInterceptors();
2079
+ cb(null);
2080
+ };
2081
+ const error = (e) => {
2082
+ this._runErrorInterceptors(e);
2083
+ cb(e);
2084
+ };
2085
+ const result = (r) => {
2086
+ this._runResultInterceptors(r);
2087
+ cb(null, r);
2088
+ };
2089
+ if (0 === tapsInRange.length) return done();
2090
+ let index = 0;
2091
+ const next = () => {
2092
+ const tap = tapsInRange[index];
2093
+ this._runTapInterceptors(tap);
2094
+ if ("promise" === tap.type) {
2095
+ const promise = tap.fn(...args2);
2096
+ if (!promise || !promise.then)
2097
+ throw new Error(
2098
+ `Tap function (tapPromise) did not return promise (returned ${promise})`,
2099
+ );
2100
+ promise.then(
2101
+ (r) => {
2102
+ index += 1;
2103
+ if (void 0 !== r) result(r);
2104
+ else if (index === tapsInRange.length) done();
2105
+ else next();
2106
+ },
2107
+ (e) => {
2108
+ index = tapsInRange.length;
2109
+ error(e);
2110
+ },
2111
+ );
2112
+ } else if ("async" === tap.type)
2113
+ tap.fn(...args2, (e, r) => {
2114
+ if (e) {
2115
+ index = tapsInRange.length;
2116
+ error(e);
2117
+ } else {
2118
+ index += 1;
2119
+ if (void 0 !== r) result(r);
2120
+ else if (index === tapsInRange.length) done();
2121
+ else next();
2122
+ }
2123
+ });
2124
+ else {
2125
+ let hasError = false;
2126
+ let r;
2127
+ try {
2128
+ r = tap.fn(...args2);
2129
+ } catch (e) {
2130
+ hasError = true;
2131
+ index = tapsInRange.length;
2132
+ error(e);
2133
+ }
2134
+ if (!hasError) {
2135
+ index += 1;
2136
+ if (void 0 !== r) result(r);
2137
+ else if (index === tapsInRange.length) done();
2138
+ else next();
2139
+ }
2140
+ }
2141
+ if (index === tapsInRange.length) return;
2142
+ };
2143
+ next();
2144
+ }
2145
+ }
2146
+ class AsyncSeriesWaterfallHook extends HookBase {
2147
+ callAsyncStageRange(queried, ...args) {
2148
+ const {
2149
+ stageRange: [from],
2150
+ tapsInRange,
2151
+ } = queried;
2152
+ const argsWithoutCb = args.slice(0, args.length - 1);
2153
+ const cb = args[args.length - 1];
2154
+ const args2 = this._prepareArgs(argsWithoutCb);
2155
+ if (from === minStage) this._runCallInterceptors(...args2);
2156
+ const result = (r) => {
2157
+ this._runResultInterceptors(r);
2158
+ cb(null, r);
2159
+ };
2160
+ const error = (e) => {
2161
+ this._runErrorInterceptors(e);
2162
+ cb(e);
2163
+ };
2164
+ if (0 === tapsInRange.length) return result(args2[0]);
2165
+ let index = 0;
2166
+ const next = () => {
2167
+ const tap = tapsInRange[index];
2168
+ this._runTapInterceptors(tap);
2169
+ if ("promise" === tap.type) {
2170
+ const promise = tap.fn(...args2);
2171
+ if (!promise || !promise.then)
2172
+ throw new Error(
2173
+ `Tap function (tapPromise) did not return promise (returned ${promise})`,
2174
+ );
2175
+ promise.then(
2176
+ (r) => {
2177
+ index += 1;
2178
+ if (void 0 !== r) args2[0] = r;
2179
+ if (index === tapsInRange.length) result(args2[0]);
2180
+ else next();
2181
+ },
2182
+ (e) => {
2183
+ index = tapsInRange.length;
2184
+ error(e);
2185
+ },
2186
+ );
2187
+ } else if ("async" === tap.type)
2188
+ tap.fn(...args2, (e, r) => {
2189
+ if (e) {
2190
+ index = tapsInRange.length;
2191
+ error(e);
2192
+ } else {
2193
+ index += 1;
2194
+ if (void 0 !== r) args2[0] = r;
2195
+ if (index === tapsInRange.length) result(args2[0]);
2196
+ else next();
2197
+ }
2198
+ });
2199
+ else {
2200
+ let hasError = false;
2201
+ try {
2202
+ const r = tap.fn(...args2);
2203
+ if (void 0 !== r) args2[0] = r;
2204
+ } catch (e) {
2205
+ hasError = true;
2206
+ index = tapsInRange.length;
2207
+ error(e);
2208
+ }
2209
+ if (!hasError) {
2210
+ index += 1;
2211
+ if (index === tapsInRange.length) result(args2[0]);
2212
+ else next();
2213
+ }
2214
+ }
2215
+ if (index === tapsInRange.length) return;
2216
+ };
2217
+ next();
2218
+ }
2219
+ constructor(args = [], name) {
2220
+ if (args.length < 1)
2221
+ throw new Error("Waterfall hooks must have at least one argument");
2222
+ super(args, name);
2223
+ }
2224
+ }
2225
+ const defaultFactory = (key, hook) => hook;
2226
+ class HookMap {
2227
+ get(key) {
2228
+ return this._map.get(key);
2229
+ }
2230
+ for(key) {
2231
+ const hook = this.get(key);
2232
+ if (void 0 !== hook) return hook;
2233
+ let newHook = this._factory(key);
2234
+ const interceptors = this._interceptors;
2235
+ for (let i = 0; i < interceptors.length; i++) {
2236
+ const factory = interceptors[i].factory;
2237
+ if (factory) newHook = factory(key, newHook);
2238
+ }
2239
+ this._map.set(key, newHook);
2240
+ return newHook;
2241
+ }
2242
+ intercept(interceptor) {
2243
+ this._interceptors.push(
2244
+ Object.assign({ factory: defaultFactory }, interceptor),
2245
+ );
2246
+ }
2247
+ isUsed() {
2248
+ for (const key of this._map.keys()) {
2249
+ const hook = this.get(key);
2250
+ if (hook?.isUsed()) return true;
2251
+ }
2252
+ return false;
2253
+ }
2254
+ queryStageRange(stageRange) {
2255
+ return new QueriedHookMap(stageRange, this);
2256
+ }
2257
+ constructor(factory, name) {
2258
+ _define_property(this, "_map", new Map());
2259
+ _define_property(this, "_factory", void 0);
2260
+ _define_property(this, "name", void 0);
2261
+ _define_property(this, "_interceptors", void 0);
2262
+ this.name = name;
2263
+ this._factory = factory;
2264
+ this._interceptors = [];
2265
+ }
2266
+ }
2267
+ class QueriedHookMap {
2268
+ get(key) {
2269
+ return this.hookMap.get(key)?.queryStageRange(this.stageRange);
2270
+ }
2271
+ for(key) {
2272
+ return this.hookMap.for(key).queryStageRange(this.stageRange);
2273
+ }
2274
+ isUsed() {
2275
+ for (const key of this.hookMap._map.keys())
2276
+ if (this.get(key)?.isUsed()) return true;
2277
+ return false;
2278
+ }
2279
+ constructor(stageRange, hookMap) {
2280
+ _define_property(this, "stageRange", void 0);
2281
+ _define_property(this, "hookMap", void 0);
2282
+ this.stageRange = stageRange;
2283
+ this.hookMap = hookMap;
2284
+ }
2285
+ }
2286
+ class MultiHook {
2287
+ tap(options, fn) {
2288
+ for (const hook of this.hooks) hook.tap(options, fn);
2289
+ }
2290
+ tapAsync(options, fn) {
2291
+ for (const hook of this.hooks) hook.tapAsync(options, fn);
2292
+ }
2293
+ tapPromise(options, fn) {
2294
+ for (const hook of this.hooks) hook.tapPromise(options, fn);
2295
+ }
2296
+ isUsed() {
2297
+ for (const hook of this.hooks) if (hook.isUsed()) return true;
2298
+ return false;
2299
+ }
2300
+ intercept(interceptor) {
2301
+ for (const hook of this.hooks) hook.intercept(interceptor);
2302
+ }
2303
+ withOptions(options) {
2304
+ return new MultiHook(
2305
+ this.hooks.map((h) => h.withOptions(options)),
2306
+ this.name,
2307
+ );
2308
+ }
2309
+ constructor(hooks, name) {
2310
+ _define_property(this, "hooks", void 0);
2311
+ _define_property(this, "name", void 0);
2312
+ this.hooks = hooks;
2313
+ this.name = name;
2314
+ }
2315
+ }
2316
+ __nested_webpack_require_18__.d(
2317
+ __nested_webpack_exports__,
2318
+ {
2319
+ AsyncParallelHook: () => AsyncParallelHook,
2320
+ AsyncSeriesBailHook: () => AsyncSeriesBailHook,
2321
+ AsyncSeriesHook: () => AsyncSeriesHook,
2322
+ AsyncSeriesWaterfallHook: () => AsyncSeriesWaterfallHook,
2323
+ HookBase: () => HookBase,
2324
+ HookMap: () => HookMap,
2325
+ MultiHook: () => MultiHook,
2326
+ QueriedHook: () => QueriedHook,
2327
+ QueriedHookMap: () => QueriedHookMap,
2328
+ SyncBailHook: () => SyncBailHook,
2329
+ SyncHook: () => SyncHook,
2330
+ SyncWaterfallHook: () => SyncWaterfallHook,
2331
+ },
2332
+ { maxStage, minStage, safeStage },
2333
+ );
2334
+ exports.AsyncParallelHook = __nested_webpack_exports__.AsyncParallelHook;
2335
+ exports.AsyncSeriesBailHook =
2336
+ __nested_webpack_exports__.AsyncSeriesBailHook;
2337
+ exports.AsyncSeriesHook = __nested_webpack_exports__.AsyncSeriesHook;
2338
+ exports.AsyncSeriesWaterfallHook =
2339
+ __nested_webpack_exports__.AsyncSeriesWaterfallHook;
2340
+ exports.HookBase = __nested_webpack_exports__.HookBase;
2341
+ exports.HookMap = __nested_webpack_exports__.HookMap;
2342
+ exports.MultiHook = __nested_webpack_exports__.MultiHook;
2343
+ exports.QueriedHook = __nested_webpack_exports__.QueriedHook;
2344
+ exports.QueriedHookMap = __nested_webpack_exports__.QueriedHookMap;
2345
+ exports.SyncBailHook = __nested_webpack_exports__.SyncBailHook;
2346
+ exports.SyncHook = __nested_webpack_exports__.SyncHook;
2347
+ exports.SyncWaterfallHook = __nested_webpack_exports__.SyncWaterfallHook;
2348
+ exports.maxStage = __nested_webpack_exports__.maxStage;
2349
+ exports.minStage = __nested_webpack_exports__.minStage;
2350
+ exports.safeStage = __nested_webpack_exports__.safeStage;
2351
+ for (var __rspack_i in __nested_webpack_exports__)
2352
+ if (
2353
+ -1 ===
2354
+ [
2355
+ "AsyncParallelHook",
2356
+ "AsyncSeriesBailHook",
2357
+ "AsyncSeriesHook",
2358
+ "AsyncSeriesWaterfallHook",
2359
+ "HookBase",
2360
+ "HookMap",
2361
+ "MultiHook",
2362
+ "QueriedHook",
2363
+ "QueriedHookMap",
2364
+ "SyncBailHook",
2365
+ "SyncHook",
2366
+ "SyncWaterfallHook",
2367
+ "maxStage",
2368
+ "minStage",
2369
+ "safeStage",
2370
+ ].indexOf(__rspack_i)
2371
+ )
2372
+ exports[__rspack_i] = __nested_webpack_exports__[__rspack_i];
2373
+ Object.defineProperty(exports, "__esModule", { value: true });
2374
+ },
2375
+ };
2376
+ var __webpack_module_cache__ = {};
2377
+ function __nccwpck_require__(moduleId) {
2378
+ var cachedModule = __webpack_module_cache__[moduleId];
2379
+ if (cachedModule !== undefined) {
2380
+ return cachedModule.exports;
2381
+ }
2382
+ var module = (__webpack_module_cache__[moduleId] = { exports: {} });
2383
+ var threw = true;
2384
+ try {
2385
+ __webpack_modules__[moduleId](
2386
+ module,
2387
+ module.exports,
2388
+ __nccwpck_require__,
2389
+ );
2390
+ threw = false;
2391
+ } finally {
2392
+ if (threw) delete __webpack_module_cache__[moduleId];
2393
+ }
2394
+ return module.exports;
2395
+ }
2396
+ if (typeof __nccwpck_require__ !== "undefined")
2397
+ __nccwpck_require__.ab = __dirname + "/";
2398
+ var __webpack_exports__ = __nccwpck_require__(718);
2399
+ module.exports = __webpack_exports__;
2400
+ })();