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.
- package/dist/bin/rollup +13 -17
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +682 -921
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +4 -4
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +6 -23
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +23 -23
- package/dist/shared/rollup.js +854 -1093
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +4 -4
- package/package.json +62 -60
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.62.
|
|
4
|
-
|
|
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
|
|
|
@@ -27,8 +27,8 @@ function _mergeNamespaces(n, m) {
|
|
|
27
27
|
return Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version = "4.62.
|
|
31
|
-
const
|
|
30
|
+
var version = "4.62.4";
|
|
31
|
+
const pkg = {
|
|
32
32
|
version: version};
|
|
33
33
|
|
|
34
34
|
// src/vlq.ts
|
|
@@ -203,214 +203,158 @@ function encode(decoded) {
|
|
|
203
203
|
return writer.flush();
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
//#region src/BitSet.ts
|
|
207
|
+
var BitSet = class BitSet {
|
|
207
208
|
constructor(arg) {
|
|
208
209
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
209
210
|
}
|
|
210
|
-
|
|
211
211
|
add(n) {
|
|
212
212
|
this.bits[n >> 5] |= 1 << (n & 31);
|
|
213
213
|
}
|
|
214
|
-
|
|
215
214
|
has(n) {
|
|
216
|
-
return !!(this.bits[n >> 5] &
|
|
215
|
+
return !!(this.bits[n >> 5] & 1 << (n & 31));
|
|
217
216
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
};
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/Chunk.ts
|
|
220
|
+
var Chunk$1 = class Chunk {
|
|
221
221
|
constructor(start, end, content) {
|
|
222
222
|
this.start = start;
|
|
223
223
|
this.end = end;
|
|
224
224
|
this.original = content;
|
|
225
|
-
|
|
226
|
-
this.
|
|
227
|
-
this.outro = '';
|
|
228
|
-
|
|
225
|
+
this.intro = "";
|
|
226
|
+
this.outro = "";
|
|
229
227
|
this.content = content;
|
|
230
228
|
this.storeName = false;
|
|
231
229
|
this.edited = false;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.previous = null;
|
|
235
|
-
this.next = null;
|
|
236
|
-
}
|
|
230
|
+
this.previous = null;
|
|
231
|
+
this.next = null;
|
|
237
232
|
}
|
|
238
|
-
|
|
239
233
|
appendLeft(content) {
|
|
240
234
|
this.outro += content;
|
|
241
235
|
}
|
|
242
|
-
|
|
243
236
|
appendRight(content) {
|
|
244
237
|
this.intro = this.intro + content;
|
|
245
238
|
}
|
|
246
|
-
|
|
247
239
|
clone() {
|
|
248
240
|
const chunk = new Chunk(this.start, this.end, this.original);
|
|
249
|
-
|
|
250
241
|
chunk.intro = this.intro;
|
|
251
242
|
chunk.outro = this.outro;
|
|
252
243
|
chunk.content = this.content;
|
|
253
244
|
chunk.storeName = this.storeName;
|
|
254
245
|
chunk.edited = this.edited;
|
|
255
|
-
|
|
256
246
|
return chunk;
|
|
257
247
|
}
|
|
258
|
-
|
|
259
248
|
contains(index) {
|
|
260
249
|
return this.start < index && index < this.end;
|
|
261
250
|
}
|
|
262
|
-
|
|
263
251
|
eachNext(fn) {
|
|
264
|
-
|
|
252
|
+
fn(this);
|
|
253
|
+
let chunk = this.next;
|
|
265
254
|
while (chunk) {
|
|
266
255
|
fn(chunk);
|
|
267
256
|
chunk = chunk.next;
|
|
268
257
|
}
|
|
269
258
|
}
|
|
270
|
-
|
|
271
259
|
eachPrevious(fn) {
|
|
272
|
-
|
|
260
|
+
fn(this);
|
|
261
|
+
let chunk = this.previous;
|
|
273
262
|
while (chunk) {
|
|
274
263
|
fn(chunk);
|
|
275
264
|
chunk = chunk.previous;
|
|
276
265
|
}
|
|
277
266
|
}
|
|
278
|
-
|
|
279
267
|
edit(content, storeName, contentOnly) {
|
|
280
268
|
this.content = content;
|
|
281
269
|
if (!contentOnly) {
|
|
282
|
-
this.intro =
|
|
283
|
-
this.outro =
|
|
270
|
+
this.intro = "";
|
|
271
|
+
this.outro = "";
|
|
284
272
|
}
|
|
285
273
|
this.storeName = storeName;
|
|
286
|
-
|
|
287
274
|
this.edited = true;
|
|
288
|
-
|
|
289
275
|
return this;
|
|
290
276
|
}
|
|
291
|
-
|
|
292
277
|
prependLeft(content) {
|
|
293
278
|
this.outro = content + this.outro;
|
|
294
279
|
}
|
|
295
|
-
|
|
296
280
|
prependRight(content) {
|
|
297
281
|
this.intro = content + this.intro;
|
|
298
282
|
}
|
|
299
|
-
|
|
300
283
|
reset() {
|
|
301
|
-
this.intro =
|
|
302
|
-
this.outro =
|
|
284
|
+
this.intro = "";
|
|
285
|
+
this.outro = "";
|
|
303
286
|
if (this.edited) {
|
|
304
287
|
this.content = this.original;
|
|
305
288
|
this.storeName = false;
|
|
306
289
|
this.edited = false;
|
|
307
290
|
}
|
|
308
291
|
}
|
|
309
|
-
|
|
310
292
|
split(index) {
|
|
311
293
|
const sliceIndex = index - this.start;
|
|
312
|
-
|
|
313
294
|
const originalBefore = this.original.slice(0, sliceIndex);
|
|
314
295
|
const originalAfter = this.original.slice(sliceIndex);
|
|
315
|
-
|
|
316
296
|
this.original = originalBefore;
|
|
317
|
-
|
|
318
297
|
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
319
298
|
newChunk.outro = this.outro;
|
|
320
|
-
this.outro =
|
|
321
|
-
|
|
299
|
+
this.outro = "";
|
|
322
300
|
this.end = index;
|
|
323
|
-
|
|
324
301
|
if (this.edited) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
// ' test'.trim()
|
|
329
|
-
// split -> ' ' + 'test'
|
|
330
|
-
// ✔️ edit -> '' + 'test'
|
|
331
|
-
// ✖️ edit -> 'test' + ''
|
|
332
|
-
// TODO is this block necessary?...
|
|
333
|
-
newChunk.edit('', false);
|
|
334
|
-
this.content = '';
|
|
335
|
-
} else {
|
|
336
|
-
this.content = originalBefore;
|
|
337
|
-
}
|
|
338
|
-
|
|
302
|
+
newChunk.edit("", false);
|
|
303
|
+
this.content = "";
|
|
304
|
+
} else this.content = originalBefore;
|
|
339
305
|
newChunk.next = this.next;
|
|
340
306
|
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
341
307
|
newChunk.previous = this;
|
|
342
308
|
this.next = newChunk;
|
|
343
|
-
|
|
344
309
|
return newChunk;
|
|
345
310
|
}
|
|
346
|
-
|
|
347
311
|
toString() {
|
|
348
312
|
return this.intro + this.content + this.outro;
|
|
349
313
|
}
|
|
350
|
-
|
|
351
314
|
trimEnd(rx) {
|
|
352
|
-
this.outro = this.outro.replace(rx,
|
|
315
|
+
this.outro = this.outro.replace(rx, "");
|
|
353
316
|
if (this.outro.length) return true;
|
|
354
|
-
|
|
355
|
-
const trimmed = this.content.replace(rx, '');
|
|
356
|
-
|
|
317
|
+
const trimmed = this.content.replace(rx, "");
|
|
357
318
|
if (trimmed.length) {
|
|
358
|
-
if (trimmed !== this.content)
|
|
359
|
-
|
|
360
|
-
if (this.edited) {
|
|
361
|
-
// save the change, if it has been edited
|
|
362
|
-
this.edit(trimmed, this.storeName, true);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
319
|
+
if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
320
|
+
else this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
365
321
|
return true;
|
|
366
322
|
} else {
|
|
367
|
-
this.edit(
|
|
368
|
-
|
|
369
|
-
this.intro = this.intro.replace(rx, '');
|
|
323
|
+
this.edit("", void 0, true);
|
|
324
|
+
this.intro = this.intro.replace(rx, "");
|
|
370
325
|
if (this.intro.length) return true;
|
|
371
326
|
}
|
|
372
327
|
}
|
|
373
|
-
|
|
374
328
|
trimStart(rx) {
|
|
375
|
-
this.intro = this.intro.replace(rx,
|
|
329
|
+
this.intro = this.intro.replace(rx, "");
|
|
376
330
|
if (this.intro.length) return true;
|
|
377
|
-
|
|
378
|
-
const trimmed = this.content.replace(rx, '');
|
|
379
|
-
|
|
331
|
+
const trimmed = this.content.replace(rx, "");
|
|
380
332
|
if (trimmed.length) {
|
|
381
|
-
if (trimmed !== this.content)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
newChunk.edit(trimmed, this.storeName, true);
|
|
386
|
-
}
|
|
387
|
-
this.edit('', undefined, true);
|
|
333
|
+
if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
334
|
+
else {
|
|
335
|
+
this.split(this.end - trimmed.length);
|
|
336
|
+
this.edit("", void 0, true);
|
|
388
337
|
}
|
|
389
338
|
return true;
|
|
390
339
|
} else {
|
|
391
|
-
this.edit(
|
|
392
|
-
|
|
393
|
-
this.outro = this.outro.replace(rx, '');
|
|
340
|
+
this.edit("", void 0, true);
|
|
341
|
+
this.outro = this.outro.replace(rx, "");
|
|
394
342
|
if (this.outro.length) return true;
|
|
395
343
|
}
|
|
396
344
|
}
|
|
397
345
|
};
|
|
398
|
-
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/SourceMap.ts
|
|
399
348
|
function getBtoa() {
|
|
400
|
-
if (typeof globalThis !==
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
407
|
-
};
|
|
408
|
-
}
|
|
349
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
350
|
+
const buffer = globalThis["Buffer"];
|
|
351
|
+
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
352
|
+
return () => {
|
|
353
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
354
|
+
};
|
|
409
355
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
class SourceMap {
|
|
356
|
+
const btoa = /* #__PURE__ */ getBtoa();
|
|
357
|
+
var SourceMap = class {
|
|
414
358
|
constructor(properties) {
|
|
415
359
|
this.version = 3;
|
|
416
360
|
this.file = properties.file;
|
|
@@ -418,103 +362,87 @@ class SourceMap {
|
|
|
418
362
|
this.sourcesContent = properties.sourcesContent;
|
|
419
363
|
this.names = properties.names;
|
|
420
364
|
this.mappings = encode(properties.mappings);
|
|
421
|
-
if (typeof properties.x_google_ignoreList !==
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
if (typeof properties.debugId !== 'undefined') {
|
|
425
|
-
this.debugId = properties.debugId;
|
|
426
|
-
}
|
|
365
|
+
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
366
|
+
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
427
367
|
}
|
|
428
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Returns the equivalent of `JSON.stringify(map)`
|
|
370
|
+
*/
|
|
429
371
|
toString() {
|
|
430
372
|
return JSON.stringify(this);
|
|
431
373
|
}
|
|
432
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
|
376
|
+
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
|
377
|
+
*/
|
|
433
378
|
toUrl() {
|
|
434
|
-
return
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
function guessIndent(code) {
|
|
439
|
-
const lines = code.split('\n');
|
|
440
|
-
|
|
441
|
-
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
442
|
-
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
443
|
-
|
|
444
|
-
if (tabbed.length === 0 && spaced.length === 0) {
|
|
445
|
-
return null;
|
|
379
|
+
return `data:application/json;charset=utf-8;base64,${btoa(this.toString())}`;
|
|
446
380
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
381
|
+
};
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/utils/getLocator.ts
|
|
384
|
+
function getLocator(source) {
|
|
385
|
+
const originalLines = source.split("\n");
|
|
386
|
+
const lineOffsets = [];
|
|
387
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
388
|
+
lineOffsets.push(pos);
|
|
389
|
+
pos += originalLines[i].length + 1;
|
|
453
390
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
391
|
+
return function locate(index) {
|
|
392
|
+
let i = 0;
|
|
393
|
+
let j = lineOffsets.length;
|
|
394
|
+
while (i < j) {
|
|
395
|
+
const m = i + j >> 1;
|
|
396
|
+
if (index < lineOffsets[m]) j = m;
|
|
397
|
+
else i = m + 1;
|
|
398
|
+
}
|
|
399
|
+
const line = i - 1;
|
|
400
|
+
return {
|
|
401
|
+
line,
|
|
402
|
+
column: index - lineOffsets[line]
|
|
403
|
+
};
|
|
404
|
+
};
|
|
462
405
|
}
|
|
463
|
-
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/utils/getRelativePath.ts
|
|
464
408
|
function getRelativePath(from, to) {
|
|
465
409
|
const fromParts = from.split(/[/\\]/);
|
|
466
410
|
const toParts = to.split(/[/\\]/);
|
|
467
|
-
|
|
468
|
-
fromParts.pop(); // get dirname
|
|
469
|
-
|
|
411
|
+
fromParts.pop();
|
|
470
412
|
while (fromParts[0] === toParts[0]) {
|
|
471
413
|
fromParts.shift();
|
|
472
414
|
toParts.shift();
|
|
473
415
|
}
|
|
474
|
-
|
|
475
416
|
if (fromParts.length) {
|
|
476
417
|
let i = fromParts.length;
|
|
477
|
-
while (i--) fromParts[i] =
|
|
418
|
+
while (i--) fromParts[i] = "..";
|
|
478
419
|
}
|
|
479
|
-
|
|
480
|
-
return fromParts.concat(toParts).join('/');
|
|
420
|
+
return fromParts.concat(toParts).join("/");
|
|
481
421
|
}
|
|
482
|
-
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/utils/guessIndent.ts
|
|
424
|
+
function guessIndent(code) {
|
|
425
|
+
const lines = code.split("\n");
|
|
426
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
427
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
428
|
+
if (tabbed.length === 0 && spaced.length === 0) return null;
|
|
429
|
+
if (tabbed.length >= spaced.length) return " ";
|
|
430
|
+
const min = spaced.reduce((previous, current) => {
|
|
431
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
432
|
+
return Math.min(numSpaces, previous);
|
|
433
|
+
}, Infinity);
|
|
434
|
+
return " ".repeat(min);
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/utils/isObject.ts
|
|
483
438
|
const toString = Object.prototype.toString;
|
|
484
|
-
|
|
485
439
|
function isObject(thing) {
|
|
486
|
-
return toString.call(thing) ===
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function getLocator(source) {
|
|
490
|
-
const originalLines = source.split('\n');
|
|
491
|
-
const lineOffsets = [];
|
|
492
|
-
|
|
493
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
494
|
-
lineOffsets.push(pos);
|
|
495
|
-
pos += originalLines[i].length + 1;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
return function locate(index) {
|
|
499
|
-
let i = 0;
|
|
500
|
-
let j = lineOffsets.length;
|
|
501
|
-
while (i < j) {
|
|
502
|
-
const m = (i + j) >> 1;
|
|
503
|
-
if (index < lineOffsets[m]) {
|
|
504
|
-
j = m;
|
|
505
|
-
} else {
|
|
506
|
-
i = m + 1;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
const line = i - 1;
|
|
510
|
-
const column = index - lineOffsets[line];
|
|
511
|
-
return { line, column };
|
|
512
|
-
};
|
|
440
|
+
return toString.call(thing) === "[object Object]";
|
|
513
441
|
}
|
|
514
|
-
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/utils/Mappings.ts
|
|
515
444
|
const wordRegex = /\w/;
|
|
516
|
-
|
|
517
|
-
class Mappings {
|
|
445
|
+
var Mappings = class {
|
|
518
446
|
constructor(hires) {
|
|
519
447
|
this.hires = hires;
|
|
520
448
|
this.generatedCodeLine = 0;
|
|
@@ -523,52 +451,47 @@ class Mappings {
|
|
|
523
451
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
524
452
|
this.pending = null;
|
|
525
453
|
}
|
|
526
|
-
|
|
527
454
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
528
455
|
if (content.length) {
|
|
529
456
|
const contentLengthMinusOne = content.length - 1;
|
|
530
|
-
let contentLineEnd = content.indexOf(
|
|
457
|
+
let contentLineEnd = content.indexOf("\n", 0);
|
|
531
458
|
let previousContentLineEnd = -1;
|
|
532
|
-
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
533
|
-
// else code afterwards would fill one line too many
|
|
534
459
|
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
535
|
-
const segment = [
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
460
|
+
const segment = [
|
|
461
|
+
this.generatedCodeColumn,
|
|
462
|
+
sourceIndex,
|
|
463
|
+
loc.line,
|
|
464
|
+
loc.column
|
|
465
|
+
];
|
|
466
|
+
if (nameIndex >= 0) segment.push(nameIndex);
|
|
539
467
|
this.rawSegments.push(segment);
|
|
540
|
-
|
|
541
468
|
this.generatedCodeLine += 1;
|
|
542
469
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
543
470
|
this.generatedCodeColumn = 0;
|
|
544
|
-
|
|
545
471
|
previousContentLineEnd = contentLineEnd;
|
|
546
|
-
contentLineEnd = content.indexOf(
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
550
|
-
if (nameIndex >= 0) {
|
|
551
|
-
segment.push(nameIndex);
|
|
472
|
+
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
552
473
|
}
|
|
474
|
+
const segment = [
|
|
475
|
+
this.generatedCodeColumn,
|
|
476
|
+
sourceIndex,
|
|
477
|
+
loc.line,
|
|
478
|
+
loc.column
|
|
479
|
+
];
|
|
480
|
+
if (nameIndex >= 0) segment.push(nameIndex);
|
|
553
481
|
this.rawSegments.push(segment);
|
|
554
|
-
|
|
555
482
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
556
483
|
} else if (this.pending) {
|
|
557
484
|
this.rawSegments.push(this.pending);
|
|
558
485
|
this.advance(content);
|
|
559
486
|
}
|
|
560
|
-
|
|
561
487
|
this.pending = null;
|
|
562
488
|
}
|
|
563
|
-
|
|
564
489
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
565
490
|
let originalCharIndex = chunk.start;
|
|
566
491
|
let first = true;
|
|
567
|
-
// when iterating each char, check if it's in a word boundary
|
|
568
492
|
let charInHiresBoundary = false;
|
|
569
|
-
|
|
570
493
|
while (originalCharIndex < chunk.end) {
|
|
571
|
-
if (original[originalCharIndex] ===
|
|
494
|
+
if (original[originalCharIndex] === "\n") {
|
|
572
495
|
loc.line += 1;
|
|
573
496
|
loc.column = 0;
|
|
574
497
|
this.generatedCodeLine += 1;
|
|
@@ -578,42 +501,34 @@ class Mappings {
|
|
|
578
501
|
charInHiresBoundary = false;
|
|
579
502
|
} else {
|
|
580
503
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
581
|
-
const segment = [
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
charInHiresBoundary = true;
|
|
590
|
-
}
|
|
591
|
-
} else {
|
|
592
|
-
// for non-word char, end the boundary by pushing a segment
|
|
504
|
+
const segment = [
|
|
505
|
+
this.generatedCodeColumn,
|
|
506
|
+
sourceIndex,
|
|
507
|
+
loc.line,
|
|
508
|
+
loc.column
|
|
509
|
+
];
|
|
510
|
+
if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
|
|
511
|
+
if (!charInHiresBoundary) {
|
|
593
512
|
this.rawSegments.push(segment);
|
|
594
|
-
charInHiresBoundary =
|
|
513
|
+
charInHiresBoundary = true;
|
|
595
514
|
}
|
|
596
515
|
} else {
|
|
597
516
|
this.rawSegments.push(segment);
|
|
517
|
+
charInHiresBoundary = false;
|
|
598
518
|
}
|
|
519
|
+
else this.rawSegments.push(segment);
|
|
599
520
|
}
|
|
600
|
-
|
|
601
521
|
loc.column += 1;
|
|
602
522
|
this.generatedCodeColumn += 1;
|
|
603
523
|
first = false;
|
|
604
524
|
}
|
|
605
|
-
|
|
606
525
|
originalCharIndex += 1;
|
|
607
526
|
}
|
|
608
|
-
|
|
609
527
|
this.pending = null;
|
|
610
528
|
}
|
|
611
|
-
|
|
612
529
|
advance(str) {
|
|
613
530
|
if (!str) return;
|
|
614
|
-
|
|
615
|
-
const lines = str.split('\n');
|
|
616
|
-
|
|
531
|
+
const lines = str.split("\n");
|
|
617
532
|
if (lines.length > 1) {
|
|
618
533
|
for (let i = 0; i < lines.length - 1; i++) {
|
|
619
534
|
this.generatedCodeLine++;
|
|
@@ -621,1029 +536,872 @@ class Mappings {
|
|
|
621
536
|
}
|
|
622
537
|
this.generatedCodeColumn = 0;
|
|
623
538
|
}
|
|
624
|
-
|
|
625
539
|
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
626
540
|
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
541
|
+
};
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/MagicString.ts
|
|
544
|
+
const n = "\n";
|
|
545
|
+
const NEWLINE_CHAR = "\n".charCodeAt(0);
|
|
546
|
+
const CR_CHAR = "\r".charCodeAt(0);
|
|
631
547
|
const warned = {
|
|
632
548
|
insertLeft: false,
|
|
633
549
|
insertRight: false,
|
|
634
|
-
storeName: false
|
|
550
|
+
storeName: false
|
|
635
551
|
};
|
|
636
|
-
|
|
637
|
-
class MagicString {
|
|
552
|
+
var MagicString = class MagicString {
|
|
638
553
|
constructor(string, options = {}) {
|
|
639
554
|
const chunk = new Chunk$1(0, string.length, string);
|
|
640
|
-
|
|
641
555
|
Object.defineProperties(this, {
|
|
642
|
-
original: {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
556
|
+
original: {
|
|
557
|
+
writable: true,
|
|
558
|
+
value: string
|
|
559
|
+
},
|
|
560
|
+
outro: {
|
|
561
|
+
writable: true,
|
|
562
|
+
value: ""
|
|
563
|
+
},
|
|
564
|
+
intro: {
|
|
565
|
+
writable: true,
|
|
566
|
+
value: ""
|
|
567
|
+
},
|
|
568
|
+
firstChunk: {
|
|
569
|
+
writable: true,
|
|
570
|
+
value: chunk
|
|
571
|
+
},
|
|
572
|
+
lastChunk: {
|
|
573
|
+
writable: true,
|
|
574
|
+
value: chunk
|
|
575
|
+
},
|
|
576
|
+
lastSearchedChunk: {
|
|
577
|
+
writable: true,
|
|
578
|
+
value: chunk
|
|
579
|
+
},
|
|
580
|
+
byStart: {
|
|
581
|
+
writable: true,
|
|
582
|
+
value: {}
|
|
583
|
+
},
|
|
584
|
+
byEnd: {
|
|
585
|
+
writable: true,
|
|
586
|
+
value: {}
|
|
587
|
+
},
|
|
588
|
+
filename: {
|
|
589
|
+
writable: true,
|
|
590
|
+
value: options.filename
|
|
591
|
+
},
|
|
592
|
+
indentExclusionRanges: {
|
|
593
|
+
writable: true,
|
|
594
|
+
value: options.indentExclusionRanges
|
|
595
|
+
},
|
|
596
|
+
sourcemapLocations: {
|
|
597
|
+
writable: true,
|
|
598
|
+
value: new BitSet()
|
|
599
|
+
},
|
|
600
|
+
storedNames: {
|
|
601
|
+
writable: true,
|
|
602
|
+
value: {}
|
|
603
|
+
},
|
|
604
|
+
indentStr: {
|
|
605
|
+
writable: true,
|
|
606
|
+
value: void 0
|
|
607
|
+
},
|
|
608
|
+
ignoreList: {
|
|
609
|
+
writable: true,
|
|
610
|
+
value: options.ignoreList
|
|
611
|
+
},
|
|
612
|
+
offset: {
|
|
613
|
+
writable: true,
|
|
614
|
+
value: options.offset || 0
|
|
615
|
+
}
|
|
657
616
|
});
|
|
658
|
-
|
|
659
|
-
this.
|
|
660
|
-
this.byEnd[string.length] = chunk;
|
|
617
|
+
this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
|
|
618
|
+
this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
|
|
661
619
|
}
|
|
662
|
-
|
|
620
|
+
/**
|
|
621
|
+
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
622
|
+
*/
|
|
663
623
|
addSourcemapLocation(char) {
|
|
664
624
|
this.sourcemapLocations.add(char);
|
|
665
625
|
}
|
|
666
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Appends the specified content to the end of the string.
|
|
628
|
+
*/
|
|
667
629
|
append(content) {
|
|
668
|
-
if (typeof content !==
|
|
669
|
-
|
|
630
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
670
631
|
this.outro += content;
|
|
671
632
|
return this;
|
|
672
633
|
}
|
|
673
|
-
|
|
634
|
+
/**
|
|
635
|
+
* Appends the specified content at the index in the original string.
|
|
636
|
+
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
|
637
|
+
* See also `s.prependLeft(...)`.
|
|
638
|
+
*/
|
|
674
639
|
appendLeft(index, content) {
|
|
675
640
|
index = index + this.offset;
|
|
676
|
-
|
|
677
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
678
|
-
|
|
641
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
679
642
|
this._split(index);
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (chunk) {
|
|
684
|
-
chunk.appendLeft(content);
|
|
685
|
-
} else {
|
|
686
|
-
this.intro += content;
|
|
687
|
-
}
|
|
643
|
+
const chunk = this.byEnd.get(index);
|
|
644
|
+
if (chunk) chunk.appendLeft(content);
|
|
645
|
+
else this.intro += content;
|
|
688
646
|
return this;
|
|
689
647
|
}
|
|
690
|
-
|
|
648
|
+
/**
|
|
649
|
+
* Appends the specified content at the index in the original string.
|
|
650
|
+
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
|
651
|
+
* See also `s.prependRight(...)`.
|
|
652
|
+
*/
|
|
691
653
|
appendRight(index, content) {
|
|
692
654
|
index = index + this.offset;
|
|
693
|
-
|
|
694
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
695
|
-
|
|
655
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
696
656
|
this._split(index);
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
if (chunk) {
|
|
701
|
-
chunk.appendRight(content);
|
|
702
|
-
} else {
|
|
703
|
-
this.outro += content;
|
|
704
|
-
}
|
|
657
|
+
const chunk = this.byStart.get(index);
|
|
658
|
+
if (chunk) chunk.appendRight(content);
|
|
659
|
+
else this.outro += content;
|
|
705
660
|
return this;
|
|
706
661
|
}
|
|
707
|
-
|
|
662
|
+
/**
|
|
663
|
+
* Does what you'd expect.
|
|
664
|
+
*/
|
|
708
665
|
clone() {
|
|
709
|
-
const cloned = new MagicString(this.original, {
|
|
710
|
-
|
|
666
|
+
const cloned = new MagicString(this.original, {
|
|
667
|
+
filename: this.filename,
|
|
668
|
+
offset: this.offset
|
|
669
|
+
});
|
|
711
670
|
let originalChunk = this.firstChunk;
|
|
712
|
-
let clonedChunk =
|
|
713
|
-
|
|
671
|
+
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
714
672
|
while (originalChunk) {
|
|
715
|
-
cloned.byStart
|
|
716
|
-
cloned.byEnd
|
|
717
|
-
|
|
673
|
+
cloned.byStart.set(clonedChunk.start, clonedChunk);
|
|
674
|
+
cloned.byEnd.set(clonedChunk.end, clonedChunk);
|
|
718
675
|
const nextOriginalChunk = originalChunk.next;
|
|
719
676
|
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
720
|
-
|
|
721
677
|
if (nextClonedChunk) {
|
|
722
678
|
clonedChunk.next = nextClonedChunk;
|
|
723
679
|
nextClonedChunk.previous = clonedChunk;
|
|
724
|
-
|
|
725
680
|
clonedChunk = nextClonedChunk;
|
|
726
681
|
}
|
|
727
|
-
|
|
728
682
|
originalChunk = nextOriginalChunk;
|
|
729
683
|
}
|
|
730
|
-
|
|
731
684
|
cloned.lastChunk = clonedChunk;
|
|
732
|
-
|
|
733
|
-
if (this.indentExclusionRanges) {
|
|
734
|
-
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
735
|
-
}
|
|
736
|
-
|
|
685
|
+
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
737
686
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
738
|
-
|
|
739
687
|
cloned.intro = this.intro;
|
|
740
688
|
cloned.outro = this.outro;
|
|
741
|
-
|
|
742
689
|
return cloned;
|
|
743
690
|
}
|
|
744
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
|
693
|
+
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
|
694
|
+
*/
|
|
745
695
|
generateDecodedMap(options) {
|
|
746
696
|
options = options || {};
|
|
747
|
-
|
|
748
697
|
const sourceIndex = 0;
|
|
749
698
|
const names = Object.keys(this.storedNames);
|
|
750
699
|
const mappings = new Mappings(options.hires);
|
|
751
|
-
|
|
752
700
|
const locate = getLocator(this.original);
|
|
753
|
-
|
|
754
|
-
if (this.intro) {
|
|
755
|
-
mappings.advance(this.intro);
|
|
756
|
-
}
|
|
757
|
-
|
|
701
|
+
if (this.intro) mappings.advance(this.intro);
|
|
758
702
|
this.firstChunk.eachNext((chunk) => {
|
|
759
703
|
const loc = locate(chunk.start);
|
|
760
|
-
|
|
761
704
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
mappings.addEdit(
|
|
765
|
-
sourceIndex,
|
|
766
|
-
chunk.content,
|
|
767
|
-
loc,
|
|
768
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
769
|
-
);
|
|
770
|
-
} else {
|
|
771
|
-
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
772
|
-
}
|
|
773
|
-
|
|
705
|
+
if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
706
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
774
707
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
775
708
|
});
|
|
776
|
-
|
|
777
|
-
if (this.outro) {
|
|
778
|
-
mappings.advance(this.outro);
|
|
779
|
-
}
|
|
780
|
-
|
|
709
|
+
if (this.outro) mappings.advance(this.outro);
|
|
781
710
|
return {
|
|
782
|
-
file: options.file ? options.file.split(/[/\\]/).pop() :
|
|
783
|
-
sources: [
|
|
784
|
-
|
|
785
|
-
],
|
|
786
|
-
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
711
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
712
|
+
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
713
|
+
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
787
714
|
names,
|
|
788
715
|
mappings: mappings.raw,
|
|
789
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] :
|
|
716
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
790
717
|
};
|
|
791
718
|
}
|
|
792
|
-
|
|
719
|
+
/**
|
|
720
|
+
* Generates a version 3 sourcemap.
|
|
721
|
+
*/
|
|
793
722
|
generateMap(options) {
|
|
794
723
|
return new SourceMap(this.generateDecodedMap(options));
|
|
795
724
|
}
|
|
796
|
-
|
|
725
|
+
/** @internal */
|
|
797
726
|
_ensureindentStr() {
|
|
798
|
-
if (this.indentStr ===
|
|
799
|
-
this.indentStr = guessIndent(this.original);
|
|
800
|
-
}
|
|
727
|
+
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
801
728
|
}
|
|
802
|
-
|
|
729
|
+
/** @internal */
|
|
803
730
|
_getRawIndentString() {
|
|
804
731
|
this._ensureindentStr();
|
|
805
732
|
return this.indentStr;
|
|
806
733
|
}
|
|
807
|
-
|
|
808
734
|
getIndentString() {
|
|
809
735
|
this._ensureindentStr();
|
|
810
|
-
return this.indentStr === null ?
|
|
736
|
+
return this.indentStr === null ? " " : this.indentStr;
|
|
811
737
|
}
|
|
812
|
-
|
|
813
738
|
indent(indentStr, options) {
|
|
814
739
|
const pattern = /^[^\r\n]/gm;
|
|
815
|
-
|
|
816
740
|
if (isObject(indentStr)) {
|
|
817
741
|
options = indentStr;
|
|
818
|
-
indentStr =
|
|
742
|
+
indentStr = void 0;
|
|
819
743
|
}
|
|
820
|
-
|
|
821
|
-
if (indentStr === undefined) {
|
|
744
|
+
if (indentStr === void 0) {
|
|
822
745
|
this._ensureindentStr();
|
|
823
|
-
indentStr = this.indentStr ||
|
|
746
|
+
indentStr = this.indentStr || " ";
|
|
824
747
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
748
|
+
if (indentStr === "") return this;
|
|
749
|
+
const resolvedIndentStr = indentStr;
|
|
828
750
|
options = options || {};
|
|
829
|
-
|
|
830
|
-
// Process exclusion ranges
|
|
831
751
|
const isExcluded = {};
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
836
|
-
exclusions.forEach((exclusion) => {
|
|
837
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
838
|
-
isExcluded[i] = true;
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
|
|
752
|
+
if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
753
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
754
|
+
});
|
|
843
755
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
844
756
|
const replacer = (match) => {
|
|
845
|
-
if (shouldIndentNextCharacter) return `${
|
|
757
|
+
if (shouldIndentNextCharacter) return `${resolvedIndentStr}${match}`;
|
|
846
758
|
shouldIndentNextCharacter = true;
|
|
847
759
|
return match;
|
|
848
760
|
};
|
|
849
|
-
|
|
850
761
|
this.intro = this.intro.replace(pattern, replacer);
|
|
851
|
-
|
|
852
762
|
let charIndex = 0;
|
|
853
763
|
let chunk = this.firstChunk;
|
|
854
|
-
|
|
764
|
+
const indentAt = (index) => {
|
|
765
|
+
shouldIndentNextCharacter = false;
|
|
766
|
+
if (index === chunk.start) chunk.prependRight(resolvedIndentStr);
|
|
767
|
+
else {
|
|
768
|
+
this._splitChunk(chunk, index);
|
|
769
|
+
chunk = chunk.next;
|
|
770
|
+
chunk.prependRight(resolvedIndentStr);
|
|
771
|
+
}
|
|
772
|
+
};
|
|
855
773
|
while (chunk) {
|
|
856
774
|
const end = chunk.end;
|
|
857
|
-
|
|
858
775
|
if (chunk.edited) {
|
|
859
776
|
if (!isExcluded[charIndex]) {
|
|
860
777
|
chunk.content = chunk.content.replace(pattern, replacer);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
778
|
+
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
779
|
+
}
|
|
780
|
+
} else if (options.exclude) {
|
|
781
|
+
charIndex = chunk.start;
|
|
782
|
+
while (charIndex < end) {
|
|
783
|
+
if (!isExcluded[charIndex]) {
|
|
784
|
+
const char = this.original.charCodeAt(charIndex);
|
|
785
|
+
if (char === NEWLINE_CHAR) shouldIndentNextCharacter = true;
|
|
786
|
+
else if (char !== CR_CHAR && shouldIndentNextCharacter) indentAt(charIndex);
|
|
864
787
|
}
|
|
788
|
+
charIndex += 1;
|
|
865
789
|
}
|
|
866
790
|
} else {
|
|
867
791
|
charIndex = chunk.start;
|
|
868
|
-
|
|
869
792
|
while (charIndex < end) {
|
|
870
|
-
if (!
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
shouldIndentNextCharacter = false;
|
|
877
|
-
|
|
878
|
-
if (charIndex === chunk.start) {
|
|
879
|
-
chunk.prependRight(indentStr);
|
|
880
|
-
} else {
|
|
881
|
-
this._splitChunk(chunk, charIndex);
|
|
882
|
-
chunk = chunk.next;
|
|
883
|
-
chunk.prependRight(indentStr);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
793
|
+
if (!shouldIndentNextCharacter) {
|
|
794
|
+
const nextLine = this.original.indexOf(n, charIndex);
|
|
795
|
+
if (nextLine === -1 || nextLine >= end) break;
|
|
796
|
+
shouldIndentNextCharacter = true;
|
|
797
|
+
charIndex = nextLine + 1;
|
|
798
|
+
continue;
|
|
886
799
|
}
|
|
887
|
-
|
|
800
|
+
const char = this.original.charCodeAt(charIndex);
|
|
801
|
+
if (char === NEWLINE_CHAR || char === CR_CHAR) {
|
|
802
|
+
charIndex += 1;
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
indentAt(charIndex);
|
|
888
806
|
charIndex += 1;
|
|
889
807
|
}
|
|
890
808
|
}
|
|
891
|
-
|
|
892
809
|
charIndex = chunk.end;
|
|
893
810
|
chunk = chunk.next;
|
|
894
811
|
}
|
|
895
|
-
|
|
896
812
|
this.outro = this.outro.replace(pattern, replacer);
|
|
897
|
-
|
|
898
813
|
return this;
|
|
899
814
|
}
|
|
900
|
-
|
|
815
|
+
/** @internal */
|
|
901
816
|
insert() {
|
|
902
|
-
throw new Error(
|
|
903
|
-
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
904
|
-
);
|
|
817
|
+
throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
|
|
905
818
|
}
|
|
906
|
-
|
|
819
|
+
/** @internal */
|
|
907
820
|
insertLeft(index, content) {
|
|
908
821
|
if (!warned.insertLeft) {
|
|
909
|
-
console.warn(
|
|
910
|
-
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
911
|
-
);
|
|
822
|
+
console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
|
|
912
823
|
warned.insertLeft = true;
|
|
913
824
|
}
|
|
914
|
-
|
|
915
825
|
return this.appendLeft(index, content);
|
|
916
826
|
}
|
|
917
|
-
|
|
827
|
+
/** @internal */
|
|
918
828
|
insertRight(index, content) {
|
|
919
829
|
if (!warned.insertRight) {
|
|
920
|
-
console.warn(
|
|
921
|
-
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
922
|
-
);
|
|
830
|
+
console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
|
|
923
831
|
warned.insertRight = true;
|
|
924
832
|
}
|
|
925
|
-
|
|
926
833
|
return this.prependRight(index, content);
|
|
927
834
|
}
|
|
928
|
-
|
|
835
|
+
/**
|
|
836
|
+
* Moves the characters from `start` and `end` to `index`.
|
|
837
|
+
*/
|
|
929
838
|
move(start, end, index) {
|
|
930
839
|
start = start + this.offset;
|
|
931
840
|
end = end + this.offset;
|
|
932
841
|
index = index + this.offset;
|
|
933
|
-
|
|
934
|
-
if (index >= start && index <= end) throw new Error(
|
|
935
|
-
|
|
842
|
+
if (start === end) return this;
|
|
843
|
+
if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
|
|
936
844
|
this._split(start);
|
|
937
845
|
this._split(end);
|
|
938
846
|
this._split(index);
|
|
939
|
-
|
|
940
|
-
const
|
|
941
|
-
const last = this.byEnd[end];
|
|
942
|
-
|
|
847
|
+
const first = this.byStart.get(start);
|
|
848
|
+
const last = this.byEnd.get(end);
|
|
943
849
|
const oldLeft = first.previous;
|
|
944
850
|
const oldRight = last.next;
|
|
945
|
-
|
|
946
|
-
const newRight = this.byStart[index];
|
|
851
|
+
const newRight = this.byStart.get(index);
|
|
947
852
|
if (!newRight && last === this.lastChunk) return this;
|
|
948
853
|
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
949
|
-
|
|
950
854
|
if (oldLeft) oldLeft.next = oldRight;
|
|
951
855
|
if (oldRight) oldRight.previous = oldLeft;
|
|
952
|
-
|
|
953
856
|
if (newLeft) newLeft.next = first;
|
|
954
857
|
if (newRight) newRight.previous = last;
|
|
955
|
-
|
|
956
858
|
if (!first.previous) this.firstChunk = last.next;
|
|
957
859
|
if (!last.next) {
|
|
958
860
|
this.lastChunk = first.previous;
|
|
959
861
|
this.lastChunk.next = null;
|
|
960
862
|
}
|
|
961
|
-
|
|
962
863
|
first.previous = newLeft;
|
|
963
864
|
last.next = newRight || null;
|
|
964
|
-
|
|
965
865
|
if (!newLeft) this.firstChunk = first;
|
|
966
866
|
if (!newRight) this.lastChunk = last;
|
|
967
867
|
return this;
|
|
968
868
|
}
|
|
969
|
-
|
|
869
|
+
/**
|
|
870
|
+
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
|
871
|
+
* that range. The same restrictions as `s.remove()` apply.
|
|
872
|
+
*
|
|
873
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
874
|
+
* for later inclusion in a sourcemap's names array - and a contentOnly property which determines whether only
|
|
875
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
876
|
+
*
|
|
877
|
+
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
|
878
|
+
*/
|
|
970
879
|
overwrite(start, end, content, options) {
|
|
971
|
-
|
|
972
|
-
return this.update(start, end, content, {
|
|
880
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
881
|
+
return this.update(start, end, content, {
|
|
882
|
+
...optionObject,
|
|
883
|
+
overwrite: !optionObject.contentOnly
|
|
884
|
+
});
|
|
973
885
|
}
|
|
974
|
-
|
|
886
|
+
/**
|
|
887
|
+
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
|
888
|
+
*
|
|
889
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
890
|
+
* for later inclusion in a sourcemap's names array - and an overwrite property which determines whether only
|
|
891
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
892
|
+
*/
|
|
975
893
|
update(start, end, content, options) {
|
|
976
894
|
start = start + this.offset;
|
|
977
895
|
end = end + this.offset;
|
|
978
|
-
|
|
979
|
-
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
980
|
-
|
|
896
|
+
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
981
897
|
if (this.original.length !== 0) {
|
|
982
898
|
while (start < 0) start += this.original.length;
|
|
983
899
|
while (end < 0) end += this.original.length;
|
|
984
900
|
}
|
|
985
|
-
|
|
986
|
-
if (
|
|
987
|
-
if (start === end)
|
|
988
|
-
throw new Error(
|
|
989
|
-
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
990
|
-
);
|
|
991
|
-
|
|
901
|
+
if (end > this.original.length) throw new Error("end is out of bounds");
|
|
902
|
+
if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
|
|
992
903
|
this._split(start);
|
|
993
904
|
this._split(end);
|
|
994
|
-
|
|
995
905
|
if (options === true) {
|
|
996
906
|
if (!warned.storeName) {
|
|
997
|
-
console.warn(
|
|
998
|
-
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
999
|
-
);
|
|
907
|
+
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
1000
908
|
warned.storeName = true;
|
|
1001
909
|
}
|
|
1002
|
-
|
|
1003
910
|
options = { storeName: true };
|
|
1004
911
|
}
|
|
1005
|
-
const
|
|
1006
|
-
const
|
|
1007
|
-
|
|
912
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
913
|
+
const storeName = optionObject.storeName || false;
|
|
914
|
+
const overwrite = optionObject.overwrite || false;
|
|
1008
915
|
if (storeName) {
|
|
1009
916
|
const original = this.original.slice(start, end);
|
|
1010
917
|
Object.defineProperty(this.storedNames, original, {
|
|
1011
918
|
writable: true,
|
|
1012
919
|
value: true,
|
|
1013
|
-
enumerable: true
|
|
920
|
+
enumerable: true
|
|
1014
921
|
});
|
|
1015
922
|
}
|
|
1016
|
-
|
|
1017
|
-
const
|
|
1018
|
-
const last = this.byEnd[end];
|
|
1019
|
-
|
|
923
|
+
const first = this.byStart.get(start);
|
|
924
|
+
const last = this.byEnd.get(end);
|
|
1020
925
|
if (first) {
|
|
1021
926
|
let chunk = first;
|
|
1022
927
|
while (chunk !== last) {
|
|
1023
|
-
if (chunk.next !== this.byStart
|
|
1024
|
-
throw new Error('Cannot overwrite across a split point');
|
|
1025
|
-
}
|
|
928
|
+
if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
|
|
1026
929
|
chunk = chunk.next;
|
|
1027
|
-
chunk.edit(
|
|
930
|
+
chunk.edit("", false);
|
|
1028
931
|
}
|
|
1029
|
-
|
|
1030
932
|
first.edit(content, storeName, !overwrite);
|
|
1031
933
|
} else {
|
|
1032
|
-
|
|
1033
|
-
const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
|
|
1034
|
-
|
|
1035
|
-
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
934
|
+
const newChunk = new Chunk$1(start, end, "").edit(content, storeName);
|
|
1036
935
|
last.next = newChunk;
|
|
1037
936
|
newChunk.previous = last;
|
|
1038
937
|
}
|
|
1039
938
|
return this;
|
|
1040
939
|
}
|
|
1041
|
-
|
|
940
|
+
/**
|
|
941
|
+
* Prepends the string with the specified content.
|
|
942
|
+
*/
|
|
1042
943
|
prepend(content) {
|
|
1043
|
-
if (typeof content !==
|
|
1044
|
-
|
|
944
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
1045
945
|
this.intro = content + this.intro;
|
|
1046
946
|
return this;
|
|
1047
947
|
}
|
|
1048
|
-
|
|
948
|
+
/**
|
|
949
|
+
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
|
950
|
+
*/
|
|
1049
951
|
prependLeft(index, content) {
|
|
1050
952
|
index = index + this.offset;
|
|
1051
|
-
|
|
1052
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1053
|
-
|
|
953
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
1054
954
|
this._split(index);
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
if (chunk) {
|
|
1059
|
-
chunk.prependLeft(content);
|
|
1060
|
-
} else {
|
|
1061
|
-
this.intro = content + this.intro;
|
|
1062
|
-
}
|
|
955
|
+
const chunk = this.byEnd.get(index);
|
|
956
|
+
if (chunk) chunk.prependLeft(content);
|
|
957
|
+
else this.intro = content + this.intro;
|
|
1063
958
|
return this;
|
|
1064
959
|
}
|
|
1065
|
-
|
|
960
|
+
/**
|
|
961
|
+
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
|
962
|
+
*/
|
|
1066
963
|
prependRight(index, content) {
|
|
1067
964
|
index = index + this.offset;
|
|
1068
|
-
|
|
1069
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1070
|
-
|
|
965
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
1071
966
|
this._split(index);
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if (chunk) {
|
|
1076
|
-
chunk.prependRight(content);
|
|
1077
|
-
} else {
|
|
1078
|
-
this.outro = content + this.outro;
|
|
1079
|
-
}
|
|
967
|
+
const chunk = this.byStart.get(index);
|
|
968
|
+
if (chunk) chunk.prependRight(content);
|
|
969
|
+
else this.outro = content + this.outro;
|
|
1080
970
|
return this;
|
|
1081
971
|
}
|
|
1082
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
974
|
+
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
975
|
+
*/
|
|
1083
976
|
remove(start, end) {
|
|
1084
977
|
start = start + this.offset;
|
|
1085
978
|
end = end + this.offset;
|
|
1086
|
-
|
|
1087
979
|
if (this.original.length !== 0) {
|
|
1088
980
|
while (start < 0) start += this.original.length;
|
|
1089
981
|
while (end < 0) end += this.original.length;
|
|
1090
982
|
}
|
|
1091
|
-
|
|
1092
983
|
if (start === end) return this;
|
|
1093
|
-
|
|
1094
|
-
if (start
|
|
1095
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
1096
|
-
|
|
984
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
985
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
1097
986
|
this._split(start);
|
|
1098
987
|
this._split(end);
|
|
1099
|
-
|
|
1100
|
-
let chunk = this.byStart[start];
|
|
1101
|
-
|
|
988
|
+
let chunk = this.byStart.get(start);
|
|
1102
989
|
while (chunk) {
|
|
1103
|
-
chunk.intro =
|
|
1104
|
-
chunk.outro =
|
|
1105
|
-
chunk.edit(
|
|
1106
|
-
|
|
1107
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
990
|
+
chunk.intro = "";
|
|
991
|
+
chunk.outro = "";
|
|
992
|
+
chunk.edit("");
|
|
993
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
1108
994
|
}
|
|
1109
995
|
return this;
|
|
1110
996
|
}
|
|
1111
|
-
|
|
997
|
+
/**
|
|
998
|
+
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
|
|
999
|
+
*/
|
|
1112
1000
|
reset(start, end) {
|
|
1113
1001
|
start = start + this.offset;
|
|
1114
1002
|
end = end + this.offset;
|
|
1115
|
-
|
|
1116
1003
|
if (this.original.length !== 0) {
|
|
1117
1004
|
while (start < 0) start += this.original.length;
|
|
1118
1005
|
while (end < 0) end += this.original.length;
|
|
1119
1006
|
}
|
|
1120
|
-
|
|
1121
1007
|
if (start === end) return this;
|
|
1122
|
-
|
|
1123
|
-
if (start
|
|
1124
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
1125
|
-
|
|
1008
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
1009
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
1126
1010
|
this._split(start);
|
|
1127
1011
|
this._split(end);
|
|
1128
|
-
|
|
1129
|
-
let chunk = this.byStart[start];
|
|
1130
|
-
|
|
1012
|
+
let chunk = this.byStart.get(start);
|
|
1131
1013
|
while (chunk) {
|
|
1132
1014
|
chunk.reset();
|
|
1133
|
-
|
|
1134
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1015
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
1135
1016
|
}
|
|
1136
1017
|
return this;
|
|
1137
1018
|
}
|
|
1138
|
-
|
|
1139
1019
|
lastChar() {
|
|
1140
1020
|
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
1141
1021
|
let chunk = this.lastChunk;
|
|
1142
|
-
|
|
1022
|
+
while (chunk) {
|
|
1143
1023
|
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
1144
1024
|
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
1145
1025
|
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
1146
|
-
|
|
1026
|
+
chunk = chunk.previous;
|
|
1027
|
+
}
|
|
1147
1028
|
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
1148
|
-
return
|
|
1029
|
+
return "";
|
|
1149
1030
|
}
|
|
1150
|
-
|
|
1151
1031
|
lastLine() {
|
|
1152
1032
|
let lineIndex = this.outro.lastIndexOf(n);
|
|
1153
1033
|
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
1154
1034
|
let lineStr = this.outro;
|
|
1155
1035
|
let chunk = this.lastChunk;
|
|
1156
|
-
|
|
1036
|
+
while (chunk) {
|
|
1157
1037
|
if (chunk.outro.length > 0) {
|
|
1158
1038
|
lineIndex = chunk.outro.lastIndexOf(n);
|
|
1159
1039
|
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
1160
1040
|
lineStr = chunk.outro + lineStr;
|
|
1161
1041
|
}
|
|
1162
|
-
|
|
1163
1042
|
if (chunk.content.length > 0) {
|
|
1164
1043
|
lineIndex = chunk.content.lastIndexOf(n);
|
|
1165
1044
|
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
1166
1045
|
lineStr = chunk.content + lineStr;
|
|
1167
1046
|
}
|
|
1168
|
-
|
|
1169
1047
|
if (chunk.intro.length > 0) {
|
|
1170
1048
|
lineIndex = chunk.intro.lastIndexOf(n);
|
|
1171
1049
|
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
1172
1050
|
lineStr = chunk.intro + lineStr;
|
|
1173
1051
|
}
|
|
1174
|
-
|
|
1052
|
+
chunk = chunk.previous;
|
|
1053
|
+
}
|
|
1175
1054
|
lineIndex = this.intro.lastIndexOf(n);
|
|
1176
1055
|
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
1177
1056
|
return this.intro + lineStr;
|
|
1178
1057
|
}
|
|
1179
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
|
1060
|
+
* Throws error if the indices are for characters that were already removed.
|
|
1061
|
+
*/
|
|
1180
1062
|
slice(start = 0, end = this.original.length - this.offset) {
|
|
1181
1063
|
start = start + this.offset;
|
|
1182
1064
|
end = end + this.offset;
|
|
1183
|
-
|
|
1184
1065
|
if (this.original.length !== 0) {
|
|
1185
1066
|
while (start < 0) start += this.original.length;
|
|
1186
1067
|
while (end < 0) end += this.original.length;
|
|
1187
1068
|
}
|
|
1188
|
-
|
|
1189
|
-
let result = '';
|
|
1190
|
-
|
|
1191
|
-
// find start chunk
|
|
1069
|
+
let result = "";
|
|
1192
1070
|
let chunk = this.firstChunk;
|
|
1193
1071
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
1194
|
-
|
|
1195
|
-
if (chunk.start < end && chunk.end >= end) {
|
|
1196
|
-
return result;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1072
|
+
if (chunk.start < end && chunk.end >= end) return result;
|
|
1199
1073
|
chunk = chunk.next;
|
|
1200
1074
|
}
|
|
1201
|
-
|
|
1202
|
-
if (chunk && chunk.edited && chunk.start !== start)
|
|
1203
|
-
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1204
|
-
|
|
1075
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1205
1076
|
const startChunk = chunk;
|
|
1206
1077
|
while (chunk) {
|
|
1207
|
-
if (chunk.intro && (startChunk !== chunk || chunk.start === start))
|
|
1208
|
-
result += chunk.intro;
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1078
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
1211
1079
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1212
|
-
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
1213
|
-
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1214
|
-
|
|
1080
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1215
1081
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1216
1082
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1217
|
-
|
|
1218
1083
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
1219
|
-
|
|
1220
|
-
if (
|
|
1221
|
-
result += chunk.outro;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
if (containsEnd) {
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1084
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
|
|
1085
|
+
if (containsEnd) break;
|
|
1228
1086
|
chunk = chunk.next;
|
|
1229
1087
|
}
|
|
1230
|
-
|
|
1231
1088
|
return result;
|
|
1232
1089
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1090
|
+
/**
|
|
1091
|
+
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
|
1092
|
+
*/
|
|
1235
1093
|
snip(start, end) {
|
|
1236
1094
|
const clone = this.clone();
|
|
1237
1095
|
clone.remove(0, start);
|
|
1238
1096
|
clone.remove(end, clone.original.length);
|
|
1239
|
-
|
|
1240
1097
|
return clone;
|
|
1241
1098
|
}
|
|
1242
|
-
|
|
1099
|
+
/** @internal */
|
|
1243
1100
|
_split(index) {
|
|
1244
|
-
if (this.byStart
|
|
1245
|
-
|
|
1101
|
+
if (this.byStart.get(index) || this.byEnd.get(index)) return;
|
|
1246
1102
|
let chunk = this.lastSearchedChunk;
|
|
1247
1103
|
let previousChunk = chunk;
|
|
1248
1104
|
const searchForward = index > chunk.end;
|
|
1249
|
-
|
|
1250
1105
|
while (chunk) {
|
|
1251
1106
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
1252
|
-
|
|
1253
|
-
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
1254
|
-
|
|
1255
|
-
// Prevent infinite loop (e.g. via empty chunks, where start === end)
|
|
1107
|
+
chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
|
|
1256
1108
|
if (chunk === previousChunk) return;
|
|
1257
|
-
|
|
1258
1109
|
previousChunk = chunk;
|
|
1259
1110
|
}
|
|
1260
1111
|
}
|
|
1261
|
-
|
|
1112
|
+
/** @internal */
|
|
1262
1113
|
_splitChunk(chunk, index) {
|
|
1263
1114
|
if (chunk.edited && chunk.content.length) {
|
|
1264
|
-
// zero-length edited chunks are a special case (overlapping replacements)
|
|
1265
1115
|
const loc = getLocator(this.original)(index);
|
|
1266
|
-
throw new Error(
|
|
1267
|
-
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
1268
|
-
);
|
|
1116
|
+
throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
1269
1117
|
}
|
|
1270
|
-
|
|
1271
1118
|
const newChunk = chunk.split(index);
|
|
1272
|
-
|
|
1273
|
-
this.
|
|
1274
|
-
this.
|
|
1275
|
-
this.byEnd[newChunk.end] = newChunk;
|
|
1276
|
-
|
|
1119
|
+
this.byEnd.set(index, chunk);
|
|
1120
|
+
this.byStart.set(index, newChunk);
|
|
1121
|
+
this.byEnd.set(newChunk.end, newChunk);
|
|
1277
1122
|
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
1278
|
-
|
|
1279
1123
|
this.lastSearchedChunk = chunk;
|
|
1280
1124
|
return true;
|
|
1281
1125
|
}
|
|
1282
|
-
|
|
1126
|
+
/**
|
|
1127
|
+
* Returns the generated string.
|
|
1128
|
+
*/
|
|
1283
1129
|
toString() {
|
|
1284
1130
|
let str = this.intro;
|
|
1285
|
-
|
|
1286
1131
|
let chunk = this.firstChunk;
|
|
1287
1132
|
while (chunk) {
|
|
1288
1133
|
str += chunk.toString();
|
|
1289
1134
|
chunk = chunk.next;
|
|
1290
1135
|
}
|
|
1291
|
-
|
|
1292
1136
|
return str + this.outro;
|
|
1293
1137
|
}
|
|
1294
|
-
|
|
1138
|
+
/**
|
|
1139
|
+
* Returns true if the resulting source is empty (disregarding white space).
|
|
1140
|
+
*/
|
|
1295
1141
|
isEmpty() {
|
|
1296
1142
|
let chunk = this.firstChunk;
|
|
1297
|
-
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
(chunk.outro.length && chunk.outro.trim())
|
|
1302
|
-
)
|
|
1303
|
-
return false;
|
|
1304
|
-
} while ((chunk = chunk.next));
|
|
1143
|
+
while (chunk) {
|
|
1144
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
1145
|
+
chunk = chunk.next;
|
|
1146
|
+
}
|
|
1305
1147
|
return true;
|
|
1306
1148
|
}
|
|
1307
|
-
|
|
1308
1149
|
length() {
|
|
1309
1150
|
let chunk = this.firstChunk;
|
|
1310
1151
|
let length = 0;
|
|
1311
|
-
|
|
1152
|
+
while (chunk) {
|
|
1312
1153
|
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
1313
|
-
|
|
1154
|
+
chunk = chunk.next;
|
|
1155
|
+
}
|
|
1314
1156
|
return length;
|
|
1315
1157
|
}
|
|
1316
|
-
|
|
1158
|
+
/**
|
|
1159
|
+
* Removes empty lines from the start and end.
|
|
1160
|
+
*/
|
|
1317
1161
|
trimLines() {
|
|
1318
|
-
return this.trim(
|
|
1162
|
+
return this.trim("[\\r\\n]");
|
|
1319
1163
|
}
|
|
1320
|
-
|
|
1164
|
+
/**
|
|
1165
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
|
1166
|
+
*/
|
|
1321
1167
|
trim(charType) {
|
|
1322
1168
|
return this.trimStart(charType).trimEnd(charType);
|
|
1323
1169
|
}
|
|
1324
|
-
|
|
1170
|
+
/** @internal */
|
|
1325
1171
|
trimEndAborted(charType) {
|
|
1326
|
-
const rx = new RegExp(
|
|
1327
|
-
|
|
1328
|
-
this.outro = this.outro.replace(rx, '');
|
|
1172
|
+
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
1173
|
+
this.outro = this.outro.replace(rx, "");
|
|
1329
1174
|
if (this.outro.length) return true;
|
|
1330
|
-
|
|
1331
1175
|
let chunk = this.lastChunk;
|
|
1332
|
-
|
|
1333
1176
|
do {
|
|
1334
1177
|
const end = chunk.end;
|
|
1335
1178
|
const aborted = chunk.trimEnd(rx);
|
|
1336
|
-
|
|
1337
|
-
// if chunk was trimmed, we have a new lastChunk
|
|
1338
1179
|
if (chunk.end !== end) {
|
|
1339
|
-
if (this.lastChunk === chunk)
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
this.byEnd[chunk.end] = chunk;
|
|
1344
|
-
this.byStart[chunk.next.start] = chunk.next;
|
|
1345
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
1180
|
+
if (this.lastChunk === chunk) this.lastChunk = chunk.next;
|
|
1181
|
+
this.byEnd.set(chunk.end, chunk);
|
|
1182
|
+
this.byStart.set(chunk.next.start, chunk.next);
|
|
1183
|
+
this.byEnd.set(chunk.next.end, chunk.next);
|
|
1346
1184
|
}
|
|
1347
|
-
|
|
1348
1185
|
if (aborted) return true;
|
|
1349
1186
|
chunk = chunk.previous;
|
|
1350
1187
|
} while (chunk);
|
|
1351
|
-
|
|
1352
1188
|
return false;
|
|
1353
1189
|
}
|
|
1354
|
-
|
|
1190
|
+
/**
|
|
1191
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
1192
|
+
*/
|
|
1355
1193
|
trimEnd(charType) {
|
|
1356
1194
|
this.trimEndAborted(charType);
|
|
1357
1195
|
return this;
|
|
1358
1196
|
}
|
|
1197
|
+
/** @internal */
|
|
1359
1198
|
trimStartAborted(charType) {
|
|
1360
|
-
const rx = new RegExp(
|
|
1361
|
-
|
|
1362
|
-
this.intro = this.intro.replace(rx, '');
|
|
1199
|
+
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
1200
|
+
this.intro = this.intro.replace(rx, "");
|
|
1363
1201
|
if (this.intro.length) return true;
|
|
1364
|
-
|
|
1365
1202
|
let chunk = this.firstChunk;
|
|
1366
|
-
|
|
1367
1203
|
do {
|
|
1368
1204
|
const end = chunk.end;
|
|
1369
1205
|
const aborted = chunk.trimStart(rx);
|
|
1370
|
-
|
|
1371
1206
|
if (chunk.end !== end) {
|
|
1372
|
-
// special case...
|
|
1373
1207
|
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
1374
|
-
|
|
1375
|
-
this.
|
|
1376
|
-
this.
|
|
1377
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
1208
|
+
this.byEnd.set(chunk.end, chunk);
|
|
1209
|
+
this.byStart.set(chunk.next.start, chunk.next);
|
|
1210
|
+
this.byEnd.set(chunk.next.end, chunk.next);
|
|
1378
1211
|
}
|
|
1379
|
-
|
|
1380
1212
|
if (aborted) return true;
|
|
1381
1213
|
chunk = chunk.next;
|
|
1382
1214
|
} while (chunk);
|
|
1383
|
-
|
|
1384
1215
|
return false;
|
|
1385
1216
|
}
|
|
1386
|
-
|
|
1217
|
+
/**
|
|
1218
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
1219
|
+
*/
|
|
1387
1220
|
trimStart(charType) {
|
|
1388
1221
|
this.trimStartAborted(charType);
|
|
1389
1222
|
return this;
|
|
1390
1223
|
}
|
|
1391
|
-
|
|
1224
|
+
/**
|
|
1225
|
+
* Indicates if the string has been changed.
|
|
1226
|
+
*/
|
|
1392
1227
|
hasChanged() {
|
|
1393
1228
|
return this.original !== this.toString();
|
|
1394
1229
|
}
|
|
1395
|
-
|
|
1230
|
+
/** @internal */
|
|
1396
1231
|
_replaceRegexp(searchValue, replacement) {
|
|
1397
1232
|
function getReplacement(match, str) {
|
|
1398
|
-
if (typeof replacement ===
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
return `$${i}`;
|
|
1406
|
-
});
|
|
1407
|
-
} else {
|
|
1408
|
-
return replacement(...match, match.index, str, match.groups);
|
|
1409
|
-
}
|
|
1233
|
+
if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
1234
|
+
if (i === "$") return "$";
|
|
1235
|
+
if (i === "&") return match[0];
|
|
1236
|
+
if (+i < match.length) return match[+i];
|
|
1237
|
+
return `$${i}`;
|
|
1238
|
+
});
|
|
1239
|
+
else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
1410
1240
|
}
|
|
1411
1241
|
function matchAll(re, str) {
|
|
1412
|
-
let match;
|
|
1413
1242
|
const matches = [];
|
|
1414
|
-
while (
|
|
1243
|
+
while (true) {
|
|
1244
|
+
const match = re.exec(str);
|
|
1245
|
+
if (!match) break;
|
|
1415
1246
|
matches.push(match);
|
|
1416
1247
|
}
|
|
1417
1248
|
return matches;
|
|
1418
1249
|
}
|
|
1419
|
-
if (searchValue.global) {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
if (match.index
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
} else {
|
|
1250
|
+
if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
|
|
1251
|
+
if (match.index != null) {
|
|
1252
|
+
const replacement = getReplacement(match, this.original);
|
|
1253
|
+
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
else {
|
|
1430
1257
|
const match = this.original.match(searchValue);
|
|
1431
1258
|
if (match && match.index != null) {
|
|
1432
1259
|
const replacement = getReplacement(match, this.original);
|
|
1433
|
-
if (replacement !== match[0])
|
|
1434
|
-
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1435
|
-
}
|
|
1260
|
+
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1436
1261
|
}
|
|
1437
1262
|
}
|
|
1438
1263
|
return this;
|
|
1439
1264
|
}
|
|
1440
|
-
|
|
1265
|
+
/** @internal */
|
|
1441
1266
|
_replaceString(string, replacement) {
|
|
1442
1267
|
const { original } = this;
|
|
1443
1268
|
const index = original.indexOf(string);
|
|
1444
|
-
|
|
1445
1269
|
if (index !== -1) {
|
|
1446
|
-
if (typeof replacement ===
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
if (string !== replacement) {
|
|
1450
|
-
this.overwrite(index, index + string.length, replacement);
|
|
1451
|
-
}
|
|
1270
|
+
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
1271
|
+
if (string !== replacement) this.overwrite(index, index + string.length, replacement);
|
|
1452
1272
|
}
|
|
1453
|
-
|
|
1454
1273
|
return this;
|
|
1455
1274
|
}
|
|
1456
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* String replacement with RegExp or string.
|
|
1277
|
+
*/
|
|
1457
1278
|
replace(searchValue, replacement) {
|
|
1458
|
-
if (typeof searchValue ===
|
|
1459
|
-
return this._replaceString(searchValue, replacement);
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1279
|
+
if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
|
|
1462
1280
|
return this._replaceRegexp(searchValue, replacement);
|
|
1463
1281
|
}
|
|
1464
|
-
|
|
1282
|
+
/** @internal */
|
|
1465
1283
|
_replaceAllString(string, replacement) {
|
|
1466
1284
|
const { original } = this;
|
|
1467
1285
|
const stringLength = string.length;
|
|
1468
|
-
for (
|
|
1469
|
-
let index = original.indexOf(string);
|
|
1470
|
-
index !== -1;
|
|
1471
|
-
index = original.indexOf(string, index + stringLength)
|
|
1472
|
-
) {
|
|
1286
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1473
1287
|
const previous = original.slice(index, index + stringLength);
|
|
1474
|
-
|
|
1475
|
-
if (typeof replacement === 'function') {
|
|
1476
|
-
_replacement = replacement(previous, index, original);
|
|
1477
|
-
}
|
|
1288
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
1478
1289
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1479
1290
|
}
|
|
1480
|
-
|
|
1481
1291
|
return this;
|
|
1482
1292
|
}
|
|
1483
|
-
|
|
1293
|
+
/**
|
|
1294
|
+
* Same as `s.replace`, but replace all matched strings instead of just one.
|
|
1295
|
+
*/
|
|
1484
1296
|
replaceAll(searchValue, replacement) {
|
|
1485
|
-
if (typeof searchValue ===
|
|
1486
|
-
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
if (!searchValue.global) {
|
|
1490
|
-
throw new TypeError(
|
|
1491
|
-
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
1492
|
-
);
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1297
|
+
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
1298
|
+
if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
1495
1299
|
return this._replaceRegexp(searchValue, replacement);
|
|
1496
1300
|
}
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1301
|
+
};
|
|
1302
|
+
//#endregion
|
|
1303
|
+
//#region src/Bundle.ts
|
|
1499
1304
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1500
|
-
|
|
1501
|
-
let Bundle$1 = class Bundle {
|
|
1305
|
+
var Bundle$1 = class Bundle {
|
|
1502
1306
|
constructor(options = {}) {
|
|
1503
|
-
this.intro = options.intro ||
|
|
1504
|
-
this.separator = options.separator !==
|
|
1307
|
+
this.intro = options.intro || "";
|
|
1308
|
+
this.separator = options.separator !== void 0 ? options.separator : "\n";
|
|
1505
1309
|
this.sources = [];
|
|
1506
1310
|
this.uniqueSources = [];
|
|
1507
1311
|
this.uniqueSourceIndexByFilename = {};
|
|
1508
1312
|
}
|
|
1509
|
-
|
|
1313
|
+
/**
|
|
1314
|
+
* Adds the specified source to the bundle, which can either be a `MagicString` object directly,
|
|
1315
|
+
* or an options object that holds a magic string `content` property and optionally provides
|
|
1316
|
+
* a `filename` for the source within the bundle, as well as an optional `ignoreList` hint
|
|
1317
|
+
* (which defaults to `false`). The `filename` is used when constructing the source map for the
|
|
1318
|
+
* bundle, to identify this `source` in the source map's `sources` field. The `ignoreList` hint
|
|
1319
|
+
* is used to populate the `x_google_ignoreList` extension field in the source map, which is a
|
|
1320
|
+
* mechanism for tools to signal to debuggers that certain sources should be ignored by default
|
|
1321
|
+
* (depending on user preferences).
|
|
1322
|
+
*/
|
|
1510
1323
|
addSource(source) {
|
|
1511
|
-
if (source instanceof MagicString) {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
|
|
1324
|
+
if (source instanceof MagicString) return this.addSource({
|
|
1325
|
+
content: source,
|
|
1326
|
+
filename: source.filename,
|
|
1327
|
+
separator: this.separator
|
|
1328
|
+
});
|
|
1329
|
+
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`");
|
|
1330
|
+
[
|
|
1331
|
+
"filename",
|
|
1332
|
+
"ignoreList",
|
|
1333
|
+
"indentExclusionRanges",
|
|
1334
|
+
"separator"
|
|
1335
|
+
].forEach((option) => {
|
|
1526
1336
|
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
1527
1337
|
});
|
|
1528
|
-
|
|
1529
|
-
if (source.
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
} else {
|
|
1539
|
-
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1540
|
-
if (source.content.original !== uniqueSource.content) {
|
|
1541
|
-
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1338
|
+
if (source.separator === void 0) source.separator = this.separator;
|
|
1339
|
+
if (source.filename) if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
1340
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
1341
|
+
this.uniqueSources.push({
|
|
1342
|
+
filename: source.filename,
|
|
1343
|
+
content: source.content.original
|
|
1344
|
+
});
|
|
1345
|
+
} else {
|
|
1346
|
+
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1347
|
+
if (source.content.original !== uniqueSource.content) throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
1544
1348
|
}
|
|
1545
|
-
|
|
1546
1349
|
this.sources.push(source);
|
|
1547
1350
|
return this;
|
|
1548
1351
|
}
|
|
1549
|
-
|
|
1550
1352
|
append(str, options) {
|
|
1551
1353
|
this.addSource({
|
|
1552
1354
|
content: new MagicString(str),
|
|
1553
|
-
separator:
|
|
1355
|
+
separator: options && options.separator || ""
|
|
1554
1356
|
});
|
|
1555
|
-
|
|
1556
1357
|
return this;
|
|
1557
1358
|
}
|
|
1558
|
-
|
|
1559
1359
|
clone() {
|
|
1560
1360
|
const bundle = new Bundle({
|
|
1561
1361
|
intro: this.intro,
|
|
1562
|
-
separator: this.separator
|
|
1362
|
+
separator: this.separator
|
|
1563
1363
|
});
|
|
1564
|
-
|
|
1565
1364
|
this.sources.forEach((source) => {
|
|
1566
1365
|
bundle.addSource({
|
|
1567
1366
|
filename: source.filename,
|
|
1568
1367
|
content: source.content.clone(),
|
|
1569
|
-
separator: source.separator
|
|
1368
|
+
separator: source.separator
|
|
1570
1369
|
});
|
|
1571
1370
|
});
|
|
1572
|
-
|
|
1573
1371
|
return bundle;
|
|
1574
1372
|
}
|
|
1575
|
-
|
|
1576
1373
|
generateDecodedMap(options = {}) {
|
|
1577
1374
|
const names = [];
|
|
1578
|
-
let x_google_ignoreList
|
|
1375
|
+
let x_google_ignoreList;
|
|
1579
1376
|
this.sources.forEach((source) => {
|
|
1580
1377
|
Object.keys(source.content.storedNames).forEach((name) => {
|
|
1581
|
-
if (
|
|
1378
|
+
if (!names.includes(name)) names.push(name);
|
|
1582
1379
|
});
|
|
1583
1380
|
});
|
|
1584
|
-
|
|
1585
1381
|
const mappings = new Mappings(options.hires);
|
|
1586
|
-
|
|
1587
|
-
if (this.intro) {
|
|
1588
|
-
mappings.advance(this.intro);
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1382
|
+
if (this.intro) mappings.advance(this.intro);
|
|
1591
1383
|
this.sources.forEach((source, i) => {
|
|
1592
|
-
if (i > 0)
|
|
1593
|
-
mappings.advance(this.separator);
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1384
|
+
if (i > 0) mappings.advance(this.separator);
|
|
1596
1385
|
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
1597
1386
|
const magicString = source.content;
|
|
1598
1387
|
const locate = getLocator(magicString.original);
|
|
1599
|
-
|
|
1600
|
-
if (magicString.intro) {
|
|
1601
|
-
mappings.advance(magicString.intro);
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1388
|
+
if (magicString.intro) mappings.advance(magicString.intro);
|
|
1604
1389
|
magicString.firstChunk.eachNext((chunk) => {
|
|
1605
1390
|
const loc = locate(chunk.start);
|
|
1606
|
-
|
|
1607
1391
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
mappings.addEdit(
|
|
1612
|
-
sourceIndex,
|
|
1613
|
-
chunk.content,
|
|
1614
|
-
loc,
|
|
1615
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
1616
|
-
);
|
|
1617
|
-
} else {
|
|
1618
|
-
mappings.addUneditedChunk(
|
|
1619
|
-
sourceIndex,
|
|
1620
|
-
chunk,
|
|
1621
|
-
magicString.original,
|
|
1622
|
-
loc,
|
|
1623
|
-
magicString.sourcemapLocations,
|
|
1624
|
-
);
|
|
1625
|
-
}
|
|
1626
|
-
} else {
|
|
1627
|
-
mappings.advance(chunk.content);
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1392
|
+
if (source.filename) if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
1393
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
|
|
1394
|
+
else mappings.advance(chunk.content);
|
|
1630
1395
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
1631
1396
|
});
|
|
1632
|
-
|
|
1633
|
-
if (magicString.outro) {
|
|
1634
|
-
mappings.advance(magicString.outro);
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1397
|
+
if (magicString.outro) mappings.advance(magicString.outro);
|
|
1637
1398
|
if (source.ignoreList && sourceIndex !== -1) {
|
|
1638
|
-
if (x_google_ignoreList ===
|
|
1639
|
-
x_google_ignoreList = [];
|
|
1640
|
-
}
|
|
1399
|
+
if (x_google_ignoreList === void 0) x_google_ignoreList = [];
|
|
1641
1400
|
x_google_ignoreList.push(sourceIndex);
|
|
1642
1401
|
}
|
|
1643
1402
|
});
|
|
1644
|
-
|
|
1645
1403
|
return {
|
|
1646
|
-
file: options.file ? options.file.split(/[/\\]/).pop() :
|
|
1404
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
1647
1405
|
sources: this.uniqueSources.map((source) => {
|
|
1648
1406
|
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
1649
1407
|
}),
|
|
@@ -1652,137 +1410,91 @@ let Bundle$1 = class Bundle {
|
|
|
1652
1410
|
}),
|
|
1653
1411
|
names,
|
|
1654
1412
|
mappings: mappings.raw,
|
|
1655
|
-
x_google_ignoreList
|
|
1413
|
+
x_google_ignoreList
|
|
1656
1414
|
};
|
|
1657
1415
|
}
|
|
1658
|
-
|
|
1659
1416
|
generateMap(options) {
|
|
1660
1417
|
return new SourceMap(this.generateDecodedMap(options));
|
|
1661
1418
|
}
|
|
1662
|
-
|
|
1663
1419
|
getIndentString() {
|
|
1664
1420
|
const indentStringCounts = {};
|
|
1665
|
-
|
|
1666
1421
|
this.sources.forEach((source) => {
|
|
1667
1422
|
const indentStr = source.content._getRawIndentString();
|
|
1668
|
-
|
|
1669
1423
|
if (indentStr === null) return;
|
|
1670
|
-
|
|
1671
1424
|
if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
|
1672
1425
|
indentStringCounts[indentStr] += 1;
|
|
1673
1426
|
});
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
return indentStringCounts[a] - indentStringCounts[b];
|
|
1678
|
-
})[0] || '\t'
|
|
1679
|
-
);
|
|
1427
|
+
return Object.keys(indentStringCounts).sort((a, b) => {
|
|
1428
|
+
return indentStringCounts[a] - indentStringCounts[b];
|
|
1429
|
+
})[0] || " ";
|
|
1680
1430
|
}
|
|
1681
|
-
|
|
1682
1431
|
indent(indentStr) {
|
|
1683
|
-
if (!arguments.length)
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (indentStr === '') return this; // noop
|
|
1688
|
-
|
|
1689
|
-
let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
|
|
1690
|
-
|
|
1432
|
+
if (!arguments.length) indentStr = this.getIndentString();
|
|
1433
|
+
if (indentStr === "") return this;
|
|
1434
|
+
let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
|
|
1691
1435
|
this.sources.forEach((source, i) => {
|
|
1692
|
-
const separator = source.separator !==
|
|
1693
|
-
const indentStart = trailingNewline ||
|
|
1694
|
-
|
|
1436
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
1437
|
+
const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
|
1695
1438
|
source.content.indent(indentStr, {
|
|
1696
1439
|
exclude: source.indentExclusionRanges,
|
|
1697
|
-
indentStart
|
|
1440
|
+
indentStart
|
|
1698
1441
|
});
|
|
1699
|
-
|
|
1700
|
-
|
|
1442
|
+
trailingNewline = source.content.lastChar() === "\n";
|
|
1443
|
+
});
|
|
1444
|
+
if (this.intro) this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
1445
|
+
return index > 0 ? indentStr + match : match;
|
|
1701
1446
|
});
|
|
1702
|
-
|
|
1703
|
-
if (this.intro) {
|
|
1704
|
-
this.intro =
|
|
1705
|
-
indentStr +
|
|
1706
|
-
this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
1707
|
-
return index > 0 ? indentStr + match : match;
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
1447
|
return this;
|
|
1712
1448
|
}
|
|
1713
|
-
|
|
1714
1449
|
prepend(str) {
|
|
1715
1450
|
this.intro = str + this.intro;
|
|
1716
1451
|
return this;
|
|
1717
1452
|
}
|
|
1718
|
-
|
|
1719
1453
|
toString() {
|
|
1720
|
-
const body = this.sources
|
|
1721
|
-
.
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
return str;
|
|
1726
|
-
})
|
|
1727
|
-
.join('');
|
|
1728
|
-
|
|
1454
|
+
const body = this.sources.map((source, i) => {
|
|
1455
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
1456
|
+
return (i > 0 ? separator : "") + source.content.toString();
|
|
1457
|
+
}).join("");
|
|
1729
1458
|
return this.intro + body;
|
|
1730
1459
|
}
|
|
1731
|
-
|
|
1732
1460
|
isEmpty() {
|
|
1733
1461
|
if (this.intro.length && this.intro.trim()) return false;
|
|
1734
1462
|
if (this.sources.some((source) => !source.content.isEmpty())) return false;
|
|
1735
1463
|
return true;
|
|
1736
1464
|
}
|
|
1737
|
-
|
|
1738
1465
|
length() {
|
|
1739
|
-
return this.sources.reduce(
|
|
1740
|
-
(length, source) => length + source.content.length(),
|
|
1741
|
-
this.intro.length,
|
|
1742
|
-
);
|
|
1466
|
+
return this.sources.reduce((length, source) => length + source.content.length(), this.intro.length);
|
|
1743
1467
|
}
|
|
1744
|
-
|
|
1745
1468
|
trimLines() {
|
|
1746
|
-
return this.trim(
|
|
1469
|
+
return this.trim("[\\r\\n]");
|
|
1747
1470
|
}
|
|
1748
|
-
|
|
1749
1471
|
trim(charType) {
|
|
1750
1472
|
return this.trimStart(charType).trimEnd(charType);
|
|
1751
1473
|
}
|
|
1752
|
-
|
|
1753
1474
|
trimStart(charType) {
|
|
1754
|
-
const rx = new RegExp(
|
|
1755
|
-
this.intro = this.intro.replace(rx,
|
|
1756
|
-
|
|
1475
|
+
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
1476
|
+
this.intro = this.intro.replace(rx, "");
|
|
1757
1477
|
if (!this.intro) {
|
|
1758
1478
|
let source;
|
|
1759
1479
|
let i = 0;
|
|
1760
|
-
|
|
1761
1480
|
do {
|
|
1762
1481
|
source = this.sources[i++];
|
|
1763
|
-
if (!source)
|
|
1764
|
-
break;
|
|
1765
|
-
}
|
|
1482
|
+
if (!source) break;
|
|
1766
1483
|
} while (!source.content.trimStartAborted(charType));
|
|
1767
1484
|
}
|
|
1768
|
-
|
|
1769
1485
|
return this;
|
|
1770
1486
|
}
|
|
1771
|
-
|
|
1772
1487
|
trimEnd(charType) {
|
|
1773
|
-
const rx = new RegExp(
|
|
1774
|
-
|
|
1488
|
+
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
1775
1489
|
let source;
|
|
1776
1490
|
let i = this.sources.length - 1;
|
|
1777
|
-
|
|
1778
1491
|
do {
|
|
1779
1492
|
source = this.sources[i--];
|
|
1780
1493
|
if (!source) {
|
|
1781
|
-
this.intro = this.intro.replace(rx,
|
|
1494
|
+
this.intro = this.intro.replace(rx, "");
|
|
1782
1495
|
break;
|
|
1783
1496
|
}
|
|
1784
1497
|
} while (!source.content.trimEndAborted(charType));
|
|
1785
|
-
|
|
1786
1498
|
return this;
|
|
1787
1499
|
}
|
|
1788
1500
|
};
|
|
@@ -2558,13 +2270,14 @@ const RESERVED_NAMES = new Set([
|
|
|
2558
2270
|
]);
|
|
2559
2271
|
|
|
2560
2272
|
const illegalCharacters = /[^\w$]/g;
|
|
2273
|
+
const illegalCharacter = /[^\w$]/;
|
|
2561
2274
|
const startsWithDigit = (value) => /\d/.test(value[0]);
|
|
2562
2275
|
const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES.has(value) || value === 'arguments';
|
|
2563
2276
|
function isLegal(value) {
|
|
2564
2277
|
if (needsEscape(value)) {
|
|
2565
2278
|
return false;
|
|
2566
2279
|
}
|
|
2567
|
-
return !
|
|
2280
|
+
return !illegalCharacter.test(value);
|
|
2568
2281
|
}
|
|
2569
2282
|
function makeLegal(value) {
|
|
2570
2283
|
value = value
|
|
@@ -5340,12 +5053,12 @@ class IdentifierBase extends NodeBase {
|
|
|
5340
5053
|
this.variable.module.hasTreeShakingPassStarted)) {
|
|
5341
5054
|
return (this.isTDZAccess = false);
|
|
5342
5055
|
}
|
|
5343
|
-
let
|
|
5056
|
+
let declaration_id;
|
|
5344
5057
|
if (this.variable.declarations &&
|
|
5345
5058
|
this.variable.declarations.length === 1 &&
|
|
5346
|
-
(
|
|
5347
|
-
this.start <
|
|
5348
|
-
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(
|
|
5059
|
+
(declaration_id = this.variable.declarations[0]) &&
|
|
5060
|
+
this.start < declaration_id.start &&
|
|
5061
|
+
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(declaration_id)) {
|
|
5349
5062
|
// a variable accessed before its declaration
|
|
5350
5063
|
// in the same function or at top level of module
|
|
5351
5064
|
return (this.isTDZAccess = true);
|
|
@@ -8239,13 +7952,13 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
8239
7952
|
}
|
|
8240
7953
|
let exportBlock = '';
|
|
8241
7954
|
if (namedExportsMode) {
|
|
8242
|
-
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode:
|
|
7955
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
8243
7956
|
if (!reexports) {
|
|
8244
7957
|
continue;
|
|
8245
7958
|
}
|
|
8246
7959
|
for (const specifier of reexports) {
|
|
8247
7960
|
if (specifier.reexported !== '*') {
|
|
8248
|
-
const importName = getReexportedImportName(name, specifier.imported,
|
|
7961
|
+
const importName = getReexportedImportName(name, specifier.imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
8249
7962
|
if (exportBlock)
|
|
8250
7963
|
exportBlock += n;
|
|
8251
7964
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
@@ -8324,14 +8037,14 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
|
|
|
8324
8037
|
return exports[0].local;
|
|
8325
8038
|
}
|
|
8326
8039
|
else {
|
|
8327
|
-
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode:
|
|
8040
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
8328
8041
|
if (reexports) {
|
|
8329
|
-
return getReexportedImportName(name, reexports[0].imported,
|
|
8042
|
+
return getReexportedImportName(name, reexports[0].imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
8330
8043
|
}
|
|
8331
8044
|
}
|
|
8332
8045
|
}
|
|
8333
8046
|
}
|
|
8334
|
-
function getReexportedImportName(moduleVariableName, imported,
|
|
8047
|
+
function getReexportedImportName(moduleVariableName, imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
|
|
8335
8048
|
if (imported === 'default') {
|
|
8336
8049
|
if (!isChunk) {
|
|
8337
8050
|
const moduleInterop = interop(moduleId);
|
|
@@ -8342,12 +8055,14 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
|
|
|
8342
8055
|
? `${variableName}${getPropertyAccess('default')}`
|
|
8343
8056
|
: variableName;
|
|
8344
8057
|
}
|
|
8345
|
-
return
|
|
8058
|
+
return dependencyNamedExportsMode
|
|
8346
8059
|
? `${moduleVariableName}${getPropertyAccess('default')}`
|
|
8347
8060
|
: moduleVariableName;
|
|
8348
8061
|
}
|
|
8349
8062
|
if (imported === '*') {
|
|
8350
|
-
return (isChunk
|
|
8063
|
+
return (isChunk
|
|
8064
|
+
? !dependencyNamedExportsMode
|
|
8065
|
+
: namespaceInteropHelpersByInteropType[interop(moduleId)])
|
|
8351
8066
|
? namespaceVariableName
|
|
8352
8067
|
: moduleVariableName;
|
|
8353
8068
|
}
|
|
@@ -8572,6 +8287,7 @@ const builtinModules = [
|
|
|
8572
8287
|
"util/types",
|
|
8573
8288
|
"node:v8",
|
|
8574
8289
|
"v8",
|
|
8290
|
+
"node:vfs",
|
|
8575
8291
|
"node:vm",
|
|
8576
8292
|
"vm",
|
|
8577
8293
|
"node:wasi",
|
|
@@ -8861,7 +8577,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultE
|
|
|
8861
8577
|
}
|
|
8862
8578
|
warnOnBuiltins(log, dependencies);
|
|
8863
8579
|
const external = trimEmptyImports(dependencies);
|
|
8864
|
-
const deps = external.map(
|
|
8580
|
+
const deps = external.map(dependency => dependency.globalName || 'null');
|
|
8865
8581
|
const parameters = external.map(m => m.name);
|
|
8866
8582
|
if (hasExports && !name) {
|
|
8867
8583
|
log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
|
|
@@ -9082,21 +8798,21 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
9082
8798
|
}
|
|
9083
8799
|
throwOnPhase('umd', id, dependencies);
|
|
9084
8800
|
warnOnBuiltins(log, dependencies);
|
|
9085
|
-
const
|
|
9086
|
-
const
|
|
8801
|
+
const amdDependencies = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
8802
|
+
const cjsDependencies = dependencies.map(m => `require('${m.importPath}')`);
|
|
9087
8803
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
9088
|
-
const
|
|
8804
|
+
const globalDependencies = trimmedImports.map(module => globalProperty(module.globalName, globalVariable, getPropertyAccess));
|
|
9089
8805
|
const factoryParameters = trimmedImports.map(m => m.name);
|
|
9090
8806
|
if ((hasExports || noConflict) &&
|
|
9091
8807
|
(namedExportsMode || (hasExports && exports[0]?.local === 'exports.default'))) {
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
8808
|
+
amdDependencies.unshift(`'exports'`);
|
|
8809
|
+
cjsDependencies.unshift(`exports`);
|
|
8810
|
+
globalDependencies.unshift(assignToDeepVariable(name, globalVariable, globals, `${extend ? `${globalProperty(name, globalVariable, getPropertyAccess)}${_}||${_}` : ''}{}`, snippets, log));
|
|
9095
8811
|
factoryParameters.unshift('exports');
|
|
9096
8812
|
}
|
|
9097
8813
|
const completeAmdId = getCompleteAmdId(amd, id);
|
|
9098
8814
|
const amdParameters = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
9099
|
-
(
|
|
8815
|
+
(amdDependencies.length > 0 ? `[${amdDependencies.join(`,${_}`)}],${_}` : ``);
|
|
9100
8816
|
const define = amd.define;
|
|
9101
8817
|
const cjsExport = !namedExportsMode && hasExports ? `module.exports${_}=${_}` : ``;
|
|
9102
8818
|
const useStrict = strict ? `${_}'use strict';${n}` : ``;
|
|
@@ -9105,13 +8821,13 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
9105
8821
|
const noConflictExportsVariable = compact ? 'e' : 'exports';
|
|
9106
8822
|
let factory;
|
|
9107
8823
|
if (!namedExportsMode && hasExports) {
|
|
9108
|
-
factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${
|
|
8824
|
+
factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${globalDependencies.join(`,${_}`)})`, snippets, log)};`;
|
|
9109
8825
|
}
|
|
9110
8826
|
else {
|
|
9111
|
-
const module =
|
|
8827
|
+
const module = globalDependencies.shift();
|
|
9112
8828
|
factory =
|
|
9113
8829
|
`${cnst} ${noConflictExportsVariable}${_}=${_}${module};${n}` +
|
|
9114
|
-
`${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...
|
|
8830
|
+
`${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...globalDependencies].join(`,${_}`)});`;
|
|
9115
8831
|
}
|
|
9116
8832
|
iifeExport =
|
|
9117
8833
|
`(${getFunctionIntro([], { isAsync: false, name: null })}{${n}` +
|
|
@@ -9125,12 +8841,12 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
9125
8841
|
`${t}})()`;
|
|
9126
8842
|
}
|
|
9127
8843
|
else {
|
|
9128
|
-
iifeExport = `${factoryVariable}(${
|
|
8844
|
+
iifeExport = `${factoryVariable}(${globalDependencies.join(`,${_}`)})`;
|
|
9129
8845
|
if (!namedExportsMode && hasExports) {
|
|
9130
8846
|
iifeExport = assignToDeepVariable(name, globalVariable, globals, iifeExport, snippets, log);
|
|
9131
8847
|
}
|
|
9132
8848
|
}
|
|
9133
|
-
const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) ||
|
|
8849
|
+
const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) || globalDependencies.length > 0;
|
|
9134
8850
|
const wrapperParameters = [factoryVariable];
|
|
9135
8851
|
if (iifeNeedsGlobal) {
|
|
9136
8852
|
wrapperParameters.unshift(globalVariable);
|
|
@@ -9142,7 +8858,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
9142
8858
|
const iifeEnd = iifeNeedsGlobal ? ')' : '';
|
|
9143
8859
|
const cjsIntro = iifeNeedsGlobal
|
|
9144
8860
|
? `${t}typeof exports${_}===${_}'object'${_}&&${_}typeof module${_}!==${_}'undefined'${_}?` +
|
|
9145
|
-
`${_}${cjsExport}${factoryVariable}(${
|
|
8861
|
+
`${_}${cjsExport}${factoryVariable}(${cjsDependencies.join(`,${_}`)})${_}:${n}`
|
|
9146
8862
|
: '';
|
|
9147
8863
|
const wrapperIntro = `(${getNonArrowFunctionIntro(wrapperParameters, { isAsync: false, name: null })}{${n}` +
|
|
9148
8864
|
cjsIntro +
|
|
@@ -10109,7 +9825,15 @@ function requireParse () {
|
|
|
10109
9825
|
}
|
|
10110
9826
|
};
|
|
10111
9827
|
|
|
10112
|
-
const
|
|
9828
|
+
const buildCharClassStar = chars => {
|
|
9829
|
+
const source = chars.length === 1
|
|
9830
|
+
? utils.escapeRegex(chars[0])
|
|
9831
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
9832
|
+
|
|
9833
|
+
return `${source}*`;
|
|
9834
|
+
};
|
|
9835
|
+
|
|
9836
|
+
const getStarExtglobSequenceChars = pattern => {
|
|
10113
9837
|
let index = 0;
|
|
10114
9838
|
const chars = [];
|
|
10115
9839
|
|
|
@@ -10138,11 +9862,7 @@ function requireParse () {
|
|
|
10138
9862
|
return;
|
|
10139
9863
|
}
|
|
10140
9864
|
|
|
10141
|
-
|
|
10142
|
-
? utils.escapeRegex(chars[0])
|
|
10143
|
-
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
10144
|
-
|
|
10145
|
-
return `${source}*`;
|
|
9865
|
+
return chars;
|
|
10146
9866
|
};
|
|
10147
9867
|
|
|
10148
9868
|
const repeatedExtglobRecursion = pattern => {
|
|
@@ -10181,17 +9901,43 @@ function requireParse () {
|
|
|
10181
9901
|
}
|
|
10182
9902
|
}
|
|
10183
9903
|
|
|
9904
|
+
// A repeated extglob is "risky" (prone to catastrophic backtracking) when a
|
|
9905
|
+
// branch is itself a `*(...)` sequence, since that nests an unbounded quantifier
|
|
9906
|
+
// inside the outer `+(...)`/`*(...)`. When *every* branch reduces to single
|
|
9907
|
+
// characters we can emit one flat, ReDoS-safe character class that preserves the
|
|
9908
|
+
// meaning of ALL branches (e.g. `+(*(a)|*(b))` -> `[ab]*`), rather than dropping
|
|
9909
|
+
// every branch but the first.
|
|
9910
|
+
const safeChars = [];
|
|
9911
|
+
let sawStarSequence = false;
|
|
9912
|
+
let combinable = true;
|
|
9913
|
+
|
|
10184
9914
|
for (const branch of branches) {
|
|
10185
|
-
const
|
|
10186
|
-
if (
|
|
10187
|
-
|
|
9915
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
9916
|
+
if (chars) {
|
|
9917
|
+
sawStarSequence = true;
|
|
9918
|
+
safeChars.push(...chars);
|
|
9919
|
+
continue;
|
|
10188
9920
|
}
|
|
10189
9921
|
|
|
9922
|
+
const literal = normalizeSimpleBranch(branch);
|
|
9923
|
+
if (literal && literal.length === 1) {
|
|
9924
|
+
safeChars.push(literal);
|
|
9925
|
+
continue;
|
|
9926
|
+
}
|
|
9927
|
+
|
|
9928
|
+
combinable = false;
|
|
9929
|
+
|
|
10190
9930
|
if (repeatedExtglobRecursion(branch) > max) {
|
|
10191
9931
|
return { risky: true };
|
|
10192
9932
|
}
|
|
10193
9933
|
}
|
|
10194
9934
|
|
|
9935
|
+
if (sawStarSequence) {
|
|
9936
|
+
return combinable
|
|
9937
|
+
? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) }
|
|
9938
|
+
: { risky: true };
|
|
9939
|
+
}
|
|
9940
|
+
|
|
10195
9941
|
return { risky: false };
|
|
10196
9942
|
};
|
|
10197
9943
|
|
|
@@ -11293,6 +11039,18 @@ function requirePicomatch$1 () {
|
|
|
11293
11039
|
* const isMatch = picomatch('*.!(*a)');
|
|
11294
11040
|
* console.log(isMatch('a.a')); //=> false
|
|
11295
11041
|
* console.log(isMatch('a.b')); //=> true
|
|
11042
|
+
*
|
|
11043
|
+
* // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
|
|
11044
|
+
* const picomatch = require('picomatch/posix');
|
|
11045
|
+
* // the same API, defaulting to posix paths
|
|
11046
|
+
* const isMatch = picomatch('a/*');
|
|
11047
|
+
* console.log(isMatch('a\\b')); //=> false
|
|
11048
|
+
* console.log(isMatch('a/b')); //=> true
|
|
11049
|
+
*
|
|
11050
|
+
* // you can still configure the matcher function to accept windows paths
|
|
11051
|
+
* const isMatch = picomatch('a/*', { options: windows });
|
|
11052
|
+
* console.log(isMatch('a\\b')); //=> true
|
|
11053
|
+
* console.log(isMatch('a/b')); //=> true
|
|
11296
11054
|
* ```
|
|
11297
11055
|
* @name picomatch
|
|
11298
11056
|
* @param {String|Array} `globs` One or more glob patterns.
|
|
@@ -11430,9 +11188,9 @@ function requirePicomatch$1 () {
|
|
|
11430
11188
|
* @api public
|
|
11431
11189
|
*/
|
|
11432
11190
|
|
|
11433
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
11191
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
11434
11192
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
11435
|
-
return regex.test(utils.basename(input));
|
|
11193
|
+
return regex.test(utils.basename(input, { windows: posix }));
|
|
11436
11194
|
};
|
|
11437
11195
|
|
|
11438
11196
|
/**
|
|
@@ -13683,19 +13441,19 @@ class ImportExpression extends NodeBase {
|
|
|
13683
13441
|
return null;
|
|
13684
13442
|
const chunkInfos = [];
|
|
13685
13443
|
const importerPath = ownChunk.getFileName();
|
|
13686
|
-
for (const
|
|
13687
|
-
const resolvedImportPath = `'${
|
|
13688
|
-
if (
|
|
13444
|
+
for (const dependency of targetChunk.dependencies) {
|
|
13445
|
+
const resolvedImportPath = `'${dependency.getImportPath(importerPath)}'`;
|
|
13446
|
+
if (dependency instanceof ExternalChunk) {
|
|
13689
13447
|
chunkInfos.push({
|
|
13690
|
-
fileName:
|
|
13448
|
+
fileName: dependency.getFileName(),
|
|
13691
13449
|
resolvedImportPath,
|
|
13692
13450
|
type: 'external'
|
|
13693
13451
|
});
|
|
13694
13452
|
}
|
|
13695
13453
|
else {
|
|
13696
13454
|
chunkInfos.push({
|
|
13697
|
-
chunk:
|
|
13698
|
-
fileName:
|
|
13455
|
+
chunk: dependency.getPreRenderedChunkInfo(),
|
|
13456
|
+
fileName: dependency.getFileName(),
|
|
13699
13457
|
resolvedImportPath,
|
|
13700
13458
|
type: 'internal'
|
|
13701
13459
|
});
|
|
@@ -18993,9 +18751,9 @@ class Chunk {
|
|
|
18993
18751
|
// for static and dynamic entry points, add transitive dependencies to this
|
|
18994
18752
|
// chunk's dependencies to avoid loading latency
|
|
18995
18753
|
if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
|
|
18996
|
-
for (const
|
|
18997
|
-
if (
|
|
18998
|
-
this.inlineChunkDependencies(
|
|
18754
|
+
for (const dependency of dependencies) {
|
|
18755
|
+
if (dependency instanceof Chunk)
|
|
18756
|
+
this.inlineChunkDependencies(dependency);
|
|
18999
18757
|
}
|
|
19000
18758
|
}
|
|
19001
18759
|
}
|
|
@@ -19167,11 +18925,11 @@ class Chunk {
|
|
|
19167
18925
|
if (!chunk || format !== 'es') {
|
|
19168
18926
|
continue;
|
|
19169
18927
|
}
|
|
19170
|
-
const
|
|
19171
|
-
if (!
|
|
18928
|
+
const chunkDependency = this.renderedDependencies.get(chunk);
|
|
18929
|
+
if (!chunkDependency) {
|
|
19172
18930
|
continue;
|
|
19173
18931
|
}
|
|
19174
|
-
const { imports, reexports } =
|
|
18932
|
+
const { imports, reexports } = chunkDependency;
|
|
19175
18933
|
const importedByReexported = reexports?.find(({ reexported }) => reexported === exportName);
|
|
19176
18934
|
const isImported = imports?.find(({ imported }) => imported === importedByReexported?.imported);
|
|
19177
18935
|
if (!isImported) {
|
|
@@ -19381,6 +19139,10 @@ class Chunk {
|
|
|
19381
19139
|
return predefinedChunkName;
|
|
19382
19140
|
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
19383
19141
|
const sanitizedId = sanitizeFileName(normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
|
|
19142
|
+
// The module id was sanitized, so the base must be sanitized as well before
|
|
19143
|
+
// comparing paths; otherwise ids containing sanitized characters escape the
|
|
19144
|
+
// base via "../" and trip the placeholder validation (#5446).
|
|
19145
|
+
const sanitizedBase = sanitizeFileName(this.inputBase);
|
|
19384
19146
|
const extensionName = extname(sanitizedId);
|
|
19385
19147
|
const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
|
|
19386
19148
|
? sanitizedId.slice(0, -extensionName.length)
|
|
@@ -19391,10 +19153,10 @@ class Chunk {
|
|
|
19391
19153
|
}
|
|
19392
19154
|
else {
|
|
19393
19155
|
// handle edge case in Windows
|
|
19394
|
-
if (
|
|
19395
|
-
return relative$1(
|
|
19156
|
+
if (sanitizedBase === '/' && idWithoutExtension[0] !== '/') {
|
|
19157
|
+
return relative$1(sanitizedBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/'));
|
|
19396
19158
|
}
|
|
19397
|
-
return relative$1(
|
|
19159
|
+
return relative$1(sanitizedBase, idWithoutExtension);
|
|
19398
19160
|
}
|
|
19399
19161
|
}
|
|
19400
19162
|
else {
|
|
@@ -19509,12 +19271,12 @@ class Chunk {
|
|
|
19509
19271
|
return (this.renderedDependencies = renderedDependencies);
|
|
19510
19272
|
}
|
|
19511
19273
|
inlineChunkDependencies(chunk) {
|
|
19512
|
-
for (const
|
|
19513
|
-
if (this.dependencies.has(
|
|
19274
|
+
for (const dependency of chunk.dependencies) {
|
|
19275
|
+
if (this.dependencies.has(dependency))
|
|
19514
19276
|
continue;
|
|
19515
|
-
this.dependencies.add(
|
|
19516
|
-
if (
|
|
19517
|
-
this.inlineChunkDependencies(
|
|
19277
|
+
this.dependencies.add(dependency);
|
|
19278
|
+
if (dependency instanceof Chunk) {
|
|
19279
|
+
this.inlineChunkDependencies(dependency);
|
|
19518
19280
|
}
|
|
19519
19281
|
}
|
|
19520
19282
|
}
|
|
@@ -20988,7 +20750,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
20988
20750
|
finalSourcemapFileName = sourcemapFileName
|
|
20989
20751
|
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
20990
20752
|
: `${finalFileName}.map`;
|
|
20991
|
-
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
20753
|
+
map.file = replacePlaceholders(map.file ?? '', hashesByPlaceholder);
|
|
20992
20754
|
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
20993
20755
|
}
|
|
20994
20756
|
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
@@ -21766,7 +21528,6 @@ async function transform(source, module, pluginDriver, options) {
|
|
|
21766
21528
|
}
|
|
21767
21529
|
return new SourceMap({
|
|
21768
21530
|
...combinedMap,
|
|
21769
|
-
file: null,
|
|
21770
21531
|
sourcesContent: combinedMap.sourcesContent
|
|
21771
21532
|
});
|
|
21772
21533
|
},
|
|
@@ -22668,7 +22429,7 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
|
22668
22429
|
};
|
|
22669
22430
|
}
|
|
22670
22431
|
|
|
22671
|
-
const rollupVersion$2 =
|
|
22432
|
+
const rollupVersion$2 = pkg.version;
|
|
22672
22433
|
function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
|
|
22673
22434
|
const { logLevel, onLog } = options;
|
|
22674
22435
|
let cacheable = true;
|
|
@@ -23390,7 +23151,7 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
|
|
|
23390
23151
|
|
|
23391
23152
|
async function initWasm() { }
|
|
23392
23153
|
|
|
23393
|
-
const rollupVersion$1 =
|
|
23154
|
+
const rollupVersion$1 = pkg.version;
|
|
23394
23155
|
function getLogger(plugins, onLog, watchMode, logLevel) {
|
|
23395
23156
|
plugins = getSortedValidatedPlugins('onLog', plugins);
|
|
23396
23157
|
const minimalPriority = logLevelPriority[logLevel];
|
|
@@ -23886,7 +23647,7 @@ const getSourcemapBaseUrl = (config) => {
|
|
|
23886
23647
|
}
|
|
23887
23648
|
};
|
|
23888
23649
|
|
|
23889
|
-
const rollupVersion =
|
|
23650
|
+
const rollupVersion = pkg.version;
|
|
23890
23651
|
// @ts-expect-error TS2540: the polyfill of `asyncDispose`.
|
|
23891
23652
|
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
|
|
23892
23653
|
function rollup(rawInputOptions) {
|
|
@@ -24521,6 +24282,6 @@ async function watchInternal(configs, emitter) {
|
|
|
24521
24282
|
new Watcher(watchOptionsList, emitter);
|
|
24522
24283
|
}
|
|
24523
24284
|
|
|
24524
|
-
const VERSION =
|
|
24285
|
+
const VERSION = pkg.version;
|
|
24525
24286
|
|
|
24526
24287
|
export { VERSION, createFilter$1 as createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, watch };
|