vitest-websocket-mock 0.1.0

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