rsbuild-plugin-dts 0.20.0 → 0.20.2
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/350.js +3592 -0
- package/dist/apiExtractor.d.ts +1 -1
- package/dist/apiExtractor.js +7 -8
- package/dist/dts.d.ts +7 -5
- package/dist/dts.js +4 -5
- package/dist/index.js +6 -10
- package/dist/rslib-runtime.js +18 -0
- package/dist/tsc.d.ts +1 -1
- package/dist/tsc.js +7 -8
- package/dist/tsgo.d.ts +1 -1
- package/dist/tsgo.js +6 -7
- package/dist/utils.d.ts +5 -2
- package/package.json +11 -12
- package/compiled/magic-string/index.d.ts +0 -292
- package/compiled/magic-string/index.js +0 -2126
- package/compiled/magic-string/license +0 -7
- package/compiled/magic-string/package.json +0 -1
- package/compiled/picocolors/index.d.ts +0 -55
- package/compiled/picocolors/index.js +0 -132
- package/compiled/picocolors/license +0 -15
- package/compiled/picocolors/package.json +0 -1
- package/compiled/tinyglobby/index.d.ts +0 -46
- package/compiled/tinyglobby/index.js +0 -3061
- package/compiled/tinyglobby/license +0 -21
- package/compiled/tinyglobby/package.json +0 -1
- package/dist/utils.js +0 -367
|
@@ -1,2126 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ var __webpack_modules__ = ({
|
|
3
|
-
|
|
4
|
-
/***/ 73:
|
|
5
|
-
/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
|
|
6
|
-
|
|
7
|
-
/* module decorator */ module = __nccwpck_require__.nmd(module);
|
|
8
|
-
(function (global, factory) {
|
|
9
|
-
if (true) {
|
|
10
|
-
factory(module);
|
|
11
|
-
module.exports = def(module);
|
|
12
|
-
} else {}
|
|
13
|
-
function def(m) { return 'default' in m.exports ? m.exports.default : m.exports; }
|
|
14
|
-
})(this, (function (module) {
|
|
15
|
-
"use strict";
|
|
16
|
-
var __defProp = Object.defineProperty;
|
|
17
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
18
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
19
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
-
};
|
|
24
|
-
var __copyProps = (to, from, except, desc) => {
|
|
25
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
-
for (let key of __getOwnPropNames(from))
|
|
27
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
-
}
|
|
30
|
-
return to;
|
|
31
|
-
};
|
|
32
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
|
|
34
|
-
// src/sourcemap-codec.ts
|
|
35
|
-
var sourcemap_codec_exports = {};
|
|
36
|
-
__export(sourcemap_codec_exports, {
|
|
37
|
-
decode: () => decode,
|
|
38
|
-
decodeGeneratedRanges: () => decodeGeneratedRanges,
|
|
39
|
-
decodeOriginalScopes: () => decodeOriginalScopes,
|
|
40
|
-
encode: () => encode,
|
|
41
|
-
encodeGeneratedRanges: () => encodeGeneratedRanges,
|
|
42
|
-
encodeOriginalScopes: () => encodeOriginalScopes
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(sourcemap_codec_exports);
|
|
45
|
-
|
|
46
|
-
// src/vlq.ts
|
|
47
|
-
var comma = ",".charCodeAt(0);
|
|
48
|
-
var semicolon = ";".charCodeAt(0);
|
|
49
|
-
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
50
|
-
var intToChar = new Uint8Array(64);
|
|
51
|
-
var charToInt = new Uint8Array(128);
|
|
52
|
-
for (let i = 0; i < chars.length; i++) {
|
|
53
|
-
const c = chars.charCodeAt(i);
|
|
54
|
-
intToChar[i] = c;
|
|
55
|
-
charToInt[c] = i;
|
|
56
|
-
}
|
|
57
|
-
function decodeInteger(reader, relative) {
|
|
58
|
-
let value = 0;
|
|
59
|
-
let shift = 0;
|
|
60
|
-
let integer = 0;
|
|
61
|
-
do {
|
|
62
|
-
const c = reader.next();
|
|
63
|
-
integer = charToInt[c];
|
|
64
|
-
value |= (integer & 31) << shift;
|
|
65
|
-
shift += 5;
|
|
66
|
-
} while (integer & 32);
|
|
67
|
-
const shouldNegate = value & 1;
|
|
68
|
-
value >>>= 1;
|
|
69
|
-
if (shouldNegate) {
|
|
70
|
-
value = -2147483648 | -value;
|
|
71
|
-
}
|
|
72
|
-
return relative + value;
|
|
73
|
-
}
|
|
74
|
-
function encodeInteger(builder, num, relative) {
|
|
75
|
-
let delta = num - relative;
|
|
76
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
77
|
-
do {
|
|
78
|
-
let clamped = delta & 31;
|
|
79
|
-
delta >>>= 5;
|
|
80
|
-
if (delta > 0) clamped |= 32;
|
|
81
|
-
builder.write(intToChar[clamped]);
|
|
82
|
-
} while (delta > 0);
|
|
83
|
-
return num;
|
|
84
|
-
}
|
|
85
|
-
function hasMoreVlq(reader, max) {
|
|
86
|
-
if (reader.pos >= max) return false;
|
|
87
|
-
return reader.peek() !== comma;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/strings.ts
|
|
91
|
-
var bufLength = 1024 * 16;
|
|
92
|
-
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
|
93
|
-
decode(buf) {
|
|
94
|
-
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
95
|
-
return out.toString();
|
|
96
|
-
}
|
|
97
|
-
} : {
|
|
98
|
-
decode(buf) {
|
|
99
|
-
let out = "";
|
|
100
|
-
for (let i = 0; i < buf.length; i++) {
|
|
101
|
-
out += String.fromCharCode(buf[i]);
|
|
102
|
-
}
|
|
103
|
-
return out;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var StringWriter = class {
|
|
107
|
-
constructor() {
|
|
108
|
-
this.pos = 0;
|
|
109
|
-
this.out = "";
|
|
110
|
-
this.buffer = new Uint8Array(bufLength);
|
|
111
|
-
}
|
|
112
|
-
write(v) {
|
|
113
|
-
const { buffer } = this;
|
|
114
|
-
buffer[this.pos++] = v;
|
|
115
|
-
if (this.pos === bufLength) {
|
|
116
|
-
this.out += td.decode(buffer);
|
|
117
|
-
this.pos = 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
flush() {
|
|
121
|
-
const { buffer, out, pos } = this;
|
|
122
|
-
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var StringReader = class {
|
|
126
|
-
constructor(buffer) {
|
|
127
|
-
this.pos = 0;
|
|
128
|
-
this.buffer = buffer;
|
|
129
|
-
}
|
|
130
|
-
next() {
|
|
131
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
132
|
-
}
|
|
133
|
-
peek() {
|
|
134
|
-
return this.buffer.charCodeAt(this.pos);
|
|
135
|
-
}
|
|
136
|
-
indexOf(char) {
|
|
137
|
-
const { buffer, pos } = this;
|
|
138
|
-
const idx = buffer.indexOf(char, pos);
|
|
139
|
-
return idx === -1 ? buffer.length : idx;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// src/scopes.ts
|
|
144
|
-
var EMPTY = [];
|
|
145
|
-
function decodeOriginalScopes(input) {
|
|
146
|
-
const { length } = input;
|
|
147
|
-
const reader = new StringReader(input);
|
|
148
|
-
const scopes = [];
|
|
149
|
-
const stack = [];
|
|
150
|
-
let line = 0;
|
|
151
|
-
for (; reader.pos < length; reader.pos++) {
|
|
152
|
-
line = decodeInteger(reader, line);
|
|
153
|
-
const column = decodeInteger(reader, 0);
|
|
154
|
-
if (!hasMoreVlq(reader, length)) {
|
|
155
|
-
const last = stack.pop();
|
|
156
|
-
last[2] = line;
|
|
157
|
-
last[3] = column;
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const kind = decodeInteger(reader, 0);
|
|
161
|
-
const fields = decodeInteger(reader, 0);
|
|
162
|
-
const hasName = fields & 1;
|
|
163
|
-
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
|
164
|
-
let vars = EMPTY;
|
|
165
|
-
if (hasMoreVlq(reader, length)) {
|
|
166
|
-
vars = [];
|
|
167
|
-
do {
|
|
168
|
-
const varsIndex = decodeInteger(reader, 0);
|
|
169
|
-
vars.push(varsIndex);
|
|
170
|
-
} while (hasMoreVlq(reader, length));
|
|
171
|
-
}
|
|
172
|
-
scope.vars = vars;
|
|
173
|
-
scopes.push(scope);
|
|
174
|
-
stack.push(scope);
|
|
175
|
-
}
|
|
176
|
-
return scopes;
|
|
177
|
-
}
|
|
178
|
-
function encodeOriginalScopes(scopes) {
|
|
179
|
-
const writer = new StringWriter();
|
|
180
|
-
for (let i = 0; i < scopes.length; ) {
|
|
181
|
-
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
|
182
|
-
}
|
|
183
|
-
return writer.flush();
|
|
184
|
-
}
|
|
185
|
-
function _encodeOriginalScopes(scopes, index, writer, state) {
|
|
186
|
-
const scope = scopes[index];
|
|
187
|
-
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
|
188
|
-
if (index > 0) writer.write(comma);
|
|
189
|
-
state[0] = encodeInteger(writer, startLine, state[0]);
|
|
190
|
-
encodeInteger(writer, startColumn, 0);
|
|
191
|
-
encodeInteger(writer, kind, 0);
|
|
192
|
-
const fields = scope.length === 6 ? 1 : 0;
|
|
193
|
-
encodeInteger(writer, fields, 0);
|
|
194
|
-
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
|
195
|
-
for (const v of vars) {
|
|
196
|
-
encodeInteger(writer, v, 0);
|
|
197
|
-
}
|
|
198
|
-
for (index++; index < scopes.length; ) {
|
|
199
|
-
const next = scopes[index];
|
|
200
|
-
const { 0: l, 1: c } = next;
|
|
201
|
-
if (l > endLine || l === endLine && c >= endColumn) {
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
index = _encodeOriginalScopes(scopes, index, writer, state);
|
|
205
|
-
}
|
|
206
|
-
writer.write(comma);
|
|
207
|
-
state[0] = encodeInteger(writer, endLine, state[0]);
|
|
208
|
-
encodeInteger(writer, endColumn, 0);
|
|
209
|
-
return index;
|
|
210
|
-
}
|
|
211
|
-
function decodeGeneratedRanges(input) {
|
|
212
|
-
const { length } = input;
|
|
213
|
-
const reader = new StringReader(input);
|
|
214
|
-
const ranges = [];
|
|
215
|
-
const stack = [];
|
|
216
|
-
let genLine = 0;
|
|
217
|
-
let definitionSourcesIndex = 0;
|
|
218
|
-
let definitionScopeIndex = 0;
|
|
219
|
-
let callsiteSourcesIndex = 0;
|
|
220
|
-
let callsiteLine = 0;
|
|
221
|
-
let callsiteColumn = 0;
|
|
222
|
-
let bindingLine = 0;
|
|
223
|
-
let bindingColumn = 0;
|
|
224
|
-
do {
|
|
225
|
-
const semi = reader.indexOf(";");
|
|
226
|
-
let genColumn = 0;
|
|
227
|
-
for (; reader.pos < semi; reader.pos++) {
|
|
228
|
-
genColumn = decodeInteger(reader, genColumn);
|
|
229
|
-
if (!hasMoreVlq(reader, semi)) {
|
|
230
|
-
const last = stack.pop();
|
|
231
|
-
last[2] = genLine;
|
|
232
|
-
last[3] = genColumn;
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
const fields = decodeInteger(reader, 0);
|
|
236
|
-
const hasDefinition = fields & 1;
|
|
237
|
-
const hasCallsite = fields & 2;
|
|
238
|
-
const hasScope = fields & 4;
|
|
239
|
-
let callsite = null;
|
|
240
|
-
let bindings = EMPTY;
|
|
241
|
-
let range;
|
|
242
|
-
if (hasDefinition) {
|
|
243
|
-
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
|
244
|
-
definitionScopeIndex = decodeInteger(
|
|
245
|
-
reader,
|
|
246
|
-
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
|
|
247
|
-
);
|
|
248
|
-
definitionSourcesIndex = defSourcesIndex;
|
|
249
|
-
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
|
250
|
-
} else {
|
|
251
|
-
range = [genLine, genColumn, 0, 0];
|
|
252
|
-
}
|
|
253
|
-
range.isScope = !!hasScope;
|
|
254
|
-
if (hasCallsite) {
|
|
255
|
-
const prevCsi = callsiteSourcesIndex;
|
|
256
|
-
const prevLine = callsiteLine;
|
|
257
|
-
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
|
258
|
-
const sameSource = prevCsi === callsiteSourcesIndex;
|
|
259
|
-
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
|
260
|
-
callsiteColumn = decodeInteger(
|
|
261
|
-
reader,
|
|
262
|
-
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
|
|
263
|
-
);
|
|
264
|
-
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
|
265
|
-
}
|
|
266
|
-
range.callsite = callsite;
|
|
267
|
-
if (hasMoreVlq(reader, semi)) {
|
|
268
|
-
bindings = [];
|
|
269
|
-
do {
|
|
270
|
-
bindingLine = genLine;
|
|
271
|
-
bindingColumn = genColumn;
|
|
272
|
-
const expressionsCount = decodeInteger(reader, 0);
|
|
273
|
-
let expressionRanges;
|
|
274
|
-
if (expressionsCount < -1) {
|
|
275
|
-
expressionRanges = [[decodeInteger(reader, 0)]];
|
|
276
|
-
for (let i = -1; i > expressionsCount; i--) {
|
|
277
|
-
const prevBl = bindingLine;
|
|
278
|
-
bindingLine = decodeInteger(reader, bindingLine);
|
|
279
|
-
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
|
280
|
-
const expression = decodeInteger(reader, 0);
|
|
281
|
-
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
expressionRanges = [[expressionsCount]];
|
|
285
|
-
}
|
|
286
|
-
bindings.push(expressionRanges);
|
|
287
|
-
} while (hasMoreVlq(reader, semi));
|
|
288
|
-
}
|
|
289
|
-
range.bindings = bindings;
|
|
290
|
-
ranges.push(range);
|
|
291
|
-
stack.push(range);
|
|
292
|
-
}
|
|
293
|
-
genLine++;
|
|
294
|
-
reader.pos = semi + 1;
|
|
295
|
-
} while (reader.pos < length);
|
|
296
|
-
return ranges;
|
|
297
|
-
}
|
|
298
|
-
function encodeGeneratedRanges(ranges) {
|
|
299
|
-
if (ranges.length === 0) return "";
|
|
300
|
-
const writer = new StringWriter();
|
|
301
|
-
for (let i = 0; i < ranges.length; ) {
|
|
302
|
-
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
|
303
|
-
}
|
|
304
|
-
return writer.flush();
|
|
305
|
-
}
|
|
306
|
-
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
|
307
|
-
const range = ranges[index];
|
|
308
|
-
const {
|
|
309
|
-
0: startLine,
|
|
310
|
-
1: startColumn,
|
|
311
|
-
2: endLine,
|
|
312
|
-
3: endColumn,
|
|
313
|
-
isScope,
|
|
314
|
-
callsite,
|
|
315
|
-
bindings
|
|
316
|
-
} = range;
|
|
317
|
-
if (state[0] < startLine) {
|
|
318
|
-
catchupLine(writer, state[0], startLine);
|
|
319
|
-
state[0] = startLine;
|
|
320
|
-
state[1] = 0;
|
|
321
|
-
} else if (index > 0) {
|
|
322
|
-
writer.write(comma);
|
|
323
|
-
}
|
|
324
|
-
state[1] = encodeInteger(writer, range[1], state[1]);
|
|
325
|
-
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
|
326
|
-
encodeInteger(writer, fields, 0);
|
|
327
|
-
if (range.length === 6) {
|
|
328
|
-
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
|
329
|
-
if (sourcesIndex !== state[2]) {
|
|
330
|
-
state[3] = 0;
|
|
331
|
-
}
|
|
332
|
-
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
|
333
|
-
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
|
334
|
-
}
|
|
335
|
-
if (callsite) {
|
|
336
|
-
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
|
337
|
-
if (sourcesIndex !== state[4]) {
|
|
338
|
-
state[5] = 0;
|
|
339
|
-
state[6] = 0;
|
|
340
|
-
} else if (callLine !== state[5]) {
|
|
341
|
-
state[6] = 0;
|
|
342
|
-
}
|
|
343
|
-
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
|
344
|
-
state[5] = encodeInteger(writer, callLine, state[5]);
|
|
345
|
-
state[6] = encodeInteger(writer, callColumn, state[6]);
|
|
346
|
-
}
|
|
347
|
-
if (bindings) {
|
|
348
|
-
for (const binding of bindings) {
|
|
349
|
-
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
|
350
|
-
const expression = binding[0][0];
|
|
351
|
-
encodeInteger(writer, expression, 0);
|
|
352
|
-
let bindingStartLine = startLine;
|
|
353
|
-
let bindingStartColumn = startColumn;
|
|
354
|
-
for (let i = 1; i < binding.length; i++) {
|
|
355
|
-
const expRange = binding[i];
|
|
356
|
-
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
|
357
|
-
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
|
358
|
-
encodeInteger(writer, expRange[0], 0);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
for (index++; index < ranges.length; ) {
|
|
363
|
-
const next = ranges[index];
|
|
364
|
-
const { 0: l, 1: c } = next;
|
|
365
|
-
if (l > endLine || l === endLine && c >= endColumn) {
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
|
369
|
-
}
|
|
370
|
-
if (state[0] < endLine) {
|
|
371
|
-
catchupLine(writer, state[0], endLine);
|
|
372
|
-
state[0] = endLine;
|
|
373
|
-
state[1] = 0;
|
|
374
|
-
} else {
|
|
375
|
-
writer.write(comma);
|
|
376
|
-
}
|
|
377
|
-
state[1] = encodeInteger(writer, endColumn, state[1]);
|
|
378
|
-
return index;
|
|
379
|
-
}
|
|
380
|
-
function catchupLine(writer, lastLine, line) {
|
|
381
|
-
do {
|
|
382
|
-
writer.write(semicolon);
|
|
383
|
-
} while (++lastLine < line);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// src/sourcemap-codec.ts
|
|
387
|
-
function decode(mappings) {
|
|
388
|
-
const { length } = mappings;
|
|
389
|
-
const reader = new StringReader(mappings);
|
|
390
|
-
const decoded = [];
|
|
391
|
-
let genColumn = 0;
|
|
392
|
-
let sourcesIndex = 0;
|
|
393
|
-
let sourceLine = 0;
|
|
394
|
-
let sourceColumn = 0;
|
|
395
|
-
let namesIndex = 0;
|
|
396
|
-
do {
|
|
397
|
-
const semi = reader.indexOf(";");
|
|
398
|
-
const line = [];
|
|
399
|
-
let sorted = true;
|
|
400
|
-
let lastCol = 0;
|
|
401
|
-
genColumn = 0;
|
|
402
|
-
while (reader.pos < semi) {
|
|
403
|
-
let seg;
|
|
404
|
-
genColumn = decodeInteger(reader, genColumn);
|
|
405
|
-
if (genColumn < lastCol) sorted = false;
|
|
406
|
-
lastCol = genColumn;
|
|
407
|
-
if (hasMoreVlq(reader, semi)) {
|
|
408
|
-
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
409
|
-
sourceLine = decodeInteger(reader, sourceLine);
|
|
410
|
-
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
411
|
-
if (hasMoreVlq(reader, semi)) {
|
|
412
|
-
namesIndex = decodeInteger(reader, namesIndex);
|
|
413
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
414
|
-
} else {
|
|
415
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
seg = [genColumn];
|
|
419
|
-
}
|
|
420
|
-
line.push(seg);
|
|
421
|
-
reader.pos++;
|
|
422
|
-
}
|
|
423
|
-
if (!sorted) sort(line);
|
|
424
|
-
decoded.push(line);
|
|
425
|
-
reader.pos = semi + 1;
|
|
426
|
-
} while (reader.pos <= length);
|
|
427
|
-
return decoded;
|
|
428
|
-
}
|
|
429
|
-
function sort(line) {
|
|
430
|
-
line.sort(sortComparator);
|
|
431
|
-
}
|
|
432
|
-
function sortComparator(a, b) {
|
|
433
|
-
return a[0] - b[0];
|
|
434
|
-
}
|
|
435
|
-
function encode(decoded) {
|
|
436
|
-
const writer = new StringWriter();
|
|
437
|
-
let sourcesIndex = 0;
|
|
438
|
-
let sourceLine = 0;
|
|
439
|
-
let sourceColumn = 0;
|
|
440
|
-
let namesIndex = 0;
|
|
441
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
442
|
-
const line = decoded[i];
|
|
443
|
-
if (i > 0) writer.write(semicolon);
|
|
444
|
-
if (line.length === 0) continue;
|
|
445
|
-
let genColumn = 0;
|
|
446
|
-
for (let j = 0; j < line.length; j++) {
|
|
447
|
-
const segment = line[j];
|
|
448
|
-
if (j > 0) writer.write(comma);
|
|
449
|
-
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
450
|
-
if (segment.length === 1) continue;
|
|
451
|
-
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
452
|
-
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
453
|
-
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
454
|
-
if (segment.length === 4) continue;
|
|
455
|
-
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
return writer.flush();
|
|
459
|
-
}
|
|
460
|
-
}));
|
|
461
|
-
//# sourceMappingURL=sourcemap-codec.umd.js.map
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
/***/ }),
|
|
465
|
-
|
|
466
|
-
/***/ 96:
|
|
467
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
468
|
-
|
|
469
|
-
"use strict";
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
var sourcemapCodec = __nccwpck_require__(73);
|
|
473
|
-
|
|
474
|
-
class BitSet {
|
|
475
|
-
constructor(arg) {
|
|
476
|
-
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
add(n) {
|
|
480
|
-
this.bits[n >> 5] |= 1 << (n & 31);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
has(n) {
|
|
484
|
-
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
class Chunk {
|
|
489
|
-
constructor(start, end, content) {
|
|
490
|
-
this.start = start;
|
|
491
|
-
this.end = end;
|
|
492
|
-
this.original = content;
|
|
493
|
-
|
|
494
|
-
this.intro = '';
|
|
495
|
-
this.outro = '';
|
|
496
|
-
|
|
497
|
-
this.content = content;
|
|
498
|
-
this.storeName = false;
|
|
499
|
-
this.edited = false;
|
|
500
|
-
|
|
501
|
-
{
|
|
502
|
-
this.previous = null;
|
|
503
|
-
this.next = null;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
appendLeft(content) {
|
|
508
|
-
this.outro += content;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
appendRight(content) {
|
|
512
|
-
this.intro = this.intro + content;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
clone() {
|
|
516
|
-
const chunk = new Chunk(this.start, this.end, this.original);
|
|
517
|
-
|
|
518
|
-
chunk.intro = this.intro;
|
|
519
|
-
chunk.outro = this.outro;
|
|
520
|
-
chunk.content = this.content;
|
|
521
|
-
chunk.storeName = this.storeName;
|
|
522
|
-
chunk.edited = this.edited;
|
|
523
|
-
|
|
524
|
-
return chunk;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
contains(index) {
|
|
528
|
-
return this.start < index && index < this.end;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
eachNext(fn) {
|
|
532
|
-
let chunk = this;
|
|
533
|
-
while (chunk) {
|
|
534
|
-
fn(chunk);
|
|
535
|
-
chunk = chunk.next;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
eachPrevious(fn) {
|
|
540
|
-
let chunk = this;
|
|
541
|
-
while (chunk) {
|
|
542
|
-
fn(chunk);
|
|
543
|
-
chunk = chunk.previous;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
edit(content, storeName, contentOnly) {
|
|
548
|
-
this.content = content;
|
|
549
|
-
if (!contentOnly) {
|
|
550
|
-
this.intro = '';
|
|
551
|
-
this.outro = '';
|
|
552
|
-
}
|
|
553
|
-
this.storeName = storeName;
|
|
554
|
-
|
|
555
|
-
this.edited = true;
|
|
556
|
-
|
|
557
|
-
return this;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
prependLeft(content) {
|
|
561
|
-
this.outro = content + this.outro;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
prependRight(content) {
|
|
565
|
-
this.intro = content + this.intro;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
reset() {
|
|
569
|
-
this.intro = '';
|
|
570
|
-
this.outro = '';
|
|
571
|
-
if (this.edited) {
|
|
572
|
-
this.content = this.original;
|
|
573
|
-
this.storeName = false;
|
|
574
|
-
this.edited = false;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
split(index) {
|
|
579
|
-
const sliceIndex = index - this.start;
|
|
580
|
-
|
|
581
|
-
const originalBefore = this.original.slice(0, sliceIndex);
|
|
582
|
-
const originalAfter = this.original.slice(sliceIndex);
|
|
583
|
-
|
|
584
|
-
this.original = originalBefore;
|
|
585
|
-
|
|
586
|
-
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
587
|
-
newChunk.outro = this.outro;
|
|
588
|
-
this.outro = '';
|
|
589
|
-
|
|
590
|
-
this.end = index;
|
|
591
|
-
|
|
592
|
-
if (this.edited) {
|
|
593
|
-
// after split we should save the edit content record into the correct chunk
|
|
594
|
-
// to make sure sourcemap correct
|
|
595
|
-
// For example:
|
|
596
|
-
// ' test'.trim()
|
|
597
|
-
// split -> ' ' + 'test'
|
|
598
|
-
// ✔️ edit -> '' + 'test'
|
|
599
|
-
// ✖️ edit -> 'test' + ''
|
|
600
|
-
// TODO is this block necessary?...
|
|
601
|
-
newChunk.edit('', false);
|
|
602
|
-
this.content = '';
|
|
603
|
-
} else {
|
|
604
|
-
this.content = originalBefore;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
newChunk.next = this.next;
|
|
608
|
-
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
609
|
-
newChunk.previous = this;
|
|
610
|
-
this.next = newChunk;
|
|
611
|
-
|
|
612
|
-
return newChunk;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
toString() {
|
|
616
|
-
return this.intro + this.content + this.outro;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
trimEnd(rx) {
|
|
620
|
-
this.outro = this.outro.replace(rx, '');
|
|
621
|
-
if (this.outro.length) return true;
|
|
622
|
-
|
|
623
|
-
const trimmed = this.content.replace(rx, '');
|
|
624
|
-
|
|
625
|
-
if (trimmed.length) {
|
|
626
|
-
if (trimmed !== this.content) {
|
|
627
|
-
this.split(this.start + trimmed.length).edit('', undefined, true);
|
|
628
|
-
if (this.edited) {
|
|
629
|
-
// save the change, if it has been edited
|
|
630
|
-
this.edit(trimmed, this.storeName, true);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return true;
|
|
634
|
-
} else {
|
|
635
|
-
this.edit('', undefined, true);
|
|
636
|
-
|
|
637
|
-
this.intro = this.intro.replace(rx, '');
|
|
638
|
-
if (this.intro.length) return true;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
trimStart(rx) {
|
|
643
|
-
this.intro = this.intro.replace(rx, '');
|
|
644
|
-
if (this.intro.length) return true;
|
|
645
|
-
|
|
646
|
-
const trimmed = this.content.replace(rx, '');
|
|
647
|
-
|
|
648
|
-
if (trimmed.length) {
|
|
649
|
-
if (trimmed !== this.content) {
|
|
650
|
-
const newChunk = this.split(this.end - trimmed.length);
|
|
651
|
-
if (this.edited) {
|
|
652
|
-
// save the change, if it has been edited
|
|
653
|
-
newChunk.edit(trimmed, this.storeName, true);
|
|
654
|
-
}
|
|
655
|
-
this.edit('', undefined, true);
|
|
656
|
-
}
|
|
657
|
-
return true;
|
|
658
|
-
} else {
|
|
659
|
-
this.edit('', undefined, true);
|
|
660
|
-
|
|
661
|
-
this.outro = this.outro.replace(rx, '');
|
|
662
|
-
if (this.outro.length) return true;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
function getBtoa() {
|
|
668
|
-
if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
|
|
669
|
-
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
670
|
-
} else if (typeof Buffer === 'function') {
|
|
671
|
-
return (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
672
|
-
} else {
|
|
673
|
-
return () => {
|
|
674
|
-
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
const btoa = /*#__PURE__*/ getBtoa();
|
|
680
|
-
|
|
681
|
-
class SourceMap {
|
|
682
|
-
constructor(properties) {
|
|
683
|
-
this.version = 3;
|
|
684
|
-
this.file = properties.file;
|
|
685
|
-
this.sources = properties.sources;
|
|
686
|
-
this.sourcesContent = properties.sourcesContent;
|
|
687
|
-
this.names = properties.names;
|
|
688
|
-
this.mappings = sourcemapCodec.encode(properties.mappings);
|
|
689
|
-
if (typeof properties.x_google_ignoreList !== 'undefined') {
|
|
690
|
-
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
691
|
-
}
|
|
692
|
-
if (typeof properties.debugId !== 'undefined') {
|
|
693
|
-
this.debugId = properties.debugId;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
toString() {
|
|
698
|
-
return JSON.stringify(this);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
toUrl() {
|
|
702
|
-
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
function guessIndent(code) {
|
|
707
|
-
const lines = code.split('\n');
|
|
708
|
-
|
|
709
|
-
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
710
|
-
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
711
|
-
|
|
712
|
-
if (tabbed.length === 0 && spaced.length === 0) {
|
|
713
|
-
return null;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
// More lines tabbed than spaced? Assume tabs, and
|
|
717
|
-
// default to tabs in the case of a tie (or nothing
|
|
718
|
-
// to go on)
|
|
719
|
-
if (tabbed.length >= spaced.length) {
|
|
720
|
-
return '\t';
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// Otherwise, we need to guess the multiple
|
|
724
|
-
const min = spaced.reduce((previous, current) => {
|
|
725
|
-
const numSpaces = /^ +/.exec(current)[0].length;
|
|
726
|
-
return Math.min(numSpaces, previous);
|
|
727
|
-
}, Infinity);
|
|
728
|
-
|
|
729
|
-
return new Array(min + 1).join(' ');
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
function getRelativePath(from, to) {
|
|
733
|
-
const fromParts = from.split(/[/\\]/);
|
|
734
|
-
const toParts = to.split(/[/\\]/);
|
|
735
|
-
|
|
736
|
-
fromParts.pop(); // get dirname
|
|
737
|
-
|
|
738
|
-
while (fromParts[0] === toParts[0]) {
|
|
739
|
-
fromParts.shift();
|
|
740
|
-
toParts.shift();
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
if (fromParts.length) {
|
|
744
|
-
let i = fromParts.length;
|
|
745
|
-
while (i--) fromParts[i] = '..';
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
return fromParts.concat(toParts).join('/');
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
const toString = Object.prototype.toString;
|
|
752
|
-
|
|
753
|
-
function isObject(thing) {
|
|
754
|
-
return toString.call(thing) === '[object Object]';
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
function getLocator(source) {
|
|
758
|
-
const originalLines = source.split('\n');
|
|
759
|
-
const lineOffsets = [];
|
|
760
|
-
|
|
761
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
762
|
-
lineOffsets.push(pos);
|
|
763
|
-
pos += originalLines[i].length + 1;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
return function locate(index) {
|
|
767
|
-
let i = 0;
|
|
768
|
-
let j = lineOffsets.length;
|
|
769
|
-
while (i < j) {
|
|
770
|
-
const m = (i + j) >> 1;
|
|
771
|
-
if (index < lineOffsets[m]) {
|
|
772
|
-
j = m;
|
|
773
|
-
} else {
|
|
774
|
-
i = m + 1;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
const line = i - 1;
|
|
778
|
-
const column = index - lineOffsets[line];
|
|
779
|
-
return { line, column };
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
const wordRegex = /\w/;
|
|
784
|
-
|
|
785
|
-
class Mappings {
|
|
786
|
-
constructor(hires) {
|
|
787
|
-
this.hires = hires;
|
|
788
|
-
this.generatedCodeLine = 0;
|
|
789
|
-
this.generatedCodeColumn = 0;
|
|
790
|
-
this.raw = [];
|
|
791
|
-
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
792
|
-
this.pending = null;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
796
|
-
if (content.length) {
|
|
797
|
-
const contentLengthMinusOne = content.length - 1;
|
|
798
|
-
let contentLineEnd = content.indexOf('\n', 0);
|
|
799
|
-
let previousContentLineEnd = -1;
|
|
800
|
-
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
801
|
-
// else code afterwards would fill one line too many
|
|
802
|
-
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
803
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
804
|
-
if (nameIndex >= 0) {
|
|
805
|
-
segment.push(nameIndex);
|
|
806
|
-
}
|
|
807
|
-
this.rawSegments.push(segment);
|
|
808
|
-
|
|
809
|
-
this.generatedCodeLine += 1;
|
|
810
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
811
|
-
this.generatedCodeColumn = 0;
|
|
812
|
-
|
|
813
|
-
previousContentLineEnd = contentLineEnd;
|
|
814
|
-
contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
818
|
-
if (nameIndex >= 0) {
|
|
819
|
-
segment.push(nameIndex);
|
|
820
|
-
}
|
|
821
|
-
this.rawSegments.push(segment);
|
|
822
|
-
|
|
823
|
-
this.advance(content.slice(previousContentLineEnd + 1));
|
|
824
|
-
} else if (this.pending) {
|
|
825
|
-
this.rawSegments.push(this.pending);
|
|
826
|
-
this.advance(content);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
this.pending = null;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
833
|
-
let originalCharIndex = chunk.start;
|
|
834
|
-
let first = true;
|
|
835
|
-
// when iterating each char, check if it's in a word boundary
|
|
836
|
-
let charInHiresBoundary = false;
|
|
837
|
-
|
|
838
|
-
while (originalCharIndex < chunk.end) {
|
|
839
|
-
if (original[originalCharIndex] === '\n') {
|
|
840
|
-
loc.line += 1;
|
|
841
|
-
loc.column = 0;
|
|
842
|
-
this.generatedCodeLine += 1;
|
|
843
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
844
|
-
this.generatedCodeColumn = 0;
|
|
845
|
-
first = true;
|
|
846
|
-
charInHiresBoundary = false;
|
|
847
|
-
} else {
|
|
848
|
-
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
849
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
850
|
-
|
|
851
|
-
if (this.hires === 'boundary') {
|
|
852
|
-
// in hires "boundary", group segments per word boundary than per char
|
|
853
|
-
if (wordRegex.test(original[originalCharIndex])) {
|
|
854
|
-
// for first char in the boundary found, start the boundary by pushing a segment
|
|
855
|
-
if (!charInHiresBoundary) {
|
|
856
|
-
this.rawSegments.push(segment);
|
|
857
|
-
charInHiresBoundary = true;
|
|
858
|
-
}
|
|
859
|
-
} else {
|
|
860
|
-
// for non-word char, end the boundary by pushing a segment
|
|
861
|
-
this.rawSegments.push(segment);
|
|
862
|
-
charInHiresBoundary = false;
|
|
863
|
-
}
|
|
864
|
-
} else {
|
|
865
|
-
this.rawSegments.push(segment);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
loc.column += 1;
|
|
870
|
-
this.generatedCodeColumn += 1;
|
|
871
|
-
first = false;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
originalCharIndex += 1;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
this.pending = null;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
advance(str) {
|
|
881
|
-
if (!str) return;
|
|
882
|
-
|
|
883
|
-
const lines = str.split('\n');
|
|
884
|
-
|
|
885
|
-
if (lines.length > 1) {
|
|
886
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
|
887
|
-
this.generatedCodeLine++;
|
|
888
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
889
|
-
}
|
|
890
|
-
this.generatedCodeColumn = 0;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
const n = '\n';
|
|
898
|
-
|
|
899
|
-
const warned = {
|
|
900
|
-
insertLeft: false,
|
|
901
|
-
insertRight: false,
|
|
902
|
-
storeName: false,
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
class MagicString {
|
|
906
|
-
constructor(string, options = {}) {
|
|
907
|
-
const chunk = new Chunk(0, string.length, string);
|
|
908
|
-
|
|
909
|
-
Object.defineProperties(this, {
|
|
910
|
-
original: { writable: true, value: string },
|
|
911
|
-
outro: { writable: true, value: '' },
|
|
912
|
-
intro: { writable: true, value: '' },
|
|
913
|
-
firstChunk: { writable: true, value: chunk },
|
|
914
|
-
lastChunk: { writable: true, value: chunk },
|
|
915
|
-
lastSearchedChunk: { writable: true, value: chunk },
|
|
916
|
-
byStart: { writable: true, value: {} },
|
|
917
|
-
byEnd: { writable: true, value: {} },
|
|
918
|
-
filename: { writable: true, value: options.filename },
|
|
919
|
-
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
920
|
-
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
921
|
-
storedNames: { writable: true, value: {} },
|
|
922
|
-
indentStr: { writable: true, value: undefined },
|
|
923
|
-
ignoreList: { writable: true, value: options.ignoreList },
|
|
924
|
-
offset: { writable: true, value: options.offset || 0 },
|
|
925
|
-
});
|
|
926
|
-
|
|
927
|
-
this.byStart[0] = chunk;
|
|
928
|
-
this.byEnd[string.length] = chunk;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
addSourcemapLocation(char) {
|
|
932
|
-
this.sourcemapLocations.add(char);
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
append(content) {
|
|
936
|
-
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
937
|
-
|
|
938
|
-
this.outro += content;
|
|
939
|
-
return this;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
appendLeft(index, content) {
|
|
943
|
-
index = index + this.offset;
|
|
944
|
-
|
|
945
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
946
|
-
|
|
947
|
-
this._split(index);
|
|
948
|
-
|
|
949
|
-
const chunk = this.byEnd[index];
|
|
950
|
-
|
|
951
|
-
if (chunk) {
|
|
952
|
-
chunk.appendLeft(content);
|
|
953
|
-
} else {
|
|
954
|
-
this.intro += content;
|
|
955
|
-
}
|
|
956
|
-
return this;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
appendRight(index, content) {
|
|
960
|
-
index = index + this.offset;
|
|
961
|
-
|
|
962
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
963
|
-
|
|
964
|
-
this._split(index);
|
|
965
|
-
|
|
966
|
-
const chunk = this.byStart[index];
|
|
967
|
-
|
|
968
|
-
if (chunk) {
|
|
969
|
-
chunk.appendRight(content);
|
|
970
|
-
} else {
|
|
971
|
-
this.outro += content;
|
|
972
|
-
}
|
|
973
|
-
return this;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
clone() {
|
|
977
|
-
const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
|
|
978
|
-
|
|
979
|
-
let originalChunk = this.firstChunk;
|
|
980
|
-
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
|
981
|
-
|
|
982
|
-
while (originalChunk) {
|
|
983
|
-
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
984
|
-
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
985
|
-
|
|
986
|
-
const nextOriginalChunk = originalChunk.next;
|
|
987
|
-
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
988
|
-
|
|
989
|
-
if (nextClonedChunk) {
|
|
990
|
-
clonedChunk.next = nextClonedChunk;
|
|
991
|
-
nextClonedChunk.previous = clonedChunk;
|
|
992
|
-
|
|
993
|
-
clonedChunk = nextClonedChunk;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
originalChunk = nextOriginalChunk;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
cloned.lastChunk = clonedChunk;
|
|
1000
|
-
|
|
1001
|
-
if (this.indentExclusionRanges) {
|
|
1002
|
-
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
1006
|
-
|
|
1007
|
-
cloned.intro = this.intro;
|
|
1008
|
-
cloned.outro = this.outro;
|
|
1009
|
-
|
|
1010
|
-
return cloned;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
generateDecodedMap(options) {
|
|
1014
|
-
options = options || {};
|
|
1015
|
-
|
|
1016
|
-
const sourceIndex = 0;
|
|
1017
|
-
const names = Object.keys(this.storedNames);
|
|
1018
|
-
const mappings = new Mappings(options.hires);
|
|
1019
|
-
|
|
1020
|
-
const locate = getLocator(this.original);
|
|
1021
|
-
|
|
1022
|
-
if (this.intro) {
|
|
1023
|
-
mappings.advance(this.intro);
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
this.firstChunk.eachNext((chunk) => {
|
|
1027
|
-
const loc = locate(chunk.start);
|
|
1028
|
-
|
|
1029
|
-
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
1030
|
-
|
|
1031
|
-
if (chunk.edited) {
|
|
1032
|
-
mappings.addEdit(
|
|
1033
|
-
sourceIndex,
|
|
1034
|
-
chunk.content,
|
|
1035
|
-
loc,
|
|
1036
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
1037
|
-
);
|
|
1038
|
-
} else {
|
|
1039
|
-
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
if (this.outro) {
|
|
1046
|
-
mappings.advance(this.outro);
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
return {
|
|
1050
|
-
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
1051
|
-
sources: [
|
|
1052
|
-
options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
|
|
1053
|
-
],
|
|
1054
|
-
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
1055
|
-
names,
|
|
1056
|
-
mappings: mappings.raw,
|
|
1057
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
generateMap(options) {
|
|
1062
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
_ensureindentStr() {
|
|
1066
|
-
if (this.indentStr === undefined) {
|
|
1067
|
-
this.indentStr = guessIndent(this.original);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
_getRawIndentString() {
|
|
1072
|
-
this._ensureindentStr();
|
|
1073
|
-
return this.indentStr;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
getIndentString() {
|
|
1077
|
-
this._ensureindentStr();
|
|
1078
|
-
return this.indentStr === null ? '\t' : this.indentStr;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
indent(indentStr, options) {
|
|
1082
|
-
const pattern = /^[^\r\n]/gm;
|
|
1083
|
-
|
|
1084
|
-
if (isObject(indentStr)) {
|
|
1085
|
-
options = indentStr;
|
|
1086
|
-
indentStr = undefined;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
if (indentStr === undefined) {
|
|
1090
|
-
this._ensureindentStr();
|
|
1091
|
-
indentStr = this.indentStr || '\t';
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
if (indentStr === '') return this; // noop
|
|
1095
|
-
|
|
1096
|
-
options = options || {};
|
|
1097
|
-
|
|
1098
|
-
// Process exclusion ranges
|
|
1099
|
-
const isExcluded = {};
|
|
1100
|
-
|
|
1101
|
-
if (options.exclude) {
|
|
1102
|
-
const exclusions =
|
|
1103
|
-
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
1104
|
-
exclusions.forEach((exclusion) => {
|
|
1105
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
1106
|
-
isExcluded[i] = true;
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
1112
|
-
const replacer = (match) => {
|
|
1113
|
-
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
1114
|
-
shouldIndentNextCharacter = true;
|
|
1115
|
-
return match;
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
|
-
this.intro = this.intro.replace(pattern, replacer);
|
|
1119
|
-
|
|
1120
|
-
let charIndex = 0;
|
|
1121
|
-
let chunk = this.firstChunk;
|
|
1122
|
-
|
|
1123
|
-
while (chunk) {
|
|
1124
|
-
const end = chunk.end;
|
|
1125
|
-
|
|
1126
|
-
if (chunk.edited) {
|
|
1127
|
-
if (!isExcluded[charIndex]) {
|
|
1128
|
-
chunk.content = chunk.content.replace(pattern, replacer);
|
|
1129
|
-
|
|
1130
|
-
if (chunk.content.length) {
|
|
1131
|
-
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
} else {
|
|
1135
|
-
charIndex = chunk.start;
|
|
1136
|
-
|
|
1137
|
-
while (charIndex < end) {
|
|
1138
|
-
if (!isExcluded[charIndex]) {
|
|
1139
|
-
const char = this.original[charIndex];
|
|
1140
|
-
|
|
1141
|
-
if (char === '\n') {
|
|
1142
|
-
shouldIndentNextCharacter = true;
|
|
1143
|
-
} else if (char !== '\r' && shouldIndentNextCharacter) {
|
|
1144
|
-
shouldIndentNextCharacter = false;
|
|
1145
|
-
|
|
1146
|
-
if (charIndex === chunk.start) {
|
|
1147
|
-
chunk.prependRight(indentStr);
|
|
1148
|
-
} else {
|
|
1149
|
-
this._splitChunk(chunk, charIndex);
|
|
1150
|
-
chunk = chunk.next;
|
|
1151
|
-
chunk.prependRight(indentStr);
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
charIndex += 1;
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
charIndex = chunk.end;
|
|
1161
|
-
chunk = chunk.next;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
this.outro = this.outro.replace(pattern, replacer);
|
|
1165
|
-
|
|
1166
|
-
return this;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
insert() {
|
|
1170
|
-
throw new Error(
|
|
1171
|
-
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
1172
|
-
);
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
insertLeft(index, content) {
|
|
1176
|
-
if (!warned.insertLeft) {
|
|
1177
|
-
console.warn(
|
|
1178
|
-
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
1179
|
-
);
|
|
1180
|
-
warned.insertLeft = true;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
return this.appendLeft(index, content);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
insertRight(index, content) {
|
|
1187
|
-
if (!warned.insertRight) {
|
|
1188
|
-
console.warn(
|
|
1189
|
-
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
1190
|
-
);
|
|
1191
|
-
warned.insertRight = true;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
return this.prependRight(index, content);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
move(start, end, index) {
|
|
1198
|
-
start = start + this.offset;
|
|
1199
|
-
end = end + this.offset;
|
|
1200
|
-
index = index + this.offset;
|
|
1201
|
-
|
|
1202
|
-
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
1203
|
-
|
|
1204
|
-
this._split(start);
|
|
1205
|
-
this._split(end);
|
|
1206
|
-
this._split(index);
|
|
1207
|
-
|
|
1208
|
-
const first = this.byStart[start];
|
|
1209
|
-
const last = this.byEnd[end];
|
|
1210
|
-
|
|
1211
|
-
const oldLeft = first.previous;
|
|
1212
|
-
const oldRight = last.next;
|
|
1213
|
-
|
|
1214
|
-
const newRight = this.byStart[index];
|
|
1215
|
-
if (!newRight && last === this.lastChunk) return this;
|
|
1216
|
-
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
1217
|
-
|
|
1218
|
-
if (oldLeft) oldLeft.next = oldRight;
|
|
1219
|
-
if (oldRight) oldRight.previous = oldLeft;
|
|
1220
|
-
|
|
1221
|
-
if (newLeft) newLeft.next = first;
|
|
1222
|
-
if (newRight) newRight.previous = last;
|
|
1223
|
-
|
|
1224
|
-
if (!first.previous) this.firstChunk = last.next;
|
|
1225
|
-
if (!last.next) {
|
|
1226
|
-
this.lastChunk = first.previous;
|
|
1227
|
-
this.lastChunk.next = null;
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
first.previous = newLeft;
|
|
1231
|
-
last.next = newRight || null;
|
|
1232
|
-
|
|
1233
|
-
if (!newLeft) this.firstChunk = first;
|
|
1234
|
-
if (!newRight) this.lastChunk = last;
|
|
1235
|
-
return this;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
overwrite(start, end, content, options) {
|
|
1239
|
-
options = options || {};
|
|
1240
|
-
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
update(start, end, content, options) {
|
|
1244
|
-
start = start + this.offset;
|
|
1245
|
-
end = end + this.offset;
|
|
1246
|
-
|
|
1247
|
-
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
1248
|
-
|
|
1249
|
-
if (this.original.length !== 0) {
|
|
1250
|
-
while (start < 0) start += this.original.length;
|
|
1251
|
-
while (end < 0) end += this.original.length;
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
if (end > this.original.length) throw new Error('end is out of bounds');
|
|
1255
|
-
if (start === end)
|
|
1256
|
-
throw new Error(
|
|
1257
|
-
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
1258
|
-
);
|
|
1259
|
-
|
|
1260
|
-
this._split(start);
|
|
1261
|
-
this._split(end);
|
|
1262
|
-
|
|
1263
|
-
if (options === true) {
|
|
1264
|
-
if (!warned.storeName) {
|
|
1265
|
-
console.warn(
|
|
1266
|
-
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
1267
|
-
);
|
|
1268
|
-
warned.storeName = true;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
options = { storeName: true };
|
|
1272
|
-
}
|
|
1273
|
-
const storeName = options !== undefined ? options.storeName : false;
|
|
1274
|
-
const overwrite = options !== undefined ? options.overwrite : false;
|
|
1275
|
-
|
|
1276
|
-
if (storeName) {
|
|
1277
|
-
const original = this.original.slice(start, end);
|
|
1278
|
-
Object.defineProperty(this.storedNames, original, {
|
|
1279
|
-
writable: true,
|
|
1280
|
-
value: true,
|
|
1281
|
-
enumerable: true,
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
const first = this.byStart[start];
|
|
1286
|
-
const last = this.byEnd[end];
|
|
1287
|
-
|
|
1288
|
-
if (first) {
|
|
1289
|
-
let chunk = first;
|
|
1290
|
-
while (chunk !== last) {
|
|
1291
|
-
if (chunk.next !== this.byStart[chunk.end]) {
|
|
1292
|
-
throw new Error('Cannot overwrite across a split point');
|
|
1293
|
-
}
|
|
1294
|
-
chunk = chunk.next;
|
|
1295
|
-
chunk.edit('', false);
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
first.edit(content, storeName, !overwrite);
|
|
1299
|
-
} else {
|
|
1300
|
-
// must be inserting at the end
|
|
1301
|
-
const newChunk = new Chunk(start, end, '').edit(content, storeName);
|
|
1302
|
-
|
|
1303
|
-
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
1304
|
-
last.next = newChunk;
|
|
1305
|
-
newChunk.previous = last;
|
|
1306
|
-
}
|
|
1307
|
-
return this;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
prepend(content) {
|
|
1311
|
-
if (typeof content !== 'string') throw new TypeError('outro content must be a string');
|
|
1312
|
-
|
|
1313
|
-
this.intro = content + this.intro;
|
|
1314
|
-
return this;
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
prependLeft(index, content) {
|
|
1318
|
-
index = index + this.offset;
|
|
1319
|
-
|
|
1320
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1321
|
-
|
|
1322
|
-
this._split(index);
|
|
1323
|
-
|
|
1324
|
-
const chunk = this.byEnd[index];
|
|
1325
|
-
|
|
1326
|
-
if (chunk) {
|
|
1327
|
-
chunk.prependLeft(content);
|
|
1328
|
-
} else {
|
|
1329
|
-
this.intro = content + this.intro;
|
|
1330
|
-
}
|
|
1331
|
-
return this;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
prependRight(index, content) {
|
|
1335
|
-
index = index + this.offset;
|
|
1336
|
-
|
|
1337
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1338
|
-
|
|
1339
|
-
this._split(index);
|
|
1340
|
-
|
|
1341
|
-
const chunk = this.byStart[index];
|
|
1342
|
-
|
|
1343
|
-
if (chunk) {
|
|
1344
|
-
chunk.prependRight(content);
|
|
1345
|
-
} else {
|
|
1346
|
-
this.outro = content + this.outro;
|
|
1347
|
-
}
|
|
1348
|
-
return this;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
remove(start, end) {
|
|
1352
|
-
start = start + this.offset;
|
|
1353
|
-
end = end + this.offset;
|
|
1354
|
-
|
|
1355
|
-
if (this.original.length !== 0) {
|
|
1356
|
-
while (start < 0) start += this.original.length;
|
|
1357
|
-
while (end < 0) end += this.original.length;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
if (start === end) return this;
|
|
1361
|
-
|
|
1362
|
-
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
1363
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
1364
|
-
|
|
1365
|
-
this._split(start);
|
|
1366
|
-
this._split(end);
|
|
1367
|
-
|
|
1368
|
-
let chunk = this.byStart[start];
|
|
1369
|
-
|
|
1370
|
-
while (chunk) {
|
|
1371
|
-
chunk.intro = '';
|
|
1372
|
-
chunk.outro = '';
|
|
1373
|
-
chunk.edit('');
|
|
1374
|
-
|
|
1375
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1376
|
-
}
|
|
1377
|
-
return this;
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
reset(start, end) {
|
|
1381
|
-
start = start + this.offset;
|
|
1382
|
-
end = end + this.offset;
|
|
1383
|
-
|
|
1384
|
-
if (this.original.length !== 0) {
|
|
1385
|
-
while (start < 0) start += this.original.length;
|
|
1386
|
-
while (end < 0) end += this.original.length;
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
if (start === end) return this;
|
|
1390
|
-
|
|
1391
|
-
if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
|
|
1392
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
1393
|
-
|
|
1394
|
-
this._split(start);
|
|
1395
|
-
this._split(end);
|
|
1396
|
-
|
|
1397
|
-
let chunk = this.byStart[start];
|
|
1398
|
-
|
|
1399
|
-
while (chunk) {
|
|
1400
|
-
chunk.reset();
|
|
1401
|
-
|
|
1402
|
-
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1403
|
-
}
|
|
1404
|
-
return this;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
lastChar() {
|
|
1408
|
-
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
1409
|
-
let chunk = this.lastChunk;
|
|
1410
|
-
do {
|
|
1411
|
-
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
1412
|
-
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
1413
|
-
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
1414
|
-
} while ((chunk = chunk.previous));
|
|
1415
|
-
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
1416
|
-
return '';
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
lastLine() {
|
|
1420
|
-
let lineIndex = this.outro.lastIndexOf(n);
|
|
1421
|
-
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
1422
|
-
let lineStr = this.outro;
|
|
1423
|
-
let chunk = this.lastChunk;
|
|
1424
|
-
do {
|
|
1425
|
-
if (chunk.outro.length > 0) {
|
|
1426
|
-
lineIndex = chunk.outro.lastIndexOf(n);
|
|
1427
|
-
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
1428
|
-
lineStr = chunk.outro + lineStr;
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
if (chunk.content.length > 0) {
|
|
1432
|
-
lineIndex = chunk.content.lastIndexOf(n);
|
|
1433
|
-
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
1434
|
-
lineStr = chunk.content + lineStr;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
if (chunk.intro.length > 0) {
|
|
1438
|
-
lineIndex = chunk.intro.lastIndexOf(n);
|
|
1439
|
-
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
1440
|
-
lineStr = chunk.intro + lineStr;
|
|
1441
|
-
}
|
|
1442
|
-
} while ((chunk = chunk.previous));
|
|
1443
|
-
lineIndex = this.intro.lastIndexOf(n);
|
|
1444
|
-
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
1445
|
-
return this.intro + lineStr;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
slice(start = 0, end = this.original.length - this.offset) {
|
|
1449
|
-
start = start + this.offset;
|
|
1450
|
-
end = end + this.offset;
|
|
1451
|
-
|
|
1452
|
-
if (this.original.length !== 0) {
|
|
1453
|
-
while (start < 0) start += this.original.length;
|
|
1454
|
-
while (end < 0) end += this.original.length;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
let result = '';
|
|
1458
|
-
|
|
1459
|
-
// find start chunk
|
|
1460
|
-
let chunk = this.firstChunk;
|
|
1461
|
-
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
1462
|
-
// found end chunk before start
|
|
1463
|
-
if (chunk.start < end && chunk.end >= end) {
|
|
1464
|
-
return result;
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
chunk = chunk.next;
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
if (chunk && chunk.edited && chunk.start !== start)
|
|
1471
|
-
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1472
|
-
|
|
1473
|
-
const startChunk = chunk;
|
|
1474
|
-
while (chunk) {
|
|
1475
|
-
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
|
|
1476
|
-
result += chunk.intro;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1480
|
-
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
1481
|
-
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1482
|
-
|
|
1483
|
-
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1484
|
-
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1485
|
-
|
|
1486
|
-
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
1487
|
-
|
|
1488
|
-
if (chunk.outro && (!containsEnd || chunk.end === end)) {
|
|
1489
|
-
result += chunk.outro;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
if (containsEnd) {
|
|
1493
|
-
break;
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
chunk = chunk.next;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
return result;
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
// TODO deprecate this? not really very useful
|
|
1503
|
-
snip(start, end) {
|
|
1504
|
-
const clone = this.clone();
|
|
1505
|
-
clone.remove(0, start);
|
|
1506
|
-
clone.remove(end, clone.original.length);
|
|
1507
|
-
|
|
1508
|
-
return clone;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
_split(index) {
|
|
1512
|
-
if (this.byStart[index] || this.byEnd[index]) return;
|
|
1513
|
-
|
|
1514
|
-
let chunk = this.lastSearchedChunk;
|
|
1515
|
-
let previousChunk = chunk;
|
|
1516
|
-
const searchForward = index > chunk.end;
|
|
1517
|
-
|
|
1518
|
-
while (chunk) {
|
|
1519
|
-
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
1520
|
-
|
|
1521
|
-
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
1522
|
-
|
|
1523
|
-
// Prevent infinite loop (e.g. via empty chunks, where start === end)
|
|
1524
|
-
if (chunk === previousChunk) return;
|
|
1525
|
-
|
|
1526
|
-
previousChunk = chunk;
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
_splitChunk(chunk, index) {
|
|
1531
|
-
if (chunk.edited && chunk.content.length) {
|
|
1532
|
-
// zero-length edited chunks are a special case (overlapping replacements)
|
|
1533
|
-
const loc = getLocator(this.original)(index);
|
|
1534
|
-
throw new Error(
|
|
1535
|
-
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
1536
|
-
);
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
const newChunk = chunk.split(index);
|
|
1540
|
-
|
|
1541
|
-
this.byEnd[index] = chunk;
|
|
1542
|
-
this.byStart[index] = newChunk;
|
|
1543
|
-
this.byEnd[newChunk.end] = newChunk;
|
|
1544
|
-
|
|
1545
|
-
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
1546
|
-
|
|
1547
|
-
this.lastSearchedChunk = chunk;
|
|
1548
|
-
return true;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
toString() {
|
|
1552
|
-
let str = this.intro;
|
|
1553
|
-
|
|
1554
|
-
let chunk = this.firstChunk;
|
|
1555
|
-
while (chunk) {
|
|
1556
|
-
str += chunk.toString();
|
|
1557
|
-
chunk = chunk.next;
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
return str + this.outro;
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
isEmpty() {
|
|
1564
|
-
let chunk = this.firstChunk;
|
|
1565
|
-
do {
|
|
1566
|
-
if (
|
|
1567
|
-
(chunk.intro.length && chunk.intro.trim()) ||
|
|
1568
|
-
(chunk.content.length && chunk.content.trim()) ||
|
|
1569
|
-
(chunk.outro.length && chunk.outro.trim())
|
|
1570
|
-
)
|
|
1571
|
-
return false;
|
|
1572
|
-
} while ((chunk = chunk.next));
|
|
1573
|
-
return true;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
length() {
|
|
1577
|
-
let chunk = this.firstChunk;
|
|
1578
|
-
let length = 0;
|
|
1579
|
-
do {
|
|
1580
|
-
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
1581
|
-
} while ((chunk = chunk.next));
|
|
1582
|
-
return length;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
trimLines() {
|
|
1586
|
-
return this.trim('[\\r\\n]');
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
trim(charType) {
|
|
1590
|
-
return this.trimStart(charType).trimEnd(charType);
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
trimEndAborted(charType) {
|
|
1594
|
-
const rx = new RegExp((charType || '\\s') + '+$');
|
|
1595
|
-
|
|
1596
|
-
this.outro = this.outro.replace(rx, '');
|
|
1597
|
-
if (this.outro.length) return true;
|
|
1598
|
-
|
|
1599
|
-
let chunk = this.lastChunk;
|
|
1600
|
-
|
|
1601
|
-
do {
|
|
1602
|
-
const end = chunk.end;
|
|
1603
|
-
const aborted = chunk.trimEnd(rx);
|
|
1604
|
-
|
|
1605
|
-
// if chunk was trimmed, we have a new lastChunk
|
|
1606
|
-
if (chunk.end !== end) {
|
|
1607
|
-
if (this.lastChunk === chunk) {
|
|
1608
|
-
this.lastChunk = chunk.next;
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
this.byEnd[chunk.end] = chunk;
|
|
1612
|
-
this.byStart[chunk.next.start] = chunk.next;
|
|
1613
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
if (aborted) return true;
|
|
1617
|
-
chunk = chunk.previous;
|
|
1618
|
-
} while (chunk);
|
|
1619
|
-
|
|
1620
|
-
return false;
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
trimEnd(charType) {
|
|
1624
|
-
this.trimEndAborted(charType);
|
|
1625
|
-
return this;
|
|
1626
|
-
}
|
|
1627
|
-
trimStartAborted(charType) {
|
|
1628
|
-
const rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
1629
|
-
|
|
1630
|
-
this.intro = this.intro.replace(rx, '');
|
|
1631
|
-
if (this.intro.length) return true;
|
|
1632
|
-
|
|
1633
|
-
let chunk = this.firstChunk;
|
|
1634
|
-
|
|
1635
|
-
do {
|
|
1636
|
-
const end = chunk.end;
|
|
1637
|
-
const aborted = chunk.trimStart(rx);
|
|
1638
|
-
|
|
1639
|
-
if (chunk.end !== end) {
|
|
1640
|
-
// special case...
|
|
1641
|
-
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
1642
|
-
|
|
1643
|
-
this.byEnd[chunk.end] = chunk;
|
|
1644
|
-
this.byStart[chunk.next.start] = chunk.next;
|
|
1645
|
-
this.byEnd[chunk.next.end] = chunk.next;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
if (aborted) return true;
|
|
1649
|
-
chunk = chunk.next;
|
|
1650
|
-
} while (chunk);
|
|
1651
|
-
|
|
1652
|
-
return false;
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
trimStart(charType) {
|
|
1656
|
-
this.trimStartAborted(charType);
|
|
1657
|
-
return this;
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
hasChanged() {
|
|
1661
|
-
return this.original !== this.toString();
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
_replaceRegexp(searchValue, replacement) {
|
|
1665
|
-
function getReplacement(match, str) {
|
|
1666
|
-
if (typeof replacement === 'string') {
|
|
1667
|
-
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
1668
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
1669
|
-
if (i === '$') return '$';
|
|
1670
|
-
if (i === '&') return match[0];
|
|
1671
|
-
const num = +i;
|
|
1672
|
-
if (num < match.length) return match[+i];
|
|
1673
|
-
return `$${i}`;
|
|
1674
|
-
});
|
|
1675
|
-
} else {
|
|
1676
|
-
return replacement(...match, match.index, str, match.groups);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
function matchAll(re, str) {
|
|
1680
|
-
let match;
|
|
1681
|
-
const matches = [];
|
|
1682
|
-
while ((match = re.exec(str))) {
|
|
1683
|
-
matches.push(match);
|
|
1684
|
-
}
|
|
1685
|
-
return matches;
|
|
1686
|
-
}
|
|
1687
|
-
if (searchValue.global) {
|
|
1688
|
-
const matches = matchAll(searchValue, this.original);
|
|
1689
|
-
matches.forEach((match) => {
|
|
1690
|
-
if (match.index != null) {
|
|
1691
|
-
const replacement = getReplacement(match, this.original);
|
|
1692
|
-
if (replacement !== match[0]) {
|
|
1693
|
-
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
});
|
|
1697
|
-
} else {
|
|
1698
|
-
const match = this.original.match(searchValue);
|
|
1699
|
-
if (match && match.index != null) {
|
|
1700
|
-
const replacement = getReplacement(match, this.original);
|
|
1701
|
-
if (replacement !== match[0]) {
|
|
1702
|
-
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
return this;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
_replaceString(string, replacement) {
|
|
1710
|
-
const { original } = this;
|
|
1711
|
-
const index = original.indexOf(string);
|
|
1712
|
-
|
|
1713
|
-
if (index !== -1) {
|
|
1714
|
-
if (typeof replacement === 'function') {
|
|
1715
|
-
replacement = replacement(string, index, original);
|
|
1716
|
-
}
|
|
1717
|
-
if (string !== replacement) {
|
|
1718
|
-
this.overwrite(index, index + string.length, replacement);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
return this;
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
replace(searchValue, replacement) {
|
|
1726
|
-
if (typeof searchValue === 'string') {
|
|
1727
|
-
return this._replaceString(searchValue, replacement);
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
return this._replaceRegexp(searchValue, replacement);
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
_replaceAllString(string, replacement) {
|
|
1734
|
-
const { original } = this;
|
|
1735
|
-
const stringLength = string.length;
|
|
1736
|
-
for (
|
|
1737
|
-
let index = original.indexOf(string);
|
|
1738
|
-
index !== -1;
|
|
1739
|
-
index = original.indexOf(string, index + stringLength)
|
|
1740
|
-
) {
|
|
1741
|
-
const previous = original.slice(index, index + stringLength);
|
|
1742
|
-
let _replacement = replacement;
|
|
1743
|
-
if (typeof replacement === 'function') {
|
|
1744
|
-
_replacement = replacement(previous, index, original);
|
|
1745
|
-
}
|
|
1746
|
-
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
return this;
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
replaceAll(searchValue, replacement) {
|
|
1753
|
-
if (typeof searchValue === 'string') {
|
|
1754
|
-
return this._replaceAllString(searchValue, replacement);
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
if (!searchValue.global) {
|
|
1758
|
-
throw new TypeError(
|
|
1759
|
-
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
1760
|
-
);
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
return this._replaceRegexp(searchValue, replacement);
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1768
|
-
|
|
1769
|
-
class Bundle {
|
|
1770
|
-
constructor(options = {}) {
|
|
1771
|
-
this.intro = options.intro || '';
|
|
1772
|
-
this.separator = options.separator !== undefined ? options.separator : '\n';
|
|
1773
|
-
this.sources = [];
|
|
1774
|
-
this.uniqueSources = [];
|
|
1775
|
-
this.uniqueSourceIndexByFilename = {};
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
addSource(source) {
|
|
1779
|
-
if (source instanceof MagicString) {
|
|
1780
|
-
return this.addSource({
|
|
1781
|
-
content: source,
|
|
1782
|
-
filename: source.filename,
|
|
1783
|
-
separator: this.separator,
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
if (!isObject(source) || !source.content) {
|
|
1788
|
-
throw new Error(
|
|
1789
|
-
'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
|
|
1790
|
-
);
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
|
|
1794
|
-
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
1795
|
-
});
|
|
1796
|
-
|
|
1797
|
-
if (source.separator === undefined) {
|
|
1798
|
-
// TODO there's a bunch of this sort of thing, needs cleaning up
|
|
1799
|
-
source.separator = this.separator;
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
if (source.filename) {
|
|
1803
|
-
if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
1804
|
-
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
1805
|
-
this.uniqueSources.push({ filename: source.filename, content: source.content.original });
|
|
1806
|
-
} else {
|
|
1807
|
-
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1808
|
-
if (source.content.original !== uniqueSource.content) {
|
|
1809
|
-
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
this.sources.push(source);
|
|
1815
|
-
return this;
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
append(str, options) {
|
|
1819
|
-
this.addSource({
|
|
1820
|
-
content: new MagicString(str),
|
|
1821
|
-
separator: (options && options.separator) || '',
|
|
1822
|
-
});
|
|
1823
|
-
|
|
1824
|
-
return this;
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
clone() {
|
|
1828
|
-
const bundle = new Bundle({
|
|
1829
|
-
intro: this.intro,
|
|
1830
|
-
separator: this.separator,
|
|
1831
|
-
});
|
|
1832
|
-
|
|
1833
|
-
this.sources.forEach((source) => {
|
|
1834
|
-
bundle.addSource({
|
|
1835
|
-
filename: source.filename,
|
|
1836
|
-
content: source.content.clone(),
|
|
1837
|
-
separator: source.separator,
|
|
1838
|
-
});
|
|
1839
|
-
});
|
|
1840
|
-
|
|
1841
|
-
return bundle;
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
generateDecodedMap(options = {}) {
|
|
1845
|
-
const names = [];
|
|
1846
|
-
let x_google_ignoreList = undefined;
|
|
1847
|
-
this.sources.forEach((source) => {
|
|
1848
|
-
Object.keys(source.content.storedNames).forEach((name) => {
|
|
1849
|
-
if (!~names.indexOf(name)) names.push(name);
|
|
1850
|
-
});
|
|
1851
|
-
});
|
|
1852
|
-
|
|
1853
|
-
const mappings = new Mappings(options.hires);
|
|
1854
|
-
|
|
1855
|
-
if (this.intro) {
|
|
1856
|
-
mappings.advance(this.intro);
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
this.sources.forEach((source, i) => {
|
|
1860
|
-
if (i > 0) {
|
|
1861
|
-
mappings.advance(this.separator);
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
1865
|
-
const magicString = source.content;
|
|
1866
|
-
const locate = getLocator(magicString.original);
|
|
1867
|
-
|
|
1868
|
-
if (magicString.intro) {
|
|
1869
|
-
mappings.advance(magicString.intro);
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
magicString.firstChunk.eachNext((chunk) => {
|
|
1873
|
-
const loc = locate(chunk.start);
|
|
1874
|
-
|
|
1875
|
-
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
1876
|
-
|
|
1877
|
-
if (source.filename) {
|
|
1878
|
-
if (chunk.edited) {
|
|
1879
|
-
mappings.addEdit(
|
|
1880
|
-
sourceIndex,
|
|
1881
|
-
chunk.content,
|
|
1882
|
-
loc,
|
|
1883
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
1884
|
-
);
|
|
1885
|
-
} else {
|
|
1886
|
-
mappings.addUneditedChunk(
|
|
1887
|
-
sourceIndex,
|
|
1888
|
-
chunk,
|
|
1889
|
-
magicString.original,
|
|
1890
|
-
loc,
|
|
1891
|
-
magicString.sourcemapLocations,
|
|
1892
|
-
);
|
|
1893
|
-
}
|
|
1894
|
-
} else {
|
|
1895
|
-
mappings.advance(chunk.content);
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
1899
|
-
});
|
|
1900
|
-
|
|
1901
|
-
if (magicString.outro) {
|
|
1902
|
-
mappings.advance(magicString.outro);
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
if (source.ignoreList && sourceIndex !== -1) {
|
|
1906
|
-
if (x_google_ignoreList === undefined) {
|
|
1907
|
-
x_google_ignoreList = [];
|
|
1908
|
-
}
|
|
1909
|
-
x_google_ignoreList.push(sourceIndex);
|
|
1910
|
-
}
|
|
1911
|
-
});
|
|
1912
|
-
|
|
1913
|
-
return {
|
|
1914
|
-
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
1915
|
-
sources: this.uniqueSources.map((source) => {
|
|
1916
|
-
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
1917
|
-
}),
|
|
1918
|
-
sourcesContent: this.uniqueSources.map((source) => {
|
|
1919
|
-
return options.includeContent ? source.content : null;
|
|
1920
|
-
}),
|
|
1921
|
-
names,
|
|
1922
|
-
mappings: mappings.raw,
|
|
1923
|
-
x_google_ignoreList,
|
|
1924
|
-
};
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
generateMap(options) {
|
|
1928
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
getIndentString() {
|
|
1932
|
-
const indentStringCounts = {};
|
|
1933
|
-
|
|
1934
|
-
this.sources.forEach((source) => {
|
|
1935
|
-
const indentStr = source.content._getRawIndentString();
|
|
1936
|
-
|
|
1937
|
-
if (indentStr === null) return;
|
|
1938
|
-
|
|
1939
|
-
if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
|
1940
|
-
indentStringCounts[indentStr] += 1;
|
|
1941
|
-
});
|
|
1942
|
-
|
|
1943
|
-
return (
|
|
1944
|
-
Object.keys(indentStringCounts).sort((a, b) => {
|
|
1945
|
-
return indentStringCounts[a] - indentStringCounts[b];
|
|
1946
|
-
})[0] || '\t'
|
|
1947
|
-
);
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
indent(indentStr) {
|
|
1951
|
-
if (!arguments.length) {
|
|
1952
|
-
indentStr = this.getIndentString();
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
if (indentStr === '') return this; // noop
|
|
1956
|
-
|
|
1957
|
-
let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
|
|
1958
|
-
|
|
1959
|
-
this.sources.forEach((source, i) => {
|
|
1960
|
-
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1961
|
-
const indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
|
|
1962
|
-
|
|
1963
|
-
source.content.indent(indentStr, {
|
|
1964
|
-
exclude: source.indentExclusionRanges,
|
|
1965
|
-
indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
|
|
1966
|
-
});
|
|
1967
|
-
|
|
1968
|
-
trailingNewline = source.content.lastChar() === '\n';
|
|
1969
|
-
});
|
|
1970
|
-
|
|
1971
|
-
if (this.intro) {
|
|
1972
|
-
this.intro =
|
|
1973
|
-
indentStr +
|
|
1974
|
-
this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
1975
|
-
return index > 0 ? indentStr + match : match;
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
return this;
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
prepend(str) {
|
|
1983
|
-
this.intro = str + this.intro;
|
|
1984
|
-
return this;
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
toString() {
|
|
1988
|
-
const body = this.sources
|
|
1989
|
-
.map((source, i) => {
|
|
1990
|
-
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1991
|
-
const str = (i > 0 ? separator : '') + source.content.toString();
|
|
1992
|
-
|
|
1993
|
-
return str;
|
|
1994
|
-
})
|
|
1995
|
-
.join('');
|
|
1996
|
-
|
|
1997
|
-
return this.intro + body;
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
isEmpty() {
|
|
2001
|
-
if (this.intro.length && this.intro.trim()) return false;
|
|
2002
|
-
if (this.sources.some((source) => !source.content.isEmpty())) return false;
|
|
2003
|
-
return true;
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
length() {
|
|
2007
|
-
return this.sources.reduce(
|
|
2008
|
-
(length, source) => length + source.content.length(),
|
|
2009
|
-
this.intro.length,
|
|
2010
|
-
);
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
trimLines() {
|
|
2014
|
-
return this.trim('[\\r\\n]');
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
trim(charType) {
|
|
2018
|
-
return this.trimStart(charType).trimEnd(charType);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
trimStart(charType) {
|
|
2022
|
-
const rx = new RegExp('^' + (charType || '\\s') + '+');
|
|
2023
|
-
this.intro = this.intro.replace(rx, '');
|
|
2024
|
-
|
|
2025
|
-
if (!this.intro) {
|
|
2026
|
-
let source;
|
|
2027
|
-
let i = 0;
|
|
2028
|
-
|
|
2029
|
-
do {
|
|
2030
|
-
source = this.sources[i++];
|
|
2031
|
-
if (!source) {
|
|
2032
|
-
break;
|
|
2033
|
-
}
|
|
2034
|
-
} while (!source.content.trimStartAborted(charType));
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
return this;
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
trimEnd(charType) {
|
|
2041
|
-
const rx = new RegExp((charType || '\\s') + '+$');
|
|
2042
|
-
|
|
2043
|
-
let source;
|
|
2044
|
-
let i = this.sources.length - 1;
|
|
2045
|
-
|
|
2046
|
-
do {
|
|
2047
|
-
source = this.sources[i--];
|
|
2048
|
-
if (!source) {
|
|
2049
|
-
this.intro = this.intro.replace(rx, '');
|
|
2050
|
-
break;
|
|
2051
|
-
}
|
|
2052
|
-
} while (!source.content.trimEndAborted(charType));
|
|
2053
|
-
|
|
2054
|
-
return this;
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
MagicString.Bundle = Bundle;
|
|
2059
|
-
MagicString.SourceMap = SourceMap;
|
|
2060
|
-
MagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121
|
|
2061
|
-
|
|
2062
|
-
module.exports = MagicString;
|
|
2063
|
-
//# sourceMappingURL=magic-string.cjs.js.map
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
/***/ })
|
|
2067
|
-
|
|
2068
|
-
/******/ });
|
|
2069
|
-
/************************************************************************/
|
|
2070
|
-
/******/ // The module cache
|
|
2071
|
-
/******/ var __webpack_module_cache__ = {};
|
|
2072
|
-
/******/
|
|
2073
|
-
/******/ // The require function
|
|
2074
|
-
/******/ function __nccwpck_require__(moduleId) {
|
|
2075
|
-
/******/ // Check if module is in cache
|
|
2076
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
2077
|
-
/******/ if (cachedModule !== undefined) {
|
|
2078
|
-
/******/ return cachedModule.exports;
|
|
2079
|
-
/******/ }
|
|
2080
|
-
/******/ // Create a new module (and put it into the cache)
|
|
2081
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
2082
|
-
/******/ id: moduleId,
|
|
2083
|
-
/******/ loaded: false,
|
|
2084
|
-
/******/ exports: {}
|
|
2085
|
-
/******/ };
|
|
2086
|
-
/******/
|
|
2087
|
-
/******/ // Execute the module function
|
|
2088
|
-
/******/ var threw = true;
|
|
2089
|
-
/******/ try {
|
|
2090
|
-
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
|
|
2091
|
-
/******/ threw = false;
|
|
2092
|
-
/******/ } finally {
|
|
2093
|
-
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
2094
|
-
/******/ }
|
|
2095
|
-
/******/
|
|
2096
|
-
/******/ // Flag the module as loaded
|
|
2097
|
-
/******/ module.loaded = true;
|
|
2098
|
-
/******/
|
|
2099
|
-
/******/ // Return the exports of the module
|
|
2100
|
-
/******/ return module.exports;
|
|
2101
|
-
/******/ }
|
|
2102
|
-
/******/
|
|
2103
|
-
/************************************************************************/
|
|
2104
|
-
/******/ /* webpack/runtime/node module decorator */
|
|
2105
|
-
/******/ (() => {
|
|
2106
|
-
/******/ __nccwpck_require__.nmd = (module) => {
|
|
2107
|
-
/******/ module.paths = [];
|
|
2108
|
-
/******/ if (!module.children) module.children = [];
|
|
2109
|
-
/******/ return module;
|
|
2110
|
-
/******/ };
|
|
2111
|
-
/******/ })();
|
|
2112
|
-
/******/
|
|
2113
|
-
/******/ /* webpack/runtime/compat */
|
|
2114
|
-
/******/
|
|
2115
|
-
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
2116
|
-
/******/
|
|
2117
|
-
/************************************************************************/
|
|
2118
|
-
/******/
|
|
2119
|
-
/******/ // startup
|
|
2120
|
-
/******/ // Load entry module and return exports
|
|
2121
|
-
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
2122
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(96);
|
|
2123
|
-
/******/ module.exports = __webpack_exports__;
|
|
2124
|
-
/******/
|
|
2125
|
-
/******/ })()
|
|
2126
|
-
;
|