@shopify/create-app 3.65.2 → 3.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2RSJVBMF.js +5625 -0
- package/dist/{chunk-Z65QJ5D7.js → chunk-4DRC2PSU.js} +17 -30
- package/dist/chunk-4OD45DDO.js +31508 -0
- package/dist/chunk-522OB3EU.js +45 -0
- package/dist/{chunk-JTKTLA7L.js → chunk-5U24TEX5.js} +5434 -10324
- package/dist/{chunk-GJPZCXGT.js → chunk-6A7MXLVB.js} +159 -405
- package/dist/{chunk-ZYKRTO5P.js → chunk-7ZCQLP5Y.js} +3 -3
- package/dist/{chunk-5LBEKXRW.js → chunk-FIJKOZJF.js} +19 -55
- package/dist/{chunk-QSKQTKTB.js → chunk-FT6PCF6E.js} +2441 -5551
- package/dist/chunk-GIUM5DCQ.js +2144 -0
- package/dist/chunk-HIAKHDLR.js +54 -0
- package/dist/chunk-LLSRDN3T.js +15352 -0
- package/dist/chunk-LTDD2GRL.js +111 -0
- package/dist/{chunk-63QVG2CD.js → chunk-NGBYQF44.js} +9 -9
- package/dist/chunk-NLC7NBUB.js +80 -0
- package/dist/{chunk-FMKVOTQK.js → chunk-O5K4AU7Q.js} +18 -34
- package/dist/chunk-OMDEA7TV.js +10615 -0
- package/dist/chunk-PNN7RS7Y.js +105 -0
- package/dist/{chunk-ZPL24Y2D.js → chunk-POZ5MGPT.js} +13 -18
- package/dist/chunk-T7T35H4F.js +108 -0
- package/dist/chunk-UBB7JKND.js +55 -0
- package/dist/chunk-VSLR7ET4.js +3034 -0
- package/dist/{chunk-SAO7C4LP.js → chunk-VZVGAREJ.js} +46821 -101962
- package/dist/{chunk-KDNBKIH4.js → chunk-WBQF4CSV.js} +12 -22
- package/dist/chunk-XVNW332R.js +524 -0
- package/dist/{chunk-YB6D4XQ7.js → chunk-Y4ECGRAF.js} +13 -23
- package/dist/chunk-ZAUZQLNO.js +3774 -0
- package/dist/chunk-ZULFH3SL.js +1847 -0
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +27 -27
- package/dist/commands/init.test.js +51 -70
- package/dist/{constants-24TFXZKQ.js → constants-WG7I7G3O.js} +5 -5
- package/dist/custom-oclif-loader-JKRJZ56E.js +47 -0
- package/dist/del-NW5KFKFP.js +1820 -0
- package/dist/devtools-UBOREV57.js +2572 -0
- package/dist/error-handler-26SLAJTC.js +35 -0
- package/dist/hooks/postrun.js +35 -42
- package/dist/hooks/prerun.js +58 -36
- package/dist/index.js +7 -7
- package/dist/lib-3K5QYF3J.js +9 -0
- package/dist/{local-3VUKCW4R.js → local-H6TW5MNX.js} +13 -13
- package/dist/magic-string.es-3RXPUXZF.js +843 -0
- package/dist/multipart-parser-QKUAJJP5.js +193 -0
- package/dist/{node-package-manager-HYZRZNU6.js → node-package-manager-QAUN6HGS.js} +16 -14
- package/dist/open-MZGVNFZO.js +197 -0
- package/dist/out-KDGAD475.js +6 -0
- package/dist/{path-CFPIDSWV.js → path-L375JOQ2.js} +4 -4
- package/dist/prompts/init.js +13 -13
- package/dist/prompts/init.test.js +42 -59
- package/dist/services/init.js +20 -20
- package/dist/services/init.test.js +5 -5
- package/dist/system-ZI2HKAKO.js +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-7NEDEALP.js → ui-727JEZUX.js} +13 -13
- package/dist/utils/template/cleanup.js +13 -13
- package/dist/utils/template/cleanup.test.js +18 -30
- package/dist/utils/template/npm.js +15 -15
- package/dist/utils/template/npm.test.js +48 -87
- package/oclif.manifest.json +1 -1
- package/package.json +3 -4
- package/dist/chunk-3US34ZNP.js +0 -145
- package/dist/chunk-3XYIOBQ2.js +0 -22131
- package/dist/chunk-6IZMEXPW.js +0 -105
- package/dist/chunk-7DRS5WXI.js +0 -7843
- package/dist/chunk-DL3MKXVR.js +0 -4754
- package/dist/chunk-HDVJ5FPK.js +0 -63
- package/dist/chunk-IKO7JBOJ.js +0 -14788
- package/dist/chunk-LSCXQWNO.js +0 -822
- package/dist/chunk-M2VKB6RG.js +0 -146
- package/dist/chunk-MCED27CG.js +0 -5626
- package/dist/chunk-SWNRLCC6.js +0 -61
- package/dist/chunk-T5LLJYYS.js +0 -195
- package/dist/chunk-U5LTJVWL.js +0 -3185
- package/dist/chunk-WR7YKB6H.js +0 -44962
- package/dist/chunk-YC4FLMDD.js +0 -74
- package/dist/chunk-ZRUHMMSQ.js +0 -2477
- package/dist/custom-oclif-loader-5KBN3RSN.js +0 -83
- package/dist/del-ZCPTGWOA.js +0 -2847
- package/dist/devtools-5N4JAP3R.js +0 -3588
- package/dist/error-handler-GTW2KSRC.js +0 -35
- package/dist/lib-CTSCLPNV.js +0 -9
- package/dist/magic-string.es-ATGURXGQ.js +0 -1353
- package/dist/multipart-parser-KYOHF24X.js +0 -360
- package/dist/open-JRS7RW22.js +0 -291
- package/dist/out-OKI3G7I5.js +0 -6
- package/dist/system-4S4YXUXZ.js +0 -26
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_cjs_shims
|
|
3
|
+
} from "./chunk-POZ5MGPT.js";
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.pnpm/magic-string@0.30.10/node_modules/magic-string/dist/magic-string.es.mjs
|
|
6
|
+
init_cjs_shims();
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
9
|
+
init_cjs_shims();
|
|
10
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
|
11
|
+
for (let i = 0; i < chars.length; i++) {
|
|
12
|
+
let c = chars.charCodeAt(i);
|
|
13
|
+
intToChar[i] = c, charToInt[c] = i;
|
|
14
|
+
}
|
|
15
|
+
var td = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
|
|
16
|
+
decode(buf) {
|
|
17
|
+
return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
|
|
18
|
+
}
|
|
19
|
+
} : {
|
|
20
|
+
decode(buf) {
|
|
21
|
+
let out = "";
|
|
22
|
+
for (let i = 0; i < buf.length; i++)
|
|
23
|
+
out += String.fromCharCode(buf[i]);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function encode(decoded) {
|
|
28
|
+
let state = new Int32Array(5), bufLength = 1024 * 16, subLength = bufLength - 36, buf = new Uint8Array(bufLength), sub = buf.subarray(0, subLength), pos = 0, out = "";
|
|
29
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
30
|
+
let line = decoded[i];
|
|
31
|
+
if (i > 0 && (pos === bufLength && (out += td.decode(buf), pos = 0), buf[pos++] = 59), line.length !== 0) {
|
|
32
|
+
state[0] = 0;
|
|
33
|
+
for (let j = 0; j < line.length; j++) {
|
|
34
|
+
let segment = line[j];
|
|
35
|
+
pos > subLength && (out += td.decode(sub), buf.copyWithin(0, subLength, pos), pos -= subLength), j > 0 && (buf[pos++] = 44), pos = encodeInteger(buf, pos, state, segment, 0), segment.length !== 1 && (pos = encodeInteger(buf, pos, state, segment, 1), pos = encodeInteger(buf, pos, state, segment, 2), pos = encodeInteger(buf, pos, state, segment, 3), segment.length !== 4 && (pos = encodeInteger(buf, pos, state, segment, 4)));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out + td.decode(buf.subarray(0, pos));
|
|
40
|
+
}
|
|
41
|
+
function encodeInteger(buf, pos, state, segment, j) {
|
|
42
|
+
let next = segment[j], num = next - state[j];
|
|
43
|
+
state[j] = next, num = num < 0 ? -num << 1 | 1 : num << 1;
|
|
44
|
+
do {
|
|
45
|
+
let clamped = num & 31;
|
|
46
|
+
num >>>= 5, num > 0 && (clamped |= 32), buf[pos++] = intToChar[clamped];
|
|
47
|
+
} while (num > 0);
|
|
48
|
+
return pos;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/.pnpm/magic-string@0.30.10/node_modules/magic-string/dist/magic-string.es.mjs
|
|
52
|
+
var BitSet = class _BitSet {
|
|
53
|
+
constructor(arg) {
|
|
54
|
+
this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
|
|
55
|
+
}
|
|
56
|
+
add(n2) {
|
|
57
|
+
this.bits[n2 >> 5] |= 1 << (n2 & 31);
|
|
58
|
+
}
|
|
59
|
+
has(n2) {
|
|
60
|
+
return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
|
|
61
|
+
}
|
|
62
|
+
}, Chunk = class _Chunk {
|
|
63
|
+
constructor(start, end, content) {
|
|
64
|
+
this.start = start, this.end = end, this.original = content, this.intro = "", this.outro = "", this.content = content, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
|
|
65
|
+
}
|
|
66
|
+
appendLeft(content) {
|
|
67
|
+
this.outro += content;
|
|
68
|
+
}
|
|
69
|
+
appendRight(content) {
|
|
70
|
+
this.intro = this.intro + content;
|
|
71
|
+
}
|
|
72
|
+
clone() {
|
|
73
|
+
let chunk = new _Chunk(this.start, this.end, this.original);
|
|
74
|
+
return chunk.intro = this.intro, chunk.outro = this.outro, chunk.content = this.content, chunk.storeName = this.storeName, chunk.edited = this.edited, chunk;
|
|
75
|
+
}
|
|
76
|
+
contains(index) {
|
|
77
|
+
return this.start < index && index < this.end;
|
|
78
|
+
}
|
|
79
|
+
eachNext(fn) {
|
|
80
|
+
let chunk = this;
|
|
81
|
+
for (; chunk; )
|
|
82
|
+
fn(chunk), chunk = chunk.next;
|
|
83
|
+
}
|
|
84
|
+
eachPrevious(fn) {
|
|
85
|
+
let chunk = this;
|
|
86
|
+
for (; chunk; )
|
|
87
|
+
fn(chunk), chunk = chunk.previous;
|
|
88
|
+
}
|
|
89
|
+
edit(content, storeName, contentOnly) {
|
|
90
|
+
return this.content = content, contentOnly || (this.intro = "", this.outro = ""), this.storeName = storeName, this.edited = !0, this;
|
|
91
|
+
}
|
|
92
|
+
prependLeft(content) {
|
|
93
|
+
this.outro = content + this.outro;
|
|
94
|
+
}
|
|
95
|
+
prependRight(content) {
|
|
96
|
+
this.intro = content + this.intro;
|
|
97
|
+
}
|
|
98
|
+
reset() {
|
|
99
|
+
this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
|
|
100
|
+
}
|
|
101
|
+
split(index) {
|
|
102
|
+
let sliceIndex = index - this.start, originalBefore = this.original.slice(0, sliceIndex), originalAfter = this.original.slice(sliceIndex);
|
|
103
|
+
this.original = originalBefore;
|
|
104
|
+
let newChunk = new _Chunk(index, this.end, originalAfter);
|
|
105
|
+
return newChunk.outro = this.outro, this.outro = "", this.end = index, this.edited ? (newChunk.edit("", !1), this.content = "") : this.content = originalBefore, newChunk.next = this.next, newChunk.next && (newChunk.next.previous = newChunk), newChunk.previous = this, this.next = newChunk, newChunk;
|
|
106
|
+
}
|
|
107
|
+
toString() {
|
|
108
|
+
return this.intro + this.content + this.outro;
|
|
109
|
+
}
|
|
110
|
+
trimEnd(rx) {
|
|
111
|
+
if (this.outro = this.outro.replace(rx, ""), this.outro.length)
|
|
112
|
+
return !0;
|
|
113
|
+
let trimmed = this.content.replace(rx, "");
|
|
114
|
+
if (trimmed.length)
|
|
115
|
+
return trimmed !== this.content && (this.split(this.start + trimmed.length).edit("", void 0, !0), this.edited && this.edit(trimmed, this.storeName, !0)), !0;
|
|
116
|
+
if (this.edit("", void 0, !0), this.intro = this.intro.replace(rx, ""), this.intro.length)
|
|
117
|
+
return !0;
|
|
118
|
+
}
|
|
119
|
+
trimStart(rx) {
|
|
120
|
+
if (this.intro = this.intro.replace(rx, ""), this.intro.length)
|
|
121
|
+
return !0;
|
|
122
|
+
let trimmed = this.content.replace(rx, "");
|
|
123
|
+
if (trimmed.length) {
|
|
124
|
+
if (trimmed !== this.content) {
|
|
125
|
+
let newChunk = this.split(this.end - trimmed.length);
|
|
126
|
+
this.edited && newChunk.edit(trimmed, this.storeName, !0), this.edit("", void 0, !0);
|
|
127
|
+
}
|
|
128
|
+
return !0;
|
|
129
|
+
} else if (this.edit("", void 0, !0), this.outro = this.outro.replace(rx, ""), this.outro.length)
|
|
130
|
+
return !0;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
function getBtoa() {
|
|
134
|
+
return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (str) => globalThis.btoa(unescape(encodeURIComponent(str))) : typeof Buffer == "function" ? (str) => Buffer.from(str, "utf-8").toString("base64") : () => {
|
|
135
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var btoa = /* @__PURE__ */ getBtoa(), SourceMap = class {
|
|
139
|
+
constructor(properties) {
|
|
140
|
+
this.version = 3, this.file = properties.file, this.sources = properties.sources, this.sourcesContent = properties.sourcesContent, this.names = properties.names, this.mappings = encode(properties.mappings), typeof properties.x_google_ignoreList < "u" && (this.x_google_ignoreList = properties.x_google_ignoreList);
|
|
141
|
+
}
|
|
142
|
+
toString() {
|
|
143
|
+
return JSON.stringify(this);
|
|
144
|
+
}
|
|
145
|
+
toUrl() {
|
|
146
|
+
return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function guessIndent(code) {
|
|
150
|
+
let lines = code.split(`
|
|
151
|
+
`), tabbed = lines.filter((line) => /^\t+/.test(line)), spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
152
|
+
if (tabbed.length === 0 && spaced.length === 0)
|
|
153
|
+
return null;
|
|
154
|
+
if (tabbed.length >= spaced.length)
|
|
155
|
+
return " ";
|
|
156
|
+
let min = spaced.reduce((previous, current) => {
|
|
157
|
+
let numSpaces = /^ +/.exec(current)[0].length;
|
|
158
|
+
return Math.min(numSpaces, previous);
|
|
159
|
+
}, 1 / 0);
|
|
160
|
+
return new Array(min + 1).join(" ");
|
|
161
|
+
}
|
|
162
|
+
function getRelativePath(from, to) {
|
|
163
|
+
let fromParts = from.split(/[/\\]/), toParts = to.split(/[/\\]/);
|
|
164
|
+
for (fromParts.pop(); fromParts[0] === toParts[0]; )
|
|
165
|
+
fromParts.shift(), toParts.shift();
|
|
166
|
+
if (fromParts.length) {
|
|
167
|
+
let i = fromParts.length;
|
|
168
|
+
for (; i--; )
|
|
169
|
+
fromParts[i] = "..";
|
|
170
|
+
}
|
|
171
|
+
return fromParts.concat(toParts).join("/");
|
|
172
|
+
}
|
|
173
|
+
var toString = Object.prototype.toString;
|
|
174
|
+
function isObject(thing) {
|
|
175
|
+
return toString.call(thing) === "[object Object]";
|
|
176
|
+
}
|
|
177
|
+
function getLocator(source) {
|
|
178
|
+
let originalLines = source.split(`
|
|
179
|
+
`), lineOffsets = [];
|
|
180
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++)
|
|
181
|
+
lineOffsets.push(pos), pos += originalLines[i].length + 1;
|
|
182
|
+
return function(index) {
|
|
183
|
+
let i = 0, j = lineOffsets.length;
|
|
184
|
+
for (; i < j; ) {
|
|
185
|
+
let m = i + j >> 1;
|
|
186
|
+
index < lineOffsets[m] ? j = m : i = m + 1;
|
|
187
|
+
}
|
|
188
|
+
let line = i - 1, column = index - lineOffsets[line];
|
|
189
|
+
return { line, column };
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
var wordRegex = /\w/, Mappings = class {
|
|
193
|
+
constructor(hires) {
|
|
194
|
+
this.hires = hires, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
|
|
195
|
+
}
|
|
196
|
+
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
197
|
+
if (content.length) {
|
|
198
|
+
let contentLengthMinusOne = content.length - 1, contentLineEnd = content.indexOf(`
|
|
199
|
+
`, 0), previousContentLineEnd = -1;
|
|
200
|
+
for (; contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd; ) {
|
|
201
|
+
let segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
202
|
+
nameIndex >= 0 && segment2.push(nameIndex), this.rawSegments.push(segment2), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, previousContentLineEnd = contentLineEnd, contentLineEnd = content.indexOf(`
|
|
203
|
+
`, contentLineEnd + 1);
|
|
204
|
+
}
|
|
205
|
+
let segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
206
|
+
nameIndex >= 0 && segment.push(nameIndex), this.rawSegments.push(segment), this.advance(content.slice(previousContentLineEnd + 1));
|
|
207
|
+
} else
|
|
208
|
+
this.pending && (this.rawSegments.push(this.pending), this.advance(content));
|
|
209
|
+
this.pending = null;
|
|
210
|
+
}
|
|
211
|
+
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
212
|
+
let originalCharIndex = chunk.start, first = !0, charInHiresBoundary = !1;
|
|
213
|
+
for (; originalCharIndex < chunk.end; ) {
|
|
214
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
215
|
+
let segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
216
|
+
this.hires === "boundary" ? wordRegex.test(original[originalCharIndex]) ? charInHiresBoundary || (this.rawSegments.push(segment), charInHiresBoundary = !0) : (this.rawSegments.push(segment), charInHiresBoundary = !1) : this.rawSegments.push(segment);
|
|
217
|
+
}
|
|
218
|
+
original[originalCharIndex] === `
|
|
219
|
+
` ? (loc.line += 1, loc.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, first = !0) : (loc.column += 1, this.generatedCodeColumn += 1, first = !1), originalCharIndex += 1;
|
|
220
|
+
}
|
|
221
|
+
this.pending = null;
|
|
222
|
+
}
|
|
223
|
+
advance(str) {
|
|
224
|
+
if (!str)
|
|
225
|
+
return;
|
|
226
|
+
let lines = str.split(`
|
|
227
|
+
`);
|
|
228
|
+
if (lines.length > 1) {
|
|
229
|
+
for (let i = 0; i < lines.length - 1; i++)
|
|
230
|
+
this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
231
|
+
this.generatedCodeColumn = 0;
|
|
232
|
+
}
|
|
233
|
+
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
234
|
+
}
|
|
235
|
+
}, n = `
|
|
236
|
+
`, warned = {
|
|
237
|
+
insertLeft: !1,
|
|
238
|
+
insertRight: !1,
|
|
239
|
+
storeName: !1
|
|
240
|
+
}, MagicString = class _MagicString {
|
|
241
|
+
constructor(string, options = {}) {
|
|
242
|
+
let chunk = new Chunk(0, string.length, string);
|
|
243
|
+
Object.defineProperties(this, {
|
|
244
|
+
original: { writable: !0, value: string },
|
|
245
|
+
outro: { writable: !0, value: "" },
|
|
246
|
+
intro: { writable: !0, value: "" },
|
|
247
|
+
firstChunk: { writable: !0, value: chunk },
|
|
248
|
+
lastChunk: { writable: !0, value: chunk },
|
|
249
|
+
lastSearchedChunk: { writable: !0, value: chunk },
|
|
250
|
+
byStart: { writable: !0, value: {} },
|
|
251
|
+
byEnd: { writable: !0, value: {} },
|
|
252
|
+
filename: { writable: !0, value: options.filename },
|
|
253
|
+
indentExclusionRanges: { writable: !0, value: options.indentExclusionRanges },
|
|
254
|
+
sourcemapLocations: { writable: !0, value: new BitSet() },
|
|
255
|
+
storedNames: { writable: !0, value: {} },
|
|
256
|
+
indentStr: { writable: !0, value: void 0 },
|
|
257
|
+
ignoreList: { writable: !0, value: options.ignoreList }
|
|
258
|
+
}), this.byStart[0] = chunk, this.byEnd[string.length] = chunk;
|
|
259
|
+
}
|
|
260
|
+
addSourcemapLocation(char) {
|
|
261
|
+
this.sourcemapLocations.add(char);
|
|
262
|
+
}
|
|
263
|
+
append(content) {
|
|
264
|
+
if (typeof content != "string")
|
|
265
|
+
throw new TypeError("outro content must be a string");
|
|
266
|
+
return this.outro += content, this;
|
|
267
|
+
}
|
|
268
|
+
appendLeft(index, content) {
|
|
269
|
+
if (typeof content != "string")
|
|
270
|
+
throw new TypeError("inserted content must be a string");
|
|
271
|
+
this._split(index);
|
|
272
|
+
let chunk = this.byEnd[index];
|
|
273
|
+
return chunk ? chunk.appendLeft(content) : this.intro += content, this;
|
|
274
|
+
}
|
|
275
|
+
appendRight(index, content) {
|
|
276
|
+
if (typeof content != "string")
|
|
277
|
+
throw new TypeError("inserted content must be a string");
|
|
278
|
+
this._split(index);
|
|
279
|
+
let chunk = this.byStart[index];
|
|
280
|
+
return chunk ? chunk.appendRight(content) : this.outro += content, this;
|
|
281
|
+
}
|
|
282
|
+
clone() {
|
|
283
|
+
let cloned = new _MagicString(this.original, { filename: this.filename }), originalChunk = this.firstChunk, clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
284
|
+
for (; originalChunk; ) {
|
|
285
|
+
cloned.byStart[clonedChunk.start] = clonedChunk, cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
286
|
+
let nextOriginalChunk = originalChunk.next, nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
287
|
+
nextClonedChunk && (clonedChunk.next = nextClonedChunk, nextClonedChunk.previous = clonedChunk, clonedChunk = nextClonedChunk), originalChunk = nextOriginalChunk;
|
|
288
|
+
}
|
|
289
|
+
return cloned.lastChunk = clonedChunk, this.indentExclusionRanges && (cloned.indentExclusionRanges = this.indentExclusionRanges.slice()), cloned.sourcemapLocations = new BitSet(this.sourcemapLocations), cloned.intro = this.intro, cloned.outro = this.outro, cloned;
|
|
290
|
+
}
|
|
291
|
+
generateDecodedMap(options) {
|
|
292
|
+
options = options || {};
|
|
293
|
+
let sourceIndex = 0, names = Object.keys(this.storedNames), mappings = new Mappings(options.hires), locate = getLocator(this.original);
|
|
294
|
+
return this.intro && mappings.advance(this.intro), this.firstChunk.eachNext((chunk) => {
|
|
295
|
+
let loc = locate(chunk.start);
|
|
296
|
+
chunk.intro.length && mappings.advance(chunk.intro), chunk.edited ? mappings.addEdit(
|
|
297
|
+
sourceIndex,
|
|
298
|
+
chunk.content,
|
|
299
|
+
loc,
|
|
300
|
+
chunk.storeName ? names.indexOf(chunk.original) : -1
|
|
301
|
+
) : mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations), chunk.outro.length && mappings.advance(chunk.outro);
|
|
302
|
+
}), {
|
|
303
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
304
|
+
sources: [
|
|
305
|
+
options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
|
|
306
|
+
],
|
|
307
|
+
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
308
|
+
names,
|
|
309
|
+
mappings: mappings.raw,
|
|
310
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
generateMap(options) {
|
|
314
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
315
|
+
}
|
|
316
|
+
_ensureindentStr() {
|
|
317
|
+
this.indentStr === void 0 && (this.indentStr = guessIndent(this.original));
|
|
318
|
+
}
|
|
319
|
+
_getRawIndentString() {
|
|
320
|
+
return this._ensureindentStr(), this.indentStr;
|
|
321
|
+
}
|
|
322
|
+
getIndentString() {
|
|
323
|
+
return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
|
|
324
|
+
}
|
|
325
|
+
indent(indentStr, options) {
|
|
326
|
+
let pattern = /^[^\r\n]/gm;
|
|
327
|
+
if (isObject(indentStr) && (options = indentStr, indentStr = void 0), indentStr === void 0 && (this._ensureindentStr(), indentStr = this.indentStr || " "), indentStr === "")
|
|
328
|
+
return this;
|
|
329
|
+
options = options || {};
|
|
330
|
+
let isExcluded = {};
|
|
331
|
+
options.exclude && (typeof options.exclude[0] == "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
332
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1)
|
|
333
|
+
isExcluded[i] = !0;
|
|
334
|
+
});
|
|
335
|
+
let shouldIndentNextCharacter = options.indentStart !== !1, replacer = (match) => shouldIndentNextCharacter ? `${indentStr}${match}` : (shouldIndentNextCharacter = !0, match);
|
|
336
|
+
this.intro = this.intro.replace(pattern, replacer);
|
|
337
|
+
let charIndex = 0, chunk = this.firstChunk;
|
|
338
|
+
for (; chunk; ) {
|
|
339
|
+
let end = chunk.end;
|
|
340
|
+
if (chunk.edited)
|
|
341
|
+
isExcluded[charIndex] || (chunk.content = chunk.content.replace(pattern, replacer), chunk.content.length && (shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === `
|
|
342
|
+
`));
|
|
343
|
+
else
|
|
344
|
+
for (charIndex = chunk.start; charIndex < end; ) {
|
|
345
|
+
if (!isExcluded[charIndex]) {
|
|
346
|
+
let char = this.original[charIndex];
|
|
347
|
+
char === `
|
|
348
|
+
` ? shouldIndentNextCharacter = !0 : char !== "\r" && shouldIndentNextCharacter && (shouldIndentNextCharacter = !1, charIndex === chunk.start || (this._splitChunk(chunk, charIndex), chunk = chunk.next), chunk.prependRight(indentStr));
|
|
349
|
+
}
|
|
350
|
+
charIndex += 1;
|
|
351
|
+
}
|
|
352
|
+
charIndex = chunk.end, chunk = chunk.next;
|
|
353
|
+
}
|
|
354
|
+
return this.outro = this.outro.replace(pattern, replacer), this;
|
|
355
|
+
}
|
|
356
|
+
insert() {
|
|
357
|
+
throw new Error(
|
|
358
|
+
"magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
insertLeft(index, content) {
|
|
362
|
+
return warned.insertLeft || (console.warn(
|
|
363
|
+
"magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
|
|
364
|
+
), warned.insertLeft = !0), this.appendLeft(index, content);
|
|
365
|
+
}
|
|
366
|
+
insertRight(index, content) {
|
|
367
|
+
return warned.insertRight || (console.warn(
|
|
368
|
+
"magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
|
|
369
|
+
), warned.insertRight = !0), this.prependRight(index, content);
|
|
370
|
+
}
|
|
371
|
+
move(start, end, index) {
|
|
372
|
+
if (index >= start && index <= end)
|
|
373
|
+
throw new Error("Cannot move a selection inside itself");
|
|
374
|
+
this._split(start), this._split(end), this._split(index);
|
|
375
|
+
let first = this.byStart[start], last = this.byEnd[end], oldLeft = first.previous, oldRight = last.next, newRight = this.byStart[index];
|
|
376
|
+
if (!newRight && last === this.lastChunk)
|
|
377
|
+
return this;
|
|
378
|
+
let newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
379
|
+
return oldLeft && (oldLeft.next = oldRight), oldRight && (oldRight.previous = oldLeft), newLeft && (newLeft.next = first), newRight && (newRight.previous = last), first.previous || (this.firstChunk = last.next), last.next || (this.lastChunk = first.previous, this.lastChunk.next = null), first.previous = newLeft, last.next = newRight || null, newLeft || (this.firstChunk = first), newRight || (this.lastChunk = last), this;
|
|
380
|
+
}
|
|
381
|
+
overwrite(start, end, content, options) {
|
|
382
|
+
return options = options || {}, this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
383
|
+
}
|
|
384
|
+
update(start, end, content, options) {
|
|
385
|
+
if (typeof content != "string")
|
|
386
|
+
throw new TypeError("replacement content must be a string");
|
|
387
|
+
for (; start < 0; )
|
|
388
|
+
start += this.original.length;
|
|
389
|
+
for (; end < 0; )
|
|
390
|
+
end += this.original.length;
|
|
391
|
+
if (end > this.original.length)
|
|
392
|
+
throw new Error("end is out of bounds");
|
|
393
|
+
if (start === end)
|
|
394
|
+
throw new Error(
|
|
395
|
+
"Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
|
|
396
|
+
);
|
|
397
|
+
this._split(start), this._split(end), options === !0 && (warned.storeName || (console.warn(
|
|
398
|
+
"The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
|
|
399
|
+
), warned.storeName = !0), options = { storeName: !0 });
|
|
400
|
+
let storeName = options !== void 0 ? options.storeName : !1, overwrite = options !== void 0 ? options.overwrite : !1;
|
|
401
|
+
if (storeName) {
|
|
402
|
+
let original = this.original.slice(start, end);
|
|
403
|
+
Object.defineProperty(this.storedNames, original, {
|
|
404
|
+
writable: !0,
|
|
405
|
+
value: !0,
|
|
406
|
+
enumerable: !0
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
let first = this.byStart[start], last = this.byEnd[end];
|
|
410
|
+
if (first) {
|
|
411
|
+
let chunk = first;
|
|
412
|
+
for (; chunk !== last; ) {
|
|
413
|
+
if (chunk.next !== this.byStart[chunk.end])
|
|
414
|
+
throw new Error("Cannot overwrite across a split point");
|
|
415
|
+
chunk = chunk.next, chunk.edit("", !1);
|
|
416
|
+
}
|
|
417
|
+
first.edit(content, storeName, !overwrite);
|
|
418
|
+
} else {
|
|
419
|
+
let newChunk = new Chunk(start, end, "").edit(content, storeName);
|
|
420
|
+
last.next = newChunk, newChunk.previous = last;
|
|
421
|
+
}
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
prepend(content) {
|
|
425
|
+
if (typeof content != "string")
|
|
426
|
+
throw new TypeError("outro content must be a string");
|
|
427
|
+
return this.intro = content + this.intro, this;
|
|
428
|
+
}
|
|
429
|
+
prependLeft(index, content) {
|
|
430
|
+
if (typeof content != "string")
|
|
431
|
+
throw new TypeError("inserted content must be a string");
|
|
432
|
+
this._split(index);
|
|
433
|
+
let chunk = this.byEnd[index];
|
|
434
|
+
return chunk ? chunk.prependLeft(content) : this.intro = content + this.intro, this;
|
|
435
|
+
}
|
|
436
|
+
prependRight(index, content) {
|
|
437
|
+
if (typeof content != "string")
|
|
438
|
+
throw new TypeError("inserted content must be a string");
|
|
439
|
+
this._split(index);
|
|
440
|
+
let chunk = this.byStart[index];
|
|
441
|
+
return chunk ? chunk.prependRight(content) : this.outro = content + this.outro, this;
|
|
442
|
+
}
|
|
443
|
+
remove(start, end) {
|
|
444
|
+
for (; start < 0; )
|
|
445
|
+
start += this.original.length;
|
|
446
|
+
for (; end < 0; )
|
|
447
|
+
end += this.original.length;
|
|
448
|
+
if (start === end)
|
|
449
|
+
return this;
|
|
450
|
+
if (start < 0 || end > this.original.length)
|
|
451
|
+
throw new Error("Character is out of bounds");
|
|
452
|
+
if (start > end)
|
|
453
|
+
throw new Error("end must be greater than start");
|
|
454
|
+
this._split(start), this._split(end);
|
|
455
|
+
let chunk = this.byStart[start];
|
|
456
|
+
for (; chunk; )
|
|
457
|
+
chunk.intro = "", chunk.outro = "", chunk.edit(""), chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
460
|
+
reset(start, end) {
|
|
461
|
+
for (; start < 0; )
|
|
462
|
+
start += this.original.length;
|
|
463
|
+
for (; end < 0; )
|
|
464
|
+
end += this.original.length;
|
|
465
|
+
if (start === end)
|
|
466
|
+
return this;
|
|
467
|
+
if (start < 0 || end > this.original.length)
|
|
468
|
+
throw new Error("Character is out of bounds");
|
|
469
|
+
if (start > end)
|
|
470
|
+
throw new Error("end must be greater than start");
|
|
471
|
+
this._split(start), this._split(end);
|
|
472
|
+
let chunk = this.byStart[start];
|
|
473
|
+
for (; chunk; )
|
|
474
|
+
chunk.reset(), chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
475
|
+
return this;
|
|
476
|
+
}
|
|
477
|
+
lastChar() {
|
|
478
|
+
if (this.outro.length)
|
|
479
|
+
return this.outro[this.outro.length - 1];
|
|
480
|
+
let chunk = this.lastChunk;
|
|
481
|
+
do {
|
|
482
|
+
if (chunk.outro.length)
|
|
483
|
+
return chunk.outro[chunk.outro.length - 1];
|
|
484
|
+
if (chunk.content.length)
|
|
485
|
+
return chunk.content[chunk.content.length - 1];
|
|
486
|
+
if (chunk.intro.length)
|
|
487
|
+
return chunk.intro[chunk.intro.length - 1];
|
|
488
|
+
} while (chunk = chunk.previous);
|
|
489
|
+
return this.intro.length ? this.intro[this.intro.length - 1] : "";
|
|
490
|
+
}
|
|
491
|
+
lastLine() {
|
|
492
|
+
let lineIndex = this.outro.lastIndexOf(n);
|
|
493
|
+
if (lineIndex !== -1)
|
|
494
|
+
return this.outro.substr(lineIndex + 1);
|
|
495
|
+
let lineStr = this.outro, chunk = this.lastChunk;
|
|
496
|
+
do {
|
|
497
|
+
if (chunk.outro.length > 0) {
|
|
498
|
+
if (lineIndex = chunk.outro.lastIndexOf(n), lineIndex !== -1)
|
|
499
|
+
return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
500
|
+
lineStr = chunk.outro + lineStr;
|
|
501
|
+
}
|
|
502
|
+
if (chunk.content.length > 0) {
|
|
503
|
+
if (lineIndex = chunk.content.lastIndexOf(n), lineIndex !== -1)
|
|
504
|
+
return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
505
|
+
lineStr = chunk.content + lineStr;
|
|
506
|
+
}
|
|
507
|
+
if (chunk.intro.length > 0) {
|
|
508
|
+
if (lineIndex = chunk.intro.lastIndexOf(n), lineIndex !== -1)
|
|
509
|
+
return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
510
|
+
lineStr = chunk.intro + lineStr;
|
|
511
|
+
}
|
|
512
|
+
} while (chunk = chunk.previous);
|
|
513
|
+
return lineIndex = this.intro.lastIndexOf(n), lineIndex !== -1 ? this.intro.substr(lineIndex + 1) + lineStr : this.intro + lineStr;
|
|
514
|
+
}
|
|
515
|
+
slice(start = 0, end = this.original.length) {
|
|
516
|
+
for (; start < 0; )
|
|
517
|
+
start += this.original.length;
|
|
518
|
+
for (; end < 0; )
|
|
519
|
+
end += this.original.length;
|
|
520
|
+
let result = "", chunk = this.firstChunk;
|
|
521
|
+
for (; chunk && (chunk.start > start || chunk.end <= start); ) {
|
|
522
|
+
if (chunk.start < end && chunk.end >= end)
|
|
523
|
+
return result;
|
|
524
|
+
chunk = chunk.next;
|
|
525
|
+
}
|
|
526
|
+
if (chunk && chunk.edited && chunk.start !== start)
|
|
527
|
+
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
528
|
+
let startChunk = chunk;
|
|
529
|
+
for (; chunk; ) {
|
|
530
|
+
chunk.intro && (startChunk !== chunk || chunk.start === start) && (result += chunk.intro);
|
|
531
|
+
let containsEnd = chunk.start < end && chunk.end >= end;
|
|
532
|
+
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
533
|
+
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
534
|
+
let sliceStart = startChunk === chunk ? start - chunk.start : 0, sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
535
|
+
if (result += chunk.content.slice(sliceStart, sliceEnd), chunk.outro && (!containsEnd || chunk.end === end) && (result += chunk.outro), containsEnd)
|
|
536
|
+
break;
|
|
537
|
+
chunk = chunk.next;
|
|
538
|
+
}
|
|
539
|
+
return result;
|
|
540
|
+
}
|
|
541
|
+
// TODO deprecate this? not really very useful
|
|
542
|
+
snip(start, end) {
|
|
543
|
+
let clone = this.clone();
|
|
544
|
+
return clone.remove(0, start), clone.remove(end, clone.original.length), clone;
|
|
545
|
+
}
|
|
546
|
+
_split(index) {
|
|
547
|
+
if (this.byStart[index] || this.byEnd[index])
|
|
548
|
+
return;
|
|
549
|
+
let chunk = this.lastSearchedChunk, searchForward = index > chunk.end;
|
|
550
|
+
for (; chunk; ) {
|
|
551
|
+
if (chunk.contains(index))
|
|
552
|
+
return this._splitChunk(chunk, index);
|
|
553
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
_splitChunk(chunk, index) {
|
|
557
|
+
if (chunk.edited && chunk.content.length) {
|
|
558
|
+
let loc = getLocator(this.original)(index);
|
|
559
|
+
throw new Error(
|
|
560
|
+
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
let newChunk = chunk.split(index);
|
|
564
|
+
return this.byEnd[index] = chunk, this.byStart[index] = newChunk, this.byEnd[newChunk.end] = newChunk, chunk === this.lastChunk && (this.lastChunk = newChunk), this.lastSearchedChunk = chunk, !0;
|
|
565
|
+
}
|
|
566
|
+
toString() {
|
|
567
|
+
let str = this.intro, chunk = this.firstChunk;
|
|
568
|
+
for (; chunk; )
|
|
569
|
+
str += chunk.toString(), chunk = chunk.next;
|
|
570
|
+
return str + this.outro;
|
|
571
|
+
}
|
|
572
|
+
isEmpty() {
|
|
573
|
+
let chunk = this.firstChunk;
|
|
574
|
+
do
|
|
575
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
|
|
576
|
+
return !1;
|
|
577
|
+
while (chunk = chunk.next);
|
|
578
|
+
return !0;
|
|
579
|
+
}
|
|
580
|
+
length() {
|
|
581
|
+
let chunk = this.firstChunk, length = 0;
|
|
582
|
+
do
|
|
583
|
+
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
584
|
+
while (chunk = chunk.next);
|
|
585
|
+
return length;
|
|
586
|
+
}
|
|
587
|
+
trimLines() {
|
|
588
|
+
return this.trim("[\\r\\n]");
|
|
589
|
+
}
|
|
590
|
+
trim(charType) {
|
|
591
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
592
|
+
}
|
|
593
|
+
trimEndAborted(charType) {
|
|
594
|
+
let rx = new RegExp((charType || "\\s") + "+$");
|
|
595
|
+
if (this.outro = this.outro.replace(rx, ""), this.outro.length)
|
|
596
|
+
return !0;
|
|
597
|
+
let chunk = this.lastChunk;
|
|
598
|
+
do {
|
|
599
|
+
let end = chunk.end, aborted = chunk.trimEnd(rx);
|
|
600
|
+
if (chunk.end !== end && (this.lastChunk === chunk && (this.lastChunk = chunk.next), this.byEnd[chunk.end] = chunk, this.byStart[chunk.next.start] = chunk.next, this.byEnd[chunk.next.end] = chunk.next), aborted)
|
|
601
|
+
return !0;
|
|
602
|
+
chunk = chunk.previous;
|
|
603
|
+
} while (chunk);
|
|
604
|
+
return !1;
|
|
605
|
+
}
|
|
606
|
+
trimEnd(charType) {
|
|
607
|
+
return this.trimEndAborted(charType), this;
|
|
608
|
+
}
|
|
609
|
+
trimStartAborted(charType) {
|
|
610
|
+
let rx = new RegExp("^" + (charType || "\\s") + "+");
|
|
611
|
+
if (this.intro = this.intro.replace(rx, ""), this.intro.length)
|
|
612
|
+
return !0;
|
|
613
|
+
let chunk = this.firstChunk;
|
|
614
|
+
do {
|
|
615
|
+
let end = chunk.end, aborted = chunk.trimStart(rx);
|
|
616
|
+
if (chunk.end !== end && (chunk === this.lastChunk && (this.lastChunk = chunk.next), this.byEnd[chunk.end] = chunk, this.byStart[chunk.next.start] = chunk.next, this.byEnd[chunk.next.end] = chunk.next), aborted)
|
|
617
|
+
return !0;
|
|
618
|
+
chunk = chunk.next;
|
|
619
|
+
} while (chunk);
|
|
620
|
+
return !1;
|
|
621
|
+
}
|
|
622
|
+
trimStart(charType) {
|
|
623
|
+
return this.trimStartAborted(charType), this;
|
|
624
|
+
}
|
|
625
|
+
hasChanged() {
|
|
626
|
+
return this.original !== this.toString();
|
|
627
|
+
}
|
|
628
|
+
_replaceRegexp(searchValue, replacement) {
|
|
629
|
+
function getReplacement(match, str) {
|
|
630
|
+
return typeof replacement == "string" ? replacement.replace(/\$(\$|&|\d+)/g, (_, i) => i === "$" ? "$" : i === "&" ? match[0] : +i < match.length ? match[+i] : `$${i}`) : replacement(...match, match.index, str, match.groups);
|
|
631
|
+
}
|
|
632
|
+
function matchAll(re, str) {
|
|
633
|
+
let match, matches = [];
|
|
634
|
+
for (; match = re.exec(str); )
|
|
635
|
+
matches.push(match);
|
|
636
|
+
return matches;
|
|
637
|
+
}
|
|
638
|
+
if (searchValue.global)
|
|
639
|
+
matchAll(searchValue, this.original).forEach((match) => {
|
|
640
|
+
if (match.index != null) {
|
|
641
|
+
let replacement2 = getReplacement(match, this.original);
|
|
642
|
+
replacement2 !== match[0] && this.overwrite(
|
|
643
|
+
match.index,
|
|
644
|
+
match.index + match[0].length,
|
|
645
|
+
replacement2
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
else {
|
|
650
|
+
let match = this.original.match(searchValue);
|
|
651
|
+
if (match && match.index != null) {
|
|
652
|
+
let replacement2 = getReplacement(match, this.original);
|
|
653
|
+
replacement2 !== match[0] && this.overwrite(
|
|
654
|
+
match.index,
|
|
655
|
+
match.index + match[0].length,
|
|
656
|
+
replacement2
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return this;
|
|
661
|
+
}
|
|
662
|
+
_replaceString(string, replacement) {
|
|
663
|
+
let { original } = this, index = original.indexOf(string);
|
|
664
|
+
return index !== -1 && this.overwrite(index, index + string.length, replacement), this;
|
|
665
|
+
}
|
|
666
|
+
replace(searchValue, replacement) {
|
|
667
|
+
return typeof searchValue == "string" ? this._replaceString(searchValue, replacement) : this._replaceRegexp(searchValue, replacement);
|
|
668
|
+
}
|
|
669
|
+
_replaceAllString(string, replacement) {
|
|
670
|
+
let { original } = this, stringLength = string.length;
|
|
671
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength))
|
|
672
|
+
original.slice(index, index + stringLength) !== replacement && this.overwrite(index, index + stringLength, replacement);
|
|
673
|
+
return this;
|
|
674
|
+
}
|
|
675
|
+
replaceAll(searchValue, replacement) {
|
|
676
|
+
if (typeof searchValue == "string")
|
|
677
|
+
return this._replaceAllString(searchValue, replacement);
|
|
678
|
+
if (!searchValue.global)
|
|
679
|
+
throw new TypeError(
|
|
680
|
+
"MagicString.prototype.replaceAll called with a non-global RegExp argument"
|
|
681
|
+
);
|
|
682
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
683
|
+
}
|
|
684
|
+
}, hasOwnProp = Object.prototype.hasOwnProperty, Bundle = class _Bundle {
|
|
685
|
+
constructor(options = {}) {
|
|
686
|
+
this.intro = options.intro || "", this.separator = options.separator !== void 0 ? options.separator : `
|
|
687
|
+
`, this.sources = [], this.uniqueSources = [], this.uniqueSourceIndexByFilename = {};
|
|
688
|
+
}
|
|
689
|
+
addSource(source) {
|
|
690
|
+
if (source instanceof MagicString)
|
|
691
|
+
return this.addSource({
|
|
692
|
+
content: source,
|
|
693
|
+
filename: source.filename,
|
|
694
|
+
separator: this.separator
|
|
695
|
+
});
|
|
696
|
+
if (!isObject(source) || !source.content)
|
|
697
|
+
throw new Error(
|
|
698
|
+
"bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`"
|
|
699
|
+
);
|
|
700
|
+
if (["filename", "ignoreList", "indentExclusionRanges", "separator"].forEach((option) => {
|
|
701
|
+
hasOwnProp.call(source, option) || (source[option] = source.content[option]);
|
|
702
|
+
}), source.separator === void 0 && (source.separator = this.separator), source.filename)
|
|
703
|
+
if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename))
|
|
704
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length, this.uniqueSources.push({ filename: source.filename, content: source.content.original });
|
|
705
|
+
else {
|
|
706
|
+
let uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
707
|
+
if (source.content.original !== uniqueSource.content)
|
|
708
|
+
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
709
|
+
}
|
|
710
|
+
return this.sources.push(source), this;
|
|
711
|
+
}
|
|
712
|
+
append(str, options) {
|
|
713
|
+
return this.addSource({
|
|
714
|
+
content: new MagicString(str),
|
|
715
|
+
separator: options && options.separator || ""
|
|
716
|
+
}), this;
|
|
717
|
+
}
|
|
718
|
+
clone() {
|
|
719
|
+
let bundle = new _Bundle({
|
|
720
|
+
intro: this.intro,
|
|
721
|
+
separator: this.separator
|
|
722
|
+
});
|
|
723
|
+
return this.sources.forEach((source) => {
|
|
724
|
+
bundle.addSource({
|
|
725
|
+
filename: source.filename,
|
|
726
|
+
content: source.content.clone(),
|
|
727
|
+
separator: source.separator
|
|
728
|
+
});
|
|
729
|
+
}), bundle;
|
|
730
|
+
}
|
|
731
|
+
generateDecodedMap(options = {}) {
|
|
732
|
+
let names = [], x_google_ignoreList;
|
|
733
|
+
this.sources.forEach((source) => {
|
|
734
|
+
Object.keys(source.content.storedNames).forEach((name) => {
|
|
735
|
+
~names.indexOf(name) || names.push(name);
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
let mappings = new Mappings(options.hires);
|
|
739
|
+
return this.intro && mappings.advance(this.intro), this.sources.forEach((source, i) => {
|
|
740
|
+
i > 0 && mappings.advance(this.separator);
|
|
741
|
+
let sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1, magicString = source.content, locate = getLocator(magicString.original);
|
|
742
|
+
magicString.intro && mappings.advance(magicString.intro), magicString.firstChunk.eachNext((chunk) => {
|
|
743
|
+
let loc = locate(chunk.start);
|
|
744
|
+
chunk.intro.length && mappings.advance(chunk.intro), source.filename ? chunk.edited ? mappings.addEdit(
|
|
745
|
+
sourceIndex,
|
|
746
|
+
chunk.content,
|
|
747
|
+
loc,
|
|
748
|
+
chunk.storeName ? names.indexOf(chunk.original) : -1
|
|
749
|
+
) : mappings.addUneditedChunk(
|
|
750
|
+
sourceIndex,
|
|
751
|
+
chunk,
|
|
752
|
+
magicString.original,
|
|
753
|
+
loc,
|
|
754
|
+
magicString.sourcemapLocations
|
|
755
|
+
) : mappings.advance(chunk.content), chunk.outro.length && mappings.advance(chunk.outro);
|
|
756
|
+
}), magicString.outro && mappings.advance(magicString.outro), source.ignoreList && sourceIndex !== -1 && (x_google_ignoreList === void 0 && (x_google_ignoreList = []), x_google_ignoreList.push(sourceIndex));
|
|
757
|
+
}), {
|
|
758
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
759
|
+
sources: this.uniqueSources.map((source) => options.file ? getRelativePath(options.file, source.filename) : source.filename),
|
|
760
|
+
sourcesContent: this.uniqueSources.map((source) => options.includeContent ? source.content : null),
|
|
761
|
+
names,
|
|
762
|
+
mappings: mappings.raw,
|
|
763
|
+
x_google_ignoreList
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
generateMap(options) {
|
|
767
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
768
|
+
}
|
|
769
|
+
getIndentString() {
|
|
770
|
+
let indentStringCounts = {};
|
|
771
|
+
return this.sources.forEach((source) => {
|
|
772
|
+
let indentStr = source.content._getRawIndentString();
|
|
773
|
+
indentStr !== null && (indentStringCounts[indentStr] || (indentStringCounts[indentStr] = 0), indentStringCounts[indentStr] += 1);
|
|
774
|
+
}), Object.keys(indentStringCounts).sort((a, b) => indentStringCounts[a] - indentStringCounts[b])[0] || " ";
|
|
775
|
+
}
|
|
776
|
+
indent(indentStr) {
|
|
777
|
+
if (arguments.length || (indentStr = this.getIndentString()), indentStr === "")
|
|
778
|
+
return this;
|
|
779
|
+
let trailingNewline = !this.intro || this.intro.slice(-1) === `
|
|
780
|
+
`;
|
|
781
|
+
return this.sources.forEach((source, i) => {
|
|
782
|
+
let separator = source.separator !== void 0 ? source.separator : this.separator, indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
|
783
|
+
source.content.indent(indentStr, {
|
|
784
|
+
exclude: source.indentExclusionRanges,
|
|
785
|
+
indentStart
|
|
786
|
+
//: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
|
|
787
|
+
}), trailingNewline = source.content.lastChar() === `
|
|
788
|
+
`;
|
|
789
|
+
}), this.intro && (this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => index > 0 ? indentStr + match : match)), this;
|
|
790
|
+
}
|
|
791
|
+
prepend(str) {
|
|
792
|
+
return this.intro = str + this.intro, this;
|
|
793
|
+
}
|
|
794
|
+
toString() {
|
|
795
|
+
let body = this.sources.map((source, i) => {
|
|
796
|
+
let separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
797
|
+
return (i > 0 ? separator : "") + source.content.toString();
|
|
798
|
+
}).join("");
|
|
799
|
+
return this.intro + body;
|
|
800
|
+
}
|
|
801
|
+
isEmpty() {
|
|
802
|
+
return !(this.intro.length && this.intro.trim() || this.sources.some((source) => !source.content.isEmpty()));
|
|
803
|
+
}
|
|
804
|
+
length() {
|
|
805
|
+
return this.sources.reduce(
|
|
806
|
+
(length, source) => length + source.content.length(),
|
|
807
|
+
this.intro.length
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
trimLines() {
|
|
811
|
+
return this.trim("[\\r\\n]");
|
|
812
|
+
}
|
|
813
|
+
trim(charType) {
|
|
814
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
815
|
+
}
|
|
816
|
+
trimStart(charType) {
|
|
817
|
+
let rx = new RegExp("^" + (charType || "\\s") + "+");
|
|
818
|
+
if (this.intro = this.intro.replace(rx, ""), !this.intro) {
|
|
819
|
+
let source, i = 0;
|
|
820
|
+
do
|
|
821
|
+
if (source = this.sources[i++], !source)
|
|
822
|
+
break;
|
|
823
|
+
while (!source.content.trimStartAborted(charType));
|
|
824
|
+
}
|
|
825
|
+
return this;
|
|
826
|
+
}
|
|
827
|
+
trimEnd(charType) {
|
|
828
|
+
let rx = new RegExp((charType || "\\s") + "+$"), source, i = this.sources.length - 1;
|
|
829
|
+
do
|
|
830
|
+
if (source = this.sources[i--], !source) {
|
|
831
|
+
this.intro = this.intro.replace(rx, "");
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
while (!source.content.trimEndAborted(charType));
|
|
835
|
+
return this;
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
export {
|
|
839
|
+
Bundle,
|
|
840
|
+
SourceMap,
|
|
841
|
+
MagicString as default
|
|
842
|
+
};
|
|
843
|
+
//# sourceMappingURL=magic-string.es-3RXPUXZF.js.map
|