@synnaxlabs/freighter 0.52.3 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/freighter.cjs +4 -4
- package/dist/freighter.js +428 -332
- package/package.json +3 -3
package/dist/freighter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Y, { z as s } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const Xe = (r) => {
|
|
3
3
|
const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
4
4
|
return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
|
|
5
5
|
}, Ee = (r) => {
|
|
@@ -10,16 +10,16 @@ const Ke = (r) => {
|
|
|
10
10
|
n = tt(n);
|
|
11
11
|
const i = {}, o = t;
|
|
12
12
|
return "toJSON" in o && typeof o.toJSON == "function" ? e(o.toJSON(), n) : (Object.keys(o).forEach((c) => {
|
|
13
|
-
let
|
|
13
|
+
let f = o[c];
|
|
14
14
|
const w = r(c);
|
|
15
|
-
n.recursive && (te(
|
|
15
|
+
n.recursive && (te(f) ? we(f) || (f = e(f, n)) : n.recursiveInArray && pe(f) && (f = [...f].map((h) => {
|
|
16
16
|
let g = h;
|
|
17
17
|
return te(h) ? we(g) || (g = e(h, n)) : pe(h) && (g = e({ key: h }, n).key), g;
|
|
18
|
-
}))), i[w] =
|
|
18
|
+
}))), i[w] = f;
|
|
19
19
|
}), i);
|
|
20
20
|
};
|
|
21
21
|
return e;
|
|
22
|
-
}, xe = Ee(
|
|
22
|
+
}, xe = Ee(Xe), Qe = (r) => (
|
|
23
23
|
// Don't convert the first character and don't convert a character that is after a
|
|
24
24
|
// non-alphanumeric character
|
|
25
25
|
r.replace(
|
|
@@ -100,13 +100,13 @@ const nt = (r) => r != null && typeof r == "object" && "toString" in r, st = (r,
|
|
|
100
100
|
}
|
|
101
101
|
return e ? it(n) : n;
|
|
102
102
|
}, it = (r) => (e, t) => r(t, e);
|
|
103
|
-
let
|
|
103
|
+
let Me = (r, e = 21) => (t = e) => {
|
|
104
104
|
let n = "", i = t | 0;
|
|
105
105
|
for (; i--; )
|
|
106
106
|
n += r[Math.random() * r.length | 0];
|
|
107
107
|
return n;
|
|
108
108
|
};
|
|
109
|
-
const
|
|
109
|
+
const Ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", at = `0123456789${Ue}`, ot = 11, ut = Me(Ue, 1), lt = Me(at, ot - 1), ct = () => `${ut()}${lt()}`, ht = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, dt = 2 ** 12 - 1, ae = 2n ** 63n - 1n, ft = 2 ** 63 - 1, _ = (r) => (e, t) => {
|
|
110
110
|
if (typeof e == "bigint") {
|
|
111
111
|
if (gt(t))
|
|
112
112
|
return r(e, BigInt(t));
|
|
@@ -114,19 +114,19 @@ const Ae = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", at = `0123456
|
|
|
114
114
|
return typeof n == "number" ? BigInt(Math.round(n)) : n;
|
|
115
115
|
}
|
|
116
116
|
return r(Number(e), Number(t));
|
|
117
|
-
},
|
|
117
|
+
}, H = _((r, e) => r - e), L = _((r, e) => r + e), gt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), U = _((r, e) => r * e), ee = _((r, e) => r / e), Ae = s.tuple([s.number(), s.number()]), Ce = s.object({ width: s.number(), height: s.number() }), mt = s.object({
|
|
118
118
|
signedWidth: s.number(),
|
|
119
119
|
signedHeight: s.number()
|
|
120
|
-
}), yt = ["start", "center", "end"],
|
|
121
|
-
s.enum(
|
|
122
|
-
const bt = ["left", "right"],
|
|
120
|
+
}), yt = ["start", "center", "end"], V = s.object({ x: s.number(), y: s.number() }), pt = s.object({ clientX: s.number(), clientY: s.number() }), wt = ["x", "y"], Be = s.enum(wt), De = ["top", "right", "bottom", "left"];
|
|
121
|
+
s.enum(De);
|
|
122
|
+
const bt = ["left", "right"], Re = s.enum(bt), Ot = ["top", "bottom"], $e = s.enum(Ot), Le = ["center"], be = s.enum(Le), Tt = [...De, ...Le], Pe = s.enum(Tt);
|
|
123
123
|
s.enum(yt);
|
|
124
124
|
const vt = ["first", "last"];
|
|
125
125
|
s.enum(vt);
|
|
126
126
|
s.object({ lower: s.number(), upper: s.number() });
|
|
127
|
-
s.enum([...Be.options, ...
|
|
128
|
-
s.union([Be,
|
|
129
|
-
const
|
|
127
|
+
s.enum([...Be.options, ...Pe.options]);
|
|
128
|
+
s.union([Be, Pe, s.instanceof(String)]);
|
|
129
|
+
const P = (r, e, t) => {
|
|
130
130
|
const n = {};
|
|
131
131
|
if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
|
|
132
132
|
e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
|
|
@@ -136,18 +136,18 @@ const k = (r, e, t) => {
|
|
|
136
136
|
} else
|
|
137
137
|
n.lower = r.lower, n.upper = r.upper;
|
|
138
138
|
return t?.makeValid ? St(n) : n;
|
|
139
|
-
}, St = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r,
|
|
140
|
-
const t =
|
|
139
|
+
}, St = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, Oe = (r, e) => {
|
|
140
|
+
const t = P(r);
|
|
141
141
|
return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
|
|
142
142
|
};
|
|
143
143
|
s.object({
|
|
144
|
-
x:
|
|
144
|
+
x: Re.or(be),
|
|
145
145
|
y: $e.or(be)
|
|
146
146
|
});
|
|
147
|
-
const
|
|
147
|
+
const ke = s.object({ x: Re, y: $e }), It = Object.freeze({ x: "left", y: "top" }), Nt = (r, e) => r.x === e.x && r.y === e.y, Te = s.union([
|
|
148
148
|
s.number(),
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
V,
|
|
150
|
+
Ae,
|
|
151
151
|
Ce,
|
|
152
152
|
mt,
|
|
153
153
|
pt
|
|
@@ -157,12 +157,12 @@ const Pe = s.object({ x: De, y: $e }), It = Object.freeze({ x: "left", y: "top"
|
|
|
157
157
|
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
158
158
|
}
|
|
159
159
|
return typeof r == "number" ? { x: r, y: e ?? r } : Array.isArray(r) ? { x: r[0], y: r[1] } : "signedWidth" in r ? { x: r.signedWidth, y: r.signedHeight } : "clientX" in r ? { x: r.clientX, y: r.clientY } : "width" in r ? { x: r.width, y: r.height } : { x: r.x, y: r.y };
|
|
160
|
-
}, ve = Object.freeze({ x: 0, y: 0 }),
|
|
160
|
+
}, ve = Object.freeze({ x: 0, y: 0 }), K = s.union([s.number(), s.string()]);
|
|
161
161
|
s.object({
|
|
162
|
-
top:
|
|
163
|
-
left:
|
|
164
|
-
width:
|
|
165
|
-
height:
|
|
162
|
+
top: K,
|
|
163
|
+
left: K,
|
|
164
|
+
width: K,
|
|
165
|
+
height: K
|
|
166
166
|
});
|
|
167
167
|
s.object({
|
|
168
168
|
left: s.number(),
|
|
@@ -171,9 +171,9 @@ s.object({
|
|
|
171
171
|
bottom: s.number()
|
|
172
172
|
});
|
|
173
173
|
s.object({
|
|
174
|
-
one:
|
|
175
|
-
two:
|
|
176
|
-
root:
|
|
174
|
+
one: V,
|
|
175
|
+
two: V,
|
|
176
|
+
root: ke
|
|
177
177
|
});
|
|
178
178
|
const he = (r, e, t = 0, n = 0, i) => {
|
|
179
179
|
const o = {
|
|
@@ -199,12 +199,12 @@ const he = (r, e, t = 0, n = 0, i) => {
|
|
|
199
199
|
}, ne = (r) => {
|
|
200
200
|
const e = he(r);
|
|
201
201
|
return { lower: e.one.y, upper: e.two.y };
|
|
202
|
-
}, xt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r,
|
|
203
|
-
s.union([Ce,
|
|
204
|
-
const
|
|
205
|
-
s.object({ offset:
|
|
202
|
+
}, xt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, Mt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
|
|
203
|
+
s.union([Ce, Mt, V, Ae]);
|
|
204
|
+
const Ut = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
205
|
+
s.object({ offset: Te, scale: Te });
|
|
206
206
|
s.object({ offset: s.number(), scale: s.number() });
|
|
207
|
-
const
|
|
207
|
+
const At = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
|
|
208
208
|
e,
|
|
209
209
|
i ? n - r : n + r
|
|
210
210
|
], Ct = (r) => (e, t, n, i) => [
|
|
@@ -212,20 +212,20 @@ const Mt = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
|
|
|
212
212
|
i ? n / r : n * r
|
|
213
213
|
], Bt = (r) => (e, t, n) => {
|
|
214
214
|
if (e === null) return [r, n];
|
|
215
|
-
const { lower: i, upper: o } = e, { lower: c, upper:
|
|
215
|
+
const { lower: i, upper: o } = e, { lower: c, upper: f } = r, w = o - i, h = f - c;
|
|
216
216
|
if (t === "dimension") return [r, n * (h / w)];
|
|
217
217
|
const g = (n - i) * (h / w) + c;
|
|
218
218
|
return [r, g];
|
|
219
|
-
},
|
|
219
|
+
}, Dt = (r) => (e, t, n) => [r, n], Rt = () => (r, e, t) => {
|
|
220
220
|
if (r === null) throw new Error("cannot invert without bounds");
|
|
221
221
|
if (e === "dimension") return [r, t];
|
|
222
222
|
const { lower: n, upper: i } = r;
|
|
223
223
|
return [r, i - (t - n)];
|
|
224
224
|
}, $t = (r) => (e, t, n) => {
|
|
225
225
|
const { lower: i, upper: o } = r;
|
|
226
|
-
return n =
|
|
226
|
+
return n = Ut(n, i, o), [e, n];
|
|
227
227
|
};
|
|
228
|
-
class
|
|
228
|
+
class D {
|
|
229
229
|
ops = [];
|
|
230
230
|
currBounds = null;
|
|
231
231
|
currType = null;
|
|
@@ -239,7 +239,7 @@ class R {
|
|
|
239
239
|
* @param value - The amount to translate by.
|
|
240
240
|
*/
|
|
241
241
|
static translate(e) {
|
|
242
|
-
return new
|
|
242
|
+
return new D().translate(e);
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
@@ -247,10 +247,10 @@ class R {
|
|
|
247
247
|
* @param value - The amount to translate by.
|
|
248
248
|
*/
|
|
249
249
|
static magnify(e) {
|
|
250
|
-
return new
|
|
250
|
+
return new D().magnify(e);
|
|
251
251
|
}
|
|
252
252
|
static scale(e, t) {
|
|
253
|
-
return new
|
|
253
|
+
return new D().scale(e, t);
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
256
|
* @returns a copy of the scale with a translation as its next operation. Any
|
|
@@ -259,7 +259,7 @@ class R {
|
|
|
259
259
|
* @param value - The amount to translate by.
|
|
260
260
|
*/
|
|
261
261
|
translate(e) {
|
|
262
|
-
const t = this.new(), n =
|
|
262
|
+
const t = this.new(), n = At(e);
|
|
263
263
|
return n.type = "translate", t.ops.push(n), t;
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
@@ -273,19 +273,19 @@ class R {
|
|
|
273
273
|
return n.type = "magnify", t.ops.push(n), t;
|
|
274
274
|
}
|
|
275
275
|
scale(e, t) {
|
|
276
|
-
const n =
|
|
276
|
+
const n = P(e, t), i = this.new(), o = Bt(n);
|
|
277
277
|
return o.type = "scale", i.ops.push(o), i;
|
|
278
278
|
}
|
|
279
279
|
clamp(e, t) {
|
|
280
|
-
const n =
|
|
280
|
+
const n = P(e, t), i = this.new(), o = $t(n);
|
|
281
281
|
return o.type = "clamp", i.ops.push(o), i;
|
|
282
282
|
}
|
|
283
283
|
reBound(e, t) {
|
|
284
|
-
const n =
|
|
284
|
+
const n = P(e, t), i = this.new(), o = Dt(n);
|
|
285
285
|
return o.type = "re-bound", i.ops.push(o), i;
|
|
286
286
|
}
|
|
287
287
|
invert() {
|
|
288
|
-
const e =
|
|
288
|
+
const e = Rt();
|
|
289
289
|
e.type = "invert";
|
|
290
290
|
const t = this.new();
|
|
291
291
|
return t.ops.push(e), t;
|
|
@@ -297,7 +297,7 @@ class R {
|
|
|
297
297
|
return this.exec("dimension", e);
|
|
298
298
|
}
|
|
299
299
|
new() {
|
|
300
|
-
const e = new
|
|
300
|
+
const e = new D();
|
|
301
301
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
302
302
|
}
|
|
303
303
|
exec(e, t) {
|
|
@@ -311,9 +311,9 @@ class R {
|
|
|
311
311
|
e.ops.reverse();
|
|
312
312
|
const t = [];
|
|
313
313
|
return e.ops.forEach((n, i) => {
|
|
314
|
-
if (n.type === "scale" || t.some(([c,
|
|
314
|
+
if (n.type === "scale" || t.some(([c, f]) => i >= c && i <= f))
|
|
315
315
|
return;
|
|
316
|
-
const o = e.ops.findIndex((c,
|
|
316
|
+
const o = e.ops.findIndex((c, f) => c.type === "scale" && f > i);
|
|
317
317
|
o !== -1 && t.push([i, o]);
|
|
318
318
|
}), t.forEach(([n, i]) => {
|
|
319
319
|
const o = e.ops.slice(n, i);
|
|
@@ -323,35 +323,35 @@ class R {
|
|
|
323
323
|
get transform() {
|
|
324
324
|
return { scale: this.dim(1), offset: this.pos(0) };
|
|
325
325
|
}
|
|
326
|
-
static IDENTITY = new
|
|
326
|
+
static IDENTITY = new D();
|
|
327
327
|
}
|
|
328
|
-
class
|
|
328
|
+
class M {
|
|
329
329
|
x;
|
|
330
330
|
y;
|
|
331
331
|
currRoot;
|
|
332
|
-
constructor(e = new
|
|
332
|
+
constructor(e = new D(), t = new D(), n = null) {
|
|
333
333
|
this.x = e, this.y = t, this.currRoot = n;
|
|
334
334
|
}
|
|
335
335
|
static translate(e, t) {
|
|
336
|
-
return new
|
|
336
|
+
return new M().translate(e, t);
|
|
337
337
|
}
|
|
338
338
|
static translateX(e) {
|
|
339
|
-
return new
|
|
339
|
+
return new M().translateX(e);
|
|
340
340
|
}
|
|
341
341
|
static translateY(e) {
|
|
342
|
-
return new
|
|
342
|
+
return new M().translateY(e);
|
|
343
343
|
}
|
|
344
344
|
static clamp(e) {
|
|
345
|
-
return new
|
|
345
|
+
return new M().clamp(e);
|
|
346
346
|
}
|
|
347
347
|
static magnify(e) {
|
|
348
|
-
return new
|
|
348
|
+
return new M().magnify(e);
|
|
349
349
|
}
|
|
350
350
|
static scale(e) {
|
|
351
|
-
return new
|
|
351
|
+
return new M().scale(e);
|
|
352
352
|
}
|
|
353
353
|
static reBound(e) {
|
|
354
|
-
return new
|
|
354
|
+
return new M().reBound(e);
|
|
355
355
|
}
|
|
356
356
|
translate(e, t) {
|
|
357
357
|
const n = Et(e, t), i = this.copy();
|
|
@@ -386,7 +386,7 @@ class U {
|
|
|
386
386
|
return t.x = this.x.clamp(re(e)), t.y = this.y.clamp(ne(e)), t;
|
|
387
387
|
}
|
|
388
388
|
copy() {
|
|
389
|
-
const e = new
|
|
389
|
+
const e = new M();
|
|
390
390
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
391
391
|
}
|
|
392
392
|
reverse() {
|
|
@@ -414,17 +414,17 @@ class U {
|
|
|
414
414
|
offset: this.pos({ x: 0, y: 0 })
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
|
-
static IDENTITY = new
|
|
417
|
+
static IDENTITY = new M();
|
|
418
418
|
}
|
|
419
|
-
const Lt =
|
|
420
|
-
root:
|
|
419
|
+
const Lt = V.extend({
|
|
420
|
+
root: ke,
|
|
421
421
|
units: Y.object({
|
|
422
422
|
x: Y.enum(["px", "decimal"]),
|
|
423
423
|
y: Y.enum(["px", "decimal"])
|
|
424
424
|
})
|
|
425
425
|
});
|
|
426
426
|
Lt.partial({ root: !0, units: !0 });
|
|
427
|
-
const
|
|
427
|
+
const Pt = s.enum(["static", "dynamic"]), Se = 365, X = 30, kt = s.union([
|
|
428
428
|
s.tuple([s.int()]),
|
|
429
429
|
s.tuple([s.int(), s.int().min(1).max(12)]),
|
|
430
430
|
s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
|
|
@@ -455,7 +455,7 @@ class u extends Z {
|
|
|
455
455
|
else if (Array.isArray(e)) super(u.parseDate(e));
|
|
456
456
|
else {
|
|
457
457
|
let n = 0n;
|
|
458
|
-
e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e ===
|
|
458
|
+
e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === ft ? e = ae : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), E(e) && (e = e.value), super(BigInt(e.valueOf()) + n);
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
static parseDate([e = 1970, t = 1, n = 1]) {
|
|
@@ -471,9 +471,9 @@ class u extends Z {
|
|
|
471
471
|
}
|
|
472
472
|
static parseTimeString(e, t = "UTC") {
|
|
473
473
|
const [n, i, o] = e.split(":");
|
|
474
|
-
let c = "00",
|
|
475
|
-
o != null && ([c,
|
|
476
|
-
let w = u.hours(parseInt(n ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(
|
|
474
|
+
let c = "00", f = "00";
|
|
475
|
+
o != null && ([c, f] = o.split("."));
|
|
476
|
+
let w = u.hours(parseInt(n ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(f ?? "00")));
|
|
477
477
|
return t === "local" && (w = w.add(u.utcOffset)), w.valueOf();
|
|
478
478
|
}
|
|
479
479
|
static parseDateTimeString(e, t = "UTC") {
|
|
@@ -487,8 +487,8 @@ class u extends Z {
|
|
|
487
487
|
const g = h[1] || "0";
|
|
488
488
|
o = parseInt(g.padEnd(3, "0").slice(0, 3));
|
|
489
489
|
}
|
|
490
|
-
const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`),
|
|
491
|
-
return
|
|
490
|
+
const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), f = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(o) * u.MILLISECOND.valueOf();
|
|
491
|
+
return f + w;
|
|
492
492
|
}
|
|
493
493
|
const n = new Date(e);
|
|
494
494
|
return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new u(
|
|
@@ -497,7 +497,11 @@ class u extends Z {
|
|
|
497
497
|
).valueOf();
|
|
498
498
|
}
|
|
499
499
|
toISOString(e = "UTC") {
|
|
500
|
-
|
|
500
|
+
if (e === "UTC") return this.date().toISOString();
|
|
501
|
+
const t = this.date(), n = new l(
|
|
502
|
+
BigInt(t.getTimezoneOffset()) * u.MINUTE.valueOf()
|
|
503
|
+
);
|
|
504
|
+
return this.sub(n).date().toISOString();
|
|
501
505
|
}
|
|
502
506
|
timeString(e = !1, t = "UTC") {
|
|
503
507
|
const n = this.toISOString(t);
|
|
@@ -631,7 +635,7 @@ class u extends Z {
|
|
|
631
635
|
* TimeSpan.
|
|
632
636
|
*/
|
|
633
637
|
sub(e) {
|
|
634
|
-
return new u(
|
|
638
|
+
return new u(H(this.valueOf(), new l(e).valueOf()));
|
|
635
639
|
}
|
|
636
640
|
/**
|
|
637
641
|
* @returns the floating point number of hours since the unix epoch to the timestamp
|
|
@@ -677,42 +681,82 @@ class u extends Z {
|
|
|
677
681
|
get nanoseconds() {
|
|
678
682
|
return Number(this.valueOf());
|
|
679
683
|
}
|
|
680
|
-
/** @returns the integer year that the timestamp corresponds to. */
|
|
684
|
+
/** @returns the integer year that the timestamp corresponds to in UTC. */
|
|
681
685
|
get year() {
|
|
682
686
|
return this.date().getUTCFullYear();
|
|
683
687
|
}
|
|
688
|
+
/** @returns the integer year that the timestamp corresponds to in local time. */
|
|
689
|
+
get localYear() {
|
|
690
|
+
return this.date().getFullYear();
|
|
691
|
+
}
|
|
684
692
|
/**
|
|
685
|
-
* @returns a copy of the timestamp with the year changed.
|
|
693
|
+
* @returns a copy of the timestamp with the year changed in UTC.
|
|
686
694
|
* @param year the value to set the year to.
|
|
687
695
|
*/
|
|
688
696
|
setYear(e) {
|
|
689
697
|
const t = this.date();
|
|
690
698
|
return t.setUTCFullYear(e), new u(t);
|
|
691
699
|
}
|
|
692
|
-
/**
|
|
700
|
+
/**
|
|
701
|
+
* @returns a copy of the timestamp with the year changed in local time.
|
|
702
|
+
* @param year the value to set the year to.
|
|
703
|
+
*/
|
|
704
|
+
setLocalYear(e) {
|
|
705
|
+
const t = this.date();
|
|
706
|
+
return t.setFullYear(e), new u(t);
|
|
707
|
+
}
|
|
708
|
+
/** @returns the integer month that the timestamp corresponds to within its year in
|
|
709
|
+
* UTC. */
|
|
693
710
|
get month() {
|
|
694
711
|
return this.date().getUTCMonth();
|
|
695
712
|
}
|
|
713
|
+
/** @returns the integer month that the timestamp corresponds to within its year in
|
|
714
|
+
* local time. */
|
|
715
|
+
get localMonth() {
|
|
716
|
+
return this.date().getMonth();
|
|
717
|
+
}
|
|
696
718
|
/**
|
|
697
|
-
* @returns a copy of the timestamp with the month changed.
|
|
719
|
+
* @returns a copy of the timestamp with the month changed in UTC.
|
|
698
720
|
* @param month the value to set the month to.
|
|
699
721
|
*/
|
|
700
722
|
setMonth(e) {
|
|
701
723
|
const t = this.date();
|
|
702
724
|
return t.setUTCMonth(e), new u(t);
|
|
703
725
|
}
|
|
704
|
-
/**
|
|
726
|
+
/**
|
|
727
|
+
* @returns a copy of the timestamp with the month changed in local time.
|
|
728
|
+
* @param month the value to set the month to.
|
|
729
|
+
*/
|
|
730
|
+
setLocalMonth(e) {
|
|
731
|
+
const t = this.date();
|
|
732
|
+
return t.setMonth(e), new u(t);
|
|
733
|
+
}
|
|
734
|
+
/** @returns the integer day that the timestamp corresponds to within its month in
|
|
735
|
+
* UTC. */
|
|
705
736
|
get day() {
|
|
706
737
|
return this.date().getUTCDate();
|
|
707
738
|
}
|
|
739
|
+
/** @returns the integer day that the timestamp corresponds to within its month in
|
|
740
|
+
* local time. */
|
|
741
|
+
get localDay() {
|
|
742
|
+
return this.date().getDate();
|
|
743
|
+
}
|
|
708
744
|
/**
|
|
709
|
-
* @returns a copy of the timestamp with the day changed.
|
|
745
|
+
* @returns a copy of the timestamp with the day changed in UTC.
|
|
710
746
|
* @param day the value the set the day to.
|
|
711
747
|
*/
|
|
712
748
|
setDay(e) {
|
|
713
749
|
const t = this.date();
|
|
714
750
|
return t.setUTCDate(e), new u(t);
|
|
715
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* @returns a copy of the timestamp with the day changed in local time.
|
|
754
|
+
* @param day the value to set the day to.
|
|
755
|
+
*/
|
|
756
|
+
setLocalDay(e) {
|
|
757
|
+
const t = this.date();
|
|
758
|
+
return t.setDate(e), new u(t);
|
|
759
|
+
}
|
|
716
760
|
/**
|
|
717
761
|
* @returns the integer hour that the timestamp corresponds to within its day.
|
|
718
762
|
*/
|
|
@@ -720,7 +764,8 @@ class u extends Z {
|
|
|
720
764
|
return this.date().getUTCHours();
|
|
721
765
|
}
|
|
722
766
|
/**
|
|
723
|
-
* @returns the integer hour that the timestamp corresponds to within its day in local
|
|
767
|
+
* @returns the integer hour that the timestamp corresponds to within its day in local
|
|
768
|
+
* time.
|
|
724
769
|
*/
|
|
725
770
|
get localHour() {
|
|
726
771
|
return this.date().getHours();
|
|
@@ -741,48 +786,92 @@ class u extends Z {
|
|
|
741
786
|
const t = this.date();
|
|
742
787
|
return t.setUTCHours(e), new u(t);
|
|
743
788
|
}
|
|
744
|
-
/** @returns the integer minute that the timestamp corresponds to within its hour
|
|
789
|
+
/** @returns the integer minute that the timestamp corresponds to within its hour in
|
|
790
|
+
* UTC. */
|
|
745
791
|
get minute() {
|
|
746
792
|
return this.date().getUTCMinutes();
|
|
747
793
|
}
|
|
794
|
+
/** @returns the integer minute that the timestamp corresponds to within its hour in
|
|
795
|
+
* local time. */
|
|
796
|
+
get localMinute() {
|
|
797
|
+
return this.date().getMinutes();
|
|
798
|
+
}
|
|
748
799
|
/**
|
|
749
|
-
* @returns a copy of the timestamp with the minute changed.
|
|
800
|
+
* @returns a copy of the timestamp with the minute changed in UTC.
|
|
750
801
|
* @param minute the value to set the minute to.
|
|
751
802
|
*/
|
|
752
803
|
setMinute(e) {
|
|
753
804
|
const t = this.date();
|
|
754
805
|
return t.setUTCMinutes(e), new u(t);
|
|
755
806
|
}
|
|
807
|
+
/**
|
|
808
|
+
* @returns a copy of the timestamp with the minute changed in local time.
|
|
809
|
+
* @param minute the value to set the minute to.
|
|
810
|
+
*/
|
|
811
|
+
setLocalMinute(e) {
|
|
812
|
+
const t = this.date();
|
|
813
|
+
return t.setMinutes(e), new u(t);
|
|
814
|
+
}
|
|
756
815
|
/**
|
|
757
816
|
* @returns the integer second that the timestamp corresponds to within its
|
|
758
|
-
* minute.
|
|
817
|
+
* minute in UTC.
|
|
759
818
|
*/
|
|
760
819
|
get second() {
|
|
761
820
|
return this.date().getUTCSeconds();
|
|
762
821
|
}
|
|
763
822
|
/**
|
|
764
|
-
* @returns
|
|
823
|
+
* @returns the integer second that the timestamp corresponds to within its minute in
|
|
824
|
+
* local time.
|
|
825
|
+
*/
|
|
826
|
+
get localSecond() {
|
|
827
|
+
return this.date().getSeconds();
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* @returns a copy of the timestamp with the second changed in UTC.
|
|
765
831
|
* @param second the value to set the second to.
|
|
766
832
|
*/
|
|
767
833
|
setSecond(e) {
|
|
768
834
|
const t = this.date();
|
|
769
835
|
return t.setUTCSeconds(e), new u(t);
|
|
770
836
|
}
|
|
837
|
+
/**
|
|
838
|
+
* @returns a copy of the timestamp with the second changed in local time.
|
|
839
|
+
* @param second the value to set the second to.
|
|
840
|
+
*/
|
|
841
|
+
setLocalSecond(e) {
|
|
842
|
+
const t = this.date();
|
|
843
|
+
return t.setSeconds(e), new u(t);
|
|
844
|
+
}
|
|
771
845
|
/**
|
|
772
846
|
* @returns the integer millisecond that the timestamp corresponds to within its
|
|
773
|
-
* second.
|
|
847
|
+
* second in UTC.
|
|
774
848
|
*/
|
|
775
849
|
get millisecond() {
|
|
776
850
|
return this.date().getUTCMilliseconds();
|
|
777
851
|
}
|
|
778
852
|
/**
|
|
779
|
-
* @returns
|
|
853
|
+
* @returns the integer millisecond that the timestamp corresponds to within its
|
|
854
|
+
* second in local time.
|
|
855
|
+
*/
|
|
856
|
+
get localMillisecond() {
|
|
857
|
+
return this.date().getMilliseconds();
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* @returns a copy of the timestamp with the milliseconds changed in UTC.
|
|
780
861
|
* @param millisecond the value to set the millisecond to.
|
|
781
862
|
*/
|
|
782
863
|
setMillisecond(e) {
|
|
783
864
|
const t = this.date();
|
|
784
865
|
return t.setUTCMilliseconds(e), new u(t);
|
|
785
866
|
}
|
|
867
|
+
/**
|
|
868
|
+
* @returns a copy of the timestamp with the milliseconds changed in local time.
|
|
869
|
+
* @param millisecond the value to set the millisecond to.
|
|
870
|
+
*/
|
|
871
|
+
setLocalMillisecond(e) {
|
|
872
|
+
const t = this.date();
|
|
873
|
+
return t.setMilliseconds(e), new u(t);
|
|
874
|
+
}
|
|
786
875
|
/**
|
|
787
876
|
* Returns a string representation of the TimeStamp.
|
|
788
877
|
*
|
|
@@ -951,7 +1040,7 @@ class u extends Z {
|
|
|
951
1040
|
s.bigint().transform((e) => new u(e)),
|
|
952
1041
|
s.date().transform((e) => new u(e)),
|
|
953
1042
|
s.custom((e) => e instanceof l).transform((e) => new u(e)),
|
|
954
|
-
|
|
1043
|
+
kt.transform((e) => new u(e))
|
|
955
1044
|
]);
|
|
956
1045
|
/**
|
|
957
1046
|
* Sorts two timestamps.
|
|
@@ -1060,63 +1149,63 @@ class l extends Z {
|
|
|
1060
1149
|
*/
|
|
1061
1150
|
toString(e = "full") {
|
|
1062
1151
|
if (e === "semantic") return this.toSemanticString();
|
|
1063
|
-
const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), o = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND),
|
|
1064
|
-
let
|
|
1065
|
-
return h.isZero || (
|
|
1152
|
+
const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), o = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), f = this.truncate(l.MICROSECOND), w = this.truncate(l.NANOSECOND), h = t, g = n.sub(t), b = i.sub(n), d = o.sub(i), O = c.sub(o), N = f.sub(c), x = w.sub(f);
|
|
1153
|
+
let p = "";
|
|
1154
|
+
return h.isZero || (p += `${h.days}d `), g.isZero || (p += `${g.hours}h `), b.isZero || (p += `${b.minutes}m `), d.isZero || (p += `${d.seconds}s `), O.isZero || (p += `${O.milliseconds}ms `), N.isZero || (p += `${N.microseconds}µs `), x.isZero || (p += `${x.nanoseconds}ns`), p.trim();
|
|
1066
1155
|
}
|
|
1067
1156
|
toSemanticString() {
|
|
1068
1157
|
const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), n = this.valueOf() < 0n;
|
|
1069
1158
|
if (t.valueOf() === 0n) return "0s";
|
|
1070
1159
|
if (t.lessThan(l.SECOND)) return "< 1s";
|
|
1071
|
-
const i = t.days, o = t.hours, c = t.minutes,
|
|
1160
|
+
const i = t.days, o = t.hours, c = t.minutes, f = t.seconds, w = Math.floor(i / Se), h = Math.floor(i / X), g = Math.floor(i / 7), b = Math.floor(i), d = Math.floor(o), O = Math.floor(c), N = Math.floor(f), x = n ? "-" : "";
|
|
1072
1161
|
if (w >= 1) {
|
|
1073
|
-
let
|
|
1162
|
+
let p = `${w}y`;
|
|
1074
1163
|
if (w < 2) {
|
|
1075
|
-
const
|
|
1076
|
-
i % Se /
|
|
1164
|
+
const T = Math.floor(
|
|
1165
|
+
i % Se / X
|
|
1077
1166
|
);
|
|
1078
|
-
|
|
1167
|
+
T > 0 && (p += ` ${T}mo`);
|
|
1079
1168
|
}
|
|
1080
|
-
return x +
|
|
1169
|
+
return x + p;
|
|
1081
1170
|
}
|
|
1082
|
-
if (g >= 1 && i <
|
|
1083
|
-
let
|
|
1084
|
-
const
|
|
1085
|
-
return g < 2 && (
|
|
1171
|
+
if (g >= 1 && i < X && i % 7 === 0) {
|
|
1172
|
+
let p = `${g}w`;
|
|
1173
|
+
const T = Math.floor(i % 7), $ = Math.floor(o - g * 7 * 24);
|
|
1174
|
+
return g < 2 && (T > 0 ? p += ` ${T}d` : $ > 0 && $ < 24 && (p += ` ${$}h`)), x + p;
|
|
1086
1175
|
}
|
|
1087
1176
|
if (h >= 1) {
|
|
1088
|
-
let
|
|
1177
|
+
let p = `${h}mo`;
|
|
1089
1178
|
if (h < 3) {
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1179
|
+
const T = Math.floor(i % X);
|
|
1180
|
+
T > 0 && (p += ` ${T}d`);
|
|
1092
1181
|
}
|
|
1093
|
-
return x +
|
|
1182
|
+
return x + p;
|
|
1094
1183
|
}
|
|
1095
1184
|
if (g >= 1) {
|
|
1096
|
-
let
|
|
1097
|
-
const
|
|
1098
|
-
return g < 2 && (
|
|
1185
|
+
let p = `${g}w`;
|
|
1186
|
+
const T = Math.floor(i % 7), $ = Math.floor(o - g * 7 * 24);
|
|
1187
|
+
return g < 2 && (T > 0 ? p += ` ${T}d` : $ > 0 && $ < 24 && (p += ` ${$}h`)), x + p;
|
|
1099
1188
|
}
|
|
1100
1189
|
if (b >= 1) {
|
|
1101
|
-
let
|
|
1102
|
-
const
|
|
1103
|
-
return b < 2 &&
|
|
1190
|
+
let p = `${b}d`;
|
|
1191
|
+
const T = Math.floor(o - b * 24);
|
|
1192
|
+
return b < 2 && T > 0 && (p += ` ${T}h`), x + p;
|
|
1104
1193
|
}
|
|
1105
|
-
if (
|
|
1106
|
-
let
|
|
1107
|
-
if (
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1194
|
+
if (d >= 1) {
|
|
1195
|
+
let p = `${d}h`;
|
|
1196
|
+
if (d < 3) {
|
|
1197
|
+
const T = Math.floor(c - d * 60);
|
|
1198
|
+
T > 0 && (p += ` ${T}m`);
|
|
1110
1199
|
}
|
|
1111
|
-
return x +
|
|
1200
|
+
return x + p;
|
|
1112
1201
|
}
|
|
1113
|
-
if (
|
|
1114
|
-
let
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1202
|
+
if (O >= 1) {
|
|
1203
|
+
let p = `${O}m`;
|
|
1204
|
+
if (O < 5) {
|
|
1205
|
+
const T = Math.floor(f - O * 60);
|
|
1206
|
+
T > 0 && (p += ` ${T}s`);
|
|
1118
1207
|
}
|
|
1119
|
-
return x +
|
|
1208
|
+
return x + p;
|
|
1120
1209
|
}
|
|
1121
1210
|
return `${x}${N}s`;
|
|
1122
1211
|
}
|
|
@@ -1127,7 +1216,7 @@ class l extends Z {
|
|
|
1127
1216
|
* @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
|
|
1128
1217
|
*/
|
|
1129
1218
|
mult(e) {
|
|
1130
|
-
return new l(
|
|
1219
|
+
return new l(U(this.valueOf(), e));
|
|
1131
1220
|
}
|
|
1132
1221
|
/**
|
|
1133
1222
|
* Divides the TimeSpan by a scalar value.
|
|
@@ -1216,7 +1305,7 @@ class l extends Z {
|
|
|
1216
1305
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
1217
1306
|
*/
|
|
1218
1307
|
static microseconds(e = 1) {
|
|
1219
|
-
return l.nanoseconds(
|
|
1308
|
+
return l.nanoseconds(U(e, 1e3));
|
|
1220
1309
|
}
|
|
1221
1310
|
/** A microsecond. */
|
|
1222
1311
|
static MICROSECOND = l.microseconds(1);
|
|
@@ -1227,7 +1316,7 @@ class l extends Z {
|
|
|
1227
1316
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
1228
1317
|
*/
|
|
1229
1318
|
static milliseconds(e = 1) {
|
|
1230
|
-
return l.microseconds(
|
|
1319
|
+
return l.microseconds(U(e, 1e3));
|
|
1231
1320
|
}
|
|
1232
1321
|
/** A millisecond. */
|
|
1233
1322
|
static MILLISECOND = l.milliseconds(1);
|
|
@@ -1238,7 +1327,7 @@ class l extends Z {
|
|
|
1238
1327
|
* @returns A TimeSpan representing the given number of seconds.
|
|
1239
1328
|
*/
|
|
1240
1329
|
static seconds(e = 1) {
|
|
1241
|
-
return l.milliseconds(
|
|
1330
|
+
return l.milliseconds(U(e, 1e3));
|
|
1242
1331
|
}
|
|
1243
1332
|
/** A second. */
|
|
1244
1333
|
static SECOND = l.seconds(1);
|
|
@@ -1249,7 +1338,7 @@ class l extends Z {
|
|
|
1249
1338
|
* @returns A TimeSpan representing the given number of minutes.
|
|
1250
1339
|
*/
|
|
1251
1340
|
static minutes(e = 1) {
|
|
1252
|
-
return l.seconds(
|
|
1341
|
+
return l.seconds(U(e, 60));
|
|
1253
1342
|
}
|
|
1254
1343
|
/** A minute. */
|
|
1255
1344
|
static MINUTE = l.minutes(1);
|
|
@@ -1260,7 +1349,7 @@ class l extends Z {
|
|
|
1260
1349
|
* @returns A TimeSpan representing the given number of hours.
|
|
1261
1350
|
*/
|
|
1262
1351
|
static hours(e) {
|
|
1263
|
-
return l.minutes(
|
|
1352
|
+
return l.minutes(U(e, 60));
|
|
1264
1353
|
}
|
|
1265
1354
|
/** Represents an hour. */
|
|
1266
1355
|
static HOUR = l.hours(1);
|
|
@@ -1271,7 +1360,7 @@ class l extends Z {
|
|
|
1271
1360
|
* @returns A TimeSpan representing the given number of days.
|
|
1272
1361
|
*/
|
|
1273
1362
|
static days(e) {
|
|
1274
|
-
return l.hours(
|
|
1363
|
+
return l.hours(U(e, 24));
|
|
1275
1364
|
}
|
|
1276
1365
|
/** Represents a day. */
|
|
1277
1366
|
static DAY = l.days(1);
|
|
@@ -1329,7 +1418,7 @@ class I extends Z {
|
|
|
1329
1418
|
* @returns The number of bytes in the given TimeSpan at this rate.
|
|
1330
1419
|
*/
|
|
1331
1420
|
byteCount(e, t) {
|
|
1332
|
-
return this.sampleCount(e) * new
|
|
1421
|
+
return this.sampleCount(e) * new y(t).valueOf();
|
|
1333
1422
|
}
|
|
1334
1423
|
/**
|
|
1335
1424
|
* Calculates a TimeSpan given the number of samples at this rate.
|
|
@@ -1348,7 +1437,7 @@ class I extends Z {
|
|
|
1348
1437
|
* @returns A TimeSpan that corresponds to the given number of bytes.
|
|
1349
1438
|
*/
|
|
1350
1439
|
byteSpan(e, t) {
|
|
1351
|
-
return this.span(e.valueOf() / new
|
|
1440
|
+
return this.span(e.valueOf() / new y(t).valueOf());
|
|
1352
1441
|
}
|
|
1353
1442
|
/**
|
|
1354
1443
|
* Adds another Rate to this Rate.
|
|
@@ -1366,7 +1455,7 @@ class I extends Z {
|
|
|
1366
1455
|
* @returns A new Rate representing the difference of the two rates.
|
|
1367
1456
|
*/
|
|
1368
1457
|
sub(e) {
|
|
1369
|
-
return new I(
|
|
1458
|
+
return new I(H(this.valueOf(), new I(e).valueOf()));
|
|
1370
1459
|
}
|
|
1371
1460
|
/**
|
|
1372
1461
|
* Multiplies this Rate by a scalar value.
|
|
@@ -1375,7 +1464,7 @@ class I extends Z {
|
|
|
1375
1464
|
* @returns A new Rate representing this Rate multiplied by the value.
|
|
1376
1465
|
*/
|
|
1377
1466
|
mult(e) {
|
|
1378
|
-
return new I(
|
|
1467
|
+
return new I(U(this.valueOf(), e));
|
|
1379
1468
|
}
|
|
1380
1469
|
/**
|
|
1381
1470
|
* Divides this Rate by a scalar value.
|
|
@@ -1410,7 +1499,7 @@ class I extends Z {
|
|
|
1410
1499
|
s.instanceof(I)
|
|
1411
1500
|
]);
|
|
1412
1501
|
}
|
|
1413
|
-
class
|
|
1502
|
+
class y extends Z {
|
|
1414
1503
|
/**
|
|
1415
1504
|
* Creates a Density representing the given number of bytes per value.
|
|
1416
1505
|
*
|
|
@@ -1446,7 +1535,7 @@ class p extends Z {
|
|
|
1446
1535
|
* @returns A new Density representing the sum of the two densities.
|
|
1447
1536
|
*/
|
|
1448
1537
|
add(e) {
|
|
1449
|
-
return new
|
|
1538
|
+
return new y(L(this.valueOf(), new y(e).valueOf()));
|
|
1450
1539
|
}
|
|
1451
1540
|
/**
|
|
1452
1541
|
* Subtracts another Density from this Density.
|
|
@@ -1455,7 +1544,7 @@ class p extends Z {
|
|
|
1455
1544
|
* @returns A new Density representing the difference of the two densities.
|
|
1456
1545
|
*/
|
|
1457
1546
|
sub(e) {
|
|
1458
|
-
return new
|
|
1547
|
+
return new y(H(this.valueOf(), new y(e).valueOf()));
|
|
1459
1548
|
}
|
|
1460
1549
|
/**
|
|
1461
1550
|
* Multiplies this Density by a scalar value.
|
|
@@ -1464,7 +1553,7 @@ class p extends Z {
|
|
|
1464
1553
|
* @returns A new Density representing this Density multiplied by the value.
|
|
1465
1554
|
*/
|
|
1466
1555
|
mult(e) {
|
|
1467
|
-
return new
|
|
1556
|
+
return new y(U(this.valueOf(), e));
|
|
1468
1557
|
}
|
|
1469
1558
|
/**
|
|
1470
1559
|
* Divides this Density by a scalar value.
|
|
@@ -1473,24 +1562,24 @@ class p extends Z {
|
|
|
1473
1562
|
* @returns A new Density representing this Density divided by the value.
|
|
1474
1563
|
*/
|
|
1475
1564
|
div(e) {
|
|
1476
|
-
return new
|
|
1565
|
+
return new y(ee(this.valueOf(), e));
|
|
1477
1566
|
}
|
|
1478
1567
|
/** Unknown/Invalid Density. */
|
|
1479
|
-
static UNKNOWN = new
|
|
1568
|
+
static UNKNOWN = new y(0);
|
|
1480
1569
|
/** 128 bits per value. */
|
|
1481
|
-
static BIT128 = new
|
|
1570
|
+
static BIT128 = new y(16);
|
|
1482
1571
|
/** 64 bits per value. */
|
|
1483
|
-
static BIT64 = new
|
|
1572
|
+
static BIT64 = new y(8);
|
|
1484
1573
|
/** 32 bits per value. */
|
|
1485
|
-
static BIT32 = new
|
|
1574
|
+
static BIT32 = new y(4);
|
|
1486
1575
|
/** 16 bits per value. */
|
|
1487
|
-
static BIT16 = new
|
|
1576
|
+
static BIT16 = new y(2);
|
|
1488
1577
|
/** 8 bits per value. */
|
|
1489
|
-
static BIT8 = new
|
|
1578
|
+
static BIT8 = new y(1);
|
|
1490
1579
|
/** A zod schema for validating and transforming densities */
|
|
1491
1580
|
static z = s.union([
|
|
1492
|
-
s.number().transform((e) => new
|
|
1493
|
-
s.instanceof(
|
|
1581
|
+
s.number().transform((e) => new y(e)),
|
|
1582
|
+
s.instanceof(y)
|
|
1494
1583
|
]);
|
|
1495
1584
|
}
|
|
1496
1585
|
class S {
|
|
@@ -1717,7 +1806,7 @@ class a extends Z {
|
|
|
1717
1806
|
* @example DataType.INT32.isVariable // false
|
|
1718
1807
|
*/
|
|
1719
1808
|
get isVariable() {
|
|
1720
|
-
return this.equals(a.JSON) || this.equals(a.STRING);
|
|
1809
|
+
return this.equals(a.JSON) || this.equals(a.STRING) || this.equals(a.BYTES);
|
|
1721
1810
|
}
|
|
1722
1811
|
/**
|
|
1723
1812
|
* @returns true if the DataType is numeric.
|
|
@@ -1813,8 +1902,6 @@ class a extends Z {
|
|
|
1813
1902
|
static UINT16 = new a("uint16");
|
|
1814
1903
|
/** Represents a 8-bit unsigned integer value. */
|
|
1815
1904
|
static UINT8 = new a("uint8");
|
|
1816
|
-
/** Represents a boolean value. Stored as a 8-bit unsigned integer. */
|
|
1817
|
-
static BOOLEAN = new a("boolean");
|
|
1818
1905
|
/** Represents a 64-bit unix epoch. */
|
|
1819
1906
|
static TIMESTAMP = new a("timestamp");
|
|
1820
1907
|
/** Represents a UUID data type. */
|
|
@@ -1825,6 +1912,9 @@ class a extends Z {
|
|
|
1825
1912
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1826
1913
|
* newline character. */
|
|
1827
1914
|
static JSON = new a("json");
|
|
1915
|
+
/** Represents a bytes data type for arbitrary byte arrays. Bytes have an unknown
|
|
1916
|
+
* density, and are separated by a newline character. */
|
|
1917
|
+
static BYTES = new a("bytes");
|
|
1828
1918
|
static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
|
|
1829
1919
|
[a.UINT8.toString(), Uint8Array],
|
|
1830
1920
|
[a.UINT16.toString(), Uint16Array],
|
|
@@ -1839,7 +1929,8 @@ class a extends Z {
|
|
|
1839
1929
|
[a.TIMESTAMP.toString(), BigInt64Array],
|
|
1840
1930
|
[a.STRING.toString(), Uint8Array],
|
|
1841
1931
|
[a.JSON.toString(), Uint8Array],
|
|
1842
|
-
[a.UUID.toString(), Uint8Array]
|
|
1932
|
+
[a.UUID.toString(), Uint8Array],
|
|
1933
|
+
[a.BYTES.toString(), Uint8Array]
|
|
1843
1934
|
]);
|
|
1844
1935
|
static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
|
|
1845
1936
|
[Uint8Array.name, a.UINT8],
|
|
@@ -1854,38 +1945,40 @@ class a extends Z {
|
|
|
1854
1945
|
[BigInt64Array.name, a.INT64]
|
|
1855
1946
|
]);
|
|
1856
1947
|
static DENSITIES = /* @__PURE__ */ new Map([
|
|
1857
|
-
[a.UINT8.toString(),
|
|
1858
|
-
[a.UINT16.toString(),
|
|
1859
|
-
[a.UINT32.toString(),
|
|
1860
|
-
[a.UINT64.toString(),
|
|
1861
|
-
[a.FLOAT32.toString(),
|
|
1862
|
-
[a.FLOAT64.toString(),
|
|
1863
|
-
[a.INT8.toString(),
|
|
1864
|
-
[a.INT16.toString(),
|
|
1865
|
-
[a.INT32.toString(),
|
|
1866
|
-
[a.INT64.toString(),
|
|
1867
|
-
[a.TIMESTAMP.toString(),
|
|
1868
|
-
[a.STRING.toString(),
|
|
1869
|
-
[a.JSON.toString(),
|
|
1870
|
-
[a.UUID.toString(),
|
|
1948
|
+
[a.UINT8.toString(), y.BIT8],
|
|
1949
|
+
[a.UINT16.toString(), y.BIT16],
|
|
1950
|
+
[a.UINT32.toString(), y.BIT32],
|
|
1951
|
+
[a.UINT64.toString(), y.BIT64],
|
|
1952
|
+
[a.FLOAT32.toString(), y.BIT32],
|
|
1953
|
+
[a.FLOAT64.toString(), y.BIT64],
|
|
1954
|
+
[a.INT8.toString(), y.BIT8],
|
|
1955
|
+
[a.INT16.toString(), y.BIT16],
|
|
1956
|
+
[a.INT32.toString(), y.BIT32],
|
|
1957
|
+
[a.INT64.toString(), y.BIT64],
|
|
1958
|
+
[a.TIMESTAMP.toString(), y.BIT64],
|
|
1959
|
+
[a.STRING.toString(), y.UNKNOWN],
|
|
1960
|
+
[a.JSON.toString(), y.UNKNOWN],
|
|
1961
|
+
[a.UUID.toString(), y.BIT128],
|
|
1962
|
+
[a.BYTES.toString(), y.UNKNOWN]
|
|
1871
1963
|
]);
|
|
1872
1964
|
/** All the data types. */
|
|
1873
1965
|
static ALL = [
|
|
1874
1966
|
a.UNKNOWN,
|
|
1875
|
-
a.FLOAT64,
|
|
1876
|
-
a.FLOAT32,
|
|
1877
|
-
a.INT64,
|
|
1878
|
-
a.INT32,
|
|
1879
|
-
a.INT16,
|
|
1880
|
-
a.INT8,
|
|
1881
|
-
a.UINT64,
|
|
1882
|
-
a.UINT32,
|
|
1883
|
-
a.UINT16,
|
|
1884
1967
|
a.UINT8,
|
|
1968
|
+
a.UINT16,
|
|
1969
|
+
a.UINT32,
|
|
1970
|
+
a.UINT64,
|
|
1971
|
+
a.INT8,
|
|
1972
|
+
a.INT16,
|
|
1973
|
+
a.INT32,
|
|
1974
|
+
a.INT64,
|
|
1975
|
+
a.FLOAT32,
|
|
1976
|
+
a.FLOAT64,
|
|
1885
1977
|
a.TIMESTAMP,
|
|
1886
1978
|
a.UUID,
|
|
1887
1979
|
a.STRING,
|
|
1888
|
-
a.JSON
|
|
1980
|
+
a.JSON,
|
|
1981
|
+
a.BYTES
|
|
1889
1982
|
];
|
|
1890
1983
|
static SHORT_STRINGS = /* @__PURE__ */ new Map([
|
|
1891
1984
|
[a.UINT8.toString(), "u8"],
|
|
@@ -1898,11 +1991,11 @@ class a extends Z {
|
|
|
1898
1991
|
[a.INT64.toString(), "i64"],
|
|
1899
1992
|
[a.FLOAT32.toString(), "f32"],
|
|
1900
1993
|
[a.FLOAT64.toString(), "f64"],
|
|
1901
|
-
[a.BOOLEAN.toString(), "bool"],
|
|
1902
1994
|
[a.TIMESTAMP.toString(), "ts"],
|
|
1903
1995
|
[a.UUID.toString(), "uuid"],
|
|
1904
1996
|
[a.STRING.toString(), "str"],
|
|
1905
|
-
[a.JSON.toString(), "json"]
|
|
1997
|
+
[a.JSON.toString(), "json"],
|
|
1998
|
+
[a.BYTES.toString(), "bytes"]
|
|
1906
1999
|
]);
|
|
1907
2000
|
static BIG_INT_TYPES = [a.INT64, a.UINT64, a.TIMESTAMP];
|
|
1908
2001
|
/** A zod schema for a DataType. */
|
|
@@ -1929,7 +2022,7 @@ class m extends Z {
|
|
|
1929
2022
|
}
|
|
1930
2023
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1931
2024
|
sub(e) {
|
|
1932
|
-
return E(e) && (e = e.value), new m(
|
|
2025
|
+
return E(e) && (e = e.value), new m(H(this.valueOf(), e.valueOf()));
|
|
1933
2026
|
}
|
|
1934
2027
|
/**
|
|
1935
2028
|
* Multiplies this Size by a scalar value.
|
|
@@ -1938,7 +2031,7 @@ class m extends Z {
|
|
|
1938
2031
|
* @returns A new Size representing this Size multiplied by the value.
|
|
1939
2032
|
*/
|
|
1940
2033
|
mult(e) {
|
|
1941
|
-
return new m(
|
|
2034
|
+
return new m(U(this.valueOf(), e));
|
|
1942
2035
|
}
|
|
1943
2036
|
/**
|
|
1944
2037
|
* Divides this Size by a scalar value.
|
|
@@ -1977,9 +2070,9 @@ class m extends Z {
|
|
|
1977
2070
|
}
|
|
1978
2071
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1979
2072
|
toString() {
|
|
1980
|
-
const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), o = this.truncate(m.BYTE), c = e,
|
|
2073
|
+
const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), o = this.truncate(m.BYTE), c = e, f = t.sub(e), w = n.sub(t), h = i.sub(n), g = o.sub(i);
|
|
1981
2074
|
let b = "";
|
|
1982
|
-
return c.isZero || (b += `${c.terabytes}TB `),
|
|
2075
|
+
return c.isZero || (b += `${c.terabytes}TB `), f.isZero || (b += `${f.gigabytes}GB `), w.isZero || (b += `${w.megabytes}MB `), h.isZero || (b += `${h.kilobytes}KB `), (!g.isZero || b === "") && (b += `${g.valueOf()}B`), b.trim();
|
|
1983
2076
|
}
|
|
1984
2077
|
/**
|
|
1985
2078
|
* Creates a Size from the given number of bytes.
|
|
@@ -2067,34 +2160,34 @@ s.union([
|
|
|
2067
2160
|
const je = (r) => {
|
|
2068
2161
|
const e = typeof r;
|
|
2069
2162
|
return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof u || r instanceof l || r instanceof Date;
|
|
2070
|
-
}, Yt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) :
|
|
2071
|
-
function
|
|
2163
|
+
}, Yt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : H(t, n), jt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
2164
|
+
function Ft(r) {
|
|
2072
2165
|
return typeof r == "string" && jt.test(r);
|
|
2073
2166
|
}
|
|
2074
2167
|
const v = [];
|
|
2075
2168
|
for (let r = 0; r < 256; ++r)
|
|
2076
2169
|
v.push((r + 256).toString(16).slice(1));
|
|
2077
|
-
function
|
|
2170
|
+
function qt(r, e = 0) {
|
|
2078
2171
|
return (v[r[e + 0]] + v[r[e + 1]] + v[r[e + 2]] + v[r[e + 3]] + "-" + v[r[e + 4]] + v[r[e + 5]] + "-" + v[r[e + 6]] + v[r[e + 7]] + "-" + v[r[e + 8]] + v[r[e + 9]] + "-" + v[r[e + 10]] + v[r[e + 11]] + v[r[e + 12]] + v[r[e + 13]] + v[r[e + 14]] + v[r[e + 15]]).toLowerCase();
|
|
2079
2172
|
}
|
|
2080
2173
|
function Zt(r, e = 0) {
|
|
2081
|
-
const t =
|
|
2082
|
-
if (!
|
|
2174
|
+
const t = qt(r, e);
|
|
2175
|
+
if (!Ft(t))
|
|
2083
2176
|
throw TypeError("Stringified UUID is invalid");
|
|
2084
2177
|
return t;
|
|
2085
2178
|
}
|
|
2086
2179
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
2087
|
-
const
|
|
2180
|
+
const Fe = (r, e) => Zt(r, e), B = -1, Wt = s.string().transform(
|
|
2088
2181
|
(r) => new Uint8Array(
|
|
2089
2182
|
atob(r).split("").map((e) => e.charCodeAt(0))
|
|
2090
2183
|
).buffer
|
|
2091
|
-
),
|
|
2184
|
+
), Gt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), oe = 10, Vt = (r, e) => {
|
|
2092
2185
|
if (r === "number" && !e.isNumeric)
|
|
2093
2186
|
throw new Error(`cannot convert series of type ${e.toString()} to number`);
|
|
2094
2187
|
if (r === "bigint" && !e.usesBigInt)
|
|
2095
2188
|
throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
|
|
2096
|
-
},
|
|
2097
|
-
class
|
|
2189
|
+
}, qe = "sy_x_telem_series";
|
|
2190
|
+
class A {
|
|
2098
2191
|
/**
|
|
2099
2192
|
* A unique identifier for the series. If specified by the user, it is their
|
|
2100
2193
|
* responsibility to ensure that it is unique. If not specified, a new ID will be
|
|
@@ -2105,7 +2198,7 @@ class M {
|
|
|
2105
2198
|
* A discriminator used for identifying instances of the series class even
|
|
2106
2199
|
* when bundlers mangle the class name.
|
|
2107
2200
|
*/
|
|
2108
|
-
discriminator =
|
|
2201
|
+
discriminator = qe;
|
|
2109
2202
|
/** The data type of the series. */
|
|
2110
2203
|
dataType;
|
|
2111
2204
|
/**
|
|
@@ -2154,18 +2247,18 @@ class M {
|
|
|
2154
2247
|
dataType: a.z,
|
|
2155
2248
|
alignment: s.coerce.bigint().optional(),
|
|
2156
2249
|
data: s.union([
|
|
2250
|
+
Wt,
|
|
2157
2251
|
Gt,
|
|
2158
|
-
Vt,
|
|
2159
2252
|
s.instanceof(ArrayBuffer),
|
|
2160
2253
|
s.instanceof(Uint8Array)
|
|
2161
2254
|
]),
|
|
2162
|
-
glBufferUsage:
|
|
2255
|
+
glBufferUsage: Pt.default("static").optional()
|
|
2163
2256
|
});
|
|
2164
2257
|
/**
|
|
2165
2258
|
* A zod schema that validates and constructs a series from it's crude
|
|
2166
2259
|
* representation.
|
|
2167
2260
|
*/
|
|
2168
|
-
static z =
|
|
2261
|
+
static z = A.crudeZ.transform((e) => new A(e));
|
|
2169
2262
|
/**
|
|
2170
2263
|
* The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
|
|
2171
2264
|
*
|
|
@@ -2240,20 +2333,20 @@ class M {
|
|
|
2240
2333
|
* @throws Error if data type cannot be inferred from input
|
|
2241
2334
|
*/
|
|
2242
2335
|
constructor(e) {
|
|
2243
|
-
|
|
2336
|
+
Ht(e) && (e = { data: e }), e.data ??= [];
|
|
2244
2337
|
const {
|
|
2245
2338
|
dataType: t,
|
|
2246
2339
|
timeRange: n,
|
|
2247
2340
|
sampleOffset: i = 0,
|
|
2248
2341
|
glBufferUsage: o = "static",
|
|
2249
2342
|
alignment: c = 0n,
|
|
2250
|
-
alignmentMultiple:
|
|
2343
|
+
alignmentMultiple: f = 1n,
|
|
2251
2344
|
key: w = ct(),
|
|
2252
2345
|
data: h
|
|
2253
2346
|
} = e;
|
|
2254
|
-
if (
|
|
2255
|
-
const
|
|
2256
|
-
this.key =
|
|
2347
|
+
if (zt(h)) {
|
|
2348
|
+
const d = h;
|
|
2349
|
+
this.key = d.key, this.dataType = d.dataType, this.sampleOffset = d.sampleOffset, this.gl = d.gl, this._data = d._data, this.timeRange = d.timeRange, this.alignment = d.alignment, this.alignmentMultiple = d.alignmentMultiple, this.cachedMin = d.cachedMin, this.cachedMax = d.cachedMax, this.writePos = d.writePos, this._refCount = d._refCount, this.cachedLength = d.cachedLength;
|
|
2257
2350
|
return;
|
|
2258
2351
|
}
|
|
2259
2352
|
const g = je(h), b = Array.isArray(h);
|
|
@@ -2264,24 +2357,24 @@ class M {
|
|
|
2264
2357
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
2265
2358
|
);
|
|
2266
2359
|
if (b || g) {
|
|
2267
|
-
let
|
|
2360
|
+
let d = h;
|
|
2268
2361
|
if (!g) {
|
|
2269
2362
|
if (h.length === 0)
|
|
2270
2363
|
throw new Error(
|
|
2271
2364
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
2272
2365
|
);
|
|
2273
|
-
|
|
2366
|
+
d = h[0];
|
|
2274
2367
|
}
|
|
2275
|
-
if (typeof
|
|
2276
|
-
else if (typeof
|
|
2277
|
-
else if (typeof
|
|
2278
|
-
else if (typeof
|
|
2279
|
-
else if (
|
|
2368
|
+
if (typeof d == "string") this.dataType = a.STRING;
|
|
2369
|
+
else if (typeof d == "number") this.dataType = a.FLOAT64;
|
|
2370
|
+
else if (typeof d == "bigint") this.dataType = a.INT64;
|
|
2371
|
+
else if (typeof d == "boolean") this.dataType = a.UINT8;
|
|
2372
|
+
else if (d instanceof u || d instanceof Date || d instanceof u)
|
|
2280
2373
|
this.dataType = a.TIMESTAMP;
|
|
2281
|
-
else if (typeof
|
|
2374
|
+
else if (typeof d == "object") this.dataType = a.JSON;
|
|
2282
2375
|
else
|
|
2283
2376
|
throw new Error(
|
|
2284
|
-
`cannot infer data type of ${typeof
|
|
2377
|
+
`cannot infer data type of ${typeof d} when constructing a Series from a JS array`
|
|
2285
2378
|
);
|
|
2286
2379
|
} else this.dataType = new a(h);
|
|
2287
2380
|
}
|
|
@@ -2289,21 +2382,21 @@ class M {
|
|
|
2289
2382
|
else if (b && h.length === 0)
|
|
2290
2383
|
this._data = new this.dataType.Array([]).buffer;
|
|
2291
2384
|
else {
|
|
2292
|
-
let
|
|
2293
|
-
const
|
|
2294
|
-
(
|
|
2385
|
+
let d = g ? [h] : h;
|
|
2386
|
+
const O = d[0];
|
|
2387
|
+
(O instanceof u || O instanceof Date || O instanceof l) && (d = d.map((N) => new u(N).valueOf())), this.dataType.equals(a.STRING) ? (this.cachedLength = d.length, this._data = new TextEncoder().encode(`${d.join(`
|
|
2295
2388
|
`)}
|
|
2296
|
-
`).buffer) : this.dataType.equals(a.JSON) ? (this.cachedLength =
|
|
2297
|
-
`${
|
|
2389
|
+
`).buffer) : this.dataType.equals(a.JSON) ? (this.cachedLength = d.length, this._data = new TextEncoder().encode(
|
|
2390
|
+
`${d.map((N) => ie.encodeString(N)).join(`
|
|
2298
2391
|
`)}
|
|
2299
2392
|
`
|
|
2300
|
-
).buffer) : this.dataType.usesBigInt && typeof
|
|
2301
|
-
|
|
2302
|
-
).buffer : !this.dataType.usesBigInt && typeof
|
|
2303
|
-
|
|
2304
|
-
).buffer : this._data = new this.dataType.Array(
|
|
2393
|
+
).buffer) : this.dataType.usesBigInt && typeof O == "number" ? this._data = new this.dataType.Array(
|
|
2394
|
+
d.map((N) => BigInt(Math.round(N)))
|
|
2395
|
+
).buffer : !this.dataType.usesBigInt && typeof O == "bigint" ? this._data = new this.dataType.Array(
|
|
2396
|
+
d.map(Number)
|
|
2397
|
+
).buffer : this._data = new this.dataType.Array(d).buffer;
|
|
2305
2398
|
}
|
|
2306
|
-
this.key = w, this.alignment = c, this.alignmentMultiple =
|
|
2399
|
+
this.key = w, this.alignment = c, this.alignmentMultiple = f, this.sampleOffset = i ?? 0, this.timeRange = n ?? S.ZERO, this.gl = {
|
|
2307
2400
|
control: null,
|
|
2308
2401
|
buffer: null,
|
|
2309
2402
|
prevBuffer: 0,
|
|
@@ -2320,7 +2413,7 @@ class M {
|
|
|
2320
2413
|
static alloc({ capacity: e, dataType: t, ...n }) {
|
|
2321
2414
|
if (e === 0)
|
|
2322
2415
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
2323
|
-
const i = new new a(t).Array(e), o = new
|
|
2416
|
+
const i = new new a(t).Array(e), o = new A({ data: i.buffer, dataType: t, ...n });
|
|
2324
2417
|
return o.writePos = 0, o;
|
|
2325
2418
|
}
|
|
2326
2419
|
/**
|
|
@@ -2468,7 +2561,7 @@ class M {
|
|
|
2468
2561
|
const n = new e.Array(this.length);
|
|
2469
2562
|
for (let i = 0; i < this.length; i++)
|
|
2470
2563
|
n[i] = Yt(this.dataType, e, this.data[i], t);
|
|
2471
|
-
return new
|
|
2564
|
+
return new A({
|
|
2472
2565
|
data: n.buffer,
|
|
2473
2566
|
dataType: e,
|
|
2474
2567
|
timeRange: this.timeRange,
|
|
@@ -2522,7 +2615,7 @@ class M {
|
|
|
2522
2615
|
}
|
|
2523
2616
|
/** @returns the bounds of the series. */
|
|
2524
2617
|
get bounds() {
|
|
2525
|
-
return
|
|
2618
|
+
return P(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
2526
2619
|
}
|
|
2527
2620
|
maybeRecomputeMinMax(e) {
|
|
2528
2621
|
if (this.cachedMin != null) {
|
|
@@ -2555,7 +2648,7 @@ class M {
|
|
|
2555
2648
|
}
|
|
2556
2649
|
atUUID(e, t) {
|
|
2557
2650
|
e < 0 && (e = this.length + e);
|
|
2558
|
-
const n =
|
|
2651
|
+
const n = Fe(
|
|
2559
2652
|
new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
|
|
2560
2653
|
);
|
|
2561
2654
|
if (n == null) {
|
|
@@ -2625,7 +2718,7 @@ class M {
|
|
|
2625
2718
|
), this.gl.prevBuffer = B;
|
|
2626
2719
|
}
|
|
2627
2720
|
as(e) {
|
|
2628
|
-
return
|
|
2721
|
+
return Vt(e, this.dataType), this;
|
|
2629
2722
|
}
|
|
2630
2723
|
/** @returns a digest containing information about the series. */
|
|
2631
2724
|
get digest() {
|
|
@@ -2653,7 +2746,7 @@ class M {
|
|
|
2653
2746
|
* is exclusive.
|
|
2654
2747
|
*/
|
|
2655
2748
|
get alignmentBounds() {
|
|
2656
|
-
return
|
|
2749
|
+
return P(
|
|
2657
2750
|
this.alignment,
|
|
2658
2751
|
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2659
2752
|
);
|
|
@@ -2674,9 +2767,9 @@ class M {
|
|
|
2674
2767
|
[Symbol.iterator]() {
|
|
2675
2768
|
if (this.dataType.isVariable) {
|
|
2676
2769
|
const e = new Jt(this);
|
|
2677
|
-
return this.dataType.equals(a.JSON) ? new
|
|
2770
|
+
return this.dataType.equals(a.JSON) ? new de(e) : e;
|
|
2678
2771
|
}
|
|
2679
|
-
return this.dataType.equals(a.UUID) ? new
|
|
2772
|
+
return this.dataType.equals(a.UUID) ? new Kt(this) : new Xt(this);
|
|
2680
2773
|
}
|
|
2681
2774
|
/**
|
|
2682
2775
|
* Returns a slice of the series from start to end.
|
|
@@ -2722,7 +2815,7 @@ class M {
|
|
|
2722
2815
|
subBytes(e, t) {
|
|
2723
2816
|
if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
|
|
2724
2817
|
const n = this.data.subarray(e, t);
|
|
2725
|
-
return new
|
|
2818
|
+
return new A({
|
|
2726
2819
|
data: n,
|
|
2727
2820
|
dataType: this.dataType,
|
|
2728
2821
|
timeRange: this.timeRange,
|
|
@@ -2734,7 +2827,7 @@ class M {
|
|
|
2734
2827
|
sliceSub(e, t, n) {
|
|
2735
2828
|
if (t <= 0 && (n == null || n >= this.length)) return this;
|
|
2736
2829
|
let i;
|
|
2737
|
-
return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new
|
|
2830
|
+
return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new A({
|
|
2738
2831
|
data: i,
|
|
2739
2832
|
dataType: this.dataType,
|
|
2740
2833
|
timeRange: this.timeRange,
|
|
@@ -2749,7 +2842,7 @@ class M {
|
|
|
2749
2842
|
* @returns A new series with the specified alignment.
|
|
2750
2843
|
*/
|
|
2751
2844
|
reAlign(e) {
|
|
2752
|
-
return new
|
|
2845
|
+
return new A({
|
|
2753
2846
|
data: this.buffer,
|
|
2754
2847
|
dataType: this.dataType,
|
|
2755
2848
|
timeRange: S.ZERO,
|
|
@@ -2776,15 +2869,15 @@ class M {
|
|
|
2776
2869
|
return e += "])", e;
|
|
2777
2870
|
}
|
|
2778
2871
|
}
|
|
2779
|
-
const
|
|
2872
|
+
const Ht = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof A ? !0 : je(r), zt = ht(qe, A);
|
|
2780
2873
|
class Ie {
|
|
2781
2874
|
series;
|
|
2782
2875
|
end;
|
|
2783
2876
|
index;
|
|
2784
2877
|
constructor(e, t, n) {
|
|
2785
2878
|
this.series = e;
|
|
2786
|
-
const i =
|
|
2787
|
-
this.end =
|
|
2879
|
+
const i = P(0, e.length + 1);
|
|
2880
|
+
this.end = Oe(i, n), this.index = Oe(i, t);
|
|
2788
2881
|
}
|
|
2789
2882
|
next() {
|
|
2790
2883
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
@@ -2808,7 +2901,7 @@ class Jt {
|
|
|
2808
2901
|
return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
|
|
2809
2902
|
}
|
|
2810
2903
|
}
|
|
2811
|
-
class
|
|
2904
|
+
class de {
|
|
2812
2905
|
wrapped;
|
|
2813
2906
|
static schema = s.record(s.string(), s.unknown());
|
|
2814
2907
|
constructor(e) {
|
|
@@ -2818,11 +2911,11 @@ class fe {
|
|
|
2818
2911
|
const e = this.wrapped.next();
|
|
2819
2912
|
return e.done === !0 ? { done: !0, value: void 0 } : {
|
|
2820
2913
|
done: !1,
|
|
2821
|
-
value: ie.decodeString(e.value,
|
|
2914
|
+
value: ie.decodeString(e.value, de.schema)
|
|
2822
2915
|
};
|
|
2823
2916
|
}
|
|
2824
2917
|
}
|
|
2825
|
-
class
|
|
2918
|
+
class Kt {
|
|
2826
2919
|
series;
|
|
2827
2920
|
index;
|
|
2828
2921
|
data;
|
|
@@ -2834,11 +2927,11 @@ class Xt {
|
|
|
2834
2927
|
}
|
|
2835
2928
|
next() {
|
|
2836
2929
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2837
|
-
const e =
|
|
2930
|
+
const e = Fe(this.data, this.index * this.density);
|
|
2838
2931
|
return this.index++, { done: !1, value: e };
|
|
2839
2932
|
}
|
|
2840
2933
|
}
|
|
2841
|
-
class
|
|
2934
|
+
class Xt {
|
|
2842
2935
|
series;
|
|
2843
2936
|
index;
|
|
2844
2937
|
constructor(e) {
|
|
@@ -2888,7 +2981,7 @@ const er = s.object({
|
|
|
2888
2981
|
__proto__: null,
|
|
2889
2982
|
Breaker: _t,
|
|
2890
2983
|
breakerConfigZ: er
|
|
2891
|
-
}, Symbol.toStringTag, { value: "Module" })), rr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ze = s.string().regex(rr), C = s.number().min(0).max(255),
|
|
2984
|
+
}, Symbol.toStringTag, { value: "Module" })), rr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ze = s.string().regex(rr), C = s.number().min(0).max(255), fe = s.number().min(0).max(1), We = s.tuple([C, C, C, fe]), nr = s.tuple([C, C, C]), sr = s.object({ rgba255: We }), ir = s.object({ r: C, g: C, b: C, a: fe }), ar = s.number().min(0).max(360), or = s.number().min(0).max(100), ur = s.number().min(0).max(100), lr = s.tuple([ar, or, ur, fe]), ge = s.union([Ze, nr, We, lr, sr, ir]), Ge = ge.transform((r) => me(r)), me = (r, e = 1) => {
|
|
2892
2985
|
if (r = ge.parse(r), typeof r == "string") return cr(r, e);
|
|
2893
2986
|
if (Array.isArray(r)) {
|
|
2894
2987
|
if (r.length < 3 || r.length > 4)
|
|
@@ -2904,22 +2997,22 @@ const er = s.object({
|
|
|
2904
2997
|
]), Q = (r, e) => parseInt(r.slice(e, e + 2), 16), hr = (r) => r.startsWith("#") ? r.slice(1) : r;
|
|
2905
2998
|
me("#000000");
|
|
2906
2999
|
me("#ffffff");
|
|
2907
|
-
const
|
|
3000
|
+
const dr = s.object({
|
|
2908
3001
|
key: s.string(),
|
|
2909
3002
|
color: ge,
|
|
2910
3003
|
position: s.number(),
|
|
2911
3004
|
switched: s.boolean().optional()
|
|
2912
3005
|
});
|
|
2913
|
-
s.array(
|
|
2914
|
-
const
|
|
3006
|
+
s.array(dr);
|
|
3007
|
+
const fr = s.object({
|
|
2915
3008
|
key: s.string(),
|
|
2916
3009
|
name: s.string(),
|
|
2917
|
-
color:
|
|
3010
|
+
color: Ge
|
|
2918
3011
|
});
|
|
2919
3012
|
s.object({
|
|
2920
3013
|
key: s.string(),
|
|
2921
3014
|
name: s.string(),
|
|
2922
|
-
swatches: s.array(
|
|
3015
|
+
swatches: s.array(fr)
|
|
2923
3016
|
});
|
|
2924
3017
|
s.int().min(0).max(255);
|
|
2925
3018
|
s.object({
|
|
@@ -2933,29 +3026,29 @@ const gr = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), mr = (r,
|
|
|
2933
3026
|
Object.defineProperty(globalThis, t, { value: n });
|
|
2934
3027
|
}
|
|
2935
3028
|
return () => globalThis[t];
|
|
2936
|
-
},
|
|
2937
|
-
static discriminator =
|
|
2938
|
-
discriminator =
|
|
3029
|
+
}, Ve = "sy_x_error", yr = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), z = (r) => class W extends Error {
|
|
3030
|
+
static discriminator = Ve;
|
|
3031
|
+
discriminator = W.discriminator;
|
|
2939
3032
|
static TYPE = r;
|
|
2940
|
-
type =
|
|
3033
|
+
type = W.TYPE;
|
|
2941
3034
|
static matches = yr(r);
|
|
2942
|
-
matches =
|
|
3035
|
+
matches = W.matches;
|
|
2943
3036
|
constructor(t, n) {
|
|
2944
|
-
super(t, n), this.name =
|
|
3037
|
+
super(t, n), this.name = W.TYPE;
|
|
2945
3038
|
}
|
|
2946
3039
|
static sub(t) {
|
|
2947
|
-
return
|
|
3040
|
+
return z(`${r}.${t}`);
|
|
2948
3041
|
}
|
|
2949
|
-
},
|
|
3042
|
+
}, He = (r) => {
|
|
2950
3043
|
if (r == null || typeof r != "object") return !1;
|
|
2951
3044
|
const e = r;
|
|
2952
|
-
if (e.discriminator !==
|
|
3045
|
+
if (e.discriminator !== Ve) return !1;
|
|
2953
3046
|
if (!("type" in e))
|
|
2954
3047
|
throw new Error(
|
|
2955
3048
|
`X Error is missing its type property: ${JSON.stringify(e)}`
|
|
2956
3049
|
);
|
|
2957
3050
|
return !0;
|
|
2958
|
-
},
|
|
3051
|
+
}, k = "unknown", ue = "nil";
|
|
2959
3052
|
class pr {
|
|
2960
3053
|
providers = [];
|
|
2961
3054
|
register(e) {
|
|
@@ -2963,22 +3056,22 @@ class pr {
|
|
|
2963
3056
|
}
|
|
2964
3057
|
encode(e) {
|
|
2965
3058
|
if (e == null) return { type: ue, data: "" };
|
|
2966
|
-
if (
|
|
3059
|
+
if (He(e))
|
|
2967
3060
|
for (const t of this.providers) {
|
|
2968
3061
|
const n = t.encode(e);
|
|
2969
3062
|
if (n != null) return n;
|
|
2970
3063
|
}
|
|
2971
|
-
if (e instanceof Error) return { type:
|
|
2972
|
-
if (typeof e == "string") return { type:
|
|
3064
|
+
if (e instanceof Error) return { type: k, data: e.message };
|
|
3065
|
+
if (typeof e == "string") return { type: k, data: e };
|
|
2973
3066
|
try {
|
|
2974
|
-
return { type:
|
|
3067
|
+
return { type: k, data: JSON.stringify(e) };
|
|
2975
3068
|
} catch {
|
|
2976
|
-
return { type:
|
|
3069
|
+
return { type: k, data: "unable to encode error information" };
|
|
2977
3070
|
}
|
|
2978
3071
|
}
|
|
2979
3072
|
decode(e) {
|
|
2980
3073
|
if (e == null || e.type === ue) return null;
|
|
2981
|
-
if (e.type ===
|
|
3074
|
+
if (e.type === k) return new le(e.data);
|
|
2982
3075
|
for (const t of this.providers) {
|
|
2983
3076
|
const n = t.decode(e);
|
|
2984
3077
|
if (n != null) return n;
|
|
@@ -2986,34 +3079,37 @@ class pr {
|
|
|
2986
3079
|
return new le(e.data);
|
|
2987
3080
|
}
|
|
2988
3081
|
}
|
|
2989
|
-
const ye = mr("synnax-error-registry", () => new pr()), wr = ({ encode: r, decode: e }) => ye().register({ encode: r, decode: e }), br = (r) => ye().encode(r),
|
|
2990
|
-
class le extends
|
|
3082
|
+
const ye = mr("synnax-error-registry", () => new pr()), wr = ({ encode: r, decode: e }) => ye().register({ encode: r, decode: e }), br = (r) => ye().encode(r), Or = (r) => r == null ? null : ye().decode(r);
|
|
3083
|
+
class le extends z("unknown") {
|
|
2991
3084
|
}
|
|
2992
|
-
const
|
|
2993
|
-
class vr extends
|
|
3085
|
+
const Tr = s.object({ type: s.string(), data: s.string() });
|
|
3086
|
+
class vr extends z("canceled") {
|
|
2994
3087
|
}
|
|
2995
|
-
class Sr extends
|
|
3088
|
+
class Sr extends z("not_implemented") {
|
|
2996
3089
|
}
|
|
2997
|
-
const
|
|
3090
|
+
const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2998
3091
|
__proto__: null,
|
|
2999
3092
|
Canceled: vr,
|
|
3000
3093
|
NONE: ue,
|
|
3001
3094
|
NotImplemented: Sr,
|
|
3002
|
-
UNKNOWN:
|
|
3095
|
+
UNKNOWN: k,
|
|
3003
3096
|
Unknown: le,
|
|
3004
|
-
createTyped:
|
|
3005
|
-
decode:
|
|
3097
|
+
createTyped: z,
|
|
3098
|
+
decode: Or,
|
|
3006
3099
|
encode: br,
|
|
3007
|
-
isTyped:
|
|
3008
|
-
payloadZ:
|
|
3100
|
+
isTyped: He,
|
|
3101
|
+
payloadZ: Tr,
|
|
3009
3102
|
register: wr
|
|
3010
3103
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3104
|
+
s.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/, "must be a valid JSON pointer (RFC 6901)");
|
|
3105
|
+
s.union([s.string(), s.number(), s.boolean(), s.null()]);
|
|
3106
|
+
s.enum(["string", "number", "boolean", "null"]);
|
|
3011
3107
|
s.object({ key: s.string(), value: s.string() });
|
|
3012
3108
|
const Ir = Y.uuid();
|
|
3013
3109
|
Y.object({
|
|
3014
3110
|
key: Ir,
|
|
3015
3111
|
name: Y.string().min(1),
|
|
3016
|
-
color:
|
|
3112
|
+
color: Ge
|
|
3017
3113
|
});
|
|
3018
3114
|
s.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);
|
|
3019
3115
|
const Nr = ["standard", "scientific", "engineering"];
|
|
@@ -3022,13 +3118,13 @@ const Er = s.union([s.string(), s.number()]);
|
|
|
3022
3118
|
s.record(Er, s.unknown());
|
|
3023
3119
|
const xr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
|
|
3024
3120
|
xr();
|
|
3025
|
-
const
|
|
3121
|
+
const Mr = ["macOS", "Windows", "Linux"], Ur = ["macos", "windows", "linux"], Ar = {
|
|
3026
3122
|
macos: "macOS",
|
|
3027
3123
|
windows: "Windows",
|
|
3028
3124
|
linux: "Linux"
|
|
3029
3125
|
};
|
|
3030
|
-
s.enum(
|
|
3031
|
-
s.enum(
|
|
3126
|
+
s.enum(Mr).or(
|
|
3127
|
+
s.enum(Ur).transform((r) => Ar[r])
|
|
3032
3128
|
);
|
|
3033
3129
|
s.enum([
|
|
3034
3130
|
"success",
|
|
@@ -3042,8 +3138,8 @@ s.object({
|
|
|
3042
3138
|
stack: s.string(),
|
|
3043
3139
|
error: s.instanceof(Error)
|
|
3044
3140
|
});
|
|
3045
|
-
const Cr = (...r) => r.map(
|
|
3046
|
-
class
|
|
3141
|
+
const Cr = (...r) => r.map(ze).join(""), ze = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Br = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Dr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
|
|
3142
|
+
class G {
|
|
3047
3143
|
protocol;
|
|
3048
3144
|
host;
|
|
3049
3145
|
port;
|
|
@@ -3055,7 +3151,7 @@ class V {
|
|
|
3055
3151
|
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
3056
3152
|
*/
|
|
3057
3153
|
constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
|
|
3058
|
-
this.protocol = n, this.host = e, this.port = t, this.path =
|
|
3154
|
+
this.protocol = n, this.host = e, this.port = t, this.path = ze(i);
|
|
3059
3155
|
}
|
|
3060
3156
|
/**
|
|
3061
3157
|
* Replaces creates a new URL with the specified properties replaced.
|
|
@@ -3063,7 +3159,7 @@ class V {
|
|
|
3063
3159
|
* @returns a new URL.
|
|
3064
3160
|
*/
|
|
3065
3161
|
replace(e) {
|
|
3066
|
-
return new
|
|
3162
|
+
return new G({
|
|
3067
3163
|
host: e.host ?? this.host,
|
|
3068
3164
|
port: e.port ?? this.port,
|
|
3069
3165
|
protocol: e.protocol ?? this.protocol,
|
|
@@ -3076,7 +3172,7 @@ class V {
|
|
|
3076
3172
|
* @returns a new URL.
|
|
3077
3173
|
*/
|
|
3078
3174
|
child(e) {
|
|
3079
|
-
return new
|
|
3175
|
+
return new G({
|
|
3080
3176
|
...this,
|
|
3081
3177
|
pathPrefix: Cr(this.path, e)
|
|
3082
3178
|
});
|
|
@@ -3087,51 +3183,51 @@ class V {
|
|
|
3087
3183
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
3088
3184
|
);
|
|
3089
3185
|
}
|
|
3090
|
-
static UNKNOWN = new
|
|
3186
|
+
static UNKNOWN = new G({ host: "unknown", port: 0 });
|
|
3091
3187
|
}
|
|
3092
|
-
s.int().min(0).max(
|
|
3093
|
-
class J extends
|
|
3188
|
+
s.int().min(0).max(dt);
|
|
3189
|
+
class J extends R.createTyped("freighter") {
|
|
3094
3190
|
}
|
|
3095
3191
|
class j extends J.sub("eof") {
|
|
3096
3192
|
constructor() {
|
|
3097
3193
|
super("EOF");
|
|
3098
3194
|
}
|
|
3099
3195
|
}
|
|
3100
|
-
class
|
|
3196
|
+
class F extends J.sub("stream_closed") {
|
|
3101
3197
|
constructor() {
|
|
3102
3198
|
super("StreamClosed");
|
|
3103
3199
|
}
|
|
3104
3200
|
}
|
|
3105
|
-
class
|
|
3201
|
+
class q extends J.sub("unreachable") {
|
|
3106
3202
|
url;
|
|
3107
3203
|
constructor(e = {}) {
|
|
3108
|
-
const { message: t = "Unreachable", url: n =
|
|
3204
|
+
const { message: t = "Unreachable", url: n = G.UNKNOWN } = e;
|
|
3109
3205
|
super(t), this.url = n;
|
|
3110
3206
|
}
|
|
3111
3207
|
}
|
|
3112
|
-
const
|
|
3208
|
+
const Rr = (r) => {
|
|
3113
3209
|
if (!r.type.startsWith(J.TYPE)) return null;
|
|
3114
3210
|
if (j.matches(r)) return { type: j.TYPE, data: "EOF" };
|
|
3115
|
-
if (q.matches(r))
|
|
3116
|
-
return { type: q.TYPE, data: "StreamClosed" };
|
|
3117
3211
|
if (F.matches(r))
|
|
3118
|
-
return { type: F.TYPE, data: "
|
|
3212
|
+
return { type: F.TYPE, data: "StreamClosed" };
|
|
3213
|
+
if (q.matches(r))
|
|
3214
|
+
return { type: q.TYPE, data: "Unreachable" };
|
|
3119
3215
|
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
3120
3216
|
}, $r = (r) => {
|
|
3121
3217
|
if (!r.type.startsWith(J.TYPE)) return null;
|
|
3122
3218
|
switch (r.type) {
|
|
3123
3219
|
case j.TYPE:
|
|
3124
3220
|
return new j();
|
|
3125
|
-
case q.TYPE:
|
|
3126
|
-
return new q();
|
|
3127
3221
|
case F.TYPE:
|
|
3128
3222
|
return new F();
|
|
3223
|
+
case q.TYPE:
|
|
3224
|
+
return new q();
|
|
3129
3225
|
default:
|
|
3130
|
-
throw new
|
|
3226
|
+
throw new R.Unknown(`Unknown error type: ${r.data}`);
|
|
3131
3227
|
}
|
|
3132
3228
|
};
|
|
3133
|
-
|
|
3134
|
-
encode:
|
|
3229
|
+
R.register({
|
|
3230
|
+
encode: Rr,
|
|
3135
3231
|
decode: $r
|
|
3136
3232
|
});
|
|
3137
3233
|
class Je {
|
|
@@ -3159,14 +3255,14 @@ class Je {
|
|
|
3159
3255
|
return await i(e);
|
|
3160
3256
|
}
|
|
3161
3257
|
}
|
|
3162
|
-
const
|
|
3258
|
+
const Ke = "Content-Type", Lr = /* @__PURE__ */ new Set([
|
|
3163
3259
|
"ECONNREFUSED",
|
|
3164
3260
|
"ECONNRESET",
|
|
3165
3261
|
"ETIMEDOUT",
|
|
3166
3262
|
"EPIPE",
|
|
3167
3263
|
"UND_ERR_CONNECT_TIMEOUT",
|
|
3168
3264
|
"UND_ERR_SOCKET"
|
|
3169
|
-
]),
|
|
3265
|
+
]), Pr = (r) => {
|
|
3170
3266
|
const e = r?.cause?.code ?? r?.code ?? r?.errno;
|
|
3171
3267
|
if (typeof e == "string" && Lr.has(e)) return !0;
|
|
3172
3268
|
if (r.name === "TypeError") {
|
|
@@ -3175,8 +3271,8 @@ const Xe = "Content-Type", Lr = /* @__PURE__ */ new Set([
|
|
|
3175
3271
|
return typeof navigator < "u" && navigator.onLine === !1, !0;
|
|
3176
3272
|
}
|
|
3177
3273
|
return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
|
|
3178
|
-
},
|
|
3179
|
-
class
|
|
3274
|
+
}, kr = 400;
|
|
3275
|
+
class Wr extends Je {
|
|
3180
3276
|
endpoint;
|
|
3181
3277
|
encoder;
|
|
3182
3278
|
constructor(e, t, n = !1) {
|
|
@@ -3186,14 +3282,14 @@ class Gr extends Je {
|
|
|
3186
3282
|
}
|
|
3187
3283
|
get headers() {
|
|
3188
3284
|
return {
|
|
3189
|
-
[
|
|
3285
|
+
[Ke]: this.encoder.contentType
|
|
3190
3286
|
};
|
|
3191
3287
|
}
|
|
3192
3288
|
async send(e, t, n, i) {
|
|
3193
3289
|
t = n?.parse(t);
|
|
3194
3290
|
let o = null;
|
|
3195
|
-
const c = this.endpoint.child(e),
|
|
3196
|
-
|
|
3291
|
+
const c = this.endpoint.child(e), f = {};
|
|
3292
|
+
f.method = "POST", f.body = this.encoder.encode(t ?? {});
|
|
3197
3293
|
const [, w] = await this.executeMiddleware(
|
|
3198
3294
|
{
|
|
3199
3295
|
target: c.toString(),
|
|
@@ -3203,30 +3299,30 @@ class Gr extends Je {
|
|
|
3203
3299
|
},
|
|
3204
3300
|
async (h) => {
|
|
3205
3301
|
const g = { ...h, params: {} };
|
|
3206
|
-
|
|
3302
|
+
f.headers = {
|
|
3207
3303
|
...this.headers,
|
|
3208
3304
|
...h.params
|
|
3209
3305
|
};
|
|
3210
3306
|
let b;
|
|
3211
3307
|
try {
|
|
3212
|
-
b = await fetch(h.target,
|
|
3213
|
-
} catch (
|
|
3214
|
-
if (!(
|
|
3215
|
-
return [g,
|
|
3308
|
+
b = await fetch(h.target, f);
|
|
3309
|
+
} catch (O) {
|
|
3310
|
+
if (!(O instanceof Error)) throw O;
|
|
3311
|
+
return [g, Pr(O) ? new q({ url: c }) : O];
|
|
3216
3312
|
}
|
|
3217
|
-
const
|
|
3313
|
+
const d = await b.arrayBuffer();
|
|
3218
3314
|
if (b?.ok)
|
|
3219
|
-
return i != null && (o = this.encoder.decode(
|
|
3315
|
+
return i != null && (o = this.encoder.decode(d, i)), [g, null];
|
|
3220
3316
|
try {
|
|
3221
|
-
if (b.status !==
|
|
3317
|
+
if (b.status !== kr)
|
|
3222
3318
|
return [g, new Error(b.statusText)];
|
|
3223
|
-
const
|
|
3319
|
+
const O = this.encoder.decode(d, R.payloadZ), N = R.decode(O);
|
|
3224
3320
|
return [g, N];
|
|
3225
|
-
} catch (
|
|
3321
|
+
} catch (O) {
|
|
3226
3322
|
return [
|
|
3227
3323
|
g,
|
|
3228
3324
|
new Error(
|
|
3229
|
-
`[freighter] - failed to decode error: ${b.statusText}: ${
|
|
3325
|
+
`[freighter] - failed to decode error: ${b.statusText}: ${O.message}`
|
|
3230
3326
|
)
|
|
3231
3327
|
];
|
|
3232
3328
|
}
|
|
@@ -3237,7 +3333,7 @@ class Gr extends Je {
|
|
|
3237
3333
|
return [o, null];
|
|
3238
3334
|
}
|
|
3239
3335
|
}
|
|
3240
|
-
const
|
|
3336
|
+
const Gr = (r, e) => {
|
|
3241
3337
|
class t {
|
|
3242
3338
|
wrapped;
|
|
3243
3339
|
constructor(i) {
|
|
@@ -3246,25 +3342,25 @@ const Vr = (r, e) => {
|
|
|
3246
3342
|
use(...i) {
|
|
3247
3343
|
this.wrapped.use(...i);
|
|
3248
3344
|
}
|
|
3249
|
-
async send(i, o, c,
|
|
3345
|
+
async send(i, o, c, f) {
|
|
3250
3346
|
const w = new tr.Breaker(e);
|
|
3251
3347
|
do {
|
|
3252
|
-
const [h, g] = await this.wrapped.send(i, o, c,
|
|
3348
|
+
const [h, g] = await this.wrapped.send(i, o, c, f);
|
|
3253
3349
|
if (g == null) return [h, null];
|
|
3254
|
-
if (!
|
|
3350
|
+
if (!q.matches(g)) return [null, g];
|
|
3255
3351
|
if (console.warn(`[freighter] ${w.retryMessage}`, g), !await w.wait()) return [h, g];
|
|
3256
3352
|
} while (!0);
|
|
3257
3353
|
}
|
|
3258
3354
|
}
|
|
3259
3355
|
return new t(r);
|
|
3260
|
-
},
|
|
3356
|
+
}, Vr = async (r, e, t, n, i) => {
|
|
3261
3357
|
const [o, c] = await r.send(e, t, n, i);
|
|
3262
3358
|
if (c != null) throw c;
|
|
3263
3359
|
return o;
|
|
3264
3360
|
}, Yr = s.object({
|
|
3265
3361
|
type: s.enum(["data", "close", "open"]),
|
|
3266
3362
|
payload: s.unknown(),
|
|
3267
|
-
error: s.optional(
|
|
3363
|
+
error: s.optional(R.payloadZ)
|
|
3268
3364
|
});
|
|
3269
3365
|
class jr {
|
|
3270
3366
|
codec;
|
|
@@ -3282,14 +3378,14 @@ class jr {
|
|
|
3282
3378
|
const e = await this.receiveMsg();
|
|
3283
3379
|
if (e.type !== "open") {
|
|
3284
3380
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3285
|
-
return
|
|
3381
|
+
return R.decode(e.error);
|
|
3286
3382
|
}
|
|
3287
3383
|
return null;
|
|
3288
3384
|
}
|
|
3289
3385
|
/** Implements the Stream protocol */
|
|
3290
3386
|
send(e) {
|
|
3291
3387
|
if (this.serverClosed != null) return new j();
|
|
3292
|
-
if (this.sendClosed) throw new
|
|
3388
|
+
if (this.sendClosed) throw new F();
|
|
3293
3389
|
return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
|
|
3294
3390
|
}
|
|
3295
3391
|
/** Implements the Stream protocol */
|
|
@@ -3298,7 +3394,7 @@ class jr {
|
|
|
3298
3394
|
const e = await this.receiveMsg();
|
|
3299
3395
|
if (e.type === "close") {
|
|
3300
3396
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3301
|
-
if (this.serverClosed =
|
|
3397
|
+
if (this.serverClosed = R.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
|
|
3302
3398
|
return [null, this.serverClosed];
|
|
3303
3399
|
}
|
|
3304
3400
|
return [this.resSchema.parse(e.payload), null];
|
|
@@ -3337,13 +3433,13 @@ class jr {
|
|
|
3337
3433
|
this.addMessage({
|
|
3338
3434
|
type: "close",
|
|
3339
3435
|
error: {
|
|
3340
|
-
type: e.code ===
|
|
3436
|
+
type: e.code === qr ? j.TYPE : F.TYPE,
|
|
3341
3437
|
data: ""
|
|
3342
3438
|
}
|
|
3343
3439
|
});
|
|
3344
3440
|
}
|
|
3345
3441
|
}
|
|
3346
|
-
const
|
|
3442
|
+
const Fr = "freighterctx", qr = 1e3;
|
|
3347
3443
|
class ce extends Je {
|
|
3348
3444
|
baseUrl;
|
|
3349
3445
|
encoder;
|
|
@@ -3367,9 +3463,9 @@ class ce extends Je {
|
|
|
3367
3463
|
const [, o] = await this.executeMiddleware(
|
|
3368
3464
|
{ target: e, protocol: "websocket", params: {}, role: "client" },
|
|
3369
3465
|
async (c) => {
|
|
3370
|
-
const
|
|
3371
|
-
|
|
3372
|
-
const h = await this.wrapSocket(
|
|
3466
|
+
const f = new WebSocket(this.buildURL(e, c)), w = { ...c, params: {} };
|
|
3467
|
+
f.binaryType = ce.MESSAGE_TYPE;
|
|
3468
|
+
const h = await this.wrapSocket(f, t, n);
|
|
3373
3469
|
return h instanceof Error ? [w, h] : (i = h, [w, null]);
|
|
3374
3470
|
}
|
|
3375
3471
|
);
|
|
@@ -3377,12 +3473,12 @@ class ce extends Je {
|
|
|
3377
3473
|
return i;
|
|
3378
3474
|
}
|
|
3379
3475
|
buildURL(e, t) {
|
|
3380
|
-
const n =
|
|
3476
|
+
const n = Dr(
|
|
3381
3477
|
{
|
|
3382
|
-
[
|
|
3478
|
+
[Ke]: this.encoder.contentType,
|
|
3383
3479
|
...t.params
|
|
3384
3480
|
},
|
|
3385
|
-
|
|
3481
|
+
Fr
|
|
3386
3482
|
);
|
|
3387
3483
|
return this.baseUrl.child(e).toString() + n;
|
|
3388
3484
|
}
|
|
@@ -3402,10 +3498,10 @@ class ce extends Je {
|
|
|
3402
3498
|
}
|
|
3403
3499
|
export {
|
|
3404
3500
|
j as EOF,
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3501
|
+
Wr as HTTPClient,
|
|
3502
|
+
F as StreamClosed,
|
|
3503
|
+
q as Unreachable,
|
|
3408
3504
|
ce as WebSocketClient,
|
|
3409
|
-
|
|
3410
|
-
|
|
3505
|
+
Vr as sendRequired,
|
|
3506
|
+
Gr as unaryWithBreaker
|
|
3411
3507
|
};
|