@rspack/core 1.3.10 → 1.3.12

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 (134) hide show
  1. package/compiled/watchpack/index.js +56 -18
  2. package/compiled/watchpack/package.json +1 -1
  3. package/compiled/webpack-sources/index.js +1539 -339
  4. package/compiled/webpack-sources/package.json +1 -1
  5. package/compiled/webpack-sources/types.d.ts +320 -0
  6. package/compiled/zod/dist/types/index.d.ts +3 -0
  7. package/compiled/zod/{lib → dist/types/v3}/ZodError.d.ts +7 -7
  8. package/compiled/zod/{lib → dist/types/v3}/errors.d.ts +2 -2
  9. package/compiled/zod/dist/types/v3/external.d.ts +6 -0
  10. package/compiled/zod/{lib → dist/types/v3}/helpers/errorUtil.d.ts +1 -1
  11. package/compiled/zod/{lib → dist/types/v3}/helpers/parseUtil.d.ts +4 -4
  12. package/compiled/zod/{lib → dist/types/v3}/helpers/partialUtil.d.ts +1 -1
  13. package/compiled/zod/{lib → dist/types/v3}/helpers/util.d.ts +12 -9
  14. package/compiled/zod/dist/types/v3/index.d.ts +4 -0
  15. package/compiled/zod/{lib → dist/types/v3}/locales/en.d.ts +1 -1
  16. package/compiled/zod/{lib/__tests__ → dist/types/v3/tests}/Mocker.d.ts +6 -6
  17. package/compiled/zod/{lib → dist/types/v3}/types.d.ts +118 -149
  18. package/compiled/zod/dist/types/v4/classic/checks.d.ts +1 -0
  19. package/compiled/zod/dist/types/v4/classic/coerce.d.ts +17 -0
  20. package/compiled/zod/dist/types/v4/classic/compat.d.ts +48 -0
  21. package/compiled/zod/dist/types/v4/classic/errors.d.ts +30 -0
  22. package/compiled/zod/dist/types/v4/classic/external.d.ts +8 -0
  23. package/compiled/zod/dist/types/v4/classic/index.d.ts +4 -0
  24. package/compiled/zod/dist/types/v4/classic/iso.d.ts +22 -0
  25. package/compiled/zod/dist/types/v4/classic/parse.d.ts +23 -0
  26. package/compiled/zod/dist/types/v4/classic/schemas.d.ts +657 -0
  27. package/compiled/zod/dist/types/v4/core/api.d.ts +273 -0
  28. package/compiled/zod/dist/types/v4/core/checks.d.ts +277 -0
  29. package/compiled/zod/dist/types/v4/core/config.d.ts +9 -0
  30. package/compiled/zod/dist/types/v4/core/core.d.ts +43 -0
  31. package/compiled/zod/dist/types/v4/core/doc.d.ts +14 -0
  32. package/compiled/zod/dist/types/v4/core/errors.d.ts +205 -0
  33. package/compiled/zod/dist/types/v4/core/function.d.ts +47 -0
  34. package/compiled/zod/dist/types/v4/core/index.d.ts +15 -0
  35. package/compiled/zod/dist/types/v4/core/json-schema.d.ts +100 -0
  36. package/compiled/zod/dist/types/v4/core/parse.d.ts +25 -0
  37. package/compiled/zod/dist/types/v4/core/regexes.d.ts +62 -0
  38. package/compiled/zod/dist/types/v4/core/registries.d.ts +32 -0
  39. package/compiled/zod/dist/types/v4/core/schemas.d.ts +983 -0
  40. package/compiled/zod/dist/types/v4/core/standard-schema.d.ts +55 -0
  41. package/compiled/zod/dist/types/v4/core/to-json-schema.d.ts +84 -0
  42. package/compiled/zod/dist/types/v4/core/util.d.ts +186 -0
  43. package/compiled/zod/dist/types/v4/core/versions.d.ts +5 -0
  44. package/compiled/zod/dist/types/v4/core/zsf.d.ts +91 -0
  45. package/compiled/zod/dist/types/v4/index.d.ts +3 -0
  46. package/compiled/zod/dist/types/v4/locales/ar.d.ts +7 -0
  47. package/compiled/zod/dist/types/v4/locales/az.d.ts +7 -0
  48. package/compiled/zod/dist/types/v4/locales/be.d.ts +7 -0
  49. package/compiled/zod/dist/types/v4/locales/ca.d.ts +7 -0
  50. package/compiled/zod/dist/types/v4/locales/cs.d.ts +7 -0
  51. package/compiled/zod/dist/types/v4/locales/de.d.ts +7 -0
  52. package/compiled/zod/dist/types/v4/locales/en.d.ts +7 -0
  53. package/compiled/zod/dist/types/v4/locales/es.d.ts +7 -0
  54. package/compiled/zod/dist/types/v4/locales/fa.d.ts +7 -0
  55. package/compiled/zod/dist/types/v4/locales/fi.d.ts +7 -0
  56. package/compiled/zod/dist/types/v4/locales/fr.d.ts +7 -0
  57. package/compiled/zod/dist/types/v4/locales/frCA.d.ts +7 -0
  58. package/compiled/zod/dist/types/v4/locales/he.d.ts +7 -0
  59. package/compiled/zod/dist/types/v4/locales/hu.d.ts +7 -0
  60. package/compiled/zod/dist/types/v4/locales/id.d.ts +7 -0
  61. package/compiled/zod/dist/types/v4/locales/index.d.ts +34 -0
  62. package/compiled/zod/dist/types/v4/locales/it.d.ts +7 -0
  63. package/compiled/zod/dist/types/v4/locales/ja.d.ts +7 -0
  64. package/compiled/zod/dist/types/v4/locales/ko.d.ts +7 -0
  65. package/compiled/zod/dist/types/v4/locales/mk.d.ts +7 -0
  66. package/compiled/zod/dist/types/v4/locales/ms.d.ts +7 -0
  67. package/compiled/zod/dist/types/v4/locales/no.d.ts +7 -0
  68. package/compiled/zod/dist/types/v4/locales/ota.d.ts +7 -0
  69. package/compiled/zod/dist/types/v4/locales/pl.d.ts +7 -0
  70. package/compiled/zod/dist/types/v4/locales/pt.d.ts +7 -0
  71. package/compiled/zod/dist/types/v4/locales/ru.d.ts +7 -0
  72. package/compiled/zod/dist/types/v4/locales/sl.d.ts +7 -0
  73. package/compiled/zod/dist/types/v4/locales/ta.d.ts +7 -0
  74. package/compiled/zod/dist/types/v4/locales/th.d.ts +7 -0
  75. package/compiled/zod/dist/types/v4/locales/tr.d.ts +7 -0
  76. package/compiled/zod/dist/types/v4/locales/ua.d.ts +7 -0
  77. package/compiled/zod/dist/types/v4/locales/ur.d.ts +7 -0
  78. package/compiled/zod/dist/types/v4/locales/vi.d.ts +7 -0
  79. package/compiled/zod/dist/types/v4/locales/zh-CN.d.ts +7 -0
  80. package/compiled/zod/dist/types/v4/locales/zh-tw.d.ts +7 -0
  81. package/compiled/zod/dist/types/v4/mini/checks.d.ts +1 -0
  82. package/compiled/zod/dist/types/v4/mini/coerce.d.ts +7 -0
  83. package/compiled/zod/dist/types/v4/mini/external.d.ts +7 -0
  84. package/compiled/zod/dist/types/v4/mini/index.d.ts +3 -0
  85. package/compiled/zod/dist/types/v4/mini/iso.d.ts +22 -0
  86. package/compiled/zod/dist/types/v4/mini/parse.d.ts +1 -0
  87. package/compiled/zod/dist/types/v4/mini/schemas.d.ts +407 -0
  88. package/compiled/zod/index.js +555 -602
  89. package/compiled/zod/license +1 -1
  90. package/compiled/zod/package.json +1 -1
  91. package/compiled/zod/v3/index.d.ts +1 -0
  92. package/compiled/zod/v4/core/index.d.ts +1 -0
  93. package/compiled/zod/v4/index.d.ts +1 -0
  94. package/compiled/zod/v4/locales/en.d.ts +2 -0
  95. package/compiled/zod/v4/locales/index.d.ts +1 -0
  96. package/compiled/zod/v4-mini/index.d.ts +1 -0
  97. package/dist/Compilation.d.ts +7 -7
  98. package/dist/Compiler.d.ts +1 -1
  99. package/dist/Diagnostics.d.ts +7 -0
  100. package/dist/Module.d.ts +9 -0
  101. package/dist/RspackError.d.ts +3 -0
  102. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +2 -3
  103. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +19 -0
  104. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  105. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -3
  106. package/dist/builtin-plugin/RstestPlugin.d.ts +11 -0
  107. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
  108. package/dist/builtin-plugin/index.d.ts +2 -0
  109. package/dist/config/zod.d.ts +6 -6
  110. package/dist/exports.d.ts +3 -0
  111. package/dist/index.d.ts +0 -1
  112. package/dist/index.js +392 -232
  113. package/dist/node/NodeWatchFileSystem.d.ts +2 -2
  114. package/dist/trace/index.d.ts +9 -3
  115. package/dist/trace/traceHookPlugin.d.ts +5 -0
  116. package/dist/worker.js +1 -1
  117. package/package.json +8 -9
  118. package/compiled/webpack-sources/index.d.ts +0 -130
  119. package/compiled/zod/index.d.ts +0 -2
  120. package/compiled/zod/lib/external.d.ts +0 -6
  121. package/compiled/zod/lib/index.d.ts +0 -4
  122. package/dist/setupEnv.d.ts +0 -1
  123. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/datetime.d.ts +0 -0
  124. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/discriminatedUnion.d.ts +0 -0
  125. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/index.d.ts +0 -0
  126. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/ipv4.d.ts +0 -0
  127. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/object.d.ts +0 -0
  128. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/primitives.d.ts +0 -0
  129. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/realworld.d.ts +0 -0
  130. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/string.d.ts +0 -0
  131. /package/compiled/zod/{lib → dist/types/v3}/benchmarks/union.d.ts +0 -0
  132. /package/compiled/zod/{lib → dist/types/v3}/helpers/enumUtil.d.ts +0 -0
  133. /package/compiled/zod/{lib → dist/types/v3}/helpers/typeAliases.d.ts +0 -0
  134. /package/compiled/zod/{lib → dist/types/v3}/standard-schema.d.ts +0 -0
@@ -1,62 +1,127 @@
1
1
  /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
2
3
  /******/ var __webpack_modules__ = ({
3
4
 
4
- /***/ 453:
5
+ /***/ 627:
5
6
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
7
 
7
- "use strict";
8
8
  /*
9
9
  MIT License http://www.opensource.org/licenses/mit-license.php
10
10
  Author Tobias Koppers @sokra
11
11
  */
12
12
 
13
13
 
14
- const Source = __nccwpck_require__(171);
15
- const streamChunksOfSourceMap = __nccwpck_require__(958);
16
- const streamChunksOfRawSource = __nccwpck_require__(348);
17
- const streamAndGetSourceAndMap = __nccwpck_require__(391);
18
14
 
19
- const mapToBufferedMap = map => {
15
+ const Source = __nccwpck_require__(225);
16
+ const streamAndGetSourceAndMap = __nccwpck_require__(765);
17
+ const streamChunksOfRawSource = __nccwpck_require__(482);
18
+ const streamChunksOfSourceMap = __nccwpck_require__(492);
19
+ const {
20
+ isDualStringBufferCachingEnabled
21
+ } = __nccwpck_require__(672);
22
+
23
+ /** @typedef {import("./Source").Hash} Hash */
24
+ /** @typedef {import("./Source").MapOptions} MapOptions */
25
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
26
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
27
+ /** @typedef {import("./Source").SourceValue} SourceValue */
28
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
29
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
30
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
31
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
32
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
33
+
34
+ /**
35
+ * @typedef {object} BufferedMap
36
+ * @property {number} version
37
+ * @property {string[]} sources
38
+ * @property {string[]} names
39
+ * @property {string=} sourceRoot
40
+ * @property {(Buffer | "")[]=} sourcesContent
41
+ * @property {Buffer=} mappings
42
+ * @property {string} file
43
+ */
44
+
45
+ /**
46
+ * @param {null | RawSourceMap} map map
47
+ * @returns {null | BufferedMap} buffered map
48
+ */
49
+ const mapToBufferedMap = (map) => {
20
50
  if (typeof map !== "object" || !map) return map;
21
- const bufferedMap = Object.assign({}, map);
51
+ /** @type {BufferedMap} */
52
+ const bufferedMap = Object.assign(/** @type {BufferedMap} */ ({}), map);
22
53
  if (map.mappings) {
23
54
  bufferedMap.mappings = Buffer.from(map.mappings, "utf-8");
24
55
  }
25
56
  if (map.sourcesContent) {
26
57
  bufferedMap.sourcesContent = map.sourcesContent.map(
27
- str => str && Buffer.from(str, "utf-8")
58
+ (str) => str && Buffer.from(str, "utf-8")
28
59
  );
29
60
  }
30
61
  return bufferedMap;
31
62
  };
32
63
 
33
- const bufferedMapToMap = bufferedMap => {
64
+ /**
65
+ * @param {null | BufferedMap} bufferedMap buffered map
66
+ * @returns {null | RawSourceMap} map
67
+ */
68
+ const bufferedMapToMap = (bufferedMap) => {
34
69
  if (typeof bufferedMap !== "object" || !bufferedMap) return bufferedMap;
35
- const map = Object.assign({}, bufferedMap);
70
+ /** @type {RawSourceMap} */
71
+ const map = Object.assign(/** @type {RawSourceMap} */ ({}), bufferedMap);
36
72
  if (bufferedMap.mappings) {
37
73
  map.mappings = bufferedMap.mappings.toString("utf-8");
38
74
  }
39
75
  if (bufferedMap.sourcesContent) {
40
76
  map.sourcesContent = bufferedMap.sourcesContent.map(
41
- buffer => buffer && buffer.toString("utf-8")
77
+ (buffer) => buffer && buffer.toString("utf-8")
42
78
  );
43
79
  }
44
80
  return map;
45
81
  };
46
82
 
83
+ /** @typedef {{ map?: null | RawSourceMap, bufferedMap?: null | BufferedMap }} BufferEntry */
84
+ /** @typedef {Map<string, BufferEntry>} BufferedMaps */
85
+
86
+ /**
87
+ * @typedef {object} CachedData
88
+ * @property {boolean=} source
89
+ * @property {Buffer} buffer
90
+ * @property {number=} size
91
+ * @property {BufferedMaps} maps
92
+ * @property {(string | Buffer)[]=} hash
93
+ */
94
+
47
95
  class CachedSource extends Source {
96
+ // eslint-disable-next-line valid-jsdoc
97
+ /**
98
+ * @param {Source | (() => Source)} source source
99
+ * @param {CachedData=} cachedData cached data
100
+ */
48
101
  constructor(source, cachedData) {
49
102
  super();
50
103
  this._source = source;
51
104
  this._cachedSourceType = cachedData ? cachedData.source : undefined;
105
+ /**
106
+ * @private
107
+ * @type {undefined | string}
108
+ */
52
109
  this._cachedSource = undefined;
53
110
  this._cachedBuffer = cachedData ? cachedData.buffer : undefined;
54
111
  this._cachedSize = cachedData ? cachedData.size : undefined;
112
+ /**
113
+ * @private
114
+ * @type {BufferedMaps}
115
+ */
55
116
  this._cachedMaps = cachedData ? cachedData.maps : new Map();
56
117
  this._cachedHashUpdate = cachedData ? cachedData.hash : undefined;
57
118
  }
58
119
 
120
+ /**
121
+ * @returns {CachedData} cached data
122
+ */
59
123
  getCachedData() {
124
+ /** @type {BufferedMaps} */
60
125
  const bufferedMaps = new Map();
61
126
  for (const pair of this._cachedMaps) {
62
127
  let cacheEntry = pair[1];
@@ -70,15 +135,14 @@ class CachedSource extends Source {
70
135
  bufferedMap: cacheEntry.bufferedMap
71
136
  });
72
137
  }
73
- // We don't want to cache strings
74
- // So if we have a caches sources
75
- // create a buffer from it and only store
76
- // if it was a Buffer or string
77
- if (this._cachedSource) {
78
- this.buffer();
79
- }
80
138
  return {
81
- buffer: this._cachedBuffer,
139
+ // We don't want to cache strings
140
+ // So if we have a caches sources
141
+ // create a buffer from it and only store
142
+ // if it was a Buffer or string
143
+ buffer: this._cachedSource
144
+ ? this.buffer()
145
+ : /** @type {Buffer} */ (this._cachedBuffer),
82
146
  source:
83
147
  this._cachedSourceType !== undefined
84
148
  ? this._cachedSourceType
@@ -102,36 +166,62 @@ class CachedSource extends Source {
102
166
  return this._source;
103
167
  }
104
168
 
169
+ /**
170
+ * @returns {SourceValue} source
171
+ */
105
172
  source() {
106
173
  const source = this._getCachedSource();
107
174
  if (source !== undefined) return source;
108
- return (this._cachedSource = this.original().source());
175
+ return (this._cachedSource =
176
+ /** @type {string} */
177
+ (this.original().source()));
109
178
  }
110
179
 
180
+ /**
181
+ * @private
182
+ * @param {BufferEntry} cacheEntry cache entry
183
+ * @returns {null | RawSourceMap} raw source map
184
+ */
111
185
  _getMapFromCacheEntry(cacheEntry) {
112
186
  if (cacheEntry.map !== undefined) {
113
187
  return cacheEntry.map;
114
188
  } else if (cacheEntry.bufferedMap !== undefined) {
115
189
  return (cacheEntry.map = bufferedMapToMap(cacheEntry.bufferedMap));
116
190
  }
191
+
192
+ return null;
117
193
  }
118
194
 
195
+ /**
196
+ * @private
197
+ * @returns {undefined | string} cached source
198
+ */
119
199
  _getCachedSource() {
120
200
  if (this._cachedSource !== undefined) return this._cachedSource;
121
201
  if (this._cachedBuffer && this._cachedSourceType !== undefined) {
122
- return (this._cachedSource = this._cachedSourceType
202
+ const value = this._cachedSourceType
123
203
  ? this._cachedBuffer.toString("utf-8")
124
- : this._cachedBuffer);
204
+ : this._cachedBuffer;
205
+ if (isDualStringBufferCachingEnabled()) {
206
+ this._cachedSource = /** @type {string} */ (value);
207
+ }
208
+ return /** @type {string} */ (value);
125
209
  }
126
210
  }
127
211
 
212
+ /**
213
+ * @returns {Buffer} buffer
214
+ */
128
215
  buffer() {
129
216
  if (this._cachedBuffer !== undefined) return this._cachedBuffer;
130
217
  if (this._cachedSource !== undefined) {
131
- if (Buffer.isBuffer(this._cachedSource)) {
132
- return (this._cachedBuffer = this._cachedSource);
218
+ const value = Buffer.isBuffer(this._cachedSource)
219
+ ? this._cachedSource
220
+ : Buffer.from(this._cachedSource, "utf-8");
221
+ if (isDualStringBufferCachingEnabled()) {
222
+ this._cachedBuffer = value;
133
223
  }
134
- return (this._cachedBuffer = Buffer.from(this._cachedSource, "utf-8"));
224
+ return value;
135
225
  }
136
226
  if (typeof this.original().buffer === "function") {
137
227
  return (this._cachedBuffer = this.original().buffer());
@@ -140,9 +230,16 @@ class CachedSource extends Source {
140
230
  if (Buffer.isBuffer(bufferOrString)) {
141
231
  return (this._cachedBuffer = bufferOrString);
142
232
  }
143
- return (this._cachedBuffer = Buffer.from(bufferOrString, "utf-8"));
233
+ const value = Buffer.from(bufferOrString, "utf-8");
234
+ if (isDualStringBufferCachingEnabled()) {
235
+ this._cachedBuffer = value;
236
+ }
237
+ return value;
144
238
  }
145
239
 
240
+ /**
241
+ * @returns {number} size
242
+ */
146
243
  size() {
147
244
  if (this._cachedSize !== undefined) return this._cachedSize;
148
245
  if (this._cachedBuffer !== undefined) {
@@ -155,6 +252,10 @@ class CachedSource extends Source {
155
252
  return (this._cachedSize = this.original().size());
156
253
  }
157
254
 
255
+ /**
256
+ * @param {MapOptions=} options map options
257
+ * @returns {SourceAndMap} source and map
258
+ */
158
259
  sourceAndMap(options) {
159
260
  const key = options ? JSON.stringify(options) : "{}";
160
261
  const cacheEntry = this._cachedMaps.get(key);
@@ -162,6 +263,7 @@ class CachedSource extends Source {
162
263
  if (cacheEntry !== undefined) {
163
264
  // We have a cached map in some representation
164
265
  const map = this._getMapFromCacheEntry(cacheEntry);
266
+
165
267
  // Either get the cached source or compute it
166
268
  return { source: this.source(), map };
167
269
  }
@@ -174,7 +276,7 @@ class CachedSource extends Source {
174
276
  } else {
175
277
  // Compute the source and map together.
176
278
  const sourceAndMap = this.original().sourceAndMap(options);
177
- source = sourceAndMap.source;
279
+ source = /** @type {string} */ (sourceAndMap.source);
178
280
  map = sourceAndMap.map;
179
281
  this._cachedSource = source;
180
282
  }
@@ -185,6 +287,13 @@ class CachedSource extends Source {
185
287
  return { source, map };
186
288
  }
187
289
 
290
+ /**
291
+ * @param {Options} options options
292
+ * @param {OnChunk} onChunk called for each chunk of code
293
+ * @param {OnSource} onSource called for each source
294
+ * @param {OnName} onName called for each name
295
+ * @returns {GeneratedSourceInfo} generated source info
296
+ */
188
297
  streamChunks(options, onChunk, onSource, onName) {
189
298
  const key = options ? JSON.stringify(options) : "{}";
190
299
  if (
@@ -194,7 +303,8 @@ class CachedSource extends Source {
194
303
  const { source, map } = this.sourceAndMap(options);
195
304
  if (map) {
196
305
  return streamChunksOfSourceMap(
197
- source,
306
+ /** @type {string} */
307
+ (source),
198
308
  map,
199
309
  onChunk,
200
310
  onSource,
@@ -204,7 +314,8 @@ class CachedSource extends Source {
204
314
  );
205
315
  } else {
206
316
  return streamChunksOfRawSource(
207
- source,
317
+ /** @type {string} */
318
+ (source),
208
319
  onChunk,
209
320
  onSource,
210
321
  onName,
@@ -221,12 +332,16 @@ class CachedSource extends Source {
221
332
  );
222
333
  this._cachedSource = source;
223
334
  this._cachedMaps.set(key, {
224
- map,
335
+ map: /** @type {RawSourceMap} */ (map),
225
336
  bufferedMap: undefined
226
337
  });
227
338
  return result;
228
339
  }
229
340
 
341
+ /**
342
+ * @param {MapOptions=} options map options
343
+ * @returns {RawSourceMap | null} map
344
+ */
230
345
  map(options) {
231
346
  const key = options ? JSON.stringify(options) : "{}";
232
347
  const cacheEntry = this._cachedMaps.get(key);
@@ -241,15 +356,25 @@ class CachedSource extends Source {
241
356
  return map;
242
357
  }
243
358
 
359
+ /**
360
+ * @param {Hash} hash hash
361
+ * @returns {void}
362
+ */
244
363
  updateHash(hash) {
245
364
  if (this._cachedHashUpdate !== undefined) {
246
365
  for (const item of this._cachedHashUpdate) hash.update(item);
247
366
  return;
248
367
  }
368
+ /** @type {(string | Buffer)[]} */
249
369
  const update = [];
370
+ /** @type {string | undefined} */
250
371
  let currentString = undefined;
251
372
  const tracker = {
252
- update: item => {
373
+ /**
374
+ * @param {string | Buffer} item item
375
+ * @returns {void}
376
+ */
377
+ update: (item) => {
253
378
  if (typeof item === "string" && item.length < 10240) {
254
379
  if (currentString === undefined) {
255
380
  currentString = item;
@@ -269,7 +394,7 @@ class CachedSource extends Source {
269
394
  }
270
395
  }
271
396
  };
272
- this.original().updateHash(tracker);
397
+ this.original().updateHash(/** @type {Hash} */ (tracker));
273
398
  if (currentString !== undefined) {
274
399
  update.push(Buffer.from(currentString));
275
400
  }
@@ -283,30 +408,56 @@ module.exports = CachedSource;
283
408
 
284
409
  /***/ }),
285
410
 
286
- /***/ 273:
411
+ /***/ 583:
287
412
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
288
413
 
289
- "use strict";
290
414
  /*
291
415
  MIT License http://www.opensource.org/licenses/mit-license.php
292
416
  Author Tobias Koppers @sokra
293
417
  */
294
418
 
295
419
 
296
- const Source = __nccwpck_require__(171);
420
+
421
+ const Source = __nccwpck_require__(225);
422
+
423
+ /** @typedef {import("./Source").Hash} Hash */
424
+ /** @typedef {import("./Source").MapOptions} MapOptions */
425
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
426
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
427
+ /** @typedef {import("./Source").SourceValue} SourceValue */
428
+
429
+ /**
430
+ * @typedef {object} SourceLike
431
+ * @property {() => SourceValue} source
432
+ * @property {(() => Buffer)=} buffer
433
+ * @property {(() => number)=} size
434
+ * @property {((options?: MapOptions) => RawSourceMap | null)=} map
435
+ * @property {((options?: MapOptions) => SourceAndMap)=} sourceAndMap
436
+ * @property {((hash: Hash) => void)=} updateHash
437
+ */
297
438
 
298
439
  class CompatSource extends Source {
440
+ /**
441
+ * @param {SourceLike} sourceLike source like
442
+ * @returns {Source} source
443
+ */
299
444
  static from(sourceLike) {
300
445
  return sourceLike instanceof Source
301
446
  ? sourceLike
302
447
  : new CompatSource(sourceLike);
303
448
  }
304
449
 
450
+ /**
451
+ * @param {SourceLike} sourceLike source like
452
+ */
305
453
  constructor(sourceLike) {
306
454
  super();
307
455
  this._sourceLike = sourceLike;
308
456
  }
309
457
 
458
+ /**
459
+ * @returns {SourceValue} source
460
+ */
310
461
  source() {
311
462
  return this._sourceLike.source();
312
463
  }
@@ -325,6 +476,10 @@ class CompatSource extends Source {
325
476
  return super.size();
326
477
  }
327
478
 
479
+ /**
480
+ * @param {MapOptions=} options map options
481
+ * @returns {RawSourceMap | null} map
482
+ */
328
483
  map(options) {
329
484
  if (typeof this._sourceLike.map === "function") {
330
485
  return this._sourceLike.map(options);
@@ -332,6 +487,10 @@ class CompatSource extends Source {
332
487
  return super.map(options);
333
488
  }
334
489
 
490
+ /**
491
+ * @param {MapOptions=} options map options
492
+ * @returns {SourceAndMap} source and map
493
+ */
335
494
  sourceAndMap(options) {
336
495
  if (typeof this._sourceLike.sourceAndMap === "function") {
337
496
  return this._sourceLike.sourceAndMap(options);
@@ -339,6 +498,10 @@ class CompatSource extends Source {
339
498
  return super.sourceAndMap(options);
340
499
  }
341
500
 
501
+ /**
502
+ * @param {Hash} hash hash
503
+ * @returns {void}
504
+ */
342
505
  updateHash(hash) {
343
506
  if (typeof this._sourceLike.updateHash === "function") {
344
507
  return this._sourceLike.updateHash(hash);
@@ -357,29 +520,52 @@ module.exports = CompatSource;
357
520
 
358
521
  /***/ }),
359
522
 
360
- /***/ 987:
523
+ /***/ 49:
361
524
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
362
525
 
363
- "use strict";
364
526
  /*
365
527
  MIT License http://www.opensource.org/licenses/mit-license.php
366
528
  Author Tobias Koppers @sokra
367
529
  */
368
530
 
369
531
 
370
- const Source = __nccwpck_require__(171);
371
- const RawSource = __nccwpck_require__(327);
372
- const streamChunks = __nccwpck_require__(266);
373
- const { getMap, getSourceAndMap } = __nccwpck_require__(56);
532
+
533
+ const RawSource = __nccwpck_require__(745);
534
+ const Source = __nccwpck_require__(225);
535
+ const { getMap, getSourceAndMap } = __nccwpck_require__(614);
536
+ const streamChunks = __nccwpck_require__(372);
537
+
538
+ /** @typedef {import("./CompatSource").SourceLike} SourceLike */
539
+ /** @typedef {import("./Source").Hash} Hash */
540
+ /** @typedef {import("./Source").MapOptions} MapOptions */
541
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
542
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
543
+ /** @typedef {import("./Source").SourceValue} SourceValue */
544
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
545
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
546
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
547
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
548
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
549
+
550
+ /** @typedef {string | Source | SourceLike} Child */
374
551
 
375
552
  const stringsAsRawSources = new WeakSet();
376
553
 
377
554
  class ConcatSource extends Source {
378
- constructor() {
555
+ /**
556
+ *
557
+ * @param {Child[]} args children
558
+ */
559
+ constructor(...args) {
379
560
  super();
561
+ /**
562
+ * @private
563
+ * @type {Child[]}
564
+ */
380
565
  this._children = [];
381
- for (let i = 0; i < arguments.length; i++) {
382
- const item = arguments[i];
566
+
567
+ for (let i = 0; i < args.length; i++) {
568
+ const item = args[i];
383
569
  if (item instanceof ConcatSource) {
384
570
  for (const child of item._children) {
385
571
  this._children.push(child);
@@ -388,14 +574,22 @@ class ConcatSource extends Source {
388
574
  this._children.push(item);
389
575
  }
390
576
  }
391
- this._isOptimized = arguments.length === 0;
577
+
578
+ this._isOptimized = args.length === 0;
392
579
  }
393
580
 
581
+ /**
582
+ * @returns {Source[]} children
583
+ */
394
584
  getChildren() {
395
585
  if (!this._isOptimized) this._optimize();
396
- return this._children;
586
+ return /** @type {Source[]} */ (this._children);
397
587
  }
398
588
 
589
+ /**
590
+ * @param {Child} item item
591
+ * @returns {void}
592
+ */
399
593
  add(item) {
400
594
  if (item instanceof ConcatSource) {
401
595
  for (const child of item._children) {
@@ -407,6 +601,10 @@ class ConcatSource extends Source {
407
601
  this._isOptimized = false;
408
602
  }
409
603
 
604
+ /**
605
+ * @param {Child[]} items items
606
+ * @returns {void}
607
+ */
410
608
  addAllSkipOptimizing(items) {
411
609
  for (const item of items) {
412
610
  this._children.push(item);
@@ -415,8 +613,9 @@ class ConcatSource extends Source {
415
613
 
416
614
  buffer() {
417
615
  if (!this._isOptimized) this._optimize();
616
+ /** @type {Buffer[]} */
418
617
  const buffers = [];
419
- for (const child of this._children) {
618
+ for (const child of /** @type {SourceLike[]} */ (this._children)) {
420
619
  if (typeof child.buffer === "function") {
421
620
  buffers.push(child.buffer());
422
621
  } else {
@@ -432,11 +631,14 @@ class ConcatSource extends Source {
432
631
  return Buffer.concat(buffers);
433
632
  }
434
633
 
634
+ /**
635
+ * @returns {SourceValue} source
636
+ */
435
637
  source() {
436
638
  if (!this._isOptimized) this._optimize();
437
639
  let source = "";
438
640
  for (const child of this._children) {
439
- source += child.source();
641
+ source += /** @type {Source} */ (child).source();
440
642
  }
441
643
  return source;
442
644
  }
@@ -445,23 +647,44 @@ class ConcatSource extends Source {
445
647
  if (!this._isOptimized) this._optimize();
446
648
  let size = 0;
447
649
  for (const child of this._children) {
448
- size += child.size();
650
+ size += /** @type {Source} */ (child).size();
449
651
  }
450
652
  return size;
451
653
  }
452
654
 
655
+ /**
656
+ * @param {MapOptions=} options map options
657
+ * @returns {RawSourceMap | null} map
658
+ */
453
659
  map(options) {
454
660
  return getMap(this, options);
455
661
  }
456
662
 
663
+ /**
664
+ * @param {MapOptions=} options map options
665
+ * @returns {SourceAndMap} source and map
666
+ */
457
667
  sourceAndMap(options) {
458
668
  return getSourceAndMap(this, options);
459
669
  }
460
670
 
671
+ /**
672
+ * @param {Options} options options
673
+ * @param {OnChunk} onChunk called for each chunk of code
674
+ * @param {OnSource} onSource called for each source
675
+ * @param {OnName} onName called for each name
676
+ * @returns {GeneratedSourceInfo} generated source info
677
+ */
461
678
  streamChunks(options, onChunk, onSource, onName) {
462
679
  if (!this._isOptimized) this._optimize();
463
- if (this._children.length === 1)
464
- return this._children[0].streamChunks(options, onChunk, onSource, onName);
680
+ if (this._children.length === 1) {
681
+ return /** @type {ConcatSource[]} */ (this._children)[0].streamChunks(
682
+ options,
683
+ onChunk,
684
+ onSource,
685
+ onName
686
+ );
687
+ }
465
688
  let currentLineOffset = 0;
466
689
  let currentColumnOffset = 0;
467
690
  let sourceMapping = new Map();
@@ -469,8 +692,10 @@ class ConcatSource extends Source {
469
692
  const finalSource = !!(options && options.finalSource);
470
693
  let code = "";
471
694
  let needToCloseMapping = false;
472
- for (const item of this._children) {
695
+ for (const item of /** @type {Source[]} */ (this._children)) {
696
+ /** @type {number[]} */
473
697
  const sourceIndexMapping = [];
698
+ /** @type {number[]} */
474
699
  const nameIndexMapping = [];
475
700
  let lastMappingLine = 0;
476
701
  const { generatedLine, generatedColumn, source } = streamChunks(
@@ -575,15 +800,15 @@ class ConcatSource extends Source {
575
800
  needToCloseMapping = false;
576
801
  }
577
802
  }
578
- if (generatedLine > 1) {
579
- currentColumnOffset = generatedColumn;
803
+ if (/** @type {number} */ (generatedLine) > 1) {
804
+ currentColumnOffset = /** @type {number} */ (generatedColumn);
580
805
  } else {
581
- currentColumnOffset += generatedColumn;
806
+ currentColumnOffset += /** @type {number} */ (generatedColumn);
582
807
  }
583
808
  needToCloseMapping =
584
809
  needToCloseMapping ||
585
810
  (finalSource && lastMappingLine === generatedLine);
586
- currentLineOffset += generatedLine - 1;
811
+ currentLineOffset += /** @type {number} */ (generatedLine) - 1;
587
812
  }
588
813
  return {
589
814
  generatedLine: currentLineOffset + 1,
@@ -592,19 +817,29 @@ class ConcatSource extends Source {
592
817
  };
593
818
  }
594
819
 
820
+ /**
821
+ * @param {Hash} hash hash
822
+ * @returns {void}
823
+ */
595
824
  updateHash(hash) {
596
825
  if (!this._isOptimized) this._optimize();
597
826
  hash.update("ConcatSource");
598
827
  for (const item of this._children) {
599
- item.updateHash(hash);
828
+ /** @type {Source} */
829
+ (item).updateHash(hash);
600
830
  }
601
831
  }
602
832
 
603
833
  _optimize() {
604
834
  const newChildren = [];
605
835
  let currentString = undefined;
836
+ /** @type {undefined | string | [string, string] | SourceLike} */
606
837
  let currentRawSources = undefined;
607
- const addStringToRawSources = string => {
838
+ /**
839
+ * @param {string} string string
840
+ * @returns {void}
841
+ */
842
+ const addStringToRawSources = (string) => {
608
843
  if (currentRawSources === undefined) {
609
844
  currentRawSources = string;
610
845
  } else if (Array.isArray(currentRawSources)) {
@@ -613,22 +848,30 @@ class ConcatSource extends Source {
613
848
  currentRawSources = [
614
849
  typeof currentRawSources === "string"
615
850
  ? currentRawSources
616
- : currentRawSources.source(),
851
+ : /** @type {string} */ (currentRawSources.source()),
617
852
  string
618
853
  ];
619
854
  }
620
855
  };
621
- const addSourceToRawSources = source => {
856
+ /**
857
+ * @param {SourceLike} source source
858
+ * @returns {void}
859
+ */
860
+ const addSourceToRawSources = (source) => {
622
861
  if (currentRawSources === undefined) {
623
862
  currentRawSources = source;
624
863
  } else if (Array.isArray(currentRawSources)) {
625
- currentRawSources.push(source.source());
864
+ currentRawSources.push(
865
+ /** @type {string} */
866
+ (source.source())
867
+ );
626
868
  } else {
627
869
  currentRawSources = [
628
870
  typeof currentRawSources === "string"
629
871
  ? currentRawSources
630
- : currentRawSources.source(),
631
- source.source()
872
+ : /** @type {string} */ (currentRawSources.source()),
873
+ /** @type {string} */
874
+ (source.source())
632
875
  ];
633
876
  }
634
877
  };
@@ -658,7 +901,10 @@ class ConcatSource extends Source {
658
901
  currentString = undefined;
659
902
  }
660
903
  if (stringsAsRawSources.has(child)) {
661
- addSourceToRawSources(child);
904
+ addSourceToRawSources(
905
+ /** @type {SourceLike} */
906
+ (child)
907
+ );
662
908
  } else {
663
909
  if (currentRawSources !== undefined) {
664
910
  mergeRawSources();
@@ -684,27 +930,55 @@ module.exports = ConcatSource;
684
930
 
685
931
  /***/ }),
686
932
 
687
- /***/ 472:
933
+ /***/ 734:
688
934
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
689
935
 
690
- "use strict";
691
936
  /*
692
937
  MIT License http://www.opensource.org/licenses/mit-license.php
693
938
  Author Tobias Koppers @sokra
694
939
  */
695
940
 
696
941
 
697
- const { getMap, getSourceAndMap } = __nccwpck_require__(56);
698
- const splitIntoLines = __nccwpck_require__(877);
699
- const getGeneratedSourceInfo = __nccwpck_require__(864);
700
- const Source = __nccwpck_require__(171);
701
- const splitIntoPotentialTokens = __nccwpck_require__(914);
942
+
943
+ const Source = __nccwpck_require__(225);
944
+ const { getMap, getSourceAndMap } = __nccwpck_require__(614);
945
+ const getGeneratedSourceInfo = __nccwpck_require__(278);
946
+ const splitIntoLines = __nccwpck_require__(51);
947
+ const splitIntoPotentialTokens = __nccwpck_require__(904);
948
+ const {
949
+ isDualStringBufferCachingEnabled
950
+ } = __nccwpck_require__(672);
951
+
952
+ /** @typedef {import("./Source").Hash} Hash */
953
+ /** @typedef {import("./Source").MapOptions} MapOptions */
954
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
955
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
956
+ /** @typedef {import("./Source").SourceValue} SourceValue */
957
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
958
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
959
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
960
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
961
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
702
962
 
703
963
  class OriginalSource extends Source {
964
+ /**
965
+ * @param {string | Buffer} value value
966
+ * @param {string} name name
967
+ */
704
968
  constructor(value, name) {
705
969
  super();
970
+
706
971
  const isBuffer = Buffer.isBuffer(value);
972
+
973
+ /**
974
+ * @private
975
+ * @type {undefined | string}
976
+ */
707
977
  this._value = isBuffer ? undefined : value;
978
+ /**
979
+ * @private
980
+ * @type {undefined | Buffer}
981
+ */
708
982
  this._valueAsBuffer = isBuffer ? value : undefined;
709
983
  this._name = name;
710
984
  }
@@ -713,38 +987,61 @@ class OriginalSource extends Source {
713
987
  return this._name;
714
988
  }
715
989
 
990
+ /**
991
+ * @returns {SourceValue} source
992
+ */
716
993
  source() {
717
994
  if (this._value === undefined) {
718
- this._value = this._valueAsBuffer.toString("utf-8");
995
+ const value =
996
+ /** @type {Buffer} */
997
+ (this._valueAsBuffer).toString("utf-8");
998
+ if (isDualStringBufferCachingEnabled()) {
999
+ this._value = value;
1000
+ }
1001
+ return value;
719
1002
  }
720
1003
  return this._value;
721
1004
  }
722
1005
 
723
1006
  buffer() {
724
1007
  if (this._valueAsBuffer === undefined) {
725
- this._valueAsBuffer = Buffer.from(this._value, "utf-8");
1008
+ const value = Buffer.from(/** @type {string} */ (this._value), "utf-8");
1009
+ if (isDualStringBufferCachingEnabled()) {
1010
+ this._valueAsBuffer = value;
1011
+ }
1012
+ return value;
726
1013
  }
727
1014
  return this._valueAsBuffer;
728
1015
  }
729
1016
 
1017
+ /**
1018
+ * @param {MapOptions=} options map options
1019
+ * @returns {RawSourceMap | null} map
1020
+ */
730
1021
  map(options) {
731
1022
  return getMap(this, options);
732
1023
  }
733
1024
 
1025
+ /**
1026
+ * @param {MapOptions=} options map options
1027
+ * @returns {SourceAndMap} source and map
1028
+ */
734
1029
  sourceAndMap(options) {
735
1030
  return getSourceAndMap(this, options);
736
1031
  }
737
1032
 
738
1033
  /**
739
- * @param {object} options options
740
- * @param {function(string, number, number, number, number, number, number): void} onChunk called for each chunk of code
741
- * @param {function(number, string, string)} onSource called for each source
742
- * @param {function(number, string)} onName called for each name
743
- * @returns {void}
1034
+ * @param {Options} options options
1035
+ * @param {OnChunk} onChunk called for each chunk of code
1036
+ * @param {OnSource} onSource called for each source
1037
+ * @param {OnName} onName called for each name
1038
+ * @returns {GeneratedSourceInfo} generated source info
744
1039
  */
745
1040
  streamChunks(options, onChunk, onSource, onName) {
746
1041
  if (this._value === undefined) {
747
- this._value = this._valueAsBuffer.toString("utf-8");
1042
+ this._value =
1043
+ /** @type {Buffer} */
1044
+ (this._valueAsBuffer).toString("utf-8");
748
1045
  }
749
1046
  onSource(0, this._name, this._value);
750
1047
  const finalSource = !!(options && options.finalSource);
@@ -781,10 +1078,14 @@ class OriginalSource extends Source {
781
1078
  const result = getGeneratedSourceInfo(this._value);
782
1079
  const { generatedLine, generatedColumn } = result;
783
1080
  if (generatedColumn === 0) {
784
- for (let line = 1; line < generatedLine; line++)
1081
+ for (let line = 1; line < /** @type {number} */ (generatedLine); line++)
785
1082
  onChunk(undefined, line, 0, 0, line, 0, -1);
786
1083
  } else {
787
- for (let line = 1; line <= generatedLine; line++)
1084
+ for (
1085
+ let line = 1;
1086
+ line <= /** @type {number} */ (generatedLine);
1087
+ line++
1088
+ )
788
1089
  onChunk(undefined, line, 0, 0, line, 0, -1);
789
1090
  }
790
1091
  return result;
@@ -793,12 +1094,14 @@ class OriginalSource extends Source {
793
1094
  // we need to split source by lines
794
1095
  let line = 1;
795
1096
  const matches = splitIntoLines(this._value);
1097
+ /** @type {string | undefined} */
796
1098
  let match;
797
1099
  for (match of matches) {
798
1100
  onChunk(finalSource ? undefined : match, line, 0, 0, line, 0, -1);
799
1101
  line++;
800
1102
  }
801
- return matches.length === 0 || match.endsWith("\n")
1103
+ return matches.length === 0 ||
1104
+ /** @type {string} */ (match).endsWith("\n")
802
1105
  ? {
803
1106
  generatedLine: matches.length + 1,
804
1107
  generatedColumn: 0,
@@ -806,18 +1109,23 @@ class OriginalSource extends Source {
806
1109
  }
807
1110
  : {
808
1111
  generatedLine: matches.length,
809
- generatedColumn: match.length,
1112
+ generatedColumn: /** @type {string} */ (match).length,
810
1113
  source: finalSource ? this._value : undefined
811
1114
  };
812
1115
  }
813
1116
  }
814
1117
 
1118
+ /**
1119
+ * @param {Hash} hash hash
1120
+ * @returns {void}
1121
+ */
815
1122
  updateHash(hash) {
816
- if (this._valueAsBuffer === undefined) {
817
- this._valueAsBuffer = Buffer.from(this._value, "utf-8");
818
- }
819
1123
  hash.update("OriginalSource");
820
- hash.update(this._valueAsBuffer);
1124
+ hash.update(
1125
+ this._valueAsBuffer
1126
+ ? /** @type {Buffer} */ (this._valueAsBuffer)
1127
+ : /** @type {string} */ (this._value)
1128
+ );
821
1129
  hash.update(this._name || "");
822
1130
  }
823
1131
  }
@@ -827,26 +1135,45 @@ module.exports = OriginalSource;
827
1135
 
828
1136
  /***/ }),
829
1137
 
830
- /***/ 663:
1138
+ /***/ 805:
831
1139
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
832
1140
 
833
- "use strict";
834
1141
  /*
835
1142
  MIT License http://www.opensource.org/licenses/mit-license.php
836
1143
  Author Tobias Koppers @sokra
837
1144
  */
838
1145
 
839
1146
 
840
- const Source = __nccwpck_require__(171);
841
- const RawSource = __nccwpck_require__(327);
842
- const streamChunks = __nccwpck_require__(266);
843
- const { getMap, getSourceAndMap } = __nccwpck_require__(56);
1147
+
1148
+ const RawSource = __nccwpck_require__(745);
1149
+ const Source = __nccwpck_require__(225);
1150
+ const { getMap, getSourceAndMap } = __nccwpck_require__(614);
1151
+ const streamChunks = __nccwpck_require__(372);
1152
+
1153
+ /** @typedef {import("./Source").Hash} Hash */
1154
+ /** @typedef {import("./Source").MapOptions} MapOptions */
1155
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
1156
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
1157
+ /** @typedef {import("./Source").SourceValue} SourceValue */
1158
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
1159
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
1160
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
1161
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
1162
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
844
1163
 
845
1164
  const REPLACE_REGEX = /\n(?=.|\s)/g;
846
1165
 
847
1166
  class PrefixSource extends Source {
1167
+ /**
1168
+ * @param {string} prefix prefix
1169
+ * @param {string | Buffer | Source} source source
1170
+ */
848
1171
  constructor(prefix, source) {
849
1172
  super();
1173
+ /**
1174
+ * @private
1175
+ * @type {Source}
1176
+ */
850
1177
  this._source =
851
1178
  typeof source === "string" || Buffer.isBuffer(source)
852
1179
  ? new RawSource(source, true)
@@ -862,22 +1189,40 @@ class PrefixSource extends Source {
862
1189
  return this._source;
863
1190
  }
864
1191
 
1192
+ /**
1193
+ * @returns {SourceValue} source
1194
+ */
865
1195
  source() {
866
- const node = this._source.source();
1196
+ const node = /** @type {string} */ (this._source.source());
867
1197
  const prefix = this._prefix;
868
1198
  return prefix + node.replace(REPLACE_REGEX, "\n" + prefix);
869
1199
  }
870
1200
 
871
1201
  // TODO efficient buffer() implementation
872
1202
 
1203
+ /**
1204
+ * @param {MapOptions=} options map options
1205
+ * @returns {RawSourceMap | null} map
1206
+ */
873
1207
  map(options) {
874
1208
  return getMap(this, options);
875
1209
  }
876
1210
 
1211
+ /**
1212
+ * @param {MapOptions=} options map options
1213
+ * @returns {SourceAndMap} source and map
1214
+ */
877
1215
  sourceAndMap(options) {
878
1216
  return getSourceAndMap(this, options);
879
1217
  }
880
1218
 
1219
+ /**
1220
+ * @param {Options} options options
1221
+ * @param {OnChunk} onChunk called for each chunk of code
1222
+ * @param {OnSource} onSource called for each source
1223
+ * @param {OnName} onName called for each name
1224
+ * @returns {GeneratedSourceInfo} generated source info
1225
+ */
881
1226
  streamChunks(options, onChunk, onSource, onName) {
882
1227
  const prefix = this._prefix;
883
1228
  const prefixOffset = prefix.length;
@@ -929,7 +1274,9 @@ class PrefixSource extends Source {
929
1274
  return {
930
1275
  generatedLine,
931
1276
  generatedColumn:
932
- generatedColumn === 0 ? 0 : prefixOffset + generatedColumn,
1277
+ generatedColumn === 0
1278
+ ? 0
1279
+ : prefixOffset + /** @type {number} */ (generatedColumn),
933
1280
  source:
934
1281
  source !== undefined
935
1282
  ? prefix + source.replace(REPLACE_REGEX, "\n" + prefix)
@@ -937,6 +1284,10 @@ class PrefixSource extends Source {
937
1284
  };
938
1285
  }
939
1286
 
1287
+ /**
1288
+ * @param {Hash} hash hash
1289
+ * @returns {void}
1290
+ */
940
1291
  updateHash(hash) {
941
1292
  hash.update("PrefixSource");
942
1293
  this._source.updateHash(hash);
@@ -949,10 +1300,9 @@ module.exports = PrefixSource;
949
1300
 
950
1301
  /***/ }),
951
1302
 
952
- /***/ 327:
1303
+ /***/ 745:
953
1304
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
954
1305
 
955
- "use strict";
956
1306
  /*
957
1307
  MIT License http://www.opensource.org/licenses/mit-license.php
958
1308
  Author Tobias Koppers @sokra
@@ -960,63 +1310,116 @@ module.exports = PrefixSource;
960
1310
 
961
1311
 
962
1312
 
963
- const streamChunksOfRawSource = __nccwpck_require__(348);
964
- const Source = __nccwpck_require__(171);
1313
+ const Source = __nccwpck_require__(225);
1314
+ const streamChunksOfRawSource = __nccwpck_require__(482);
1315
+ const {
1316
+ internString,
1317
+ isDualStringBufferCachingEnabled
1318
+ } = __nccwpck_require__(672);
1319
+
1320
+ /** @typedef {import("./Source").Hash} Hash */
1321
+ /** @typedef {import("./Source").MapOptions} MapOptions */
1322
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
1323
+ /** @typedef {import("./Source").SourceValue} SourceValue */
1324
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
1325
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
1326
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
1327
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
1328
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
965
1329
 
966
1330
  class RawSource extends Source {
1331
+ /**
1332
+ * @param {string | Buffer} value value
1333
+ * @param {boolean=} convertToString convert to string
1334
+ */
967
1335
  constructor(value, convertToString = false) {
968
1336
  super();
969
1337
  const isBuffer = Buffer.isBuffer(value);
970
1338
  if (!isBuffer && typeof value !== "string") {
971
- throw new TypeError("argument 'value' must be either string of Buffer");
1339
+ throw new TypeError("argument 'value' must be either string or Buffer");
972
1340
  }
973
1341
  this._valueIsBuffer = !convertToString && isBuffer;
974
- this._value = convertToString && isBuffer ? undefined : value;
1342
+ const internedString =
1343
+ typeof value === "string" ? internString(value) : undefined;
1344
+ /**
1345
+ * @private
1346
+ * @type {undefined | string | Buffer}
1347
+ */
1348
+ this._value =
1349
+ convertToString && isBuffer
1350
+ ? undefined
1351
+ : typeof value === "string"
1352
+ ? internedString
1353
+ : value;
1354
+ /**
1355
+ * @private
1356
+ * @type {undefined | Buffer}
1357
+ */
975
1358
  this._valueAsBuffer = isBuffer ? value : undefined;
976
- this._valueAsString = isBuffer ? undefined : value;
1359
+ /**
1360
+ * @private
1361
+ * @type {undefined | string}
1362
+ */
1363
+ this._valueAsString = isBuffer ? undefined : internedString;
977
1364
  }
978
1365
 
979
1366
  isBuffer() {
980
1367
  return this._valueIsBuffer;
981
1368
  }
982
1369
 
1370
+ /**
1371
+ * @returns {SourceValue} source
1372
+ */
983
1373
  source() {
984
1374
  if (this._value === undefined) {
985
- this._value = this._valueAsBuffer.toString("utf-8");
1375
+ const value =
1376
+ /** @type {Buffer} */
1377
+ (this._valueAsBuffer).toString("utf-8");
1378
+ if (isDualStringBufferCachingEnabled()) {
1379
+ this._value = internString(value);
1380
+ }
1381
+ return value;
986
1382
  }
987
1383
  return this._value;
988
1384
  }
989
1385
 
990
1386
  buffer() {
991
1387
  if (this._valueAsBuffer === undefined) {
992
- this._valueAsBuffer = Buffer.from(this._value, "utf-8");
1388
+ const value = Buffer.from(/** @type {string} */ (this._value), "utf-8");
1389
+ if (isDualStringBufferCachingEnabled()) {
1390
+ this._valueAsBuffer = value;
1391
+ }
1392
+ return value;
993
1393
  }
994
1394
  return this._valueAsBuffer;
995
1395
  }
996
1396
 
1397
+ /**
1398
+ * @param {MapOptions=} options map options
1399
+ * @returns {RawSourceMap | null} map
1400
+ */
997
1401
  map(options) {
998
1402
  return null;
999
1403
  }
1000
1404
 
1001
1405
  /**
1002
- * @param {object} options options
1003
- * @param {function(string, number, number, number, number, number, number): void} onChunk called for each chunk of code
1004
- * @param {function(number, string, string)} onSource called for each source
1005
- * @param {function(number, string)} onName called for each name
1006
- * @returns {void}
1406
+ * @param {Options} options options
1407
+ * @param {OnChunk} onChunk called for each chunk of code
1408
+ * @param {OnSource} onSource called for each source
1409
+ * @param {OnName} onName called for each name
1410
+ * @returns {GeneratedSourceInfo} generated source info
1007
1411
  */
1008
1412
  streamChunks(options, onChunk, onSource, onName) {
1009
- if (this._value === undefined) {
1010
- this._value = Buffer.from(this._valueAsBuffer, "utf-8");
1011
- }
1012
- if (this._valueAsString === undefined) {
1013
- this._valueAsString =
1014
- typeof this._value === "string"
1015
- ? this._value
1016
- : this._value.toString("utf-8");
1413
+ let strValue = this._valueAsString;
1414
+ if (strValue === undefined) {
1415
+ const value = this.source();
1416
+ strValue = typeof value === "string" ? value : value.toString("utf-8");
1417
+ if (isDualStringBufferCachingEnabled()) {
1418
+ this._valueAsString = internString(strValue);
1419
+ }
1017
1420
  }
1018
1421
  return streamChunksOfRawSource(
1019
- this._valueAsString,
1422
+ strValue,
1020
1423
  onChunk,
1021
1424
  onSource,
1022
1425
  onName,
@@ -1024,12 +1427,17 @@ class RawSource extends Source {
1024
1427
  );
1025
1428
  }
1026
1429
 
1430
+ /**
1431
+ * @param {Hash} hash hash
1432
+ * @returns {void}
1433
+ */
1027
1434
  updateHash(hash) {
1028
- if (this._valueAsBuffer === undefined) {
1029
- this._valueAsBuffer = Buffer.from(this._value, "utf-8");
1030
- }
1031
1435
  hash.update("RawSource");
1032
- hash.update(this._valueAsBuffer);
1436
+ hash.update(
1437
+ this._valueAsBuffer
1438
+ ? /** @type {Buffer} */ (this._valueAsBuffer)
1439
+ : /** @type {string} */ (this._valueAsString)
1440
+ );
1033
1441
  }
1034
1442
  }
1035
1443
 
@@ -1038,20 +1446,31 @@ module.exports = RawSource;
1038
1446
 
1039
1447
  /***/ }),
1040
1448
 
1041
- /***/ 829:
1449
+ /***/ 807:
1042
1450
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1043
1451
 
1044
- "use strict";
1045
1452
  /*
1046
1453
  MIT License http://www.opensource.org/licenses/mit-license.php
1047
1454
  Author Tobias Koppers @sokra
1048
1455
  */
1049
1456
 
1050
1457
 
1051
- const { getMap, getSourceAndMap } = __nccwpck_require__(56);
1052
- const streamChunks = __nccwpck_require__(266);
1053
- const Source = __nccwpck_require__(171);
1054
- const splitIntoLines = __nccwpck_require__(877);
1458
+
1459
+ const Source = __nccwpck_require__(225);
1460
+ const { getMap, getSourceAndMap } = __nccwpck_require__(614);
1461
+ const splitIntoLines = __nccwpck_require__(51);
1462
+ const streamChunks = __nccwpck_require__(372);
1463
+
1464
+ /** @typedef {import("./Source").Hash} Hash */
1465
+ /** @typedef {import("./Source").MapOptions} MapOptions */
1466
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
1467
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
1468
+ /** @typedef {import("./Source").SourceValue} SourceValue */
1469
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
1470
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
1471
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
1472
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
1473
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
1055
1474
 
1056
1475
  // since v8 7.0, Array.prototype.sort is stable
1057
1476
  const hasStableSort =
@@ -1064,6 +1483,12 @@ const hasStableSort =
1064
1483
  const MAX_SOURCE_POSITION = 0x20000000;
1065
1484
 
1066
1485
  class Replacement {
1486
+ /**
1487
+ * @param {number} start start
1488
+ * @param {number} end end
1489
+ * @param {string} content content
1490
+ * @param {string=} name name
1491
+ */
1067
1492
  constructor(start, end, content, name) {
1068
1493
  this.start = start;
1069
1494
  this.end = end;
@@ -1076,6 +1501,10 @@ class Replacement {
1076
1501
  }
1077
1502
 
1078
1503
  class ReplaceSource extends Source {
1504
+ /**
1505
+ * @param {Source} source source
1506
+ * @param {string=} name name
1507
+ */
1079
1508
  constructor(source, name) {
1080
1509
  super();
1081
1510
  this._source = source;
@@ -1094,6 +1523,13 @@ class ReplaceSource extends Source {
1094
1523
  return this._replacements;
1095
1524
  }
1096
1525
 
1526
+ /**
1527
+ * @param {number} start start
1528
+ * @param {number} end end
1529
+ * @param {string} newValue new value
1530
+ * @param {string=} name name
1531
+ * @returns {void}
1532
+ */
1097
1533
  replace(start, end, newValue, name) {
1098
1534
  if (typeof newValue !== "string")
1099
1535
  throw new Error(
@@ -1103,6 +1539,12 @@ class ReplaceSource extends Source {
1103
1539
  this._isSorted = false;
1104
1540
  }
1105
1541
 
1542
+ /**
1543
+ * @param {number} pos pos
1544
+ * @param {string} newValue new value
1545
+ * @param {string=} name name
1546
+ * @returns {void}
1547
+ */
1106
1548
  insert(pos, newValue, name) {
1107
1549
  if (typeof newValue !== "string")
1108
1550
  throw new Error(
@@ -1115,6 +1557,9 @@ class ReplaceSource extends Source {
1115
1557
  this._isSorted = false;
1116
1558
  }
1117
1559
 
1560
+ /**
1561
+ * @returns {SourceValue} source
1562
+ */
1118
1563
  source() {
1119
1564
  if (this._replacements.length === 0) {
1120
1565
  return this._source.source();
@@ -1144,6 +1589,10 @@ class ReplaceSource extends Source {
1144
1589
  return result.join("");
1145
1590
  }
1146
1591
 
1592
+ /**
1593
+ * @param {MapOptions=} options map options
1594
+ * @returns {RawSourceMap | null} map
1595
+ */
1147
1596
  map(options) {
1148
1597
  if (this._replacements.length === 0) {
1149
1598
  return this._source.map(options);
@@ -1151,6 +1600,10 @@ class ReplaceSource extends Source {
1151
1600
  return getMap(this, options);
1152
1601
  }
1153
1602
 
1603
+ /**
1604
+ * @param {MapOptions=} options map options
1605
+ * @returns {SourceAndMap} source and map
1606
+ */
1154
1607
  sourceAndMap(options) {
1155
1608
  if (this._replacements.length === 0) {
1156
1609
  return this._source.sourceAndMap(options);
@@ -1179,27 +1632,49 @@ class ReplaceSource extends Source {
1179
1632
  if (diff1 !== 0) return diff1;
1180
1633
  const diff2 = a.end - b.end;
1181
1634
  if (diff2 !== 0) return diff2;
1182
- return a.index - b.index;
1635
+ return (
1636
+ /** @type {number} */ (a.index) - /** @type {number} */ (b.index)
1637
+ );
1183
1638
  });
1184
1639
  }
1185
1640
  this._isSorted = true;
1186
1641
  }
1187
1642
 
1643
+ /**
1644
+ * @param {Options} options options
1645
+ * @param {OnChunk} onChunk called for each chunk of code
1646
+ * @param {OnSource} onSource called for each source
1647
+ * @param {OnName} onName called for each name
1648
+ * @returns {GeneratedSourceInfo} generated source info
1649
+ */
1188
1650
  streamChunks(options, onChunk, onSource, onName) {
1189
1651
  this._sortReplacements();
1190
- const repls = this._replacements;
1652
+ const replacements = this._replacements;
1191
1653
  let pos = 0;
1192
1654
  let i = 0;
1193
1655
  let replacmentEnd = -1;
1194
1656
  let nextReplacement =
1195
- i < repls.length ? Math.floor(repls[i].start) : MAX_SOURCE_POSITION;
1657
+ i < replacements.length
1658
+ ? Math.floor(replacements[i].start)
1659
+ : MAX_SOURCE_POSITION;
1196
1660
  let generatedLineOffset = 0;
1197
1661
  let generatedColumnOffset = 0;
1198
1662
  let generatedColumnOffsetLine = 0;
1663
+ /** @type {(string | string[] | undefined)[]} */
1199
1664
  const sourceContents = [];
1665
+ /** @type {Map<string, number>} */
1200
1666
  const nameMapping = new Map();
1667
+ /** @type {number[]} */
1201
1668
  const nameIndexMapping = [];
1669
+ /**
1670
+ * @param {number} sourceIndex source index
1671
+ * @param {number} line line
1672
+ * @param {number} column column
1673
+ * @param {string} expectedChunk expected chunk
1674
+ * @returns {boolean} result
1675
+ */
1202
1676
  const checkOriginalContent = (sourceIndex, line, column, expectedChunk) => {
1677
+ /** @type {undefined | string | string[]} */
1203
1678
  let content =
1204
1679
  sourceIndex < sourceContents.length
1205
1680
  ? sourceContents[sourceIndex]
@@ -1220,7 +1695,7 @@ class ReplaceSource extends Source {
1220
1695
  this._source,
1221
1696
  Object.assign({}, options, { finalSource: false }),
1222
1697
  (
1223
- chunk,
1698
+ _chunk,
1224
1699
  generatedLine,
1225
1700
  generatedColumn,
1226
1701
  sourceIndex,
@@ -1229,6 +1704,7 @@ class ReplaceSource extends Source {
1229
1704
  nameIndex
1230
1705
  ) => {
1231
1706
  let chunkPos = 0;
1707
+ const chunk = /** @type {string} */ (_chunk);
1232
1708
  let endPos = pos + chunk.length;
1233
1709
 
1234
1710
  // Skip over when it has been replaced
@@ -1313,7 +1789,7 @@ class ReplaceSource extends Source {
1313
1789
  }
1314
1790
 
1315
1791
  // Insert replacement content splitted into chunks by lines
1316
- const { content, name } = repls[i];
1792
+ const { content, name } = replacements[i];
1317
1793
  let matches = splitIntoLines(content);
1318
1794
  let replacementNameIndex = nameIndex;
1319
1795
  if (sourceIndex >= 0 && name) {
@@ -1361,14 +1837,14 @@ class ReplaceSource extends Source {
1361
1837
  // Remove replaced content by settings this variable
1362
1838
  replacmentEnd = Math.max(
1363
1839
  replacmentEnd,
1364
- Math.floor(repls[i].end + 1)
1840
+ Math.floor(replacements[i].end + 1)
1365
1841
  );
1366
1842
 
1367
1843
  // Move to next replacment
1368
1844
  i++;
1369
1845
  nextReplacement =
1370
- i < repls.length
1371
- ? Math.floor(repls[i].start)
1846
+ i < replacements.length
1847
+ ? Math.floor(replacements[i].start)
1372
1848
  : MAX_SOURCE_POSITION;
1373
1849
 
1374
1850
  // Skip over when it has been replaced
@@ -1454,19 +1930,20 @@ class ReplaceSource extends Source {
1454
1930
 
1455
1931
  // Handle remaining replacements
1456
1932
  let remainer = "";
1457
- for (; i < repls.length; i++) {
1458
- remainer += repls[i].content;
1933
+ for (; i < replacements.length; i++) {
1934
+ remainer += replacements[i].content;
1459
1935
  }
1460
1936
 
1461
1937
  // Insert remaining replacements content splitted into chunks by lines
1462
- let line = generatedLine + generatedLineOffset;
1938
+ let line = /** @type {number} */ (generatedLine) + generatedLineOffset;
1463
1939
  let matches = splitIntoLines(remainer);
1464
1940
  for (let m = 0; m < matches.length; m++) {
1465
1941
  const contentLine = matches[m];
1466
1942
  onChunk(
1467
1943
  contentLine,
1468
1944
  line,
1469
- generatedColumn +
1945
+ /** @type {number} */
1946
+ (generatedColumn) +
1470
1947
  (line === generatedColumnOffsetLine ? generatedColumnOffset : 0),
1471
1948
  -1,
1472
1949
  -1,
@@ -1484,7 +1961,7 @@ class ReplaceSource extends Source {
1484
1961
  } else {
1485
1962
  generatedLineOffset++;
1486
1963
  line++;
1487
- generatedColumnOffset = -generatedColumn;
1964
+ generatedColumnOffset = -(/** @type {number} */ (generatedColumn));
1488
1965
  generatedColumnOffsetLine = line;
1489
1966
  }
1490
1967
  }
@@ -1492,40 +1969,56 @@ class ReplaceSource extends Source {
1492
1969
  return {
1493
1970
  generatedLine: line,
1494
1971
  generatedColumn:
1495
- generatedColumn +
1972
+ /** @type {number} */
1973
+ (generatedColumn) +
1496
1974
  (line === generatedColumnOffsetLine ? generatedColumnOffset : 0)
1497
1975
  };
1498
1976
  }
1499
1977
 
1978
+ /**
1979
+ * @param {Hash} hash hash
1980
+ * @returns {void}
1981
+ */
1500
1982
  updateHash(hash) {
1501
1983
  this._sortReplacements();
1502
1984
  hash.update("ReplaceSource");
1503
1985
  this._source.updateHash(hash);
1504
1986
  hash.update(this._name || "");
1505
1987
  for (const repl of this._replacements) {
1506
- hash.update(`${repl.start}${repl.end}${repl.content}${repl.name}`);
1988
+ hash.update(
1989
+ `${repl.start}${repl.end}${repl.content}${repl.name ? repl.name : ""}`
1990
+ );
1507
1991
  }
1508
1992
  }
1509
1993
  }
1510
1994
 
1511
1995
  module.exports = ReplaceSource;
1996
+ module.exports.Replacement = Replacement;
1512
1997
 
1513
1998
 
1514
1999
  /***/ }),
1515
2000
 
1516
- /***/ 908:
2001
+ /***/ 90:
1517
2002
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1518
2003
 
1519
- "use strict";
1520
2004
  /*
1521
2005
  MIT License http://www.opensource.org/licenses/mit-license.php
1522
2006
  Author Tobias Koppers @sokra
1523
2007
  */
1524
2008
 
1525
2009
 
1526
- const Source = __nccwpck_require__(171);
2010
+
2011
+ const Source = __nccwpck_require__(225);
2012
+
2013
+ /** @typedef {import("./Source").Hash} Hash */
2014
+ /** @typedef {import("./Source").MapOptions} MapOptions */
2015
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
2016
+ /** @typedef {import("./Source").SourceValue} SourceValue */
1527
2017
 
1528
2018
  class SizeOnlySource extends Source {
2019
+ /**
2020
+ * @param {number} size size
2021
+ */
1529
2022
  constructor(size) {
1530
2023
  super();
1531
2024
  this._size = size;
@@ -1541,19 +2034,33 @@ class SizeOnlySource extends Source {
1541
2034
  return this._size;
1542
2035
  }
1543
2036
 
2037
+ /**
2038
+ * @returns {SourceValue} source
2039
+ */
1544
2040
  source() {
1545
2041
  throw this._error();
1546
2042
  }
1547
2043
 
2044
+ /**
2045
+ * @returns {Buffer} buffer
2046
+ */
1548
2047
  buffer() {
1549
2048
  throw this._error();
1550
2049
  }
1551
2050
 
2051
+ /**
2052
+ * @param {MapOptions=} options map options
2053
+ * @returns {RawSourceMap | null} map
2054
+ */
1552
2055
  map(options) {
1553
2056
  throw this._error();
1554
2057
  }
1555
2058
 
1556
- updateHash() {
2059
+ /**
2060
+ * @param {Hash} hash hash
2061
+ * @returns {void}
2062
+ */
2063
+ updateHash(hash) {
1557
2064
  throw this._error();
1558
2065
  }
1559
2066
  }
@@ -1563,17 +2070,51 @@ module.exports = SizeOnlySource;
1563
2070
 
1564
2071
  /***/ }),
1565
2072
 
1566
- /***/ 171:
2073
+ /***/ 225:
1567
2074
  /***/ ((module) => {
1568
2075
 
1569
- "use strict";
1570
2076
  /*
1571
2077
  MIT License http://www.opensource.org/licenses/mit-license.php
1572
2078
  Author Tobias Koppers @sokra
1573
2079
  */
1574
2080
 
1575
2081
 
2082
+
2083
+ /**
2084
+ * @typedef {object} MapOptions
2085
+ * @property {boolean=} columns
2086
+ * @property {boolean=} module
2087
+ */
2088
+
2089
+ /**
2090
+ * @typedef {object} RawSourceMap
2091
+ * @property {number} version
2092
+ * @property {string[]} sources
2093
+ * @property {string[]} names
2094
+ * @property {string=} sourceRoot
2095
+ * @property {string[]=} sourcesContent
2096
+ * @property {string} mappings
2097
+ * @property {string} file
2098
+ */
2099
+
2100
+ /** @typedef {string | Buffer} SourceValue */
2101
+
2102
+ /**
2103
+ * @typedef {object} SourceAndMap
2104
+ * @property {SourceValue} source
2105
+ * @property {RawSourceMap | null} map
2106
+ */
2107
+
2108
+ /**
2109
+ * @typedef {object} Hash
2110
+ * @property {(data: string | Buffer, inputEncoding?: string) => Hash} update
2111
+ * @property {(encoding?: string) => string | Buffer} digest
2112
+ */
2113
+
1576
2114
  class Source {
2115
+ /**
2116
+ * @returns {SourceValue} source
2117
+ */
1577
2118
  source() {
1578
2119
  throw new Error("Abstract");
1579
2120
  }
@@ -1588,10 +2129,18 @@ class Source {
1588
2129
  return this.buffer().length;
1589
2130
  }
1590
2131
 
2132
+ /**
2133
+ * @param {MapOptions=} options map options
2134
+ * @returns {RawSourceMap | null} map
2135
+ */
1591
2136
  map(options) {
1592
2137
  return null;
1593
2138
  }
1594
2139
 
2140
+ /**
2141
+ * @param {MapOptions=} options map options
2142
+ * @returns {SourceAndMap} source and map
2143
+ */
1595
2144
  sourceAndMap(options) {
1596
2145
  return {
1597
2146
  source: this.source(),
@@ -1599,6 +2148,10 @@ class Source {
1599
2148
  };
1600
2149
  }
1601
2150
 
2151
+ /**
2152
+ * @param {Hash} hash hash
2153
+ * @returns {void}
2154
+ */
1602
2155
  updateHash(hash) {
1603
2156
  throw new Error("Abstract");
1604
2157
  }
@@ -1609,22 +2162,44 @@ module.exports = Source;
1609
2162
 
1610
2163
  /***/ }),
1611
2164
 
1612
- /***/ 188:
2165
+ /***/ 150:
1613
2166
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1614
2167
 
1615
- "use strict";
1616
2168
  /*
1617
2169
  MIT License http://www.opensource.org/licenses/mit-license.php
1618
2170
  Author Tobias Koppers @sokra
1619
2171
  */
1620
2172
 
1621
2173
 
1622
- const Source = __nccwpck_require__(171);
1623
- const streamChunksOfSourceMap = __nccwpck_require__(958);
1624
- const streamChunksOfCombinedSourceMap = __nccwpck_require__(503);
1625
- const { getMap, getSourceAndMap } = __nccwpck_require__(56);
2174
+
2175
+ const Source = __nccwpck_require__(225);
2176
+ const { getMap, getSourceAndMap } = __nccwpck_require__(614);
2177
+ const streamChunksOfCombinedSourceMap = __nccwpck_require__(549);
2178
+ const streamChunksOfSourceMap = __nccwpck_require__(492);
2179
+ const {
2180
+ isDualStringBufferCachingEnabled
2181
+ } = __nccwpck_require__(672);
2182
+
2183
+ /** @typedef {import("./Source").Hash} Hash */
2184
+ /** @typedef {import("./Source").MapOptions} MapOptions */
2185
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
2186
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
2187
+ /** @typedef {import("./Source").SourceValue} SourceValue */
2188
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
2189
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
2190
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
2191
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
2192
+ /** @typedef {import("./helpers/streamChunks").Options} Options */
1626
2193
 
1627
2194
  class SourceMapSource extends Source {
2195
+ /**
2196
+ * @param {string | Buffer} value value
2197
+ * @param {string} name name
2198
+ * @param {string | Buffer | RawSourceMap=} sourceMap source map
2199
+ * @param {SourceValue=} originalSource original source
2200
+ * @param {(string | Buffer | RawSourceMap)=} innerSourceMap inner source map
2201
+ * @param {boolean=} removeOriginalSource do remove original source
2202
+ */
1628
2203
  constructor(
1629
2204
  value,
1630
2205
  name,
@@ -1635,7 +2210,15 @@ class SourceMapSource extends Source {
1635
2210
  ) {
1636
2211
  super();
1637
2212
  const valueIsBuffer = Buffer.isBuffer(value);
2213
+ /**
2214
+ * @private
2215
+ * @type {undefined | string}
2216
+ */
1638
2217
  this._valueAsString = valueIsBuffer ? undefined : value;
2218
+ /**
2219
+ * @private
2220
+ * @type {undefined | Buffer}
2221
+ */
1639
2222
  this._valueAsBuffer = valueIsBuffer ? value : undefined;
1640
2223
 
1641
2224
  this._name = name;
@@ -1643,9 +2226,21 @@ class SourceMapSource extends Source {
1643
2226
  this._hasSourceMap = !!sourceMap;
1644
2227
  const sourceMapIsBuffer = Buffer.isBuffer(sourceMap);
1645
2228
  const sourceMapIsString = typeof sourceMap === "string";
2229
+ /**
2230
+ * @private
2231
+ * @type {undefined | RawSourceMap}
2232
+ */
1646
2233
  this._sourceMapAsObject =
1647
2234
  sourceMapIsBuffer || sourceMapIsString ? undefined : sourceMap;
2235
+ /**
2236
+ * @private
2237
+ * @type {undefined | string}
2238
+ */
1648
2239
  this._sourceMapAsString = sourceMapIsString ? sourceMap : undefined;
2240
+ /**
2241
+ * @private
2242
+ * @type {undefined | Buffer}
2243
+ */
1649
2244
  this._sourceMapAsBuffer = sourceMapIsBuffer ? sourceMap : undefined;
1650
2245
 
1651
2246
  this._hasOriginalSource = !!originalSource;
@@ -1660,13 +2255,25 @@ class SourceMapSource extends Source {
1660
2255
  this._hasInnerSourceMap = !!innerSourceMap;
1661
2256
  const innerSourceMapIsBuffer = Buffer.isBuffer(innerSourceMap);
1662
2257
  const innerSourceMapIsString = typeof innerSourceMap === "string";
2258
+ /**
2259
+ * @private
2260
+ * @type {undefined | RawSourceMap}
2261
+ */
1663
2262
  this._innerSourceMapAsObject =
1664
2263
  innerSourceMapIsBuffer || innerSourceMapIsString
1665
2264
  ? undefined
1666
2265
  : innerSourceMap;
2266
+ /**
2267
+ * @private
2268
+ * @type {undefined | string}
2269
+ */
1667
2270
  this._innerSourceMapAsString = innerSourceMapIsString
1668
2271
  ? innerSourceMap
1669
2272
  : undefined;
2273
+ /**
2274
+ * @private
2275
+ * @type {undefined | Buffer}
2276
+ */
1670
2277
  this._innerSourceMapAsBuffer = innerSourceMapIsBuffer
1671
2278
  ? innerSourceMap
1672
2279
  : undefined;
@@ -1674,147 +2281,211 @@ class SourceMapSource extends Source {
1674
2281
  this._removeOriginalSource = removeOriginalSource;
1675
2282
  }
1676
2283
 
1677
- _ensureValueBuffer() {
2284
+ // eslint-disable-next-line valid-jsdoc
2285
+ /**
2286
+ * @returns {[Buffer, string, Buffer, Buffer | undefined, Buffer | undefined, boolean | undefined]} args
2287
+ */
2288
+ getArgsAsBuffers() {
2289
+ return [
2290
+ this.buffer(),
2291
+ this._name,
2292
+ this._sourceMapBuffer(),
2293
+ this._originalSourceBuffer(),
2294
+ this._innerSourceMapBuffer(),
2295
+ this._removeOriginalSource
2296
+ ];
2297
+ }
2298
+
2299
+ buffer() {
1678
2300
  if (this._valueAsBuffer === undefined) {
1679
- this._valueAsBuffer = Buffer.from(this._valueAsString, "utf-8");
2301
+ const value = Buffer.from(
2302
+ /** @type {string} */ (this._valueAsString),
2303
+ "utf-8"
2304
+ );
2305
+ if (isDualStringBufferCachingEnabled()) {
2306
+ this._valueAsBuffer = value;
2307
+ }
2308
+ return value;
1680
2309
  }
2310
+ return this._valueAsBuffer;
1681
2311
  }
1682
2312
 
1683
- _ensureValueString() {
2313
+ /**
2314
+ * @returns {SourceValue} source
2315
+ */
2316
+ source() {
1684
2317
  if (this._valueAsString === undefined) {
1685
- this._valueAsString = this._valueAsBuffer.toString("utf-8");
2318
+ const value =
2319
+ /** @type {Buffer} */
2320
+ (this._valueAsBuffer).toString("utf-8");
2321
+ if (isDualStringBufferCachingEnabled()) {
2322
+ this._valueAsString = value;
2323
+ }
2324
+ return value;
1686
2325
  }
2326
+ return this._valueAsString;
1687
2327
  }
1688
2328
 
1689
- _ensureOriginalSourceBuffer() {
2329
+ /**
2330
+ * @private
2331
+ * @returns {undefined | Buffer} buffer
2332
+ */
2333
+ _originalSourceBuffer() {
1690
2334
  if (this._originalSourceAsBuffer === undefined && this._hasOriginalSource) {
1691
- this._originalSourceAsBuffer = Buffer.from(
1692
- this._originalSourceAsString,
2335
+ const value = Buffer.from(
2336
+ /** @type {string} */
2337
+ (this._originalSourceAsString),
1693
2338
  "utf-8"
1694
2339
  );
2340
+ if (isDualStringBufferCachingEnabled()) {
2341
+ this._originalSourceAsBuffer = value;
2342
+ }
2343
+ return value;
1695
2344
  }
2345
+ return this._originalSourceAsBuffer;
1696
2346
  }
1697
2347
 
1698
- _ensureOriginalSourceString() {
2348
+ _originalSourceString() {
1699
2349
  if (this._originalSourceAsString === undefined && this._hasOriginalSource) {
1700
- this._originalSourceAsString = this._originalSourceAsBuffer.toString(
1701
- "utf-8"
1702
- );
2350
+ const value =
2351
+ /** @type {Buffer} */
2352
+ (this._originalSourceAsBuffer).toString("utf-8");
2353
+ if (isDualStringBufferCachingEnabled()) {
2354
+ this._originalSourceAsString = value;
2355
+ }
2356
+ return value;
1703
2357
  }
2358
+ return this._originalSourceAsString;
1704
2359
  }
1705
2360
 
1706
- _ensureInnerSourceMapObject() {
2361
+ _innerSourceMapObject() {
1707
2362
  if (this._innerSourceMapAsObject === undefined && this._hasInnerSourceMap) {
1708
- this._ensureInnerSourceMapString();
1709
- this._innerSourceMapAsObject = JSON.parse(this._innerSourceMapAsString);
2363
+ const value = JSON.parse(this._innerSourceMapString());
2364
+ if (isDualStringBufferCachingEnabled()) {
2365
+ this._innerSourceMapAsObject = value;
2366
+ }
2367
+ return value;
1710
2368
  }
2369
+ return this._innerSourceMapAsObject;
1711
2370
  }
1712
2371
 
1713
- _ensureInnerSourceMapBuffer() {
2372
+ _innerSourceMapBuffer() {
1714
2373
  if (this._innerSourceMapAsBuffer === undefined && this._hasInnerSourceMap) {
1715
- this._ensureInnerSourceMapString();
1716
- this._innerSourceMapAsBuffer = Buffer.from(
1717
- this._innerSourceMapAsString,
1718
- "utf-8"
1719
- );
2374
+ const value = Buffer.from(this._innerSourceMapString(), "utf-8");
2375
+ if (isDualStringBufferCachingEnabled()) {
2376
+ this._innerSourceMapAsBuffer = value;
2377
+ }
2378
+ return value;
1720
2379
  }
2380
+ return this._innerSourceMapAsBuffer;
1721
2381
  }
1722
2382
 
1723
- _ensureInnerSourceMapString() {
2383
+ /**
2384
+ * @private
2385
+ * @returns {string} result
2386
+ */
2387
+ _innerSourceMapString() {
1724
2388
  if (this._innerSourceMapAsString === undefined && this._hasInnerSourceMap) {
1725
2389
  if (this._innerSourceMapAsBuffer !== undefined) {
1726
- this._innerSourceMapAsString = this._innerSourceMapAsBuffer.toString(
1727
- "utf-8"
1728
- );
2390
+ const value = this._innerSourceMapAsBuffer.toString("utf-8");
2391
+ if (isDualStringBufferCachingEnabled()) {
2392
+ this._innerSourceMapAsString = value;
2393
+ }
2394
+ return value;
1729
2395
  } else {
1730
- this._innerSourceMapAsString = JSON.stringify(
1731
- this._innerSourceMapAsObject
1732
- );
2396
+ const value = JSON.stringify(this._innerSourceMapAsObject);
2397
+ if (isDualStringBufferCachingEnabled()) {
2398
+ this._innerSourceMapAsString = value;
2399
+ }
2400
+ return value;
1733
2401
  }
1734
2402
  }
2403
+ return /** @type {string} */ (this._innerSourceMapAsString);
1735
2404
  }
1736
2405
 
1737
- _ensureSourceMapObject() {
2406
+ _sourceMapObject() {
1738
2407
  if (this._sourceMapAsObject === undefined) {
1739
- this._ensureSourceMapString();
1740
- this._sourceMapAsObject = JSON.parse(this._sourceMapAsString);
2408
+ const value = JSON.parse(this._sourceMapString());
2409
+ if (isDualStringBufferCachingEnabled()) {
2410
+ this._sourceMapAsObject = value;
2411
+ }
2412
+ return value;
1741
2413
  }
2414
+ return this._sourceMapAsObject;
1742
2415
  }
1743
2416
 
1744
- _ensureSourceMapBuffer() {
2417
+ _sourceMapBuffer() {
1745
2418
  if (this._sourceMapAsBuffer === undefined) {
1746
- this._ensureSourceMapString();
1747
- this._sourceMapAsBuffer = Buffer.from(this._sourceMapAsString, "utf-8");
2419
+ const value = Buffer.from(this._sourceMapString(), "utf-8");
2420
+ if (isDualStringBufferCachingEnabled()) {
2421
+ this._sourceMapAsBuffer = value;
2422
+ }
2423
+ return value;
1748
2424
  }
2425
+ return this._sourceMapAsBuffer;
1749
2426
  }
1750
2427
 
1751
- _ensureSourceMapString() {
2428
+ _sourceMapString() {
1752
2429
  if (this._sourceMapAsString === undefined) {
1753
2430
  if (this._sourceMapAsBuffer !== undefined) {
1754
- this._sourceMapAsString = this._sourceMapAsBuffer.toString("utf-8");
2431
+ const value = this._sourceMapAsBuffer.toString("utf-8");
2432
+ if (isDualStringBufferCachingEnabled()) {
2433
+ this._sourceMapAsString = value;
2434
+ }
2435
+ return value;
1755
2436
  } else {
1756
- this._sourceMapAsString = JSON.stringify(this._sourceMapAsObject);
2437
+ const value = JSON.stringify(this._sourceMapAsObject);
2438
+ if (isDualStringBufferCachingEnabled()) {
2439
+ this._sourceMapAsString = value;
2440
+ }
2441
+ return value;
1757
2442
  }
1758
2443
  }
2444
+ return this._sourceMapAsString;
1759
2445
  }
1760
2446
 
1761
- getArgsAsBuffers() {
1762
- this._ensureValueBuffer();
1763
- this._ensureSourceMapBuffer();
1764
- this._ensureOriginalSourceBuffer();
1765
- this._ensureInnerSourceMapBuffer();
1766
- return [
1767
- this._valueAsBuffer,
1768
- this._name,
1769
- this._sourceMapAsBuffer,
1770
- this._originalSourceAsBuffer,
1771
- this._innerSourceMapAsBuffer,
1772
- this._removeOriginalSource
1773
- ];
1774
- }
1775
-
1776
- buffer() {
1777
- this._ensureValueBuffer();
1778
- return this._valueAsBuffer;
1779
- }
1780
-
1781
- source() {
1782
- this._ensureValueString();
1783
- return this._valueAsString;
1784
- }
1785
-
2447
+ /**
2448
+ * @param {MapOptions=} options map options
2449
+ * @returns {RawSourceMap | null} map
2450
+ */
1786
2451
  map(options) {
1787
2452
  if (!this._hasInnerSourceMap) {
1788
- this._ensureSourceMapObject();
1789
- return this._sourceMapAsObject;
2453
+ return this._sourceMapObject();
1790
2454
  }
1791
2455
  return getMap(this, options);
1792
2456
  }
1793
2457
 
2458
+ /**
2459
+ * @param {MapOptions=} options map options
2460
+ * @returns {SourceAndMap} source and map
2461
+ */
1794
2462
  sourceAndMap(options) {
1795
2463
  if (!this._hasInnerSourceMap) {
1796
- this._ensureValueString();
1797
- this._ensureSourceMapObject();
1798
2464
  return {
1799
- source: this._valueAsString,
1800
- map: this._sourceMapAsObject
2465
+ source: this.source(),
2466
+ map: this._sourceMapObject()
1801
2467
  };
1802
2468
  }
1803
2469
  return getSourceAndMap(this, options);
1804
2470
  }
1805
2471
 
2472
+ /**
2473
+ * @param {Options} options options
2474
+ * @param {OnChunk} onChunk called for each chunk of code
2475
+ * @param {OnSource} onSource called for each source
2476
+ * @param {OnName} onName called for each name
2477
+ * @returns {GeneratedSourceInfo} generated source info
2478
+ */
1806
2479
  streamChunks(options, onChunk, onSource, onName) {
1807
- this._ensureValueString();
1808
- this._ensureSourceMapObject();
1809
- this._ensureOriginalSourceString();
1810
2480
  if (this._hasInnerSourceMap) {
1811
- this._ensureInnerSourceMapObject();
1812
2481
  return streamChunksOfCombinedSourceMap(
1813
- this._valueAsString,
1814
- this._sourceMapAsObject,
2482
+ /** @type {string} */
2483
+ (this.source()),
2484
+ this._sourceMapObject(),
1815
2485
  this._name,
1816
- this._originalSourceAsString,
1817
- this._innerSourceMapAsObject,
2486
+ /** @type {string} */
2487
+ (this._originalSourceString()),
2488
+ this._innerSourceMapObject(),
1818
2489
  this._removeOriginalSource,
1819
2490
  onChunk,
1820
2491
  onSource,
@@ -1824,8 +2495,9 @@ class SourceMapSource extends Source {
1824
2495
  );
1825
2496
  } else {
1826
2497
  return streamChunksOfSourceMap(
1827
- this._valueAsString,
1828
- this._sourceMapAsObject,
2498
+ /** @type {string} */
2499
+ (this.source()),
2500
+ this._sourceMapObject(),
1829
2501
  onChunk,
1830
2502
  onSource,
1831
2503
  onName,
@@ -1835,24 +2507,41 @@ class SourceMapSource extends Source {
1835
2507
  }
1836
2508
  }
1837
2509
 
2510
+ /**
2511
+ * @param {Hash} hash hash
2512
+ * @returns {void}
2513
+ */
1838
2514
  updateHash(hash) {
1839
- this._ensureValueBuffer();
1840
- this._ensureSourceMapBuffer();
1841
- this._ensureOriginalSourceBuffer();
1842
- this._ensureInnerSourceMapBuffer();
1843
-
1844
2515
  hash.update("SourceMapSource");
1845
-
1846
- hash.update(this._valueAsBuffer);
1847
-
1848
- hash.update(this._sourceMapAsBuffer);
2516
+ hash.update(
2517
+ this._valueAsBuffer
2518
+ ? this._valueAsBuffer
2519
+ : typeof this._valueAsString === "string"
2520
+ ? this._valueAsString
2521
+ : // Fallback when memory optimization enabled
2522
+ this.buffer()
2523
+ );
2524
+ hash.update(
2525
+ this._sourceMapAsBuffer
2526
+ ? this._sourceMapAsBuffer
2527
+ : typeof this._sourceMapAsString === "string"
2528
+ ? this._sourceMapAsString
2529
+ : // Fallback when memory optimization enabled
2530
+ this._sourceMapBuffer()
2531
+ );
1849
2532
 
1850
2533
  if (this._hasOriginalSource) {
1851
- hash.update(this._originalSourceAsBuffer);
2534
+ hash.update(
2535
+ /** @type {Buffer} */
2536
+ (this._originalSourceBuffer())
2537
+ );
1852
2538
  }
1853
2539
 
1854
2540
  if (this._hasInnerSourceMap) {
1855
- hash.update(this._innerSourceMapAsBuffer);
2541
+ hash.update(
2542
+ /** @type {Buffer} */
2543
+ (this._innerSourceMapBuffer())
2544
+ );
1856
2545
  }
1857
2546
 
1858
2547
  hash.update(this._removeOriginalSource ? "true" : "false");
@@ -1864,10 +2553,9 @@ module.exports = SourceMapSource;
1864
2553
 
1865
2554
  /***/ }),
1866
2555
 
1867
- /***/ 543:
2556
+ /***/ 965:
1868
2557
  /***/ ((module) => {
1869
2558
 
1870
- "use strict";
1871
2559
  /*
1872
2560
  MIT License http://www.opensource.org/licenses/mit-license.php
1873
2561
  Author Tobias Koppers @sokra
@@ -1875,13 +2563,28 @@ module.exports = SourceMapSource;
1875
2563
 
1876
2564
 
1877
2565
 
1878
- const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(
1879
- ""
1880
- );
2566
+ const ALPHABET =
2567
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
1881
2568
 
1882
2569
  const CONTINUATION_BIT = 0x20;
1883
2570
 
1884
- const createMappingsSerializer = options => {
2571
+ /**
2572
+ * @callback MappingsSerializer
2573
+ * @param {number} generatedLine generated line
2574
+ * @param {number} generatedColumn generated column
2575
+ * @param {number} sourceIndex source index
2576
+ * @param {number} originalLine original line
2577
+ * @param {number} originalColumn generated line
2578
+ * @param {number} nameIndex generated line
2579
+ * @returns {string} result
2580
+ */
2581
+
2582
+ // eslint-disable-next-line valid-jsdoc
2583
+ /**
2584
+ * @param {{ columns?: boolean }=} options options
2585
+ * @returns {MappingsSerializer} mappings serializer
2586
+ */
2587
+ const createMappingsSerializer = (options) => {
1885
2588
  const linesOnly = options && options.columns === false;
1886
2589
  return linesOnly
1887
2590
  ? createLinesOnlyMappingsSerializer()
@@ -1898,6 +2601,8 @@ const createFullMappingsSerializer = () => {
1898
2601
  let activeMapping = false;
1899
2602
  let activeName = false;
1900
2603
  let initial = true;
2604
+ // eslint-disable-next-line valid-jsdoc
2605
+ /** @type {MappingsSerializer} */
1901
2606
  return (
1902
2607
  generatedLine,
1903
2608
  generatedColumn,
@@ -1926,6 +2631,7 @@ const createFullMappingsSerializer = () => {
1926
2631
  }
1927
2632
  }
1928
2633
 
2634
+ /** @type {undefined | string} */
1929
2635
  let str;
1930
2636
  if (currentLine < generatedLine) {
1931
2637
  str = ";".repeat(generatedLine - currentLine);
@@ -1939,7 +2645,11 @@ const createFullMappingsSerializer = () => {
1939
2645
  str = ",";
1940
2646
  }
1941
2647
 
1942
- const writeValue = value => {
2648
+ /**
2649
+ * @param {number} value value
2650
+ * @returns {void}
2651
+ */
2652
+ const writeValue = (value) => {
1943
2653
  const sign = (value >>> 31) & 1;
1944
2654
  const mask = value >> 31;
1945
2655
  const absValue = (value + mask) ^ mask;
@@ -1992,6 +2702,8 @@ const createLinesOnlyMappingsSerializer = () => {
1992
2702
  let currentLine = 1;
1993
2703
  let currentSourceIndex = 0;
1994
2704
  let currentOriginalLine = 1;
2705
+ // eslint-disable-next-line valid-jsdoc
2706
+ /** @type {MappingsSerializer} */
1995
2707
  return (
1996
2708
  generatedLine,
1997
2709
  _generatedColumn,
@@ -2008,8 +2720,13 @@ const createLinesOnlyMappingsSerializer = () => {
2008
2720
  // avoid writing multiple original mappings per line
2009
2721
  return "";
2010
2722
  }
2723
+ /** @type {undefined | string} */
2011
2724
  let str;
2012
- const writeValue = value => {
2725
+ /**
2726
+ * @param {number} value value
2727
+ * @returns {void}
2728
+ */
2729
+ const writeValue = (value) => {
2013
2730
  const sign = (value >>> 31) & 1;
2014
2731
  const mask = value >> 31;
2015
2732
  const absValue = (value + mask) ^ mask;
@@ -2029,7 +2746,6 @@ const createLinesOnlyMappingsSerializer = () => {
2029
2746
  if (generatedLine === currentLine + 1) {
2030
2747
  currentLine = generatedLine;
2031
2748
  if (sourceIndex === currentSourceIndex) {
2032
- currentSourceIndex = sourceIndex;
2033
2749
  if (originalLine === currentOriginalLine + 1) {
2034
2750
  currentOriginalLine = originalLine;
2035
2751
  return ";AACA";
@@ -2051,7 +2767,6 @@ const createLinesOnlyMappingsSerializer = () => {
2051
2767
  str = ";".repeat(generatedLine - currentLine);
2052
2768
  currentLine = generatedLine;
2053
2769
  if (sourceIndex === currentSourceIndex) {
2054
- currentSourceIndex = sourceIndex;
2055
2770
  if (originalLine === currentOriginalLine + 1) {
2056
2771
  currentOriginalLine = originalLine;
2057
2772
  return str + "AACA";
@@ -2078,10 +2793,9 @@ module.exports = createMappingsSerializer;
2078
2793
 
2079
2794
  /***/ }),
2080
2795
 
2081
- /***/ 56:
2796
+ /***/ 614:
2082
2797
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2083
2798
 
2084
- "use strict";
2085
2799
  /*
2086
2800
  MIT License http://www.opensource.org/licenses/mit-license.php
2087
2801
  Author Tobias Koppers @sokra
@@ -2089,13 +2803,28 @@ module.exports = createMappingsSerializer;
2089
2803
 
2090
2804
 
2091
2805
 
2092
- const createMappingsSerializer = __nccwpck_require__(543);
2806
+ const createMappingsSerializer = __nccwpck_require__(965);
2807
+
2808
+ /** @typedef {import("../Source").RawSourceMap} RawSourceMap */
2809
+ /** @typedef {import("../Source").SourceAndMap} SourceAndMap */
2810
+ /** @typedef {import("./streamChunks").Options} Options */
2811
+ /** @typedef {import("./streamChunks").StreamChunksFunction} StreamChunksFunction */
2093
2812
 
2813
+ /** @typedef {{ streamChunks: StreamChunksFunction }} SourceLikeWithStreamChunks */
2814
+
2815
+ /**
2816
+ * @param {SourceLikeWithStreamChunks} inputSource input source
2817
+ * @param {Options=} options options
2818
+ * @returns {SourceAndMap} map
2819
+ */
2094
2820
  exports.getSourceAndMap = (inputSource, options) => {
2095
2821
  let code = "";
2096
2822
  let mappings = "";
2823
+ /** @type {(string | null)[]} */
2097
2824
  let sources = [];
2825
+ /** @type {(string | null)[]} */
2098
2826
  let sourcesContent = [];
2827
+ /** @type {(string | null)[]} */
2099
2828
  let names = [];
2100
2829
  const addMapping = createMappingsSerializer(options);
2101
2830
  const { source } = inputSource.streamChunks(
@@ -2146,19 +2875,30 @@ exports.getSourceAndMap = (inputSource, options) => {
2146
2875
  version: 3,
2147
2876
  file: "x",
2148
2877
  mappings,
2149
- sources,
2878
+ // We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
2879
+ sources: /** @type {string[]} */ (sources),
2150
2880
  sourcesContent:
2151
- sourcesContent.length > 0 ? sourcesContent : undefined,
2152
- names
2881
+ sourcesContent.length > 0
2882
+ ? /** @type {string[]} */ (sourcesContent)
2883
+ : undefined,
2884
+ names: /** @type {string[]} */ (names)
2153
2885
  }
2154
2886
  : null
2155
2887
  };
2156
2888
  };
2157
2889
 
2890
+ /**
2891
+ * @param {SourceLikeWithStreamChunks} source source
2892
+ * @param {Options=} options options
2893
+ * @returns {RawSourceMap | null} map
2894
+ */
2158
2895
  exports.getMap = (source, options) => {
2159
2896
  let mappings = "";
2897
+ /** @type {(string | null)[]} */
2160
2898
  let sources = [];
2899
+ /** @type {(string | null)[]} */
2161
2900
  let sourcesContent = [];
2901
+ /** @type {(string | null)[]} */
2162
2902
  let names = [];
2163
2903
  const addMapping = createMappingsSerializer(options);
2164
2904
  source.streamChunks(
@@ -2205,9 +2945,13 @@ exports.getMap = (source, options) => {
2205
2945
  version: 3,
2206
2946
  file: "x",
2207
2947
  mappings,
2208
- sources,
2209
- sourcesContent: sourcesContent.length > 0 ? sourcesContent : undefined,
2210
- names
2948
+ // We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
2949
+ sources: /** @type {string[]} */ (sources),
2950
+ sourcesContent:
2951
+ sourcesContent.length > 0
2952
+ ? /** @type {string[]} */ (sourcesContent)
2953
+ : undefined,
2954
+ names: /** @type {string[]} */ (names)
2211
2955
  }
2212
2956
  : null;
2213
2957
  };
@@ -2215,10 +2959,9 @@ exports.getMap = (source, options) => {
2215
2959
 
2216
2960
  /***/ }),
2217
2961
 
2218
- /***/ 864:
2962
+ /***/ 278:
2219
2963
  /***/ ((module) => {
2220
2964
 
2221
- "use strict";
2222
2965
  /*
2223
2966
  MIT License http://www.opensource.org/licenses/mit-license.php
2224
2967
  Author Tobias Koppers @sokra
@@ -2228,7 +2971,18 @@ exports.getMap = (source, options) => {
2228
2971
 
2229
2972
  const CHAR_CODE_NEW_LINE = "\n".charCodeAt(0);
2230
2973
 
2231
- const getGeneratedSourceInfo = source => {
2974
+ /**
2975
+ * @typedef {object} GeneratedSourceInfo
2976
+ * @property {number=} generatedLine
2977
+ * @property {number=} generatedColumn
2978
+ * @property {string=} source
2979
+ */
2980
+
2981
+ /**
2982
+ * @param {string | undefined} source source
2983
+ * @returns {GeneratedSourceInfo} source info
2984
+ */
2985
+ const getGeneratedSourceInfo = (source) => {
2232
2986
  if (source === undefined) {
2233
2987
  return {};
2234
2988
  }
@@ -2256,10 +3010,9 @@ module.exports = getGeneratedSourceInfo;
2256
3010
 
2257
3011
  /***/ }),
2258
3012
 
2259
- /***/ 367:
3013
+ /***/ 265:
2260
3014
  /***/ ((module) => {
2261
3015
 
2262
- "use strict";
2263
3016
  /*
2264
3017
  MIT License http://www.opensource.org/licenses/mit-license.php
2265
3018
  Author Tobias Koppers @sokra
@@ -2267,6 +3020,13 @@ module.exports = getGeneratedSourceInfo;
2267
3020
 
2268
3021
 
2269
3022
 
3023
+ /** @typedef {import("../Source").RawSourceMap} RawSourceMap */
3024
+
3025
+ /**
3026
+ * @param {RawSourceMap} sourceMap source map
3027
+ * @param {number} index index
3028
+ * @returns {string | null} name
3029
+ */
2270
3030
  const getSource = (sourceMap, index) => {
2271
3031
  if (index < 0) return null;
2272
3032
  const { sourceRoot, sources } = sourceMap;
@@ -2281,10 +3041,9 @@ module.exports = getSource;
2281
3041
 
2282
3042
  /***/ }),
2283
3043
 
2284
- /***/ 479:
3044
+ /***/ 449:
2285
3045
  /***/ ((module) => {
2286
3046
 
2287
- "use strict";
2288
3047
  /*
2289
3048
  MIT License http://www.opensource.org/licenses/mit-license.php
2290
3049
  Author Tobias Koppers @sokra
@@ -2312,9 +3071,11 @@ const ccToValue = new Uint8Array("z".charCodeAt(0) + 1);
2312
3071
  }
2313
3072
  const ccMax = ccToValue.length - 1;
2314
3073
 
3074
+ /** @typedef {function(number, number, number, number, number, number): void} OnMapping */
3075
+
2315
3076
  /**
2316
3077
  * @param {string} mappings the mappings string
2317
- * @param {function(number, number, number, number, number, number): void} onMapping called for each mapping
3078
+ * @param {OnMapping} onMapping called for each mapping
2318
3079
  * @returns {void}
2319
3080
  */
2320
3081
  const readMappings = (mappings, onMapping) => {
@@ -2405,10 +3166,21 @@ module.exports = readMappings;
2405
3166
 
2406
3167
  /***/ }),
2407
3168
 
2408
- /***/ 877:
3169
+ /***/ 51:
2409
3170
  /***/ ((module) => {
2410
3171
 
2411
- const splitIntoLines = str => {
3172
+ /*
3173
+ MIT License http://www.opensource.org/licenses/mit-license.php
3174
+ Author Tobias Koppers @sokra
3175
+ */
3176
+
3177
+
3178
+
3179
+ /**
3180
+ * @param {string} str string
3181
+ * @returns {string[]} array of string separated by lines
3182
+ */
3183
+ const splitIntoLines = (str) => {
2412
3184
  const results = [];
2413
3185
  const len = str.length;
2414
3186
  let i = 0;
@@ -2428,14 +3200,22 @@ const splitIntoLines = str => {
2428
3200
  }
2429
3201
  return results;
2430
3202
  };
3203
+
2431
3204
  module.exports = splitIntoLines;
2432
3205
 
2433
3206
 
2434
3207
  /***/ }),
2435
3208
 
2436
- /***/ 914:
3209
+ /***/ 904:
2437
3210
  /***/ ((module) => {
2438
3211
 
3212
+ /*
3213
+ MIT License http://www.opensource.org/licenses/mit-license.php
3214
+ Author Tobias Koppers @sokra
3215
+ */
3216
+
3217
+
3218
+
2439
3219
  // \n = 10
2440
3220
  // ; = 59
2441
3221
  // { = 123
@@ -2444,7 +3224,11 @@ module.exports = splitIntoLines;
2444
3224
  // \r = 13
2445
3225
  // \t = 9
2446
3226
 
2447
- const splitIntoPotentialTokens = str => {
3227
+ /**
3228
+ * @param {string} str string
3229
+ * @returns {string[] | null} array of string separated by potential tokens
3230
+ */
3231
+ const splitIntoPotentialTokens = (str) => {
2448
3232
  const len = str.length;
2449
3233
  if (len === 0) return null;
2450
3234
  const results = [];
@@ -2476,15 +3260,15 @@ const splitIntoPotentialTokens = str => {
2476
3260
  }
2477
3261
  return results;
2478
3262
  };
3263
+
2479
3264
  module.exports = splitIntoPotentialTokens;
2480
3265
 
2481
3266
 
2482
3267
  /***/ }),
2483
3268
 
2484
- /***/ 391:
3269
+ /***/ 765:
2485
3270
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2486
3271
 
2487
- "use strict";
2488
3272
  /*
2489
3273
  MIT License http://www.opensource.org/licenses/mit-license.php
2490
3274
  Author Tobias Koppers @sokra
@@ -2492,9 +3276,26 @@ module.exports = splitIntoPotentialTokens;
2492
3276
 
2493
3277
 
2494
3278
 
2495
- const createMappingsSerializer = __nccwpck_require__(543);
2496
- const streamChunks = __nccwpck_require__(266);
3279
+ const createMappingsSerializer = __nccwpck_require__(965);
3280
+ const streamChunks = __nccwpck_require__(372);
3281
+
3282
+ /** @typedef {import("../Source").RawSourceMap} RawSourceMap */
3283
+ /** @typedef {import("./streamChunks").GeneratedSourceInfo} GeneratedSourceInfo */
3284
+ /** @typedef {import("./streamChunks").OnChunk} OnChunk */
3285
+ /** @typedef {import("./streamChunks").OnName} OnName */
3286
+ /** @typedef {import("./streamChunks").OnSource} OnSource */
3287
+ /** @typedef {import("./streamChunks").Options} Options */
3288
+ /** @typedef {import("./streamChunks").SourceMaybeWithStreamChunksFunction} SourceMaybeWithStreamChunksFunction */
2497
3289
 
3290
+ // eslint-disable-next-line valid-jsdoc
3291
+ /**
3292
+ * @param {SourceMaybeWithStreamChunksFunction} inputSource input source
3293
+ * @param {Options} options options
3294
+ * @param {OnChunk} onChunk on chunk
3295
+ * @param {OnSource} onSource on source
3296
+ * @param {OnName} onName on name
3297
+ * @returns {{ result: GeneratedSourceInfo, source: string, map: RawSourceMap | null }} result
3298
+ */
2498
3299
  const streamAndGetSourceAndMap = (
2499
3300
  inputSource,
2500
3301
  options,
@@ -2504,8 +3305,11 @@ const streamAndGetSourceAndMap = (
2504
3305
  ) => {
2505
3306
  let code = "";
2506
3307
  let mappings = "";
3308
+ /** @type {(string | null)[]} */
2507
3309
  let sources = [];
3310
+ /** @type {(string | null)[]} */
2508
3311
  let sourcesContent = [];
3312
+ /** @type {(string | null)[]} */
2509
3313
  let names = [];
2510
3314
  const addMapping = createMappingsSerializer(
2511
3315
  Object.assign({}, options, { columns: true })
@@ -2564,6 +3368,7 @@ const streamAndGetSourceAndMap = (
2564
3368
  }
2565
3369
  );
2566
3370
  const resultSource = source !== undefined ? source : code;
3371
+
2567
3372
  return {
2568
3373
  result: {
2569
3374
  generatedLine,
@@ -2577,10 +3382,13 @@ const streamAndGetSourceAndMap = (
2577
3382
  version: 3,
2578
3383
  file: "x",
2579
3384
  mappings,
2580
- sources,
3385
+ // We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
3386
+ sources: /** @type {string[]} */ (sources),
2581
3387
  sourcesContent:
2582
- sourcesContent.length > 0 ? sourcesContent : undefined,
2583
- names
3388
+ sourcesContent.length > 0
3389
+ ? /** @type {string[]} */ (sourcesContent)
3390
+ : undefined,
3391
+ names: /** @type {string[]} */ (names)
2584
3392
  }
2585
3393
  : null
2586
3394
  };
@@ -2591,10 +3399,9 @@ module.exports = streamAndGetSourceAndMap;
2591
3399
 
2592
3400
  /***/ }),
2593
3401
 
2594
- /***/ 266:
3402
+ /***/ 372:
2595
3403
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2596
3404
 
2597
- "use strict";
2598
3405
  /*
2599
3406
  MIT License http://www.opensource.org/licenses/mit-license.php
2600
3407
  Author Tobias Koppers @sokra
@@ -2602,9 +3409,35 @@ module.exports = streamAndGetSourceAndMap;
2602
3409
 
2603
3410
 
2604
3411
 
2605
- const streamChunksOfRawSource = __nccwpck_require__(348);
2606
- const streamChunksOfSourceMap = __nccwpck_require__(958);
3412
+ const streamChunksOfRawSource = __nccwpck_require__(482);
3413
+ const streamChunksOfSourceMap = __nccwpck_require__(492);
3414
+
3415
+ /** @typedef {import("../Source")} Source */
3416
+ /** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
3417
+ /** @typedef {(chunk: string | undefined, generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number, originalColumn: number, nameIndex: number) => void} OnChunk */
3418
+ /** @typedef {(sourceIndex: number, source: string | null, sourceContent: string | undefined) => void} OnSource */
3419
+ /** @typedef {(nameIndex: number, name: string) => void} OnName */
2607
3420
 
3421
+ /** @typedef {{ source?: boolean, finalSource?: boolean, columns?: boolean }} Options */
3422
+
3423
+ /**
3424
+ * @callback StreamChunksFunction
3425
+ * @param {Options} options options
3426
+ * @param {OnChunk} onChunk on chunk
3427
+ * @param {OnSource} onSource on source
3428
+ * @param {OnName} onName on name
3429
+ */
3430
+
3431
+ /** @typedef {Source & { streamChunks?: StreamChunksFunction }} SourceMaybeWithStreamChunksFunction */
3432
+
3433
+ /**
3434
+ * @param {SourceMaybeWithStreamChunksFunction} source source
3435
+ * @param {Options} options options
3436
+ * @param {OnChunk} onChunk on chunk
3437
+ * @param {OnSource} onSource on source
3438
+ * @param {OnName} onName on name
3439
+ * @returns {GeneratedSourceInfo} generated source info
3440
+ */
2608
3441
  module.exports = (source, options, onChunk, onSource, onName) => {
2609
3442
  if (typeof source.streamChunks === "function") {
2610
3443
  return source.streamChunks(options, onChunk, onSource, onName);
@@ -2612,7 +3445,8 @@ module.exports = (source, options, onChunk, onSource, onName) => {
2612
3445
  const sourceAndMap = source.sourceAndMap(options);
2613
3446
  if (sourceAndMap.map) {
2614
3447
  return streamChunksOfSourceMap(
2615
- sourceAndMap.source,
3448
+ /** @type {string} */
3449
+ (sourceAndMap.source),
2616
3450
  sourceAndMap.map,
2617
3451
  onChunk,
2618
3452
  onSource,
@@ -2622,7 +3456,8 @@ module.exports = (source, options, onChunk, onSource, onName) => {
2622
3456
  );
2623
3457
  } else {
2624
3458
  return streamChunksOfRawSource(
2625
- sourceAndMap.source,
3459
+ /** @type {string} */
3460
+ (sourceAndMap.source),
2626
3461
  onChunk,
2627
3462
  onSource,
2628
3463
  onName,
@@ -2635,10 +3470,9 @@ module.exports = (source, options, onChunk, onSource, onName) => {
2635
3470
 
2636
3471
  /***/ }),
2637
3472
 
2638
- /***/ 503:
3473
+ /***/ 549:
2639
3474
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2640
3475
 
2641
- "use strict";
2642
3476
  /*
2643
3477
  MIT License http://www.opensource.org/licenses/mit-license.php
2644
3478
  Author Tobias Koppers @sokra
@@ -2646,9 +3480,29 @@ module.exports = (source, options, onChunk, onSource, onName) => {
2646
3480
 
2647
3481
 
2648
3482
 
2649
- const streamChunksOfSourceMap = __nccwpck_require__(958);
2650
- const splitIntoLines = __nccwpck_require__(877);
3483
+ const splitIntoLines = __nccwpck_require__(51);
3484
+ const streamChunksOfSourceMap = __nccwpck_require__(492);
3485
+
3486
+ /** @typedef {import("../Source").RawSourceMap} RawSourceMap */
3487
+ /** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
3488
+ /** @typedef {import("./streamChunks").OnChunk} onChunk */
3489
+ /** @typedef {import("./streamChunks").OnName} OnName */
3490
+ /** @typedef {import("./streamChunks").OnSource} OnSource */
2651
3491
 
3492
+ /**
3493
+ * @param {string} source source
3494
+ * @param {RawSourceMap} sourceMap source map
3495
+ * @param {string} innerSourceName inner source name
3496
+ * @param {string} innerSource inner source
3497
+ * @param {RawSourceMap} innerSourceMap inner source map
3498
+ * @param {boolean | undefined} removeInnerSource do remove inner source
3499
+ * @param {onChunk} onChunk on chunk
3500
+ * @param {OnSource} onSource on source
3501
+ * @param {OnName} onName on name
3502
+ * @param {boolean} finalSource finalSource
3503
+ * @param {boolean} columns columns
3504
+ * @returns {GeneratedSourceInfo} generated source info
3505
+ */
2652
3506
  const streamChunksOfCombinedSourceMap = (
2653
3507
  source,
2654
3508
  sourceMap,
@@ -2662,19 +3516,37 @@ const streamChunksOfCombinedSourceMap = (
2662
3516
  finalSource,
2663
3517
  columns
2664
3518
  ) => {
3519
+ /** @type {Map<string | null, number>} */
2665
3520
  let sourceMapping = new Map();
3521
+ /** @type {Map<string, number>} */
2666
3522
  let nameMapping = new Map();
3523
+ /** @type {number[]} */
2667
3524
  const sourceIndexMapping = [];
3525
+ /** @type {number[]} */
2668
3526
  const nameIndexMapping = [];
3527
+ /** @type {string[]} */
2669
3528
  const nameIndexValueMapping = [];
2670
3529
  let innerSourceIndex = -2;
3530
+ /** @type {number[]} */
2671
3531
  const innerSourceIndexMapping = [];
3532
+ /** @type {[string | null, string | undefined][]} */
2672
3533
  const innerSourceIndexValueMapping = [];
3534
+ /** @type {(string | undefined)[]} */
2673
3535
  const innerSourceContents = [];
3536
+ /** @type {(null | undefined | string[])[]} */
2674
3537
  const innerSourceContentLines = [];
3538
+ /** @type {number[]} */
2675
3539
  const innerNameIndexMapping = [];
3540
+ /** @type {string[]} */
2676
3541
  const innerNameIndexValueMapping = [];
3542
+ /** @typedef {[number, number, number, number, number]} MappingsData */
3543
+ /** @type {{ chunks: string[], mappingsData: MappingsData }[]} */
2677
3544
  const innerSourceMapLineData = [];
3545
+ /**
3546
+ * @param {number} line line
3547
+ * @param {number} column column
3548
+ * @returns {number} result
3549
+ */
2678
3550
  const findInnerMapping = (line, column) => {
2679
3551
  if (line > innerSourceMapLineData.length) return -1;
2680
3552
  const { mappingsData } = innerSourceMapLineData[line - 1];
@@ -2708,9 +3580,8 @@ const streamChunksOfCombinedSourceMap = (
2708
3580
  // Check if there is a mapping in the inner source
2709
3581
  const idx = findInnerMapping(originalLine, originalColumn);
2710
3582
  if (idx !== -1) {
2711
- const { chunks, mappingsData } = innerSourceMapLineData[
2712
- originalLine - 1
2713
- ];
3583
+ const { chunks, mappingsData } =
3584
+ innerSourceMapLineData[originalLine - 1];
2714
3585
  const mi = idx * 5;
2715
3586
  const innerSourceIndex = mappingsData[mi + 1];
2716
3587
  const innerOriginalLine = mappingsData[mi + 2];
@@ -2906,10 +3777,11 @@ const streamChunksOfCombinedSourceMap = (
2906
3777
  if (source === innerSourceName) {
2907
3778
  innerSourceIndex = i;
2908
3779
  if (innerSource !== undefined) sourceContent = innerSource;
2909
- else innerSource = sourceContent;
3780
+ else innerSource = /** @type {string} */ (sourceContent);
2910
3781
  sourceIndexMapping[i] = -2;
2911
3782
  streamChunksOfSourceMap(
2912
- sourceContent,
3783
+ /** @type {string} */
3784
+ (sourceContent),
2913
3785
  innerSourceMap,
2914
3786
  (
2915
3787
  chunk,
@@ -2922,7 +3794,7 @@ const streamChunksOfCombinedSourceMap = (
2922
3794
  ) => {
2923
3795
  while (innerSourceMapLineData.length < generatedLine) {
2924
3796
  innerSourceMapLineData.push({
2925
- mappingsData: [],
3797
+ mappingsData: /** @type {any} */ ([]),
2926
3798
  chunks: []
2927
3799
  });
2928
3800
  }
@@ -2934,7 +3806,7 @@ const streamChunksOfCombinedSourceMap = (
2934
3806
  originalColumn,
2935
3807
  nameIndex
2936
3808
  );
2937
- data.chunks.push(chunk);
3809
+ data.chunks.push(/** @type {string} */ (chunk));
2938
3810
  },
2939
3811
  (i, source, sourceContent) => {
2940
3812
  innerSourceContents[i] = sourceContent;
@@ -2972,10 +3844,9 @@ module.exports = streamChunksOfCombinedSourceMap;
2972
3844
 
2973
3845
  /***/ }),
2974
3846
 
2975
- /***/ 348:
3847
+ /***/ 482:
2976
3848
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2977
3849
 
2978
- "use strict";
2979
3850
  /*
2980
3851
  MIT License http://www.opensource.org/licenses/mit-license.php
2981
3852
  Author Tobias Koppers @sokra
@@ -2983,28 +3854,49 @@ module.exports = streamChunksOfCombinedSourceMap;
2983
3854
 
2984
3855
 
2985
3856
 
2986
- const getGeneratedSourceInfo = __nccwpck_require__(864);
2987
- const splitIntoLines = __nccwpck_require__(877);
3857
+ const getGeneratedSourceInfo = __nccwpck_require__(278);
3858
+ const splitIntoLines = __nccwpck_require__(51);
3859
+
3860
+ /** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
3861
+ /** @typedef {import("./streamChunks").OnChunk} OnChunk */
3862
+ /** @typedef {import("./streamChunks").OnName} OnName */
3863
+ /** @typedef {import("./streamChunks").OnSource} OnSource */
2988
3864
 
3865
+ /**
3866
+ * @param {string} source source
3867
+ * @param {OnChunk} onChunk on chunk
3868
+ * @param {OnSource} onSource on source
3869
+ * @param {OnName} onName on name
3870
+ * @returns {GeneratedSourceInfo} source info
3871
+ */
2989
3872
  const streamChunksOfRawSource = (source, onChunk, onSource, onName) => {
2990
3873
  let line = 1;
2991
3874
  const matches = splitIntoLines(source);
3875
+ /** @type {undefined | string} */
2992
3876
  let match;
2993
3877
  for (match of matches) {
2994
3878
  onChunk(match, line, 0, -1, -1, -1, -1);
2995
3879
  line++;
2996
3880
  }
2997
- return matches.length === 0 || match.endsWith("\n")
3881
+ return matches.length === 0 || /** @type {string} */ (match).endsWith("\n")
2998
3882
  ? {
2999
3883
  generatedLine: matches.length + 1,
3000
3884
  generatedColumn: 0
3001
3885
  }
3002
3886
  : {
3003
3887
  generatedLine: matches.length,
3004
- generatedColumn: match.length
3888
+ generatedColumn: /** @type {string} */ (match).length
3005
3889
  };
3006
3890
  };
3007
3891
 
3892
+ /**
3893
+ * @param {string} source source
3894
+ * @param {OnChunk} onChunk on chunk
3895
+ * @param {OnSource} onSource on source
3896
+ * @param {OnName} onName on name
3897
+ * @param {boolean} finalSource is final source
3898
+ * @returns {GeneratedSourceInfo} source info
3899
+ */
3008
3900
  module.exports = (source, onChunk, onSource, onName, finalSource) => {
3009
3901
  return finalSource
3010
3902
  ? getGeneratedSourceInfo(source)
@@ -3014,10 +3906,9 @@ module.exports = (source, onChunk, onSource, onName, finalSource) => {
3014
3906
 
3015
3907
  /***/ }),
3016
3908
 
3017
- /***/ 958:
3909
+ /***/ 492:
3018
3910
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3019
3911
 
3020
- "use strict";
3021
3912
  /*
3022
3913
  MIT License http://www.opensource.org/licenses/mit-license.php
3023
3914
  Author Tobias Koppers @sokra
@@ -3025,11 +3916,25 @@ module.exports = (source, onChunk, onSource, onName, finalSource) => {
3025
3916
 
3026
3917
 
3027
3918
 
3028
- const getGeneratedSourceInfo = __nccwpck_require__(864);
3029
- const getSource = __nccwpck_require__(367);
3030
- const readMappings = __nccwpck_require__(479);
3031
- const splitIntoLines = __nccwpck_require__(877);
3919
+ const getGeneratedSourceInfo = __nccwpck_require__(278);
3920
+ const getSource = __nccwpck_require__(265);
3921
+ const readMappings = __nccwpck_require__(449);
3922
+ const splitIntoLines = __nccwpck_require__(51);
3032
3923
 
3924
+ /** @typedef {import("../Source").RawSourceMap} RawSourceMap */
3925
+ /** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
3926
+ /** @typedef {import("./streamChunks").OnChunk} OnChunk */
3927
+ /** @typedef {import("./streamChunks").OnName} OnName */
3928
+ /** @typedef {import("./streamChunks").OnSource} OnSource */
3929
+
3930
+ /**
3931
+ * @param {string} source source
3932
+ * @param {RawSourceMap} sourceMap source map
3933
+ * @param {OnChunk} onChunk on chunk
3934
+ * @param {OnSource} onSource on source
3935
+ * @param {OnName} onName on name
3936
+ * @returns {GeneratedSourceInfo} generated source info
3937
+ */
3033
3938
  const streamChunksOfSourceMapFull = (
3034
3939
  source,
3035
3940
  sourceMap,
@@ -3072,6 +3977,15 @@ const streamChunksOfSourceMapFull = (
3072
3977
  let activeMappingOriginalColumn = -1;
3073
3978
  let activeMappingNameIndex = -1;
3074
3979
 
3980
+ /**
3981
+ * @param {number} generatedLine generated line
3982
+ * @param {number} generatedColumn generated column
3983
+ * @param {number} sourceIndex source index
3984
+ * @param {number} originalLine original line
3985
+ * @param {number} originalColumn original column
3986
+ * @param {number} nameIndex name index
3987
+ * @returns {void}
3988
+ */
3075
3989
  const onMapping = (
3076
3990
  generatedLine,
3077
3991
  generatedColumn,
@@ -3176,6 +4090,14 @@ const streamChunksOfSourceMapFull = (
3176
4090
  };
3177
4091
  };
3178
4092
 
4093
+ /**
4094
+ * @param {string} source source
4095
+ * @param {RawSourceMap} sourceMap source map
4096
+ * @param {OnChunk} onChunk on chunk
4097
+ * @param {OnSource} onSource on source
4098
+ * @param {OnName} _onName on name
4099
+ * @returns {GeneratedSourceInfo} generated source info
4100
+ */
3179
4101
  const streamChunksOfSourceMapLinesFull = (
3180
4102
  source,
3181
4103
  sourceMap,
@@ -3201,6 +4123,15 @@ const streamChunksOfSourceMapLinesFull = (
3201
4123
 
3202
4124
  let currentGeneratedLine = 1;
3203
4125
 
4126
+ /**
4127
+ * @param {number} generatedLine generated line
4128
+ * @param {number} _generatedColumn generated column
4129
+ * @param {number} sourceIndex source index
4130
+ * @param {number} originalLine original line
4131
+ * @param {number} originalColumn original column
4132
+ * @param {number} _nameIndex name index
4133
+ * @returns {void}
4134
+ */
3204
4135
  const onMapping = (
3205
4136
  generatedLine,
3206
4137
  _generatedColumn,
@@ -3268,6 +4199,14 @@ const streamChunksOfSourceMapLinesFull = (
3268
4199
  };
3269
4200
  };
3270
4201
 
4202
+ /**
4203
+ * @param {string} source source
4204
+ * @param {RawSourceMap} sourceMap source map
4205
+ * @param {OnChunk} onChunk on chunk
4206
+ * @param {OnSource} onSource on source
4207
+ * @param {OnName} onName on name
4208
+ * @returns {GeneratedSourceInfo} generated source info
4209
+ */
3271
4210
  const streamChunksOfSourceMapFinal = (
3272
4211
  source,
3273
4212
  sourceMap,
@@ -3295,6 +4234,15 @@ const streamChunksOfSourceMapFinal = (
3295
4234
 
3296
4235
  let mappingActiveLine = 0;
3297
4236
 
4237
+ /**
4238
+ * @param {number} generatedLine generated line
4239
+ * @param {number} generatedColumn generated column
4240
+ * @param {number} sourceIndex source index
4241
+ * @param {number} originalLine original line
4242
+ * @param {number} originalColumn original column
4243
+ * @param {number} nameIndex name index
4244
+ * @returns {void}
4245
+ */
3298
4246
  const onMapping = (
3299
4247
  generatedLine,
3300
4248
  generatedColumn,
@@ -3304,8 +4252,9 @@ const streamChunksOfSourceMapFinal = (
3304
4252
  nameIndex
3305
4253
  ) => {
3306
4254
  if (
3307
- generatedLine >= finalLine &&
3308
- (generatedColumn >= finalColumn || generatedLine > finalLine)
4255
+ generatedLine >= /** @type {number} */ (finalLine) &&
4256
+ (generatedColumn >= /** @type {number} */ (finalColumn) ||
4257
+ generatedLine > /** @type {number} */ (finalLine))
3309
4258
  ) {
3310
4259
  return;
3311
4260
  }
@@ -3329,6 +4278,14 @@ const streamChunksOfSourceMapFinal = (
3329
4278
  return result;
3330
4279
  };
3331
4280
 
4281
+ /**
4282
+ * @param {string} source source
4283
+ * @param {RawSourceMap} sourceMap source map
4284
+ * @param {OnChunk} onChunk on chunk
4285
+ * @param {OnSource} onSource on source
4286
+ * @param {OnName} _onName on name
4287
+ * @returns {GeneratedSourceInfo} generated source info
4288
+ */
3332
4289
  const streamChunksOfSourceMapLinesFinal = (
3333
4290
  source,
3334
4291
  sourceMap,
@@ -3354,10 +4311,22 @@ const streamChunksOfSourceMapLinesFinal = (
3354
4311
  );
3355
4312
  }
3356
4313
 
3357
- const finalLine = generatedColumn === 0 ? generatedLine - 1 : generatedLine;
4314
+ const finalLine =
4315
+ generatedColumn === 0
4316
+ ? /** @type {number} */ (generatedLine) - 1
4317
+ : /** @type {number} */ (generatedLine);
3358
4318
 
3359
4319
  let currentGeneratedLine = 1;
3360
4320
 
4321
+ /**
4322
+ * @param {number} generatedLine generated line
4323
+ * @param {number} _generatedColumn generated column
4324
+ * @param {number} sourceIndex source index
4325
+ * @param {number} originalLine original line
4326
+ * @param {number} originalColumn original column
4327
+ * @param {number} _nameIndex name index
4328
+ * @returns {void}
4329
+ */
3361
4330
  const onMapping = (
3362
4331
  generatedLine,
3363
4332
  _generatedColumn,
@@ -3387,6 +4356,16 @@ const streamChunksOfSourceMapLinesFinal = (
3387
4356
  return result;
3388
4357
  };
3389
4358
 
4359
+ /**
4360
+ * @param {string} source source
4361
+ * @param {RawSourceMap} sourceMap source map
4362
+ * @param {OnChunk} onChunk on chunk
4363
+ * @param {OnSource} onSource on source
4364
+ * @param {OnName} onName on name
4365
+ * @param {boolean} finalSource final source
4366
+ * @param {boolean} columns columns
4367
+ * @returns {GeneratedSourceInfo} generated source info
4368
+ */
3390
4369
  module.exports = (
3391
4370
  source,
3392
4371
  sourceMap,
@@ -3434,39 +4413,260 @@ module.exports = (
3434
4413
 
3435
4414
  /***/ }),
3436
4415
 
3437
- /***/ 452:
3438
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4416
+ /***/ 672:
4417
+ /***/ ((module) => {
4418
+
4419
+ /*
4420
+ MIT License http://www.opensource.org/licenses/mit-license.php
4421
+ Author Mark Knichel @mknichel
4422
+ */
4423
+
4424
+
4425
+
4426
+ let dualStringBufferCaching = true;
4427
+
4428
+ /**
4429
+ * @returns {boolean} Whether the optimization to cache copies of both the
4430
+ * string and buffer version of source content is enabled. This is enabled by
4431
+ * default to improve performance but can consume more memory since values are
4432
+ * stored twice.
4433
+ */
4434
+ function isDualStringBufferCachingEnabled() {
4435
+ return dualStringBufferCaching;
4436
+ }
4437
+
4438
+ /**
4439
+ * Enables an optimization to save both string and buffer in memory to avoid
4440
+ * repeat conversions between the two formats when they are requested. This
4441
+ * is enabled by default. This option can improve performance but can consume
4442
+ * additional memory since values are stored twice.
4443
+ *
4444
+ * @returns {void}
4445
+ */
4446
+ function enableDualStringBufferCaching() {
4447
+ dualStringBufferCaching = true;
4448
+ }
4449
+
4450
+ /**
4451
+ * Disables the optimization to save both string and buffer in memory. This
4452
+ * may increase performance but should reduce memory usage in the Webpack
4453
+ * compiler.
4454
+ *
4455
+ * @returns {void}
4456
+ */
4457
+ function disableDualStringBufferCaching() {
4458
+ dualStringBufferCaching = false;
4459
+ }
4460
+
4461
+ const interningStringMap = new Map();
4462
+
4463
+ /**
4464
+ * Saves the string in a map to ensure that only one copy of the string exists
4465
+ * in memory at a given time. This is controlled by {@link enableStringInterning}
4466
+ * and {@link disableStringInterning}. Callers are expect to manage the memory
4467
+ * of the interned strings by calling {@link disableStringInterning} after the
4468
+ * compiler no longer needs to save the interned memory.
4469
+ *
4470
+ * @param {string} str A string to be interned.
4471
+ * @returns {string} The original string or a reference to an existing string of the same value if it has already been interned.
4472
+ */
4473
+ function internString(str) {
4474
+ if (
4475
+ !isStringInterningEnabled() ||
4476
+ !str ||
4477
+ str.length < 128 ||
4478
+ typeof str !== "string"
4479
+ ) {
4480
+ return str;
4481
+ }
4482
+ let internedString = interningStringMap.get(str);
4483
+ if (internedString === undefined) {
4484
+ internedString = str;
4485
+ interningStringMap.set(str, internedString);
4486
+ }
4487
+ return internedString;
4488
+ }
4489
+
4490
+ let enableStringInterningRefCount = 0;
4491
+
4492
+ /**
4493
+ * @returns {boolean} value
4494
+ */
4495
+ function isStringInterningEnabled() {
4496
+ return enableStringInterningRefCount > 0;
4497
+ }
4498
+
4499
+ /**
4500
+ * Starts a memory optimization to avoid repeat copies of the same string in
4501
+ * memory by caching a single reference to the string. This can reduce memory
4502
+ * usage if the same string is repeated many times in the compiler, such as
4503
+ * when Webpack layers are used with the same files.
4504
+ *
4505
+ * {@link exitStringInterningRange} should be called when string interning is
4506
+ * no longer necessary to free up the memory used by the interned strings. If
4507
+ * {@link enterStringInterningRange} has been called multiple times, then
4508
+ * this method may not immediately free all the memory until
4509
+ * {@link exitStringInterningRange} has been called to end all string
4510
+ * interning ranges.
4511
+ *
4512
+ * @returns {void}
4513
+ */
4514
+ function enterStringInterningRange() {
4515
+ enableStringInterningRefCount++;
4516
+ }
4517
+
4518
+ /**
4519
+ * Stops the current string interning range. Once all string interning ranges
4520
+ * have been exited, this method will free all the memory used by the interned
4521
+ * strings. This method should be called once for each time that
4522
+ * {@link enterStringInterningRange} was called.
4523
+ *
4524
+ * @returns {void}
4525
+ */
4526
+ function exitStringInterningRange() {
4527
+ if (--enableStringInterningRefCount <= 0) {
4528
+ interningStringMap.clear();
4529
+ enableStringInterningRefCount = 0;
4530
+ }
4531
+ }
4532
+
4533
+ module.exports = {
4534
+ disableDualStringBufferCaching,
4535
+ enableDualStringBufferCaching,
4536
+ internString,
4537
+ isDualStringBufferCachingEnabled,
4538
+ enterStringInterningRange,
4539
+ exitStringInterningRange
4540
+ };
4541
+
4542
+
4543
+ /***/ }),
4544
+
4545
+ /***/ 570:
4546
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3439
4547
 
3440
4548
  /*
3441
4549
  MIT License http://www.opensource.org/licenses/mit-license.php
3442
4550
  Author Tobias Koppers @sokra
3443
4551
  */
3444
4552
 
3445
- const defineExport = (name, fn) => {
3446
- let value;
3447
- Object.defineProperty(exports, name, {
3448
- get: () => {
3449
- if (fn !== undefined) {
3450
- value = fn();
3451
- fn = undefined;
3452
- }
3453
- return value;
3454
- },
3455
- configurable: true
3456
- });
4553
+
4554
+
4555
+ /** @typedef {import("./CachedSource").CachedData} CachedData */
4556
+ /** @typedef {import("./CompatSource").SourceLike} SourceLike */
4557
+ /** @typedef {import("./ConcatSource").Child} ConcatSourceChild */
4558
+ /** @typedef {import("./ReplaceSource").Replacement} Replacement */
4559
+ /** @typedef {import("./Source").Hash} Hash */
4560
+ /** @typedef {import("./Source").MapOptions} MapOptions */
4561
+ /** @typedef {import("./Source").RawSourceMap} RawSourceMap */
4562
+ /** @typedef {import("./Source").SourceAndMap} SourceAndMap */
4563
+ /** @typedef {import("./Source").SourceValue} SourceValue */
4564
+ /** @typedef {import("./helpers/getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
4565
+ /** @typedef {import("./helpers/streamChunks").OnChunk} OnChunk */
4566
+ /** @typedef {import("./helpers/streamChunks").OnName} OnName */
4567
+ /** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
4568
+ /** @typedef {import("./helpers/streamChunks").Options} StreamChunksOptions */
4569
+
4570
+ // eslint-disable-next-line valid-jsdoc
4571
+ /**
4572
+ * @template T
4573
+ * @param {() => T} fn memorized function
4574
+ * @returns {() => T} new function
4575
+ */
4576
+ const memoize = (fn) => {
4577
+ let cache = false;
4578
+ /** @type {T | undefined} */
4579
+ let result;
4580
+ return () => {
4581
+ if (cache) {
4582
+ return /** @type {T} */ (result);
4583
+ }
4584
+
4585
+ result = fn();
4586
+ cache = true;
4587
+ // Allow to clean up memory for fn
4588
+ // and all dependent resources
4589
+ /** @type {(() => T) | undefined} */
4590
+ (fn) = undefined;
4591
+ return /** @type {T} */ (result);
4592
+ };
3457
4593
  };
3458
4594
 
3459
- defineExport("Source", () => __nccwpck_require__(171));
4595
+ // eslint-disable-next-line valid-jsdoc
4596
+ /**
4597
+ * @template A
4598
+ * @template B
4599
+ * @param {A} obj input a
4600
+ * @param {B} exports input b
4601
+ * @returns {A & B} merged
4602
+ */
4603
+ const mergeExports = (obj, exports) => {
4604
+ const descriptors = Object.getOwnPropertyDescriptors(exports);
4605
+ for (const name of Object.keys(descriptors)) {
4606
+ const descriptor = descriptors[name];
4607
+ if (descriptor.get) {
4608
+ const fn = descriptor.get;
4609
+ Object.defineProperty(obj, name, {
4610
+ configurable: false,
4611
+ enumerable: true,
4612
+ get: memoize(fn)
4613
+ });
4614
+ } else if (typeof descriptor.value === "object") {
4615
+ Object.defineProperty(obj, name, {
4616
+ configurable: false,
4617
+ enumerable: true,
4618
+ writable: false,
4619
+ value: mergeExports({}, descriptor.value)
4620
+ });
4621
+ } else {
4622
+ throw new Error(
4623
+ "Exposed values must be either a getter or an nested object"
4624
+ );
4625
+ }
4626
+ }
4627
+ return /** @type {A & B} */ (Object.freeze(obj));
4628
+ };
3460
4629
 
3461
- defineExport("RawSource", () => __nccwpck_require__(327));
3462
- defineExport("OriginalSource", () => __nccwpck_require__(472));
3463
- defineExport("SourceMapSource", () => __nccwpck_require__(188));
3464
- defineExport("CachedSource", () => __nccwpck_require__(453));
3465
- defineExport("ConcatSource", () => __nccwpck_require__(987));
3466
- defineExport("ReplaceSource", () => __nccwpck_require__(829));
3467
- defineExport("PrefixSource", () => __nccwpck_require__(663));
3468
- defineExport("SizeOnlySource", () => __nccwpck_require__(908));
3469
- defineExport("CompatSource", () => __nccwpck_require__(273));
4630
+ module.exports = mergeExports(
4631
+ {},
4632
+ {
4633
+ get Source() {
4634
+ return __nccwpck_require__(225);
4635
+ },
4636
+ get RawSource() {
4637
+ return __nccwpck_require__(745);
4638
+ },
4639
+ get OriginalSource() {
4640
+ return __nccwpck_require__(734);
4641
+ },
4642
+ get SourceMapSource() {
4643
+ return __nccwpck_require__(150);
4644
+ },
4645
+ get CachedSource() {
4646
+ return __nccwpck_require__(627);
4647
+ },
4648
+ get ConcatSource() {
4649
+ return __nccwpck_require__(49);
4650
+ },
4651
+ get ReplaceSource() {
4652
+ return __nccwpck_require__(807);
4653
+ },
4654
+ get PrefixSource() {
4655
+ return __nccwpck_require__(805);
4656
+ },
4657
+ get SizeOnlySource() {
4658
+ return __nccwpck_require__(90);
4659
+ },
4660
+ get CompatSource() {
4661
+ return __nccwpck_require__(583);
4662
+ },
4663
+ util: {
4664
+ get stringBufferUtils() {
4665
+ return __nccwpck_require__(672);
4666
+ }
4667
+ }
4668
+ }
4669
+ );
3470
4670
 
3471
4671
 
3472
4672
  /***/ })
@@ -3513,7 +4713,7 @@ defineExport("CompatSource", () => __nccwpck_require__(273));
3513
4713
  /******/ // startup
3514
4714
  /******/ // Load entry module and return exports
3515
4715
  /******/ // This entry module is referenced by other modules so it can't be inlined
3516
- /******/ var __webpack_exports__ = __nccwpck_require__(452);
4716
+ /******/ var __webpack_exports__ = __nccwpck_require__(570);
3517
4717
  /******/ module.exports = __webpack_exports__;
3518
4718
  /******/
3519
4719
  /******/ })()