@choksheak/react-utils 0.4.4 → 0.4.6
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/NoSSR.cjs +30 -7
- package/NoSSR.min.cjs +1 -1
- package/NoSSR.min.cjs.map +1 -1
- package/NoSSR.min.mjs +1 -1
- package/NoSSR.min.mjs.map +1 -1
- package/NoSSR.mjs +0 -2
- package/index.cjs +985 -43
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.min.cjs +1 -1
- package/index.min.cjs.map +1 -1
- package/index.min.mjs +1 -1
- package/index.min.mjs.map +1 -1
- package/index.mjs +922 -25
- package/package.json +1 -41
- package/sharedQuery.cjs +944 -10
- package/sharedQuery.d.cts +21 -20
- package/sharedQuery.d.ts +21 -20
- package/sharedQuery.min.cjs +1 -1
- package/sharedQuery.min.cjs.map +1 -1
- package/sharedQuery.min.mjs +1 -1
- package/sharedQuery.min.mjs.map +1 -1
- package/sharedQuery.mjs +912 -10
- package/sharedState.cjs +334 -15
- package/sharedState.min.cjs +1 -1
- package/sharedState.min.cjs.map +1 -1
- package/sharedState.min.mjs +1 -1
- package/sharedState.min.mjs.map +1 -1
- package/sharedState.mjs +299 -10
- package/storage.cjs +129 -10
- package/storage.min.cjs +1 -1
- package/storage.min.cjs.map +1 -1
- package/storage.min.mjs +1 -1
- package/storage.min.mjs.map +1 -1
- package/storage.mjs +98 -6
- package/stringify.cjs +57 -6
- package/stringify.min.cjs +1 -1
- package/stringify.min.cjs.map +1 -1
- package/stringify.min.mjs +1 -1
- package/stringify.min.mjs.map +1 -1
- package/stringify.mjs +30 -4
- package/useDeepMemo.cjs +40 -6
- package/useDeepMemo.min.cjs +1 -1
- package/useDeepMemo.min.cjs.map +1 -1
- package/useDeepMemo.min.mjs +1 -1
- package/useDeepMemo.min.mjs.map +1 -1
- package/useDeepMemo.mjs +13 -4
- package/chunk-4235I4VO.mjs +0 -34
- package/chunk-433OAJVP.min.cjs +0 -2
- package/chunk-433OAJVP.min.cjs.map +0 -1
- package/chunk-4J7TN5JN.mjs +0 -17
- package/chunk-5PDGU37E.cjs +0 -104
- package/chunk-7D2YNZO3.cjs +0 -577
- package/chunk-BQIRLDQC.min.mjs +0 -2
- package/chunk-BQIRLDQC.min.mjs.map +0 -1
- package/chunk-CYTO5EZE.cjs +0 -34
- package/chunk-FXCYHS3L.mjs +0 -577
- package/chunk-HRE7YPUJ.min.mjs +0 -2
- package/chunk-HRE7YPUJ.min.mjs.map +0 -1
- package/chunk-IS3BZTWE.cjs +0 -35
- package/chunk-JOHZV3FD.min.cjs +0 -2
- package/chunk-JOHZV3FD.min.cjs.map +0 -1
- package/chunk-KGN4HQPP.min.cjs +0 -2
- package/chunk-KGN4HQPP.min.cjs.map +0 -1
- package/chunk-NGGNAAHA.cjs +0 -203
- package/chunk-NL4FU2MJ.min.mjs +0 -2
- package/chunk-NL4FU2MJ.min.mjs.map +0 -1
- package/chunk-PHLY3LR4.mjs +0 -104
- package/chunk-R7POPVJR.mjs +0 -35
- package/chunk-RP2TWHFU.min.cjs +0 -2
- package/chunk-RP2TWHFU.min.cjs.map +0 -1
- package/chunk-TI3FMEYP.min.mjs +0 -2
- package/chunk-TI3FMEYP.min.mjs.map +0 -1
- package/chunk-UFJQLQFI.min.cjs +0 -2
- package/chunk-UFJQLQFI.min.cjs.map +0 -1
- package/chunk-VHMO75EY.min.mjs +0 -2
- package/chunk-VHMO75EY.min.mjs.map +0 -1
- package/chunk-WXLUEDBO.cjs +0 -17
- package/chunk-XRHQCN2J.min.mjs +0 -2
- package/chunk-XRHQCN2J.min.mjs.map +0 -1
- package/chunk-YHU4KW2D.mjs +0 -203
- package/chunk-ZCDXPV3A.min.cjs +0 -2
- package/chunk-ZCDXPV3A.min.cjs.map +0 -1
- package/dist-O6NNX4Y3.min.mjs +0 -2
- package/dist-O6NNX4Y3.min.mjs.map +0 -1
- package/dist-SEGTJ72R.min.cjs +0 -2
- package/dist-SEGTJ72R.min.cjs.map +0 -1
- package/dist-UKP7SPWZ.cjs +0 -545
- package/dist-YXYQDOH5.mjs +0 -545
- package/magic-string.es-5QZEPJXJ.min.mjs +0 -14
- package/magic-string.es-5QZEPJXJ.min.mjs.map +0 -1
- package/magic-string.es-EREYSDLL.mjs +0 -1308
- package/magic-string.es-FXUUD55Y.min.cjs +0 -14
- package/magic-string.es-FXUUD55Y.min.cjs.map +0 -1
- package/magic-string.es-HC5PDAU3.cjs +0 -1308
package/dist-YXYQDOH5.mjs
DELETED
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
import "./chunk-R7POPVJR.mjs";
|
|
2
|
-
|
|
3
|
-
// node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js
|
|
4
|
-
var $ = Object.defineProperty;
|
|
5
|
-
var C = (s) => {
|
|
6
|
-
throw TypeError(s);
|
|
7
|
-
};
|
|
8
|
-
var D = (s, n, t) => n in s ? $(s, n, { enumerable: true, configurable: true, writable: true, value: t }) : s[n] = t;
|
|
9
|
-
var O = (s, n, t) => D(s, typeof n != "symbol" ? n + "" : n, t);
|
|
10
|
-
var q = (s, n, t) => n.has(s) || C("Cannot " + t);
|
|
11
|
-
var d = (s, n, t) => (q(s, n, "read from private field"), t ? t.call(s) : n.get(s));
|
|
12
|
-
var k = (s, n, t) => n.has(s) ? C("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(s) : n.set(s, t);
|
|
13
|
-
var f = (s, n, t, e) => (q(s, n, "write to private field"), e ? e.call(s, t) : n.set(s, t), t);
|
|
14
|
-
var F = (s, n, t, e) => ({
|
|
15
|
-
set _(r) {
|
|
16
|
-
f(s, n, r, t);
|
|
17
|
-
},
|
|
18
|
-
get _() {
|
|
19
|
-
return d(s, n, e);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
var M = class {
|
|
23
|
-
constructor(n) {
|
|
24
|
-
O(this, "value");
|
|
25
|
-
O(this, "next");
|
|
26
|
-
this.value = n;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var m;
|
|
30
|
-
var w;
|
|
31
|
-
var E;
|
|
32
|
-
var g = class {
|
|
33
|
-
constructor() {
|
|
34
|
-
k(this, m);
|
|
35
|
-
k(this, w);
|
|
36
|
-
k(this, E);
|
|
37
|
-
this.clear();
|
|
38
|
-
}
|
|
39
|
-
enqueue(n) {
|
|
40
|
-
let t = new M(n);
|
|
41
|
-
d(this, m) ? (d(this, w).next = t, f(this, w, t)) : (f(this, m, t), f(this, w, t)), F(this, E)._++;
|
|
42
|
-
}
|
|
43
|
-
dequeue() {
|
|
44
|
-
let n = d(this, m);
|
|
45
|
-
if (n)
|
|
46
|
-
return f(this, m, d(this, m).next), F(this, E)._--, n.value;
|
|
47
|
-
}
|
|
48
|
-
clear() {
|
|
49
|
-
f(this, m, void 0), f(this, w, void 0), f(this, E, 0);
|
|
50
|
-
}
|
|
51
|
-
get size() {
|
|
52
|
-
return d(this, E);
|
|
53
|
-
}
|
|
54
|
-
*[Symbol.iterator]() {
|
|
55
|
-
let n = d(this, m);
|
|
56
|
-
for (; n; )
|
|
57
|
-
yield n.value, n = n.next;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
m = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap();
|
|
61
|
-
function y(s) {
|
|
62
|
-
if (!((Number.isInteger(s) || s === Number.POSITIVE_INFINITY) && s > 0))
|
|
63
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
64
|
-
let n = new g(), t = 0, e = () => {
|
|
65
|
-
t--, n.size > 0 && n.dequeue()();
|
|
66
|
-
}, r = async (h, p, a) => {
|
|
67
|
-
t++;
|
|
68
|
-
let l = (async () => h(...a))();
|
|
69
|
-
p(l);
|
|
70
|
-
try {
|
|
71
|
-
await l;
|
|
72
|
-
} catch (T) {
|
|
73
|
-
}
|
|
74
|
-
e();
|
|
75
|
-
}, i = (h, p, a) => {
|
|
76
|
-
n.enqueue(r.bind(void 0, h, p, a)), (async () => (await Promise.resolve(), t < s && n.size > 0 && n.dequeue()()))();
|
|
77
|
-
}, c = (h, ...p) => new Promise((a) => {
|
|
78
|
-
i(h, a, p);
|
|
79
|
-
});
|
|
80
|
-
return Object.defineProperties(c, {
|
|
81
|
-
activeCount: {
|
|
82
|
-
get: () => t
|
|
83
|
-
},
|
|
84
|
-
pendingCount: {
|
|
85
|
-
get: () => n.size
|
|
86
|
-
},
|
|
87
|
-
clearQueue: {
|
|
88
|
-
value: () => {
|
|
89
|
-
n.clear();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}), c;
|
|
93
|
-
}
|
|
94
|
-
function o(s, n = null) {
|
|
95
|
-
let t = new Event(s);
|
|
96
|
-
return n && Object.defineProperty(t, "task", {
|
|
97
|
-
value: n,
|
|
98
|
-
enumerable: true,
|
|
99
|
-
writable: false,
|
|
100
|
-
configurable: false
|
|
101
|
-
}), t;
|
|
102
|
-
}
|
|
103
|
-
var G = {
|
|
104
|
-
1: 12.71,
|
|
105
|
-
2: 4.303,
|
|
106
|
-
3: 3.182,
|
|
107
|
-
4: 2.776,
|
|
108
|
-
5: 2.571,
|
|
109
|
-
6: 2.447,
|
|
110
|
-
7: 2.365,
|
|
111
|
-
8: 2.306,
|
|
112
|
-
9: 2.262,
|
|
113
|
-
10: 2.228,
|
|
114
|
-
11: 2.201,
|
|
115
|
-
12: 2.179,
|
|
116
|
-
13: 2.16,
|
|
117
|
-
14: 2.145,
|
|
118
|
-
15: 2.131,
|
|
119
|
-
16: 2.12,
|
|
120
|
-
17: 2.11,
|
|
121
|
-
18: 2.101,
|
|
122
|
-
19: 2.093,
|
|
123
|
-
20: 2.086,
|
|
124
|
-
21: 2.08,
|
|
125
|
-
22: 2.074,
|
|
126
|
-
23: 2.069,
|
|
127
|
-
24: 2.064,
|
|
128
|
-
25: 2.06,
|
|
129
|
-
26: 2.056,
|
|
130
|
-
27: 2.052,
|
|
131
|
-
28: 2.048,
|
|
132
|
-
29: 2.045,
|
|
133
|
-
30: 2.042,
|
|
134
|
-
31: 2.0399,
|
|
135
|
-
32: 2.0378,
|
|
136
|
-
33: 2.0357,
|
|
137
|
-
34: 2.0336,
|
|
138
|
-
35: 2.0315,
|
|
139
|
-
36: 2.0294,
|
|
140
|
-
37: 2.0273,
|
|
141
|
-
38: 2.0252,
|
|
142
|
-
39: 2.0231,
|
|
143
|
-
40: 2.021,
|
|
144
|
-
41: 2.0198,
|
|
145
|
-
42: 2.0186,
|
|
146
|
-
43: 2.0174,
|
|
147
|
-
44: 2.0162,
|
|
148
|
-
45: 2.015,
|
|
149
|
-
46: 2.0138,
|
|
150
|
-
47: 2.0126,
|
|
151
|
-
48: 2.0114,
|
|
152
|
-
49: 2.0102,
|
|
153
|
-
50: 2.009,
|
|
154
|
-
51: 2.0081,
|
|
155
|
-
52: 2.0072,
|
|
156
|
-
53: 2.0063,
|
|
157
|
-
54: 2.0054,
|
|
158
|
-
55: 2.0045,
|
|
159
|
-
56: 2.0036,
|
|
160
|
-
57: 2.0027,
|
|
161
|
-
58: 2.0018,
|
|
162
|
-
59: 2.0009,
|
|
163
|
-
60: 2,
|
|
164
|
-
61: 1.9995,
|
|
165
|
-
62: 1.999,
|
|
166
|
-
63: 1.9985,
|
|
167
|
-
64: 1.998,
|
|
168
|
-
65: 1.9975,
|
|
169
|
-
66: 1.997,
|
|
170
|
-
67: 1.9965,
|
|
171
|
-
68: 1.996,
|
|
172
|
-
69: 1.9955,
|
|
173
|
-
70: 1.995,
|
|
174
|
-
71: 1.9945,
|
|
175
|
-
72: 1.994,
|
|
176
|
-
73: 1.9935,
|
|
177
|
-
74: 1.993,
|
|
178
|
-
75: 1.9925,
|
|
179
|
-
76: 1.992,
|
|
180
|
-
77: 1.9915,
|
|
181
|
-
78: 1.991,
|
|
182
|
-
79: 1.9905,
|
|
183
|
-
80: 1.99,
|
|
184
|
-
81: 1.9897,
|
|
185
|
-
82: 1.9894,
|
|
186
|
-
83: 1.9891,
|
|
187
|
-
84: 1.9888,
|
|
188
|
-
85: 1.9885,
|
|
189
|
-
86: 1.9882,
|
|
190
|
-
87: 1.9879,
|
|
191
|
-
88: 1.9876,
|
|
192
|
-
89: 1.9873,
|
|
193
|
-
90: 1.987,
|
|
194
|
-
91: 1.9867,
|
|
195
|
-
92: 1.9864,
|
|
196
|
-
93: 1.9861,
|
|
197
|
-
94: 1.9858,
|
|
198
|
-
95: 1.9855,
|
|
199
|
-
96: 1.9852,
|
|
200
|
-
97: 1.9849,
|
|
201
|
-
98: 1.9846,
|
|
202
|
-
99: 1.9843,
|
|
203
|
-
100: 1.984,
|
|
204
|
-
101: 1.9838,
|
|
205
|
-
102: 1.9836,
|
|
206
|
-
103: 1.9834,
|
|
207
|
-
104: 1.9832,
|
|
208
|
-
105: 1.983,
|
|
209
|
-
106: 1.9828,
|
|
210
|
-
107: 1.9826,
|
|
211
|
-
108: 1.9824,
|
|
212
|
-
109: 1.9822,
|
|
213
|
-
110: 1.982,
|
|
214
|
-
111: 1.9818,
|
|
215
|
-
112: 1.9816,
|
|
216
|
-
113: 1.9814,
|
|
217
|
-
114: 1.9812,
|
|
218
|
-
115: 1.9819,
|
|
219
|
-
116: 1.9808,
|
|
220
|
-
117: 1.9806,
|
|
221
|
-
118: 1.9804,
|
|
222
|
-
119: 1.9802,
|
|
223
|
-
120: 1.98,
|
|
224
|
-
infinity: 1.96
|
|
225
|
-
};
|
|
226
|
-
var N = G;
|
|
227
|
-
var J = (s) => s / 1e6;
|
|
228
|
-
var U = () => J(Number(process.hrtime.bigint()));
|
|
229
|
-
var B = () => performance.now();
|
|
230
|
-
function W(s) {
|
|
231
|
-
return s !== null && typeof s == "object" && typeof s.then == "function";
|
|
232
|
-
}
|
|
233
|
-
var S = (s, n) => s.reduce((e, r) => e + (r - n) ** 2, 0) / (s.length - 1) || 0;
|
|
234
|
-
var X = (async () => {
|
|
235
|
-
}).constructor;
|
|
236
|
-
var Z = (s) => s.constructor === X;
|
|
237
|
-
var z = async (s) => {
|
|
238
|
-
if (Z(s.fn))
|
|
239
|
-
return true;
|
|
240
|
-
try {
|
|
241
|
-
if (s.opts.beforeEach != null)
|
|
242
|
-
try {
|
|
243
|
-
await s.opts.beforeEach.call(s);
|
|
244
|
-
} catch (e) {
|
|
245
|
-
}
|
|
246
|
-
let n = s.fn(), t = W(n);
|
|
247
|
-
if (t)
|
|
248
|
-
try {
|
|
249
|
-
await n;
|
|
250
|
-
} catch (e) {
|
|
251
|
-
}
|
|
252
|
-
if (s.opts.afterEach != null)
|
|
253
|
-
try {
|
|
254
|
-
await s.opts.afterEach.call(s);
|
|
255
|
-
} catch (e) {
|
|
256
|
-
}
|
|
257
|
-
return t;
|
|
258
|
-
} catch (n) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
var b = class extends EventTarget {
|
|
263
|
-
constructor(t, e, r, i = {}) {
|
|
264
|
-
super();
|
|
265
|
-
this.runs = 0;
|
|
266
|
-
this.bench = t, this.name = e, this.fn = r, this.opts = i;
|
|
267
|
-
}
|
|
268
|
-
async loop(t, e) {
|
|
269
|
-
var T;
|
|
270
|
-
let r = this.bench.concurrency === "task", { threshold: i } = this.bench, c = 0, h = [];
|
|
271
|
-
if (this.opts.beforeAll != null)
|
|
272
|
-
try {
|
|
273
|
-
await this.opts.beforeAll.call(this);
|
|
274
|
-
} catch (u) {
|
|
275
|
-
return { error: u };
|
|
276
|
-
}
|
|
277
|
-
let p = await z(this), a = async () => {
|
|
278
|
-
this.opts.beforeEach != null && await this.opts.beforeEach.call(this);
|
|
279
|
-
let u = 0;
|
|
280
|
-
if (p) {
|
|
281
|
-
let v = this.bench.now();
|
|
282
|
-
await this.fn.call(this), u = this.bench.now() - v;
|
|
283
|
-
} else {
|
|
284
|
-
let v = this.bench.now();
|
|
285
|
-
this.fn.call(this), u = this.bench.now() - v;
|
|
286
|
-
}
|
|
287
|
-
h.push(u), c += u, this.opts.afterEach != null && await this.opts.afterEach.call(this);
|
|
288
|
-
}, l = y(i);
|
|
289
|
-
try {
|
|
290
|
-
let u = [];
|
|
291
|
-
for (; (c < t || h.length + l.activeCount + l.pendingCount < e) && !((T = this.bench.signal) != null && T.aborted); )
|
|
292
|
-
r ? u.push(l(a)) : await a();
|
|
293
|
-
u.length && await Promise.all(u);
|
|
294
|
-
} catch (u) {
|
|
295
|
-
return { error: u };
|
|
296
|
-
}
|
|
297
|
-
if (this.opts.afterAll != null)
|
|
298
|
-
try {
|
|
299
|
-
await this.opts.afterAll.call(this);
|
|
300
|
-
} catch (u) {
|
|
301
|
-
return { error: u };
|
|
302
|
-
}
|
|
303
|
-
return { samples: h };
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* run the current task and write the results in `Task.result` object
|
|
307
|
-
*/
|
|
308
|
-
async run() {
|
|
309
|
-
var r, i;
|
|
310
|
-
if ((r = this.result) != null && r.error)
|
|
311
|
-
return this;
|
|
312
|
-
this.dispatchEvent(o("start", this)), await this.bench.setup(this, "run");
|
|
313
|
-
let { samples: t, error: e } = await this.loop(this.bench.time, this.bench.iterations);
|
|
314
|
-
if (this.bench.teardown(this, "run"), t) {
|
|
315
|
-
let c = t.reduce((L, A) => L + A, 0);
|
|
316
|
-
this.runs = t.length, t.sort((L, A) => L - A);
|
|
317
|
-
let h = c / this.runs, p = 1e3 / h, a = t.length, l = a - 1, T = t[0], u = t[l], v = c / t.length || 0, P = S(t, v), R = Math.sqrt(P), I = R / Math.sqrt(a), _ = N[String(Math.round(l) || 1)] || N.infinity, K = I * _, j = K / v * 100, H = t[Math.ceil(a * 0.75) - 1], V = t[Math.ceil(a * 0.99) - 1], Q = t[Math.ceil(a * 0.995) - 1], Y = t[Math.ceil(a * 0.999) - 1];
|
|
318
|
-
if ((i = this.bench.signal) != null && i.aborted)
|
|
319
|
-
return this;
|
|
320
|
-
this.setResult({
|
|
321
|
-
totalTime: c,
|
|
322
|
-
min: T,
|
|
323
|
-
max: u,
|
|
324
|
-
hz: p,
|
|
325
|
-
period: h,
|
|
326
|
-
samples: t,
|
|
327
|
-
mean: v,
|
|
328
|
-
variance: P,
|
|
329
|
-
sd: R,
|
|
330
|
-
sem: I,
|
|
331
|
-
df: l,
|
|
332
|
-
critical: _,
|
|
333
|
-
moe: K,
|
|
334
|
-
rme: j,
|
|
335
|
-
p75: H,
|
|
336
|
-
p99: V,
|
|
337
|
-
p995: Q,
|
|
338
|
-
p999: Y
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
if (e) {
|
|
342
|
-
if (this.setResult({ error: e }), this.bench.throws)
|
|
343
|
-
throw e;
|
|
344
|
-
this.dispatchEvent(o("error", this)), this.bench.dispatchEvent(o("error", this));
|
|
345
|
-
}
|
|
346
|
-
return this.dispatchEvent(o("cycle", this)), this.bench.dispatchEvent(o("cycle", this)), this.dispatchEvent(o("complete", this)), this;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* warmup the current task
|
|
350
|
-
*/
|
|
351
|
-
async warmup() {
|
|
352
|
-
var e;
|
|
353
|
-
if ((e = this.result) != null && e.error)
|
|
354
|
-
return;
|
|
355
|
-
this.dispatchEvent(o("warmup", this)), await this.bench.setup(this, "warmup");
|
|
356
|
-
let { error: t } = await this.loop(this.bench.warmupTime, this.bench.warmupIterations);
|
|
357
|
-
if (this.bench.teardown(this, "warmup"), t && (this.setResult({ error: t }), this.bench.throws))
|
|
358
|
-
throw t;
|
|
359
|
-
}
|
|
360
|
-
addEventListener(t, e, r) {
|
|
361
|
-
super.addEventListener(t, e, r);
|
|
362
|
-
}
|
|
363
|
-
removeEventListener(t, e, r) {
|
|
364
|
-
super.removeEventListener(t, e, r);
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* change the result object values
|
|
368
|
-
*/
|
|
369
|
-
setResult(t) {
|
|
370
|
-
this.result = { ...this.result, ...t }, Object.freeze(this.result);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* reset the task to make the `Task.runs` a zero-value and remove the `Task.result`
|
|
374
|
-
* object
|
|
375
|
-
*/
|
|
376
|
-
reset() {
|
|
377
|
-
this.dispatchEvent(o("reset", this)), this.runs = 0, this.result = void 0;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
var x = class extends EventTarget {
|
|
381
|
-
constructor(t = {}) {
|
|
382
|
-
var e, r, i, c, h, p, a, l;
|
|
383
|
-
super();
|
|
384
|
-
this._tasks = /* @__PURE__ */ new Map();
|
|
385
|
-
this._todos = /* @__PURE__ */ new Map();
|
|
386
|
-
this.concurrency = null;
|
|
387
|
-
this.threshold = 1 / 0;
|
|
388
|
-
this.warmupTime = 100;
|
|
389
|
-
this.warmupIterations = 5;
|
|
390
|
-
this.time = 500;
|
|
391
|
-
this.iterations = 10;
|
|
392
|
-
this.now = B;
|
|
393
|
-
this.now = (e = t.now) != null ? e : this.now, this.warmupTime = (r = t.warmupTime) != null ? r : this.warmupTime, this.warmupIterations = (i = t.warmupIterations) != null ? i : this.warmupIterations, this.time = (c = t.time) != null ? c : this.time, this.iterations = (h = t.iterations) != null ? h : this.iterations, this.signal = t.signal, this.throws = (p = t.throws) != null ? p : false, this.setup = (a = t.setup) != null ? a : () => {
|
|
394
|
-
}, this.teardown = (l = t.teardown) != null ? l : () => {
|
|
395
|
-
}, this.signal && this.signal.addEventListener(
|
|
396
|
-
"abort",
|
|
397
|
-
() => {
|
|
398
|
-
this.dispatchEvent(o("abort"));
|
|
399
|
-
},
|
|
400
|
-
{ once: true }
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
runTask(t) {
|
|
404
|
-
var e;
|
|
405
|
-
return (e = this.signal) != null && e.aborted ? t : t.run();
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* run the added tasks that were registered using the
|
|
409
|
-
* {@link add} method.
|
|
410
|
-
* Note: This method does not do any warmup. Call {@link warmup} for that.
|
|
411
|
-
*/
|
|
412
|
-
async run() {
|
|
413
|
-
if (this.concurrency === "bench")
|
|
414
|
-
return this.runConcurrently(this.threshold, this.concurrency);
|
|
415
|
-
this.dispatchEvent(o("start"));
|
|
416
|
-
let t = [];
|
|
417
|
-
for (let e of [...this._tasks.values()])
|
|
418
|
-
t.push(await this.runTask(e));
|
|
419
|
-
return this.dispatchEvent(o("complete")), t;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* See Bench.{@link concurrency}
|
|
423
|
-
*/
|
|
424
|
-
async runConcurrently(t = 1 / 0, e = "bench") {
|
|
425
|
-
if (this.threshold = t, this.concurrency = e, e === "task")
|
|
426
|
-
return this.run();
|
|
427
|
-
this.dispatchEvent(o("start"));
|
|
428
|
-
let r = y(t), i = [];
|
|
429
|
-
for (let h of [...this._tasks.values()])
|
|
430
|
-
i.push(r(() => this.runTask(h)));
|
|
431
|
-
let c = await Promise.all(i);
|
|
432
|
-
return this.dispatchEvent(o("complete")), c;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* warmup the benchmark tasks.
|
|
436
|
-
* This is not run by default by the {@link run} method.
|
|
437
|
-
*/
|
|
438
|
-
async warmup() {
|
|
439
|
-
if (this.concurrency === "bench") {
|
|
440
|
-
await this.warmupConcurrently(this.threshold, this.concurrency);
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
this.dispatchEvent(o("warmup"));
|
|
444
|
-
for (let [, t] of this._tasks)
|
|
445
|
-
await t.warmup();
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* warmup the benchmark tasks concurrently.
|
|
449
|
-
* This is not run by default by the {@link runConcurrently} method.
|
|
450
|
-
*/
|
|
451
|
-
async warmupConcurrently(t = 1 / 0, e = "bench") {
|
|
452
|
-
if (this.threshold = t, this.concurrency = e, e === "task") {
|
|
453
|
-
await this.warmup();
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
this.dispatchEvent(o("warmup"));
|
|
457
|
-
let r = y(t), i = [];
|
|
458
|
-
for (let [, c] of this._tasks)
|
|
459
|
-
i.push(r(() => c.warmup()));
|
|
460
|
-
await Promise.all(i);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* reset each task and remove its result
|
|
464
|
-
*/
|
|
465
|
-
reset() {
|
|
466
|
-
this.dispatchEvent(o("reset")), this._tasks.forEach((t) => {
|
|
467
|
-
t.reset();
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* add a benchmark task to the task map
|
|
472
|
-
*/
|
|
473
|
-
add(t, e, r = {}) {
|
|
474
|
-
let i = new b(this, t, e, r);
|
|
475
|
-
return this._tasks.set(t, i), this.dispatchEvent(o("add", i)), this;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* add a benchmark todo to the todo map
|
|
479
|
-
*/
|
|
480
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
481
|
-
todo(t, e = () => {
|
|
482
|
-
}, r = {}) {
|
|
483
|
-
let i = new b(this, t, e, r);
|
|
484
|
-
return this._todos.set(t, i), this.dispatchEvent(o("todo", i)), this;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* remove a benchmark task from the task map
|
|
488
|
-
*/
|
|
489
|
-
remove(t) {
|
|
490
|
-
let e = this.getTask(t);
|
|
491
|
-
return e && (this.dispatchEvent(o("remove", e)), this._tasks.delete(t)), this;
|
|
492
|
-
}
|
|
493
|
-
addEventListener(t, e, r) {
|
|
494
|
-
super.addEventListener(t, e, r);
|
|
495
|
-
}
|
|
496
|
-
removeEventListener(t, e, r) {
|
|
497
|
-
super.removeEventListener(t, e, r);
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* table of the tasks results
|
|
501
|
-
*/
|
|
502
|
-
table(t) {
|
|
503
|
-
return this.tasks.map((e) => {
|
|
504
|
-
if (e.result) {
|
|
505
|
-
if (e.result.error)
|
|
506
|
-
throw e.result.error;
|
|
507
|
-
return (t == null ? void 0 : t(e)) || {
|
|
508
|
-
"Task Name": e.name,
|
|
509
|
-
"ops/sec": e.result.error ? "NaN" : parseInt(e.result.hz.toString(), 10).toLocaleString(),
|
|
510
|
-
"Average Time (ns)": e.result.error ? "NaN" : e.result.mean * 1e3 * 1e3,
|
|
511
|
-
Margin: e.result.error ? "NaN" : `\xB1${e.result.rme.toFixed(2)}%`,
|
|
512
|
-
Samples: e.result.error ? "NaN" : e.result.samples.length
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
return null;
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* (getter) tasks results as an array
|
|
520
|
-
*/
|
|
521
|
-
get results() {
|
|
522
|
-
return [...this._tasks.values()].map((t) => t.result);
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* (getter) tasks as an array
|
|
526
|
-
*/
|
|
527
|
-
get tasks() {
|
|
528
|
-
return [...this._tasks.values()];
|
|
529
|
-
}
|
|
530
|
-
get todos() {
|
|
531
|
-
return [...this._todos.values()];
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* get a task based on the task name
|
|
535
|
-
*/
|
|
536
|
-
getTask(t) {
|
|
537
|
-
return this._tasks.get(t);
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
export {
|
|
541
|
-
x as Bench,
|
|
542
|
-
b as Task,
|
|
543
|
-
U as hrtimeNow,
|
|
544
|
-
B as now
|
|
545
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import"./chunk-HRE7YPUJ.min.mjs";var O=44,N=59,x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E=new Uint8Array(64),A=new Uint8Array(128);for(let l=0;l<x.length;l++){let t=x.charCodeAt(l);E[l]=t,A[t]=l}function d(l,t,e){let n=t-e;n=n<0?-n<<1|1:n<<1;do{let i=n&31;n>>>=5,n>0&&(i|=32),l.write(E[i])}while(n>0);return t}var v=1024*16,y=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(l){return Buffer.from(l.buffer,l.byteOffset,l.byteLength).toString()}}:{decode(l){let t="";for(let e=0;e<l.length;e++)t+=String.fromCharCode(l[e]);return t}},j=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(v)}write(l){let{buffer:t}=this;t[this.pos++]=l,this.pos===v&&(this.out+=y.decode(t),this.pos=0)}flush(){let{buffer:l,out:t,pos:e}=this;return e>0?t+y.decode(l.subarray(0,e)):t}};function L(l){let t=new j,e=0,n=0,i=0,r=0;for(let s=0;s<l.length;s++){let h=l[s];if(s>0&&t.write(N),h.length===0)continue;let o=0;for(let u=0;u<h.length;u++){let a=h[u];u>0&&t.write(O),o=d(t,a[0],o),a.length!==1&&(e=d(t,a[1],e),n=d(t,a[2],n),i=d(t,a[3],i),a.length!==4&&(r=d(t,a[4],r)))}}return t.flush()}var p=class l{constructor(t){this.bits=t instanceof l?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}},m=class l{constructor(t,e,n){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}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){let t=new l(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let e=this;for(;e;)t(e),e=e.next}eachPrevious(t){let e=this;for(;e;)t(e),e=e.previous}edit(t,e,n){return this.content=t,n||(this.intro="",this.outro=""),this.storeName=e,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){let e=t-this.start,n=this.original.slice(0,e),i=this.original.slice(e);this.original=n;let r=new l(t,this.end,i);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}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let e=this.content.replace(t,"");if(e.length)return e!==this.content&&(this.split(this.start+e.length).edit("",void 0,!0),this.edited&&this.edit(e,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),this.intro.length)return!0}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let e=this.content.replace(t,"");if(e.length){if(e!==this.content){let n=this.split(this.end-e.length);this.edited&&n.edit(e,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),this.outro.length)return!0}};function $(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?l=>globalThis.btoa(unescape(encodeURIComponent(l))):typeof Buffer=="function"?l=>Buffer.from(l,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}var q=$(),w=class{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=L(t.mappings),typeof t.x_google_ignoreList<"u"&&(this.x_google_ignoreList=t.x_google_ignoreList),typeof t.debugId<"u"&&(this.debugId=t.debugId)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+q(this.toString())}};function T(l){let t=l.split(`
|
|
2
|
-
`),e=t.filter(r=>/^\t+/.test(r)),n=t.filter(r=>/^ {2,}/.test(r));if(e.length===0&&n.length===0)return null;if(e.length>=n.length)return" ";let i=n.reduce((r,s)=>{let h=/^ +/.exec(s)[0].length;return Math.min(h,r)},1/0);return new Array(i+1).join(" ")}function I(l,t){let e=l.split(/[/\\]/),n=t.split(/[/\\]/);for(e.pop();e[0]===n[0];)e.shift(),n.shift();if(e.length){let i=e.length;for(;i--;)e[i]=".."}return e.concat(n).join("/")}var B=Object.prototype.toString;function _(l){return B.call(l)==="[object Object]"}function S(l){let t=l.split(`
|
|
3
|
-
`),e=[];for(let n=0,i=0;n<t.length;n++)e.push(i),i+=t[n].length+1;return function(i){let r=0,s=e.length;for(;r<s;){let u=r+s>>1;i<e[u]?s=u:r=u+1}let h=r-1,o=i-e[h];return{line:h,column:o}}}var U=/\w/,b=class{constructor(t){this.hires=t,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(t,e,n,i){if(e.length){let r=e.length-1,s=e.indexOf(`
|
|
4
|
-
`,0),h=-1;for(;s>=0&&r>s;){let u=[this.generatedCodeColumn,t,n.line,n.column];i>=0&&u.push(i),this.rawSegments.push(u),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,h=s,s=e.indexOf(`
|
|
5
|
-
`,s+1)}let o=[this.generatedCodeColumn,t,n.line,n.column];i>=0&&o.push(i),this.rawSegments.push(o),this.advance(e.slice(h+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(e));this.pending=null}addUneditedChunk(t,e,n,i,r){let s=e.start,h=!0,o=!1;for(;s<e.end;){if(n[s]===`
|
|
6
|
-
`)i.line+=1,i.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,h=!0,o=!1;else{if(this.hires||h||r.has(s)){let u=[this.generatedCodeColumn,t,i.line,i.column];this.hires==="boundary"?U.test(n[s])?o||(this.rawSegments.push(u),o=!0):(this.rawSegments.push(u),o=!1):this.rawSegments.push(u)}i.column+=1,this.generatedCodeColumn+=1,h=!1}s+=1}this.pending=null}advance(t){if(!t)return;let e=t.split(`
|
|
7
|
-
`);if(e.length>1){for(let n=0;n<e.length-1;n++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=e[e.length-1].length}},g=`
|
|
8
|
-
`,c={insertLeft:!1,insertRight:!1,storeName:!1},C=class l{constructor(t,e={}){let n=new m(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:n},lastChunk:{writable:!0,value:n},lastSearchedChunk:{writable:!0,value:n},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:e.filename},indentExclusionRanges:{writable:!0,value:e.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new p},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:e.ignoreList},offset:{writable:!0,value:e.offset||0}}),this.byStart[0]=n,this.byEnd[t.length]=n}addSourcemapLocation(t){this.sourcemapLocations.add(t)}append(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.outro+=t,this}appendLeft(t,e){if(t=t+this.offset,typeof e!="string")throw new TypeError("inserted content must be a string");this._split(t);let n=this.byEnd[t];return n?n.appendLeft(e):this.intro+=e,this}appendRight(t,e){if(t=t+this.offset,typeof e!="string")throw new TypeError("inserted content must be a string");this._split(t);let n=this.byStart[t];return n?n.appendRight(e):this.outro+=e,this}clone(){let t=new l(this.original,{filename:this.filename,offset:this.offset}),e=this.firstChunk,n=t.firstChunk=t.lastSearchedChunk=e.clone();for(;e;){t.byStart[n.start]=n,t.byEnd[n.end]=n;let i=e.next,r=i&&i.clone();r&&(n.next=r,r.previous=n,n=r),e=i}return t.lastChunk=n,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new p(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};let e=0,n=Object.keys(this.storedNames),i=new b(t.hires),r=S(this.original);return this.intro&&i.advance(this.intro),this.firstChunk.eachNext(s=>{let h=r(s.start);s.intro.length&&i.advance(s.intro),s.edited?i.addEdit(e,s.content,h,s.storeName?n.indexOf(s.original):-1):i.addUneditedChunk(e,s,this.original,h,this.sourcemapLocations),s.outro.length&&i.advance(s.outro)}),this.outro&&i.advance(this.outro),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?I(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:n,mappings:i.raw,x_google_ignoreList:this.ignoreList?[e]:void 0}}generateMap(t){return new w(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=T(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(t,e){let n=/^[^\r\n]/gm;if(_(t)&&(e=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;e=e||{};let i={};e.exclude&&(typeof e.exclude[0]=="number"?[e.exclude]:e.exclude).forEach(a=>{for(let f=a[0];f<a[1];f+=1)i[f]=!0});let r=e.indentStart!==!1,s=u=>r?`${t}${u}`:(r=!0,u);this.intro=this.intro.replace(n,s);let h=0,o=this.firstChunk;for(;o;){let u=o.end;if(o.edited)i[h]||(o.content=o.content.replace(n,s),o.content.length&&(r=o.content[o.content.length-1]===`
|
|
9
|
-
`));else for(h=o.start;h<u;){if(!i[h]){let a=this.original[h];a===`
|
|
10
|
-
`?r=!0:a!=="\r"&&r&&(r=!1,h===o.start||(this._splitChunk(o,h),o=o.next),o.prependRight(t))}h+=1}h=o.end,o=o.next}return this.outro=this.outro.replace(n,s),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,e){return c.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),c.insertLeft=!0),this.appendLeft(t,e)}insertRight(t,e){return c.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),c.insertRight=!0),this.prependRight(t,e)}move(t,e,n){if(t=t+this.offset,e=e+this.offset,n=n+this.offset,n>=t&&n<=e)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(e),this._split(n);let i=this.byStart[t],r=this.byEnd[e],s=i.previous,h=r.next,o=this.byStart[n];if(!o&&r===this.lastChunk)return this;let u=o?o.previous:this.lastChunk;return s&&(s.next=h),h&&(h.previous=s),u&&(u.next=i),o&&(o.previous=r),i.previous||(this.firstChunk=r.next),r.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=u,r.next=o||null,u||(this.firstChunk=i),o||(this.lastChunk=r),this}overwrite(t,e,n,i){return i=i||{},this.update(t,e,n,{...i,overwrite:!i.contentOnly})}update(t,e,n,i){if(t=t+this.offset,e=e+this.offset,typeof n!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(e>this.original.length)throw new Error("end is out of bounds");if(t===e)throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");this._split(t),this._split(e),i===!0&&(c.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),c.storeName=!0),i={storeName:!0});let r=i!==void 0?i.storeName:!1,s=i!==void 0?i.overwrite:!1;if(r){let u=this.original.slice(t,e);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}let h=this.byStart[t],o=this.byEnd[e];if(h){let u=h;for(;u!==o;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}h.edit(n,r,!s)}else{let u=new m(t,e,"").edit(n,r);o.next=u,u.previous=o}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,e){if(t=t+this.offset,typeof e!="string")throw new TypeError("inserted content must be a string");this._split(t);let n=this.byEnd[t];return n?n.prependLeft(e):this.intro=e+this.intro,this}prependRight(t,e){if(t=t+this.offset,typeof e!="string")throw new TypeError("inserted content must be a string");this._split(t);let n=this.byStart[t];return n?n.prependRight(e):this.outro=e+this.outro,this}remove(t,e){if(t=t+this.offset,e=e+this.offset,this.original.length!==0){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(t===e)return this;if(t<0||e>this.original.length)throw new Error("Character is out of bounds");if(t>e)throw new Error("end must be greater than start");this._split(t),this._split(e);let n=this.byStart[t];for(;n;)n.intro="",n.outro="",n.edit(""),n=e>n.end?this.byStart[n.end]:null;return this}reset(t,e){if(t=t+this.offset,e=e+this.offset,this.original.length!==0){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(t===e)return this;if(t<0||e>this.original.length)throw new Error("Character is out of bounds");if(t>e)throw new Error("end must be greater than start");this._split(t),this._split(e);let n=this.byStart[t];for(;n;)n.reset(),n=e>n.end?this.byStart[n.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let t=this.lastChunk;do{if(t.outro.length)return t.outro[t.outro.length-1];if(t.content.length)return t.content[t.content.length-1];if(t.intro.length)return t.intro[t.intro.length-1]}while(t=t.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let t=this.outro.lastIndexOf(g);if(t!==-1)return this.outro.substr(t+1);let e=this.outro,n=this.lastChunk;do{if(n.outro.length>0){if(t=n.outro.lastIndexOf(g),t!==-1)return n.outro.substr(t+1)+e;e=n.outro+e}if(n.content.length>0){if(t=n.content.lastIndexOf(g),t!==-1)return n.content.substr(t+1)+e;e=n.content+e}if(n.intro.length>0){if(t=n.intro.lastIndexOf(g),t!==-1)return n.intro.substr(t+1)+e;e=n.intro+e}}while(n=n.previous);return t=this.intro.lastIndexOf(g),t!==-1?this.intro.substr(t+1)+e:this.intro+e}slice(t=0,e=this.original.length-this.offset){if(t=t+this.offset,e=e+this.offset,this.original.length!==0){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}let n="",i=this.firstChunk;for(;i&&(i.start>t||i.end<=t);){if(i.start<e&&i.end>=e)return n;i=i.next}if(i&&i.edited&&i.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);let r=i;for(;i;){i.intro&&(r!==i||i.start===t)&&(n+=i.intro);let s=i.start<e&&i.end>=e;if(s&&i.edited&&i.end!==e)throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);let h=r===i?t-i.start:0,o=s?i.content.length+e-i.end:i.content.length;if(n+=i.content.slice(h,o),i.outro&&(!s||i.end===e)&&(n+=i.outro),s)break;i=i.next}return n}snip(t,e){let n=this.clone();return n.remove(0,t),n.remove(e,n.original.length),n}_split(t){if(this.byStart[t]||this.byEnd[t])return;let e=this.lastSearchedChunk,n=e,i=t>e.end;for(;e;){if(e.contains(t))return this._splitChunk(e,t);if(e=i?this.byStart[e.end]:this.byEnd[e.start],e===n)return;n=e}}_splitChunk(t,e){if(t.edited&&t.content.length){let i=S(this.original)(e);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} \u2013 "${t.original}")`)}let n=t.split(e);return this.byEnd[e]=t,this.byStart[e]=n,this.byEnd[n.end]=n,t===this.lastChunk&&(this.lastChunk=n),this.lastSearchedChunk=t,!0}toString(){let t=this.intro,e=this.firstChunk;for(;e;)t+=e.toString(),e=e.next;return t+this.outro}isEmpty(){let t=this.firstChunk;do if(t.intro.length&&t.intro.trim()||t.content.length&&t.content.trim()||t.outro.length&&t.outro.trim())return!1;while(t=t.next);return!0}length(){let t=this.firstChunk,e=0;do e+=t.intro.length+t.content.length+t.outro.length;while(t=t.next);return e}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimEndAborted(t){let e=new RegExp((t||"\\s")+"+$");if(this.outro=this.outro.replace(e,""),this.outro.length)return!0;let n=this.lastChunk;do{let i=n.end,r=n.trimEnd(e);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)return!0;n=n.previous}while(n);return!1}trimEnd(t){return this.trimEndAborted(t),this}trimStartAborted(t){let e=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(e,""),this.intro.length)return!0;let n=this.firstChunk;do{let i=n.end,r=n.trimStart(e);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)return!0;n=n.next}while(n);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,e){function n(r,s){return typeof e=="string"?e.replace(/\$(\$|&|\d+)/g,(h,o)=>o==="$"?"$":o==="&"?r[0]:+o<r.length?r[+o]:`$${o}`):e(...r,r.index,s,r.groups)}function i(r,s){let h,o=[];for(;h=r.exec(s);)o.push(h);return o}if(t.global)i(t,this.original).forEach(s=>{if(s.index!=null){let h=n(s,this.original);h!==s[0]&&this.overwrite(s.index,s.index+s[0].length,h)}});else{let r=this.original.match(t);if(r&&r.index!=null){let s=n(r,this.original);s!==r[0]&&this.overwrite(r.index,r.index+r[0].length,s)}}return this}_replaceString(t,e){let{original:n}=this,i=n.indexOf(t);return i!==-1&&(typeof e=="function"&&(e=e(t,i,n)),t!==e&&this.overwrite(i,i+t.length,e)),this}replace(t,e){return typeof t=="string"?this._replaceString(t,e):this._replaceRegexp(t,e)}_replaceAllString(t,e){let{original:n}=this,i=t.length;for(let r=n.indexOf(t);r!==-1;r=n.indexOf(t,r+i)){let s=n.slice(r,r+i),h=e;typeof e=="function"&&(h=e(s,r,n)),s!==h&&this.overwrite(r,r+i,h)}return this}replaceAll(t,e){if(typeof t=="string")return this._replaceAllString(t,e);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(t,e)}},k=Object.prototype.hasOwnProperty,R=class l{constructor(t={}){this.intro=t.intro||"",this.separator=t.separator!==void 0?t.separator:`
|
|
11
|
-
`,this.sources=[],this.uniqueSources=[],this.uniqueSourceIndexByFilename={}}addSource(t){if(t instanceof C)return this.addSource({content:t,filename:t.filename,separator:this.separator});if(!_(t)||!t.content)throw new Error("bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`");if(["filename","ignoreList","indentExclusionRanges","separator"].forEach(e=>{k.call(t,e)||(t[e]=t.content[e])}),t.separator===void 0&&(t.separator=this.separator),t.filename)if(!k.call(this.uniqueSourceIndexByFilename,t.filename))this.uniqueSourceIndexByFilename[t.filename]=this.uniqueSources.length,this.uniqueSources.push({filename:t.filename,content:t.content.original});else{let e=this.uniqueSources[this.uniqueSourceIndexByFilename[t.filename]];if(t.content.original!==e.content)throw new Error(`Illegal source: same filename (${t.filename}), different contents`)}return this.sources.push(t),this}append(t,e){return this.addSource({content:new C(t),separator:e&&e.separator||""}),this}clone(){let t=new l({intro:this.intro,separator:this.separator});return this.sources.forEach(e=>{t.addSource({filename:e.filename,content:e.content.clone(),separator:e.separator})}),t}generateDecodedMap(t={}){let e=[],n;this.sources.forEach(r=>{Object.keys(r.content.storedNames).forEach(s=>{~e.indexOf(s)||e.push(s)})});let i=new b(t.hires);return this.intro&&i.advance(this.intro),this.sources.forEach((r,s)=>{s>0&&i.advance(this.separator);let h=r.filename?this.uniqueSourceIndexByFilename[r.filename]:-1,o=r.content,u=S(o.original);o.intro&&i.advance(o.intro),o.firstChunk.eachNext(a=>{let f=u(a.start);a.intro.length&&i.advance(a.intro),r.filename?a.edited?i.addEdit(h,a.content,f,a.storeName?e.indexOf(a.original):-1):i.addUneditedChunk(h,a,o.original,f,o.sourcemapLocations):i.advance(a.content),a.outro.length&&i.advance(a.outro)}),o.outro&&i.advance(o.outro),r.ignoreList&&h!==-1&&(n===void 0&&(n=[]),n.push(h))}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:this.uniqueSources.map(r=>t.file?I(t.file,r.filename):r.filename),sourcesContent:this.uniqueSources.map(r=>t.includeContent?r.content:null),names:e,mappings:i.raw,x_google_ignoreList:n}}generateMap(t){return new w(this.generateDecodedMap(t))}getIndentString(){let t={};return this.sources.forEach(e=>{let n=e.content._getRawIndentString();n!==null&&(t[n]||(t[n]=0),t[n]+=1)}),Object.keys(t).sort((e,n)=>t[e]-t[n])[0]||" "}indent(t){if(arguments.length||(t=this.getIndentString()),t==="")return this;let e=!this.intro||this.intro.slice(-1)===`
|
|
12
|
-
`;return this.sources.forEach((n,i)=>{let r=n.separator!==void 0?n.separator:this.separator,s=e||i>0&&/\r?\n$/.test(r);n.content.indent(t,{exclude:n.indentExclusionRanges,indentStart:s}),e=n.content.lastChar()===`
|
|
13
|
-
`}),this.intro&&(this.intro=t+this.intro.replace(/^[^\n]/gm,(n,i)=>i>0?t+n:n)),this}prepend(t){return this.intro=t+this.intro,this}toString(){let t=this.sources.map((e,n)=>{let i=e.separator!==void 0?e.separator:this.separator;return(n>0?i:"")+e.content.toString()}).join("");return this.intro+t}isEmpty(){return!(this.intro.length&&this.intro.trim()||this.sources.some(t=>!t.content.isEmpty()))}length(){return this.sources.reduce((t,e)=>t+e.content.length(),this.intro.length)}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimStart(t){let e=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(e,""),!this.intro){let n,i=0;do if(n=this.sources[i++],!n)break;while(!n.content.trimStartAborted(t))}return this}trimEnd(t){let e=new RegExp((t||"\\s")+"+$"),n,i=this.sources.length-1;do if(n=this.sources[i--],!n){this.intro=this.intro.replace(e,"");break}while(!n.content.trimEndAborted(t));return this}};export{R as Bundle,w as SourceMap,C as default};
|
|
14
|
-
//# sourceMappingURL=magic-string.es-5QZEPJXJ.min.mjs.map
|