@cyberskill/shared 1.204.0 → 1.205.1
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/magic-string.es-C6Zk6wMx.js +671 -0
- package/dist/magic-string.es-CjWtD8Pa.cjs +10 -0
- package/dist/src/config/env/env.util.cjs +1 -1
- package/dist/src/config/env/env.util.js +16 -15
- package/dist/src/config/eslint/index.d.ts +8 -0
- package/dist/src/config/vitest/vitest.unit.setup.cjs +1 -1
- package/dist/src/config/vitest/vitest.unit.setup.js +1 -1
- package/dist/src/node/cli/cli.util.cjs +1 -1
- package/dist/src/node/cli/cli.util.js +2 -2
- package/dist/src/node/mongo/mongo.util.cjs +5 -5
- package/dist/src/node/mongo/mongo.util.d.ts +1 -4
- package/dist/src/node/mongo/mongo.util.js +46 -53
- package/package.json +9 -9
- package/dist/magic-string.es-D_iPNVbJ.cjs +0 -10
- package/dist/magic-string.es-cELbkQ5L.js +0 -901
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
var R = Object.defineProperty, _ = Object.defineProperties;
|
|
2
|
+
var O = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var m = Object.getOwnPropertySymbols;
|
|
4
|
+
var N = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (h, t, e) => t in h ? R(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, C = (h, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
N.call(t, e) && b(h, e, t[e]);
|
|
8
|
+
if (m)
|
|
9
|
+
for (var e of m(t))
|
|
10
|
+
I.call(t, e) && b(h, e, t[e]);
|
|
11
|
+
return h;
|
|
12
|
+
}, y = (h, t) => _(h, O(t));
|
|
13
|
+
var A = 44, T = 59, S = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", k = new Uint8Array(64), j = new Uint8Array(128);
|
|
14
|
+
for (let h = 0; h < S.length; h++) {
|
|
15
|
+
const t = S.charCodeAt(h);
|
|
16
|
+
k[h] = t, j[t] = h;
|
|
17
|
+
}
|
|
18
|
+
function c(h, t, e) {
|
|
19
|
+
let i = t - e;
|
|
20
|
+
i = i < 0 ? -i << 1 | 1 : i << 1;
|
|
21
|
+
do {
|
|
22
|
+
let n = i & 31;
|
|
23
|
+
i >>>= 5, i > 0 && (n |= 32), h.write(k[n]);
|
|
24
|
+
} while (i > 0);
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
var v = 1024 * 16, x = typeof TextDecoder != "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer != "undefined" ? {
|
|
28
|
+
decode(h) {
|
|
29
|
+
return Buffer.from(h.buffer, h.byteOffset, h.byteLength).toString();
|
|
30
|
+
}
|
|
31
|
+
} : {
|
|
32
|
+
decode(h) {
|
|
33
|
+
let t = "";
|
|
34
|
+
for (let e = 0; e < h.length; e++)
|
|
35
|
+
t += String.fromCharCode(h[e]);
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
}, $ = class {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.pos = 0, this.out = "", this.buffer = new Uint8Array(v);
|
|
41
|
+
}
|
|
42
|
+
write(h) {
|
|
43
|
+
const { buffer: t } = this;
|
|
44
|
+
t[this.pos++] = h, this.pos === v && (this.out += x.decode(t), this.pos = 0);
|
|
45
|
+
}
|
|
46
|
+
flush() {
|
|
47
|
+
const { buffer: h, out: t, pos: e } = this;
|
|
48
|
+
return e > 0 ? t + x.decode(h.subarray(0, e)) : t;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function U(h) {
|
|
52
|
+
const t = new $();
|
|
53
|
+
let e = 0, i = 0, n = 0, r = 0;
|
|
54
|
+
for (let s = 0; s < h.length; s++) {
|
|
55
|
+
const l = h[s];
|
|
56
|
+
if (s > 0 && t.write(T), l.length === 0) continue;
|
|
57
|
+
let o = 0;
|
|
58
|
+
for (let u = 0; u < l.length; u++) {
|
|
59
|
+
const a = l[u];
|
|
60
|
+
u > 0 && t.write(A), o = c(t, a[0], o), a.length !== 1 && (e = c(t, a[1], e), i = c(t, a[2], i), n = c(t, a[3], n), a.length !== 4 && (r = c(t, a[4], r)));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return t.flush();
|
|
64
|
+
}
|
|
65
|
+
class p {
|
|
66
|
+
constructor(t) {
|
|
67
|
+
this.bits = t instanceof p ? t.bits.slice() : [];
|
|
68
|
+
}
|
|
69
|
+
add(t) {
|
|
70
|
+
this.bits[t >> 5] |= 1 << (t & 31);
|
|
71
|
+
}
|
|
72
|
+
has(t) {
|
|
73
|
+
return !!(this.bits[t >> 5] & 1 << (t & 31));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class g {
|
|
77
|
+
constructor(t, e, i) {
|
|
78
|
+
this.start = t, this.end = e, this.original = i, this.intro = "", this.outro = "", this.content = i, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
|
|
79
|
+
}
|
|
80
|
+
appendLeft(t) {
|
|
81
|
+
this.outro += t;
|
|
82
|
+
}
|
|
83
|
+
appendRight(t) {
|
|
84
|
+
this.intro = this.intro + t;
|
|
85
|
+
}
|
|
86
|
+
clone() {
|
|
87
|
+
const t = new g(this.start, this.end, this.original);
|
|
88
|
+
return t.intro = this.intro, t.outro = this.outro, t.content = this.content, t.storeName = this.storeName, t.edited = this.edited, t;
|
|
89
|
+
}
|
|
90
|
+
contains(t) {
|
|
91
|
+
return this.start < t && t < this.end;
|
|
92
|
+
}
|
|
93
|
+
eachNext(t) {
|
|
94
|
+
let e = this;
|
|
95
|
+
for (; e; )
|
|
96
|
+
t(e), e = e.next;
|
|
97
|
+
}
|
|
98
|
+
eachPrevious(t) {
|
|
99
|
+
let e = this;
|
|
100
|
+
for (; e; )
|
|
101
|
+
t(e), e = e.previous;
|
|
102
|
+
}
|
|
103
|
+
edit(t, e, i) {
|
|
104
|
+
return this.content = t, i || (this.intro = "", this.outro = ""), this.storeName = e, this.edited = !0, this;
|
|
105
|
+
}
|
|
106
|
+
prependLeft(t) {
|
|
107
|
+
this.outro = t + this.outro;
|
|
108
|
+
}
|
|
109
|
+
prependRight(t) {
|
|
110
|
+
this.intro = t + this.intro;
|
|
111
|
+
}
|
|
112
|
+
reset() {
|
|
113
|
+
this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
|
|
114
|
+
}
|
|
115
|
+
split(t) {
|
|
116
|
+
const e = t - this.start, i = this.original.slice(0, e), n = this.original.slice(e);
|
|
117
|
+
this.original = i;
|
|
118
|
+
const r = new g(t, this.end, n);
|
|
119
|
+
return r.outro = this.outro, this.outro = "", this.end = t, this.edited ? (r.edit("", !1), this.content = "") : this.content = i, r.next = this.next, r.next && (r.next.previous = r), r.previous = this, this.next = r, r;
|
|
120
|
+
}
|
|
121
|
+
toString() {
|
|
122
|
+
return this.intro + this.content + this.outro;
|
|
123
|
+
}
|
|
124
|
+
trimEnd(t) {
|
|
125
|
+
if (this.outro = this.outro.replace(t, ""), this.outro.length) return !0;
|
|
126
|
+
const e = this.content.replace(t, "");
|
|
127
|
+
if (e.length)
|
|
128
|
+
return e !== this.content && (this.split(this.start + e.length).edit("", void 0, !0), this.edited && this.edit(e, this.storeName, !0)), !0;
|
|
129
|
+
if (this.edit("", void 0, !0), this.intro = this.intro.replace(t, ""), this.intro.length) return !0;
|
|
130
|
+
}
|
|
131
|
+
trimStart(t) {
|
|
132
|
+
if (this.intro = this.intro.replace(t, ""), this.intro.length) return !0;
|
|
133
|
+
const e = this.content.replace(t, "");
|
|
134
|
+
if (e.length) {
|
|
135
|
+
if (e !== this.content) {
|
|
136
|
+
const i = this.split(this.end - e.length);
|
|
137
|
+
this.edited && i.edit(e, this.storeName, !0), this.edit("", void 0, !0);
|
|
138
|
+
}
|
|
139
|
+
return !0;
|
|
140
|
+
} else if (this.edit("", void 0, !0), this.outro = this.outro.replace(t, ""), this.outro.length) return !0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function B() {
|
|
144
|
+
return typeof globalThis != "undefined" && typeof globalThis.btoa == "function" ? (h) => globalThis.btoa(unescape(encodeURIComponent(h))) : typeof Buffer == "function" ? (h) => Buffer.from(h, "utf-8").toString("base64") : () => {
|
|
145
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const M = /* @__PURE__ */ B();
|
|
149
|
+
class P {
|
|
150
|
+
constructor(t) {
|
|
151
|
+
this.version = 3, this.file = t.file, this.sources = t.sources, this.sourcesContent = t.sourcesContent, this.names = t.names, this.mappings = U(t.mappings), typeof t.x_google_ignoreList != "undefined" && (this.x_google_ignoreList = t.x_google_ignoreList), typeof t.debugId != "undefined" && (this.debugId = t.debugId);
|
|
152
|
+
}
|
|
153
|
+
toString() {
|
|
154
|
+
return JSON.stringify(this);
|
|
155
|
+
}
|
|
156
|
+
toUrl() {
|
|
157
|
+
return "data:application/json;charset=utf-8;base64," + M(this.toString());
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function D(h) {
|
|
161
|
+
const t = h.split(`
|
|
162
|
+
`), e = t.filter((r) => /^\t+/.test(r)), i = t.filter((r) => /^ {2,}/.test(r));
|
|
163
|
+
if (e.length === 0 && i.length === 0)
|
|
164
|
+
return null;
|
|
165
|
+
if (e.length >= i.length)
|
|
166
|
+
return " ";
|
|
167
|
+
const n = i.reduce((r, s) => {
|
|
168
|
+
const l = /^ +/.exec(s)[0].length;
|
|
169
|
+
return Math.min(l, r);
|
|
170
|
+
}, 1 / 0);
|
|
171
|
+
return new Array(n + 1).join(" ");
|
|
172
|
+
}
|
|
173
|
+
function z(h, t) {
|
|
174
|
+
const e = h.split(/[/\\]/), i = t.split(/[/\\]/);
|
|
175
|
+
for (e.pop(); e[0] === i[0]; )
|
|
176
|
+
e.shift(), i.shift();
|
|
177
|
+
if (e.length) {
|
|
178
|
+
let n = e.length;
|
|
179
|
+
for (; n--; ) e[n] = "..";
|
|
180
|
+
}
|
|
181
|
+
return e.concat(i).join("/");
|
|
182
|
+
}
|
|
183
|
+
const F = Object.prototype.toString;
|
|
184
|
+
function H(h) {
|
|
185
|
+
return F.call(h) === "[object Object]";
|
|
186
|
+
}
|
|
187
|
+
function E(h) {
|
|
188
|
+
const t = h.split(`
|
|
189
|
+
`), e = [];
|
|
190
|
+
for (let i = 0, n = 0; i < t.length; i++)
|
|
191
|
+
e.push(n), n += t[i].length + 1;
|
|
192
|
+
return function(n) {
|
|
193
|
+
let r = 0, s = e.length;
|
|
194
|
+
for (; r < s; ) {
|
|
195
|
+
const u = r + s >> 1;
|
|
196
|
+
n < e[u] ? s = u : r = u + 1;
|
|
197
|
+
}
|
|
198
|
+
const l = r - 1, o = n - e[l];
|
|
199
|
+
return { line: l, column: o };
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const J = /\w/;
|
|
203
|
+
class W {
|
|
204
|
+
constructor(t) {
|
|
205
|
+
this.hires = t, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
|
|
206
|
+
}
|
|
207
|
+
addEdit(t, e, i, n) {
|
|
208
|
+
if (e.length) {
|
|
209
|
+
const r = e.length - 1;
|
|
210
|
+
let s = e.indexOf(`
|
|
211
|
+
`, 0), l = -1;
|
|
212
|
+
for (; s >= 0 && r > s; ) {
|
|
213
|
+
const u = [this.generatedCodeColumn, t, i.line, i.column];
|
|
214
|
+
n >= 0 && u.push(n), this.rawSegments.push(u), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, l = s, s = e.indexOf(`
|
|
215
|
+
`, s + 1);
|
|
216
|
+
}
|
|
217
|
+
const o = [this.generatedCodeColumn, t, i.line, i.column];
|
|
218
|
+
n >= 0 && o.push(n), this.rawSegments.push(o), this.advance(e.slice(l + 1));
|
|
219
|
+
} else this.pending && (this.rawSegments.push(this.pending), this.advance(e));
|
|
220
|
+
this.pending = null;
|
|
221
|
+
}
|
|
222
|
+
addUneditedChunk(t, e, i, n, r) {
|
|
223
|
+
let s = e.start, l = !0, o = !1;
|
|
224
|
+
for (; s < e.end; ) {
|
|
225
|
+
if (i[s] === `
|
|
226
|
+
`)
|
|
227
|
+
n.line += 1, n.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, l = !0, o = !1;
|
|
228
|
+
else {
|
|
229
|
+
if (this.hires || l || r.has(s)) {
|
|
230
|
+
const u = [this.generatedCodeColumn, t, n.line, n.column];
|
|
231
|
+
this.hires === "boundary" ? J.test(i[s]) ? o || (this.rawSegments.push(u), o = !0) : (this.rawSegments.push(u), o = !1) : this.rawSegments.push(u);
|
|
232
|
+
}
|
|
233
|
+
n.column += 1, this.generatedCodeColumn += 1, l = !1;
|
|
234
|
+
}
|
|
235
|
+
s += 1;
|
|
236
|
+
}
|
|
237
|
+
this.pending = null;
|
|
238
|
+
}
|
|
239
|
+
advance(t) {
|
|
240
|
+
if (!t) return;
|
|
241
|
+
const e = t.split(`
|
|
242
|
+
`);
|
|
243
|
+
if (e.length > 1) {
|
|
244
|
+
for (let i = 0; i < e.length - 1; i++)
|
|
245
|
+
this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
246
|
+
this.generatedCodeColumn = 0;
|
|
247
|
+
}
|
|
248
|
+
this.generatedCodeColumn += e[e.length - 1].length;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const d = `
|
|
252
|
+
`, f = {
|
|
253
|
+
insertLeft: !1,
|
|
254
|
+
insertRight: !1,
|
|
255
|
+
storeName: !1
|
|
256
|
+
};
|
|
257
|
+
class L {
|
|
258
|
+
constructor(t, e = {}) {
|
|
259
|
+
const i = new g(0, t.length, t);
|
|
260
|
+
Object.defineProperties(this, {
|
|
261
|
+
original: { writable: !0, value: t },
|
|
262
|
+
outro: { writable: !0, value: "" },
|
|
263
|
+
intro: { writable: !0, value: "" },
|
|
264
|
+
firstChunk: { writable: !0, value: i },
|
|
265
|
+
lastChunk: { writable: !0, value: i },
|
|
266
|
+
lastSearchedChunk: { writable: !0, value: i },
|
|
267
|
+
byStart: { writable: !0, value: {} },
|
|
268
|
+
byEnd: { writable: !0, value: {} },
|
|
269
|
+
filename: { writable: !0, value: e.filename },
|
|
270
|
+
indentExclusionRanges: { writable: !0, value: e.indentExclusionRanges },
|
|
271
|
+
sourcemapLocations: { writable: !0, value: new p() },
|
|
272
|
+
storedNames: { writable: !0, value: {} },
|
|
273
|
+
indentStr: { writable: !0, value: void 0 },
|
|
274
|
+
ignoreList: { writable: !0, value: e.ignoreList },
|
|
275
|
+
offset: { writable: !0, value: e.offset || 0 }
|
|
276
|
+
}), this.byStart[0] = i, this.byEnd[t.length] = i;
|
|
277
|
+
}
|
|
278
|
+
addSourcemapLocation(t) {
|
|
279
|
+
this.sourcemapLocations.add(t);
|
|
280
|
+
}
|
|
281
|
+
append(t) {
|
|
282
|
+
if (typeof t != "string") throw new TypeError("outro content must be a string");
|
|
283
|
+
return this.outro += t, this;
|
|
284
|
+
}
|
|
285
|
+
appendLeft(t, e) {
|
|
286
|
+
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
287
|
+
this._split(t);
|
|
288
|
+
const i = this.byEnd[t];
|
|
289
|
+
return i ? i.appendLeft(e) : this.intro += e, this;
|
|
290
|
+
}
|
|
291
|
+
appendRight(t, e) {
|
|
292
|
+
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
293
|
+
this._split(t);
|
|
294
|
+
const i = this.byStart[t];
|
|
295
|
+
return i ? i.appendRight(e) : this.outro += e, this;
|
|
296
|
+
}
|
|
297
|
+
clone() {
|
|
298
|
+
const t = new L(this.original, { filename: this.filename, offset: this.offset });
|
|
299
|
+
let e = this.firstChunk, i = t.firstChunk = t.lastSearchedChunk = e.clone();
|
|
300
|
+
for (; e; ) {
|
|
301
|
+
t.byStart[i.start] = i, t.byEnd[i.end] = i;
|
|
302
|
+
const n = e.next, r = n && n.clone();
|
|
303
|
+
r && (i.next = r, r.previous = i, i = r), e = n;
|
|
304
|
+
}
|
|
305
|
+
return t.lastChunk = i, this.indentExclusionRanges && (t.indentExclusionRanges = this.indentExclusionRanges.slice()), t.sourcemapLocations = new p(this.sourcemapLocations), t.intro = this.intro, t.outro = this.outro, t;
|
|
306
|
+
}
|
|
307
|
+
generateDecodedMap(t) {
|
|
308
|
+
t = t || {};
|
|
309
|
+
const e = 0, i = Object.keys(this.storedNames), n = new W(t.hires), r = E(this.original);
|
|
310
|
+
return this.intro && n.advance(this.intro), this.firstChunk.eachNext((s) => {
|
|
311
|
+
const l = r(s.start);
|
|
312
|
+
s.intro.length && n.advance(s.intro), s.edited ? n.addEdit(
|
|
313
|
+
e,
|
|
314
|
+
s.content,
|
|
315
|
+
l,
|
|
316
|
+
s.storeName ? i.indexOf(s.original) : -1
|
|
317
|
+
) : n.addUneditedChunk(e, s, this.original, l, this.sourcemapLocations), s.outro.length && n.advance(s.outro);
|
|
318
|
+
}), {
|
|
319
|
+
file: t.file ? t.file.split(/[/\\]/).pop() : void 0,
|
|
320
|
+
sources: [
|
|
321
|
+
t.source ? z(t.file || "", t.source) : t.file || ""
|
|
322
|
+
],
|
|
323
|
+
sourcesContent: t.includeContent ? [this.original] : void 0,
|
|
324
|
+
names: i,
|
|
325
|
+
mappings: n.raw,
|
|
326
|
+
x_google_ignoreList: this.ignoreList ? [e] : void 0
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
generateMap(t) {
|
|
330
|
+
return new P(this.generateDecodedMap(t));
|
|
331
|
+
}
|
|
332
|
+
_ensureindentStr() {
|
|
333
|
+
this.indentStr === void 0 && (this.indentStr = D(this.original));
|
|
334
|
+
}
|
|
335
|
+
_getRawIndentString() {
|
|
336
|
+
return this._ensureindentStr(), this.indentStr;
|
|
337
|
+
}
|
|
338
|
+
getIndentString() {
|
|
339
|
+
return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
|
|
340
|
+
}
|
|
341
|
+
indent(t, e) {
|
|
342
|
+
const i = /^[^\r\n]/gm;
|
|
343
|
+
if (H(t) && (e = t, t = void 0), t === void 0 && (this._ensureindentStr(), t = this.indentStr || " "), t === "") return this;
|
|
344
|
+
e = e || {};
|
|
345
|
+
const n = {};
|
|
346
|
+
e.exclude && (typeof e.exclude[0] == "number" ? [e.exclude] : e.exclude).forEach((a) => {
|
|
347
|
+
for (let w = a[0]; w < a[1]; w += 1)
|
|
348
|
+
n[w] = !0;
|
|
349
|
+
});
|
|
350
|
+
let r = e.indentStart !== !1;
|
|
351
|
+
const s = (u) => r ? `${t}${u}` : (r = !0, u);
|
|
352
|
+
this.intro = this.intro.replace(i, s);
|
|
353
|
+
let l = 0, o = this.firstChunk;
|
|
354
|
+
for (; o; ) {
|
|
355
|
+
const u = o.end;
|
|
356
|
+
if (o.edited)
|
|
357
|
+
n[l] || (o.content = o.content.replace(i, s), o.content.length && (r = o.content[o.content.length - 1] === `
|
|
358
|
+
`));
|
|
359
|
+
else
|
|
360
|
+
for (l = o.start; l < u; ) {
|
|
361
|
+
if (!n[l]) {
|
|
362
|
+
const a = this.original[l];
|
|
363
|
+
a === `
|
|
364
|
+
` ? r = !0 : a !== "\r" && r && (r = !1, l === o.start || (this._splitChunk(o, l), o = o.next), o.prependRight(t));
|
|
365
|
+
}
|
|
366
|
+
l += 1;
|
|
367
|
+
}
|
|
368
|
+
l = o.end, o = o.next;
|
|
369
|
+
}
|
|
370
|
+
return this.outro = this.outro.replace(i, s), this;
|
|
371
|
+
}
|
|
372
|
+
insert() {
|
|
373
|
+
throw new Error(
|
|
374
|
+
"magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
insertLeft(t, e) {
|
|
378
|
+
return f.insertLeft || (console.warn(
|
|
379
|
+
"magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
|
|
380
|
+
), f.insertLeft = !0), this.appendLeft(t, e);
|
|
381
|
+
}
|
|
382
|
+
insertRight(t, e) {
|
|
383
|
+
return f.insertRight || (console.warn(
|
|
384
|
+
"magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
|
|
385
|
+
), f.insertRight = !0), this.prependRight(t, e);
|
|
386
|
+
}
|
|
387
|
+
move(t, e, i) {
|
|
388
|
+
if (t = t + this.offset, e = e + this.offset, i = i + this.offset, i >= t && i <= e) throw new Error("Cannot move a selection inside itself");
|
|
389
|
+
this._split(t), this._split(e), this._split(i);
|
|
390
|
+
const n = this.byStart[t], r = this.byEnd[e], s = n.previous, l = r.next, o = this.byStart[i];
|
|
391
|
+
if (!o && r === this.lastChunk) return this;
|
|
392
|
+
const u = o ? o.previous : this.lastChunk;
|
|
393
|
+
return s && (s.next = l), l && (l.previous = s), u && (u.next = n), o && (o.previous = r), n.previous || (this.firstChunk = r.next), r.next || (this.lastChunk = n.previous, this.lastChunk.next = null), n.previous = u, r.next = o || null, u || (this.firstChunk = n), o || (this.lastChunk = r), this;
|
|
394
|
+
}
|
|
395
|
+
overwrite(t, e, i, n) {
|
|
396
|
+
return n = n || {}, this.update(t, e, i, y(C({}, n), { overwrite: !n.contentOnly }));
|
|
397
|
+
}
|
|
398
|
+
update(t, e, i, n) {
|
|
399
|
+
if (t = t + this.offset, e = e + this.offset, typeof i != "string") throw new TypeError("replacement content must be a string");
|
|
400
|
+
if (this.original.length !== 0) {
|
|
401
|
+
for (; t < 0; ) t += this.original.length;
|
|
402
|
+
for (; e < 0; ) e += this.original.length;
|
|
403
|
+
}
|
|
404
|
+
if (e > this.original.length) throw new Error("end is out of bounds");
|
|
405
|
+
if (t === e)
|
|
406
|
+
throw new Error(
|
|
407
|
+
"Cannot overwrite a zero-length range – use appendLeft or prependRight instead"
|
|
408
|
+
);
|
|
409
|
+
this._split(t), this._split(e), n === !0 && (f.storeName || (console.warn(
|
|
410
|
+
"The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
|
|
411
|
+
), f.storeName = !0), n = { storeName: !0 });
|
|
412
|
+
const r = n !== void 0 ? n.storeName : !1, s = n !== void 0 ? n.overwrite : !1;
|
|
413
|
+
if (r) {
|
|
414
|
+
const u = this.original.slice(t, e);
|
|
415
|
+
Object.defineProperty(this.storedNames, u, {
|
|
416
|
+
writable: !0,
|
|
417
|
+
value: !0,
|
|
418
|
+
enumerable: !0
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
const l = this.byStart[t], o = this.byEnd[e];
|
|
422
|
+
if (l) {
|
|
423
|
+
let u = l;
|
|
424
|
+
for (; u !== o; ) {
|
|
425
|
+
if (u.next !== this.byStart[u.end])
|
|
426
|
+
throw new Error("Cannot overwrite across a split point");
|
|
427
|
+
u = u.next, u.edit("", !1);
|
|
428
|
+
}
|
|
429
|
+
l.edit(i, r, !s);
|
|
430
|
+
} else {
|
|
431
|
+
const u = new g(t, e, "").edit(i, r);
|
|
432
|
+
o.next = u, u.previous = o;
|
|
433
|
+
}
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
prepend(t) {
|
|
437
|
+
if (typeof t != "string") throw new TypeError("outro content must be a string");
|
|
438
|
+
return this.intro = t + this.intro, this;
|
|
439
|
+
}
|
|
440
|
+
prependLeft(t, e) {
|
|
441
|
+
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
442
|
+
this._split(t);
|
|
443
|
+
const i = this.byEnd[t];
|
|
444
|
+
return i ? i.prependLeft(e) : this.intro = e + this.intro, this;
|
|
445
|
+
}
|
|
446
|
+
prependRight(t, e) {
|
|
447
|
+
if (t = t + this.offset, typeof e != "string") throw new TypeError("inserted content must be a string");
|
|
448
|
+
this._split(t);
|
|
449
|
+
const i = this.byStart[t];
|
|
450
|
+
return i ? i.prependRight(e) : this.outro = e + this.outro, this;
|
|
451
|
+
}
|
|
452
|
+
remove(t, e) {
|
|
453
|
+
if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
|
|
454
|
+
for (; t < 0; ) t += this.original.length;
|
|
455
|
+
for (; e < 0; ) e += this.original.length;
|
|
456
|
+
}
|
|
457
|
+
if (t === e) return this;
|
|
458
|
+
if (t < 0 || e > this.original.length) throw new Error("Character is out of bounds");
|
|
459
|
+
if (t > e) throw new Error("end must be greater than start");
|
|
460
|
+
this._split(t), this._split(e);
|
|
461
|
+
let i = this.byStart[t];
|
|
462
|
+
for (; i; )
|
|
463
|
+
i.intro = "", i.outro = "", i.edit(""), i = e > i.end ? this.byStart[i.end] : null;
|
|
464
|
+
return this;
|
|
465
|
+
}
|
|
466
|
+
reset(t, e) {
|
|
467
|
+
if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
|
|
468
|
+
for (; t < 0; ) t += this.original.length;
|
|
469
|
+
for (; e < 0; ) e += this.original.length;
|
|
470
|
+
}
|
|
471
|
+
if (t === e) return this;
|
|
472
|
+
if (t < 0 || e > this.original.length) throw new Error("Character is out of bounds");
|
|
473
|
+
if (t > e) throw new Error("end must be greater than start");
|
|
474
|
+
this._split(t), this._split(e);
|
|
475
|
+
let i = this.byStart[t];
|
|
476
|
+
for (; i; )
|
|
477
|
+
i.reset(), i = e > i.end ? this.byStart[i.end] : null;
|
|
478
|
+
return this;
|
|
479
|
+
}
|
|
480
|
+
lastChar() {
|
|
481
|
+
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
482
|
+
let t = this.lastChunk;
|
|
483
|
+
do {
|
|
484
|
+
if (t.outro.length) return t.outro[t.outro.length - 1];
|
|
485
|
+
if (t.content.length) return t.content[t.content.length - 1];
|
|
486
|
+
if (t.intro.length) return t.intro[t.intro.length - 1];
|
|
487
|
+
} while (t = t.previous);
|
|
488
|
+
return this.intro.length ? this.intro[this.intro.length - 1] : "";
|
|
489
|
+
}
|
|
490
|
+
lastLine() {
|
|
491
|
+
let t = this.outro.lastIndexOf(d);
|
|
492
|
+
if (t !== -1) return this.outro.substr(t + 1);
|
|
493
|
+
let e = this.outro, i = this.lastChunk;
|
|
494
|
+
do {
|
|
495
|
+
if (i.outro.length > 0) {
|
|
496
|
+
if (t = i.outro.lastIndexOf(d), t !== -1) return i.outro.substr(t + 1) + e;
|
|
497
|
+
e = i.outro + e;
|
|
498
|
+
}
|
|
499
|
+
if (i.content.length > 0) {
|
|
500
|
+
if (t = i.content.lastIndexOf(d), t !== -1) return i.content.substr(t + 1) + e;
|
|
501
|
+
e = i.content + e;
|
|
502
|
+
}
|
|
503
|
+
if (i.intro.length > 0) {
|
|
504
|
+
if (t = i.intro.lastIndexOf(d), t !== -1) return i.intro.substr(t + 1) + e;
|
|
505
|
+
e = i.intro + e;
|
|
506
|
+
}
|
|
507
|
+
} while (i = i.previous);
|
|
508
|
+
return t = this.intro.lastIndexOf(d), t !== -1 ? this.intro.substr(t + 1) + e : this.intro + e;
|
|
509
|
+
}
|
|
510
|
+
slice(t = 0, e = this.original.length - this.offset) {
|
|
511
|
+
if (t = t + this.offset, e = e + this.offset, this.original.length !== 0) {
|
|
512
|
+
for (; t < 0; ) t += this.original.length;
|
|
513
|
+
for (; e < 0; ) e += this.original.length;
|
|
514
|
+
}
|
|
515
|
+
let i = "", n = this.firstChunk;
|
|
516
|
+
for (; n && (n.start > t || n.end <= t); ) {
|
|
517
|
+
if (n.start < e && n.end >= e)
|
|
518
|
+
return i;
|
|
519
|
+
n = n.next;
|
|
520
|
+
}
|
|
521
|
+
if (n && n.edited && n.start !== t)
|
|
522
|
+
throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);
|
|
523
|
+
const r = n;
|
|
524
|
+
for (; n; ) {
|
|
525
|
+
n.intro && (r !== n || n.start === t) && (i += n.intro);
|
|
526
|
+
const s = n.start < e && n.end >= e;
|
|
527
|
+
if (s && n.edited && n.end !== e)
|
|
528
|
+
throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);
|
|
529
|
+
const l = r === n ? t - n.start : 0, o = s ? n.content.length + e - n.end : n.content.length;
|
|
530
|
+
if (i += n.content.slice(l, o), n.outro && (!s || n.end === e) && (i += n.outro), s)
|
|
531
|
+
break;
|
|
532
|
+
n = n.next;
|
|
533
|
+
}
|
|
534
|
+
return i;
|
|
535
|
+
}
|
|
536
|
+
// TODO deprecate this? not really very useful
|
|
537
|
+
snip(t, e) {
|
|
538
|
+
const i = this.clone();
|
|
539
|
+
return i.remove(0, t), i.remove(e, i.original.length), i;
|
|
540
|
+
}
|
|
541
|
+
_split(t) {
|
|
542
|
+
if (this.byStart[t] || this.byEnd[t]) return;
|
|
543
|
+
let e = this.lastSearchedChunk;
|
|
544
|
+
const i = t > e.end;
|
|
545
|
+
for (; e; ) {
|
|
546
|
+
if (e.contains(t)) return this._splitChunk(e, t);
|
|
547
|
+
e = i ? this.byStart[e.end] : this.byEnd[e.start];
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
_splitChunk(t, e) {
|
|
551
|
+
if (t.edited && t.content.length) {
|
|
552
|
+
const n = E(this.original)(e);
|
|
553
|
+
throw new Error(
|
|
554
|
+
`Cannot split a chunk that has already been edited (${n.line}:${n.column} – "${t.original}")`
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
const i = t.split(e);
|
|
558
|
+
return this.byEnd[e] = t, this.byStart[e] = i, this.byEnd[i.end] = i, t === this.lastChunk && (this.lastChunk = i), this.lastSearchedChunk = t, !0;
|
|
559
|
+
}
|
|
560
|
+
toString() {
|
|
561
|
+
let t = this.intro, e = this.firstChunk;
|
|
562
|
+
for (; e; )
|
|
563
|
+
t += e.toString(), e = e.next;
|
|
564
|
+
return t + this.outro;
|
|
565
|
+
}
|
|
566
|
+
isEmpty() {
|
|
567
|
+
let t = this.firstChunk;
|
|
568
|
+
do
|
|
569
|
+
if (t.intro.length && t.intro.trim() || t.content.length && t.content.trim() || t.outro.length && t.outro.trim())
|
|
570
|
+
return !1;
|
|
571
|
+
while (t = t.next);
|
|
572
|
+
return !0;
|
|
573
|
+
}
|
|
574
|
+
length() {
|
|
575
|
+
let t = this.firstChunk, e = 0;
|
|
576
|
+
do
|
|
577
|
+
e += t.intro.length + t.content.length + t.outro.length;
|
|
578
|
+
while (t = t.next);
|
|
579
|
+
return e;
|
|
580
|
+
}
|
|
581
|
+
trimLines() {
|
|
582
|
+
return this.trim("[\\r\\n]");
|
|
583
|
+
}
|
|
584
|
+
trim(t) {
|
|
585
|
+
return this.trimStart(t).trimEnd(t);
|
|
586
|
+
}
|
|
587
|
+
trimEndAborted(t) {
|
|
588
|
+
const e = new RegExp((t || "\\s") + "+$");
|
|
589
|
+
if (this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
|
|
590
|
+
let i = this.lastChunk;
|
|
591
|
+
do {
|
|
592
|
+
const n = i.end, r = i.trimEnd(e);
|
|
593
|
+
if (i.end !== n && (this.lastChunk === i && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.byEnd[i.next.end] = i.next), r) return !0;
|
|
594
|
+
i = i.previous;
|
|
595
|
+
} while (i);
|
|
596
|
+
return !1;
|
|
597
|
+
}
|
|
598
|
+
trimEnd(t) {
|
|
599
|
+
return this.trimEndAborted(t), this;
|
|
600
|
+
}
|
|
601
|
+
trimStartAborted(t) {
|
|
602
|
+
const e = new RegExp("^" + (t || "\\s") + "+");
|
|
603
|
+
if (this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
|
|
604
|
+
let i = this.firstChunk;
|
|
605
|
+
do {
|
|
606
|
+
const n = i.end, r = i.trimStart(e);
|
|
607
|
+
if (i.end !== n && (i === this.lastChunk && (this.lastChunk = i.next), this.byEnd[i.end] = i, this.byStart[i.next.start] = i.next, this.byEnd[i.next.end] = i.next), r) return !0;
|
|
608
|
+
i = i.next;
|
|
609
|
+
} while (i);
|
|
610
|
+
return !1;
|
|
611
|
+
}
|
|
612
|
+
trimStart(t) {
|
|
613
|
+
return this.trimStartAborted(t), this;
|
|
614
|
+
}
|
|
615
|
+
hasChanged() {
|
|
616
|
+
return this.original !== this.toString();
|
|
617
|
+
}
|
|
618
|
+
_replaceRegexp(t, e) {
|
|
619
|
+
function i(r, s) {
|
|
620
|
+
return typeof e == "string" ? e.replace(/\$(\$|&|\d+)/g, (l, o) => o === "$" ? "$" : o === "&" ? r[0] : +o < r.length ? r[+o] : `$${o}`) : e(...r, r.index, s, r.groups);
|
|
621
|
+
}
|
|
622
|
+
function n(r, s) {
|
|
623
|
+
let l;
|
|
624
|
+
const o = [];
|
|
625
|
+
for (; l = r.exec(s); )
|
|
626
|
+
o.push(l);
|
|
627
|
+
return o;
|
|
628
|
+
}
|
|
629
|
+
if (t.global)
|
|
630
|
+
n(t, this.original).forEach((s) => {
|
|
631
|
+
if (s.index != null) {
|
|
632
|
+
const l = i(s, this.original);
|
|
633
|
+
l !== s[0] && this.overwrite(s.index, s.index + s[0].length, l);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
else {
|
|
637
|
+
const r = this.original.match(t);
|
|
638
|
+
if (r && r.index != null) {
|
|
639
|
+
const s = i(r, this.original);
|
|
640
|
+
s !== r[0] && this.overwrite(r.index, r.index + r[0].length, s);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
_replaceString(t, e) {
|
|
646
|
+
const { original: i } = this, n = i.indexOf(t);
|
|
647
|
+
return n !== -1 && this.overwrite(n, n + t.length, e), this;
|
|
648
|
+
}
|
|
649
|
+
replace(t, e) {
|
|
650
|
+
return typeof t == "string" ? this._replaceString(t, e) : this._replaceRegexp(t, e);
|
|
651
|
+
}
|
|
652
|
+
_replaceAllString(t, e) {
|
|
653
|
+
const { original: i } = this, n = t.length;
|
|
654
|
+
for (let r = i.indexOf(t); r !== -1; r = i.indexOf(t, r + n))
|
|
655
|
+
i.slice(r, r + n) !== e && this.overwrite(r, r + n, e);
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
replaceAll(t, e) {
|
|
659
|
+
if (typeof t == "string")
|
|
660
|
+
return this._replaceAllString(t, e);
|
|
661
|
+
if (!t.global)
|
|
662
|
+
throw new TypeError(
|
|
663
|
+
"MagicString.prototype.replaceAll called with a non-global RegExp argument"
|
|
664
|
+
);
|
|
665
|
+
return this._replaceRegexp(t, e);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
export {
|
|
669
|
+
P as SourceMap,
|
|
670
|
+
L as default
|
|
671
|
+
};
|