@ohos-ports/rspack-core 2.2.2-beta.0 → 2.3.2-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 (228) hide show
  1. package/README.md +9 -0
  2. package/compiled/@rspack/lite-tapable/dist/index.d.ts +20 -6
  3. package/compiled/@rspack/lite-tapable/package.json +1 -1
  4. package/compiled/http-proxy-middleware/index.d.ts +10 -10
  5. package/compiled/http-proxy-middleware/package.json +1 -1
  6. package/compiled/open/package.json +1 -1
  7. package/compiled/tinypool/README.md +4 -4
  8. package/compiled/tinypool/dist/index.d.ts +3 -2
  9. package/compiled/tinypool/dist/index.js +3 -3
  10. package/compiled/tinypool/package.json +1 -1
  11. package/compiled/watchpack/index.js +276 -49
  12. package/compiled/watchpack/package.json +1 -1
  13. package/compiled/watchpack/types/DirectoryWatcher.d.ts +24 -0
  14. package/compiled/watchpack/types/index.d.ts +1 -1
  15. package/compiled/watchpack/types/watchEventSource.d.ts +9 -0
  16. package/compiled/webpack-sources/index.d.ts +61 -0
  17. package/compiled/webpack-sources/index.js +858 -224
  18. package/compiled/webpack-sources/package.json +8 -1
  19. package/compiled/webpack-sources/types/CachedSource.d.ts +192 -0
  20. package/compiled/webpack-sources/types/CompatSource.d.ts +87 -0
  21. package/compiled/webpack-sources/types/ConcatSource.d.ts +75 -0
  22. package/compiled/webpack-sources/types/OriginalSource.d.ts +87 -0
  23. package/compiled/webpack-sources/types/PrefixSource.d.ts +59 -0
  24. package/compiled/webpack-sources/types/RawSource.d.ts +75 -0
  25. package/compiled/webpack-sources/types/ReplaceSource.d.ts +107 -0
  26. package/compiled/webpack-sources/types/SizeOnlySource.d.ts +24 -0
  27. package/compiled/webpack-sources/types/Source.d.ts +189 -0
  28. package/compiled/webpack-sources/types/SourceMapSource.d.ts +136 -0
  29. package/compiled/webpack-sources/types/helpers/createMappingsSerializer.d.ts +60 -0
  30. package/compiled/webpack-sources/types/helpers/getFromStreamChunks.d.ts +16 -0
  31. package/compiled/webpack-sources/types/helpers/getGeneratedSourceInfo.d.ts +31 -0
  32. package/compiled/webpack-sources/types/helpers/getName.d.ts +15 -0
  33. package/compiled/webpack-sources/types/helpers/getSource.d.ts +15 -0
  34. package/compiled/webpack-sources/types/helpers/readMappings.d.ts +19 -0
  35. package/compiled/webpack-sources/types/helpers/scopes.d.ts +119 -0
  36. package/compiled/webpack-sources/types/helpers/splitIntoLines.d.ts +6 -0
  37. package/compiled/webpack-sources/types/helpers/splitIntoPotentialTokens.d.ts +37 -0
  38. package/compiled/webpack-sources/types/helpers/streamAndGetSourceAndMap.d.ts +39 -0
  39. package/compiled/webpack-sources/types/helpers/streamChunks.d.ts +56 -0
  40. package/compiled/webpack-sources/types/helpers/streamChunksOfCombinedSourceMap.d.ts +42 -0
  41. package/compiled/webpack-sources/types/helpers/streamChunksOfRawSource.d.ts +16 -0
  42. package/compiled/webpack-sources/types/helpers/streamChunksOfSourceMap.d.ts +19 -0
  43. package/compiled/webpack-sources/types/helpers/stringBufferUtils.d.ts +55 -0
  44. package/compiled/webpack-sources/types/index.d.ts +50 -0
  45. package/dist/BuildInfo.d.ts +13 -4
  46. package/dist/Chunk.d.ts +3 -3
  47. package/dist/ChunkGraph.d.ts +2 -2
  48. package/dist/Chunks.d.ts +2 -2
  49. package/dist/CodeGenerationResults.d.ts +6 -1
  50. package/dist/Compilation.d.ts +16 -53
  51. package/dist/Compiler.d.ts +9 -10
  52. package/dist/ConcatenatedModule.d.ts +5 -1
  53. package/dist/ContextModule.d.ts +3 -1
  54. package/dist/Diagnostics.d.ts +2 -6
  55. package/dist/Entrypoint.d.ts +1 -1
  56. package/dist/ExportsInfo.d.ts +1 -1
  57. package/dist/ExternalModule.d.ts +7 -6
  58. package/dist/FileSystem.d.ts +3 -1
  59. package/dist/FileSystemDependencies.d.ts +15 -0
  60. package/dist/FileSystemInfo.d.ts +1 -0
  61. package/dist/Module.d.ts +19 -11
  62. package/dist/ModuleGraph.d.ts +6 -6
  63. package/dist/ModuleGraphConnection.d.ts +9 -3
  64. package/dist/Modules.d.ts +3 -0
  65. package/dist/NativeWatchFileSystem.d.ts +20 -8
  66. package/dist/NormalModule.d.ts +14 -6
  67. package/dist/NormalModuleFactory.d.ts +2 -1
  68. package/dist/Resolver.d.ts +10 -2
  69. package/dist/ResolverFactory.d.ts +1 -1
  70. package/dist/RspackError.d.ts +2 -2
  71. package/dist/RuntimeGlobals.d.ts +4 -3
  72. package/dist/RuntimeModule.d.ts +1 -1
  73. package/dist/RuntimeTemplate.d.ts +1 -0
  74. package/dist/Stats.d.ts +1 -1
  75. package/dist/builtin-loader/lightningcss/target.d.ts +1 -1
  76. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
  81. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  82. package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  84. package/dist/builtin-plugin/CircularCheckRspackPlugin.d.ts +1 -1
  85. package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +1 -1
  86. package/dist/builtin-plugin/CircularModulesInfoPlugin.d.ts +1 -1
  87. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  88. package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +1 -1
  89. package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +1 -1
  90. package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +1 -1
  91. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +2 -2
  92. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +1 -1
  93. package/dist/builtin-plugin/CssHttpExternalsRspackPlugin.d.ts +1 -1
  94. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  95. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  96. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  97. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  98. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  99. package/dist/builtin-plugin/DllEntryPlugin.d.ts +1 -1
  100. package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +2 -2
  101. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  102. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  103. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  104. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
  105. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  106. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  107. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  108. package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +1 -1
  109. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +2 -2
  110. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -4
  111. package/dist/builtin-plugin/ExternalsPlugin.d.ts +1 -1
  112. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  113. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  114. package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +1 -1
  115. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  116. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  117. package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +2 -2
  118. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +1 -1
  119. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  120. package/dist/builtin-plugin/HttpUriPlugin.d.ts +5 -1
  121. package/dist/builtin-plugin/IgnorePlugin.d.ts +2 -2
  122. package/dist/builtin-plugin/ImportedByDeferModulesPlugin.d.ts +9 -0
  123. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  124. package/dist/builtin-plugin/InlineExportsPlugin.d.ts +1 -1
  125. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  126. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  127. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  128. package/dist/builtin-plugin/LibManifestPlugin.d.ts +1 -1
  129. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +1 -1
  130. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  131. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  132. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  133. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  134. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  135. package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +1 -1
  136. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  137. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  138. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  139. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  140. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +1 -1
  141. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  142. package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +1 -1
  143. package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +2 -2
  144. package/dist/builtin-plugin/ProgressPlugin.d.ts +2 -2
  145. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  146. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  147. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +1 -1
  148. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  149. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +2 -2
  150. package/dist/builtin-plugin/RslibPlugin.d.ts +4 -4
  151. package/dist/builtin-plugin/RstestPlugin.d.ts +2 -2
  152. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +2 -2
  153. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  154. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  155. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  156. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +2 -2
  157. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +1 -1
  158. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +3 -2
  159. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  160. package/dist/builtin-plugin/SyncModuleIdsPlugin.d.ts +1 -1
  161. package/dist/builtin-plugin/URLPlugin.d.ts +1 -1
  162. package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -1
  163. package/dist/builtin-plugin/base.d.ts +1 -1
  164. package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
  165. package/dist/builtin-plugin/css-extract/utils.d.ts +4 -1
  166. package/dist/builtin-plugin/html-plugin/hooks.d.ts +1 -1
  167. package/dist/builtin-plugin/html-plugin/plugin.d.ts +2 -2
  168. package/dist/builtin-plugin/index.d.ts +1 -0
  169. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +3 -3
  170. package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +1 -1
  171. package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +1 -1
  172. package/dist/config/adapter.d.ts +1 -1
  173. package/dist/config/adapterRuleUse.d.ts +3 -2
  174. package/dist/config/normalization.d.ts +5 -8
  175. package/dist/config/target.d.ts +2 -0
  176. package/dist/config/types.d.ts +104 -19
  177. package/dist/container/ContainerPlugin.d.ts +1 -1
  178. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  179. package/dist/container/ModuleFederationManifestPlugin.d.ts +1 -1
  180. package/dist/container/ModuleFederationPluginV1.d.ts +5 -1
  181. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  182. package/dist/cssExtractHmr.js +1 -1
  183. package/dist/cssExtractLoader.js +7 -5
  184. package/dist/exports.d.ts +7 -7
  185. package/dist/index.js +1845 -1070
  186. package/dist/lib/Cache.d.ts +3 -0
  187. package/dist/lib/DllReferencePlugin.d.ts +1 -1
  188. package/dist/lib/WebpackError.d.ts +1 -1
  189. package/dist/loader-runner/codeFilter.d.ts +9 -0
  190. package/dist/loader-runner/dependencies.d.ts +5 -4
  191. package/dist/loader-runner/index.d.ts +3 -2
  192. package/dist/loader-runner/service.d.ts +6 -5
  193. package/dist/loader-runner/worker.d.ts +5 -2
  194. package/dist/l~0.js +34 -0
  195. package/dist/l~3.js +34 -0
  196. package/dist/node/NodeWatchFileSystem.d.ts +7 -4
  197. package/dist/sharing/CollectSharedEntryPlugin.d.ts +1 -1
  198. package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
  199. package/dist/sharing/ProvideSharedPlugin.d.ts +1 -1
  200. package/dist/sharing/SharePlugin.d.ts +13 -1
  201. package/dist/sharing/ShareRuntimePlugin.d.ts +1 -1
  202. package/dist/sharing/SharedContainerPlugin.d.ts +1 -1
  203. package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +2 -2
  204. package/dist/sources.d.ts +3 -0
  205. package/dist/stats/StatsFactory.d.ts +4 -2
  206. package/dist/stats/StatsPrinter.d.ts +5 -5
  207. package/dist/stats/statsFactoryUtils.d.ts +12 -6
  208. package/dist/swc.d.ts +1 -1
  209. package/dist/taps/compilation.d.ts +1 -1
  210. package/dist/taps/types.d.ts +1 -1
  211. package/dist/util/SplitChunkSize.d.ts +1 -1
  212. package/dist/util/bindingHelpers.d.ts +9 -0
  213. package/dist/util/createModule.d.ts +3 -0
  214. package/dist/util/fs.d.ts +22 -16
  215. package/dist/util/resolveLayerExternals.d.ts +1 -0
  216. package/dist/util/source.d.ts +13 -4
  217. package/dist/util/symbols.d.ts +10 -0
  218. package/dist/util/watchTimeInfo.d.ts +11 -0
  219. package/dist/worker.js +386 -353
  220. package/hot/lazy-compilation-node.js +1 -1
  221. package/hot/lazy-compilation-web.js +1 -1
  222. package/package.json +8 -32
  223. package/compiled/webpack-sources/types.d.ts +0 -500
  224. package/dist/612~0.js +0 -32
  225. package/dist/612~3.js +0 -32
  226. package/dist/loader-runner/cache.d.ts +0 -18
  227. package/dist/util/MergeCaller.d.ts +0 -10
  228. package/dist/util/fake.d.ts +0 -11
package/dist/worker.js CHANGED
@@ -1,32 +1,29 @@
1
1
  let createMd4, createXxhash64, url;
2
+ import { rspackRequire, moduleFactories, definePropertyGetters, makeNamespaceObject, compatGetDefaultExport } from "./l~3.js";
2
3
  import node_fs from "node:fs";
3
4
  import node_querystring from "node:querystring";
4
5
  import { inspect, promisify } from "node:util";
5
6
  import { receiveMessageOnPort } from "node:worker_threads";
6
7
  import { createRequire, createRequire as __rspack_createRequire } from "node:module";
7
8
  import node_path from "node:path";
8
- import { __webpack_require__ } from "./612~3.js";
9
9
  let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
10
- __webpack_require__.add({
10
+ moduleFactories.add({
11
11
  "node:crypto" (module) {
12
12
  module.exports = __rspack_createRequire_require("node:crypto");
13
13
  },
14
- "node:os" (module) {
15
- module.exports = __rspack_createRequire_require("node:os");
16
- },
17
14
  "node:url" (module) {
18
15
  module.exports = __rspack_createRequire_require("node:url");
19
16
  }
20
17
  });
21
18
  var swc_namespaceObject = {};
22
- __webpack_require__.r(swc_namespaceObject), __webpack_require__.d(swc_namespaceObject, {
19
+ makeNamespaceObject(swc_namespaceObject), definePropertyGetters(swc_namespaceObject, {
23
20
  minify: ()=>minify,
24
21
  minifySync: ()=>minifySync,
25
22
  transform: ()=>transform,
26
23
  transformSync: ()=>transformSync
27
24
  });
28
25
  let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING || "@ohos-ports/rspack-binding");
29
- var binding_default = __webpack_require__.n(binding_namespaceObject);
26
+ var binding_default = compatGetDefaultExport(binding_namespaceObject);
30
27
  async function minify(source, options) {
31
28
  let _options = JSON.stringify(options || {});
32
29
  return binding_default().minify(source, _options);
@@ -43,15 +40,7 @@ function transformSync(source, options) {
43
40
  let _options = JSON.stringify(options || {});
44
41
  return binding_default().transformSync(source, _options);
45
42
  }
46
- let decoder = new TextDecoder(), toObject = (input)=>{
47
- let s;
48
- if (Buffer.isBuffer(input)) s = input.toString('utf8');
49
- else if (input instanceof Uint8Array) s = decoder.decode(input);
50
- else if (input && 'object' == typeof input) return input;
51
- else if ('string' == typeof input) s = input;
52
- else throw Error('Buffer or string or object expected');
53
- return JSON.parse(s);
54
- }, DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(), DELETE = Symbol('DELETE'), cachedCleverMerge = (first, second)=>{
43
+ let DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(), DELETE = Symbol('DELETE'), cachedCleverMerge = (first, second)=>{
55
44
  if (void 0 === second) return first;
56
45
  if (void 0 === first || 'object' != typeof second || null === second) return second;
57
46
  if ('object' != typeof first || null === first) return first;
@@ -99,7 +88,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
99
88
  static: info,
100
89
  dynamic: dynamicInfo
101
90
  };
102
- }, cleverMerge_serializeObject = (info, dynamicInfo)=>{
91
+ }, serializeObject = (info, dynamicInfo)=>{
103
92
  let obj = {};
104
93
  for (let entry of info.values())if (void 0 !== entry.byProperty) {
105
94
  let byObj = obj[entry.byProperty] = obj[entry.byProperty] || {};
@@ -125,7 +114,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
125
114
  return newFn[DYNAMIC_INFO] = [
126
115
  fn,
127
116
  secondObj
128
- ], cleverMerge_serializeObject(firstObject.static, {
117
+ ], serializeObject(firstObject.static, {
129
118
  byProperty,
130
119
  fn: newFn
131
120
  });
@@ -136,7 +125,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
136
125
  resultInfo.set(key, entry);
137
126
  }
138
127
  for (let [key, secondEntry] of secondInfo)firstInfo.has(key) || resultInfo.set(key, secondEntry);
139
- return cleverMerge_serializeObject(resultInfo, secondDynamicInfo);
128
+ return serializeObject(resultInfo, secondDynamicInfo);
140
129
  }, mergeEntries = (firstEntry, secondEntry, internalCaching)=>{
141
130
  switch(getValueType(secondEntry.base)){
142
131
  case 1:
@@ -263,7 +252,6 @@ class Hash {
263
252
  throw new AbstractMethodError();
264
253
  }
265
254
  }
266
- let MAX_SHORT_STRING = -4 & Math.floor(16368);
267
255
  class WasmHash {
268
256
  exports;
269
257
  instancesPool;
@@ -281,7 +269,7 @@ class WasmHash {
281
269
  update(data, encoding) {
282
270
  if ('string' == typeof data) {
283
271
  let normalizedData = data;
284
- for(; normalizedData.length > MAX_SHORT_STRING;)this._updateWithShortString(normalizedData.slice(0, MAX_SHORT_STRING), encoding), normalizedData = normalizedData.slice(MAX_SHORT_STRING);
272
+ for(; normalizedData.length > 16368;)this._updateWithShortString(normalizedData.slice(0, 16368), encoding), normalizedData = normalizedData.slice(16368);
285
273
  return this._updateWithShortString(normalizedData, encoding), this;
286
274
  }
287
275
  return this._updateWithBuffer(data), this;
@@ -404,24 +392,30 @@ let createHash_createHash = (algorithm)=>{
404
392
  })());
405
393
  case 'native-md4':
406
394
  return new BulkUpdateDecorator(()=>{
407
- let { createHash } = __webpack_require__("node:crypto");
395
+ let { createHash } = rspackRequire("node:crypto");
408
396
  return createHash('md4');
409
397
  }, 'md4');
410
398
  default:
411
399
  return new BulkUpdateDecorator(()=>{
412
- let { createHash } = __webpack_require__("node:crypto");
400
+ let { createHash } = rspackRequire("node:crypto");
413
401
  return createHash(algorithm);
414
402
  }, algorithm);
415
403
  }
416
- }, WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
404
+ }, WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, getWindowsDosDevicePathPrefixLength = (identifier)=>{
405
+ if (identifier.length >= 4 && 92 === identifier.charCodeAt(0) && 92 === identifier.charCodeAt(1) && 92 === identifier.charCodeAt(3)) {
406
+ let namespace = identifier.charCodeAt(2);
407
+ if (63 === namespace || 46 === namespace) return 4;
408
+ }
409
+ return 0;
410
+ }, isWindowsAbsolutePath = (identifier)=>WINDOWS_ABS_PATH_REGEXP.test(identifier) || 0 !== getWindowsDosDevicePathPrefixLength(identifier), getQuerySplitPosition = (identifier)=>identifier.indexOf('?', getWindowsDosDevicePathPrefixLength(identifier)), relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
417
411
  if ('/' === maybeAbsolutePath[0]) {
418
412
  if (maybeAbsolutePath.length > 1 && '/' === maybeAbsolutePath[maybeAbsolutePath.length - 1]) return maybeAbsolutePath;
419
- let querySplitPos = maybeAbsolutePath.indexOf('?'), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
413
+ let querySplitPos = getQuerySplitPosition(maybeAbsolutePath), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
420
414
  return resource = relativePathToRequest(node_path.posix.relative(context, resource)), -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
421
415
  }
422
- if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) {
423
- let querySplitPos = maybeAbsolutePath.indexOf('?'), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
424
- return resource = node_path.win32.relative(context, resource), WINDOWS_ABS_PATH_REGEXP.test(resource) || (resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, '/'))), -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
416
+ if (isWindowsAbsolutePath(maybeAbsolutePath)) {
417
+ let querySplitPos = getQuerySplitPosition(maybeAbsolutePath), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
418
+ return isWindowsAbsolutePath(resource = node_path.win32.relative(context, resource)) || (resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, '/'))), -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
425
419
  }
426
420
  return maybeAbsolutePath;
427
421
  }, makeCacheable = (realFn)=>{
@@ -482,14 +476,15 @@ let createHash_createHash = (algorithm)=>{
482
476
  makeCacheableWithContext((context, identifier)=>identifier.split(SEGMENTS_SPLIT_REGEXP).map((str)=>absoluteToRequest(context, str)).join(''));
483
477
  let contextify = makeCacheableWithContext((context, request)=>request.split('!').map((r)=>absoluteToRequest(context, r)).join('!')), absolutify = makeCacheableWithContext((context, request)=>request.split('!').map((r)=>r.startsWith('./') || r.startsWith('../') ? node_path.join(context, r) : r).join('!')), PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/, PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
484
478
  makeCacheable(function(str) {
485
- if (!str.includes('?') && !str.includes('#') && !str.includes('\u200b')) return {
479
+ let prefixLength = getWindowsDosDevicePathPrefixLength(str), resource = str.slice(prefixLength);
480
+ if (!resource.includes('?') && !resource.includes('#') && !resource.includes('\u200b')) return {
486
481
  path: str,
487
482
  query: '',
488
483
  fragment: ''
489
484
  };
490
- let match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
485
+ let match = PATH_QUERY_FRAGMENT_REGEXP.exec(resource);
491
486
  return match ? {
492
- path: match[1].replace(/\u200b(.)/g, '$1'),
487
+ path: str.slice(0, prefixLength) + match[1].replace(/\u200b(.)/g, '$1'),
493
488
  query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : '',
494
489
  fragment: match[3] || ''
495
490
  } : {
@@ -498,29 +493,31 @@ makeCacheable(function(str) {
498
493
  fragment: ''
499
494
  };
500
495
  }), makeCacheable((str)=>{
501
- let match = PATH_QUERY_REGEXP.exec(str);
496
+ let prefixLength = getWindowsDosDevicePathPrefixLength(str), match = PATH_QUERY_REGEXP.exec(str.slice(prefixLength));
502
497
  return {
503
- path: match[1].replace(/\u200b(.)/g, '$1'),
498
+ path: str.slice(0, prefixLength) + match[1].replace(/\u200b(.)/g, '$1'),
504
499
  query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : ''
505
500
  };
506
501
  });
507
502
  let memoize = (fn)=>{
508
503
  let result, cache = !1, callback = fn;
509
504
  return ()=>(cache || (result = callback(), cache = !0, callback = void 0), result);
510
- }, LoaderLoadingError = class extends Error {
505
+ }, decoder = new TextDecoder('utf-8', {
506
+ fatal: !0
507
+ }), LoaderLoadingError = class extends Error {
511
508
  constructor(message){
512
509
  super(message), this.name = 'LoaderRunnerError', Error.captureStackTrace(this, this.constructor);
513
510
  }
514
- }, loadLoader_require = createRequire(import.meta.url), moduleCache = new Map(), modulePromiseCache = new Map(), loaderUrlCache = new Map();
511
+ }, loadLoader_require = createRequire(import.meta.url), loadLoader_moduleCache = new Map(), modulePromiseCache = new Map(), loaderUrlCache = new Map();
515
512
  function loadLoader(loader, compiler, callback) {
516
- let cacheKey = `${loader.type ?? 'commonjs'}\0${loader.path}`, cachedModule = moduleCache.get(cacheKey);
513
+ let cacheKey = `${loader.type ?? 'commonjs'}\0${loader.path}`, cachedModule = loadLoader_moduleCache.get(cacheKey);
517
514
  if (void 0 !== cachedModule) return handleResult(loader, cachedModule, callback);
518
515
  if ('module' === loader.type) try {
519
516
  let modulePromise = modulePromiseCache.get(cacheKey);
520
517
  if (void 0 === modulePromise) {
521
- void 0 === url && (url = __webpack_require__("node:url"));
518
+ void 0 === url && (url = rspackRequire("node:url"));
522
519
  let loaderUrl = loaderUrlCache.get(loader.path);
523
- void 0 === loaderUrl && (loaderUrl = url.pathToFileURL(loader.path).toString(), loaderUrlCache.set(loader.path, loaderUrl)), modulePromise = import(loaderUrl).then((module)=>(moduleCache.set(cacheKey, module), modulePromiseCache.delete(cacheKey), module), (err)=>{
520
+ void 0 === loaderUrl && (loaderUrl = url.pathToFileURL(loader.path).toString(), loaderUrlCache.set(loader.path, loaderUrl)), modulePromise = import(loaderUrl).then((module)=>(loadLoader_moduleCache.set(cacheKey, module), modulePromiseCache.delete(cacheKey), module), (err)=>{
524
521
  throw modulePromiseCache.delete(cacheKey), err;
525
522
  }), modulePromiseCache.set(cacheKey, modulePromise);
526
523
  }
@@ -548,19 +545,47 @@ function handleResult(loader, module, callback) {
548
545
  function isWorkerResponseMessage(message) {
549
546
  return 'response' === message.type;
550
547
  }
551
- function serializeError(error) {
552
- if (error instanceof Error || error && 'object' == typeof error && 'message' in error) return {
553
- ...error,
554
- name: error.name,
555
- stack: error.stack,
556
- message: error.message
548
+ function serializeAggregateErrorMember(value) {
549
+ return value instanceof Error ? {
550
+ __internal__type: 'error',
551
+ value: serializeErrorWithoutCloneCheck(value)
552
+ } : {
553
+ __internal__type: 'value',
554
+ value
557
555
  };
556
+ }
557
+ function serializeErrorWithoutCloneCheck(error) {
558
+ if (error instanceof Error || error && 'object' == typeof error && 'message' in error) {
559
+ let serializedError = {
560
+ ...error,
561
+ name: error.name,
562
+ stack: error.stack,
563
+ message: error.message
564
+ };
565
+ return error instanceof AggregateError ? (serializedError.__internal__isAggregateError = !0, serializedError.errors = error.errors.map(serializeAggregateErrorMember)) : delete serializedError.__internal__isAggregateError, serializedError;
566
+ }
558
567
  if ('string' == typeof error) return {
559
568
  name: 'Error',
560
569
  message: error
561
570
  };
562
571
  throw Error('Failed to serialize error, only string, Error instances and objects with a message property are supported');
563
572
  }
573
+ function serializeError(error) {
574
+ try {
575
+ let serializedError = serializeErrorWithoutCloneCheck(error);
576
+ return structuredClone(serializedError), serializedError;
577
+ } catch (serializationError) {
578
+ let reason = serializationError instanceof Error ? serializationError.message : 'unknown reason';
579
+ return serializeErrorWithoutCloneCheck(Error(`Failed to serialize error: ${reason}`));
580
+ }
581
+ }
582
+ function deserializeAggregateErrorMember(member) {
583
+ return 'error' === member.__internal__type ? deserializeError(member.value) : member.value;
584
+ }
585
+ function deserializeError(error) {
586
+ let { __internal__isAggregateError, errors, ...properties } = error, shouldDeserializeAsAggregate = !0 === __internal__isAggregateError && Array.isArray(errors), deserializedError = shouldDeserializeAsAggregate ? AggregateError(errors.map(deserializeAggregateErrorMember), error.message) : Error(error.message);
587
+ return Object.assign(deserializedError, properties), shouldDeserializeAsAggregate || void 0 === errors || (deserializedError.errors = errors), deserializedError;
588
+ }
564
589
  let utils_decoder = new TextDecoder();
565
590
  promisify(loadLoader);
566
591
  let utils_runSyncOrAsync = promisify(function(fn, context, args, callback) {
@@ -604,312 +629,7 @@ let utils_runSyncOrAsync = promisify(function(fn, context, args, callback) {
604
629
  if (isDone) return void (e instanceof Error ? console.error(e.stack) : console.error(e));
605
630
  isDone = !0, reportedError = !0, callback(e, []);
606
631
  }
607
- }), loadLoaderAsync = promisify(loadLoader);
608
- async function loaderImpl({ args, loaderContext, loaderState }, sendRequest, waitForPendingRequest) {
609
- let resourcePath = loaderContext.resourcePath, contextDirectory = resourcePath ? function(path) {
610
- if ('/' === path) return '/';
611
- let i = path.lastIndexOf('/'), j = path.lastIndexOf('\\'), i2 = path.indexOf('/'), j2 = path.indexOf('\\'), idx = i > j ? i : j, idx2 = i > j ? i2 : j2;
612
- return idx < 0 ? path : idx === idx2 ? path.slice(0, idx + 1) : path.slice(0, idx);
613
- }(resourcePath) : null, pendingDependencyRequest = [];
614
- loaderContext.parallel = !0, loaderContext.dependency = loaderContext.addDependency = function(file) {
615
- pendingDependencyRequest.push(sendRequest("AddDependency", file));
616
- }, loaderContext.addContextDependency = function(context) {
617
- pendingDependencyRequest.push(sendRequest("AddContextDependency", context));
618
- }, loaderContext.addMissingDependency = function(missing) {
619
- pendingDependencyRequest.push(sendRequest("AddMissingDependency", missing));
620
- }, loaderContext.addBuildDependency = function(file) {
621
- pendingDependencyRequest.push(sendRequest("AddBuildDependency", file));
622
- }, loaderContext.getDependencies = function() {
623
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetDependencies").wait();
624
- }, loaderContext.getContextDependencies = function() {
625
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetContextDependencies").wait();
626
- }, loaderContext.getMissingDependencies = function() {
627
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetMissingDependencies").wait();
628
- }, loaderContext.clearDependencies = function() {
629
- pendingDependencyRequest.push(sendRequest("ClearDependencies"));
630
- };
631
- let beginDependencyChanges = ()=>sendRequest("BeginDependencyChanges"), mergeDependencyChanges = async ()=>{
632
- pendingDependencyRequest.length > 0 && (waitForPendingRequest(pendingDependencyRequest), pendingDependencyRequest.length = 0), await sendRequest("MergeDependencyChanges");
633
- };
634
- loaderContext.resolve = function(context, request, callback) {
635
- sendRequest("Resolve", context, request).then(([result, resolveRequest])=>{
636
- callback(null, result, resolveRequest);
637
- }, (err)=>{
638
- callback(err);
639
- });
640
- }, loaderContext.getResolve = function(options) {
641
- return function(context, request, callback) {
642
- if (!callback) return new Promise((resolve, reject)=>{
643
- sendRequest("GetResolve", options, context, request).then(([result])=>{
644
- resolve(result);
645
- }, (err)=>{
646
- reject(err);
647
- });
648
- });
649
- sendRequest("GetResolve", options, context, request).then(([result, resolveRequest])=>{
650
- callback(null, result, resolveRequest);
651
- }, (err)=>{
652
- callback(err);
653
- });
654
- };
655
- }, loaderContext.getLogger = function(name) {
656
- return {
657
- error (...args) {
658
- sendRequest("GetLogger", 'error', name, args);
659
- },
660
- warn (...args) {
661
- sendRequest("GetLogger", 'warn', name, args);
662
- },
663
- info (...args) {
664
- sendRequest("GetLogger", 'info', name, args);
665
- },
666
- log (...args) {
667
- sendRequest("GetLogger", 'log', name, args);
668
- },
669
- debug (...args) {
670
- sendRequest("GetLogger", 'debug', name, args);
671
- },
672
- assert (assertion, ...args) {
673
- assertion || sendRequest("GetLogger", 'error', name, args);
674
- },
675
- trace () {
676
- sendRequest("GetLogger", 'trace', name, [
677
- 'Trace'
678
- ]);
679
- },
680
- clear () {
681
- sendRequest("GetLogger", 'clear', name, []);
682
- },
683
- status (...args) {
684
- sendRequest("GetLogger", 'status', name, args);
685
- },
686
- group (...args) {
687
- sendRequest("GetLogger", 'group', name, args);
688
- },
689
- groupCollapsed (...args) {
690
- sendRequest("GetLogger", 'groupCollapsed', name, args);
691
- },
692
- groupEnd (...args) {
693
- sendRequest("GetLogger", 'groupEnd', name, args);
694
- },
695
- profile (label) {
696
- sendRequest("GetLogger", 'profile', name, [
697
- label
698
- ]);
699
- },
700
- profileEnd (label) {
701
- sendRequest("GetLogger", 'profileEnd', name, [
702
- label
703
- ]);
704
- },
705
- time (label) {
706
- sendRequest("GetLogger", 'time', name, [
707
- label
708
- ]);
709
- },
710
- timeEnd (label) {
711
- sendRequest("GetLogger", 'timeEnd', name, [
712
- label
713
- ]);
714
- },
715
- timeLog (label, ...args) {
716
- sendRequest("GetLogger", 'timeLog', name, [
717
- label,
718
- ...args
719
- ]);
720
- },
721
- timeAggregate (label) {
722
- sendRequest("GetLogger", 'timeAggregate', name, [
723
- label
724
- ]);
725
- },
726
- timeAggregateEnd (label) {
727
- sendRequest("GetLogger", 'timeAggregateEnd', name, [
728
- label
729
- ]);
730
- }
731
- };
732
- }, loaderContext.emitError = function(err) {
733
- sendRequest("EmitError", serializeError(err));
734
- }, loaderContext.emitWarning = function(warning) {
735
- sendRequest("EmitWarning", serializeError(warning));
736
- }, loaderContext.emitFile = function(name, content, sourceMap, assetInfo) {
737
- sendRequest("EmitFile", name, content, sourceMap, assetInfo);
738
- }, loaderContext.experiments = {
739
- emitDiagnostic (diagnostic) {
740
- sendRequest("EmitDiagnostic", diagnostic);
741
- }
742
- };
743
- let getAbsolutify = memoize(()=>absolutify.bindCache({})), getAbsolutifyInContext = memoize(()=>absolutify.bindContextCache(contextDirectory, {})), getContextify = memoize(()=>contextify.bindCache({})), getContextifyInContext = memoize(()=>contextify.bindContextCache(contextDirectory, {}));
744
- loaderContext.utils = {
745
- absolutify: (context, request)=>context === contextDirectory ? getAbsolutifyInContext()(request) : getAbsolutify()(context, request),
746
- contextify: (context, request)=>context === contextDirectory ? getContextifyInContext()(request) : getContextify()(context, request),
747
- createHash: (type)=>createHash_createHash(type || loaderContext._compilation.outputOptions.hashFunction)
748
- }, loaderContext._compiler = {
749
- ...loaderContext._compiler,
750
- rspack: {
751
- experiments: {
752
- swc: swc_namespaceObject
753
- }
754
- },
755
- webpack: {
756
- util: {
757
- createHash: createHash_createHash,
758
- cleverMerge: cleverMerge
759
- }
760
- }
761
- }, loaderContext._compilation = {
762
- ...loaderContext._compilation,
763
- getPath: (filename, data = {})=>(data.hash || (data = {
764
- hash: loaderContext._compilation.hash ?? void 0,
765
- ...data
766
- }), sendRequest("CompilationGetPath", 'function' == typeof filename ? filename(data) : filename, data).wait()),
767
- getPathWithInfo (filename, data = {}) {
768
- data.hash || (data = {
769
- hash: loaderContext._compilation.hash ?? void 0,
770
- ...data
771
- });
772
- let info = {}, result = sendRequest("CompilationGetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
773
- return Object.assign(info, result.info), {
774
- path: result.path,
775
- info
776
- };
777
- },
778
- getAssetPath: (filename, data = {})=>sendRequest("CompilationGetAssetPath", 'function' == typeof filename ? filename(data) : filename, data).wait(),
779
- getAssetPathWithInfo (filename, data = {}) {
780
- let info = {}, result = sendRequest("CompilationGetAssetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
781
- return Object.assign(info, result.info), {
782
- path: result.path,
783
- info
784
- };
785
- }
786
- };
787
- let _module = loaderContext._module;
788
- loaderContext._module = {
789
- type: _module.type,
790
- identifier: ()=>_module.identifier,
791
- matchResource: _module.matchResource,
792
- request: _module.request,
793
- userRequest: _module.userRequest,
794
- rawRequest: _module.rawRequest
795
- }, loaderContext.importModule = function(request, options, callback) {
796
- if (!callback) return new Promise((resolve, reject)=>{
797
- sendRequest("ImportModule", request, options).then((result)=>{
798
- resolve(result);
799
- }, (err)=>{
800
- reject(err);
801
- });
802
- });
803
- sendRequest("ImportModule", request, options).then((result)=>{
804
- callback(null, result);
805
- }, (err)=>{
806
- callback(err);
807
- });
808
- }, loaderContext.fs = node_fs, Object.defineProperty(loaderContext, 'request', {
809
- enumerable: !0,
810
- get: ()=>loaderContext.loaders.map((o)=>o.request).concat(loaderContext.resource || '').join('!')
811
- }), Object.defineProperty(loaderContext, 'remainingRequest', {
812
- enumerable: !0,
813
- get: ()=>loaderContext.loaderIndex >= loaderContext.loaders.length - 1 && !loaderContext.resource ? '' : loaderContext.loaders.slice(loaderContext.loaderIndex + 1).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
814
- }), Object.defineProperty(loaderContext, 'currentRequest', {
815
- enumerable: !0,
816
- get: ()=>loaderContext.loaders.slice(loaderContext.loaderIndex).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
817
- }), Object.defineProperty(loaderContext, 'previousRequest', {
818
- enumerable: !0,
819
- get: ()=>loaderContext.loaders.slice(0, loaderContext.loaderIndex).map((o)=>o.request).join('!')
820
- }), Object.defineProperty(loaderContext, 'query', {
821
- enumerable: !0,
822
- get: ()=>{
823
- let entry = loaderContext.loaders[loaderContext.loaderIndex];
824
- return entry.options && 'object' == typeof entry.options ? entry.options : entry.query;
825
- }
826
- }), loaderContext.getOptions = function() {
827
- let loader = function(loaderContext, index = loaderContext.loaderIndex) {
828
- return loaderContext.loaders?.length && index < loaderContext.loaders.length && index >= 0 && loaderContext.loaders[index] ? loaderContext.loaders[index] : null;
829
- }(loaderContext), options = loader?.options;
830
- if ('string' == typeof options) if (options.startsWith('{') && options.endsWith('}')) try {
831
- options = JSON.parse(options);
832
- } catch (e) {
833
- throw Error(`JSON parsing failed for loader's string options: ${e.message}`);
834
- }
835
- else options = node_querystring.parse(options);
836
- return null == options && (options = {}), options;
837
- }, loaderContext.cacheable = function(flag) {
838
- !1 === flag && sendRequest("SetCacheable", !1);
839
- }, Object.defineProperty(loaderContext, 'data', {
840
- enumerable: !0,
841
- get: ()=>loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data,
842
- set: (value)=>{
843
- loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data = value;
844
- }
845
- });
846
- let shouldYieldToMainThread = (currentLoaderObject)=>!!(!currentLoaderObject?.parallel || currentLoaderObject?.request.startsWith('builtin:'));
847
- switch(loaderState){
848
- case binding_namespaceObject.JsLoaderState.Pitching:
849
- for(; loaderContext.loaderIndex < loaderContext.loaders.length;){
850
- let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
851
- if (shouldYieldToMainThread(currentLoaderObject)) break;
852
- if (currentLoaderObject.pitchExecuted) {
853
- loaderContext.loaderIndex += 1;
854
- continue;
855
- }
856
- await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
857
- let fn = currentLoaderObject.pitch;
858
- if ((currentLoaderObject.pitchExecuted = !0, fn) && (args = await utils_runSyncOrAsync(fn, loaderContext, [
859
- loaderContext.remainingRequest,
860
- loaderContext.previousRequest,
861
- currentLoaderObject.loaderItem.data
862
- ]) || []).some((value)=>void 0 !== value)) break;
863
- }
864
- break;
865
- case binding_namespaceObject.JsLoaderState.Normal:
866
- for(; loaderContext.loaderIndex >= 0;){
867
- let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
868
- if (shouldYieldToMainThread(currentLoaderObject)) break;
869
- if (currentLoaderObject.normalExecuted) {
870
- loaderContext.loaderIndex--;
871
- continue;
872
- }
873
- let trackDependencies = currentLoaderObject.loaderItem.cache;
874
- trackDependencies && await beginDependencyChanges();
875
- try {
876
- if (currentLoaderObject.loaderItem.cache) {
877
- waitForPendingRequest(pendingDependencyRequest);
878
- let hit = await sendRequest("LoaderCacheGet", loaderContext.loaderIndex, args[0], args[2]);
879
- if (hit) {
880
- currentLoaderObject.normalExecuted = !0, args = [
881
- 'string' == typeof hit.content ? hit.content : hit.content && Buffer.from(hit.content),
882
- hit.sourceMap ? toObject(Buffer.from(hit.sourceMap)) : void 0,
883
- void 0
884
- ];
885
- continue;
886
- }
887
- }
888
- await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
889
- let fn = currentLoaderObject.normal;
890
- if (currentLoaderObject.normalExecuted = !0, !fn) continue;
891
- !function(args, raw) {
892
- if (!raw && args[0] instanceof Uint8Array) {
893
- var buf;
894
- let isShared, str;
895
- args[0] = (isShared = (buf = args[0]).buffer instanceof SharedArrayBuffer || buf.buffer.constructor?.name === 'SharedArrayBuffer', str = utils_decoder.decode(isShared ? Buffer.from(buf) : buf), 0xfeff === str.charCodeAt(0) ? str.slice(1) : str);
896
- } else raw && 'string' == typeof args[0] && (args[0] = Buffer.from(args[0], 'utf-8'));
897
- raw && args[0] instanceof Uint8Array && !Buffer.isBuffer(args[0]) && (args[0] = Buffer.from(args[0].buffer, args[0].byteOffset, args[0].byteLength));
898
- }(args, !!currentLoaderObject.raw), args = await utils_runSyncOrAsync(fn, loaderContext, args) || [], currentLoaderObject.loaderItem.cache && (waitForPendingRequest(pendingDependencyRequest), await sendRequest("LoaderCacheStore", loaderContext.loaderIndex, args[0], function(map) {
899
- if (null != map) return 'string' == typeof map ? map ? Buffer.from(map) : void 0 : Buffer.from(JSON.stringify(map));
900
- }(args[1]), args[2]));
901
- } finally{
902
- trackDependencies && await mergeDependencyChanges();
903
- }
904
- }
905
- }
906
- return sendRequest("UpdateLoaderObjects", loaderContext.loaders.map((item)=>({
907
- data: item.loaderItem.data,
908
- normalExecuted: item.normalExecuted,
909
- pitchExecuted: item.pitchExecuted
910
- }))), args;
911
- }
912
- let nextId = 0, responseCallbacks = {};
632
+ }), loadLoaderAsync = promisify(loadLoader), nextId = 0, responseCallbacks = {};
913
633
  function handleIncomingResponses(workerMessage) {
914
634
  if (isWorkerResponseMessage(workerMessage)) {
915
635
  let { id, data } = workerMessage, callback = responseCallbacks[id];
@@ -917,7 +637,7 @@ function handleIncomingResponses(workerMessage) {
917
637
  else throw Error(`No callback found for response with id ${id}`);
918
638
  } else if ('response-error' === workerMessage.type) {
919
639
  let { id, error } = workerMessage, callback = responseCallbacks[id];
920
- if (callback) delete responseCallbacks[id], callback(error, void 0);
640
+ if (callback) delete responseCallbacks[id], callback(deserializeError(error), void 0);
921
641
  else throw Error(`No callback found for response with id ${id}`);
922
642
  }
923
643
  }
@@ -953,11 +673,324 @@ export default function(workerOptions) {
953
673
  let { message } = receiveMessageOnPort(workerSyncPort1);
954
674
  if (id !== message.id) throw Error(`Unexpected response id: ${message.id}, expected: ${id}`);
955
675
  if (isWorkerResponseMessage(message)) return message.data;
956
- throw message.error;
676
+ throw deserializeError(message.error);
957
677
  }), sendRequest), waitFor = (requests)=>sendRequest1.sync("WaitForPendingRequest", (Array.isArray(requests) ? requests : [
958
678
  requests
959
679
  ]).map((request)=>request.id));
960
- loaderImpl(workerOptions, sendRequest1, waitFor).then((data)=>{
680
+ (async function({ args, loaderContext, loaderState }, sendRequest, waitForPendingRequest) {
681
+ let resourcePath = loaderContext.resourcePath, contextDirectory = resourcePath ? function(path) {
682
+ if ('/' === path) return '/';
683
+ let i = path.lastIndexOf('/'), j = path.lastIndexOf('\\'), i2 = path.indexOf('/'), j2 = path.indexOf('\\'), idx = i > j ? i : j, idx2 = i > j ? i2 : j2;
684
+ return idx < 0 ? path : idx === idx2 ? path.slice(0, idx + 1) : path.slice(0, idx);
685
+ }(resourcePath) : null, pendingDependencyRequest = [];
686
+ loaderContext.parallel = !0, loaderContext.dependency = loaderContext.addDependency = function(file) {
687
+ pendingDependencyRequest.push(sendRequest("AddDependency", file));
688
+ }, loaderContext.addContextDependency = function(context) {
689
+ pendingDependencyRequest.push(sendRequest("AddContextDependency", context));
690
+ }, loaderContext.addMissingDependency = function(missing) {
691
+ pendingDependencyRequest.push(sendRequest("AddMissingDependency", missing));
692
+ }, loaderContext.addBuildDependency = function(file) {
693
+ pendingDependencyRequest.push(sendRequest("AddBuildDependency", file));
694
+ }, loaderContext.getDependencies = function() {
695
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetDependencies").wait();
696
+ }, loaderContext.getContextDependencies = function() {
697
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetContextDependencies").wait();
698
+ }, loaderContext.getMissingDependencies = function() {
699
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetMissingDependencies").wait();
700
+ }, loaderContext.clearDependencies = function() {
701
+ pendingDependencyRequest.push(sendRequest("ClearDependencies"));
702
+ }, loaderContext.resolve = function(context, request, callback) {
703
+ sendRequest("Resolve", context, request).then(([result, resolveRequest])=>{
704
+ callback(null, result, resolveRequest);
705
+ }, (err)=>{
706
+ callback(err);
707
+ });
708
+ }, loaderContext.getResolve = function(options) {
709
+ return function(context, request, callback) {
710
+ if (!callback) return new Promise((resolve, reject)=>{
711
+ sendRequest("GetResolve", options, context, request).then(([result])=>{
712
+ resolve(result);
713
+ }, (err)=>{
714
+ reject(err);
715
+ });
716
+ });
717
+ sendRequest("GetResolve", options, context, request).then(([result, resolveRequest])=>{
718
+ callback(null, result, resolveRequest);
719
+ }, (err)=>{
720
+ callback(err);
721
+ });
722
+ };
723
+ }, loaderContext.getLogger = function(name) {
724
+ return {
725
+ error (...args) {
726
+ sendRequest("GetLogger", 'error', name, args);
727
+ },
728
+ warn (...args) {
729
+ sendRequest("GetLogger", 'warn', name, args);
730
+ },
731
+ info (...args) {
732
+ sendRequest("GetLogger", 'info', name, args);
733
+ },
734
+ log (...args) {
735
+ sendRequest("GetLogger", 'log', name, args);
736
+ },
737
+ debug (...args) {
738
+ sendRequest("GetLogger", 'debug', name, args);
739
+ },
740
+ assert (assertion, ...args) {
741
+ assertion || sendRequest("GetLogger", 'error', name, args);
742
+ },
743
+ trace () {
744
+ sendRequest("GetLogger", 'trace', name, [
745
+ 'Trace'
746
+ ]);
747
+ },
748
+ clear () {
749
+ sendRequest("GetLogger", 'clear', name, []);
750
+ },
751
+ status (...args) {
752
+ sendRequest("GetLogger", 'status', name, args);
753
+ },
754
+ group (...args) {
755
+ sendRequest("GetLogger", 'group', name, args);
756
+ },
757
+ groupCollapsed (...args) {
758
+ sendRequest("GetLogger", 'groupCollapsed', name, args);
759
+ },
760
+ groupEnd (...args) {
761
+ sendRequest("GetLogger", 'groupEnd', name, args);
762
+ },
763
+ profile (label) {
764
+ sendRequest("GetLogger", 'profile', name, [
765
+ label
766
+ ]);
767
+ },
768
+ profileEnd (label) {
769
+ sendRequest("GetLogger", 'profileEnd', name, [
770
+ label
771
+ ]);
772
+ },
773
+ time (label) {
774
+ sendRequest("GetLogger", 'time', name, [
775
+ label
776
+ ]);
777
+ },
778
+ timeEnd (label) {
779
+ sendRequest("GetLogger", 'timeEnd', name, [
780
+ label
781
+ ]);
782
+ },
783
+ timeLog (label, ...args) {
784
+ sendRequest("GetLogger", 'timeLog', name, [
785
+ label,
786
+ ...args
787
+ ]);
788
+ },
789
+ timeAggregate (label) {
790
+ sendRequest("GetLogger", 'timeAggregate', name, [
791
+ label
792
+ ]);
793
+ },
794
+ timeAggregateEnd (label) {
795
+ sendRequest("GetLogger", 'timeAggregateEnd', name, [
796
+ label
797
+ ]);
798
+ }
799
+ };
800
+ }, loaderContext.emitError = function(err) {
801
+ sendRequest("EmitError", serializeError(err));
802
+ }, loaderContext.emitWarning = function(warning) {
803
+ sendRequest("EmitWarning", serializeError(warning));
804
+ }, loaderContext.emitFile = function(name, content, sourceMap, assetInfo) {
805
+ sendRequest("EmitFile", name, content, sourceMap, assetInfo);
806
+ }, loaderContext.experiments = {
807
+ emitDiagnostic (diagnostic) {
808
+ sendRequest("EmitDiagnostic", diagnostic);
809
+ }
810
+ };
811
+ let getAbsolutify = memoize(()=>absolutify.bindCache({})), getAbsolutifyInContext = memoize(()=>absolutify.bindContextCache(contextDirectory, {})), getContextify = memoize(()=>contextify.bindCache({})), getContextifyInContext = memoize(()=>contextify.bindContextCache(contextDirectory, {}));
812
+ loaderContext.utils = {
813
+ absolutify: (context, request)=>context === contextDirectory ? getAbsolutifyInContext()(request) : getAbsolutify()(context, request),
814
+ contextify: (context, request)=>context === contextDirectory ? getContextifyInContext()(request) : getContextify()(context, request),
815
+ createHash: (type)=>createHash_createHash(type || loaderContext._compilation.outputOptions.hashFunction)
816
+ }, loaderContext._compiler = {
817
+ ...loaderContext._compiler,
818
+ rspack: {
819
+ experiments: {
820
+ swc: swc_namespaceObject
821
+ }
822
+ },
823
+ webpack: {
824
+ util: {
825
+ createHash: createHash_createHash,
826
+ cleverMerge: cleverMerge
827
+ }
828
+ }
829
+ }, loaderContext._compilation = {
830
+ ...loaderContext._compilation,
831
+ getPath: (filename, data = {})=>(data.hash || (data = {
832
+ hash: loaderContext._compilation.hash ?? void 0,
833
+ ...data
834
+ }), sendRequest("CompilationGetPath", 'function' == typeof filename ? filename(data) : filename, data).wait()),
835
+ getPathWithInfo (filename, data = {}) {
836
+ data.hash || (data = {
837
+ hash: loaderContext._compilation.hash ?? void 0,
838
+ ...data
839
+ });
840
+ let info = {}, result = sendRequest("CompilationGetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
841
+ return Object.assign(info, result.info), {
842
+ path: result.path,
843
+ info
844
+ };
845
+ },
846
+ getAssetPath: (filename, data = {})=>sendRequest("CompilationGetAssetPath", 'function' == typeof filename ? filename(data) : filename, data).wait(),
847
+ getAssetPathWithInfo (filename, data = {}) {
848
+ let info = {}, result = sendRequest("CompilationGetAssetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
849
+ return Object.assign(info, result.info), {
850
+ path: result.path,
851
+ info
852
+ };
853
+ }
854
+ };
855
+ let _module = loaderContext._module, buildInfo = {
856
+ ..._module.buildInfo ?? {}
857
+ };
858
+ loaderContext._module = {
859
+ type: _module.type,
860
+ identifier: ()=>_module.identifier,
861
+ matchResource: _module.matchResource,
862
+ request: _module.request,
863
+ userRequest: _module.userRequest,
864
+ rawRequest: _module.rawRequest,
865
+ buildInfo
866
+ }, loaderContext.importModule = function(request, options, callback) {
867
+ if (!callback) return new Promise((resolve, reject)=>{
868
+ sendRequest("ImportModule", request, options).then((result)=>{
869
+ resolve(result);
870
+ }, (err)=>{
871
+ reject(err);
872
+ });
873
+ });
874
+ sendRequest("ImportModule", request, options).then((result)=>{
875
+ callback(null, result);
876
+ }, (err)=>{
877
+ callback(err);
878
+ });
879
+ }, loaderContext.fs = node_fs, Object.defineProperty(loaderContext, 'request', {
880
+ enumerable: !0,
881
+ get: ()=>loaderContext.loaders.map((o)=>o.request).concat(loaderContext.resource || '').join('!')
882
+ }), Object.defineProperty(loaderContext, 'remainingRequest', {
883
+ enumerable: !0,
884
+ get: ()=>loaderContext.loaderIndex >= loaderContext.loaders.length - 1 && !loaderContext.resource ? '' : loaderContext.loaders.slice(loaderContext.loaderIndex + 1).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
885
+ }), Object.defineProperty(loaderContext, 'currentRequest', {
886
+ enumerable: !0,
887
+ get: ()=>loaderContext.loaders.slice(loaderContext.loaderIndex).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
888
+ }), Object.defineProperty(loaderContext, 'previousRequest', {
889
+ enumerable: !0,
890
+ get: ()=>loaderContext.loaders.slice(0, loaderContext.loaderIndex).map((o)=>o.request).join('!')
891
+ }), Object.defineProperty(loaderContext, 'query', {
892
+ enumerable: !0,
893
+ get: ()=>{
894
+ let entry = loaderContext.loaders[loaderContext.loaderIndex];
895
+ return entry.options && 'object' == typeof entry.options ? entry.options : entry.query;
896
+ }
897
+ }), loaderContext.getOptions = function() {
898
+ let loader = function(loaderContext, index = loaderContext.loaderIndex) {
899
+ return loaderContext.loaders?.length && index < loaderContext.loaders.length && index >= 0 && loaderContext.loaders[index] ? loaderContext.loaders[index] : null;
900
+ }(loaderContext), options = loader?.options;
901
+ if ('string' == typeof options) if (options.startsWith('{') && options.endsWith('}')) try {
902
+ options = JSON.parse(options);
903
+ } catch (e) {
904
+ throw Error(`JSON parsing failed for loader's string options: ${e.message}`);
905
+ }
906
+ else options = node_querystring.parse(options);
907
+ return null == options && (options = {}), options;
908
+ }, loaderContext.cacheable = function(flag) {
909
+ !1 === flag && sendRequest("SetCacheable", !1);
910
+ }, Object.defineProperty(loaderContext, 'data', {
911
+ enumerable: !0,
912
+ get: ()=>loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data,
913
+ set: (value)=>{
914
+ loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data = value;
915
+ }
916
+ });
917
+ let shouldYieldToMainThread = (currentLoaderObject)=>!currentLoaderObject?.parallel;
918
+ switch(loaderState){
919
+ case binding_namespaceObject.JsLoaderState.Pitching:
920
+ for(; loaderContext.loaderIndex < loaderContext.loaderChainEnd;){
921
+ let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
922
+ if (shouldYieldToMainThread(currentLoaderObject)) break;
923
+ if (currentLoaderObject.pitchExecuted) {
924
+ loaderContext.loaderIndex += 1;
925
+ continue;
926
+ }
927
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
928
+ let fn = currentLoaderObject.pitch;
929
+ if ((currentLoaderObject.pitchExecuted = !0, fn) && (args = await utils_runSyncOrAsync(fn, loaderContext, [
930
+ loaderContext.remainingRequest,
931
+ loaderContext.previousRequest,
932
+ currentLoaderObject.loaderItem.data
933
+ ]) || []).some((value)=>void 0 !== value)) break;
934
+ }
935
+ break;
936
+ case binding_namespaceObject.JsLoaderState.Normal:
937
+ {
938
+ let codeFilterTextCache = {
939
+ initialized: !1
940
+ };
941
+ for(; loaderContext.loaderIndex >= loaderContext.loaderChainStart;){
942
+ let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
943
+ if (currentLoaderObject.normalExecuted) {
944
+ loaderContext.loaderIndex--;
945
+ continue;
946
+ }
947
+ let { loaderItem } = currentLoaderObject, codeFilter = loaderItem.codeFilter;
948
+ if (codeFilter && !loaderItem.filterMatched) {
949
+ let matched = function(filter, content, cache) {
950
+ let code = function(content, cache) {
951
+ let text;
952
+ if (cache.initialized && cache.content === content) return cache.text ?? null;
953
+ if ('string' == typeof content) text = content;
954
+ else if (content instanceof Uint8Array) try {
955
+ text = decoder.decode(content);
956
+ } catch {
957
+ text = null;
958
+ }
959
+ else text = null;
960
+ return cache.initialized = !0, cache.content = content, cache.text = text, text;
961
+ }(content, cache);
962
+ if (null !== code) {
963
+ let matched;
964
+ return 'string' == typeof filter ? code.includes(filter) : (filter.lastIndex = 0, matched = filter.test(code), filter.lastIndex = 0, matched);
965
+ }
966
+ }(codeFilter, args[0], codeFilterTextCache);
967
+ if (!1 === matched) {
968
+ currentLoaderObject.normalExecuted = !0, loaderContext.loaderIndex--;
969
+ continue;
970
+ }
971
+ matched && (loaderItem.filterMatched = !0);
972
+ }
973
+ if (shouldYieldToMainThread(currentLoaderObject)) break;
974
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
975
+ let fn = currentLoaderObject.normal;
976
+ currentLoaderObject.normalExecuted = !0, fn && (!function(args, raw) {
977
+ if (!raw && args[0] instanceof Uint8Array) {
978
+ var buf;
979
+ let isShared, str;
980
+ args[0] = (isShared = (buf = args[0]).buffer instanceof SharedArrayBuffer || buf.buffer.constructor?.name === 'SharedArrayBuffer', 0xfeff === (str = utils_decoder.decode(isShared ? Buffer.from(buf) : buf)).charCodeAt(0) ? str.slice(1) : str);
981
+ } else raw && 'string' == typeof args[0] && (args[0] = Buffer.from(args[0], 'utf-8'));
982
+ raw && args[0] instanceof Uint8Array && !Buffer.isBuffer(args[0]) && (args[0] = Buffer.from(args[0].buffer, args[0].byteOffset, args[0].byteLength));
983
+ }(args, !!currentLoaderObject.raw), args = await utils_runSyncOrAsync(fn, loaderContext, args) || [], codeFilterTextCache.initialized = !1, codeFilterTextCache.content = void 0, codeFilterTextCache.text = void 0);
984
+ }
985
+ }
986
+ }
987
+ return sendRequest("UpdateLoaderObjects", loaderContext.loaders.map((item)=>({
988
+ data: item.loaderItem.data,
989
+ normalExecuted: item.normalExecuted,
990
+ pitchExecuted: item.pitchExecuted,
991
+ filterMatched: item.loaderItem.filterMatched
992
+ }))), sendRequest("UpdateBuildInfo", buildInfo), args;
993
+ })(workerOptions, sendRequest1, waitFor).then((data)=>{
961
994
  workerData.workerPort.postMessage({
962
995
  type: 'done',
963
996
  data