rollup 4.62.2 → 4.62.4

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.62.2
4
- Fri, 19 Jun 2026 14:55:11 GMT - commit 8faa18777374582bb813d54ce3623f4acf1f9e0b
3
+ Rollup.js v4.62.4
4
+ Sat, 01 Aug 2026 05:20:25 GMT - commit ddc4ffab628944e45dbb8d66d58aae818015440f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
42
42
 
43
43
  const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
44
44
 
45
- var version = "4.62.2";
45
+ var version = "4.62.4";
46
46
  const package_ = {
47
47
  version: version};
48
48
 
@@ -56,6 +56,170 @@ function ensureArray$1(items) {
56
56
  return [];
57
57
  }
58
58
 
59
+ const doNothing = () => { };
60
+
61
+ async function asyncFlatten(array) {
62
+ do {
63
+ array = (await Promise.all(array)).flat(Infinity);
64
+ } while (array.some((v) => v?.then));
65
+ return array;
66
+ }
67
+
68
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
69
+ const { onwarn, onLog } = config;
70
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
71
+ if (onLog) {
72
+ const minimalPriority = parseAst_js.logLevelPriority[logLevel];
73
+ return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
74
+ if (level === parseAst_js.LOGLEVEL_ERROR) {
75
+ return parseAst_js.error(normalizeLog(handledLog));
76
+ }
77
+ if (parseAst_js.logLevelPriority[level] >= minimalPriority) {
78
+ defaultOnLog(level, normalizeLog(handledLog));
79
+ }
80
+ });
81
+ }
82
+ return defaultOnLog;
83
+ };
84
+ const getDefaultOnLog = (printLog, onwarn) => onwarn
85
+ ? (level, log) => {
86
+ if (level === parseAst_js.LOGLEVEL_WARN) {
87
+ onwarn(addLogToString(log), warning => printLog(parseAst_js.LOGLEVEL_WARN, normalizeLog(warning)));
88
+ }
89
+ else {
90
+ printLog(level, log);
91
+ }
92
+ }
93
+ : printLog;
94
+ const addLogToString = (log) => {
95
+ Object.defineProperty(log, 'toString', {
96
+ value: () => log.message,
97
+ writable: true
98
+ });
99
+ return log;
100
+ };
101
+ const normalizeLog = (log) => typeof log === 'string'
102
+ ? { message: log }
103
+ : typeof log === 'function'
104
+ ? normalizeLog(log())
105
+ : log;
106
+ const defaultPrintLog = (level, { message }) => {
107
+ switch (level) {
108
+ case parseAst_js.LOGLEVEL_WARN: {
109
+ return console.warn(message);
110
+ }
111
+ case parseAst_js.LOGLEVEL_DEBUG: {
112
+ return console.debug(message);
113
+ }
114
+ default: {
115
+ return console.info(message);
116
+ }
117
+ }
118
+ };
119
+ function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
120
+ const validOptionSet = new Set(validOptions);
121
+ const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
122
+ if (unknownOptions.length > 0) {
123
+ log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
124
+ }
125
+ }
126
+ const treeshakePresets = {
127
+ recommended: {
128
+ annotations: true,
129
+ correctVarValueBeforeDeclaration: false,
130
+ manualPureFunctions: parseAst_js.EMPTY_ARRAY,
131
+ moduleSideEffects: () => true,
132
+ propertyReadSideEffects: true,
133
+ tryCatchDeoptimization: true,
134
+ unknownGlobalSideEffects: false
135
+ },
136
+ safest: {
137
+ annotations: true,
138
+ correctVarValueBeforeDeclaration: true,
139
+ manualPureFunctions: parseAst_js.EMPTY_ARRAY,
140
+ moduleSideEffects: () => true,
141
+ propertyReadSideEffects: true,
142
+ tryCatchDeoptimization: true,
143
+ unknownGlobalSideEffects: true
144
+ },
145
+ smallest: {
146
+ annotations: true,
147
+ correctVarValueBeforeDeclaration: false,
148
+ manualPureFunctions: parseAst_js.EMPTY_ARRAY,
149
+ moduleSideEffects: () => false,
150
+ propertyReadSideEffects: false,
151
+ tryCatchDeoptimization: false,
152
+ unknownGlobalSideEffects: false
153
+ }
154
+ };
155
+ const jsxPresets = {
156
+ preserve: {
157
+ factory: null,
158
+ fragment: null,
159
+ importSource: null,
160
+ mode: 'preserve'
161
+ },
162
+ 'preserve-react': {
163
+ factory: 'React.createElement',
164
+ fragment: 'React.Fragment',
165
+ importSource: 'react',
166
+ mode: 'preserve'
167
+ },
168
+ react: {
169
+ factory: 'React.createElement',
170
+ fragment: 'React.Fragment',
171
+ importSource: 'react',
172
+ mode: 'classic'
173
+ },
174
+ 'react-jsx': {
175
+ factory: 'React.createElement',
176
+ importSource: 'react',
177
+ jsxImportSource: 'react/jsx-runtime',
178
+ mode: 'automatic'
179
+ }
180
+ };
181
+ const generatedCodePresets = {
182
+ es2015: {
183
+ arrowFunctions: true,
184
+ constBindings: true,
185
+ objectShorthand: true,
186
+ reservedNamesAsProps: true,
187
+ symbols: true
188
+ },
189
+ es5: {
190
+ arrowFunctions: false,
191
+ constBindings: false,
192
+ objectShorthand: false,
193
+ reservedNamesAsProps: true,
194
+ symbols: false
195
+ }
196
+ };
197
+ const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
198
+ const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
199
+ if (typeof value === 'string') {
200
+ const preset = presets[value];
201
+ if (preset) {
202
+ return preset;
203
+ }
204
+ parseAst_js.error(parseAst_js.logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${parseAst_js.printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
205
+ }
206
+ return objectifyOption(value);
207
+ };
208
+ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
209
+ const presetName = value?.preset;
210
+ if (presetName) {
211
+ const preset = presets[presetName];
212
+ if (preset) {
213
+ return { ...preset, ...value };
214
+ }
215
+ else {
216
+ parseAst_js.error(parseAst_js.logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${parseAst_js.printQuotedStringList(Object.keys(presets))}`, presetName));
217
+ }
218
+ }
219
+ return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
220
+ };
221
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
222
+
59
223
  var BuildPhase;
60
224
  (function (BuildPhase) {
61
225
  BuildPhase[BuildPhase["LOAD_AND_PARSE"] = 0] = "LOAD_AND_PARSE";
@@ -620,186 +784,22 @@ function getNamesFromAssets(consumedFiles) {
620
784
  return { names, originalFileNames };
621
785
  }
622
786
 
623
- const doNothing = () => { };
624
-
625
- async function asyncFlatten(array) {
626
- do {
627
- array = (await Promise.all(array)).flat(Infinity);
628
- } while (array.some((v) => v?.then));
629
- return array;
630
- }
631
-
632
- const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
633
- const { onwarn, onLog } = config;
634
- const defaultOnLog = getDefaultOnLog(printLog, onwarn);
635
- if (onLog) {
636
- const minimalPriority = parseAst_js.logLevelPriority[logLevel];
637
- return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
638
- if (level === parseAst_js.LOGLEVEL_ERROR) {
639
- return parseAst_js.error(normalizeLog(handledLog));
640
- }
641
- if (parseAst_js.logLevelPriority[level] >= minimalPriority) {
642
- defaultOnLog(level, normalizeLog(handledLog));
643
- }
644
- });
645
- }
646
- return defaultOnLog;
647
- };
648
- const getDefaultOnLog = (printLog, onwarn) => onwarn
649
- ? (level, log) => {
650
- if (level === parseAst_js.LOGLEVEL_WARN) {
651
- onwarn(addLogToString(log), warning => printLog(parseAst_js.LOGLEVEL_WARN, normalizeLog(warning)));
652
- }
653
- else {
654
- printLog(level, log);
655
- }
787
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
788
+ if (parseAst_js.logLevelPriority[level] < parseAst_js.logLevelPriority[logLevel]) {
789
+ return doNothing;
656
790
  }
657
- : printLog;
658
- const addLogToString = (log) => {
659
- Object.defineProperty(log, 'toString', {
660
- value: () => log.message,
661
- writable: true
662
- });
663
- return log;
664
- };
665
- const normalizeLog = (log) => typeof log === 'string'
666
- ? { message: log }
667
- : typeof log === 'function'
668
- ? normalizeLog(log())
669
- : log;
670
- const defaultPrintLog = (level, { message }) => {
671
- switch (level) {
672
- case parseAst_js.LOGLEVEL_WARN: {
673
- return console.warn(message);
674
- }
675
- case parseAst_js.LOGLEVEL_DEBUG: {
676
- return console.debug(message);
791
+ return (log, pos) => {
792
+ if (pos != null) {
793
+ logger(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidLogPosition(pluginName));
677
794
  }
678
- default: {
679
- return console.info(message);
795
+ log = normalizeLog(log);
796
+ if (log.code && !log.pluginCode) {
797
+ log.pluginCode = log.code;
680
798
  }
681
- }
682
- };
683
- function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
684
- const validOptionSet = new Set(validOptions);
685
- const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
686
- if (unknownOptions.length > 0) {
687
- log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
688
- }
689
- }
690
- const treeshakePresets = {
691
- recommended: {
692
- annotations: true,
693
- correctVarValueBeforeDeclaration: false,
694
- manualPureFunctions: parseAst_js.EMPTY_ARRAY,
695
- moduleSideEffects: () => true,
696
- propertyReadSideEffects: true,
697
- tryCatchDeoptimization: true,
698
- unknownGlobalSideEffects: false
699
- },
700
- safest: {
701
- annotations: true,
702
- correctVarValueBeforeDeclaration: true,
703
- manualPureFunctions: parseAst_js.EMPTY_ARRAY,
704
- moduleSideEffects: () => true,
705
- propertyReadSideEffects: true,
706
- tryCatchDeoptimization: true,
707
- unknownGlobalSideEffects: true
708
- },
709
- smallest: {
710
- annotations: true,
711
- correctVarValueBeforeDeclaration: false,
712
- manualPureFunctions: parseAst_js.EMPTY_ARRAY,
713
- moduleSideEffects: () => false,
714
- propertyReadSideEffects: false,
715
- tryCatchDeoptimization: false,
716
- unknownGlobalSideEffects: false
717
- }
718
- };
719
- const jsxPresets = {
720
- preserve: {
721
- factory: null,
722
- fragment: null,
723
- importSource: null,
724
- mode: 'preserve'
725
- },
726
- 'preserve-react': {
727
- factory: 'React.createElement',
728
- fragment: 'React.Fragment',
729
- importSource: 'react',
730
- mode: 'preserve'
731
- },
732
- react: {
733
- factory: 'React.createElement',
734
- fragment: 'React.Fragment',
735
- importSource: 'react',
736
- mode: 'classic'
737
- },
738
- 'react-jsx': {
739
- factory: 'React.createElement',
740
- importSource: 'react',
741
- jsxImportSource: 'react/jsx-runtime',
742
- mode: 'automatic'
743
- }
744
- };
745
- const generatedCodePresets = {
746
- es2015: {
747
- arrowFunctions: true,
748
- constBindings: true,
749
- objectShorthand: true,
750
- reservedNamesAsProps: true,
751
- symbols: true
752
- },
753
- es5: {
754
- arrowFunctions: false,
755
- constBindings: false,
756
- objectShorthand: false,
757
- reservedNamesAsProps: true,
758
- symbols: false
759
- }
760
- };
761
- const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
762
- const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
763
- if (typeof value === 'string') {
764
- const preset = presets[value];
765
- if (preset) {
766
- return preset;
767
- }
768
- parseAst_js.error(parseAst_js.logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${parseAst_js.printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
769
- }
770
- return objectifyOption(value);
771
- };
772
- const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
773
- const presetName = value?.preset;
774
- if (presetName) {
775
- const preset = presets[presetName];
776
- if (preset) {
777
- return { ...preset, ...value };
778
- }
779
- else {
780
- parseAst_js.error(parseAst_js.logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${parseAst_js.printQuotedStringList(Object.keys(presets))}`, presetName));
781
- }
782
- }
783
- return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
784
- };
785
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
786
-
787
- function getLogHandler(level, code, logger, pluginName, logLevel) {
788
- if (parseAst_js.logLevelPriority[level] < parseAst_js.logLevelPriority[logLevel]) {
789
- return doNothing;
790
- }
791
- return (log, pos) => {
792
- if (pos != null) {
793
- logger(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidLogPosition(pluginName));
794
- }
795
- log = normalizeLog(log);
796
- if (log.code && !log.pluginCode) {
797
- log.pluginCode = log.code;
798
- }
799
- log.code = code;
800
- log.plugin = pluginName;
801
- logger(level, log);
802
- };
799
+ log.code = code;
800
+ log.plugin = pluginName;
801
+ logger(level, log);
802
+ };
803
803
  }
804
804
 
805
805
  const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
@@ -1881,7 +1881,15 @@ function requireParse () {
1881
1881
  }
1882
1882
  };
1883
1883
 
1884
- const getStarExtglobSequenceOutput = pattern => {
1884
+ const buildCharClassStar = chars => {
1885
+ const source = chars.length === 1
1886
+ ? utils.escapeRegex(chars[0])
1887
+ : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
1888
+
1889
+ return `${source}*`;
1890
+ };
1891
+
1892
+ const getStarExtglobSequenceChars = pattern => {
1885
1893
  let index = 0;
1886
1894
  const chars = [];
1887
1895
 
@@ -1910,11 +1918,7 @@ function requireParse () {
1910
1918
  return;
1911
1919
  }
1912
1920
 
1913
- const source = chars.length === 1
1914
- ? utils.escapeRegex(chars[0])
1915
- : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
1916
-
1917
- return `${source}*`;
1921
+ return chars;
1918
1922
  };
1919
1923
 
1920
1924
  const repeatedExtglobRecursion = pattern => {
@@ -1953,17 +1957,43 @@ function requireParse () {
1953
1957
  }
1954
1958
  }
1955
1959
 
1960
+ // A repeated extglob is "risky" (prone to catastrophic backtracking) when a
1961
+ // branch is itself a `*(...)` sequence, since that nests an unbounded quantifier
1962
+ // inside the outer `+(...)`/`*(...)`. When *every* branch reduces to single
1963
+ // characters we can emit one flat, ReDoS-safe character class that preserves the
1964
+ // meaning of ALL branches (e.g. `+(*(a)|*(b))` -> `[ab]*`), rather than dropping
1965
+ // every branch but the first.
1966
+ const safeChars = [];
1967
+ let sawStarSequence = false;
1968
+ let combinable = true;
1969
+
1956
1970
  for (const branch of branches) {
1957
- const safeOutput = getStarExtglobSequenceOutput(branch);
1958
- if (safeOutput) {
1959
- return { risky: true, safeOutput };
1971
+ const chars = getStarExtglobSequenceChars(branch);
1972
+ if (chars) {
1973
+ sawStarSequence = true;
1974
+ safeChars.push(...chars);
1975
+ continue;
1960
1976
  }
1961
1977
 
1978
+ const literal = normalizeSimpleBranch(branch);
1979
+ if (literal && literal.length === 1) {
1980
+ safeChars.push(literal);
1981
+ continue;
1982
+ }
1983
+
1984
+ combinable = false;
1985
+
1962
1986
  if (repeatedExtglobRecursion(branch) > max) {
1963
1987
  return { risky: true };
1964
1988
  }
1965
1989
  }
1966
1990
 
1991
+ if (sawStarSequence) {
1992
+ return combinable
1993
+ ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) }
1994
+ : { risky: true };
1995
+ }
1996
+
1967
1997
  return { risky: false };
1968
1998
  };
1969
1999
 
@@ -3065,6 +3095,18 @@ function requirePicomatch$1 () {
3065
3095
  * const isMatch = picomatch('*.!(*a)');
3066
3096
  * console.log(isMatch('a.a')); //=> false
3067
3097
  * console.log(isMatch('a.b')); //=> true
3098
+ *
3099
+ * // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
3100
+ * const picomatch = require('picomatch/posix');
3101
+ * // the same API, defaulting to posix paths
3102
+ * const isMatch = picomatch('a/*');
3103
+ * console.log(isMatch('a\\b')); //=> false
3104
+ * console.log(isMatch('a/b')); //=> true
3105
+ *
3106
+ * // you can still configure the matcher function to accept windows paths
3107
+ * const isMatch = picomatch('a/*', { options: windows });
3108
+ * console.log(isMatch('a\\b')); //=> true
3109
+ * console.log(isMatch('a/b')); //=> true
3068
3110
  * ```
3069
3111
  * @name picomatch
3070
3112
  * @param {String|Array} `globs` One or more glob patterns.
@@ -3202,9 +3244,9 @@ function requirePicomatch$1 () {
3202
3244
  * @api public
3203
3245
  */
3204
3246
 
3205
- picomatch.matchBase = (input, glob, options) => {
3247
+ picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
3206
3248
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3207
- return regex.test(utils.basename(input));
3249
+ return regex.test(utils.basename(input, { windows: posix }));
3208
3250
  };
3209
3251
 
3210
3252
  /**
@@ -4330,214 +4372,158 @@ function encode(decoded) {
4330
4372
  return writer.flush();
4331
4373
  }
4332
4374
 
4333
- class BitSet {
4375
+ //#region src/BitSet.ts
4376
+ var BitSet = class BitSet {
4334
4377
  constructor(arg) {
4335
4378
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
4336
4379
  }
4337
-
4338
4380
  add(n) {
4339
4381
  this.bits[n >> 5] |= 1 << (n & 31);
4340
4382
  }
4341
-
4342
4383
  has(n) {
4343
- return !!(this.bits[n >> 5] & (1 << (n & 31)));
4384
+ return !!(this.bits[n >> 5] & 1 << (n & 31));
4344
4385
  }
4345
- }
4346
-
4347
- let Chunk$1 = class Chunk {
4386
+ };
4387
+ //#endregion
4388
+ //#region src/Chunk.ts
4389
+ var Chunk$1 = class Chunk {
4348
4390
  constructor(start, end, content) {
4349
4391
  this.start = start;
4350
4392
  this.end = end;
4351
4393
  this.original = content;
4352
-
4353
- this.intro = '';
4354
- this.outro = '';
4355
-
4394
+ this.intro = "";
4395
+ this.outro = "";
4356
4396
  this.content = content;
4357
4397
  this.storeName = false;
4358
4398
  this.edited = false;
4359
-
4360
- {
4361
- this.previous = null;
4362
- this.next = null;
4363
- }
4399
+ this.previous = null;
4400
+ this.next = null;
4364
4401
  }
4365
-
4366
4402
  appendLeft(content) {
4367
4403
  this.outro += content;
4368
4404
  }
4369
-
4370
4405
  appendRight(content) {
4371
4406
  this.intro = this.intro + content;
4372
4407
  }
4373
-
4374
4408
  clone() {
4375
4409
  const chunk = new Chunk(this.start, this.end, this.original);
4376
-
4377
4410
  chunk.intro = this.intro;
4378
4411
  chunk.outro = this.outro;
4379
4412
  chunk.content = this.content;
4380
4413
  chunk.storeName = this.storeName;
4381
4414
  chunk.edited = this.edited;
4382
-
4383
4415
  return chunk;
4384
4416
  }
4385
-
4386
4417
  contains(index) {
4387
4418
  return this.start < index && index < this.end;
4388
4419
  }
4389
-
4390
4420
  eachNext(fn) {
4391
- let chunk = this;
4421
+ fn(this);
4422
+ let chunk = this.next;
4392
4423
  while (chunk) {
4393
4424
  fn(chunk);
4394
4425
  chunk = chunk.next;
4395
4426
  }
4396
4427
  }
4397
-
4398
4428
  eachPrevious(fn) {
4399
- let chunk = this;
4429
+ fn(this);
4430
+ let chunk = this.previous;
4400
4431
  while (chunk) {
4401
4432
  fn(chunk);
4402
4433
  chunk = chunk.previous;
4403
4434
  }
4404
4435
  }
4405
-
4406
4436
  edit(content, storeName, contentOnly) {
4407
4437
  this.content = content;
4408
4438
  if (!contentOnly) {
4409
- this.intro = '';
4410
- this.outro = '';
4439
+ this.intro = "";
4440
+ this.outro = "";
4411
4441
  }
4412
4442
  this.storeName = storeName;
4413
-
4414
4443
  this.edited = true;
4415
-
4416
4444
  return this;
4417
4445
  }
4418
-
4419
4446
  prependLeft(content) {
4420
4447
  this.outro = content + this.outro;
4421
4448
  }
4422
-
4423
4449
  prependRight(content) {
4424
4450
  this.intro = content + this.intro;
4425
4451
  }
4426
-
4427
4452
  reset() {
4428
- this.intro = '';
4429
- this.outro = '';
4453
+ this.intro = "";
4454
+ this.outro = "";
4430
4455
  if (this.edited) {
4431
4456
  this.content = this.original;
4432
4457
  this.storeName = false;
4433
4458
  this.edited = false;
4434
4459
  }
4435
4460
  }
4436
-
4437
4461
  split(index) {
4438
4462
  const sliceIndex = index - this.start;
4439
-
4440
4463
  const originalBefore = this.original.slice(0, sliceIndex);
4441
4464
  const originalAfter = this.original.slice(sliceIndex);
4442
-
4443
4465
  this.original = originalBefore;
4444
-
4445
4466
  const newChunk = new Chunk(index, this.end, originalAfter);
4446
4467
  newChunk.outro = this.outro;
4447
- this.outro = '';
4448
-
4468
+ this.outro = "";
4449
4469
  this.end = index;
4450
-
4451
4470
  if (this.edited) {
4452
- // after split we should save the edit content record into the correct chunk
4453
- // to make sure sourcemap correct
4454
- // For example:
4455
- // ' test'.trim()
4456
- // split -> ' ' + 'test'
4457
- // ✔️ edit -> '' + 'test'
4458
- // ✖️ edit -> 'test' + ''
4459
- // TODO is this block necessary?...
4460
- newChunk.edit('', false);
4461
- this.content = '';
4462
- } else {
4463
- this.content = originalBefore;
4464
- }
4465
-
4471
+ newChunk.edit("", false);
4472
+ this.content = "";
4473
+ } else this.content = originalBefore;
4466
4474
  newChunk.next = this.next;
4467
4475
  if (newChunk.next) newChunk.next.previous = newChunk;
4468
4476
  newChunk.previous = this;
4469
4477
  this.next = newChunk;
4470
-
4471
4478
  return newChunk;
4472
4479
  }
4473
-
4474
4480
  toString() {
4475
4481
  return this.intro + this.content + this.outro;
4476
4482
  }
4477
-
4478
4483
  trimEnd(rx) {
4479
- this.outro = this.outro.replace(rx, '');
4484
+ this.outro = this.outro.replace(rx, "");
4480
4485
  if (this.outro.length) return true;
4481
-
4482
- const trimmed = this.content.replace(rx, '');
4483
-
4486
+ const trimmed = this.content.replace(rx, "");
4484
4487
  if (trimmed.length) {
4485
- if (trimmed !== this.content) {
4486
- this.split(this.start + trimmed.length).edit('', undefined, true);
4487
- if (this.edited) {
4488
- // save the change, if it has been edited
4489
- this.edit(trimmed, this.storeName, true);
4490
- }
4491
- }
4488
+ if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
4489
+ else this.split(this.start + trimmed.length).edit("", void 0, true);
4492
4490
  return true;
4493
4491
  } else {
4494
- this.edit('', undefined, true);
4495
-
4496
- this.intro = this.intro.replace(rx, '');
4492
+ this.edit("", void 0, true);
4493
+ this.intro = this.intro.replace(rx, "");
4497
4494
  if (this.intro.length) return true;
4498
4495
  }
4499
4496
  }
4500
-
4501
4497
  trimStart(rx) {
4502
- this.intro = this.intro.replace(rx, '');
4498
+ this.intro = this.intro.replace(rx, "");
4503
4499
  if (this.intro.length) return true;
4504
-
4505
- const trimmed = this.content.replace(rx, '');
4506
-
4500
+ const trimmed = this.content.replace(rx, "");
4507
4501
  if (trimmed.length) {
4508
- if (trimmed !== this.content) {
4509
- const newChunk = this.split(this.end - trimmed.length);
4510
- if (this.edited) {
4511
- // save the change, if it has been edited
4512
- newChunk.edit(trimmed, this.storeName, true);
4513
- }
4514
- this.edit('', undefined, true);
4502
+ if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
4503
+ else {
4504
+ this.split(this.end - trimmed.length);
4505
+ this.edit("", void 0, true);
4515
4506
  }
4516
4507
  return true;
4517
4508
  } else {
4518
- this.edit('', undefined, true);
4519
-
4520
- this.outro = this.outro.replace(rx, '');
4509
+ this.edit("", void 0, true);
4510
+ this.outro = this.outro.replace(rx, "");
4521
4511
  if (this.outro.length) return true;
4522
4512
  }
4523
4513
  }
4524
4514
  };
4525
-
4515
+ //#endregion
4516
+ //#region src/SourceMap.ts
4526
4517
  function getBtoa() {
4527
- if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
4528
- return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
4529
- } else if (typeof Buffer === 'function') {
4530
- return (str) => Buffer.from(str, 'utf-8').toString('base64');
4531
- } else {
4532
- return () => {
4533
- throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
4534
- };
4535
- }
4518
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
4519
+ const buffer = globalThis["Buffer"];
4520
+ if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
4521
+ return () => {
4522
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
4523
+ };
4536
4524
  }
4537
-
4538
- const btoa = /*#__PURE__*/ getBtoa();
4539
-
4540
- class SourceMap {
4525
+ const btoa = /* #__PURE__ */ getBtoa();
4526
+ var SourceMap = class {
4541
4527
  constructor(properties) {
4542
4528
  this.version = 3;
4543
4529
  this.file = properties.file;
@@ -4545,103 +4531,87 @@ class SourceMap {
4545
4531
  this.sourcesContent = properties.sourcesContent;
4546
4532
  this.names = properties.names;
4547
4533
  this.mappings = encode(properties.mappings);
4548
- if (typeof properties.x_google_ignoreList !== 'undefined') {
4549
- this.x_google_ignoreList = properties.x_google_ignoreList;
4550
- }
4551
- if (typeof properties.debugId !== 'undefined') {
4552
- this.debugId = properties.debugId;
4553
- }
4534
+ if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
4535
+ if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
4554
4536
  }
4555
-
4537
+ /**
4538
+ * Returns the equivalent of `JSON.stringify(map)`
4539
+ */
4556
4540
  toString() {
4557
4541
  return JSON.stringify(this);
4558
4542
  }
4559
-
4543
+ /**
4544
+ * Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
4545
+ * `generateMap(options?: SourceMapOptions): SourceMap;`
4546
+ */
4560
4547
  toUrl() {
4561
- return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
4562
- }
4563
- }
4564
-
4565
- function guessIndent(code) {
4566
- const lines = code.split('\n');
4567
-
4568
- const tabbed = lines.filter((line) => /^\t+/.test(line));
4569
- const spaced = lines.filter((line) => /^ {2,}/.test(line));
4570
-
4571
- if (tabbed.length === 0 && spaced.length === 0) {
4572
- return null;
4548
+ return `data:application/json;charset=utf-8;base64,${btoa(this.toString())}`;
4573
4549
  }
4574
-
4575
- // More lines tabbed than spaced? Assume tabs, and
4576
- // default to tabs in the case of a tie (or nothing
4577
- // to go on)
4578
- if (tabbed.length >= spaced.length) {
4579
- return '\t';
4550
+ };
4551
+ //#endregion
4552
+ //#region src/utils/getLocator.ts
4553
+ function getLocator(source) {
4554
+ const originalLines = source.split("\n");
4555
+ const lineOffsets = [];
4556
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
4557
+ lineOffsets.push(pos);
4558
+ pos += originalLines[i].length + 1;
4580
4559
  }
4581
-
4582
- // Otherwise, we need to guess the multiple
4583
- const min = spaced.reduce((previous, current) => {
4584
- const numSpaces = /^ +/.exec(current)[0].length;
4585
- return Math.min(numSpaces, previous);
4586
- }, Infinity);
4587
-
4588
- return new Array(min + 1).join(' ');
4560
+ return function locate(index) {
4561
+ let i = 0;
4562
+ let j = lineOffsets.length;
4563
+ while (i < j) {
4564
+ const m = i + j >> 1;
4565
+ if (index < lineOffsets[m]) j = m;
4566
+ else i = m + 1;
4567
+ }
4568
+ const line = i - 1;
4569
+ return {
4570
+ line,
4571
+ column: index - lineOffsets[line]
4572
+ };
4573
+ };
4589
4574
  }
4590
-
4575
+ //#endregion
4576
+ //#region src/utils/getRelativePath.ts
4591
4577
  function getRelativePath(from, to) {
4592
4578
  const fromParts = from.split(/[/\\]/);
4593
4579
  const toParts = to.split(/[/\\]/);
4594
-
4595
- fromParts.pop(); // get dirname
4596
-
4580
+ fromParts.pop();
4597
4581
  while (fromParts[0] === toParts[0]) {
4598
4582
  fromParts.shift();
4599
4583
  toParts.shift();
4600
4584
  }
4601
-
4602
4585
  if (fromParts.length) {
4603
4586
  let i = fromParts.length;
4604
- while (i--) fromParts[i] = '..';
4587
+ while (i--) fromParts[i] = "..";
4605
4588
  }
4606
-
4607
- return fromParts.concat(toParts).join('/');
4589
+ return fromParts.concat(toParts).join("/");
4608
4590
  }
4609
-
4591
+ //#endregion
4592
+ //#region src/utils/guessIndent.ts
4593
+ function guessIndent(code) {
4594
+ const lines = code.split("\n");
4595
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
4596
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
4597
+ if (tabbed.length === 0 && spaced.length === 0) return null;
4598
+ if (tabbed.length >= spaced.length) return " ";
4599
+ const min = spaced.reduce((previous, current) => {
4600
+ const numSpaces = /^ +/.exec(current)[0].length;
4601
+ return Math.min(numSpaces, previous);
4602
+ }, Infinity);
4603
+ return " ".repeat(min);
4604
+ }
4605
+ //#endregion
4606
+ //#region src/utils/isObject.ts
4610
4607
  const toString = Object.prototype.toString;
4611
-
4612
4608
  function isObject(thing) {
4613
- return toString.call(thing) === '[object Object]';
4614
- }
4615
-
4616
- function getLocator(source) {
4617
- const originalLines = source.split('\n');
4618
- const lineOffsets = [];
4619
-
4620
- for (let i = 0, pos = 0; i < originalLines.length; i++) {
4621
- lineOffsets.push(pos);
4622
- pos += originalLines[i].length + 1;
4623
- }
4624
-
4625
- return function locate(index) {
4626
- let i = 0;
4627
- let j = lineOffsets.length;
4628
- while (i < j) {
4629
- const m = (i + j) >> 1;
4630
- if (index < lineOffsets[m]) {
4631
- j = m;
4632
- } else {
4633
- i = m + 1;
4634
- }
4635
- }
4636
- const line = i - 1;
4637
- const column = index - lineOffsets[line];
4638
- return { line, column };
4639
- };
4609
+ return toString.call(thing) === "[object Object]";
4640
4610
  }
4641
-
4611
+ //#endregion
4612
+ //#region src/utils/Mappings.ts
4642
4613
  const wordRegex = /\w/;
4643
-
4644
- class Mappings {
4614
+ var Mappings = class {
4645
4615
  constructor(hires) {
4646
4616
  this.hires = hires;
4647
4617
  this.generatedCodeLine = 0;
@@ -4650,52 +4620,47 @@ class Mappings {
4650
4620
  this.rawSegments = this.raw[this.generatedCodeLine] = [];
4651
4621
  this.pending = null;
4652
4622
  }
4653
-
4654
4623
  addEdit(sourceIndex, content, loc, nameIndex) {
4655
4624
  if (content.length) {
4656
4625
  const contentLengthMinusOne = content.length - 1;
4657
- let contentLineEnd = content.indexOf('\n', 0);
4626
+ let contentLineEnd = content.indexOf("\n", 0);
4658
4627
  let previousContentLineEnd = -1;
4659
- // Loop through each line in the content and add a segment, but stop if the last line is empty,
4660
- // else code afterwards would fill one line too many
4661
4628
  while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
4662
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4663
- if (nameIndex >= 0) {
4664
- segment.push(nameIndex);
4665
- }
4629
+ const segment = [
4630
+ this.generatedCodeColumn,
4631
+ sourceIndex,
4632
+ loc.line,
4633
+ loc.column
4634
+ ];
4635
+ if (nameIndex >= 0) segment.push(nameIndex);
4666
4636
  this.rawSegments.push(segment);
4667
-
4668
4637
  this.generatedCodeLine += 1;
4669
4638
  this.raw[this.generatedCodeLine] = this.rawSegments = [];
4670
4639
  this.generatedCodeColumn = 0;
4671
-
4672
4640
  previousContentLineEnd = contentLineEnd;
4673
- contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
4674
- }
4675
-
4676
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4677
- if (nameIndex >= 0) {
4678
- segment.push(nameIndex);
4641
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
4679
4642
  }
4643
+ const segment = [
4644
+ this.generatedCodeColumn,
4645
+ sourceIndex,
4646
+ loc.line,
4647
+ loc.column
4648
+ ];
4649
+ if (nameIndex >= 0) segment.push(nameIndex);
4680
4650
  this.rawSegments.push(segment);
4681
-
4682
4651
  this.advance(content.slice(previousContentLineEnd + 1));
4683
4652
  } else if (this.pending) {
4684
4653
  this.rawSegments.push(this.pending);
4685
4654
  this.advance(content);
4686
4655
  }
4687
-
4688
4656
  this.pending = null;
4689
4657
  }
4690
-
4691
4658
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
4692
4659
  let originalCharIndex = chunk.start;
4693
4660
  let first = true;
4694
- // when iterating each char, check if it's in a word boundary
4695
4661
  let charInHiresBoundary = false;
4696
-
4697
4662
  while (originalCharIndex < chunk.end) {
4698
- if (original[originalCharIndex] === '\n') {
4663
+ if (original[originalCharIndex] === "\n") {
4699
4664
  loc.line += 1;
4700
4665
  loc.column = 0;
4701
4666
  this.generatedCodeLine += 1;
@@ -4705,42 +4670,34 @@ class Mappings {
4705
4670
  charInHiresBoundary = false;
4706
4671
  } else {
4707
4672
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
4708
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4709
-
4710
- if (this.hires === 'boundary') {
4711
- // in hires "boundary", group segments per word boundary than per char
4712
- if (wordRegex.test(original[originalCharIndex])) {
4713
- // for first char in the boundary found, start the boundary by pushing a segment
4714
- if (!charInHiresBoundary) {
4715
- this.rawSegments.push(segment);
4716
- charInHiresBoundary = true;
4717
- }
4718
- } else {
4719
- // for non-word char, end the boundary by pushing a segment
4673
+ const segment = [
4674
+ this.generatedCodeColumn,
4675
+ sourceIndex,
4676
+ loc.line,
4677
+ loc.column
4678
+ ];
4679
+ if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
4680
+ if (!charInHiresBoundary) {
4720
4681
  this.rawSegments.push(segment);
4721
- charInHiresBoundary = false;
4682
+ charInHiresBoundary = true;
4722
4683
  }
4723
4684
  } else {
4724
4685
  this.rawSegments.push(segment);
4686
+ charInHiresBoundary = false;
4725
4687
  }
4688
+ else this.rawSegments.push(segment);
4726
4689
  }
4727
-
4728
4690
  loc.column += 1;
4729
4691
  this.generatedCodeColumn += 1;
4730
4692
  first = false;
4731
4693
  }
4732
-
4733
4694
  originalCharIndex += 1;
4734
4695
  }
4735
-
4736
4696
  this.pending = null;
4737
4697
  }
4738
-
4739
4698
  advance(str) {
4740
4699
  if (!str) return;
4741
-
4742
- const lines = str.split('\n');
4743
-
4700
+ const lines = str.split("\n");
4744
4701
  if (lines.length > 1) {
4745
4702
  for (let i = 0; i < lines.length - 1; i++) {
4746
4703
  this.generatedCodeLine++;
@@ -4748,1029 +4705,872 @@ class Mappings {
4748
4705
  }
4749
4706
  this.generatedCodeColumn = 0;
4750
4707
  }
4751
-
4752
4708
  this.generatedCodeColumn += lines[lines.length - 1].length;
4753
4709
  }
4754
- }
4755
-
4756
- const n = '\n';
4757
-
4710
+ };
4711
+ //#endregion
4712
+ //#region src/MagicString.ts
4713
+ const n = "\n";
4714
+ const NEWLINE_CHAR = "\n".charCodeAt(0);
4715
+ const CR_CHAR = "\r".charCodeAt(0);
4758
4716
  const warned = {
4759
4717
  insertLeft: false,
4760
4718
  insertRight: false,
4761
- storeName: false,
4719
+ storeName: false
4762
4720
  };
4763
-
4764
- class MagicString {
4721
+ var MagicString = class MagicString {
4765
4722
  constructor(string, options = {}) {
4766
4723
  const chunk = new Chunk$1(0, string.length, string);
4767
-
4768
4724
  Object.defineProperties(this, {
4769
- original: { writable: true, value: string },
4770
- outro: { writable: true, value: '' },
4771
- intro: { writable: true, value: '' },
4772
- firstChunk: { writable: true, value: chunk },
4773
- lastChunk: { writable: true, value: chunk },
4774
- lastSearchedChunk: { writable: true, value: chunk },
4775
- byStart: { writable: true, value: {} },
4776
- byEnd: { writable: true, value: {} },
4777
- filename: { writable: true, value: options.filename },
4778
- indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
4779
- sourcemapLocations: { writable: true, value: new BitSet() },
4780
- storedNames: { writable: true, value: {} },
4781
- indentStr: { writable: true, value: undefined },
4782
- ignoreList: { writable: true, value: options.ignoreList },
4783
- offset: { writable: true, value: options.offset || 0 },
4725
+ original: {
4726
+ writable: true,
4727
+ value: string
4728
+ },
4729
+ outro: {
4730
+ writable: true,
4731
+ value: ""
4732
+ },
4733
+ intro: {
4734
+ writable: true,
4735
+ value: ""
4736
+ },
4737
+ firstChunk: {
4738
+ writable: true,
4739
+ value: chunk
4740
+ },
4741
+ lastChunk: {
4742
+ writable: true,
4743
+ value: chunk
4744
+ },
4745
+ lastSearchedChunk: {
4746
+ writable: true,
4747
+ value: chunk
4748
+ },
4749
+ byStart: {
4750
+ writable: true,
4751
+ value: {}
4752
+ },
4753
+ byEnd: {
4754
+ writable: true,
4755
+ value: {}
4756
+ },
4757
+ filename: {
4758
+ writable: true,
4759
+ value: options.filename
4760
+ },
4761
+ indentExclusionRanges: {
4762
+ writable: true,
4763
+ value: options.indentExclusionRanges
4764
+ },
4765
+ sourcemapLocations: {
4766
+ writable: true,
4767
+ value: new BitSet()
4768
+ },
4769
+ storedNames: {
4770
+ writable: true,
4771
+ value: {}
4772
+ },
4773
+ indentStr: {
4774
+ writable: true,
4775
+ value: void 0
4776
+ },
4777
+ ignoreList: {
4778
+ writable: true,
4779
+ value: options.ignoreList
4780
+ },
4781
+ offset: {
4782
+ writable: true,
4783
+ value: options.offset || 0
4784
+ }
4784
4785
  });
4785
-
4786
- this.byStart[0] = chunk;
4787
- this.byEnd[string.length] = chunk;
4786
+ this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
4787
+ this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
4788
4788
  }
4789
-
4789
+ /**
4790
+ * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
4791
+ */
4790
4792
  addSourcemapLocation(char) {
4791
4793
  this.sourcemapLocations.add(char);
4792
4794
  }
4793
-
4795
+ /**
4796
+ * Appends the specified content to the end of the string.
4797
+ */
4794
4798
  append(content) {
4795
- if (typeof content !== 'string') throw new TypeError('outro content must be a string');
4796
-
4799
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
4797
4800
  this.outro += content;
4798
4801
  return this;
4799
4802
  }
4800
-
4803
+ /**
4804
+ * Appends the specified content at the index in the original string.
4805
+ * If a range *ending* with index is subsequently moved, the insert will be moved with it.
4806
+ * See also `s.prependLeft(...)`.
4807
+ */
4801
4808
  appendLeft(index, content) {
4802
4809
  index = index + this.offset;
4803
-
4804
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4805
-
4810
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4806
4811
  this._split(index);
4807
-
4808
- const chunk = this.byEnd[index];
4809
-
4810
- if (chunk) {
4811
- chunk.appendLeft(content);
4812
- } else {
4813
- this.intro += content;
4814
- }
4812
+ const chunk = this.byEnd.get(index);
4813
+ if (chunk) chunk.appendLeft(content);
4814
+ else this.intro += content;
4815
4815
  return this;
4816
4816
  }
4817
-
4817
+ /**
4818
+ * Appends the specified content at the index in the original string.
4819
+ * If a range *starting* with index is subsequently moved, the insert will be moved with it.
4820
+ * See also `s.prependRight(...)`.
4821
+ */
4818
4822
  appendRight(index, content) {
4819
4823
  index = index + this.offset;
4820
-
4821
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4822
-
4824
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4823
4825
  this._split(index);
4824
-
4825
- const chunk = this.byStart[index];
4826
-
4827
- if (chunk) {
4828
- chunk.appendRight(content);
4829
- } else {
4830
- this.outro += content;
4831
- }
4826
+ const chunk = this.byStart.get(index);
4827
+ if (chunk) chunk.appendRight(content);
4828
+ else this.outro += content;
4832
4829
  return this;
4833
4830
  }
4834
-
4831
+ /**
4832
+ * Does what you'd expect.
4833
+ */
4835
4834
  clone() {
4836
- const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
4837
-
4835
+ const cloned = new MagicString(this.original, {
4836
+ filename: this.filename,
4837
+ offset: this.offset
4838
+ });
4838
4839
  let originalChunk = this.firstChunk;
4839
- let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
4840
-
4840
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
4841
4841
  while (originalChunk) {
4842
- cloned.byStart[clonedChunk.start] = clonedChunk;
4843
- cloned.byEnd[clonedChunk.end] = clonedChunk;
4844
-
4842
+ cloned.byStart.set(clonedChunk.start, clonedChunk);
4843
+ cloned.byEnd.set(clonedChunk.end, clonedChunk);
4845
4844
  const nextOriginalChunk = originalChunk.next;
4846
4845
  const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
4847
-
4848
4846
  if (nextClonedChunk) {
4849
4847
  clonedChunk.next = nextClonedChunk;
4850
4848
  nextClonedChunk.previous = clonedChunk;
4851
-
4852
4849
  clonedChunk = nextClonedChunk;
4853
4850
  }
4854
-
4855
4851
  originalChunk = nextOriginalChunk;
4856
4852
  }
4857
-
4858
4853
  cloned.lastChunk = clonedChunk;
4859
-
4860
- if (this.indentExclusionRanges) {
4861
- cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
4862
- }
4863
-
4854
+ if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
4864
4855
  cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
4865
-
4866
4856
  cloned.intro = this.intro;
4867
4857
  cloned.outro = this.outro;
4868
-
4869
4858
  return cloned;
4870
4859
  }
4871
-
4860
+ /**
4861
+ * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
4862
+ * Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
4863
+ */
4872
4864
  generateDecodedMap(options) {
4873
4865
  options = options || {};
4874
-
4875
4866
  const sourceIndex = 0;
4876
4867
  const names = Object.keys(this.storedNames);
4877
4868
  const mappings = new Mappings(options.hires);
4878
-
4879
4869
  const locate = getLocator(this.original);
4880
-
4881
- if (this.intro) {
4882
- mappings.advance(this.intro);
4883
- }
4884
-
4870
+ if (this.intro) mappings.advance(this.intro);
4885
4871
  this.firstChunk.eachNext((chunk) => {
4886
4872
  const loc = locate(chunk.start);
4887
-
4888
4873
  if (chunk.intro.length) mappings.advance(chunk.intro);
4889
-
4890
- if (chunk.edited) {
4891
- mappings.addEdit(
4892
- sourceIndex,
4893
- chunk.content,
4894
- loc,
4895
- chunk.storeName ? names.indexOf(chunk.original) : -1,
4896
- );
4897
- } else {
4898
- mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
4899
- }
4900
-
4874
+ if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
4875
+ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
4901
4876
  if (chunk.outro.length) mappings.advance(chunk.outro);
4902
4877
  });
4903
-
4904
- if (this.outro) {
4905
- mappings.advance(this.outro);
4906
- }
4907
-
4878
+ if (this.outro) mappings.advance(this.outro);
4908
4879
  return {
4909
- file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
4910
- sources: [
4911
- options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
4912
- ],
4913
- sourcesContent: options.includeContent ? [this.original] : undefined,
4880
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
4881
+ sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
4882
+ sourcesContent: options.includeContent ? [this.original] : void 0,
4914
4883
  names,
4915
4884
  mappings: mappings.raw,
4916
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
4885
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
4917
4886
  };
4918
4887
  }
4919
-
4888
+ /**
4889
+ * Generates a version 3 sourcemap.
4890
+ */
4920
4891
  generateMap(options) {
4921
4892
  return new SourceMap(this.generateDecodedMap(options));
4922
4893
  }
4923
-
4894
+ /** @internal */
4924
4895
  _ensureindentStr() {
4925
- if (this.indentStr === undefined) {
4926
- this.indentStr = guessIndent(this.original);
4927
- }
4896
+ if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
4928
4897
  }
4929
-
4898
+ /** @internal */
4930
4899
  _getRawIndentString() {
4931
4900
  this._ensureindentStr();
4932
4901
  return this.indentStr;
4933
4902
  }
4934
-
4935
4903
  getIndentString() {
4936
4904
  this._ensureindentStr();
4937
- return this.indentStr === null ? '\t' : this.indentStr;
4905
+ return this.indentStr === null ? " " : this.indentStr;
4938
4906
  }
4939
-
4940
4907
  indent(indentStr, options) {
4941
4908
  const pattern = /^[^\r\n]/gm;
4942
-
4943
4909
  if (isObject(indentStr)) {
4944
4910
  options = indentStr;
4945
- indentStr = undefined;
4911
+ indentStr = void 0;
4946
4912
  }
4947
-
4948
- if (indentStr === undefined) {
4913
+ if (indentStr === void 0) {
4949
4914
  this._ensureindentStr();
4950
- indentStr = this.indentStr || '\t';
4915
+ indentStr = this.indentStr || " ";
4951
4916
  }
4952
-
4953
- if (indentStr === '') return this; // noop
4954
-
4917
+ if (indentStr === "") return this;
4918
+ const resolvedIndentStr = indentStr;
4955
4919
  options = options || {};
4956
-
4957
- // Process exclusion ranges
4958
4920
  const isExcluded = {};
4959
-
4960
- if (options.exclude) {
4961
- const exclusions =
4962
- typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
4963
- exclusions.forEach((exclusion) => {
4964
- for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
4965
- isExcluded[i] = true;
4966
- }
4967
- });
4968
- }
4969
-
4921
+ if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
4922
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
4923
+ });
4970
4924
  let shouldIndentNextCharacter = options.indentStart !== false;
4971
4925
  const replacer = (match) => {
4972
- if (shouldIndentNextCharacter) return `${indentStr}${match}`;
4926
+ if (shouldIndentNextCharacter) return `${resolvedIndentStr}${match}`;
4973
4927
  shouldIndentNextCharacter = true;
4974
4928
  return match;
4975
4929
  };
4976
-
4977
4930
  this.intro = this.intro.replace(pattern, replacer);
4978
-
4979
4931
  let charIndex = 0;
4980
4932
  let chunk = this.firstChunk;
4981
-
4933
+ const indentAt = (index) => {
4934
+ shouldIndentNextCharacter = false;
4935
+ if (index === chunk.start) chunk.prependRight(resolvedIndentStr);
4936
+ else {
4937
+ this._splitChunk(chunk, index);
4938
+ chunk = chunk.next;
4939
+ chunk.prependRight(resolvedIndentStr);
4940
+ }
4941
+ };
4982
4942
  while (chunk) {
4983
4943
  const end = chunk.end;
4984
-
4985
4944
  if (chunk.edited) {
4986
4945
  if (!isExcluded[charIndex]) {
4987
4946
  chunk.content = chunk.content.replace(pattern, replacer);
4988
-
4989
- if (chunk.content.length) {
4990
- shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
4947
+ if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
4948
+ }
4949
+ } else if (options.exclude) {
4950
+ charIndex = chunk.start;
4951
+ while (charIndex < end) {
4952
+ if (!isExcluded[charIndex]) {
4953
+ const char = this.original.charCodeAt(charIndex);
4954
+ if (char === NEWLINE_CHAR) shouldIndentNextCharacter = true;
4955
+ else if (char !== CR_CHAR && shouldIndentNextCharacter) indentAt(charIndex);
4991
4956
  }
4957
+ charIndex += 1;
4992
4958
  }
4993
4959
  } else {
4994
4960
  charIndex = chunk.start;
4995
-
4996
4961
  while (charIndex < end) {
4997
- if (!isExcluded[charIndex]) {
4998
- const char = this.original[charIndex];
4999
-
5000
- if (char === '\n') {
5001
- shouldIndentNextCharacter = true;
5002
- } else if (char !== '\r' && shouldIndentNextCharacter) {
5003
- shouldIndentNextCharacter = false;
5004
-
5005
- if (charIndex === chunk.start) {
5006
- chunk.prependRight(indentStr);
5007
- } else {
5008
- this._splitChunk(chunk, charIndex);
5009
- chunk = chunk.next;
5010
- chunk.prependRight(indentStr);
5011
- }
5012
- }
4962
+ if (!shouldIndentNextCharacter) {
4963
+ const nextLine = this.original.indexOf(n, charIndex);
4964
+ if (nextLine === -1 || nextLine >= end) break;
4965
+ shouldIndentNextCharacter = true;
4966
+ charIndex = nextLine + 1;
4967
+ continue;
5013
4968
  }
5014
-
4969
+ const char = this.original.charCodeAt(charIndex);
4970
+ if (char === NEWLINE_CHAR || char === CR_CHAR) {
4971
+ charIndex += 1;
4972
+ continue;
4973
+ }
4974
+ indentAt(charIndex);
5015
4975
  charIndex += 1;
5016
4976
  }
5017
4977
  }
5018
-
5019
4978
  charIndex = chunk.end;
5020
4979
  chunk = chunk.next;
5021
4980
  }
5022
-
5023
4981
  this.outro = this.outro.replace(pattern, replacer);
5024
-
5025
4982
  return this;
5026
4983
  }
5027
-
4984
+ /** @internal */
5028
4985
  insert() {
5029
- throw new Error(
5030
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
5031
- );
4986
+ throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
5032
4987
  }
5033
-
4988
+ /** @internal */
5034
4989
  insertLeft(index, content) {
5035
4990
  if (!warned.insertLeft) {
5036
- console.warn(
5037
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
5038
- );
4991
+ console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
5039
4992
  warned.insertLeft = true;
5040
4993
  }
5041
-
5042
4994
  return this.appendLeft(index, content);
5043
4995
  }
5044
-
4996
+ /** @internal */
5045
4997
  insertRight(index, content) {
5046
4998
  if (!warned.insertRight) {
5047
- console.warn(
5048
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
5049
- );
4999
+ console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
5050
5000
  warned.insertRight = true;
5051
5001
  }
5052
-
5053
5002
  return this.prependRight(index, content);
5054
5003
  }
5055
-
5004
+ /**
5005
+ * Moves the characters from `start` and `end` to `index`.
5006
+ */
5056
5007
  move(start, end, index) {
5057
5008
  start = start + this.offset;
5058
5009
  end = end + this.offset;
5059
5010
  index = index + this.offset;
5060
-
5061
- if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
5062
-
5011
+ if (start === end) return this;
5012
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
5063
5013
  this._split(start);
5064
5014
  this._split(end);
5065
5015
  this._split(index);
5066
-
5067
- const first = this.byStart[start];
5068
- const last = this.byEnd[end];
5069
-
5016
+ const first = this.byStart.get(start);
5017
+ const last = this.byEnd.get(end);
5070
5018
  const oldLeft = first.previous;
5071
5019
  const oldRight = last.next;
5072
-
5073
- const newRight = this.byStart[index];
5020
+ const newRight = this.byStart.get(index);
5074
5021
  if (!newRight && last === this.lastChunk) return this;
5075
5022
  const newLeft = newRight ? newRight.previous : this.lastChunk;
5076
-
5077
5023
  if (oldLeft) oldLeft.next = oldRight;
5078
5024
  if (oldRight) oldRight.previous = oldLeft;
5079
-
5080
5025
  if (newLeft) newLeft.next = first;
5081
5026
  if (newRight) newRight.previous = last;
5082
-
5083
5027
  if (!first.previous) this.firstChunk = last.next;
5084
5028
  if (!last.next) {
5085
5029
  this.lastChunk = first.previous;
5086
5030
  this.lastChunk.next = null;
5087
5031
  }
5088
-
5089
5032
  first.previous = newLeft;
5090
5033
  last.next = newRight || null;
5091
-
5092
5034
  if (!newLeft) this.firstChunk = first;
5093
5035
  if (!newRight) this.lastChunk = last;
5094
5036
  return this;
5095
5037
  }
5096
-
5038
+ /**
5039
+ * Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
5040
+ * that range. The same restrictions as `s.remove()` apply.
5041
+ *
5042
+ * The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
5043
+ * for later inclusion in a sourcemap's names array - and a contentOnly property which determines whether only
5044
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
5045
+ *
5046
+ * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
5047
+ */
5097
5048
  overwrite(start, end, content, options) {
5098
- options = options || {};
5099
- return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
5049
+ const optionObject = typeof options === "object" && options ? options : {};
5050
+ return this.update(start, end, content, {
5051
+ ...optionObject,
5052
+ overwrite: !optionObject.contentOnly
5053
+ });
5100
5054
  }
5101
-
5055
+ /**
5056
+ * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
5057
+ *
5058
+ * The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
5059
+ * for later inclusion in a sourcemap's names array - and an overwrite property which determines whether only
5060
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
5061
+ */
5102
5062
  update(start, end, content, options) {
5103
5063
  start = start + this.offset;
5104
5064
  end = end + this.offset;
5105
-
5106
- if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
5107
-
5065
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
5108
5066
  if (this.original.length !== 0) {
5109
5067
  while (start < 0) start += this.original.length;
5110
5068
  while (end < 0) end += this.original.length;
5111
5069
  }
5112
-
5113
- if (end > this.original.length) throw new Error('end is out of bounds');
5114
- if (start === end)
5115
- throw new Error(
5116
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
5117
- );
5118
-
5070
+ if (end > this.original.length) throw new Error("end is out of bounds");
5071
+ if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
5119
5072
  this._split(start);
5120
5073
  this._split(end);
5121
-
5122
5074
  if (options === true) {
5123
5075
  if (!warned.storeName) {
5124
- console.warn(
5125
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
5126
- );
5076
+ console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
5127
5077
  warned.storeName = true;
5128
5078
  }
5129
-
5130
5079
  options = { storeName: true };
5131
5080
  }
5132
- const storeName = options !== undefined ? options.storeName : false;
5133
- const overwrite = options !== undefined ? options.overwrite : false;
5134
-
5081
+ const optionObject = typeof options === "object" && options ? options : {};
5082
+ const storeName = optionObject.storeName || false;
5083
+ const overwrite = optionObject.overwrite || false;
5135
5084
  if (storeName) {
5136
5085
  const original = this.original.slice(start, end);
5137
5086
  Object.defineProperty(this.storedNames, original, {
5138
5087
  writable: true,
5139
5088
  value: true,
5140
- enumerable: true,
5089
+ enumerable: true
5141
5090
  });
5142
5091
  }
5143
-
5144
- const first = this.byStart[start];
5145
- const last = this.byEnd[end];
5146
-
5092
+ const first = this.byStart.get(start);
5093
+ const last = this.byEnd.get(end);
5147
5094
  if (first) {
5148
5095
  let chunk = first;
5149
5096
  while (chunk !== last) {
5150
- if (chunk.next !== this.byStart[chunk.end]) {
5151
- throw new Error('Cannot overwrite across a split point');
5152
- }
5097
+ if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
5153
5098
  chunk = chunk.next;
5154
- chunk.edit('', false);
5099
+ chunk.edit("", false);
5155
5100
  }
5156
-
5157
5101
  first.edit(content, storeName, !overwrite);
5158
5102
  } else {
5159
- // must be inserting at the end
5160
- const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
5161
-
5162
- // TODO last chunk in the array may not be the last chunk, if it's moved...
5103
+ const newChunk = new Chunk$1(start, end, "").edit(content, storeName);
5163
5104
  last.next = newChunk;
5164
5105
  newChunk.previous = last;
5165
5106
  }
5166
5107
  return this;
5167
5108
  }
5168
-
5109
+ /**
5110
+ * Prepends the string with the specified content.
5111
+ */
5169
5112
  prepend(content) {
5170
- if (typeof content !== 'string') throw new TypeError('outro content must be a string');
5171
-
5113
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
5172
5114
  this.intro = content + this.intro;
5173
5115
  return this;
5174
5116
  }
5175
-
5117
+ /**
5118
+ * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
5119
+ */
5176
5120
  prependLeft(index, content) {
5177
5121
  index = index + this.offset;
5178
-
5179
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
5180
-
5122
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
5181
5123
  this._split(index);
5182
-
5183
- const chunk = this.byEnd[index];
5184
-
5185
- if (chunk) {
5186
- chunk.prependLeft(content);
5187
- } else {
5188
- this.intro = content + this.intro;
5189
- }
5124
+ const chunk = this.byEnd.get(index);
5125
+ if (chunk) chunk.prependLeft(content);
5126
+ else this.intro = content + this.intro;
5190
5127
  return this;
5191
5128
  }
5192
-
5129
+ /**
5130
+ * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
5131
+ */
5193
5132
  prependRight(index, content) {
5194
5133
  index = index + this.offset;
5195
-
5196
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
5197
-
5134
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
5198
5135
  this._split(index);
5199
-
5200
- const chunk = this.byStart[index];
5201
-
5202
- if (chunk) {
5203
- chunk.prependRight(content);
5204
- } else {
5205
- this.outro = content + this.outro;
5206
- }
5136
+ const chunk = this.byStart.get(index);
5137
+ if (chunk) chunk.prependRight(content);
5138
+ else this.outro = content + this.outro;
5207
5139
  return this;
5208
5140
  }
5209
-
5141
+ /**
5142
+ * Removes the characters from `start` to `end` (of the original string, **not** the generated string).
5143
+ * Removing the same content twice, or making removals that partially overlap, will cause an error.
5144
+ */
5210
5145
  remove(start, end) {
5211
5146
  start = start + this.offset;
5212
5147
  end = end + this.offset;
5213
-
5214
5148
  if (this.original.length !== 0) {
5215
5149
  while (start < 0) start += this.original.length;
5216
5150
  while (end < 0) end += this.original.length;
5217
5151
  }
5218
-
5219
5152
  if (start === end) return this;
5220
-
5221
- if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
5222
- if (start > end) throw new Error('end must be greater than start');
5223
-
5153
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
5154
+ if (start > end) throw new Error("end must be greater than start");
5224
5155
  this._split(start);
5225
5156
  this._split(end);
5226
-
5227
- let chunk = this.byStart[start];
5228
-
5157
+ let chunk = this.byStart.get(start);
5229
5158
  while (chunk) {
5230
- chunk.intro = '';
5231
- chunk.outro = '';
5232
- chunk.edit('');
5233
-
5234
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
5159
+ chunk.intro = "";
5160
+ chunk.outro = "";
5161
+ chunk.edit("");
5162
+ chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
5235
5163
  }
5236
5164
  return this;
5237
5165
  }
5238
-
5166
+ /**
5167
+ * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
5168
+ */
5239
5169
  reset(start, end) {
5240
5170
  start = start + this.offset;
5241
5171
  end = end + this.offset;
5242
-
5243
5172
  if (this.original.length !== 0) {
5244
5173
  while (start < 0) start += this.original.length;
5245
5174
  while (end < 0) end += this.original.length;
5246
5175
  }
5247
-
5248
5176
  if (start === end) return this;
5249
-
5250
- if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
5251
- if (start > end) throw new Error('end must be greater than start');
5252
-
5177
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
5178
+ if (start > end) throw new Error("end must be greater than start");
5253
5179
  this._split(start);
5254
5180
  this._split(end);
5255
-
5256
- let chunk = this.byStart[start];
5257
-
5181
+ let chunk = this.byStart.get(start);
5258
5182
  while (chunk) {
5259
5183
  chunk.reset();
5260
-
5261
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
5184
+ chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
5262
5185
  }
5263
5186
  return this;
5264
5187
  }
5265
-
5266
5188
  lastChar() {
5267
5189
  if (this.outro.length) return this.outro[this.outro.length - 1];
5268
5190
  let chunk = this.lastChunk;
5269
- do {
5191
+ while (chunk) {
5270
5192
  if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
5271
5193
  if (chunk.content.length) return chunk.content[chunk.content.length - 1];
5272
5194
  if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
5273
- } while ((chunk = chunk.previous));
5195
+ chunk = chunk.previous;
5196
+ }
5274
5197
  if (this.intro.length) return this.intro[this.intro.length - 1];
5275
- return '';
5198
+ return "";
5276
5199
  }
5277
-
5278
5200
  lastLine() {
5279
5201
  let lineIndex = this.outro.lastIndexOf(n);
5280
5202
  if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
5281
5203
  let lineStr = this.outro;
5282
5204
  let chunk = this.lastChunk;
5283
- do {
5205
+ while (chunk) {
5284
5206
  if (chunk.outro.length > 0) {
5285
5207
  lineIndex = chunk.outro.lastIndexOf(n);
5286
5208
  if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
5287
5209
  lineStr = chunk.outro + lineStr;
5288
5210
  }
5289
-
5290
5211
  if (chunk.content.length > 0) {
5291
5212
  lineIndex = chunk.content.lastIndexOf(n);
5292
5213
  if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
5293
5214
  lineStr = chunk.content + lineStr;
5294
5215
  }
5295
-
5296
5216
  if (chunk.intro.length > 0) {
5297
5217
  lineIndex = chunk.intro.lastIndexOf(n);
5298
5218
  if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
5299
5219
  lineStr = chunk.intro + lineStr;
5300
5220
  }
5301
- } while ((chunk = chunk.previous));
5221
+ chunk = chunk.previous;
5222
+ }
5302
5223
  lineIndex = this.intro.lastIndexOf(n);
5303
5224
  if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
5304
5225
  return this.intro + lineStr;
5305
5226
  }
5306
-
5227
+ /**
5228
+ * Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
5229
+ * Throws error if the indices are for characters that were already removed.
5230
+ */
5307
5231
  slice(start = 0, end = this.original.length - this.offset) {
5308
5232
  start = start + this.offset;
5309
5233
  end = end + this.offset;
5310
-
5311
5234
  if (this.original.length !== 0) {
5312
5235
  while (start < 0) start += this.original.length;
5313
5236
  while (end < 0) end += this.original.length;
5314
5237
  }
5315
-
5316
- let result = '';
5317
-
5318
- // find start chunk
5238
+ let result = "";
5319
5239
  let chunk = this.firstChunk;
5320
5240
  while (chunk && (chunk.start > start || chunk.end <= start)) {
5321
- // found end chunk before start
5322
- if (chunk.start < end && chunk.end >= end) {
5323
- return result;
5324
- }
5325
-
5241
+ if (chunk.start < end && chunk.end >= end) return result;
5326
5242
  chunk = chunk.next;
5327
5243
  }
5328
-
5329
- if (chunk && chunk.edited && chunk.start !== start)
5330
- throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
5331
-
5244
+ if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
5332
5245
  const startChunk = chunk;
5333
5246
  while (chunk) {
5334
- if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
5335
- result += chunk.intro;
5336
- }
5337
-
5247
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
5338
5248
  const containsEnd = chunk.start < end && chunk.end >= end;
5339
- if (containsEnd && chunk.edited && chunk.end !== end)
5340
- throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
5341
-
5249
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
5342
5250
  const sliceStart = startChunk === chunk ? start - chunk.start : 0;
5343
5251
  const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
5344
-
5345
5252
  result += chunk.content.slice(sliceStart, sliceEnd);
5346
-
5347
- if (chunk.outro && (!containsEnd || chunk.end === end)) {
5348
- result += chunk.outro;
5349
- }
5350
-
5351
- if (containsEnd) {
5352
- break;
5353
- }
5354
-
5253
+ if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
5254
+ if (containsEnd) break;
5355
5255
  chunk = chunk.next;
5356
5256
  }
5357
-
5358
5257
  return result;
5359
5258
  }
5360
-
5361
- // TODO deprecate this? not really very useful
5259
+ /**
5260
+ * Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
5261
+ */
5362
5262
  snip(start, end) {
5363
5263
  const clone = this.clone();
5364
5264
  clone.remove(0, start);
5365
5265
  clone.remove(end, clone.original.length);
5366
-
5367
5266
  return clone;
5368
5267
  }
5369
-
5268
+ /** @internal */
5370
5269
  _split(index) {
5371
- if (this.byStart[index] || this.byEnd[index]) return;
5372
-
5270
+ if (this.byStart.get(index) || this.byEnd.get(index)) return;
5373
5271
  let chunk = this.lastSearchedChunk;
5374
5272
  let previousChunk = chunk;
5375
5273
  const searchForward = index > chunk.end;
5376
-
5377
5274
  while (chunk) {
5378
5275
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
5379
-
5380
- chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
5381
-
5382
- // Prevent infinite loop (e.g. via empty chunks, where start === end)
5276
+ chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
5383
5277
  if (chunk === previousChunk) return;
5384
-
5385
5278
  previousChunk = chunk;
5386
5279
  }
5387
5280
  }
5388
-
5281
+ /** @internal */
5389
5282
  _splitChunk(chunk, index) {
5390
5283
  if (chunk.edited && chunk.content.length) {
5391
- // zero-length edited chunks are a special case (overlapping replacements)
5392
5284
  const loc = getLocator(this.original)(index);
5393
- throw new Error(
5394
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
5395
- );
5285
+ throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
5396
5286
  }
5397
-
5398
5287
  const newChunk = chunk.split(index);
5399
-
5400
- this.byEnd[index] = chunk;
5401
- this.byStart[index] = newChunk;
5402
- this.byEnd[newChunk.end] = newChunk;
5403
-
5288
+ this.byEnd.set(index, chunk);
5289
+ this.byStart.set(index, newChunk);
5290
+ this.byEnd.set(newChunk.end, newChunk);
5404
5291
  if (chunk === this.lastChunk) this.lastChunk = newChunk;
5405
-
5406
5292
  this.lastSearchedChunk = chunk;
5407
5293
  return true;
5408
5294
  }
5409
-
5295
+ /**
5296
+ * Returns the generated string.
5297
+ */
5410
5298
  toString() {
5411
5299
  let str = this.intro;
5412
-
5413
5300
  let chunk = this.firstChunk;
5414
5301
  while (chunk) {
5415
5302
  str += chunk.toString();
5416
5303
  chunk = chunk.next;
5417
5304
  }
5418
-
5419
5305
  return str + this.outro;
5420
5306
  }
5421
-
5307
+ /**
5308
+ * Returns true if the resulting source is empty (disregarding white space).
5309
+ */
5422
5310
  isEmpty() {
5423
5311
  let chunk = this.firstChunk;
5424
- do {
5425
- if (
5426
- (chunk.intro.length && chunk.intro.trim()) ||
5427
- (chunk.content.length && chunk.content.trim()) ||
5428
- (chunk.outro.length && chunk.outro.trim())
5429
- )
5430
- return false;
5431
- } while ((chunk = chunk.next));
5312
+ while (chunk) {
5313
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
5314
+ chunk = chunk.next;
5315
+ }
5432
5316
  return true;
5433
5317
  }
5434
-
5435
5318
  length() {
5436
5319
  let chunk = this.firstChunk;
5437
5320
  let length = 0;
5438
- do {
5321
+ while (chunk) {
5439
5322
  length += chunk.intro.length + chunk.content.length + chunk.outro.length;
5440
- } while ((chunk = chunk.next));
5323
+ chunk = chunk.next;
5324
+ }
5441
5325
  return length;
5442
5326
  }
5443
-
5327
+ /**
5328
+ * Removes empty lines from the start and end.
5329
+ */
5444
5330
  trimLines() {
5445
- return this.trim('[\\r\\n]');
5331
+ return this.trim("[\\r\\n]");
5446
5332
  }
5447
-
5333
+ /**
5334
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
5335
+ */
5448
5336
  trim(charType) {
5449
5337
  return this.trimStart(charType).trimEnd(charType);
5450
5338
  }
5451
-
5339
+ /** @internal */
5452
5340
  trimEndAborted(charType) {
5453
- const rx = new RegExp((charType || '\\s') + '+$');
5454
-
5455
- this.outro = this.outro.replace(rx, '');
5341
+ const rx = new RegExp(`${charType || "\\s"}+$`);
5342
+ this.outro = this.outro.replace(rx, "");
5456
5343
  if (this.outro.length) return true;
5457
-
5458
5344
  let chunk = this.lastChunk;
5459
-
5460
5345
  do {
5461
5346
  const end = chunk.end;
5462
5347
  const aborted = chunk.trimEnd(rx);
5463
-
5464
- // if chunk was trimmed, we have a new lastChunk
5465
5348
  if (chunk.end !== end) {
5466
- if (this.lastChunk === chunk) {
5467
- this.lastChunk = chunk.next;
5468
- }
5469
-
5470
- this.byEnd[chunk.end] = chunk;
5471
- this.byStart[chunk.next.start] = chunk.next;
5472
- this.byEnd[chunk.next.end] = chunk.next;
5349
+ if (this.lastChunk === chunk) this.lastChunk = chunk.next;
5350
+ this.byEnd.set(chunk.end, chunk);
5351
+ this.byStart.set(chunk.next.start, chunk.next);
5352
+ this.byEnd.set(chunk.next.end, chunk.next);
5473
5353
  }
5474
-
5475
5354
  if (aborted) return true;
5476
5355
  chunk = chunk.previous;
5477
5356
  } while (chunk);
5478
-
5479
5357
  return false;
5480
5358
  }
5481
-
5359
+ /**
5360
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
5361
+ */
5482
5362
  trimEnd(charType) {
5483
5363
  this.trimEndAborted(charType);
5484
5364
  return this;
5485
5365
  }
5366
+ /** @internal */
5486
5367
  trimStartAborted(charType) {
5487
- const rx = new RegExp('^' + (charType || '\\s') + '+');
5488
-
5489
- this.intro = this.intro.replace(rx, '');
5368
+ const rx = new RegExp(`^${charType || "\\s"}+`);
5369
+ this.intro = this.intro.replace(rx, "");
5490
5370
  if (this.intro.length) return true;
5491
-
5492
5371
  let chunk = this.firstChunk;
5493
-
5494
5372
  do {
5495
5373
  const end = chunk.end;
5496
5374
  const aborted = chunk.trimStart(rx);
5497
-
5498
5375
  if (chunk.end !== end) {
5499
- // special case...
5500
5376
  if (chunk === this.lastChunk) this.lastChunk = chunk.next;
5501
-
5502
- this.byEnd[chunk.end] = chunk;
5503
- this.byStart[chunk.next.start] = chunk.next;
5504
- this.byEnd[chunk.next.end] = chunk.next;
5377
+ this.byEnd.set(chunk.end, chunk);
5378
+ this.byStart.set(chunk.next.start, chunk.next);
5379
+ this.byEnd.set(chunk.next.end, chunk.next);
5505
5380
  }
5506
-
5507
5381
  if (aborted) return true;
5508
5382
  chunk = chunk.next;
5509
5383
  } while (chunk);
5510
-
5511
5384
  return false;
5512
5385
  }
5513
-
5386
+ /**
5387
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
5388
+ */
5514
5389
  trimStart(charType) {
5515
5390
  this.trimStartAborted(charType);
5516
5391
  return this;
5517
5392
  }
5518
-
5393
+ /**
5394
+ * Indicates if the string has been changed.
5395
+ */
5519
5396
  hasChanged() {
5520
5397
  return this.original !== this.toString();
5521
5398
  }
5522
-
5399
+ /** @internal */
5523
5400
  _replaceRegexp(searchValue, replacement) {
5524
5401
  function getReplacement(match, str) {
5525
- if (typeof replacement === 'string') {
5526
- return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
5527
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
5528
- if (i === '$') return '$';
5529
- if (i === '&') return match[0];
5530
- const num = +i;
5531
- if (num < match.length) return match[+i];
5532
- return `$${i}`;
5533
- });
5534
- } else {
5535
- return replacement(...match, match.index, str, match.groups);
5536
- }
5402
+ if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
5403
+ if (i === "$") return "$";
5404
+ if (i === "&") return match[0];
5405
+ if (+i < match.length) return match[+i];
5406
+ return `$${i}`;
5407
+ });
5408
+ else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
5537
5409
  }
5538
5410
  function matchAll(re, str) {
5539
- let match;
5540
5411
  const matches = [];
5541
- while ((match = re.exec(str))) {
5412
+ while (true) {
5413
+ const match = re.exec(str);
5414
+ if (!match) break;
5542
5415
  matches.push(match);
5543
5416
  }
5544
5417
  return matches;
5545
5418
  }
5546
- if (searchValue.global) {
5547
- const matches = matchAll(searchValue, this.original);
5548
- matches.forEach((match) => {
5549
- if (match.index != null) {
5550
- const replacement = getReplacement(match, this.original);
5551
- if (replacement !== match[0]) {
5552
- this.overwrite(match.index, match.index + match[0].length, replacement);
5553
- }
5554
- }
5555
- });
5556
- } else {
5419
+ if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
5420
+ if (match.index != null) {
5421
+ const replacement = getReplacement(match, this.original);
5422
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
5423
+ }
5424
+ });
5425
+ else {
5557
5426
  const match = this.original.match(searchValue);
5558
5427
  if (match && match.index != null) {
5559
5428
  const replacement = getReplacement(match, this.original);
5560
- if (replacement !== match[0]) {
5561
- this.overwrite(match.index, match.index + match[0].length, replacement);
5562
- }
5429
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
5563
5430
  }
5564
5431
  }
5565
5432
  return this;
5566
5433
  }
5567
-
5434
+ /** @internal */
5568
5435
  _replaceString(string, replacement) {
5569
5436
  const { original } = this;
5570
5437
  const index = original.indexOf(string);
5571
-
5572
5438
  if (index !== -1) {
5573
- if (typeof replacement === 'function') {
5574
- replacement = replacement(string, index, original);
5575
- }
5576
- if (string !== replacement) {
5577
- this.overwrite(index, index + string.length, replacement);
5578
- }
5439
+ if (typeof replacement === "function") replacement = replacement(string, index, original);
5440
+ if (string !== replacement) this.overwrite(index, index + string.length, replacement);
5579
5441
  }
5580
-
5581
5442
  return this;
5582
5443
  }
5583
-
5444
+ /**
5445
+ * String replacement with RegExp or string.
5446
+ */
5584
5447
  replace(searchValue, replacement) {
5585
- if (typeof searchValue === 'string') {
5586
- return this._replaceString(searchValue, replacement);
5587
- }
5588
-
5448
+ if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
5589
5449
  return this._replaceRegexp(searchValue, replacement);
5590
5450
  }
5591
-
5451
+ /** @internal */
5592
5452
  _replaceAllString(string, replacement) {
5593
5453
  const { original } = this;
5594
5454
  const stringLength = string.length;
5595
- for (
5596
- let index = original.indexOf(string);
5597
- index !== -1;
5598
- index = original.indexOf(string, index + stringLength)
5599
- ) {
5455
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
5600
5456
  const previous = original.slice(index, index + stringLength);
5601
- let _replacement = replacement;
5602
- if (typeof replacement === 'function') {
5603
- _replacement = replacement(previous, index, original);
5604
- }
5457
+ const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
5605
5458
  if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
5606
5459
  }
5607
-
5608
5460
  return this;
5609
5461
  }
5610
-
5462
+ /**
5463
+ * Same as `s.replace`, but replace all matched strings instead of just one.
5464
+ */
5611
5465
  replaceAll(searchValue, replacement) {
5612
- if (typeof searchValue === 'string') {
5613
- return this._replaceAllString(searchValue, replacement);
5614
- }
5615
-
5616
- if (!searchValue.global) {
5617
- throw new TypeError(
5618
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
5619
- );
5620
- }
5621
-
5466
+ if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
5467
+ if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
5622
5468
  return this._replaceRegexp(searchValue, replacement);
5623
5469
  }
5624
- }
5625
-
5470
+ };
5471
+ //#endregion
5472
+ //#region src/Bundle.ts
5626
5473
  const hasOwnProp = Object.prototype.hasOwnProperty;
5627
-
5628
- let Bundle$1 = class Bundle {
5474
+ var Bundle$1 = class Bundle {
5629
5475
  constructor(options = {}) {
5630
- this.intro = options.intro || '';
5631
- this.separator = options.separator !== undefined ? options.separator : '\n';
5476
+ this.intro = options.intro || "";
5477
+ this.separator = options.separator !== void 0 ? options.separator : "\n";
5632
5478
  this.sources = [];
5633
5479
  this.uniqueSources = [];
5634
5480
  this.uniqueSourceIndexByFilename = {};
5635
5481
  }
5636
-
5482
+ /**
5483
+ * Adds the specified source to the bundle, which can either be a `MagicString` object directly,
5484
+ * or an options object that holds a magic string `content` property and optionally provides
5485
+ * a `filename` for the source within the bundle, as well as an optional `ignoreList` hint
5486
+ * (which defaults to `false`). The `filename` is used when constructing the source map for the
5487
+ * bundle, to identify this `source` in the source map's `sources` field. The `ignoreList` hint
5488
+ * is used to populate the `x_google_ignoreList` extension field in the source map, which is a
5489
+ * mechanism for tools to signal to debuggers that certain sources should be ignored by default
5490
+ * (depending on user preferences).
5491
+ */
5637
5492
  addSource(source) {
5638
- if (source instanceof MagicString) {
5639
- return this.addSource({
5640
- content: source,
5641
- filename: source.filename,
5642
- separator: this.separator,
5643
- });
5644
- }
5645
-
5646
- if (!isObject(source) || !source.content) {
5647
- throw new Error(
5648
- 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
5649
- );
5650
- }
5651
-
5652
- ['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
5493
+ if (source instanceof MagicString) return this.addSource({
5494
+ content: source,
5495
+ filename: source.filename,
5496
+ separator: this.separator
5497
+ });
5498
+ if (!isObject(source) || !source.content) throw new Error("bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`");
5499
+ [
5500
+ "filename",
5501
+ "ignoreList",
5502
+ "indentExclusionRanges",
5503
+ "separator"
5504
+ ].forEach((option) => {
5653
5505
  if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
5654
5506
  });
5655
-
5656
- if (source.separator === undefined) {
5657
- // TODO there's a bunch of this sort of thing, needs cleaning up
5658
- source.separator = this.separator;
5659
- }
5660
-
5661
- if (source.filename) {
5662
- if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
5663
- this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
5664
- this.uniqueSources.push({ filename: source.filename, content: source.content.original });
5665
- } else {
5666
- const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
5667
- if (source.content.original !== uniqueSource.content) {
5668
- throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
5669
- }
5670
- }
5507
+ if (source.separator === void 0) source.separator = this.separator;
5508
+ if (source.filename) if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
5509
+ this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
5510
+ this.uniqueSources.push({
5511
+ filename: source.filename,
5512
+ content: source.content.original
5513
+ });
5514
+ } else {
5515
+ const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
5516
+ if (source.content.original !== uniqueSource.content) throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
5671
5517
  }
5672
-
5673
5518
  this.sources.push(source);
5674
5519
  return this;
5675
5520
  }
5676
-
5677
5521
  append(str, options) {
5678
5522
  this.addSource({
5679
5523
  content: new MagicString(str),
5680
- separator: (options && options.separator) || '',
5524
+ separator: options && options.separator || ""
5681
5525
  });
5682
-
5683
5526
  return this;
5684
5527
  }
5685
-
5686
5528
  clone() {
5687
5529
  const bundle = new Bundle({
5688
5530
  intro: this.intro,
5689
- separator: this.separator,
5531
+ separator: this.separator
5690
5532
  });
5691
-
5692
5533
  this.sources.forEach((source) => {
5693
5534
  bundle.addSource({
5694
5535
  filename: source.filename,
5695
5536
  content: source.content.clone(),
5696
- separator: source.separator,
5537
+ separator: source.separator
5697
5538
  });
5698
5539
  });
5699
-
5700
5540
  return bundle;
5701
5541
  }
5702
-
5703
5542
  generateDecodedMap(options = {}) {
5704
5543
  const names = [];
5705
- let x_google_ignoreList = undefined;
5544
+ let x_google_ignoreList;
5706
5545
  this.sources.forEach((source) => {
5707
5546
  Object.keys(source.content.storedNames).forEach((name) => {
5708
- if (!~names.indexOf(name)) names.push(name);
5547
+ if (!names.includes(name)) names.push(name);
5709
5548
  });
5710
5549
  });
5711
-
5712
5550
  const mappings = new Mappings(options.hires);
5713
-
5714
- if (this.intro) {
5715
- mappings.advance(this.intro);
5716
- }
5717
-
5551
+ if (this.intro) mappings.advance(this.intro);
5718
5552
  this.sources.forEach((source, i) => {
5719
- if (i > 0) {
5720
- mappings.advance(this.separator);
5721
- }
5722
-
5553
+ if (i > 0) mappings.advance(this.separator);
5723
5554
  const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
5724
5555
  const magicString = source.content;
5725
5556
  const locate = getLocator(magicString.original);
5726
-
5727
- if (magicString.intro) {
5728
- mappings.advance(magicString.intro);
5729
- }
5730
-
5557
+ if (magicString.intro) mappings.advance(magicString.intro);
5731
5558
  magicString.firstChunk.eachNext((chunk) => {
5732
5559
  const loc = locate(chunk.start);
5733
-
5734
5560
  if (chunk.intro.length) mappings.advance(chunk.intro);
5735
-
5736
- if (source.filename) {
5737
- if (chunk.edited) {
5738
- mappings.addEdit(
5739
- sourceIndex,
5740
- chunk.content,
5741
- loc,
5742
- chunk.storeName ? names.indexOf(chunk.original) : -1,
5743
- );
5744
- } else {
5745
- mappings.addUneditedChunk(
5746
- sourceIndex,
5747
- chunk,
5748
- magicString.original,
5749
- loc,
5750
- magicString.sourcemapLocations,
5751
- );
5752
- }
5753
- } else {
5754
- mappings.advance(chunk.content);
5755
- }
5756
-
5561
+ if (source.filename) if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
5562
+ else mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
5563
+ else mappings.advance(chunk.content);
5757
5564
  if (chunk.outro.length) mappings.advance(chunk.outro);
5758
5565
  });
5759
-
5760
- if (magicString.outro) {
5761
- mappings.advance(magicString.outro);
5762
- }
5763
-
5566
+ if (magicString.outro) mappings.advance(magicString.outro);
5764
5567
  if (source.ignoreList && sourceIndex !== -1) {
5765
- if (x_google_ignoreList === undefined) {
5766
- x_google_ignoreList = [];
5767
- }
5568
+ if (x_google_ignoreList === void 0) x_google_ignoreList = [];
5768
5569
  x_google_ignoreList.push(sourceIndex);
5769
5570
  }
5770
5571
  });
5771
-
5772
5572
  return {
5773
- file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
5573
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
5774
5574
  sources: this.uniqueSources.map((source) => {
5775
5575
  return options.file ? getRelativePath(options.file, source.filename) : source.filename;
5776
5576
  }),
@@ -5779,137 +5579,91 @@ let Bundle$1 = class Bundle {
5779
5579
  }),
5780
5580
  names,
5781
5581
  mappings: mappings.raw,
5782
- x_google_ignoreList,
5582
+ x_google_ignoreList
5783
5583
  };
5784
5584
  }
5785
-
5786
5585
  generateMap(options) {
5787
5586
  return new SourceMap(this.generateDecodedMap(options));
5788
5587
  }
5789
-
5790
5588
  getIndentString() {
5791
5589
  const indentStringCounts = {};
5792
-
5793
5590
  this.sources.forEach((source) => {
5794
5591
  const indentStr = source.content._getRawIndentString();
5795
-
5796
5592
  if (indentStr === null) return;
5797
-
5798
5593
  if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
5799
5594
  indentStringCounts[indentStr] += 1;
5800
5595
  });
5801
-
5802
- return (
5803
- Object.keys(indentStringCounts).sort((a, b) => {
5804
- return indentStringCounts[a] - indentStringCounts[b];
5805
- })[0] || '\t'
5806
- );
5596
+ return Object.keys(indentStringCounts).sort((a, b) => {
5597
+ return indentStringCounts[a] - indentStringCounts[b];
5598
+ })[0] || " ";
5807
5599
  }
5808
-
5809
5600
  indent(indentStr) {
5810
- if (!arguments.length) {
5811
- indentStr = this.getIndentString();
5812
- }
5813
-
5814
- if (indentStr === '') return this; // noop
5815
-
5816
- let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
5817
-
5601
+ if (!arguments.length) indentStr = this.getIndentString();
5602
+ if (indentStr === "") return this;
5603
+ let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
5818
5604
  this.sources.forEach((source, i) => {
5819
- const separator = source.separator !== undefined ? source.separator : this.separator;
5820
- const indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
5821
-
5605
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
5606
+ const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
5822
5607
  source.content.indent(indentStr, {
5823
5608
  exclude: source.indentExclusionRanges,
5824
- indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
5609
+ indentStart
5825
5610
  });
5826
-
5827
- trailingNewline = source.content.lastChar() === '\n';
5611
+ trailingNewline = source.content.lastChar() === "\n";
5612
+ });
5613
+ if (this.intro) this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
5614
+ return index > 0 ? indentStr + match : match;
5828
5615
  });
5829
-
5830
- if (this.intro) {
5831
- this.intro =
5832
- indentStr +
5833
- this.intro.replace(/^[^\n]/gm, (match, index) => {
5834
- return index > 0 ? indentStr + match : match;
5835
- });
5836
- }
5837
-
5838
5616
  return this;
5839
5617
  }
5840
-
5841
5618
  prepend(str) {
5842
5619
  this.intro = str + this.intro;
5843
5620
  return this;
5844
5621
  }
5845
-
5846
5622
  toString() {
5847
- const body = this.sources
5848
- .map((source, i) => {
5849
- const separator = source.separator !== undefined ? source.separator : this.separator;
5850
- const str = (i > 0 ? separator : '') + source.content.toString();
5851
-
5852
- return str;
5853
- })
5854
- .join('');
5855
-
5623
+ const body = this.sources.map((source, i) => {
5624
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
5625
+ return (i > 0 ? separator : "") + source.content.toString();
5626
+ }).join("");
5856
5627
  return this.intro + body;
5857
5628
  }
5858
-
5859
5629
  isEmpty() {
5860
5630
  if (this.intro.length && this.intro.trim()) return false;
5861
5631
  if (this.sources.some((source) => !source.content.isEmpty())) return false;
5862
5632
  return true;
5863
5633
  }
5864
-
5865
5634
  length() {
5866
- return this.sources.reduce(
5867
- (length, source) => length + source.content.length(),
5868
- this.intro.length,
5869
- );
5635
+ return this.sources.reduce((length, source) => length + source.content.length(), this.intro.length);
5870
5636
  }
5871
-
5872
5637
  trimLines() {
5873
- return this.trim('[\\r\\n]');
5638
+ return this.trim("[\\r\\n]");
5874
5639
  }
5875
-
5876
5640
  trim(charType) {
5877
5641
  return this.trimStart(charType).trimEnd(charType);
5878
5642
  }
5879
-
5880
5643
  trimStart(charType) {
5881
- const rx = new RegExp('^' + (charType || '\\s') + '+');
5882
- this.intro = this.intro.replace(rx, '');
5883
-
5644
+ const rx = new RegExp(`^${charType || "\\s"}+`);
5645
+ this.intro = this.intro.replace(rx, "");
5884
5646
  if (!this.intro) {
5885
5647
  let source;
5886
5648
  let i = 0;
5887
-
5888
5649
  do {
5889
5650
  source = this.sources[i++];
5890
- if (!source) {
5891
- break;
5892
- }
5651
+ if (!source) break;
5893
5652
  } while (!source.content.trimStartAborted(charType));
5894
5653
  }
5895
-
5896
5654
  return this;
5897
5655
  }
5898
-
5899
5656
  trimEnd(charType) {
5900
- const rx = new RegExp((charType || '\\s') + '+$');
5901
-
5657
+ const rx = new RegExp(`${charType || "\\s"}+$`);
5902
5658
  let source;
5903
5659
  let i = this.sources.length - 1;
5904
-
5905
5660
  do {
5906
5661
  source = this.sources[i--];
5907
5662
  if (!source) {
5908
- this.intro = this.intro.replace(rx, '');
5663
+ this.intro = this.intro.replace(rx, "");
5909
5664
  break;
5910
5665
  }
5911
5666
  } while (!source.content.trimEndAborted(charType));
5912
-
5913
5667
  return this;
5914
5668
  }
5915
5669
  };
@@ -6669,13 +6423,14 @@ const RESERVED_NAMES = new Set([
6669
6423
  ]);
6670
6424
 
6671
6425
  const illegalCharacters = /[^\w$]/g;
6426
+ const illegalCharacter = /[^\w$]/;
6672
6427
  const startsWithDigit = (value) => /\d/.test(value[0]);
6673
6428
  const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES.has(value) || value === 'arguments';
6674
6429
  function isLegal(value) {
6675
6430
  if (needsEscape(value)) {
6676
6431
  return false;
6677
6432
  }
6678
- return !illegalCharacters.test(value);
6433
+ return !illegalCharacter.test(value);
6679
6434
  }
6680
6435
  function makeLegal(value) {
6681
6436
  value = value
@@ -9449,12 +9204,12 @@ class IdentifierBase extends NodeBase {
9449
9204
  this.variable.module.hasTreeShakingPassStarted)) {
9450
9205
  return (this.isTDZAccess = false);
9451
9206
  }
9452
- let decl_id;
9207
+ let declaration_id;
9453
9208
  if (this.variable.declarations &&
9454
9209
  this.variable.declarations.length === 1 &&
9455
- (decl_id = this.variable.declarations[0]) &&
9456
- this.start < decl_id.start &&
9457
- closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
9210
+ (declaration_id = this.variable.declarations[0]) &&
9211
+ this.start < declaration_id.start &&
9212
+ closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(declaration_id)) {
9458
9213
  // a variable accessed before its declaration
9459
9214
  // in the same function or at top level of module
9460
9215
  return (this.isTDZAccess = true);
@@ -12336,13 +12091,13 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
12336
12091
  }
12337
12092
  let exportBlock = '';
12338
12093
  if (namedExportsMode) {
12339
- for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
12094
+ for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
12340
12095
  if (!reexports) {
12341
12096
  continue;
12342
12097
  }
12343
12098
  for (const specifier of reexports) {
12344
12099
  if (specifier.reexported !== '*') {
12345
- const importName = getReexportedImportName(name, specifier.imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
12100
+ const importName = getReexportedImportName(name, specifier.imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
12346
12101
  if (exportBlock)
12347
12102
  exportBlock += n;
12348
12103
  if (specifier.imported !== '*' && specifier.needsLiveBinding) {
@@ -12421,14 +12176,14 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
12421
12176
  return exports[0].local;
12422
12177
  }
12423
12178
  else {
12424
- for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: depNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
12179
+ for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
12425
12180
  if (reexports) {
12426
- return getReexportedImportName(name, reexports[0].imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
12181
+ return getReexportedImportName(name, reexports[0].imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
12427
12182
  }
12428
12183
  }
12429
12184
  }
12430
12185
  }
12431
- function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
12186
+ function getReexportedImportName(moduleVariableName, imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
12432
12187
  if (imported === 'default') {
12433
12188
  if (!isChunk) {
12434
12189
  const moduleInterop = interop(moduleId);
@@ -12439,12 +12194,14 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
12439
12194
  ? `${variableName}${getPropertyAccess('default')}`
12440
12195
  : variableName;
12441
12196
  }
12442
- return depNamedExportsMode
12197
+ return dependencyNamedExportsMode
12443
12198
  ? `${moduleVariableName}${getPropertyAccess('default')}`
12444
12199
  : moduleVariableName;
12445
12200
  }
12446
12201
  if (imported === '*') {
12447
- return (isChunk ? !depNamedExportsMode : namespaceInteropHelpersByInteropType[interop(moduleId)])
12202
+ return (isChunk
12203
+ ? !dependencyNamedExportsMode
12204
+ : namespaceInteropHelpersByInteropType[interop(moduleId)])
12448
12205
  ? namespaceVariableName
12449
12206
  : moduleVariableName;
12450
12207
  }
@@ -12669,6 +12426,7 @@ const builtinModules = [
12669
12426
  "util/types",
12670
12427
  "node:v8",
12671
12428
  "v8",
12429
+ "node:vfs",
12672
12430
  "node:vm",
12673
12431
  "vm",
12674
12432
  "node:wasi",
@@ -12958,7 +12716,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultE
12958
12716
  }
12959
12717
  warnOnBuiltins(log, dependencies);
12960
12718
  const external = trimEmptyImports(dependencies);
12961
- const deps = external.map(dep => dep.globalName || 'null');
12719
+ const deps = external.map(dependency => dependency.globalName || 'null');
12962
12720
  const parameters = external.map(m => m.name);
12963
12721
  if (hasExports && !name) {
12964
12722
  log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingNameOptionForIifeExport());
@@ -13179,21 +12937,21 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
13179
12937
  }
13180
12938
  throwOnPhase('umd', id, dependencies);
13181
12939
  warnOnBuiltins(log, dependencies);
13182
- const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
13183
- const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
12940
+ const amdDependencies = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
12941
+ const cjsDependencies = dependencies.map(m => `require('${m.importPath}')`);
13184
12942
  const trimmedImports = trimEmptyImports(dependencies);
13185
- const globalDeps = trimmedImports.map(module => globalProperty(module.globalName, globalVariable, getPropertyAccess));
12943
+ const globalDependencies = trimmedImports.map(module => globalProperty(module.globalName, globalVariable, getPropertyAccess));
13186
12944
  const factoryParameters = trimmedImports.map(m => m.name);
13187
12945
  if ((hasExports || noConflict) &&
13188
12946
  (namedExportsMode || (hasExports && exports[0]?.local === 'exports.default'))) {
13189
- amdDeps.unshift(`'exports'`);
13190
- cjsDeps.unshift(`exports`);
13191
- globalDeps.unshift(assignToDeepVariable(name, globalVariable, globals, `${extend ? `${globalProperty(name, globalVariable, getPropertyAccess)}${_}||${_}` : ''}{}`, snippets, log));
12947
+ amdDependencies.unshift(`'exports'`);
12948
+ cjsDependencies.unshift(`exports`);
12949
+ globalDependencies.unshift(assignToDeepVariable(name, globalVariable, globals, `${extend ? `${globalProperty(name, globalVariable, getPropertyAccess)}${_}||${_}` : ''}{}`, snippets, log));
13192
12950
  factoryParameters.unshift('exports');
13193
12951
  }
13194
12952
  const completeAmdId = getCompleteAmdId(amd, id);
13195
12953
  const amdParameters = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
13196
- (amdDeps.length > 0 ? `[${amdDeps.join(`,${_}`)}],${_}` : ``);
12954
+ (amdDependencies.length > 0 ? `[${amdDependencies.join(`,${_}`)}],${_}` : ``);
13197
12955
  const define = amd.define;
13198
12956
  const cjsExport = !namedExportsMode && hasExports ? `module.exports${_}=${_}` : ``;
13199
12957
  const useStrict = strict ? `${_}'use strict';${n}` : ``;
@@ -13202,13 +12960,13 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
13202
12960
  const noConflictExportsVariable = compact ? 'e' : 'exports';
13203
12961
  let factory;
13204
12962
  if (!namedExportsMode && hasExports) {
13205
- factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${globalDeps.join(`,${_}`)})`, snippets, log)};`;
12963
+ factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${globalDependencies.join(`,${_}`)})`, snippets, log)};`;
13206
12964
  }
13207
12965
  else {
13208
- const module = globalDeps.shift();
12966
+ const module = globalDependencies.shift();
13209
12967
  factory =
13210
12968
  `${cnst} ${noConflictExportsVariable}${_}=${_}${module};${n}` +
13211
- `${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...globalDeps].join(`,${_}`)});`;
12969
+ `${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...globalDependencies].join(`,${_}`)});`;
13212
12970
  }
13213
12971
  iifeExport =
13214
12972
  `(${getFunctionIntro([], { isAsync: false, name: null })}{${n}` +
@@ -13222,12 +12980,12 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
13222
12980
  `${t}})()`;
13223
12981
  }
13224
12982
  else {
13225
- iifeExport = `${factoryVariable}(${globalDeps.join(`,${_}`)})`;
12983
+ iifeExport = `${factoryVariable}(${globalDependencies.join(`,${_}`)})`;
13226
12984
  if (!namedExportsMode && hasExports) {
13227
12985
  iifeExport = assignToDeepVariable(name, globalVariable, globals, iifeExport, snippets, log);
13228
12986
  }
13229
12987
  }
13230
- const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) || globalDeps.length > 0;
12988
+ const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) || globalDependencies.length > 0;
13231
12989
  const wrapperParameters = [factoryVariable];
13232
12990
  if (iifeNeedsGlobal) {
13233
12991
  wrapperParameters.unshift(globalVariable);
@@ -13239,7 +12997,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
13239
12997
  const iifeEnd = iifeNeedsGlobal ? ')' : '';
13240
12998
  const cjsIntro = iifeNeedsGlobal
13241
12999
  ? `${t}typeof exports${_}===${_}'object'${_}&&${_}typeof module${_}!==${_}'undefined'${_}?` +
13242
- `${_}${cjsExport}${factoryVariable}(${cjsDeps.join(`,${_}`)})${_}:${n}`
13000
+ `${_}${cjsExport}${factoryVariable}(${cjsDependencies.join(`,${_}`)})${_}:${n}`
13243
13001
  : '';
13244
13002
  const wrapperIntro = `(${getNonArrowFunctionIntro(wrapperParameters, { isAsync: false, name: null })}{${n}` +
13245
13003
  cjsIntro +
@@ -15300,19 +15058,19 @@ class ImportExpression extends NodeBase {
15300
15058
  return null;
15301
15059
  const chunkInfos = [];
15302
15060
  const importerPath = ownChunk.getFileName();
15303
- for (const dep of targetChunk.dependencies) {
15304
- const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`;
15305
- if (dep instanceof ExternalChunk) {
15061
+ for (const dependency of targetChunk.dependencies) {
15062
+ const resolvedImportPath = `'${dependency.getImportPath(importerPath)}'`;
15063
+ if (dependency instanceof ExternalChunk) {
15306
15064
  chunkInfos.push({
15307
- fileName: dep.getFileName(),
15065
+ fileName: dependency.getFileName(),
15308
15066
  resolvedImportPath,
15309
15067
  type: 'external'
15310
15068
  });
15311
15069
  }
15312
15070
  else {
15313
15071
  chunkInfos.push({
15314
- chunk: dep.getPreRenderedChunkInfo(),
15315
- fileName: dep.getFileName(),
15072
+ chunk: dependency.getPreRenderedChunkInfo(),
15073
+ fileName: dependency.getFileName(),
15316
15074
  resolvedImportPath,
15317
15075
  type: 'internal'
15318
15076
  });
@@ -20489,9 +20247,9 @@ class Chunk {
20489
20247
  // for static and dynamic entry points, add transitive dependencies to this
20490
20248
  // chunk's dependencies to avoid loading latency
20491
20249
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
20492
- for (const dep of dependencies) {
20493
- if (dep instanceof Chunk)
20494
- this.inlineChunkDependencies(dep);
20250
+ for (const dependency of dependencies) {
20251
+ if (dependency instanceof Chunk)
20252
+ this.inlineChunkDependencies(dependency);
20495
20253
  }
20496
20254
  }
20497
20255
  }
@@ -20663,11 +20421,11 @@ class Chunk {
20663
20421
  if (!chunk || format !== 'es') {
20664
20422
  continue;
20665
20423
  }
20666
- const chunkDep = this.renderedDependencies.get(chunk);
20667
- if (!chunkDep) {
20424
+ const chunkDependency = this.renderedDependencies.get(chunk);
20425
+ if (!chunkDependency) {
20668
20426
  continue;
20669
20427
  }
20670
- const { imports, reexports } = chunkDep;
20428
+ const { imports, reexports } = chunkDependency;
20671
20429
  const importedByReexported = reexports?.find(({ reexported }) => reexported === exportName);
20672
20430
  const isImported = imports?.find(({ imported }) => imported === importedByReexported?.imported);
20673
20431
  if (!isImported) {
@@ -20877,6 +20635,10 @@ class Chunk {
20877
20635
  return predefinedChunkName;
20878
20636
  const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
20879
20637
  const sanitizedId = sanitizeFileName(parseAst_js.normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
20638
+ // The module id was sanitized, so the base must be sanitized as well before
20639
+ // comparing paths; otherwise ids containing sanitized characters escape the
20640
+ // base via "../" and trip the placeholder validation (#5446).
20641
+ const sanitizedBase = sanitizeFileName(this.inputBase);
20880
20642
  const extensionName = path.extname(sanitizedId);
20881
20643
  const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
20882
20644
  ? sanitizedId.slice(0, -extensionName.length)
@@ -20887,10 +20649,10 @@ class Chunk {
20887
20649
  }
20888
20650
  else {
20889
20651
  // handle edge case in Windows
20890
- if (this.inputBase === '/' && idWithoutExtension[0] !== '/') {
20891
- return parseAst_js.relative(this.inputBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/'));
20652
+ if (sanitizedBase === '/' && idWithoutExtension[0] !== '/') {
20653
+ return parseAst_js.relative(sanitizedBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/'));
20892
20654
  }
20893
- return parseAst_js.relative(this.inputBase, idWithoutExtension);
20655
+ return parseAst_js.relative(sanitizedBase, idWithoutExtension);
20894
20656
  }
20895
20657
  }
20896
20658
  else {
@@ -21005,12 +20767,12 @@ class Chunk {
21005
20767
  return (this.renderedDependencies = renderedDependencies);
21006
20768
  }
21007
20769
  inlineChunkDependencies(chunk) {
21008
- for (const dep of chunk.dependencies) {
21009
- if (this.dependencies.has(dep))
20770
+ for (const dependency of chunk.dependencies) {
20771
+ if (this.dependencies.has(dependency))
21010
20772
  continue;
21011
- this.dependencies.add(dep);
21012
- if (dep instanceof Chunk) {
21013
- this.inlineChunkDependencies(dep);
20773
+ this.dependencies.add(dependency);
20774
+ if (dependency instanceof Chunk) {
20775
+ this.inlineChunkDependencies(dependency);
21014
20776
  }
21015
20777
  }
21016
20778
  }
@@ -22464,7 +22226,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
22464
22226
  finalSourcemapFileName = sourcemapFileName
22465
22227
  ? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
22466
22228
  : `${finalFileName}.map`;
22467
- map.file = replacePlaceholders(map.file, hashesByPlaceholder);
22229
+ map.file = replacePlaceholders(map.file ?? '', hashesByPlaceholder);
22468
22230
  updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
22469
22231
  }
22470
22232
  bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
@@ -22997,7 +22759,6 @@ async function transform(source, module, pluginDriver, options) {
22997
22759
  }
22998
22760
  return new SourceMap({
22999
22761
  ...combinedMap,
23000
- file: null,
23001
22762
  sourcesContent: combinedMap.sourcesContent
23002
22763
  });
23003
22764
  },