@m2c2kit/build-helpers 0.3.17 → 0.3.18
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/index.js +91 -1418
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5300,17 +5300,17 @@ const selectAll = getSelectorFunc((query, elems, options) => query === boolbase$
|
|
|
5300
5300
|
? []
|
|
5301
5301
|
: options.adapter.findAll(query, elems));
|
|
5302
5302
|
|
|
5303
|
-
const comma
|
|
5304
|
-
const semicolon
|
|
5305
|
-
const chars$
|
|
5306
|
-
const intToChar
|
|
5307
|
-
const charToInt
|
|
5308
|
-
for (let i = 0; i < chars$
|
|
5309
|
-
const c = chars$
|
|
5310
|
-
intToChar
|
|
5311
|
-
charToInt
|
|
5312
|
-
}
|
|
5313
|
-
function encodeInteger
|
|
5303
|
+
const comma = ','.charCodeAt(0);
|
|
5304
|
+
const semicolon = ';'.charCodeAt(0);
|
|
5305
|
+
const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
5306
|
+
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
5307
|
+
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
5308
|
+
for (let i = 0; i < chars$1.length; i++) {
|
|
5309
|
+
const c = chars$1.charCodeAt(i);
|
|
5310
|
+
intToChar[i] = c;
|
|
5311
|
+
charToInt[c] = i;
|
|
5312
|
+
}
|
|
5313
|
+
function encodeInteger(builder, num, relative) {
|
|
5314
5314
|
let delta = num - relative;
|
|
5315
5315
|
delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
|
|
5316
5316
|
do {
|
|
@@ -5318,14 +5318,14 @@ function encodeInteger$1(builder, num, relative) {
|
|
|
5318
5318
|
delta >>>= 5;
|
|
5319
5319
|
if (delta > 0)
|
|
5320
5320
|
clamped |= 0b100000;
|
|
5321
|
-
builder.write(intToChar
|
|
5321
|
+
builder.write(intToChar[clamped]);
|
|
5322
5322
|
} while (delta > 0);
|
|
5323
5323
|
return num;
|
|
5324
5324
|
}
|
|
5325
5325
|
|
|
5326
5326
|
const bufLength = 1024 * 16;
|
|
5327
5327
|
// Provide a fallback for older environments.
|
|
5328
|
-
const td
|
|
5328
|
+
const td = typeof TextDecoder !== 'undefined'
|
|
5329
5329
|
? /* #__PURE__ */ new TextDecoder()
|
|
5330
5330
|
: typeof Buffer !== 'undefined'
|
|
5331
5331
|
? {
|
|
@@ -5353,16 +5353,16 @@ class StringWriter {
|
|
|
5353
5353
|
const { buffer } = this;
|
|
5354
5354
|
buffer[this.pos++] = v;
|
|
5355
5355
|
if (this.pos === bufLength) {
|
|
5356
|
-
this.out += td
|
|
5356
|
+
this.out += td.decode(buffer);
|
|
5357
5357
|
this.pos = 0;
|
|
5358
5358
|
}
|
|
5359
5359
|
}
|
|
5360
5360
|
flush() {
|
|
5361
5361
|
const { buffer, out, pos } = this;
|
|
5362
|
-
return pos > 0 ? out + td
|
|
5362
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
5363
5363
|
}
|
|
5364
5364
|
}
|
|
5365
|
-
function encode
|
|
5365
|
+
function encode(decoded) {
|
|
5366
5366
|
const writer = new StringWriter();
|
|
5367
5367
|
let sourcesIndex = 0;
|
|
5368
5368
|
let sourceLine = 0;
|
|
@@ -5371,29 +5371,29 @@ function encode$1(decoded) {
|
|
|
5371
5371
|
for (let i = 0; i < decoded.length; i++) {
|
|
5372
5372
|
const line = decoded[i];
|
|
5373
5373
|
if (i > 0)
|
|
5374
|
-
writer.write(semicolon
|
|
5374
|
+
writer.write(semicolon);
|
|
5375
5375
|
if (line.length === 0)
|
|
5376
5376
|
continue;
|
|
5377
5377
|
let genColumn = 0;
|
|
5378
5378
|
for (let j = 0; j < line.length; j++) {
|
|
5379
5379
|
const segment = line[j];
|
|
5380
5380
|
if (j > 0)
|
|
5381
|
-
writer.write(comma
|
|
5382
|
-
genColumn = encodeInteger
|
|
5381
|
+
writer.write(comma);
|
|
5382
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
5383
5383
|
if (segment.length === 1)
|
|
5384
5384
|
continue;
|
|
5385
|
-
sourcesIndex = encodeInteger
|
|
5386
|
-
sourceLine = encodeInteger
|
|
5387
|
-
sourceColumn = encodeInteger
|
|
5385
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
5386
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
5387
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
5388
5388
|
if (segment.length === 4)
|
|
5389
5389
|
continue;
|
|
5390
|
-
namesIndex = encodeInteger
|
|
5390
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
5391
5391
|
}
|
|
5392
5392
|
}
|
|
5393
5393
|
return writer.flush();
|
|
5394
5394
|
}
|
|
5395
5395
|
|
|
5396
|
-
|
|
5396
|
+
class BitSet {
|
|
5397
5397
|
constructor(arg) {
|
|
5398
5398
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
5399
5399
|
}
|
|
@@ -5405,9 +5405,9 @@ let BitSet$1 = class BitSet {
|
|
|
5405
5405
|
has(n) {
|
|
5406
5406
|
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
5407
5407
|
}
|
|
5408
|
-
}
|
|
5408
|
+
}
|
|
5409
5409
|
|
|
5410
|
-
|
|
5410
|
+
class Chunk {
|
|
5411
5411
|
constructor(start, end, content) {
|
|
5412
5412
|
this.start = start;
|
|
5413
5413
|
this.end = end;
|
|
@@ -5584,9 +5584,9 @@ let Chunk$1 = class Chunk {
|
|
|
5584
5584
|
if (this.outro.length) return true;
|
|
5585
5585
|
}
|
|
5586
5586
|
}
|
|
5587
|
-
}
|
|
5587
|
+
}
|
|
5588
5588
|
|
|
5589
|
-
function getBtoa
|
|
5589
|
+
function getBtoa() {
|
|
5590
5590
|
if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
|
|
5591
5591
|
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
5592
5592
|
} else if (typeof Buffer === 'function') {
|
|
@@ -5598,16 +5598,16 @@ function getBtoa$1() {
|
|
|
5598
5598
|
}
|
|
5599
5599
|
}
|
|
5600
5600
|
|
|
5601
|
-
const btoa
|
|
5601
|
+
const btoa = /*#__PURE__*/ getBtoa();
|
|
5602
5602
|
|
|
5603
|
-
|
|
5603
|
+
class SourceMap {
|
|
5604
5604
|
constructor(properties) {
|
|
5605
5605
|
this.version = 3;
|
|
5606
5606
|
this.file = properties.file;
|
|
5607
5607
|
this.sources = properties.sources;
|
|
5608
5608
|
this.sourcesContent = properties.sourcesContent;
|
|
5609
5609
|
this.names = properties.names;
|
|
5610
|
-
this.mappings = encode
|
|
5610
|
+
this.mappings = encode(properties.mappings);
|
|
5611
5611
|
if (typeof properties.x_google_ignoreList !== 'undefined') {
|
|
5612
5612
|
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
5613
5613
|
}
|
|
@@ -5618,11 +5618,11 @@ let SourceMap$1 = class SourceMap {
|
|
|
5618
5618
|
}
|
|
5619
5619
|
|
|
5620
5620
|
toUrl() {
|
|
5621
|
-
return 'data:application/json;charset=utf-8;base64,' + btoa
|
|
5621
|
+
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
5622
5622
|
}
|
|
5623
|
-
}
|
|
5623
|
+
}
|
|
5624
5624
|
|
|
5625
|
-
function guessIndent
|
|
5625
|
+
function guessIndent(code) {
|
|
5626
5626
|
const lines = code.split('\n');
|
|
5627
5627
|
|
|
5628
5628
|
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
@@ -5648,7 +5648,7 @@ function guessIndent$1(code) {
|
|
|
5648
5648
|
return new Array(min + 1).join(' ');
|
|
5649
5649
|
}
|
|
5650
5650
|
|
|
5651
|
-
function getRelativePath
|
|
5651
|
+
function getRelativePath(from, to) {
|
|
5652
5652
|
const fromParts = from.split(/[/\\]/);
|
|
5653
5653
|
const toParts = to.split(/[/\\]/);
|
|
5654
5654
|
|
|
@@ -5667,13 +5667,13 @@ function getRelativePath$1(from, to) {
|
|
|
5667
5667
|
return fromParts.concat(toParts).join('/');
|
|
5668
5668
|
}
|
|
5669
5669
|
|
|
5670
|
-
const toString
|
|
5670
|
+
const toString = Object.prototype.toString;
|
|
5671
5671
|
|
|
5672
|
-
function isObject$
|
|
5673
|
-
return toString
|
|
5672
|
+
function isObject$3(thing) {
|
|
5673
|
+
return toString.call(thing) === '[object Object]';
|
|
5674
5674
|
}
|
|
5675
5675
|
|
|
5676
|
-
function getLocator
|
|
5676
|
+
function getLocator(source) {
|
|
5677
5677
|
const originalLines = source.split('\n');
|
|
5678
5678
|
const lineOffsets = [];
|
|
5679
5679
|
|
|
@@ -5699,9 +5699,9 @@ function getLocator$1(source) {
|
|
|
5699
5699
|
};
|
|
5700
5700
|
}
|
|
5701
5701
|
|
|
5702
|
-
const wordRegex
|
|
5702
|
+
const wordRegex = /\w/;
|
|
5703
5703
|
|
|
5704
|
-
|
|
5704
|
+
class Mappings {
|
|
5705
5705
|
constructor(hires) {
|
|
5706
5706
|
this.hires = hires;
|
|
5707
5707
|
this.generatedCodeLine = 0;
|
|
@@ -5760,7 +5760,7 @@ let Mappings$1 = class Mappings {
|
|
|
5760
5760
|
|
|
5761
5761
|
if (this.hires === 'boundary') {
|
|
5762
5762
|
// in hires "boundary", group segments per word boundary than per char
|
|
5763
|
-
if (wordRegex
|
|
5763
|
+
if (wordRegex.test(original[originalCharIndex])) {
|
|
5764
5764
|
// for first char in the boundary found, start the boundary by pushing a segment
|
|
5765
5765
|
if (!charInHiresBoundary) {
|
|
5766
5766
|
this.rawSegments.push(segment);
|
|
@@ -5810,19 +5810,19 @@ let Mappings$1 = class Mappings {
|
|
|
5810
5810
|
|
|
5811
5811
|
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
5812
5812
|
}
|
|
5813
|
-
}
|
|
5813
|
+
}
|
|
5814
5814
|
|
|
5815
|
-
const n
|
|
5815
|
+
const n = '\n';
|
|
5816
5816
|
|
|
5817
|
-
const warned
|
|
5817
|
+
const warned = {
|
|
5818
5818
|
insertLeft: false,
|
|
5819
5819
|
insertRight: false,
|
|
5820
5820
|
storeName: false,
|
|
5821
5821
|
};
|
|
5822
5822
|
|
|
5823
|
-
|
|
5823
|
+
class MagicString {
|
|
5824
5824
|
constructor(string, options = {}) {
|
|
5825
|
-
const chunk = new Chunk
|
|
5825
|
+
const chunk = new Chunk(0, string.length, string);
|
|
5826
5826
|
|
|
5827
5827
|
Object.defineProperties(this, {
|
|
5828
5828
|
original: { writable: true, value: string },
|
|
@@ -5835,7 +5835,7 @@ let MagicString$1 = class MagicString {
|
|
|
5835
5835
|
byEnd: { writable: true, value: {} },
|
|
5836
5836
|
filename: { writable: true, value: options.filename },
|
|
5837
5837
|
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
5838
|
-
sourcemapLocations: { writable: true, value: new BitSet
|
|
5838
|
+
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
5839
5839
|
storedNames: { writable: true, value: {} },
|
|
5840
5840
|
indentStr: { writable: true, value: undefined },
|
|
5841
5841
|
ignoreList: { writable: true, value: options.ignoreList },
|
|
@@ -5915,7 +5915,7 @@ let MagicString$1 = class MagicString {
|
|
|
5915
5915
|
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
5916
5916
|
}
|
|
5917
5917
|
|
|
5918
|
-
cloned.sourcemapLocations = new BitSet
|
|
5918
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
5919
5919
|
|
|
5920
5920
|
cloned.intro = this.intro;
|
|
5921
5921
|
cloned.outro = this.outro;
|
|
@@ -5928,9 +5928,9 @@ let MagicString$1 = class MagicString {
|
|
|
5928
5928
|
|
|
5929
5929
|
const sourceIndex = 0;
|
|
5930
5930
|
const names = Object.keys(this.storedNames);
|
|
5931
|
-
const mappings = new Mappings
|
|
5931
|
+
const mappings = new Mappings(options.hires);
|
|
5932
5932
|
|
|
5933
|
-
const locate = getLocator
|
|
5933
|
+
const locate = getLocator(this.original);
|
|
5934
5934
|
|
|
5935
5935
|
if (this.intro) {
|
|
5936
5936
|
mappings.advance(this.intro);
|
|
@@ -5958,7 +5958,7 @@ let MagicString$1 = class MagicString {
|
|
|
5958
5958
|
return {
|
|
5959
5959
|
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
5960
5960
|
sources: [
|
|
5961
|
-
options.source ? getRelativePath
|
|
5961
|
+
options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
|
|
5962
5962
|
],
|
|
5963
5963
|
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
5964
5964
|
names,
|
|
@@ -5968,12 +5968,12 @@ let MagicString$1 = class MagicString {
|
|
|
5968
5968
|
}
|
|
5969
5969
|
|
|
5970
5970
|
generateMap(options) {
|
|
5971
|
-
return new SourceMap
|
|
5971
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
5972
5972
|
}
|
|
5973
5973
|
|
|
5974
5974
|
_ensureindentStr() {
|
|
5975
5975
|
if (this.indentStr === undefined) {
|
|
5976
|
-
this.indentStr = guessIndent
|
|
5976
|
+
this.indentStr = guessIndent(this.original);
|
|
5977
5977
|
}
|
|
5978
5978
|
}
|
|
5979
5979
|
|
|
@@ -5990,7 +5990,7 @@ let MagicString$1 = class MagicString {
|
|
|
5990
5990
|
indent(indentStr, options) {
|
|
5991
5991
|
const pattern = /^[^\r\n]/gm;
|
|
5992
5992
|
|
|
5993
|
-
if (isObject$
|
|
5993
|
+
if (isObject$3(indentStr)) {
|
|
5994
5994
|
options = indentStr;
|
|
5995
5995
|
indentStr = undefined;
|
|
5996
5996
|
}
|
|
@@ -6082,22 +6082,22 @@ let MagicString$1 = class MagicString {
|
|
|
6082
6082
|
}
|
|
6083
6083
|
|
|
6084
6084
|
insertLeft(index, content) {
|
|
6085
|
-
if (!warned
|
|
6085
|
+
if (!warned.insertLeft) {
|
|
6086
6086
|
console.warn(
|
|
6087
6087
|
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
6088
6088
|
); // eslint-disable-line no-console
|
|
6089
|
-
warned
|
|
6089
|
+
warned.insertLeft = true;
|
|
6090
6090
|
}
|
|
6091
6091
|
|
|
6092
6092
|
return this.appendLeft(index, content);
|
|
6093
6093
|
}
|
|
6094
6094
|
|
|
6095
6095
|
insertRight(index, content) {
|
|
6096
|
-
if (!warned
|
|
6096
|
+
if (!warned.insertRight) {
|
|
6097
6097
|
console.warn(
|
|
6098
6098
|
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
6099
6099
|
); // eslint-disable-line no-console
|
|
6100
|
-
warned
|
|
6100
|
+
warned.insertRight = true;
|
|
6101
6101
|
}
|
|
6102
6102
|
|
|
6103
6103
|
return this.prependRight(index, content);
|
|
@@ -6163,11 +6163,11 @@ let MagicString$1 = class MagicString {
|
|
|
6163
6163
|
this._split(end);
|
|
6164
6164
|
|
|
6165
6165
|
if (options === true) {
|
|
6166
|
-
if (!warned
|
|
6166
|
+
if (!warned.storeName) {
|
|
6167
6167
|
console.warn(
|
|
6168
6168
|
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
6169
6169
|
); // eslint-disable-line no-console
|
|
6170
|
-
warned
|
|
6170
|
+
warned.storeName = true;
|
|
6171
6171
|
}
|
|
6172
6172
|
|
|
6173
6173
|
options = { storeName: true };
|
|
@@ -6200,7 +6200,7 @@ let MagicString$1 = class MagicString {
|
|
|
6200
6200
|
first.edit(content, storeName, !overwrite);
|
|
6201
6201
|
} else {
|
|
6202
6202
|
// must be inserting at the end
|
|
6203
|
-
const newChunk = new Chunk
|
|
6203
|
+
const newChunk = new Chunk(start, end, '').edit(content, storeName);
|
|
6204
6204
|
|
|
6205
6205
|
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
6206
6206
|
last.next = newChunk;
|
|
@@ -6309,30 +6309,30 @@ let MagicString$1 = class MagicString {
|
|
|
6309
6309
|
}
|
|
6310
6310
|
|
|
6311
6311
|
lastLine() {
|
|
6312
|
-
let lineIndex = this.outro.lastIndexOf(n
|
|
6312
|
+
let lineIndex = this.outro.lastIndexOf(n);
|
|
6313
6313
|
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
6314
6314
|
let lineStr = this.outro;
|
|
6315
6315
|
let chunk = this.lastChunk;
|
|
6316
6316
|
do {
|
|
6317
6317
|
if (chunk.outro.length > 0) {
|
|
6318
|
-
lineIndex = chunk.outro.lastIndexOf(n
|
|
6318
|
+
lineIndex = chunk.outro.lastIndexOf(n);
|
|
6319
6319
|
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
6320
6320
|
lineStr = chunk.outro + lineStr;
|
|
6321
6321
|
}
|
|
6322
6322
|
|
|
6323
6323
|
if (chunk.content.length > 0) {
|
|
6324
|
-
lineIndex = chunk.content.lastIndexOf(n
|
|
6324
|
+
lineIndex = chunk.content.lastIndexOf(n);
|
|
6325
6325
|
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
6326
6326
|
lineStr = chunk.content + lineStr;
|
|
6327
6327
|
}
|
|
6328
6328
|
|
|
6329
6329
|
if (chunk.intro.length > 0) {
|
|
6330
|
-
lineIndex = chunk.intro.lastIndexOf(n
|
|
6330
|
+
lineIndex = chunk.intro.lastIndexOf(n);
|
|
6331
6331
|
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
6332
6332
|
lineStr = chunk.intro + lineStr;
|
|
6333
6333
|
}
|
|
6334
6334
|
} while ((chunk = chunk.previous));
|
|
6335
|
-
lineIndex = this.intro.lastIndexOf(n
|
|
6335
|
+
lineIndex = this.intro.lastIndexOf(n);
|
|
6336
6336
|
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
6337
6337
|
return this.intro + lineStr;
|
|
6338
6338
|
}
|
|
@@ -6413,7 +6413,7 @@ let MagicString$1 = class MagicString {
|
|
|
6413
6413
|
_splitChunk(chunk, index) {
|
|
6414
6414
|
if (chunk.edited && chunk.content.length) {
|
|
6415
6415
|
// zero-length edited chunks are a special case (overlapping replacements)
|
|
6416
|
-
const loc = getLocator
|
|
6416
|
+
const loc = getLocator(this.original)(index);
|
|
6417
6417
|
throw new Error(
|
|
6418
6418
|
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
6419
6419
|
);
|
|
@@ -6645,7 +6645,7 @@ let MagicString$1 = class MagicString {
|
|
|
6645
6645
|
|
|
6646
6646
|
return this._replaceRegexp(searchValue, replacement);
|
|
6647
6647
|
}
|
|
6648
|
-
}
|
|
6648
|
+
}
|
|
6649
6649
|
|
|
6650
6650
|
const HASH_CHARACTER_LENGTH = 16;
|
|
6651
6651
|
function hashM2c2kitAssets(rootDir, cwd = "") {
|
|
@@ -6654,7 +6654,7 @@ function hashM2c2kitAssets(rootDir, cwd = "") {
|
|
|
6654
6654
|
name: "hash-m2c2kit-assets",
|
|
6655
6655
|
renderChunk: {
|
|
6656
6656
|
handler(code) {
|
|
6657
|
-
const magicString = new MagicString
|
|
6657
|
+
const magicString = new MagicString(code);
|
|
6658
6658
|
magicString.replace(
|
|
6659
6659
|
new RegExp("__NO_M2C2KIT_MANIFEST_JSON_URL__", "g"),
|
|
6660
6660
|
"manifest.json"
|
|
@@ -6859,7 +6859,7 @@ function restoreImportMeta(pattern = "import_meta = {};", replacement = "import_
|
|
|
6859
6859
|
name: "restore-import-meta",
|
|
6860
6860
|
renderChunk: {
|
|
6861
6861
|
handler(code) {
|
|
6862
|
-
const magicString = new MagicString
|
|
6862
|
+
const magicString = new MagicString(code);
|
|
6863
6863
|
magicString.replace(new RegExp(pattern, "g"), replacement);
|
|
6864
6864
|
return {
|
|
6865
6865
|
code: magicString.toString(),
|
|
@@ -10840,7 +10840,7 @@ var isExtglob$1 = function isExtglob(str) {
|
|
|
10840
10840
|
*/
|
|
10841
10841
|
|
|
10842
10842
|
var isExtglob = isExtglob$1;
|
|
10843
|
-
var chars
|
|
10843
|
+
var chars = { '{': '}', '(': ')', '[': ']'};
|
|
10844
10844
|
var strictCheck = function(str) {
|
|
10845
10845
|
if (str[0] === '!') {
|
|
10846
10846
|
return true;
|
|
@@ -10913,7 +10913,7 @@ var strictCheck = function(str) {
|
|
|
10913
10913
|
if (str[index] === '\\') {
|
|
10914
10914
|
var open = str[index + 1];
|
|
10915
10915
|
index += 2;
|
|
10916
|
-
var close = chars
|
|
10916
|
+
var close = chars[open];
|
|
10917
10917
|
|
|
10918
10918
|
if (close) {
|
|
10919
10919
|
var n = str.indexOf(close, index);
|
|
@@ -10945,7 +10945,7 @@ var relaxedCheck = function(str) {
|
|
|
10945
10945
|
if (str[index] === '\\') {
|
|
10946
10946
|
var open = str[index + 1];
|
|
10947
10947
|
index += 2;
|
|
10948
|
-
var close = chars
|
|
10948
|
+
var close = chars[open];
|
|
10949
10949
|
|
|
10950
10950
|
if (close) {
|
|
10951
10951
|
var n = str.indexOf(close, index);
|
|
@@ -11494,7 +11494,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
11494
11494
|
const util$1 = require$$0$1;
|
|
11495
11495
|
const toRegexRange = toRegexRange_1;
|
|
11496
11496
|
|
|
11497
|
-
const isObject$
|
|
11497
|
+
const isObject$2 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
11498
11498
|
|
|
11499
11499
|
const transform = toNumber => {
|
|
11500
11500
|
return value => toNumber === true ? Number(value) : String(value);
|
|
@@ -11709,7 +11709,7 @@ const fill$2 = (start, end, step, options = {}) => {
|
|
|
11709
11709
|
return fill$2(start, end, 1, { transform: step });
|
|
11710
11710
|
}
|
|
11711
11711
|
|
|
11712
|
-
if (isObject$
|
|
11712
|
+
if (isObject$2(step)) {
|
|
11713
11713
|
return fill$2(start, end, 0, step);
|
|
11714
11714
|
}
|
|
11715
11715
|
|
|
@@ -11718,7 +11718,7 @@ const fill$2 = (start, end, step, options = {}) => {
|
|
|
11718
11718
|
step = step || opts.step || 1;
|
|
11719
11719
|
|
|
11720
11720
|
if (!isNumber(step)) {
|
|
11721
|
-
if (step != null && !isObject$
|
|
11721
|
+
if (step != null && !isObject$2(step)) return invalidStep(step, opts);
|
|
11722
11722
|
return fill$2(start, end, 1, step);
|
|
11723
11723
|
}
|
|
11724
11724
|
|
|
@@ -14188,7 +14188,7 @@ const scan = scan_1;
|
|
|
14188
14188
|
const parse$7 = parse_1$1;
|
|
14189
14189
|
const utils$c = utils$f;
|
|
14190
14190
|
const constants$3 = constants$5;
|
|
14191
|
-
const isObject$
|
|
14191
|
+
const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
14192
14192
|
|
|
14193
14193
|
/**
|
|
14194
14194
|
* Creates a matcher function from one or more glob patterns. The
|
|
@@ -14225,7 +14225,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
|
14225
14225
|
return arrayMatcher;
|
|
14226
14226
|
}
|
|
14227
14227
|
|
|
14228
|
-
const isState = isObject$
|
|
14228
|
+
const isState = isObject$1(glob) && glob.tokens && glob.input;
|
|
14229
14229
|
|
|
14230
14230
|
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
14231
14231
|
throw new TypeError('Expected pattern to be a non-empty string');
|
|
@@ -14532,7 +14532,12 @@ const util = require$$0$1;
|
|
|
14532
14532
|
const braces = braces_1;
|
|
14533
14533
|
const picomatch = picomatch$1;
|
|
14534
14534
|
const utils$b = utils$f;
|
|
14535
|
-
|
|
14535
|
+
|
|
14536
|
+
const isEmptyString = v => v === '' || v === './';
|
|
14537
|
+
const hasBraces = v => {
|
|
14538
|
+
const index = v.indexOf('{');
|
|
14539
|
+
return index > -1 && v.indexOf('}', index) > -1;
|
|
14540
|
+
};
|
|
14536
14541
|
|
|
14537
14542
|
/**
|
|
14538
14543
|
* Returns an array of strings that match one or more glob patterns.
|
|
@@ -14973,7 +14978,7 @@ micromatch$1.parse = (patterns, options) => {
|
|
|
14973
14978
|
|
|
14974
14979
|
micromatch$1.braces = (pattern, options) => {
|
|
14975
14980
|
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
|
14976
|
-
if ((options && options.nobrace === true) ||
|
|
14981
|
+
if ((options && options.nobrace === true) || !hasBraces(pattern)) {
|
|
14977
14982
|
return [pattern];
|
|
14978
14983
|
}
|
|
14979
14984
|
return braces(pattern, options);
|
|
@@ -14992,6 +14997,8 @@ micromatch$1.braceExpand = (pattern, options) => {
|
|
|
14992
14997
|
* Expose micromatch
|
|
14993
14998
|
*/
|
|
14994
14999
|
|
|
15000
|
+
// exposed for tests
|
|
15001
|
+
micromatch$1.hasBraces = hasBraces;
|
|
14995
15002
|
var micromatch_1 = micromatch$1;
|
|
14996
15003
|
|
|
14997
15004
|
var micromatch$2 = /*@__PURE__*/getDefaultExportFromCjs(micromatch_1);
|
|
@@ -18691,7 +18698,7 @@ function requireSymbols () {
|
|
|
18691
18698
|
return symbols.exports;
|
|
18692
18699
|
}
|
|
18693
18700
|
|
|
18694
|
-
const isObject
|
|
18701
|
+
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
18695
18702
|
|
|
18696
18703
|
/* eslint-disable no-control-regex */
|
|
18697
18704
|
// this is a modified version of https://github.com/chalk/ansi-regex (MIT License)
|
|
@@ -18847,7 +18854,7 @@ const create = () => {
|
|
|
18847
18854
|
};
|
|
18848
18855
|
|
|
18849
18856
|
colors.theme = custom => {
|
|
18850
|
-
if (!isObject
|
|
18857
|
+
if (!isObject(custom)) throw new TypeError('Expected theme to be an object');
|
|
18851
18858
|
for (let name of Object.keys(custom)) {
|
|
18852
18859
|
colors.alias(name, custom[name]);
|
|
18853
18860
|
}
|
|
@@ -21523,7 +21530,7 @@ function addModuleMetadata() {
|
|
|
21523
21530
|
transform: {
|
|
21524
21531
|
async handler(code) {
|
|
21525
21532
|
const pkg = JSON.parse(await readFile("./package.json", "utf8"));
|
|
21526
|
-
const magicString = new MagicString
|
|
21533
|
+
const magicString = new MagicString(code);
|
|
21527
21534
|
magicString.replace(
|
|
21528
21535
|
new RegExp(
|
|
21529
21536
|
"moduleMetadata:\\s*Constants.MODULE_METADATA_PLACEHOLDER",
|
|
@@ -21540,1340 +21547,6 @@ function addModuleMetadata() {
|
|
|
21540
21547
|
};
|
|
21541
21548
|
}
|
|
21542
21549
|
|
|
21543
|
-
const comma = ','.charCodeAt(0);
|
|
21544
|
-
const semicolon = ';'.charCodeAt(0);
|
|
21545
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
21546
|
-
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
21547
|
-
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
21548
|
-
for (let i = 0; i < chars.length; i++) {
|
|
21549
|
-
const c = chars.charCodeAt(i);
|
|
21550
|
-
intToChar[i] = c;
|
|
21551
|
-
charToInt[c] = i;
|
|
21552
|
-
}
|
|
21553
|
-
// Provide a fallback for older environments.
|
|
21554
|
-
const td = typeof TextDecoder !== 'undefined'
|
|
21555
|
-
? /* #__PURE__ */ new TextDecoder()
|
|
21556
|
-
: typeof Buffer !== 'undefined'
|
|
21557
|
-
? {
|
|
21558
|
-
decode(buf) {
|
|
21559
|
-
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
21560
|
-
return out.toString();
|
|
21561
|
-
},
|
|
21562
|
-
}
|
|
21563
|
-
: {
|
|
21564
|
-
decode(buf) {
|
|
21565
|
-
let out = '';
|
|
21566
|
-
for (let i = 0; i < buf.length; i++) {
|
|
21567
|
-
out += String.fromCharCode(buf[i]);
|
|
21568
|
-
}
|
|
21569
|
-
return out;
|
|
21570
|
-
},
|
|
21571
|
-
};
|
|
21572
|
-
function encode(decoded) {
|
|
21573
|
-
const state = new Int32Array(5);
|
|
21574
|
-
const bufLength = 1024 * 16;
|
|
21575
|
-
const subLength = bufLength - 36;
|
|
21576
|
-
const buf = new Uint8Array(bufLength);
|
|
21577
|
-
const sub = buf.subarray(0, subLength);
|
|
21578
|
-
let pos = 0;
|
|
21579
|
-
let out = '';
|
|
21580
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
21581
|
-
const line = decoded[i];
|
|
21582
|
-
if (i > 0) {
|
|
21583
|
-
if (pos === bufLength) {
|
|
21584
|
-
out += td.decode(buf);
|
|
21585
|
-
pos = 0;
|
|
21586
|
-
}
|
|
21587
|
-
buf[pos++] = semicolon;
|
|
21588
|
-
}
|
|
21589
|
-
if (line.length === 0)
|
|
21590
|
-
continue;
|
|
21591
|
-
state[0] = 0;
|
|
21592
|
-
for (let j = 0; j < line.length; j++) {
|
|
21593
|
-
const segment = line[j];
|
|
21594
|
-
// We can push up to 5 ints, each int can take at most 7 chars, and we
|
|
21595
|
-
// may push a comma.
|
|
21596
|
-
if (pos > subLength) {
|
|
21597
|
-
out += td.decode(sub);
|
|
21598
|
-
buf.copyWithin(0, subLength, pos);
|
|
21599
|
-
pos -= subLength;
|
|
21600
|
-
}
|
|
21601
|
-
if (j > 0)
|
|
21602
|
-
buf[pos++] = comma;
|
|
21603
|
-
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
|
|
21604
|
-
if (segment.length === 1)
|
|
21605
|
-
continue;
|
|
21606
|
-
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
|
|
21607
|
-
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
|
|
21608
|
-
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
|
|
21609
|
-
if (segment.length === 4)
|
|
21610
|
-
continue;
|
|
21611
|
-
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
|
|
21612
|
-
}
|
|
21613
|
-
}
|
|
21614
|
-
return out + td.decode(buf.subarray(0, pos));
|
|
21615
|
-
}
|
|
21616
|
-
function encodeInteger(buf, pos, state, segment, j) {
|
|
21617
|
-
const next = segment[j];
|
|
21618
|
-
let num = next - state[j];
|
|
21619
|
-
state[j] = next;
|
|
21620
|
-
num = num < 0 ? (-num << 1) | 1 : num << 1;
|
|
21621
|
-
do {
|
|
21622
|
-
let clamped = num & 0b011111;
|
|
21623
|
-
num >>>= 5;
|
|
21624
|
-
if (num > 0)
|
|
21625
|
-
clamped |= 0b100000;
|
|
21626
|
-
buf[pos++] = intToChar[clamped];
|
|
21627
|
-
} while (num > 0);
|
|
21628
|
-
return pos;
|
|
21629
|
-
}
|
|
21630
|
-
|
|
21631
|
-
class BitSet {
|
|
21632
|
-
constructor(arg) {
|
|
21633
|
-
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
21634
|
-
}
|
|
21635
|
-
|
|
21636
|
-
add(n) {
|
|
21637
|
-
this.bits[n >> 5] |= 1 << (n & 31);
|
|
21638
|
-
}
|
|
21639
|
-
|
|
21640
|
-
has(n) {
|
|
21641
|
-
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
21642
|
-
}
|
|
21643
|
-
}
|
|
21644
|
-
|
|
21645
|
-
class Chunk {
|
|
21646
|
-
constructor(start, end, content) {
|
|
21647
|
-
this.start = start;
|
|
21648
|
-
this.end = end;
|
|
21649
|
-
this.original = content;
|
|
21650
|
-
|
|
21651
|
-
this.intro = '';
|
|
21652
|
-
this.outro = '';
|
|
21653
|
-
|
|
21654
|
-
this.content = content;
|
|
21655
|
-
this.storeName = false;
|
|
21656
|
-
this.edited = false;
|
|
21657
|
-
|
|
21658
|
-
{
|
|
21659
|
-
this.previous = null;
|
|
21660
|
-
this.next = null;
|
|
21661
|
-
}
|
|
21662
|
-
}
|
|
21663
|
-
|
|
21664
|
-
appendLeft(content) {
|
|
21665
|
-
this.outro += content;
|
|
21666
|
-
}
|
|
21667
|
-
|
|
21668
|
-
appendRight(content) {
|
|
21669
|
-
this.intro = this.intro + content;
|
|
21670
|
-
}
|
|
21671
|
-
|
|
21672
|
-
clone() {
|
|
21673
|
-
const chunk = new Chunk(this.start, this.end, this.original);
|
|
21674
|
-
|
|
21675
|
-
chunk.intro = this.intro;
|
|
21676
|
-
chunk.outro = this.outro;
|
|
21677
|
-
chunk.content = this.content;
|
|
21678
|
-
chunk.storeName = this.storeName;
|
|
21679
|
-
chunk.edited = this.edited;
|
|
21680
|
-
|
|
21681
|
-
return chunk;
|
|
21682
|
-
}
|
|
21683
|
-
|
|
21684
|
-
contains(index) {
|
|
21685
|
-
return this.start < index && index < this.end;
|
|
21686
|
-
}
|
|
21687
|
-
|
|
21688
|
-
eachNext(fn) {
|
|
21689
|
-
let chunk = this;
|
|
21690
|
-
while (chunk) {
|
|
21691
|
-
fn(chunk);
|
|
21692
|
-
chunk = chunk.next;
|
|
21693
|
-
}
|
|
21694
|
-
}
|
|
21695
|
-
|
|
21696
|
-
eachPrevious(fn) {
|
|
21697
|
-
let chunk = this;
|
|
21698
|
-
while (chunk) {
|
|
21699
|
-
fn(chunk);
|
|
21700
|
-
chunk = chunk.previous;
|
|
21701
|
-
}
|
|
21702
|
-
}
|
|
21703
|
-
|
|
21704
|
-
edit(content, storeName, contentOnly) {
|
|
21705
|
-
this.content = content;
|
|
21706
|
-
if (!contentOnly) {
|
|
21707
|
-
this.intro = '';
|
|
21708
|
-
this.outro = '';
|
|
21709
|
-
}
|
|
21710
|
-
this.storeName = storeName;
|
|
21711
|
-
|
|
21712
|
-
this.edited = true;
|
|
21713
|
-
|
|
21714
|
-
return this;
|
|
21715
|
-
}
|
|
21716
|
-
|
|
21717
|
-
prependLeft(content) {
|
|
21718
|
-
this.outro = content + this.outro;
|
|
21719
|
-
}
|
|
21720
|
-
|
|
21721
|
-
prependRight(content) {
|
|
21722
|
-
this.intro = content + this.intro;
|
|
21723
|
-
}
|
|
21724
|
-
|
|
21725
|
-
reset() {
|
|
21726
|
-
this.intro = '';
|
|
21727
|
-
this.outro = '';
|
|
21728
|
-
if (this.edited) {
|
|
21729
|
-
this.content = this.original;
|
|
21730
|
-
this.storeName = false;
|
|
21731
|
-
this.edited = false;
|
|
21732
|
-
}
|
|
21733
|
-
}
|
|
21734
|
-
|
|
21735
|
-
split(index) {
|
|
21736
|
-
const sliceIndex = index - this.start;
|
|
21737
|
-
|
|
21738
|
-
const originalBefore = this.original.slice(0, sliceIndex);
|
|
21739
|
-
const originalAfter = this.original.slice(sliceIndex);
|
|
21740
|
-
|
|
21741
|
-
this.original = originalBefore;
|
|
21742
|
-
|
|
21743
|
-
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
21744
|
-
newChunk.outro = this.outro;
|
|
21745
|
-
this.outro = '';
|
|
21746
|
-
|
|
21747
|
-
this.end = index;
|
|
21748
|
-
|
|
21749
|
-
if (this.edited) {
|
|
21750
|
-
// after split we should save the edit content record into the correct chunk
|
|
21751
|
-
// to make sure sourcemap correct
|
|
21752
|
-
// For example:
|
|
21753
|
-
// ' test'.trim()
|
|
21754
|
-
// split -> ' ' + 'test'
|
|
21755
|
-
// ✔️ edit -> '' + 'test'
|
|
21756
|
-
// ✖️ edit -> 'test' + ''
|
|
21757
|
-
// TODO is this block necessary?...
|
|
21758
|
-
newChunk.edit('', false);
|
|
21759
|
-
this.content = '';
|
|
21760
|
-
} else {
|
|
21761
|
-
this.content = originalBefore;
|
|
21762
|
-
}
|
|
21763
|
-
|
|
21764
|
-
newChunk.next = this.next;
|
|
21765
|
-
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
21766
|
-
newChunk.previous = this;
|
|
21767
|
-
this.next = newChunk;
|
|
21768
|
-
|
|
21769
|
-
return newChunk;
|
|
21770
|
-
}
|
|
21771
|
-
|
|
21772
|
-
toString() {
|
|
21773
|
-
return this.intro + this.content + this.outro;
|
|
21774
|
-
}
|
|
21775
|
-
|
|
21776
|
-
trimEnd(rx) {
|
|
21777
|
-
this.outro = this.outro.replace(rx, '');
|
|
21778
|
-
if (this.outro.length) return true;
|
|
21779
|
-
|
|
21780
|
-
const trimmed = this.content.replace(rx, '');
|
|
21781
|
-
|
|
21782
|
-
if (trimmed.length) {
|
|
21783
|
-
if (trimmed !== this.content) {
|
|
21784
|
-
this.split(this.start + trimmed.length).edit('', undefined, true);
|
|
21785
|
-
if (this.edited) {
|
|
21786
|
-
// save the change, if it has been edited
|
|
21787
|
-
this.edit(trimmed, this.storeName, true);
|
|
21788
|
-
}
|
|
21789
|
-
}
|
|
21790
|
-
return true;
|
|
21791
|
-
} else {
|
|
21792
|
-
this.edit('', undefined, true);
|
|
21793
|
-
|
|
21794
|
-
this.intro = this.intro.replace(rx, '');
|
|
21795
|
-
if (this.intro.length) return true;
|
|
21796
|
-
}
|
|
21797
|
-
}
|
|
21798
|
-
|
|
21799
|
-
trimStart(rx) {
|
|
21800
|
-
this.intro = this.intro.replace(rx, '');
|
|
21801
|
-
if (this.intro.length) return true;
|
|
21802
|
-
|
|
21803
|
-
const trimmed = this.content.replace(rx, '');
|
|
21804
|
-
|
|
21805
|
-
if (trimmed.length) {
|
|
21806
|
-
if (trimmed !== this.content) {
|
|
21807
|
-
const newChunk = this.split(this.end - trimmed.length);
|
|
21808
|
-
if (this.edited) {
|
|
21809
|
-
// save the change, if it has been edited
|
|
21810
|
-
newChunk.edit(trimmed, this.storeName, true);
|
|
21811
|
-
}
|
|
21812
|
-
this.edit('', undefined, true);
|
|
21813
|
-
}
|
|
21814
|
-
return true;
|
|
21815
|
-
} else {
|
|
21816
|
-
this.edit('', undefined, true);
|
|
21817
|
-
|
|
21818
|
-
this.outro = this.outro.replace(rx, '');
|
|
21819
|
-
if (this.outro.length) return true;
|
|
21820
|
-
}
|
|
21821
|
-
}
|
|
21822
|
-
}
|
|
21823
|
-
|
|
21824
|
-
function getBtoa() {
|
|
21825
|
-
if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
|
|
21826
|
-
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
21827
|
-
} else if (typeof Buffer === 'function') {
|
|
21828
|
-
return (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
21829
|
-
} else {
|
|
21830
|
-
return () => {
|
|
21831
|
-
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
21832
|
-
};
|
|
21833
|
-
}
|
|
21834
|
-
}
|
|
21835
|
-
|
|
21836
|
-
const btoa = /*#__PURE__*/ getBtoa();
|
|
21837
|
-
|
|
21838
|
-
class SourceMap {
|
|
21839
|
-
constructor(properties) {
|
|
21840
|
-
this.version = 3;
|
|
21841
|
-
this.file = properties.file;
|
|
21842
|
-
this.sources = properties.sources;
|
|
21843
|
-
this.sourcesContent = properties.sourcesContent;
|
|
21844
|
-
this.names = properties.names;
|
|
21845
|
-
this.mappings = encode(properties.mappings);
|
|
21846
|
-
if (typeof properties.x_google_ignoreList !== 'undefined') {
|
|
21847
|
-
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
21848
|
-
}
|
|
21849
|
-
}
|
|
21850
|
-
|
|
21851
|
-
toString() {
|
|
21852
|
-
return JSON.stringify(this);
|
|
21853
|
-
}
|
|
21854
|
-
|
|
21855
|
-
toUrl() {
|
|
21856
|
-
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
21857
|
-
}
|
|
21858
|
-
}
|
|
21859
|
-
|
|
21860
|
-
function guessIndent(code) {
|
|
21861
|
-
const lines = code.split('\n');
|
|
21862
|
-
|
|
21863
|
-
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
21864
|
-
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
21865
|
-
|
|
21866
|
-
if (tabbed.length === 0 && spaced.length === 0) {
|
|
21867
|
-
return null;
|
|
21868
|
-
}
|
|
21869
|
-
|
|
21870
|
-
// More lines tabbed than spaced? Assume tabs, and
|
|
21871
|
-
// default to tabs in the case of a tie (or nothing
|
|
21872
|
-
// to go on)
|
|
21873
|
-
if (tabbed.length >= spaced.length) {
|
|
21874
|
-
return '\t';
|
|
21875
|
-
}
|
|
21876
|
-
|
|
21877
|
-
// Otherwise, we need to guess the multiple
|
|
21878
|
-
const min = spaced.reduce((previous, current) => {
|
|
21879
|
-
const numSpaces = /^ +/.exec(current)[0].length;
|
|
21880
|
-
return Math.min(numSpaces, previous);
|
|
21881
|
-
}, Infinity);
|
|
21882
|
-
|
|
21883
|
-
return new Array(min + 1).join(' ');
|
|
21884
|
-
}
|
|
21885
|
-
|
|
21886
|
-
function getRelativePath(from, to) {
|
|
21887
|
-
const fromParts = from.split(/[/\\]/);
|
|
21888
|
-
const toParts = to.split(/[/\\]/);
|
|
21889
|
-
|
|
21890
|
-
fromParts.pop(); // get dirname
|
|
21891
|
-
|
|
21892
|
-
while (fromParts[0] === toParts[0]) {
|
|
21893
|
-
fromParts.shift();
|
|
21894
|
-
toParts.shift();
|
|
21895
|
-
}
|
|
21896
|
-
|
|
21897
|
-
if (fromParts.length) {
|
|
21898
|
-
let i = fromParts.length;
|
|
21899
|
-
while (i--) fromParts[i] = '..';
|
|
21900
|
-
}
|
|
21901
|
-
|
|
21902
|
-
return fromParts.concat(toParts).join('/');
|
|
21903
|
-
}
|
|
21904
|
-
|
|
21905
|
-
const toString = Object.prototype.toString;
|
|
21906
|
-
|
|
21907
|
-
function isObject(thing) {
|
|
21908
|
-
return toString.call(thing) === '[object Object]';
|
|
21909
|
-
}
|
|
21910
|
-
|
|
21911
|
-
function getLocator(source) {
|
|
21912
|
-
const originalLines = source.split('\n');
|
|
21913
|
-
const lineOffsets = [];
|
|
21914
|
-
|
|
21915
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
21916
|
-
lineOffsets.push(pos);
|
|
21917
|
-
pos += originalLines[i].length + 1;
|
|
21918
|
-
}
|
|
21919
|
-
|
|
21920
|
-
return function locate(index) {
|
|
21921
|
-
let i = 0;
|
|
21922
|
-
let j = lineOffsets.length;
|
|
21923
|
-
while (i < j) {
|
|
21924
|
-
const m = (i + j) >> 1;
|
|
21925
|
-
if (index < lineOffsets[m]) {
|
|
21926
|
-
j = m;
|
|
21927
|
-
} else {
|
|
21928
|
-
i = m + 1;
|
|
21929
|
-
}
|
|
21930
|
-
}
|
|
21931
|
-
const line = i - 1;
|
|
21932
|
-
const column = index - lineOffsets[line];
|
|
21933
|
-
return { line, column };
|
|
21934
|
-
};
|
|
21935
|
-
}
|
|
21936
|
-
|
|
21937
|
-
const wordRegex = /\w/;
|
|
21938
|
-
|
|
21939
|
-
class Mappings {
|
|
21940
|
-
constructor(hires) {
|
|
21941
|
-
this.hires = hires;
|
|
21942
|
-
this.generatedCodeLine = 0;
|
|
21943
|
-
this.generatedCodeColumn = 0;
|
|
21944
|
-
this.raw = [];
|
|
21945
|
-
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
21946
|
-
this.pending = null;
|
|
21947
|
-
}
|
|
21948
|
-
|
|
21949
|
-
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
21950
|
-
if (content.length) {
|
|
21951
|
-
const contentLengthMinusOne = content.length - 1;
|
|
21952
|
-
let contentLineEnd = content.indexOf('\n', 0);
|
|
21953
|
-
let previousContentLineEnd = -1;
|
|
21954
|
-
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
21955
|
-
// else code afterwards would fill one line too many
|
|
21956
|
-
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
21957
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
21958
|
-
if (nameIndex >= 0) {
|
|
21959
|
-
segment.push(nameIndex);
|
|
21960
|
-
}
|
|
21961
|
-
this.rawSegments.push(segment);
|
|
21962
|
-
|
|
21963
|
-
this.generatedCodeLine += 1;
|
|
21964
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
21965
|
-
this.generatedCodeColumn = 0;
|
|
21966
|
-
|
|
21967
|
-
previousContentLineEnd = contentLineEnd;
|
|
21968
|
-
contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
|
|
21969
|
-
}
|
|
21970
|
-
|
|
21971
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
21972
|
-
if (nameIndex >= 0) {
|
|
21973
|
-
segment.push(nameIndex);
|
|
21974
|
-
}
|
|
21975
|
-
this.rawSegments.push(segment);
|
|
21976
|
-
|
|
21977
|
-
this.advance(content.slice(previousContentLineEnd + 1));
|
|
21978
|
-
} else if (this.pending) {
|
|
21979
|
-
this.rawSegments.push(this.pending);
|
|
21980
|
-
this.advance(content);
|
|
21981
|
-
}
|
|
21982
|
-
|
|
21983
|
-
this.pending = null;
|
|
21984
|
-
}
|
|
21985
|
-
|
|
21986
|
-
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
21987
|
-
let originalCharIndex = chunk.start;
|
|
21988
|
-
let first = true;
|
|
21989
|
-
// when iterating each char, check if it's in a word boundary
|
|
21990
|
-
let charInHiresBoundary = false;
|
|
21991
|
-
|
|
21992
|
-
while (originalCharIndex < chunk.end) {
|
|
21993
|
-
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
21994
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
21995
|
-
|
|
21996
|
-
if (this.hires === 'boundary') {
|
|
21997
|
-
// in hires "boundary", group segments per word boundary than per char
|
|
21998
|
-
if (wordRegex.test(original[originalCharIndex])) {
|
|
21999
|
-
// for first char in the boundary found, start the boundary by pushing a segment
|
|
22000
|
-
if (!charInHiresBoundary) {
|
|
22001
|
-
this.rawSegments.push(segment);
|
|
22002
|
-
charInHiresBoundary = true;
|
|
22003
|
-
}
|
|
22004
|
-
} else {
|
|
22005
|
-
// for non-word char, end the boundary by pushing a segment
|
|
22006
|
-
this.rawSegments.push(segment);
|
|
22007
|
-
charInHiresBoundary = false;
|
|
22008
|
-
}
|
|
22009
|
-
} else {
|
|
22010
|
-
this.rawSegments.push(segment);
|
|
22011
|
-
}
|
|
22012
|
-
}
|
|
22013
|
-
|
|
22014
|
-
if (original[originalCharIndex] === '\n') {
|
|
22015
|
-
loc.line += 1;
|
|
22016
|
-
loc.column = 0;
|
|
22017
|
-
this.generatedCodeLine += 1;
|
|
22018
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
22019
|
-
this.generatedCodeColumn = 0;
|
|
22020
|
-
first = true;
|
|
22021
|
-
} else {
|
|
22022
|
-
loc.column += 1;
|
|
22023
|
-
this.generatedCodeColumn += 1;
|
|
22024
|
-
first = false;
|
|
22025
|
-
}
|
|
22026
|
-
|
|
22027
|
-
originalCharIndex += 1;
|
|
22028
|
-
}
|
|
22029
|
-
|
|
22030
|
-
this.pending = null;
|
|
22031
|
-
}
|
|
22032
|
-
|
|
22033
|
-
advance(str) {
|
|
22034
|
-
if (!str) return;
|
|
22035
|
-
|
|
22036
|
-
const lines = str.split('\n');
|
|
22037
|
-
|
|
22038
|
-
if (lines.length > 1) {
|
|
22039
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
|
22040
|
-
this.generatedCodeLine++;
|
|
22041
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
22042
|
-
}
|
|
22043
|
-
this.generatedCodeColumn = 0;
|
|
22044
|
-
}
|
|
22045
|
-
|
|
22046
|
-
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
22047
|
-
}
|
|
22048
|
-
}
|
|
22049
|
-
|
|
22050
|
-
const n = '\n';
|
|
22051
|
-
|
|
22052
|
-
const warned = {
|
|
22053
|
-
insertLeft: false,
|
|
22054
|
-
insertRight: false,
|
|
22055
|
-
storeName: false,
|
|
22056
|
-
};
|
|
22057
|
-
|
|
22058
|
-
class MagicString {
|
|
22059
|
-
constructor(string, options = {}) {
|
|
22060
|
-
const chunk = new Chunk(0, string.length, string);
|
|
22061
|
-
|
|
22062
|
-
Object.defineProperties(this, {
|
|
22063
|
-
original: { writable: true, value: string },
|
|
22064
|
-
outro: { writable: true, value: '' },
|
|
22065
|
-
intro: { writable: true, value: '' },
|
|
22066
|
-
firstChunk: { writable: true, value: chunk },
|
|
22067
|
-
lastChunk: { writable: true, value: chunk },
|
|
22068
|
-
lastSearchedChunk: { writable: true, value: chunk },
|
|
22069
|
-
byStart: { writable: true, value: {} },
|
|
22070
|
-
byEnd: { writable: true, value: {} },
|
|
22071
|
-
filename: { writable: true, value: options.filename },
|
|
22072
|
-
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
22073
|
-
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
22074
|
-
storedNames: { writable: true, value: {} },
|
|
22075
|
-
indentStr: { writable: true, value: undefined },
|
|
22076
|
-
ignoreList: { writable: true, value: options.ignoreList },
|
|
22077
|
-
});
|
|
22078
|
-
|
|
22079
|
-
this.byStart[0] = chunk;
|
|
22080
|
-
this.byEnd[string.length] = chunk;
|
|
22081
|
-
}
|
|
22082
|
-
|
|
22083
|
-
addSourcemapLocation(char) {
|
|
22084
|
-
this.sourcemapLocations.add(char);
|
|
22085
|
-
}
|
|
22086
|
-
|
|
22087
|
-
append(content) {
|
|
22088
|
-
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
22089
|
-
|
|
22090
|
-
this.outro += content;
|
|
22091
|
-
return this;
|
|
22092
|
-
}
|
|
22093
|
-
|
|
22094
|
-
appendLeft(index, content) {
|
|
22095
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
22096
|
-
|
|
22097
|
-
this._split(index);
|
|
22098
|
-
|
|
22099
|
-
const chunk = this.byEnd[index];
|
|
22100
|
-
|
|
22101
|
-
if (chunk) {
|
|
22102
|
-
chunk.appendLeft(content);
|
|
22103
|
-
} else {
|
|
22104
|
-
this.intro += content;
|
|
22105
|
-
}
|
|
22106
|
-
return this;
|
|
22107
|
-
}
|
|
22108
|
-
|
|
22109
|
-
appendRight(index, content) {
|
|
22110
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
22111
|
-
|
|
22112
|
-
this._split(index);
|
|
22113
|
-
|
|
22114
|
-
const chunk = this.byStart[index];
|
|
22115
|
-
|
|
22116
|
-
if (chunk) {
|
|
22117
|
-
chunk.appendRight(content);
|
|
22118
|
-
} else {
|
|
22119
|
-
this.outro += content;
|
|
22120
|
-
}
|
|
22121
|
-
return this;
|
|
22122
|
-
}
|
|
22123
|
-
|
|
22124
|
-
clone() {
|
|
22125
|
-
const cloned = new MagicString(this.original, { filename: this.filename });
|
|
22126
|
-
|
|
22127
|
-
let originalChunk = this.firstChunk;
|
|
22128
|
-
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
|
22129
|
-
|
|
22130
|
-
while (originalChunk) {
|
|
22131
|
-
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
22132
|
-
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
22133
|
-
|
|
22134
|
-
const nextOriginalChunk = originalChunk.next;
|
|
22135
|
-
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
22136
|
-
|
|
22137
|
-
if (nextClonedChunk) {
|
|
22138
|
-
clonedChunk.next = nextClonedChunk;
|
|
22139
|
-
nextClonedChunk.previous = clonedChunk;
|
|
22140
|
-
|
|
22141
|
-
clonedChunk = nextClonedChunk;
|
|
22142
|
-
}
|
|
22143
|
-
|
|
22144
|
-
originalChunk = nextOriginalChunk;
|
|
22145
|
-
}
|
|
22146
|
-
|
|
22147
|
-
cloned.lastChunk = clonedChunk;
|
|
22148
|
-
|
|
22149
|
-
if (this.indentExclusionRanges) {
|
|
22150
|
-
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
22151
|
-
}
|
|
22152
|
-
|
|
22153
|
-
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
22154
|
-
|
|
22155
|
-
cloned.intro = this.intro;
|
|
22156
|
-
cloned.outro = this.outro;
|
|
22157
|
-
|
|
22158
|
-
return cloned;
|
|
22159
|
-
}
|
|
22160
|
-
|
|
22161
|
-
generateDecodedMap(options) {
|
|
22162
|
-
options = options || {};
|
|
22163
|
-
|
|
22164
|
-
const sourceIndex = 0;
|
|
22165
|
-
const names = Object.keys(this.storedNames);
|
|
22166
|
-
const mappings = new Mappings(options.hires);
|
|
22167
|
-
|
|
22168
|
-
const locate = getLocator(this.original);
|
|
22169
|
-
|
|
22170
|
-
if (this.intro) {
|
|
22171
|
-
mappings.advance(this.intro);
|
|
22172
|
-
}
|
|
22173
|
-
|
|
22174
|
-
this.firstChunk.eachNext((chunk) => {
|
|
22175
|
-
const loc = locate(chunk.start);
|
|
22176
|
-
|
|
22177
|
-
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
22178
|
-
|
|
22179
|
-
if (chunk.edited) {
|
|
22180
|
-
mappings.addEdit(
|
|
22181
|
-
sourceIndex,
|
|
22182
|
-
chunk.content,
|
|
22183
|
-
loc,
|
|
22184
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
22185
|
-
);
|
|
22186
|
-
} else {
|
|
22187
|
-
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
22188
|
-
}
|
|
22189
|
-
|
|
22190
|
-
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
22191
|
-
});
|
|
22192
|
-
|
|
22193
|
-
return {
|
|
22194
|
-
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
22195
|
-
sources: [
|
|
22196
|
-
options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
|
|
22197
|
-
],
|
|
22198
|
-
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
22199
|
-
names,
|
|
22200
|
-
mappings: mappings.raw,
|
|
22201
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
|
|
22202
|
-
};
|
|
22203
|
-
}
|
|
22204
|
-
|
|
22205
|
-
generateMap(options) {
|
|
22206
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
22207
|
-
}
|
|
22208
|
-
|
|
22209
|
-
_ensureindentStr() {
|
|
22210
|
-
if (this.indentStr === undefined) {
|
|
22211
|
-
this.indentStr = guessIndent(this.original);
|
|
22212
|
-
}
|
|
22213
|
-
}
|
|
22214
|
-
|
|
22215
|
-
_getRawIndentString() {
|
|
22216
|
-
this._ensureindentStr();
|
|
22217
|
-
return this.indentStr;
|
|
22218
|
-
}
|
|
22219
|
-
|
|
22220
|
-
getIndentString() {
|
|
22221
|
-
this._ensureindentStr();
|
|
22222
|
-
return this.indentStr === null ? '\t' : this.indentStr;
|
|
22223
|
-
}
|
|
22224
|
-
|
|
22225
|
-
indent(indentStr, options) {
|
|
22226
|
-
const pattern = /^[^\r\n]/gm;
|
|
22227
|
-
|
|
22228
|
-
if (isObject(indentStr)) {
|
|
22229
|
-
options = indentStr;
|
|
22230
|
-
indentStr = undefined;
|
|
22231
|
-
}
|
|
22232
|
-
|
|
22233
|
-
if (indentStr === undefined) {
|
|
22234
|
-
this._ensureindentStr();
|
|
22235
|
-
indentStr = this.indentStr || '\t';
|
|
22236
|
-
}
|
|
22237
|
-
|
|
22238
|
-
if (indentStr === '') return this; // noop
|
|
22239
|
-
|
|
22240
|
-
options = options || {};
|
|
22241
|
-
|
|
22242
|
-
// Process exclusion ranges
|
|
22243
|
-
const isExcluded = {};
|
|
22244
|
-
|
|
22245
|
-
if (options.exclude) {
|
|
22246
|
-
const exclusions =
|
|
22247
|
-
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
22248
|
-
exclusions.forEach((exclusion) => {
|
|
22249
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
22250
|
-
isExcluded[i] = true;
|
|
22251
|
-
}
|
|
22252
|
-
});
|
|
22253
|
-
}
|
|
22254
|
-
|
|
22255
|
-
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
22256
|
-
const replacer = (match) => {
|
|
22257
|
-
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
22258
|
-
shouldIndentNextCharacter = true;
|
|
22259
|
-
return match;
|
|
22260
|
-
};
|
|
22261
|
-
|
|
22262
|
-
this.intro = this.intro.replace(pattern, replacer);
|
|
22263
|
-
|
|
22264
|
-
let charIndex = 0;
|
|
22265
|
-
let chunk = this.firstChunk;
|
|
22266
|
-
|
|
22267
|
-
while (chunk) {
|
|
22268
|
-
const end = chunk.end;
|
|
22269
|
-
|
|
22270
|
-
if (chunk.edited) {
|
|
22271
|
-
if (!isExcluded[charIndex]) {
|
|
22272
|
-
chunk.content = chunk.content.replace(pattern, replacer);
|
|
22273
|
-
|
|
22274
|
-
if (chunk.content.length) {
|
|
22275
|
-
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
|
|
22276
|
-
}
|
|
22277
|
-
}
|
|
22278
|
-
} else {
|
|
22279
|
-
charIndex = chunk.start;
|
|
22280
|
-
|
|
22281
|
-
while (charIndex < end) {
|
|
22282
|
-
if (!isExcluded[charIndex]) {
|
|
22283
|
-
const char = this.original[charIndex];
|
|
22284
|
-
|
|
22285
|
-
if (char === '\n') {
|
|
22286
|
-
shouldIndentNextCharacter = true;
|
|
22287
|
-
} else if (char !== '\r' && shouldIndentNextCharacter) {
|
|
22288
|
-
shouldIndentNextCharacter = false;
|
|
22289
|
-
|
|
22290
|
-
if (charIndex === chunk.start) {
|
|
22291
|
-
chunk.prependRight(indentStr);
|
|
22292
|
-
} else {
|
|
22293
|
-
this._splitChunk(chunk, charIndex);
|
|
22294
|
-
chunk = chunk.next;
|
|
22295
|
-
chunk.prependRight(indentStr);
|
|
22296
|
-
}
|
|
22297
|
-
}
|
|
22298
|
-
}
|
|
22299
|
-
|
|
22300
|
-
charIndex += 1;
|
|
22301
|
-
}
|
|
22302
|
-
}
|
|
22303
|
-
|
|
22304
|
-
charIndex = chunk.end;
|
|
22305
|
-
chunk = chunk.next;
|
|
22306
|
-
}
|
|
22307
|
-
|
|
22308
|
-
this.outro = this.outro.replace(pattern, replacer);
|
|
22309
|
-
|
|
22310
|
-
return this;
|
|
22311
|
-
}
|
|
22312
|
-
|
|
22313
|
-
insert() {
|
|
22314
|
-
throw new Error(
|
|
22315
|
-
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
22316
|
-
);
|
|
22317
|
-
}
|
|
22318
|
-
|
|
22319
|
-
insertLeft(index, content) {
|
|
22320
|
-
if (!warned.insertLeft) {
|
|
22321
|
-
console.warn(
|
|
22322
|
-
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
22323
|
-
); // eslint-disable-line no-console
|
|
22324
|
-
warned.insertLeft = true;
|
|
22325
|
-
}
|
|
22326
|
-
|
|
22327
|
-
return this.appendLeft(index, content);
|
|
22328
|
-
}
|
|
22329
|
-
|
|
22330
|
-
insertRight(index, content) {
|
|
22331
|
-
if (!warned.insertRight) {
|
|
22332
|
-
console.warn(
|
|
22333
|
-
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
22334
|
-
); // eslint-disable-line no-console
|
|
22335
|
-
warned.insertRight = true;
|
|
22336
|
-
}
|
|
22337
|
-
|
|
22338
|
-
return this.prependRight(index, content);
|
|
22339
|
-
}
|
|
22340
|
-
|
|
22341
|
-
move(start, end, index) {
|
|
22342
|
-
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
22343
|
-
|
|
22344
|
-
this._split(start);
|
|
22345
|
-
this._split(end);
|
|
22346
|
-
this._split(index);
|
|
22347
|
-
|
|
22348
|
-
const first = this.byStart[start];
|
|
22349
|
-
const last = this.byEnd[end];
|
|
22350
|
-
|
|
22351
|
-
const oldLeft = first.previous;
|
|
22352
|
-
const oldRight = last.next;
|
|
22353
|
-
|
|
22354
|
-
const newRight = this.byStart[index];
|
|
22355
|
-
if (!newRight && last === this.lastChunk) return this;
|
|
22356
|
-
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
22357
|
-
|
|
22358
|
-
if (oldLeft) oldLeft.next = oldRight;
|
|
22359
|
-
if (oldRight) oldRight.previous = oldLeft;
|
|
22360
|
-
|
|
22361
|
-
if (newLeft) newLeft.next = first;
|
|
22362
|
-
if (newRight) newRight.previous = last;
|
|
22363
|
-
|
|
22364
|
-
if (!first.previous) this.firstChunk = last.next;
|
|
22365
|
-
if (!last.next) {
|
|
22366
|
-
this.lastChunk = first.previous;
|
|
22367
|
-
this.lastChunk.next = null;
|
|
22368
|
-
}
|
|
22369
|
-
|
|
22370
|
-
first.previous = newLeft;
|
|
22371
|
-
last.next = newRight || null;
|
|
22372
|
-
|
|
22373
|
-
if (!newLeft) this.firstChunk = first;
|
|
22374
|
-
if (!newRight) this.lastChunk = last;
|
|
22375
|
-
return this;
|
|
22376
|
-
}
|
|
22377
|
-
|
|
22378
|
-
overwrite(start, end, content, options) {
|
|
22379
|
-
options = options || {};
|
|
22380
|
-
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
22381
|
-
}
|
|
22382
|
-
|
|
22383
|
-
update(start, end, content, options) {
|
|
22384
|
-
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
22385
|
-
|
|
22386
|
-
while (start < 0) start += this.original.length;
|
|
22387
|
-
while (end < 0) end += this.original.length;
|
|
22388
|
-
|
|
22389
|
-
if (end > this.original.length) throw new Error('end is out of bounds');
|
|
22390
|
-
if (start === end)
|
|
22391
|
-
throw new Error(
|
|
22392
|
-
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
22393
|
-
);
|
|
22394
|
-
|
|
22395
|
-
this._split(start);
|
|
22396
|
-
this._split(end);
|
|
22397
|
-
|
|
22398
|
-
if (options === true) {
|
|
22399
|
-
if (!warned.storeName) {
|
|
22400
|
-
console.warn(
|
|
22401
|
-
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
22402
|
-
); // eslint-disable-line no-console
|
|
22403
|
-
warned.storeName = true;
|
|
22404
|
-
}
|
|
22405
|
-
|
|
22406
|
-
options = { storeName: true };
|
|
22407
|
-
}
|
|
22408
|
-
const storeName = options !== undefined ? options.storeName : false;
|
|
22409
|
-
const overwrite = options !== undefined ? options.overwrite : false;
|
|
22410
|
-
|
|
22411
|
-
if (storeName) {
|
|
22412
|
-
const original = this.original.slice(start, end);
|
|
22413
|
-
Object.defineProperty(this.storedNames, original, {
|
|
22414
|
-
writable: true,
|
|
22415
|
-
value: true,
|
|
22416
|
-
enumerable: true,
|
|
22417
|
-
});
|
|
22418
|
-
}
|
|
22419
|
-
|
|
22420
|
-
const first = this.byStart[start];
|
|
22421
|
-
const last = this.byEnd[end];
|
|
22422
|
-
|
|
22423
|
-
if (first) {
|
|
22424
|
-
let chunk = first;
|
|
22425
|
-
while (chunk !== last) {
|
|
22426
|
-
if (chunk.next !== this.byStart[chunk.end]) {
|
|
22427
|
-
throw new Error('Cannot overwrite across a split point');
|
|
22428
|
-
}
|
|
22429
|
-
chunk = chunk.next;
|
|
22430
|
-
chunk.edit('', false);
|
|
22431
|
-
}
|
|
22432
|
-
|
|
22433
|
-
first.edit(content, storeName, !overwrite);
|
|
22434
|
-
} else {
|
|
22435
|
-
// must be inserting at the end
|
|
22436
|
-
const newChunk = new Chunk(start, end, '').edit(content, storeName);
|
|
22437
|
-
|
|
22438
|
-
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
22439
|
-
last.next = newChunk;
|
|
22440
|
-
newChunk.previous = last;
|
|
22441
|
-
}
|
|
22442
|
-
return this;
|
|
22443
|
-
}
|
|
22444
|
-
|
|
22445
|
-
prepend(content) {
|
|
22446
|
-
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
22447
|
-
|
|
22448
|
-
this.intro = content + this.intro;
|
|
22449
|
-
return this;
|
|
22450
|
-
}
|
|
22451
|
-
|
|
22452
|
-
prependLeft(index, content) {
|
|
22453
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
22454
|
-
|
|
22455
|
-
this._split(index);
|
|
22456
|
-
|
|
22457
|
-
const chunk = this.byEnd[index];
|
|
22458
|
-
|
|
22459
|
-
if (chunk) {
|
|
22460
|
-
chunk.prependLeft(content);
|
|
22461
|
-
} else {
|
|
22462
|
-
this.intro = content + this.intro;
|
|
22463
|
-
}
|
|
22464
|
-
return this;
|
|
22465
|
-
}
|
|
22466
|
-
|
|
22467
|
-
prependRight(index, content) {
|
|
22468
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
22469
|
-
|
|
22470
|
-
this._split(index);
|
|
22471
|
-
|
|
22472
|
-
const chunk = this.byStart[index];
|
|
22473
|
-
|
|
22474
|
-
if (chunk) {
|
|
22475
|
-
chunk.prependRight(content);
|
|
22476
|
-
} else {
|
|
22477
|
-
this.outro = content + this.outro;
|
|
22478
|
-
}
|
|
22479
|
-
return this;
|
|
22480
|
-
}
|
|
22481
|
-
|
|
22482
|
-
remove(start, end) {
|
|
22483
|
-
while (start < 0) start += this.original.length;
|
|
22484
|
-
while (end < 0) end += this.original.length;
|
|
22485
|
-
|
|
22486
|
-
if (start === end) return this;
|
|
22487
|
-
|
|
22488
|
-
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
22489
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
22490
|
-
|
|
22491
|
-
this._split(start);
|
|
22492
|
-
this._split(end);
|
|
22493
|
-
|
|
22494
|
-
let chunk = this.byStart[start];
|
|
22495
|
-
|
|
22496
|
-
while (chunk) {
|
|
22497
|
-
chunk.intro = '';
|
|
22498
|
-
chunk.outro = '';
|
|
22499
|
-
chunk.edit('');
|
|
22500
|
-
|
|
22501
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
22502
|
-
}
|
|
22503
|
-
return this;
|
|
22504
|
-
}
|
|
22505
|
-
|
|
22506
|
-
reset(start, end) {
|
|
22507
|
-
while (start < 0) start += this.original.length;
|
|
22508
|
-
while (end < 0) end += this.original.length;
|
|
22509
|
-
|
|
22510
|
-
if (start === end) return this;
|
|
22511
|
-
|
|
22512
|
-
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
22513
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
22514
|
-
|
|
22515
|
-
this._split(start);
|
|
22516
|
-
this._split(end);
|
|
22517
|
-
|
|
22518
|
-
let chunk = this.byStart[start];
|
|
22519
|
-
|
|
22520
|
-
while (chunk) {
|
|
22521
|
-
chunk.reset();
|
|
22522
|
-
|
|
22523
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
22524
|
-
}
|
|
22525
|
-
return this;
|
|
22526
|
-
}
|
|
22527
|
-
|
|
22528
|
-
lastChar() {
|
|
22529
|
-
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
22530
|
-
let chunk = this.lastChunk;
|
|
22531
|
-
do {
|
|
22532
|
-
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
22533
|
-
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
22534
|
-
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
22535
|
-
} while ((chunk = chunk.previous));
|
|
22536
|
-
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
22537
|
-
return '';
|
|
22538
|
-
}
|
|
22539
|
-
|
|
22540
|
-
lastLine() {
|
|
22541
|
-
let lineIndex = this.outro.lastIndexOf(n);
|
|
22542
|
-
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
22543
|
-
let lineStr = this.outro;
|
|
22544
|
-
let chunk = this.lastChunk;
|
|
22545
|
-
do {
|
|
22546
|
-
if (chunk.outro.length > 0) {
|
|
22547
|
-
lineIndex = chunk.outro.lastIndexOf(n);
|
|
22548
|
-
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
22549
|
-
lineStr = chunk.outro + lineStr;
|
|
22550
|
-
}
|
|
22551
|
-
|
|
22552
|
-
if (chunk.content.length > 0) {
|
|
22553
|
-
lineIndex = chunk.content.lastIndexOf(n);
|
|
22554
|
-
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
22555
|
-
lineStr = chunk.content + lineStr;
|
|
22556
|
-
}
|
|
22557
|
-
|
|
22558
|
-
if (chunk.intro.length > 0) {
|
|
22559
|
-
lineIndex = chunk.intro.lastIndexOf(n);
|
|
22560
|
-
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
22561
|
-
lineStr = chunk.intro + lineStr;
|
|
22562
|
-
}
|
|
22563
|
-
} while ((chunk = chunk.previous));
|
|
22564
|
-
lineIndex = this.intro.lastIndexOf(n);
|
|
22565
|
-
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
22566
|
-
return this.intro + lineStr;
|
|
22567
|
-
}
|
|
22568
|
-
|
|
22569
|
-
slice(start = 0, end = this.original.length) {
|
|
22570
|
-
while (start < 0) start += this.original.length;
|
|
22571
|
-
while (end < 0) end += this.original.length;
|
|
22572
|
-
|
|
22573
|
-
let result = '';
|
|
22574
|
-
|
|
22575
|
-
// find start chunk
|
|
22576
|
-
let chunk = this.firstChunk;
|
|
22577
|
-
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
22578
|
-
// found end chunk before start
|
|
22579
|
-
if (chunk.start < end && chunk.end >= end) {
|
|
22580
|
-
return result;
|
|
22581
|
-
}
|
|
22582
|
-
|
|
22583
|
-
chunk = chunk.next;
|
|
22584
|
-
}
|
|
22585
|
-
|
|
22586
|
-
if (chunk && chunk.edited && chunk.start !== start)
|
|
22587
|
-
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
22588
|
-
|
|
22589
|
-
const startChunk = chunk;
|
|
22590
|
-
while (chunk) {
|
|
22591
|
-
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
|
|
22592
|
-
result += chunk.intro;
|
|
22593
|
-
}
|
|
22594
|
-
|
|
22595
|
-
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
22596
|
-
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
22597
|
-
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
22598
|
-
|
|
22599
|
-
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
22600
|
-
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
22601
|
-
|
|
22602
|
-
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
22603
|
-
|
|
22604
|
-
if (chunk.outro && (!containsEnd || chunk.end === end)) {
|
|
22605
|
-
result += chunk.outro;
|
|
22606
|
-
}
|
|
22607
|
-
|
|
22608
|
-
if (containsEnd) {
|
|
22609
|
-
break;
|
|
22610
|
-
}
|
|
22611
|
-
|
|
22612
|
-
chunk = chunk.next;
|
|
22613
|
-
}
|
|
22614
|
-
|
|
22615
|
-
return result;
|
|
22616
|
-
}
|
|
22617
|
-
|
|
22618
|
-
// TODO deprecate this? not really very useful
|
|
22619
|
-
snip(start, end) {
|
|
22620
|
-
const clone = this.clone();
|
|
22621
|
-
clone.remove(0, start);
|
|
22622
|
-
clone.remove(end, clone.original.length);
|
|
22623
|
-
|
|
22624
|
-
return clone;
|
|
22625
|
-
}
|
|
22626
|
-
|
|
22627
|
-
_split(index) {
|
|
22628
|
-
if (this.byStart[index] || this.byEnd[index]) return;
|
|
22629
|
-
|
|
22630
|
-
let chunk = this.lastSearchedChunk;
|
|
22631
|
-
const searchForward = index > chunk.end;
|
|
22632
|
-
|
|
22633
|
-
while (chunk) {
|
|
22634
|
-
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
22635
|
-
|
|
22636
|
-
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
22637
|
-
}
|
|
22638
|
-
}
|
|
22639
|
-
|
|
22640
|
-
_splitChunk(chunk, index) {
|
|
22641
|
-
if (chunk.edited && chunk.content.length) {
|
|
22642
|
-
// zero-length edited chunks are a special case (overlapping replacements)
|
|
22643
|
-
const loc = getLocator(this.original)(index);
|
|
22644
|
-
throw new Error(
|
|
22645
|
-
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
22646
|
-
);
|
|
22647
|
-
}
|
|
22648
|
-
|
|
22649
|
-
const newChunk = chunk.split(index);
|
|
22650
|
-
|
|
22651
|
-
this.byEnd[index] = chunk;
|
|
22652
|
-
this.byStart[index] = newChunk;
|
|
22653
|
-
this.byEnd[newChunk.end] = newChunk;
|
|
22654
|
-
|
|
22655
|
-
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
22656
|
-
|
|
22657
|
-
this.lastSearchedChunk = chunk;
|
|
22658
|
-
return true;
|
|
22659
|
-
}
|
|
22660
|
-
|
|
22661
|
-
toString() {
|
|
22662
|
-
let str = this.intro;
|
|
22663
|
-
|
|
22664
|
-
let chunk = this.firstChunk;
|
|
22665
|
-
while (chunk) {
|
|
22666
|
-
str += chunk.toString();
|
|
22667
|
-
chunk = chunk.next;
|
|
22668
|
-
}
|
|
22669
|
-
|
|
22670
|
-
return str + this.outro;
|
|
22671
|
-
}
|
|
22672
|
-
|
|
22673
|
-
isEmpty() {
|
|
22674
|
-
let chunk = this.firstChunk;
|
|
22675
|
-
do {
|
|
22676
|
-
if (
|
|
22677
|
-
(chunk.intro.length && chunk.intro.trim()) ||
|
|
22678
|
-
(chunk.content.length && chunk.content.trim()) ||
|
|
22679
|
-
(chunk.outro.length && chunk.outro.trim())
|
|
22680
|
-
)
|
|
22681
|
-
return false;
|
|
22682
|
-
} while ((chunk = chunk.next));
|
|
22683
|
-
return true;
|
|
22684
|
-
}
|
|
22685
|
-
|
|
22686
|
-
length() {
|
|
22687
|
-
let chunk = this.firstChunk;
|
|
22688
|
-
let length = 0;
|
|
22689
|
-
do {
|
|
22690
|
-
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
22691
|
-
} while ((chunk = chunk.next));
|
|
22692
|
-
return length;
|
|
22693
|
-
}
|
|
22694
|
-
|
|
22695
|
-
trimLines() {
|
|
22696
|
-
return this.trim('[\\r\\n]');
|
|
22697
|
-
}
|
|
22698
|
-
|
|
22699
|
-
trim(charType) {
|
|
22700
|
-
return this.trimStart(charType).trimEnd(charType);
|
|
22701
|
-
}
|
|
22702
|
-
|
|
22703
|
-
trimEndAborted(charType) {
|
|
22704
|
-
const rx = new RegExp((charType || '\\s') + '+$');
|
|
22705
|
-
|
|
22706
|
-
this.outro = this.outro.replace(rx, '');
|
|
22707
|
-
if (this.outro.length) return true;
|
|
22708
|
-
|
|
22709
|
-
let chunk = this.lastChunk;
|
|
22710
|
-
|
|
22711
|
-
do {
|
|
22712
|
-
const end = chunk.end;
|
|
22713
|
-
const aborted = chunk.trimEnd(rx);
|
|
22714
|
-
|
|
22715
|
-
// if chunk was trimmed, we have a new lastChunk
|
|
22716
|
-
if (chunk.end !== end) {
|
|
22717
|
-
if (this.lastChunk === chunk) {
|
|
22718
|
-
this.lastChunk = chunk.next;
|
|
22719
|
-
}
|
|
22720
|
-
|
|
22721
|
-
this.byEnd[chunk.end] = chunk;
|
|
22722
|
-
this.byStart[chunk.next.start] = chunk.next;
|
|
22723
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
22724
|
-
}
|
|
22725
|
-
|
|
22726
|
-
if (aborted) return true;
|
|
22727
|
-
chunk = chunk.previous;
|
|
22728
|
-
} while (chunk);
|
|
22729
|
-
|
|
22730
|
-
return false;
|
|
22731
|
-
}
|
|
22732
|
-
|
|
22733
|
-
trimEnd(charType) {
|
|
22734
|
-
this.trimEndAborted(charType);
|
|
22735
|
-
return this;
|
|
22736
|
-
}
|
|
22737
|
-
trimStartAborted(charType) {
|
|
22738
|
-
const rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
22739
|
-
|
|
22740
|
-
this.intro = this.intro.replace(rx, '');
|
|
22741
|
-
if (this.intro.length) return true;
|
|
22742
|
-
|
|
22743
|
-
let chunk = this.firstChunk;
|
|
22744
|
-
|
|
22745
|
-
do {
|
|
22746
|
-
const end = chunk.end;
|
|
22747
|
-
const aborted = chunk.trimStart(rx);
|
|
22748
|
-
|
|
22749
|
-
if (chunk.end !== end) {
|
|
22750
|
-
// special case...
|
|
22751
|
-
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
22752
|
-
|
|
22753
|
-
this.byEnd[chunk.end] = chunk;
|
|
22754
|
-
this.byStart[chunk.next.start] = chunk.next;
|
|
22755
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
22756
|
-
}
|
|
22757
|
-
|
|
22758
|
-
if (aborted) return true;
|
|
22759
|
-
chunk = chunk.next;
|
|
22760
|
-
} while (chunk);
|
|
22761
|
-
|
|
22762
|
-
return false;
|
|
22763
|
-
}
|
|
22764
|
-
|
|
22765
|
-
trimStart(charType) {
|
|
22766
|
-
this.trimStartAborted(charType);
|
|
22767
|
-
return this;
|
|
22768
|
-
}
|
|
22769
|
-
|
|
22770
|
-
hasChanged() {
|
|
22771
|
-
return this.original !== this.toString();
|
|
22772
|
-
}
|
|
22773
|
-
|
|
22774
|
-
_replaceRegexp(searchValue, replacement) {
|
|
22775
|
-
function getReplacement(match, str) {
|
|
22776
|
-
if (typeof replacement === 'string') {
|
|
22777
|
-
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
22778
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
22779
|
-
if (i === '$') return '$';
|
|
22780
|
-
if (i === '&') return match[0];
|
|
22781
|
-
const num = +i;
|
|
22782
|
-
if (num < match.length) return match[+i];
|
|
22783
|
-
return `$${i}`;
|
|
22784
|
-
});
|
|
22785
|
-
} else {
|
|
22786
|
-
return replacement(...match, match.index, str, match.groups);
|
|
22787
|
-
}
|
|
22788
|
-
}
|
|
22789
|
-
function matchAll(re, str) {
|
|
22790
|
-
let match;
|
|
22791
|
-
const matches = [];
|
|
22792
|
-
while ((match = re.exec(str))) {
|
|
22793
|
-
matches.push(match);
|
|
22794
|
-
}
|
|
22795
|
-
return matches;
|
|
22796
|
-
}
|
|
22797
|
-
if (searchValue.global) {
|
|
22798
|
-
const matches = matchAll(searchValue, this.original);
|
|
22799
|
-
matches.forEach((match) => {
|
|
22800
|
-
if (match.index != null) {
|
|
22801
|
-
const replacement = getReplacement(match, this.original);
|
|
22802
|
-
if (replacement !== match[0]) {
|
|
22803
|
-
this.overwrite(
|
|
22804
|
-
match.index,
|
|
22805
|
-
match.index + match[0].length,
|
|
22806
|
-
replacement
|
|
22807
|
-
);
|
|
22808
|
-
}
|
|
22809
|
-
}
|
|
22810
|
-
});
|
|
22811
|
-
} else {
|
|
22812
|
-
const match = this.original.match(searchValue);
|
|
22813
|
-
if (match && match.index != null) {
|
|
22814
|
-
const replacement = getReplacement(match, this.original);
|
|
22815
|
-
if (replacement !== match[0]) {
|
|
22816
|
-
this.overwrite(
|
|
22817
|
-
match.index,
|
|
22818
|
-
match.index + match[0].length,
|
|
22819
|
-
replacement
|
|
22820
|
-
);
|
|
22821
|
-
}
|
|
22822
|
-
}
|
|
22823
|
-
}
|
|
22824
|
-
return this;
|
|
22825
|
-
}
|
|
22826
|
-
|
|
22827
|
-
_replaceString(string, replacement) {
|
|
22828
|
-
const { original } = this;
|
|
22829
|
-
const index = original.indexOf(string);
|
|
22830
|
-
|
|
22831
|
-
if (index !== -1) {
|
|
22832
|
-
this.overwrite(index, index + string.length, replacement);
|
|
22833
|
-
}
|
|
22834
|
-
|
|
22835
|
-
return this;
|
|
22836
|
-
}
|
|
22837
|
-
|
|
22838
|
-
replace(searchValue, replacement) {
|
|
22839
|
-
if (typeof searchValue === 'string') {
|
|
22840
|
-
return this._replaceString(searchValue, replacement);
|
|
22841
|
-
}
|
|
22842
|
-
|
|
22843
|
-
return this._replaceRegexp(searchValue, replacement);
|
|
22844
|
-
}
|
|
22845
|
-
|
|
22846
|
-
_replaceAllString(string, replacement) {
|
|
22847
|
-
const { original } = this;
|
|
22848
|
-
const stringLength = string.length;
|
|
22849
|
-
for (
|
|
22850
|
-
let index = original.indexOf(string);
|
|
22851
|
-
index !== -1;
|
|
22852
|
-
index = original.indexOf(string, index + stringLength)
|
|
22853
|
-
) {
|
|
22854
|
-
const previous = original.slice(index, index + stringLength);
|
|
22855
|
-
if (previous !== replacement)
|
|
22856
|
-
this.overwrite(index, index + stringLength, replacement);
|
|
22857
|
-
}
|
|
22858
|
-
|
|
22859
|
-
return this;
|
|
22860
|
-
}
|
|
22861
|
-
|
|
22862
|
-
replaceAll(searchValue, replacement) {
|
|
22863
|
-
if (typeof searchValue === 'string') {
|
|
22864
|
-
return this._replaceAllString(searchValue, replacement);
|
|
22865
|
-
}
|
|
22866
|
-
|
|
22867
|
-
if (!searchValue.global) {
|
|
22868
|
-
throw new TypeError(
|
|
22869
|
-
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
22870
|
-
);
|
|
22871
|
-
}
|
|
22872
|
-
|
|
22873
|
-
return this._replaceRegexp(searchValue, replacement);
|
|
22874
|
-
}
|
|
22875
|
-
}
|
|
22876
|
-
|
|
22877
21550
|
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
|
22878
21551
|
function isArray(arg) {
|
|
22879
21552
|
return Array.isArray(arg);
|