@synnaxlabs/freighter 0.44.0 → 0.44.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/freighter.cjs +4 -4
- package/dist/freighter.js +1094 -937
- package/dist/http.d.ts +1 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/unary.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/http.ts +32 -5
- package/src/unary.ts +1 -0
package/dist/freighter.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
const e =
|
|
1
|
+
import O, { z as s } from "zod";
|
|
2
|
+
const Xe = (r) => {
|
|
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
|
-
},
|
|
6
|
-
const e = (t,
|
|
7
|
-
if (typeof t == "string") return
|
|
8
|
-
if (Array.isArray(t)) return t.map((
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
const i = {},
|
|
12
|
-
return "toJSON" in
|
|
13
|
-
let d =
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
return
|
|
18
|
-
}))), i[
|
|
5
|
+
}, Se = (r) => {
|
|
6
|
+
const e = (t, n = ie) => {
|
|
7
|
+
if (typeof t == "string") return r(t);
|
|
8
|
+
if (Array.isArray(t)) return t.map((c) => e(c, n));
|
|
9
|
+
if (!re(t)) return t;
|
|
10
|
+
n = et(n);
|
|
11
|
+
const i = {}, a = t;
|
|
12
|
+
return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), n) : (Object.keys(a).forEach((c) => {
|
|
13
|
+
let d = a[c];
|
|
14
|
+
const y = r(c);
|
|
15
|
+
n.recursive && (re(d) ? ye(d) || (d = e(d, n)) : n.recursiveInArray && me(d) && (d = [...d].map((f) => {
|
|
16
|
+
let p = f;
|
|
17
|
+
return re(f) ? ye(p) || (p = e(f, n)) : me(f) && (p = e({ key: f }, n).key), p;
|
|
18
|
+
}))), i[y] = d;
|
|
19
19
|
}), i);
|
|
20
20
|
};
|
|
21
21
|
return e;
|
|
22
|
-
},
|
|
22
|
+
}, Ee = Se(Xe), Ke = (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(
|
|
26
26
|
/([a-z0-9])([A-Z])/g,
|
|
27
|
-
(e, t,
|
|
27
|
+
(e, t, n) => `${t}_${n.toLowerCase()}`
|
|
28
28
|
)
|
|
29
|
-
),
|
|
29
|
+
), Qe = Se(Ke), _e = [Number, String, Uint8Array], ie = {
|
|
30
30
|
recursive: !0,
|
|
31
31
|
recursiveInArray: !0
|
|
32
|
-
},
|
|
33
|
-
let
|
|
32
|
+
}, et = (r = ie) => (r.recursive == null ? r = ie : r.recursiveInArray ??= !1, r), me = (r) => r != null && Array.isArray(r), re = (r) => r != null && typeof r == "object" && !Array.isArray(r), ye = (r) => _e.some((e) => r instanceof e);
|
|
33
|
+
let tt = class {
|
|
34
34
|
contentType = "application/json";
|
|
35
35
|
decoder;
|
|
36
36
|
encoder;
|
|
@@ -44,16 +44,16 @@ let Ge = class {
|
|
|
44
44
|
return this.decodeString(this.decoder.decode(e), t);
|
|
45
45
|
}
|
|
46
46
|
decodeString(e, t) {
|
|
47
|
-
const
|
|
47
|
+
const n = JSON.parse(e), i = Ee(n);
|
|
48
48
|
return t != null ? t.parse(i) : i;
|
|
49
49
|
}
|
|
50
50
|
encodeString(e) {
|
|
51
|
-
const t =
|
|
52
|
-
return JSON.stringify(t, (
|
|
51
|
+
const t = Qe(e);
|
|
52
|
+
return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
const
|
|
56
|
-
let
|
|
55
|
+
const ae = new tt();
|
|
56
|
+
let q = class {
|
|
57
57
|
/** The underlying primitive value */
|
|
58
58
|
value;
|
|
59
59
|
constructor(e) {
|
|
@@ -73,152 +73,162 @@ let j = class {
|
|
|
73
73
|
return this.value.toString();
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
const
|
|
77
|
-
const t =
|
|
78
|
-
let
|
|
76
|
+
const rt = (r) => r != null && typeof r == "object" && "toString" in r, nt = (r, e = !1) => {
|
|
77
|
+
const t = rt(r) ? "stringer" : typeof r;
|
|
78
|
+
let n;
|
|
79
79
|
switch (t) {
|
|
80
80
|
case "string":
|
|
81
|
-
|
|
81
|
+
n = (i, a) => i.localeCompare(a);
|
|
82
82
|
break;
|
|
83
83
|
case "stringer":
|
|
84
|
-
|
|
84
|
+
n = (i, a) => i.toString().localeCompare(a.toString());
|
|
85
85
|
break;
|
|
86
86
|
case "number":
|
|
87
|
-
|
|
87
|
+
n = (i, a) => Number(i) - Number(a);
|
|
88
88
|
break;
|
|
89
89
|
case "bigint":
|
|
90
|
-
|
|
90
|
+
n = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
|
|
91
91
|
break;
|
|
92
92
|
case "boolean":
|
|
93
|
-
|
|
93
|
+
n = (i, a) => Number(i) - Number(a);
|
|
94
94
|
break;
|
|
95
95
|
case "undefined":
|
|
96
|
-
|
|
96
|
+
n = () => 0;
|
|
97
97
|
break;
|
|
98
98
|
default:
|
|
99
99
|
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
100
100
|
}
|
|
101
|
-
return e ?
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
signedWidth:
|
|
106
|
-
signedHeight:
|
|
107
|
-
}),
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
101
|
+
return e ? st(n) : n;
|
|
102
|
+
}, st = (r) => (e, t) => r(t, e), K = s.tuple([s.number(), s.number()]);
|
|
103
|
+
s.tuple([s.bigint(), s.bigint()]);
|
|
104
|
+
const xe = s.object({ width: s.number(), height: s.number() }), it = s.object({
|
|
105
|
+
signedWidth: s.number(),
|
|
106
|
+
signedHeight: s.number()
|
|
107
|
+
}), at = ["width", "height"];
|
|
108
|
+
s.enum(at);
|
|
109
|
+
const ot = ["start", "center", "end"], ut = ["signedWidth", "signedHeight"];
|
|
110
|
+
s.enum(ut);
|
|
111
|
+
const X = s.object({ x: s.number(), y: s.number() }), lt = s.object({ clientX: s.number(), clientY: s.number() }), ct = ["x", "y"], Ae = s.enum(ct), Ue = ["top", "right", "bottom", "left"];
|
|
112
|
+
s.enum(Ue);
|
|
113
|
+
const ht = ["left", "right"], Me = s.enum(ht), ft = ["top", "bottom"], Ce = s.enum(ft), $e = ["center"], we = s.enum($e), dt = [...Ue, ...$e], Be = s.enum(dt);
|
|
114
|
+
s.enum(ot);
|
|
115
|
+
const gt = ["first", "last"];
|
|
116
|
+
s.enum(gt);
|
|
117
|
+
const pt = s.object({ lower: s.number(), upper: s.number() }), mt = s.object({ lower: s.bigint(), upper: s.bigint() });
|
|
118
|
+
s.union([pt, K]);
|
|
119
|
+
s.union([mt, K]);
|
|
120
|
+
s.enum([...Ae.options, ...Be.options]);
|
|
121
|
+
s.enum(["x", "left", "right"]);
|
|
122
|
+
s.enum(["y", "top", "bottom"]);
|
|
123
|
+
s.union([Ae, Be, s.instanceof(String)]);
|
|
124
|
+
const Q = (r) => (e, t) => {
|
|
125
|
+
if (typeof e == "bigint") {
|
|
126
|
+
if (yt(t))
|
|
127
|
+
return r(e, BigInt(t));
|
|
128
|
+
const n = r(Number(e), Number(t));
|
|
129
|
+
return typeof n == "number" ? BigInt(Math.round(n)) : n;
|
|
130
|
+
}
|
|
131
|
+
return r(Number(e), Number(t));
|
|
132
|
+
}, _ = Q((r, e) => r - e), ee = Q((r, e) => r + e), yt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), U = Q((r, e) => r * e), te = Q((r, e) => r / e), R = (r, e, t) => {
|
|
133
|
+
const n = {};
|
|
134
|
+
if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
|
|
135
|
+
e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
|
|
136
|
+
else if (Array.isArray(r)) {
|
|
137
|
+
if (r.length !== 2) throw new Error("bounds: expected array of length 2");
|
|
138
|
+
[n.lower, n.upper] = r;
|
|
129
139
|
} else
|
|
130
|
-
|
|
131
|
-
return t?.makeValid ?
|
|
132
|
-
},
|
|
133
|
-
const t =
|
|
140
|
+
n.lower = r.lower, n.upper = r.upper;
|
|
141
|
+
return t?.makeValid ? wt(n) : n;
|
|
142
|
+
}, wt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, be = (r, e) => {
|
|
143
|
+
const t = R(r);
|
|
134
144
|
return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
|
|
135
145
|
};
|
|
136
|
-
|
|
137
|
-
x:
|
|
138
|
-
y:
|
|
146
|
+
s.object({
|
|
147
|
+
x: Me.or(we),
|
|
148
|
+
y: Ce.or(we)
|
|
139
149
|
});
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
]),
|
|
148
|
-
if (typeof
|
|
150
|
+
const bt = s.object({ x: Me, y: Ce }), Ot = Object.freeze({ x: "left", y: "top" }), Tt = (r, e) => r.x === e.x && r.y === e.y, Oe = s.union([
|
|
151
|
+
s.number(),
|
|
152
|
+
X,
|
|
153
|
+
K,
|
|
154
|
+
xe,
|
|
155
|
+
it,
|
|
156
|
+
lt
|
|
157
|
+
]), vt = (r, e) => {
|
|
158
|
+
if (typeof r == "string") {
|
|
149
159
|
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
return typeof
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
top:
|
|
156
|
-
left:
|
|
157
|
-
width:
|
|
158
|
-
height:
|
|
160
|
+
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
161
|
+
}
|
|
162
|
+
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 };
|
|
163
|
+
}, Te = Object.freeze({ x: 0, y: 0 }), G = s.union([s.number(), s.string()]);
|
|
164
|
+
s.object({
|
|
165
|
+
top: G,
|
|
166
|
+
left: G,
|
|
167
|
+
width: G,
|
|
168
|
+
height: G
|
|
159
169
|
});
|
|
160
|
-
|
|
161
|
-
left:
|
|
162
|
-
top:
|
|
163
|
-
right:
|
|
164
|
-
bottom:
|
|
170
|
+
s.object({
|
|
171
|
+
left: s.number(),
|
|
172
|
+
top: s.number(),
|
|
173
|
+
right: s.number(),
|
|
174
|
+
bottom: s.number()
|
|
165
175
|
});
|
|
166
|
-
|
|
167
|
-
one:
|
|
168
|
-
two:
|
|
169
|
-
root:
|
|
176
|
+
s.object({
|
|
177
|
+
one: X,
|
|
178
|
+
two: X,
|
|
179
|
+
root: bt
|
|
170
180
|
});
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
one: { ...
|
|
174
|
-
two: { ...
|
|
175
|
-
root: i ??
|
|
181
|
+
const fe = (r, e, t = 0, n = 0, i) => {
|
|
182
|
+
const a = {
|
|
183
|
+
one: { ...Te },
|
|
184
|
+
two: { ...Te },
|
|
185
|
+
root: i ?? Ot
|
|
176
186
|
};
|
|
177
|
-
if (typeof
|
|
187
|
+
if (typeof r == "number") {
|
|
178
188
|
if (typeof e != "number")
|
|
179
189
|
throw new Error("Box constructor called with invalid arguments");
|
|
180
|
-
return
|
|
181
|
-
}
|
|
182
|
-
return "one" in
|
|
183
|
-
x:
|
|
184
|
-
y:
|
|
185
|
-
} : "signedWidth" in e ?
|
|
186
|
-
x:
|
|
187
|
-
y:
|
|
188
|
-
} :
|
|
189
|
-
},
|
|
190
|
-
const e =
|
|
190
|
+
return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
|
|
191
|
+
}
|
|
192
|
+
return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (a.one = { x: r.left, y: r.top }, a.two = { x: r.right, y: r.bottom }, a) : (a.one = r, e == null ? a.two = { x: a.one.x + t, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
|
|
193
|
+
x: a.one.x + e.width,
|
|
194
|
+
y: a.one.y + e.height
|
|
195
|
+
} : "signedWidth" in e ? a.two = {
|
|
196
|
+
x: a.one.x + e.signedWidth,
|
|
197
|
+
y: a.one.y + e.signedHeight
|
|
198
|
+
} : a.two = e, a));
|
|
199
|
+
}, ne = (r) => {
|
|
200
|
+
const e = fe(r);
|
|
191
201
|
return { lower: e.one.x, upper: e.two.x };
|
|
192
|
-
},
|
|
193
|
-
const e =
|
|
202
|
+
}, se = (r) => {
|
|
203
|
+
const e = fe(r);
|
|
194
204
|
return { lower: e.one.y, upper: e.two.y };
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
205
|
+
}, It = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, Nt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
|
|
206
|
+
s.union([xe, Nt, X, K]);
|
|
207
|
+
const St = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
208
|
+
s.object({ offset: Oe, scale: Oe });
|
|
209
|
+
s.object({ offset: s.number(), scale: s.number() });
|
|
210
|
+
const Et = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
|
|
201
211
|
e,
|
|
202
|
-
i ?
|
|
203
|
-
],
|
|
212
|
+
i ? n - r : n + r
|
|
213
|
+
], xt = (r) => (e, t, n, i) => [
|
|
204
214
|
e,
|
|
205
|
-
i ?
|
|
206
|
-
],
|
|
207
|
-
if (e === null) return [
|
|
208
|
-
const { lower: i, upper:
|
|
209
|
-
if (t === "dimension") return [
|
|
210
|
-
const
|
|
211
|
-
return [
|
|
212
|
-
},
|
|
213
|
-
if (
|
|
214
|
-
if (e === "dimension") return [
|
|
215
|
-
const { lower:
|
|
216
|
-
return [
|
|
217
|
-
},
|
|
218
|
-
const { lower: i, upper:
|
|
219
|
-
return
|
|
215
|
+
i ? n / r : n * r
|
|
216
|
+
], At = (r) => (e, t, n) => {
|
|
217
|
+
if (e === null) return [r, n];
|
|
218
|
+
const { lower: i, upper: a } = e, { lower: c, upper: d } = r, y = a - i, f = d - c;
|
|
219
|
+
if (t === "dimension") return [r, n * (f / y)];
|
|
220
|
+
const p = (n - i) * (f / y) + c;
|
|
221
|
+
return [r, p];
|
|
222
|
+
}, Ut = (r) => (e, t, n) => [r, n], Mt = () => (r, e, t) => {
|
|
223
|
+
if (r === null) throw new Error("cannot invert without bounds");
|
|
224
|
+
if (e === "dimension") return [r, t];
|
|
225
|
+
const { lower: n, upper: i } = r;
|
|
226
|
+
return [r, i - (t - n)];
|
|
227
|
+
}, Ct = (r) => (e, t, n) => {
|
|
228
|
+
const { lower: i, upper: a } = r;
|
|
229
|
+
return n = St(n, i, a), [e, n];
|
|
220
230
|
};
|
|
221
|
-
let
|
|
231
|
+
let ve = class D {
|
|
222
232
|
ops = [];
|
|
223
233
|
currBounds = null;
|
|
224
234
|
currType = null;
|
|
@@ -232,7 +242,7 @@ let ye = class B {
|
|
|
232
242
|
* @param value - The amount to translate by.
|
|
233
243
|
*/
|
|
234
244
|
static translate(e) {
|
|
235
|
-
return new
|
|
245
|
+
return new D().translate(e);
|
|
236
246
|
}
|
|
237
247
|
/**
|
|
238
248
|
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
@@ -240,10 +250,10 @@ let ye = class B {
|
|
|
240
250
|
* @param value - The amount to translate by.
|
|
241
251
|
*/
|
|
242
252
|
static magnify(e) {
|
|
243
|
-
return new
|
|
253
|
+
return new D().magnify(e);
|
|
244
254
|
}
|
|
245
255
|
static scale(e, t) {
|
|
246
|
-
return new
|
|
256
|
+
return new D().scale(e, t);
|
|
247
257
|
}
|
|
248
258
|
/**
|
|
249
259
|
* @returns a copy of the scale with a translation as its next operation. Any
|
|
@@ -252,8 +262,8 @@ let ye = class B {
|
|
|
252
262
|
* @param value - The amount to translate by.
|
|
253
263
|
*/
|
|
254
264
|
translate(e) {
|
|
255
|
-
const t = this.new(),
|
|
256
|
-
return
|
|
265
|
+
const t = this.new(), n = Et(e);
|
|
266
|
+
return n.type = "translate", t.ops.push(n), t;
|
|
257
267
|
}
|
|
258
268
|
/**
|
|
259
269
|
* @returns a copy of the scale with a translation as its next operation. Any number
|
|
@@ -262,23 +272,23 @@ let ye = class B {
|
|
|
262
272
|
* @param value - The amount to magnify by.
|
|
263
273
|
*/
|
|
264
274
|
magnify(e) {
|
|
265
|
-
const t = this.new(),
|
|
266
|
-
return
|
|
275
|
+
const t = this.new(), n = xt(e);
|
|
276
|
+
return n.type = "magnify", t.ops.push(n), t;
|
|
267
277
|
}
|
|
268
278
|
scale(e, t) {
|
|
269
|
-
const
|
|
270
|
-
return
|
|
279
|
+
const n = R(e, t), i = this.new(), a = At(n);
|
|
280
|
+
return a.type = "scale", i.ops.push(a), i;
|
|
271
281
|
}
|
|
272
282
|
clamp(e, t) {
|
|
273
|
-
const
|
|
274
|
-
return
|
|
283
|
+
const n = R(e, t), i = this.new(), a = Ct(n);
|
|
284
|
+
return a.type = "clamp", i.ops.push(a), i;
|
|
275
285
|
}
|
|
276
286
|
reBound(e, t) {
|
|
277
|
-
const
|
|
278
|
-
return
|
|
287
|
+
const n = R(e, t), i = this.new(), a = Ut(n);
|
|
288
|
+
return a.type = "re-bound", i.ops.push(a), i;
|
|
279
289
|
}
|
|
280
290
|
invert() {
|
|
281
|
-
const e =
|
|
291
|
+
const e = Mt();
|
|
282
292
|
e.type = "invert";
|
|
283
293
|
const t = this.new();
|
|
284
294
|
return t.ops.push(e), t;
|
|
@@ -290,12 +300,12 @@ let ye = class B {
|
|
|
290
300
|
return this.exec("dimension", e);
|
|
291
301
|
}
|
|
292
302
|
new() {
|
|
293
|
-
const e = new
|
|
303
|
+
const e = new D();
|
|
294
304
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
295
305
|
}
|
|
296
306
|
exec(e, t) {
|
|
297
307
|
return this.currBounds = null, this.ops.reduce(
|
|
298
|
-
([
|
|
308
|
+
([n, i], a) => a(n, e, i, this.reversed),
|
|
299
309
|
[null, t]
|
|
300
310
|
)[1];
|
|
301
311
|
}
|
|
@@ -303,51 +313,51 @@ let ye = class B {
|
|
|
303
313
|
const e = this.new();
|
|
304
314
|
e.ops.reverse();
|
|
305
315
|
const t = [];
|
|
306
|
-
return e.ops.forEach((
|
|
307
|
-
if (
|
|
316
|
+
return e.ops.forEach((n, i) => {
|
|
317
|
+
if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
|
|
308
318
|
return;
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
}), t.forEach(([
|
|
312
|
-
const
|
|
313
|
-
|
|
319
|
+
const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
|
|
320
|
+
a !== -1 && t.push([i, a]);
|
|
321
|
+
}), t.forEach(([n, i]) => {
|
|
322
|
+
const a = e.ops.slice(n, i);
|
|
323
|
+
a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
|
|
314
324
|
}), e.reversed = !e.reversed, e;
|
|
315
325
|
}
|
|
316
326
|
get transform() {
|
|
317
327
|
return { scale: this.dim(1), offset: this.pos(0) };
|
|
318
328
|
}
|
|
319
|
-
static IDENTITY = new
|
|
320
|
-
},
|
|
329
|
+
static IDENTITY = new D();
|
|
330
|
+
}, Xr = class A {
|
|
321
331
|
x;
|
|
322
332
|
y;
|
|
323
333
|
currRoot;
|
|
324
|
-
constructor(e = new
|
|
325
|
-
this.x = e, this.y = t, this.currRoot =
|
|
334
|
+
constructor(e = new ve(), t = new ve(), n = null) {
|
|
335
|
+
this.x = e, this.y = t, this.currRoot = n;
|
|
326
336
|
}
|
|
327
337
|
static translate(e, t) {
|
|
328
|
-
return new
|
|
338
|
+
return new A().translate(e, t);
|
|
329
339
|
}
|
|
330
340
|
static translateX(e) {
|
|
331
|
-
return new
|
|
341
|
+
return new A().translateX(e);
|
|
332
342
|
}
|
|
333
343
|
static translateY(e) {
|
|
334
|
-
return new
|
|
344
|
+
return new A().translateY(e);
|
|
335
345
|
}
|
|
336
346
|
static clamp(e) {
|
|
337
|
-
return new
|
|
347
|
+
return new A().clamp(e);
|
|
338
348
|
}
|
|
339
349
|
static magnify(e) {
|
|
340
|
-
return new
|
|
350
|
+
return new A().magnify(e);
|
|
341
351
|
}
|
|
342
352
|
static scale(e) {
|
|
343
|
-
return new
|
|
353
|
+
return new A().scale(e);
|
|
344
354
|
}
|
|
345
355
|
static reBound(e) {
|
|
346
|
-
return new
|
|
356
|
+
return new A().reBound(e);
|
|
347
357
|
}
|
|
348
358
|
translate(e, t) {
|
|
349
|
-
const
|
|
350
|
-
return i.x = this.x.translate(
|
|
359
|
+
const n = vt(e, t), i = this.copy();
|
|
360
|
+
return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
|
|
351
361
|
}
|
|
352
362
|
translateX(e) {
|
|
353
363
|
const t = this.copy();
|
|
@@ -363,22 +373,22 @@ let ye = class B {
|
|
|
363
373
|
}
|
|
364
374
|
scale(e) {
|
|
365
375
|
const t = this.copy();
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
368
|
-
return t.currRoot = e.root,
|
|
376
|
+
if (It(e)) {
|
|
377
|
+
const n = this.currRoot;
|
|
378
|
+
return t.currRoot = e.root, n != null && !Tt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ne(e)), t.y = t.y.scale(se(e)), t;
|
|
369
379
|
}
|
|
370
380
|
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
371
381
|
}
|
|
372
382
|
reBound(e) {
|
|
373
383
|
const t = this.copy();
|
|
374
|
-
return t.x = this.x.reBound(
|
|
384
|
+
return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
|
|
375
385
|
}
|
|
376
386
|
clamp(e) {
|
|
377
387
|
const t = this.copy();
|
|
378
|
-
return t.x = this.x.clamp(
|
|
388
|
+
return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
|
|
379
389
|
}
|
|
380
390
|
copy() {
|
|
381
|
-
const e = new
|
|
391
|
+
const e = new A();
|
|
382
392
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
383
393
|
}
|
|
384
394
|
reverse() {
|
|
@@ -392,7 +402,7 @@ let ye = class B {
|
|
|
392
402
|
return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
|
|
393
403
|
}
|
|
394
404
|
box(e) {
|
|
395
|
-
return
|
|
405
|
+
return fe(
|
|
396
406
|
this.pos(e.one),
|
|
397
407
|
this.pos(e.two),
|
|
398
408
|
0,
|
|
@@ -406,50 +416,50 @@ let ye = class B {
|
|
|
406
416
|
offset: this.pos({ x: 0, y: 0 })
|
|
407
417
|
};
|
|
408
418
|
}
|
|
409
|
-
static IDENTITY = new
|
|
410
|
-
},
|
|
411
|
-
let
|
|
419
|
+
static IDENTITY = new A();
|
|
420
|
+
}, Re = (r, e = 21) => (t = e) => {
|
|
421
|
+
let n = "", i = t | 0;
|
|
412
422
|
for (; i--; )
|
|
413
|
-
|
|
414
|
-
return
|
|
423
|
+
n += r[Math.random() * r.length | 0];
|
|
424
|
+
return n;
|
|
415
425
|
};
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
]),
|
|
421
|
-
const t = new
|
|
426
|
+
const De = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", $t = `0123456789${De}`, Bt = 11, Rt = Re(De, 1), Dt = Re($t, Bt - 1), Lt = () => `${Rt()}${Dt()}`, Pt = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, kt = s.enum(["static", "dynamic"]), Yt = s.union([
|
|
427
|
+
s.tuple([s.int()]),
|
|
428
|
+
s.tuple([s.int(), s.int().min(1).max(12)]),
|
|
429
|
+
s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
|
|
430
|
+
]), Le = (r, e) => {
|
|
431
|
+
const t = new o(e);
|
|
422
432
|
if (![
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
433
|
+
g.DAY,
|
|
434
|
+
g.HOUR,
|
|
435
|
+
g.MINUTE,
|
|
436
|
+
g.SECOND,
|
|
437
|
+
g.MILLISECOND,
|
|
438
|
+
g.MICROSECOND,
|
|
439
|
+
g.NANOSECOND
|
|
430
440
|
].some((i) => i.equals(t)))
|
|
431
441
|
throw new Error(
|
|
432
442
|
"Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
|
|
433
443
|
);
|
|
434
|
-
const
|
|
435
|
-
return
|
|
444
|
+
const n = r.valueOf() % t.valueOf();
|
|
445
|
+
return r instanceof o ? new o(n) : new g(n);
|
|
436
446
|
};
|
|
437
|
-
|
|
447
|
+
class o extends q {
|
|
438
448
|
constructor(e, t = "UTC") {
|
|
439
|
-
if (e == null) super(
|
|
449
|
+
if (e == null) super(o.now().valueOf());
|
|
440
450
|
else if (e instanceof Date)
|
|
441
|
-
super(BigInt(e.getTime()) *
|
|
451
|
+
super(BigInt(e.getTime()) * o.MILLISECOND.valueOf());
|
|
442
452
|
else if (typeof e == "string")
|
|
443
|
-
super(
|
|
444
|
-
else if (Array.isArray(e)) super(
|
|
453
|
+
super(o.parseDateTimeString(e, t).valueOf());
|
|
454
|
+
else if (Array.isArray(e)) super(o.parseDate(e));
|
|
445
455
|
else {
|
|
446
|
-
let
|
|
447
|
-
e instanceof Number && (e = e.valueOf()), t === "local" && (
|
|
456
|
+
let n = 0n;
|
|
457
|
+
e instanceof Number && (e = e.valueOf()), t === "local" && (n = o.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = o.MAX : e = o.MIN)), super(BigInt(e.valueOf()) + n);
|
|
448
458
|
}
|
|
449
459
|
}
|
|
450
|
-
static parseDate([e = 1970, t = 1,
|
|
451
|
-
const i = new Date(e, t - 1,
|
|
452
|
-
return new
|
|
460
|
+
static parseDate([e = 1970, t = 1, n = 1]) {
|
|
461
|
+
const i = new Date(e, t - 1, n, 0, 0, 0, 0);
|
|
462
|
+
return new o(BigInt(i.getTime()) * o.MILLISECOND.valueOf()).truncate(o.DAY).valueOf();
|
|
453
463
|
}
|
|
454
464
|
/**
|
|
455
465
|
* @returns the primitive value of the TimeStamp. Overrides standard JS valueOf()
|
|
@@ -459,18 +469,18 @@ let y = class c extends j {
|
|
|
459
469
|
return this.value;
|
|
460
470
|
}
|
|
461
471
|
static parseTimeString(e, t = "UTC") {
|
|
462
|
-
const [
|
|
463
|
-
let
|
|
464
|
-
|
|
465
|
-
let
|
|
466
|
-
return t === "local" && (
|
|
472
|
+
const [n, i, a] = e.split(":");
|
|
473
|
+
let c = "00", d = "00";
|
|
474
|
+
a != null && ([c, d] = a.split("."));
|
|
475
|
+
let y = o.hours(parseInt(n ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(d ?? "00")));
|
|
476
|
+
return t === "local" && (y = y.add(o.utcOffset)), y.valueOf();
|
|
467
477
|
}
|
|
468
478
|
static parseDateTimeString(e, t = "UTC") {
|
|
469
479
|
if (!e.includes("/") && !e.includes("-"))
|
|
470
|
-
return
|
|
471
|
-
const
|
|
472
|
-
return e.includes(":") ||
|
|
473
|
-
BigInt(
|
|
480
|
+
return o.parseTimeString(e, t);
|
|
481
|
+
const n = new Date(e);
|
|
482
|
+
return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new o(
|
|
483
|
+
BigInt(n.getTime()) * o.MILLISECOND.valueOf(),
|
|
474
484
|
t
|
|
475
485
|
).valueOf();
|
|
476
486
|
}
|
|
@@ -502,20 +512,20 @@ let y = class c extends j {
|
|
|
502
512
|
}
|
|
503
513
|
}
|
|
504
514
|
toISOString(e = "UTC") {
|
|
505
|
-
return e === "UTC" ? this.date().toISOString() : this.sub(
|
|
515
|
+
return e === "UTC" ? this.date().toISOString() : this.sub(o.utcOffset).date().toISOString();
|
|
506
516
|
}
|
|
507
517
|
timeString(e = !1, t = "UTC") {
|
|
508
|
-
const
|
|
509
|
-
return e ?
|
|
518
|
+
const n = this.toISOString(t);
|
|
519
|
+
return e ? n.slice(11, 23) : n.slice(11, 19);
|
|
510
520
|
}
|
|
511
521
|
dateString() {
|
|
512
|
-
const e = this.date(), t = e.toLocaleString("default", { month: "short" }),
|
|
513
|
-
return `${t} ${
|
|
522
|
+
const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
|
|
523
|
+
return `${t} ${n}`;
|
|
514
524
|
}
|
|
515
525
|
/** @returns The UTC offset for the time zone of the machine. */
|
|
516
526
|
static get utcOffset() {
|
|
517
|
-
return new
|
|
518
|
-
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) *
|
|
527
|
+
return new g(
|
|
528
|
+
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * o.MINUTE.valueOf()
|
|
519
529
|
);
|
|
520
530
|
}
|
|
521
531
|
/**
|
|
@@ -524,7 +534,7 @@ let y = class c extends j {
|
|
|
524
534
|
* @param other - The other timestamp.
|
|
525
535
|
*/
|
|
526
536
|
static since(e) {
|
|
527
|
-
return new
|
|
537
|
+
return new o().span(e);
|
|
528
538
|
}
|
|
529
539
|
/** @returns A JavaScript Date object representing the TimeStamp. */
|
|
530
540
|
date() {
|
|
@@ -537,7 +547,7 @@ let y = class c extends j {
|
|
|
537
547
|
* @returns True if the TimeStamps are equal, false otherwise.
|
|
538
548
|
*/
|
|
539
549
|
equals(e) {
|
|
540
|
-
return this.valueOf() === new
|
|
550
|
+
return this.valueOf() === new o(e).valueOf();
|
|
541
551
|
}
|
|
542
552
|
/**
|
|
543
553
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -557,7 +567,7 @@ let y = class c extends j {
|
|
|
557
567
|
* valid, regardless of the TimeStamp order.
|
|
558
568
|
*/
|
|
559
569
|
range(e) {
|
|
560
|
-
return new
|
|
570
|
+
return new F(this, e).makeValid();
|
|
561
571
|
}
|
|
562
572
|
/**
|
|
563
573
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -586,7 +596,7 @@ let y = class c extends j {
|
|
|
586
596
|
* otherwise.
|
|
587
597
|
*/
|
|
588
598
|
after(e) {
|
|
589
|
-
return this.valueOf() > new
|
|
599
|
+
return this.valueOf() > new o(e).valueOf();
|
|
590
600
|
}
|
|
591
601
|
/**
|
|
592
602
|
* Checks if the TimeStamp is after or equal to the given TimeStamp.
|
|
@@ -596,7 +606,7 @@ let y = class c extends j {
|
|
|
596
606
|
* false otherwise.
|
|
597
607
|
*/
|
|
598
608
|
afterEq(e) {
|
|
599
|
-
return this.valueOf() >= new
|
|
609
|
+
return this.valueOf() >= new o(e).valueOf();
|
|
600
610
|
}
|
|
601
611
|
/**
|
|
602
612
|
* Checks if the TimeStamp is before the given TimeStamp.
|
|
@@ -606,7 +616,7 @@ let y = class c extends j {
|
|
|
606
616
|
* otherwise.
|
|
607
617
|
*/
|
|
608
618
|
before(e) {
|
|
609
|
-
return this.valueOf() < new
|
|
619
|
+
return this.valueOf() < new o(e).valueOf();
|
|
610
620
|
}
|
|
611
621
|
/**
|
|
612
622
|
* Checks if TimeStamp is before or equal to the current timestamp.
|
|
@@ -616,7 +626,7 @@ let y = class c extends j {
|
|
|
616
626
|
* false otherwise.
|
|
617
627
|
*/
|
|
618
628
|
beforeEq(e) {
|
|
619
|
-
return this.valueOf() <= new
|
|
629
|
+
return this.valueOf() <= new o(e).valueOf();
|
|
620
630
|
}
|
|
621
631
|
/**
|
|
622
632
|
* Adds a TimeSpan to the TimeStamp.
|
|
@@ -626,7 +636,7 @@ let y = class c extends j {
|
|
|
626
636
|
* TimeSpan.
|
|
627
637
|
*/
|
|
628
638
|
add(e) {
|
|
629
|
-
return new
|
|
639
|
+
return new o(ee(this.valueOf(), new g(e).valueOf()));
|
|
630
640
|
}
|
|
631
641
|
/**
|
|
632
642
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -636,43 +646,43 @@ let y = class c extends j {
|
|
|
636
646
|
* TimeSpan.
|
|
637
647
|
*/
|
|
638
648
|
sub(e) {
|
|
639
|
-
return new
|
|
649
|
+
return new o(_(this.valueOf(), new g(e).valueOf()));
|
|
640
650
|
}
|
|
641
651
|
/**
|
|
642
652
|
* @returns the floating point number of hours since the unix epoch to the timestamp
|
|
643
653
|
* value.
|
|
644
654
|
*/
|
|
645
655
|
get hours() {
|
|
646
|
-
return Number(this.valueOf()) / Number(
|
|
656
|
+
return Number(this.valueOf()) / Number(g.HOUR.valueOf());
|
|
647
657
|
}
|
|
648
658
|
/**
|
|
649
659
|
* @returns the floating point number of minutes since the unix epoch to the timestamp
|
|
650
660
|
* value.
|
|
651
661
|
*/
|
|
652
662
|
get minutes() {
|
|
653
|
-
return Number(this.valueOf()) / Number(
|
|
663
|
+
return Number(this.valueOf()) / Number(g.MINUTE.valueOf());
|
|
654
664
|
}
|
|
655
665
|
/**
|
|
656
666
|
* @returns the floating point number of days since the unix epoch to the timestamp
|
|
657
667
|
* value.
|
|
658
668
|
*/
|
|
659
669
|
get days() {
|
|
660
|
-
return Number(this.valueOf()) / Number(
|
|
670
|
+
return Number(this.valueOf()) / Number(g.DAY.valueOf());
|
|
661
671
|
}
|
|
662
672
|
/**
|
|
663
673
|
* @returns the floating point number of seconds since the unix epoch to the timestamp
|
|
664
674
|
* value.
|
|
665
675
|
*/
|
|
666
676
|
get seconds() {
|
|
667
|
-
return Number(this.valueOf()) / Number(
|
|
677
|
+
return Number(this.valueOf()) / Number(g.SECOND.valueOf());
|
|
668
678
|
}
|
|
669
679
|
/** @returns the floating point number of milliseconds since the unix epoch. */
|
|
670
680
|
get milliseconds() {
|
|
671
|
-
return Number(this.valueOf()) / Number(
|
|
681
|
+
return Number(this.valueOf()) / Number(o.MILLISECOND.valueOf());
|
|
672
682
|
}
|
|
673
683
|
/** @returns the floating point number of microseconds since the unix epoch. */
|
|
674
684
|
get microseconds() {
|
|
675
|
-
return Number(this.valueOf()) / Number(
|
|
685
|
+
return Number(this.valueOf()) / Number(o.MICROSECOND.valueOf());
|
|
676
686
|
}
|
|
677
687
|
/**
|
|
678
688
|
* @returns the floating point number of nanoseconds since the unix epoch.
|
|
@@ -692,7 +702,7 @@ let y = class c extends j {
|
|
|
692
702
|
*/
|
|
693
703
|
setYear(e) {
|
|
694
704
|
const t = this.date();
|
|
695
|
-
return t.setUTCFullYear(e), new
|
|
705
|
+
return t.setUTCFullYear(e), new o(t);
|
|
696
706
|
}
|
|
697
707
|
/** @returns the integer month that the timestamp corresponds to with its year. */
|
|
698
708
|
get month() {
|
|
@@ -704,7 +714,7 @@ let y = class c extends j {
|
|
|
704
714
|
*/
|
|
705
715
|
setMonth(e) {
|
|
706
716
|
const t = this.date();
|
|
707
|
-
return t.setUTCMonth(e), new
|
|
717
|
+
return t.setUTCMonth(e), new o(t);
|
|
708
718
|
}
|
|
709
719
|
/** @returns the integer day that the timestamp corresponds to within its month. */
|
|
710
720
|
get day() {
|
|
@@ -716,7 +726,7 @@ let y = class c extends j {
|
|
|
716
726
|
*/
|
|
717
727
|
setDay(e) {
|
|
718
728
|
const t = this.date();
|
|
719
|
-
return t.setUTCDate(e), new
|
|
729
|
+
return t.setUTCDate(e), new o(t);
|
|
720
730
|
}
|
|
721
731
|
/**
|
|
722
732
|
* @returns the integer hour that the timestamp corresponds to within its day.
|
|
@@ -730,7 +740,7 @@ let y = class c extends j {
|
|
|
730
740
|
*/
|
|
731
741
|
setHour(e) {
|
|
732
742
|
const t = this.date();
|
|
733
|
-
return t.setUTCHours(e), new
|
|
743
|
+
return t.setUTCHours(e), new o(t, "UTC");
|
|
734
744
|
}
|
|
735
745
|
/** @returns the integer minute that the timestamp corresponds to within its hour. */
|
|
736
746
|
get minute() {
|
|
@@ -742,7 +752,7 @@ let y = class c extends j {
|
|
|
742
752
|
*/
|
|
743
753
|
setMinute(e) {
|
|
744
754
|
const t = this.date();
|
|
745
|
-
return t.setUTCMinutes(e), new
|
|
755
|
+
return t.setUTCMinutes(e), new o(t);
|
|
746
756
|
}
|
|
747
757
|
/**
|
|
748
758
|
* @returns the integer second that the timestamp corresponds to within its
|
|
@@ -757,7 +767,7 @@ let y = class c extends j {
|
|
|
757
767
|
*/
|
|
758
768
|
setSecond(e) {
|
|
759
769
|
const t = this.date();
|
|
760
|
-
return t.setUTCSeconds(e), new
|
|
770
|
+
return t.setUTCSeconds(e), new o(t);
|
|
761
771
|
}
|
|
762
772
|
/**
|
|
763
773
|
* @reutrns the integer millisecond that the timestamp corresponds to within
|
|
@@ -772,7 +782,7 @@ let y = class c extends j {
|
|
|
772
782
|
*/
|
|
773
783
|
setMillisecond(e) {
|
|
774
784
|
const t = this.date();
|
|
775
|
-
return t.setUTCMilliseconds(e), new
|
|
785
|
+
return t.setUTCMilliseconds(e), new o(t);
|
|
776
786
|
}
|
|
777
787
|
/** @returns the time stamp formatted as an ISO string. */
|
|
778
788
|
toString() {
|
|
@@ -790,11 +800,11 @@ let y = class c extends j {
|
|
|
790
800
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
791
801
|
*/
|
|
792
802
|
remainder(e) {
|
|
793
|
-
return
|
|
803
|
+
return Le(this, e);
|
|
794
804
|
}
|
|
795
805
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
796
806
|
get isToday() {
|
|
797
|
-
return this.truncate(
|
|
807
|
+
return this.truncate(g.DAY).equals(o.now().truncate(g.DAY));
|
|
798
808
|
}
|
|
799
809
|
/**
|
|
800
810
|
* Truncates the TimeStamp to the nearest multiple of the given span.
|
|
@@ -811,7 +821,7 @@ let y = class c extends j {
|
|
|
811
821
|
* JavaScript can do).
|
|
812
822
|
*/
|
|
813
823
|
static now() {
|
|
814
|
-
return new
|
|
824
|
+
return new o(/* @__PURE__ */ new Date());
|
|
815
825
|
}
|
|
816
826
|
/**
|
|
817
827
|
* Finds the maximum timestamp among the provided timestamps.
|
|
@@ -820,9 +830,9 @@ let y = class c extends j {
|
|
|
820
830
|
* @returns The maximum (latest) timestamp from the input.
|
|
821
831
|
*/
|
|
822
832
|
static max(...e) {
|
|
823
|
-
let t =
|
|
824
|
-
for (const
|
|
825
|
-
const i = new
|
|
833
|
+
let t = o.MIN;
|
|
834
|
+
for (const n of e) {
|
|
835
|
+
const i = new o(n);
|
|
826
836
|
i.after(t) && (t = i);
|
|
827
837
|
}
|
|
828
838
|
return t;
|
|
@@ -834,9 +844,9 @@ let y = class c extends j {
|
|
|
834
844
|
* @returns The minimum (earliest) timestamp from the input.
|
|
835
845
|
*/
|
|
836
846
|
static min(...e) {
|
|
837
|
-
let t =
|
|
838
|
-
for (const
|
|
839
|
-
const i = new
|
|
847
|
+
let t = o.MAX;
|
|
848
|
+
for (const n of e) {
|
|
849
|
+
const i = new o(n);
|
|
840
850
|
i.before(t) && (t = i);
|
|
841
851
|
}
|
|
842
852
|
return t;
|
|
@@ -848,62 +858,62 @@ let y = class c extends j {
|
|
|
848
858
|
* @returns A TimeStamp representing the given number of nanoseconds.
|
|
849
859
|
*/
|
|
850
860
|
static nanoseconds(e, t = "UTC") {
|
|
851
|
-
return new
|
|
861
|
+
return new o(e, t);
|
|
852
862
|
}
|
|
853
863
|
/** One nanosecond after the unix epoch */
|
|
854
|
-
static NANOSECOND =
|
|
864
|
+
static NANOSECOND = o.nanoseconds(1);
|
|
855
865
|
/** @returns a new TimeStamp n microseconds after the unix epoch */
|
|
856
866
|
static microseconds(e, t = "UTC") {
|
|
857
|
-
return
|
|
867
|
+
return o.nanoseconds(e * 1e3, t);
|
|
858
868
|
}
|
|
859
869
|
/** One microsecond after the unix epoch */
|
|
860
|
-
static MICROSECOND =
|
|
870
|
+
static MICROSECOND = o.microseconds(1);
|
|
861
871
|
/** @returns a new TimeStamp n milliseconds after the unix epoch */
|
|
862
872
|
static milliseconds(e, t = "UTC") {
|
|
863
|
-
return
|
|
873
|
+
return o.microseconds(e * 1e3, t);
|
|
864
874
|
}
|
|
865
875
|
/** One millisecond after the unix epoch */
|
|
866
|
-
static MILLISECOND =
|
|
876
|
+
static MILLISECOND = o.milliseconds(1);
|
|
867
877
|
/** @returns a new TimeStamp n seconds after the unix epoch */
|
|
868
878
|
static seconds(e, t = "UTC") {
|
|
869
|
-
return
|
|
879
|
+
return o.milliseconds(e * 1e3, t);
|
|
870
880
|
}
|
|
871
881
|
/** One second after the unix epoch */
|
|
872
|
-
static SECOND =
|
|
882
|
+
static SECOND = o.seconds(1);
|
|
873
883
|
/** @returns a new TimeStamp n minutes after the unix epoch */
|
|
874
884
|
static minutes(e, t = "UTC") {
|
|
875
|
-
return
|
|
885
|
+
return o.seconds(e * 60, t);
|
|
876
886
|
}
|
|
877
887
|
/** One minute after the unix epoch */
|
|
878
|
-
static MINUTE =
|
|
888
|
+
static MINUTE = o.minutes(1);
|
|
879
889
|
/** @returns a new TimeStamp n hours after the unix epoch */
|
|
880
890
|
static hours(e, t = "UTC") {
|
|
881
|
-
return
|
|
891
|
+
return o.minutes(e * 60, t);
|
|
882
892
|
}
|
|
883
893
|
/** One hour after the unix epoch */
|
|
884
|
-
static HOUR =
|
|
894
|
+
static HOUR = o.hours(1);
|
|
885
895
|
/** @returns a new TimeStamp n days after the unix epoch */
|
|
886
896
|
static days(e, t = "UTC") {
|
|
887
|
-
return
|
|
897
|
+
return o.hours(e * 24, t);
|
|
888
898
|
}
|
|
889
899
|
/** One day after the unix epoch */
|
|
890
|
-
static DAY =
|
|
900
|
+
static DAY = o.days(1);
|
|
891
901
|
/** The maximum possible value for a timestamp */
|
|
892
|
-
static MAX = new
|
|
902
|
+
static MAX = new o((1n << 63n) - 1n);
|
|
893
903
|
/** The minimum possible value for a timestamp */
|
|
894
|
-
static MIN = new
|
|
904
|
+
static MIN = new o(0);
|
|
895
905
|
/** The unix epoch */
|
|
896
|
-
static ZERO = new
|
|
906
|
+
static ZERO = new o(0);
|
|
897
907
|
/** A zod schema for validating timestamps */
|
|
898
|
-
static z =
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
908
|
+
static z = s.union([
|
|
909
|
+
s.instanceof(o),
|
|
910
|
+
s.object({ value: s.bigint() }).transform((e) => new o(e.value)),
|
|
911
|
+
s.string().transform((e) => new o(BigInt(e))),
|
|
912
|
+
s.number().transform((e) => new o(e)),
|
|
913
|
+
s.bigint().transform((e) => new o(e)),
|
|
914
|
+
s.date().transform((e) => new o(e)),
|
|
915
|
+
s.custom((e) => e instanceof g).transform((e) => new o(e)),
|
|
916
|
+
Yt.transform((e) => new o(e))
|
|
907
917
|
]);
|
|
908
918
|
/**
|
|
909
919
|
* Sorts two timestamps.
|
|
@@ -916,8 +926,8 @@ let y = class c extends j {
|
|
|
916
926
|
static sort(e, t) {
|
|
917
927
|
return Number(e.valueOf() - t.valueOf());
|
|
918
928
|
}
|
|
919
|
-
}
|
|
920
|
-
class
|
|
929
|
+
}
|
|
930
|
+
let g = class l extends q {
|
|
921
931
|
constructor(e) {
|
|
922
932
|
typeof e == "number" && (e = Math.trunc(e.valueOf())), super(BigInt(e.valueOf()));
|
|
923
933
|
}
|
|
@@ -928,7 +938,7 @@ class u extends j {
|
|
|
928
938
|
* @returns A TimeSpan representing the given number of seconds.
|
|
929
939
|
*/
|
|
930
940
|
static fromSeconds(e) {
|
|
931
|
-
return e instanceof
|
|
941
|
+
return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e);
|
|
932
942
|
}
|
|
933
943
|
/**
|
|
934
944
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -937,7 +947,7 @@ class u extends j {
|
|
|
937
947
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
938
948
|
*/
|
|
939
949
|
static fromMilliseconds(e) {
|
|
940
|
-
return e instanceof
|
|
950
|
+
return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e);
|
|
941
951
|
}
|
|
942
952
|
/**
|
|
943
953
|
* @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
|
|
@@ -953,7 +963,7 @@ class u extends j {
|
|
|
953
963
|
* @returns True if the TimeSpan is less than the other TimeSpan, false otherwise.
|
|
954
964
|
*/
|
|
955
965
|
lessThan(e) {
|
|
956
|
-
return this.valueOf() < new
|
|
966
|
+
return this.valueOf() < new l(e).valueOf();
|
|
957
967
|
}
|
|
958
968
|
/**
|
|
959
969
|
* Checks if the TimeSpan is greater than another TimeSpan.
|
|
@@ -962,7 +972,7 @@ class u extends j {
|
|
|
962
972
|
* @returns True if the TimeSpan is greater than the other TimeSpan, false otherwise.
|
|
963
973
|
*/
|
|
964
974
|
greaterThan(e) {
|
|
965
|
-
return this.valueOf() > new
|
|
975
|
+
return this.valueOf() > new l(e).valueOf();
|
|
966
976
|
}
|
|
967
977
|
/**
|
|
968
978
|
* Checks if the TimeSpan is less than or equal to another TimeSpan.
|
|
@@ -971,7 +981,7 @@ class u extends j {
|
|
|
971
981
|
* @returns True if the TimeSpan is less than or equal to the other TimeSpan, false otherwise.
|
|
972
982
|
*/
|
|
973
983
|
lessThanOrEqual(e) {
|
|
974
|
-
return this.valueOf() <= new
|
|
984
|
+
return this.valueOf() <= new l(e).valueOf();
|
|
975
985
|
}
|
|
976
986
|
/**
|
|
977
987
|
* Checks if the TimeSpan is greater than or equal to another TimeSpan.
|
|
@@ -980,7 +990,7 @@ class u extends j {
|
|
|
980
990
|
* @returns True if the TimeSpan is greater than or equal to the other TimeSpan, false otherwise.
|
|
981
991
|
*/
|
|
982
992
|
greaterThanOrEqual(e) {
|
|
983
|
-
return this.valueOf() >= new
|
|
993
|
+
return this.valueOf() >= new l(e).valueOf();
|
|
984
994
|
}
|
|
985
995
|
/**
|
|
986
996
|
* Calculates the remainder of the TimeSpan when divided by another TimeSpan.
|
|
@@ -989,7 +999,7 @@ class u extends j {
|
|
|
989
999
|
* @returns A new TimeSpan representing the remainder.
|
|
990
1000
|
*/
|
|
991
1001
|
remainder(e) {
|
|
992
|
-
return
|
|
1002
|
+
return Le(this, e);
|
|
993
1003
|
}
|
|
994
1004
|
/**
|
|
995
1005
|
* Truncates the TimeSpan to the nearest multiple of the given span.
|
|
@@ -998,7 +1008,7 @@ class u extends j {
|
|
|
998
1008
|
* @returns A new TimeSpan that is truncated to the nearest multiple of the given span.
|
|
999
1009
|
*/
|
|
1000
1010
|
truncate(e) {
|
|
1001
|
-
return new
|
|
1011
|
+
return new l(
|
|
1002
1012
|
BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
|
|
1003
1013
|
);
|
|
1004
1014
|
}
|
|
@@ -1008,9 +1018,9 @@ class u extends j {
|
|
|
1008
1018
|
* @returns A string representation of the TimeSpan.
|
|
1009
1019
|
*/
|
|
1010
1020
|
toString() {
|
|
1011
|
-
const e = this.truncate(
|
|
1012
|
-
let
|
|
1013
|
-
return
|
|
1021
|
+
const e = this.truncate(l.DAY), t = this.truncate(l.HOUR), n = this.truncate(l.MINUTE), i = this.truncate(l.SECOND), a = this.truncate(l.MILLISECOND), c = this.truncate(l.MICROSECOND), d = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), p = n.sub(t), b = i.sub(n), h = a.sub(i), T = c.sub(a), x = d.sub(c);
|
|
1022
|
+
let C = "";
|
|
1023
|
+
return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `), p.isZero || (C += `${p.minutes}m `), b.isZero || (C += `${b.seconds}s `), h.isZero || (C += `${h.milliseconds}ms `), T.isZero || (C += `${T.microseconds}µs `), x.isZero || (C += `${x.nanoseconds}ns`), C.trim();
|
|
1014
1024
|
}
|
|
1015
1025
|
/**
|
|
1016
1026
|
* Multiplies the TimeSpan by a scalar value.
|
|
@@ -1019,31 +1029,40 @@ class u extends j {
|
|
|
1019
1029
|
* @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
|
|
1020
1030
|
*/
|
|
1021
1031
|
mult(e) {
|
|
1022
|
-
return new
|
|
1032
|
+
return new l(U(this.valueOf(), e));
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Divides the TimeSpan by a scalar value.
|
|
1036
|
+
*
|
|
1037
|
+
* @param value - The scalar value to divide by.
|
|
1038
|
+
* @returns A new TimeSpan that is this TimeSpan divided by the provided value.
|
|
1039
|
+
*/
|
|
1040
|
+
div(e) {
|
|
1041
|
+
return new l(te(this.valueOf(), e));
|
|
1023
1042
|
}
|
|
1024
1043
|
/** @returns the decimal number of days in the TimeSpan. */
|
|
1025
1044
|
get days() {
|
|
1026
|
-
return Number(this.valueOf()) / Number(
|
|
1045
|
+
return Number(this.valueOf()) / Number(l.DAY.valueOf());
|
|
1027
1046
|
}
|
|
1028
1047
|
/** @returns the decimal number of hours in the TimeSpan. */
|
|
1029
1048
|
get hours() {
|
|
1030
|
-
return Number(this.valueOf()) / Number(
|
|
1049
|
+
return Number(this.valueOf()) / Number(l.HOUR.valueOf());
|
|
1031
1050
|
}
|
|
1032
1051
|
/** @returns the decimal number of minutes in the TimeSpan. */
|
|
1033
1052
|
get minutes() {
|
|
1034
|
-
return Number(this.valueOf()) / Number(
|
|
1053
|
+
return Number(this.valueOf()) / Number(l.MINUTE.valueOf());
|
|
1035
1054
|
}
|
|
1036
1055
|
/** @returns The number of seconds in the TimeSpan. */
|
|
1037
1056
|
get seconds() {
|
|
1038
|
-
return Number(this.valueOf()) / Number(
|
|
1057
|
+
return Number(this.valueOf()) / Number(l.SECOND.valueOf());
|
|
1039
1058
|
}
|
|
1040
1059
|
/** @returns The number of milliseconds in the TimeSpan. */
|
|
1041
1060
|
get milliseconds() {
|
|
1042
|
-
return Number(this.valueOf()) / Number(
|
|
1061
|
+
return Number(this.valueOf()) / Number(l.MILLISECOND.valueOf());
|
|
1043
1062
|
}
|
|
1044
1063
|
/** @returns The number of microseconds in the TimeSpan. */
|
|
1045
1064
|
get microseconds() {
|
|
1046
|
-
return Number(this.valueOf()) / Number(
|
|
1065
|
+
return Number(this.valueOf()) / Number(l.MICROSECOND.valueOf());
|
|
1047
1066
|
}
|
|
1048
1067
|
/** @returns The number of nanoseconds in the TimeSpan. */
|
|
1049
1068
|
get nanoseconds() {
|
|
@@ -1063,7 +1082,7 @@ class u extends j {
|
|
|
1063
1082
|
* @returns True if the TimeSpans are equal, false otherwise.
|
|
1064
1083
|
*/
|
|
1065
1084
|
equals(e) {
|
|
1066
|
-
return this.valueOf() === new
|
|
1085
|
+
return this.valueOf() === new l(e).valueOf();
|
|
1067
1086
|
}
|
|
1068
1087
|
/**
|
|
1069
1088
|
* Adds a TimeSpan to the TimeSpan.
|
|
@@ -1071,7 +1090,7 @@ class u extends j {
|
|
|
1071
1090
|
* @returns A new TimeSpan representing the sum of the two TimeSpans.
|
|
1072
1091
|
*/
|
|
1073
1092
|
add(e) {
|
|
1074
|
-
return new
|
|
1093
|
+
return new l(this.valueOf() + new l(e).valueOf());
|
|
1075
1094
|
}
|
|
1076
1095
|
/**
|
|
1077
1096
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -1079,7 +1098,7 @@ class u extends j {
|
|
|
1079
1098
|
* @param other
|
|
1080
1099
|
*/
|
|
1081
1100
|
sub(e) {
|
|
1082
|
-
return new
|
|
1101
|
+
return new l(this.valueOf() - new l(e).valueOf());
|
|
1083
1102
|
}
|
|
1084
1103
|
/**
|
|
1085
1104
|
* Creates a TimeSpan representing the given number of nanoseconds.
|
|
@@ -1088,10 +1107,10 @@ class u extends j {
|
|
|
1088
1107
|
* @returns A TimeSpan representing the given number of nanoseconds.
|
|
1089
1108
|
*/
|
|
1090
1109
|
static nanoseconds(e = 1) {
|
|
1091
|
-
return new
|
|
1110
|
+
return new l(e);
|
|
1092
1111
|
}
|
|
1093
1112
|
/** A nanosecond. */
|
|
1094
|
-
static NANOSECOND =
|
|
1113
|
+
static NANOSECOND = l.nanoseconds(1);
|
|
1095
1114
|
/**
|
|
1096
1115
|
* Creates a TimeSpan representing the given number of microseconds.
|
|
1097
1116
|
*
|
|
@@ -1099,10 +1118,10 @@ class u extends j {
|
|
|
1099
1118
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
1100
1119
|
*/
|
|
1101
1120
|
static microseconds(e = 1) {
|
|
1102
|
-
return
|
|
1121
|
+
return l.nanoseconds(U(e, 1e3));
|
|
1103
1122
|
}
|
|
1104
1123
|
/** A microsecond. */
|
|
1105
|
-
static MICROSECOND =
|
|
1124
|
+
static MICROSECOND = l.microseconds(1);
|
|
1106
1125
|
/**
|
|
1107
1126
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
1108
1127
|
*
|
|
@@ -1110,10 +1129,10 @@ class u extends j {
|
|
|
1110
1129
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
1111
1130
|
*/
|
|
1112
1131
|
static milliseconds(e = 1) {
|
|
1113
|
-
return
|
|
1132
|
+
return l.microseconds(U(e, 1e3));
|
|
1114
1133
|
}
|
|
1115
1134
|
/** A millisecond. */
|
|
1116
|
-
static MILLISECOND =
|
|
1135
|
+
static MILLISECOND = l.milliseconds(1);
|
|
1117
1136
|
/**
|
|
1118
1137
|
* Creates a TimeSpan representing the given number of seconds.
|
|
1119
1138
|
*
|
|
@@ -1121,10 +1140,10 @@ class u extends j {
|
|
|
1121
1140
|
* @returns A TimeSpan representing the given number of seconds.
|
|
1122
1141
|
*/
|
|
1123
1142
|
static seconds(e = 1) {
|
|
1124
|
-
return
|
|
1143
|
+
return l.milliseconds(U(e, 1e3));
|
|
1125
1144
|
}
|
|
1126
1145
|
/** A second. */
|
|
1127
|
-
static SECOND =
|
|
1146
|
+
static SECOND = l.seconds(1);
|
|
1128
1147
|
/**
|
|
1129
1148
|
* Creates a TimeSpan representing the given number of minutes.
|
|
1130
1149
|
*
|
|
@@ -1132,10 +1151,10 @@ class u extends j {
|
|
|
1132
1151
|
* @returns A TimeSpan representing the given number of minutes.
|
|
1133
1152
|
*/
|
|
1134
1153
|
static minutes(e = 1) {
|
|
1135
|
-
return
|
|
1154
|
+
return l.seconds(U(e, 60));
|
|
1136
1155
|
}
|
|
1137
1156
|
/** A minute. */
|
|
1138
|
-
static MINUTE =
|
|
1157
|
+
static MINUTE = l.minutes(1);
|
|
1139
1158
|
/**
|
|
1140
1159
|
* Creates a TimeSpan representing the given number of hours.
|
|
1141
1160
|
*
|
|
@@ -1143,10 +1162,10 @@ class u extends j {
|
|
|
1143
1162
|
* @returns A TimeSpan representing the given number of hours.
|
|
1144
1163
|
*/
|
|
1145
1164
|
static hours(e) {
|
|
1146
|
-
return
|
|
1165
|
+
return l.minutes(U(e, 60));
|
|
1147
1166
|
}
|
|
1148
1167
|
/** Represents an hour. */
|
|
1149
|
-
static HOUR =
|
|
1168
|
+
static HOUR = l.hours(1);
|
|
1150
1169
|
/**
|
|
1151
1170
|
* Creates a TimeSpan representing the given number of days.
|
|
1152
1171
|
*
|
|
@@ -1154,25 +1173,28 @@ class u extends j {
|
|
|
1154
1173
|
* @returns A TimeSpan representing the given number of days.
|
|
1155
1174
|
*/
|
|
1156
1175
|
static days(e) {
|
|
1157
|
-
return
|
|
1176
|
+
return l.hours(U(e, 24));
|
|
1158
1177
|
}
|
|
1159
1178
|
/** Represents a day. */
|
|
1160
|
-
static DAY =
|
|
1179
|
+
static DAY = l.days(1);
|
|
1161
1180
|
/** The maximum possible value for a TimeSpan. */
|
|
1162
|
-
static MAX = new
|
|
1181
|
+
static MAX = new l((1n << 63n) - 1n);
|
|
1163
1182
|
/** The minimum possible value for a TimeSpan. */
|
|
1164
|
-
static MIN = new
|
|
1183
|
+
static MIN = new l(0);
|
|
1165
1184
|
/** The zero value for a TimeSpan. */
|
|
1166
|
-
static ZERO = new
|
|
1185
|
+
static ZERO = new l(0);
|
|
1167
1186
|
/** A zod schema for validating and transforming timespans */
|
|
1168
|
-
static z =
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1187
|
+
static z = s.union([
|
|
1188
|
+
s.object({ value: s.bigint() }).transform((e) => new l(e.value)),
|
|
1189
|
+
s.string().transform((e) => new l(BigInt(e))),
|
|
1190
|
+
s.number().transform((e) => new l(e)),
|
|
1191
|
+
s.bigint().transform((e) => new l(e)),
|
|
1192
|
+
s.instanceof(l),
|
|
1193
|
+
s.instanceof(o).transform((e) => new l(e)),
|
|
1194
|
+
s.custom((e) => e instanceof S).transform((e) => new l(e))
|
|
1173
1195
|
]);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1196
|
+
};
|
|
1197
|
+
class S extends q {
|
|
1176
1198
|
constructor(e) {
|
|
1177
1199
|
super(e.valueOf());
|
|
1178
1200
|
}
|
|
@@ -1182,7 +1204,7 @@ let me = class $ extends j {
|
|
|
1182
1204
|
}
|
|
1183
1205
|
/** @returns The number of seconds in the Rate. */
|
|
1184
1206
|
equals(e) {
|
|
1185
|
-
return this.valueOf() === new
|
|
1207
|
+
return this.valueOf() === new S(e).valueOf();
|
|
1186
1208
|
}
|
|
1187
1209
|
/**
|
|
1188
1210
|
* Calculates the period of the Rate as a TimeSpan.
|
|
@@ -1190,7 +1212,7 @@ let me = class $ extends j {
|
|
|
1190
1212
|
* @returns A TimeSpan representing the period of the Rate.
|
|
1191
1213
|
*/
|
|
1192
1214
|
get period() {
|
|
1193
|
-
return
|
|
1215
|
+
return g.seconds(1 / this.valueOf());
|
|
1194
1216
|
}
|
|
1195
1217
|
/**
|
|
1196
1218
|
* Calculates the number of samples in the given TimeSpan at this rate.
|
|
@@ -1199,7 +1221,7 @@ let me = class $ extends j {
|
|
|
1199
1221
|
* @returns The number of samples in the given TimeSpan at this rate.
|
|
1200
1222
|
*/
|
|
1201
1223
|
sampleCount(e) {
|
|
1202
|
-
return new
|
|
1224
|
+
return new g(e).seconds * this.valueOf();
|
|
1203
1225
|
}
|
|
1204
1226
|
/**
|
|
1205
1227
|
* Calculates the number of bytes in the given TimeSpan at this rate.
|
|
@@ -1209,7 +1231,7 @@ let me = class $ extends j {
|
|
|
1209
1231
|
* @returns The number of bytes in the given TimeSpan at this rate.
|
|
1210
1232
|
*/
|
|
1211
1233
|
byteCount(e, t) {
|
|
1212
|
-
return this.sampleCount(e) * new
|
|
1234
|
+
return this.sampleCount(e) * new I(t).valueOf();
|
|
1213
1235
|
}
|
|
1214
1236
|
/**
|
|
1215
1237
|
* Calculates a TimeSpan given the number of samples at this rate.
|
|
@@ -1218,7 +1240,7 @@ let me = class $ extends j {
|
|
|
1218
1240
|
* @returns A TimeSpan that corresponds to the given number of samples.
|
|
1219
1241
|
*/
|
|
1220
1242
|
span(e) {
|
|
1221
|
-
return
|
|
1243
|
+
return g.seconds(e / this.valueOf());
|
|
1222
1244
|
}
|
|
1223
1245
|
/**
|
|
1224
1246
|
* Calculates a TimeSpan given the number of bytes at this rate.
|
|
@@ -1230,6 +1252,42 @@ let me = class $ extends j {
|
|
|
1230
1252
|
byteSpan(e, t) {
|
|
1231
1253
|
return this.span(e.valueOf() / t.valueOf());
|
|
1232
1254
|
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Adds another Rate to this Rate.
|
|
1257
|
+
*
|
|
1258
|
+
* @param other - The Rate to add.
|
|
1259
|
+
* @returns A new Rate representing the sum of the two rates.
|
|
1260
|
+
*/
|
|
1261
|
+
add(e) {
|
|
1262
|
+
return new S(ee(this.valueOf(), e.valueOf()));
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Subtracts another Rate from this Rate.
|
|
1266
|
+
*
|
|
1267
|
+
* @param other - The Rate to subtract.
|
|
1268
|
+
* @returns A new Rate representing the difference of the two rates.
|
|
1269
|
+
*/
|
|
1270
|
+
sub(e) {
|
|
1271
|
+
return new S(_(this.valueOf(), e.valueOf()));
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Multiplies this Rate by a scalar value.
|
|
1275
|
+
*
|
|
1276
|
+
* @param value - The scalar value to multiply by.
|
|
1277
|
+
* @returns A new Rate representing this Rate multiplied by the value.
|
|
1278
|
+
*/
|
|
1279
|
+
mult(e) {
|
|
1280
|
+
return new S(U(this.valueOf(), e));
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Divides this Rate by a scalar value.
|
|
1284
|
+
*
|
|
1285
|
+
* @param value - The scalar value to divide by.
|
|
1286
|
+
* @returns A new Rate representing this Rate divided by the value.
|
|
1287
|
+
*/
|
|
1288
|
+
div(e) {
|
|
1289
|
+
return new S(te(this.valueOf(), e));
|
|
1290
|
+
}
|
|
1233
1291
|
/**
|
|
1234
1292
|
* Creates a Rate representing the given number of Hz.
|
|
1235
1293
|
*
|
|
@@ -1237,7 +1295,7 @@ let me = class $ extends j {
|
|
|
1237
1295
|
* @returns A Rate representing the given number of Hz.
|
|
1238
1296
|
*/
|
|
1239
1297
|
static hz(e) {
|
|
1240
|
-
return new
|
|
1298
|
+
return new S(e);
|
|
1241
1299
|
}
|
|
1242
1300
|
/**
|
|
1243
1301
|
* Creates a Rate representing the given number of kHz.
|
|
@@ -1246,14 +1304,15 @@ let me = class $ extends j {
|
|
|
1246
1304
|
* @returns A Rate representing the given number of kHz.
|
|
1247
1305
|
*/
|
|
1248
1306
|
static khz(e) {
|
|
1249
|
-
return
|
|
1307
|
+
return S.hz(e * 1e3);
|
|
1250
1308
|
}
|
|
1251
1309
|
/** A zod schema for validating and transforming rates */
|
|
1252
|
-
static z =
|
|
1253
|
-
|
|
1254
|
-
|
|
1310
|
+
static z = s.union([
|
|
1311
|
+
s.number().transform((e) => new S(e)),
|
|
1312
|
+
s.instanceof(S)
|
|
1255
1313
|
]);
|
|
1256
|
-
}
|
|
1314
|
+
}
|
|
1315
|
+
let I = class N extends q {
|
|
1257
1316
|
/**
|
|
1258
1317
|
* Creates a Density representing the given number of bytes per value.
|
|
1259
1318
|
*
|
|
@@ -1280,27 +1339,62 @@ let me = class $ extends j {
|
|
|
1280
1339
|
* @returns A Size representing the given number of values.
|
|
1281
1340
|
*/
|
|
1282
1341
|
size(e) {
|
|
1283
|
-
return new
|
|
1342
|
+
return new oe(e * this.valueOf());
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Adds another Density to this Density.
|
|
1346
|
+
*
|
|
1347
|
+
* @param other - The Density to add.
|
|
1348
|
+
* @returns A new Density representing the sum of the two densities.
|
|
1349
|
+
*/
|
|
1350
|
+
add(e) {
|
|
1351
|
+
return new N(ee(this.valueOf(), e.valueOf()));
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Subtracts another Density from this Density.
|
|
1355
|
+
*
|
|
1356
|
+
* @param other - The Density to subtract.
|
|
1357
|
+
* @returns A new Density representing the difference of the two densities.
|
|
1358
|
+
*/
|
|
1359
|
+
sub(e) {
|
|
1360
|
+
return new N(_(this.valueOf(), e.valueOf()));
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Multiplies this Density by a scalar value.
|
|
1364
|
+
*
|
|
1365
|
+
* @param value - The scalar value to multiply by.
|
|
1366
|
+
* @returns A new Density representing this Density multiplied by the value.
|
|
1367
|
+
*/
|
|
1368
|
+
mult(e) {
|
|
1369
|
+
return new N(U(this.valueOf(), e));
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Divides this Density by a scalar value.
|
|
1373
|
+
*
|
|
1374
|
+
* @param value - The scalar value to divide by.
|
|
1375
|
+
* @returns A new Density representing this Density divided by the value.
|
|
1376
|
+
*/
|
|
1377
|
+
div(e) {
|
|
1378
|
+
return new N(te(this.valueOf(), e));
|
|
1284
1379
|
}
|
|
1285
1380
|
/** Unknown/Invalid Density. */
|
|
1286
|
-
static UNKNOWN = new
|
|
1381
|
+
static UNKNOWN = new N(0);
|
|
1287
1382
|
/** 128 bits per value. */
|
|
1288
|
-
static BIT128 = new
|
|
1383
|
+
static BIT128 = new N(16);
|
|
1289
1384
|
/** 64 bits per value. */
|
|
1290
|
-
static BIT64 = new
|
|
1385
|
+
static BIT64 = new N(8);
|
|
1291
1386
|
/** 32 bits per value. */
|
|
1292
|
-
static BIT32 = new
|
|
1387
|
+
static BIT32 = new N(4);
|
|
1293
1388
|
/** 16 bits per value. */
|
|
1294
|
-
static BIT16 = new
|
|
1389
|
+
static BIT16 = new N(2);
|
|
1295
1390
|
/** 8 bits per value. */
|
|
1296
|
-
static BIT8 = new
|
|
1391
|
+
static BIT8 = new N(1);
|
|
1297
1392
|
/** A zod schema for validating and transforming densities */
|
|
1298
|
-
static z =
|
|
1299
|
-
|
|
1300
|
-
|
|
1393
|
+
static z = s.union([
|
|
1394
|
+
s.number().transform((e) => new N(e)),
|
|
1395
|
+
s.instanceof(N)
|
|
1301
1396
|
]);
|
|
1302
|
-
}
|
|
1303
|
-
class v {
|
|
1397
|
+
}, F = class E {
|
|
1304
1398
|
/**
|
|
1305
1399
|
* The starting TimeStamp of the TimeRange.
|
|
1306
1400
|
*
|
|
@@ -1326,11 +1420,11 @@ class v {
|
|
|
1326
1420
|
* @param end - A TimeStamp representing the end of the range.
|
|
1327
1421
|
*/
|
|
1328
1422
|
constructor(e, t) {
|
|
1329
|
-
typeof e == "object" && "start" in e ? (this.start = new
|
|
1423
|
+
typeof e == "object" && "start" in e ? (this.start = new o(e.start), this.end = new o(e.end)) : (this.start = new o(e), this.end = new o(t));
|
|
1330
1424
|
}
|
|
1331
1425
|
/** @returns The TimeSpan occupied by the TimeRange. */
|
|
1332
1426
|
get span() {
|
|
1333
|
-
return new
|
|
1427
|
+
return new g(this.end.valueOf() - this.start.valueOf());
|
|
1334
1428
|
}
|
|
1335
1429
|
/**
|
|
1336
1430
|
* Checks if the timestamp is valid i.e. the start is before the end.
|
|
@@ -1368,7 +1462,7 @@ class v {
|
|
|
1368
1462
|
* @returns A TimeRange with the start and end swapped.
|
|
1369
1463
|
*/
|
|
1370
1464
|
swap() {
|
|
1371
|
-
return new
|
|
1465
|
+
return new E(this.end, this.start);
|
|
1372
1466
|
}
|
|
1373
1467
|
get numericBounds() {
|
|
1374
1468
|
return {
|
|
@@ -1382,11 +1476,11 @@ class v {
|
|
|
1382
1476
|
* @param other - The TimeRange to compare to.
|
|
1383
1477
|
* @returns True if the TimeRange is equal to the given TimeRange.
|
|
1384
1478
|
*/
|
|
1385
|
-
equals(e, t =
|
|
1479
|
+
equals(e, t = g.ZERO) {
|
|
1386
1480
|
if (t.isZero)
|
|
1387
1481
|
return this.start.equals(e.start) && this.end.equals(e.end);
|
|
1388
|
-
let
|
|
1389
|
-
return
|
|
1482
|
+
let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
|
|
1483
|
+
return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
|
|
1390
1484
|
}
|
|
1391
1485
|
/**
|
|
1392
1486
|
* Returns a string representation of the TimeRange.
|
|
@@ -1415,16 +1509,16 @@ class v {
|
|
|
1415
1509
|
* checking for overlap.
|
|
1416
1510
|
* @returns True if the two TimeRanges overlap, false otherwise.
|
|
1417
1511
|
*/
|
|
1418
|
-
overlapsWith(e, t =
|
|
1512
|
+
overlapsWith(e, t = g.ZERO) {
|
|
1419
1513
|
e = e.makeValid();
|
|
1420
|
-
const
|
|
1514
|
+
const n = this.makeValid();
|
|
1421
1515
|
if (this.equals(e)) return !0;
|
|
1422
|
-
if (e.end.equals(
|
|
1423
|
-
const i =
|
|
1424
|
-
return
|
|
1516
|
+
if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
|
|
1517
|
+
const i = o.max(n.start, e.start), a = o.min(n.end, e.end);
|
|
1518
|
+
return a.before(i) ? !1 : new g(a.sub(i)).greaterThanOrEqual(t);
|
|
1425
1519
|
}
|
|
1426
1520
|
contains(e) {
|
|
1427
|
-
return e instanceof
|
|
1521
|
+
return e instanceof E ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
|
|
1428
1522
|
}
|
|
1429
1523
|
/**
|
|
1430
1524
|
* Returns a new TimeRange that is bound by the given TimeRange.
|
|
@@ -1438,25 +1532,25 @@ class v {
|
|
|
1438
1532
|
* console.log(bounded); // TimeRange(1500, 2000)
|
|
1439
1533
|
*/
|
|
1440
1534
|
boundBy(e) {
|
|
1441
|
-
const t = new
|
|
1535
|
+
const t = new E(this.start, this.end);
|
|
1442
1536
|
return e.start.after(this.start) && (t.start = e.start), e.start.after(this.end) && (t.end = e.start), e.end.before(this.end) && (t.end = e.end), e.end.before(this.start) && (t.start = e.end), t;
|
|
1443
1537
|
}
|
|
1444
1538
|
static max(...e) {
|
|
1445
|
-
return new
|
|
1446
|
-
|
|
1447
|
-
|
|
1539
|
+
return new E(
|
|
1540
|
+
o.min(...e.map((t) => t.start)),
|
|
1541
|
+
o.max(...e.map((t) => t.end))
|
|
1448
1542
|
);
|
|
1449
1543
|
}
|
|
1450
1544
|
/** The maximum possible time range. */
|
|
1451
|
-
static MAX = new
|
|
1545
|
+
static MAX = new E(o.MIN, o.MAX);
|
|
1452
1546
|
/** The minimum possible time range. */
|
|
1453
|
-
static MIN = new
|
|
1547
|
+
static MIN = new E(o.MAX, o.MIN);
|
|
1454
1548
|
/** A time range whose start and end are both zero. */
|
|
1455
|
-
static ZERO = new
|
|
1549
|
+
static ZERO = new E(o.ZERO, o.ZERO);
|
|
1456
1550
|
/** A zod schema for validating and transforming time ranges */
|
|
1457
|
-
static z =
|
|
1458
|
-
|
|
1459
|
-
|
|
1551
|
+
static z = s.union([
|
|
1552
|
+
s.object({ start: o.z, end: o.z }).transform((e) => new E(e.start, e.end)),
|
|
1553
|
+
s.instanceof(E)
|
|
1460
1554
|
]);
|
|
1461
1555
|
/**
|
|
1462
1556
|
* Sorts two time ranges. The range with the earlier start time is considered less than
|
|
@@ -1470,15 +1564,30 @@ class v {
|
|
|
1470
1564
|
* equal.
|
|
1471
1565
|
*/
|
|
1472
1566
|
static sort(e, t) {
|
|
1473
|
-
return
|
|
1567
|
+
return o.sort(e.start, t.start) || o.sort(e.end, t.end);
|
|
1474
1568
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1569
|
+
/**
|
|
1570
|
+
* Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
|
|
1571
|
+
* merges any overlapping ranges.
|
|
1572
|
+
*
|
|
1573
|
+
* @param ranges - The list of `TimeRange`s to simplify.
|
|
1574
|
+
* @returns A list of simplified `TimeRange`s.
|
|
1575
|
+
*/
|
|
1576
|
+
static simplify(e) {
|
|
1577
|
+
return e.map((t) => t.makeValid()).sort((t, n) => E.sort(t, n)).reduce((t, n) => {
|
|
1578
|
+
if (n.isZero) return t;
|
|
1579
|
+
if (t.length === 0)
|
|
1580
|
+
return t.push(n), t;
|
|
1581
|
+
const i = t[t.length - 1];
|
|
1582
|
+
return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = o.max(i.end, n.end) : t.push(n), t;
|
|
1583
|
+
}, []);
|
|
1584
|
+
}
|
|
1585
|
+
}, w = class u extends q {
|
|
1477
1586
|
constructor(e) {
|
|
1478
|
-
if (e instanceof
|
|
1587
|
+
if (e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
|
|
1479
1588
|
super(e.valueOf());
|
|
1480
1589
|
else {
|
|
1481
|
-
const t =
|
|
1590
|
+
const t = u.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
|
|
1482
1591
|
if (t == null)
|
|
1483
1592
|
throw new Error(`unable to find data type for ${e.toString()}`);
|
|
1484
1593
|
super(t.valueOf());
|
|
@@ -1488,7 +1597,7 @@ class a extends j {
|
|
|
1488
1597
|
* @returns the TypedArray constructor for the DataType.
|
|
1489
1598
|
*/
|
|
1490
1599
|
get Array() {
|
|
1491
|
-
const e =
|
|
1600
|
+
const e = u.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
1492
1601
|
if (e == null)
|
|
1493
1602
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
1494
1603
|
return e;
|
|
@@ -1515,7 +1624,7 @@ class a extends j {
|
|
|
1515
1624
|
* @example DataType.INT32.isVariable // false
|
|
1516
1625
|
*/
|
|
1517
1626
|
get isVariable() {
|
|
1518
|
-
return this.equals(
|
|
1627
|
+
return this.equals(u.JSON) || this.equals(u.STRING);
|
|
1519
1628
|
}
|
|
1520
1629
|
/**
|
|
1521
1630
|
* @returns true if the DataType is numeric.
|
|
@@ -1523,7 +1632,7 @@ class a extends j {
|
|
|
1523
1632
|
* @example DataType.STRING.isNumeric // false
|
|
1524
1633
|
*/
|
|
1525
1634
|
get isNumeric() {
|
|
1526
|
-
return !this.isVariable && !this.equals(
|
|
1635
|
+
return !this.isVariable && !this.equals(u.UUID);
|
|
1527
1636
|
}
|
|
1528
1637
|
/**
|
|
1529
1638
|
* @returns true if the DataType is an integer.
|
|
@@ -1548,7 +1657,7 @@ class a extends j {
|
|
|
1548
1657
|
* @example DataType.FLOAT32.density // Density.BIT32
|
|
1549
1658
|
*/
|
|
1550
1659
|
get density() {
|
|
1551
|
-
const e =
|
|
1660
|
+
const e = u.DENSITIES.get(this.toString());
|
|
1552
1661
|
if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1553
1662
|
return e;
|
|
1554
1663
|
}
|
|
@@ -1558,7 +1667,7 @@ class a extends j {
|
|
|
1558
1667
|
* @example DataType.INT32.isUnsigned // false
|
|
1559
1668
|
*/
|
|
1560
1669
|
get isUnsignedInteger() {
|
|
1561
|
-
return this.equals(
|
|
1670
|
+
return this.equals(u.UINT8) || this.equals(u.UINT16) || this.equals(u.UINT32) || this.equals(u.UINT64);
|
|
1562
1671
|
}
|
|
1563
1672
|
/**
|
|
1564
1673
|
* @returns true if the DataType is a signed integer.
|
|
@@ -1566,11 +1675,11 @@ class a extends j {
|
|
|
1566
1675
|
* @example DataType.UINT32.isSigned // false
|
|
1567
1676
|
*/
|
|
1568
1677
|
get isSignedInteger() {
|
|
1569
|
-
return this.equals(
|
|
1678
|
+
return this.equals(u.INT8) || this.equals(u.INT16) || this.equals(u.INT32) || this.equals(u.INT64);
|
|
1570
1679
|
}
|
|
1571
1680
|
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
1572
1681
|
canSafelyCastTo(e) {
|
|
1573
|
-
return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(
|
|
1682
|
+
return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(u.INT32) && e.equals(u.FLOAT64) || this.equals(u.INT8) && e.equals(u.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
|
|
1574
1683
|
}
|
|
1575
1684
|
/** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
|
|
1576
1685
|
canCastTo(e) {
|
|
@@ -1587,112 +1696,111 @@ class a extends j {
|
|
|
1587
1696
|
}
|
|
1588
1697
|
/** @returns true if the data type uses bigints to store values. */
|
|
1589
1698
|
get usesBigInt() {
|
|
1590
|
-
return
|
|
1699
|
+
return u.BIG_INT_TYPES.some((e) => e.equals(this));
|
|
1591
1700
|
}
|
|
1592
1701
|
/** Represents an Unknown/Invalid DataType. */
|
|
1593
|
-
static UNKNOWN = new
|
|
1702
|
+
static UNKNOWN = new u("unknown");
|
|
1594
1703
|
/** Represents a 64-bit floating point value. */
|
|
1595
|
-
static FLOAT64 = new
|
|
1704
|
+
static FLOAT64 = new u("float64");
|
|
1596
1705
|
/** Represents a 32-bit floating point value. */
|
|
1597
|
-
static FLOAT32 = new
|
|
1706
|
+
static FLOAT32 = new u("float32");
|
|
1598
1707
|
/** Represents a 64-bit signed integer value. */
|
|
1599
|
-
static INT64 = new
|
|
1708
|
+
static INT64 = new u("int64");
|
|
1600
1709
|
/** Represents a 32-bit signed integer value. */
|
|
1601
|
-
static INT32 = new
|
|
1710
|
+
static INT32 = new u("int32");
|
|
1602
1711
|
/** Represents a 16-bit signed integer value. */
|
|
1603
|
-
static INT16 = new
|
|
1712
|
+
static INT16 = new u("int16");
|
|
1604
1713
|
/** Represents a 8-bit signed integer value. */
|
|
1605
|
-
static INT8 = new
|
|
1714
|
+
static INT8 = new u("int8");
|
|
1606
1715
|
/** Represents a 64-bit unsigned integer value. */
|
|
1607
|
-
static UINT64 = new
|
|
1716
|
+
static UINT64 = new u("uint64");
|
|
1608
1717
|
/** Represents a 32-bit unsigned integer value. */
|
|
1609
|
-
static UINT32 = new
|
|
1718
|
+
static UINT32 = new u("uint32");
|
|
1610
1719
|
/** Represents a 16-bit unsigned integer value. */
|
|
1611
|
-
static UINT16 = new
|
|
1720
|
+
static UINT16 = new u("uint16");
|
|
1612
1721
|
/** Represents a 8-bit unsigned integer value. */
|
|
1613
|
-
static UINT8 = new
|
|
1722
|
+
static UINT8 = new u("uint8");
|
|
1614
1723
|
/** Represents a boolean value. Alias for UINT8. */
|
|
1615
1724
|
static BOOLEAN = this.UINT8;
|
|
1616
1725
|
/** Represents a 64-bit unix epoch. */
|
|
1617
|
-
static TIMESTAMP = new
|
|
1726
|
+
static TIMESTAMP = new u("timestamp");
|
|
1618
1727
|
/** Represents a UUID data type */
|
|
1619
|
-
static UUID = new
|
|
1728
|
+
static UUID = new u("uuid");
|
|
1620
1729
|
/** Represents a string data type. Strings have an unknown density, and are separate
|
|
1621
1730
|
* by a newline character. */
|
|
1622
|
-
static STRING = new
|
|
1731
|
+
static STRING = new u("string");
|
|
1623
1732
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1624
1733
|
* newline character. */
|
|
1625
|
-
static JSON = new
|
|
1734
|
+
static JSON = new u("json");
|
|
1626
1735
|
static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
|
|
1627
|
-
[
|
|
1628
|
-
[
|
|
1629
|
-
[
|
|
1630
|
-
[
|
|
1631
|
-
[
|
|
1632
|
-
[
|
|
1633
|
-
[
|
|
1634
|
-
[
|
|
1635
|
-
[
|
|
1636
|
-
[
|
|
1637
|
-
[
|
|
1638
|
-
[
|
|
1639
|
-
[
|
|
1640
|
-
[
|
|
1736
|
+
[u.UINT8.toString(), Uint8Array],
|
|
1737
|
+
[u.UINT16.toString(), Uint16Array],
|
|
1738
|
+
[u.UINT32.toString(), Uint32Array],
|
|
1739
|
+
[u.UINT64.toString(), BigUint64Array],
|
|
1740
|
+
[u.FLOAT32.toString(), Float32Array],
|
|
1741
|
+
[u.FLOAT64.toString(), Float64Array],
|
|
1742
|
+
[u.INT8.toString(), Int8Array],
|
|
1743
|
+
[u.INT16.toString(), Int16Array],
|
|
1744
|
+
[u.INT32.toString(), Int32Array],
|
|
1745
|
+
[u.INT64.toString(), BigInt64Array],
|
|
1746
|
+
[u.TIMESTAMP.toString(), BigInt64Array],
|
|
1747
|
+
[u.STRING.toString(), Uint8Array],
|
|
1748
|
+
[u.JSON.toString(), Uint8Array],
|
|
1749
|
+
[u.UUID.toString(), Uint8Array]
|
|
1641
1750
|
]);
|
|
1642
1751
|
static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
|
|
1643
|
-
[Uint8Array.name,
|
|
1644
|
-
[Uint16Array.name,
|
|
1645
|
-
[Uint32Array.name,
|
|
1646
|
-
[BigUint64Array.name,
|
|
1647
|
-
[Float32Array.name,
|
|
1648
|
-
[Float64Array.name,
|
|
1649
|
-
[Int8Array.name,
|
|
1650
|
-
[Int16Array.name,
|
|
1651
|
-
[Int32Array.name,
|
|
1652
|
-
[BigInt64Array.name,
|
|
1752
|
+
[Uint8Array.name, u.UINT8],
|
|
1753
|
+
[Uint16Array.name, u.UINT16],
|
|
1754
|
+
[Uint32Array.name, u.UINT32],
|
|
1755
|
+
[BigUint64Array.name, u.UINT64],
|
|
1756
|
+
[Float32Array.name, u.FLOAT32],
|
|
1757
|
+
[Float64Array.name, u.FLOAT64],
|
|
1758
|
+
[Int8Array.name, u.INT8],
|
|
1759
|
+
[Int16Array.name, u.INT16],
|
|
1760
|
+
[Int32Array.name, u.INT32],
|
|
1761
|
+
[BigInt64Array.name, u.INT64]
|
|
1653
1762
|
]);
|
|
1654
1763
|
static DENSITIES = /* @__PURE__ */ new Map([
|
|
1655
|
-
[
|
|
1656
|
-
[
|
|
1657
|
-
[
|
|
1658
|
-
[
|
|
1659
|
-
[
|
|
1660
|
-
[
|
|
1661
|
-
[
|
|
1662
|
-
[
|
|
1663
|
-
[
|
|
1664
|
-
[
|
|
1665
|
-
[
|
|
1666
|
-
[
|
|
1667
|
-
[
|
|
1668
|
-
[
|
|
1764
|
+
[u.UINT8.toString(), I.BIT8],
|
|
1765
|
+
[u.UINT16.toString(), I.BIT16],
|
|
1766
|
+
[u.UINT32.toString(), I.BIT32],
|
|
1767
|
+
[u.UINT64.toString(), I.BIT64],
|
|
1768
|
+
[u.FLOAT32.toString(), I.BIT32],
|
|
1769
|
+
[u.FLOAT64.toString(), I.BIT64],
|
|
1770
|
+
[u.INT8.toString(), I.BIT8],
|
|
1771
|
+
[u.INT16.toString(), I.BIT16],
|
|
1772
|
+
[u.INT32.toString(), I.BIT32],
|
|
1773
|
+
[u.INT64.toString(), I.BIT64],
|
|
1774
|
+
[u.TIMESTAMP.toString(), I.BIT64],
|
|
1775
|
+
[u.STRING.toString(), I.UNKNOWN],
|
|
1776
|
+
[u.JSON.toString(), I.UNKNOWN],
|
|
1777
|
+
[u.UUID.toString(), I.BIT128]
|
|
1669
1778
|
]);
|
|
1670
1779
|
/** All the data types. */
|
|
1671
1780
|
static ALL = [
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1781
|
+
u.UNKNOWN,
|
|
1782
|
+
u.FLOAT64,
|
|
1783
|
+
u.FLOAT32,
|
|
1784
|
+
u.INT64,
|
|
1785
|
+
u.INT32,
|
|
1786
|
+
u.INT16,
|
|
1787
|
+
u.INT8,
|
|
1788
|
+
u.UINT64,
|
|
1789
|
+
u.UINT32,
|
|
1790
|
+
u.UINT16,
|
|
1791
|
+
u.UINT8,
|
|
1792
|
+
u.TIMESTAMP,
|
|
1793
|
+
u.UUID,
|
|
1794
|
+
u.STRING,
|
|
1795
|
+
u.JSON
|
|
1687
1796
|
];
|
|
1688
|
-
static BIG_INT_TYPES = [
|
|
1797
|
+
static BIG_INT_TYPES = [u.INT64, u.UINT64, u.TIMESTAMP];
|
|
1689
1798
|
/** A zod schema for a DataType. */
|
|
1690
|
-
static z =
|
|
1691
|
-
|
|
1692
|
-
|
|
1799
|
+
static z = s.union([
|
|
1800
|
+
s.string().transform((e) => new u(e)),
|
|
1801
|
+
s.instanceof(u)
|
|
1693
1802
|
]);
|
|
1694
|
-
}
|
|
1695
|
-
class p extends j {
|
|
1803
|
+
}, oe = class m extends q {
|
|
1696
1804
|
constructor(e) {
|
|
1697
1805
|
super(e.valueOf());
|
|
1698
1806
|
}
|
|
@@ -1706,41 +1814,59 @@ class p extends j {
|
|
|
1706
1814
|
}
|
|
1707
1815
|
/** @returns a new Size representing the sum of the two Sizes. */
|
|
1708
1816
|
add(e) {
|
|
1709
|
-
return
|
|
1817
|
+
return new m(ee(this.valueOf(), e.valueOf()));
|
|
1710
1818
|
}
|
|
1711
1819
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1712
1820
|
sub(e) {
|
|
1713
|
-
return
|
|
1821
|
+
return new m(_(this.valueOf(), e.valueOf()));
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Multiplies this Size by a scalar value.
|
|
1825
|
+
*
|
|
1826
|
+
* @param value - The scalar value to multiply by.
|
|
1827
|
+
* @returns A new Size representing this Size multiplied by the value.
|
|
1828
|
+
*/
|
|
1829
|
+
mult(e) {
|
|
1830
|
+
return new m(U(this.valueOf(), e));
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Divides this Size by a scalar value.
|
|
1834
|
+
*
|
|
1835
|
+
* @param value - The scalar value to divide by.
|
|
1836
|
+
* @returns A new Size representing this Size divided by the value.
|
|
1837
|
+
*/
|
|
1838
|
+
div(e) {
|
|
1839
|
+
return new m(te(this.valueOf(), e));
|
|
1714
1840
|
}
|
|
1715
1841
|
/** @returns a new Size representing the truncated value of the Size. */
|
|
1716
1842
|
truncate(e) {
|
|
1717
|
-
return new
|
|
1843
|
+
return new m(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
|
|
1718
1844
|
}
|
|
1719
1845
|
/** @returns a new Size representing the remainder of the Size. */
|
|
1720
1846
|
remainder(e) {
|
|
1721
|
-
return
|
|
1847
|
+
return m.bytes(this.valueOf() % e.valueOf());
|
|
1722
1848
|
}
|
|
1723
1849
|
/** @returns the number of gigabytes in the Size. */
|
|
1724
1850
|
get gigabytes() {
|
|
1725
|
-
return this.valueOf() /
|
|
1851
|
+
return this.valueOf() / m.GIGABYTE.valueOf();
|
|
1726
1852
|
}
|
|
1727
1853
|
/** @returns the number of megabytes in the Size. */
|
|
1728
1854
|
get megabytes() {
|
|
1729
|
-
return this.valueOf() /
|
|
1855
|
+
return this.valueOf() / m.MEGABYTE.valueOf();
|
|
1730
1856
|
}
|
|
1731
1857
|
/** @returns the number of kilobytes in the Size. */
|
|
1732
1858
|
get kilobytes() {
|
|
1733
|
-
return this.valueOf() /
|
|
1859
|
+
return this.valueOf() / m.KILOBYTE.valueOf();
|
|
1734
1860
|
}
|
|
1735
1861
|
/** @returns the number of terabytes in the Size. */
|
|
1736
1862
|
get terabytes() {
|
|
1737
|
-
return this.valueOf() /
|
|
1863
|
+
return this.valueOf() / m.TERABYTE.valueOf();
|
|
1738
1864
|
}
|
|
1739
1865
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1740
1866
|
toString() {
|
|
1741
|
-
const e = this.truncate(
|
|
1742
|
-
let
|
|
1743
|
-
return
|
|
1867
|
+
const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), a = this.truncate(m.BYTE), c = e, d = t.sub(e), y = n.sub(t), f = i.sub(n), p = a.sub(i);
|
|
1868
|
+
let b = "";
|
|
1869
|
+
return c.isZero || (b += `${c.terabytes}TB `), d.isZero || (b += `${d.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), f.isZero || (b += `${f.kilobytes}KB `), (!p.isZero || b === "") && (b += `${p.valueOf()}B`), b.trim();
|
|
1744
1870
|
}
|
|
1745
1871
|
/**
|
|
1746
1872
|
* Creates a Size from the given number of bytes.
|
|
@@ -1749,10 +1875,10 @@ class p extends j {
|
|
|
1749
1875
|
* @returns A Size representing the given number of bytes.
|
|
1750
1876
|
*/
|
|
1751
1877
|
static bytes(e = 1) {
|
|
1752
|
-
return new
|
|
1878
|
+
return new m(e);
|
|
1753
1879
|
}
|
|
1754
1880
|
/** A single byte */
|
|
1755
|
-
static BYTE = new
|
|
1881
|
+
static BYTE = new m(1);
|
|
1756
1882
|
/**
|
|
1757
1883
|
* Creates a Size from the given number if kilobytes.
|
|
1758
1884
|
*
|
|
@@ -1760,10 +1886,10 @@ class p extends j {
|
|
|
1760
1886
|
* @returns A Size representing the given number of kilobytes.
|
|
1761
1887
|
*/
|
|
1762
1888
|
static kilobytes(e = 1) {
|
|
1763
|
-
return
|
|
1889
|
+
return m.bytes(e.valueOf() * 1e3);
|
|
1764
1890
|
}
|
|
1765
1891
|
/** A kilobyte */
|
|
1766
|
-
static KILOBYTE =
|
|
1892
|
+
static KILOBYTE = m.kilobytes(1);
|
|
1767
1893
|
/**
|
|
1768
1894
|
* Creates a Size from the given number of megabytes.
|
|
1769
1895
|
*
|
|
@@ -1771,10 +1897,10 @@ class p extends j {
|
|
|
1771
1897
|
* @returns A Size representing the given number of megabytes.
|
|
1772
1898
|
*/
|
|
1773
1899
|
static megabytes(e = 1) {
|
|
1774
|
-
return
|
|
1900
|
+
return m.kilobytes(e.valueOf() * 1e3);
|
|
1775
1901
|
}
|
|
1776
1902
|
/** A megabyte */
|
|
1777
|
-
static MEGABYTE =
|
|
1903
|
+
static MEGABYTE = m.megabytes(1);
|
|
1778
1904
|
/**
|
|
1779
1905
|
* Creates a Size from the given number of gigabytes.
|
|
1780
1906
|
*
|
|
@@ -1782,10 +1908,10 @@ class p extends j {
|
|
|
1782
1908
|
* @returns A Size representing the given number of gigabytes.
|
|
1783
1909
|
*/
|
|
1784
1910
|
static gigabytes(e = 1) {
|
|
1785
|
-
return
|
|
1911
|
+
return m.megabytes(e.valueOf() * 1e3);
|
|
1786
1912
|
}
|
|
1787
1913
|
/** A gigabyte */
|
|
1788
|
-
static GIGABYTE =
|
|
1914
|
+
static GIGABYTE = m.gigabytes(1);
|
|
1789
1915
|
/**
|
|
1790
1916
|
* Creates a Size from the given number of terabytes.
|
|
1791
1917
|
*
|
|
@@ -1793,65 +1919,65 @@ class p extends j {
|
|
|
1793
1919
|
* @returns A Size representing the given number of terabytes.
|
|
1794
1920
|
*/
|
|
1795
1921
|
static terabytes(e) {
|
|
1796
|
-
return
|
|
1922
|
+
return m.gigabytes(e.valueOf() * 1e3);
|
|
1797
1923
|
}
|
|
1798
1924
|
/** A terabyte. */
|
|
1799
|
-
static TERABYTE =
|
|
1925
|
+
static TERABYTE = m.terabytes(1);
|
|
1800
1926
|
/** The zero value for Size */
|
|
1801
|
-
static ZERO = new
|
|
1927
|
+
static ZERO = new m(0);
|
|
1802
1928
|
/** A zod schema for a Size. */
|
|
1803
|
-
static z =
|
|
1804
|
-
|
|
1805
|
-
|
|
1929
|
+
static z = s.union([
|
|
1930
|
+
s.number().transform((e) => new m(e)),
|
|
1931
|
+
s.instanceof(m)
|
|
1806
1932
|
]);
|
|
1807
1933
|
/** @returns true if the Size is zero. */
|
|
1808
1934
|
get isZero() {
|
|
1809
1935
|
return this.valueOf() === 0;
|
|
1810
1936
|
}
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1937
|
+
};
|
|
1938
|
+
s.union([
|
|
1939
|
+
s.instanceof(Uint8Array),
|
|
1940
|
+
s.instanceof(Uint16Array),
|
|
1941
|
+
s.instanceof(Uint32Array),
|
|
1942
|
+
s.instanceof(BigUint64Array),
|
|
1943
|
+
s.instanceof(Float32Array),
|
|
1944
|
+
s.instanceof(Float64Array),
|
|
1945
|
+
s.instanceof(Int8Array),
|
|
1946
|
+
s.instanceof(Int16Array),
|
|
1947
|
+
s.instanceof(Int32Array),
|
|
1948
|
+
s.instanceof(BigInt64Array)
|
|
1823
1949
|
]);
|
|
1824
|
-
const
|
|
1825
|
-
const e = typeof
|
|
1826
|
-
return e === "string" || e === "number" || e === "boolean" || e === "bigint" ||
|
|
1827
|
-
},
|
|
1828
|
-
function
|
|
1829
|
-
return typeof
|
|
1950
|
+
const Pe = (r) => {
|
|
1951
|
+
const e = typeof r;
|
|
1952
|
+
return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof o || r instanceof g || r instanceof Date;
|
|
1953
|
+
}, jt = (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), H = (r, e) => e == 0 ? r : r == 0 ? e : typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : Number(r) + Number(e), qt = /^(?:[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;
|
|
1954
|
+
function Ft(r) {
|
|
1955
|
+
return typeof r == "string" && qt.test(r);
|
|
1830
1956
|
}
|
|
1831
|
-
const
|
|
1832
|
-
for (let
|
|
1833
|
-
|
|
1834
|
-
function
|
|
1835
|
-
return (
|
|
1957
|
+
const v = [];
|
|
1958
|
+
for (let r = 0; r < 256; ++r)
|
|
1959
|
+
v.push((r + 256).toString(16).slice(1));
|
|
1960
|
+
function Wt(r, e = 0) {
|
|
1961
|
+
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();
|
|
1836
1962
|
}
|
|
1837
|
-
function
|
|
1838
|
-
const t =
|
|
1839
|
-
if (
|
|
1963
|
+
function Zt(r, e = 0) {
|
|
1964
|
+
const t = Wt(r, e);
|
|
1965
|
+
if (!Ft(t))
|
|
1840
1966
|
throw TypeError("Stringified UUID is invalid");
|
|
1841
1967
|
return t;
|
|
1842
1968
|
}
|
|
1843
1969
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1844
|
-
const
|
|
1845
|
-
(
|
|
1846
|
-
atob(
|
|
1970
|
+
const ke = (r, e) => Zt(r, e), $ = -1, Vt = s.string().transform(
|
|
1971
|
+
(r) => new Uint8Array(
|
|
1972
|
+
atob(r).split("").map((e) => e.charCodeAt(0))
|
|
1847
1973
|
).buffer
|
|
1848
|
-
),
|
|
1849
|
-
if (
|
|
1974
|
+
), zt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), ue = 10, Gt = (r, e) => {
|
|
1975
|
+
if (r === "number" && !e.isNumeric)
|
|
1850
1976
|
throw new Error(`cannot convert series of type ${e.toString()} to number`);
|
|
1851
|
-
if (
|
|
1977
|
+
if (r === "bigint" && !e.usesBigInt)
|
|
1852
1978
|
throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
|
|
1853
|
-
},
|
|
1854
|
-
class
|
|
1979
|
+
}, Ye = "sy_x_telem_series";
|
|
1980
|
+
class M {
|
|
1855
1981
|
/**
|
|
1856
1982
|
* A unique identifier for the series. If specified by the user, it is their
|
|
1857
1983
|
* responsibility to ensure that it is unique. If not specified, a new ID will be
|
|
@@ -1862,7 +1988,7 @@ class N {
|
|
|
1862
1988
|
* A discriminator used for identifying instances of the series class even
|
|
1863
1989
|
* when bundlers mangle the class name.
|
|
1864
1990
|
*/
|
|
1865
|
-
discriminator =
|
|
1991
|
+
discriminator = Ye;
|
|
1866
1992
|
/** The data type of the series. */
|
|
1867
1993
|
dataType;
|
|
1868
1994
|
/**
|
|
@@ -1878,18 +2004,24 @@ class N {
|
|
|
1878
2004
|
/** The underlying data. */
|
|
1879
2005
|
_data;
|
|
1880
2006
|
/** The time range occupied by the series' data. */
|
|
1881
|
-
timeRange =
|
|
2007
|
+
timeRange = F.ZERO;
|
|
1882
2008
|
/**
|
|
1883
2009
|
* Alignment defines the location of the series relative to other series in a logical
|
|
1884
2010
|
* group. Useful for defining the position of the series within a channel's data.
|
|
1885
2011
|
*/
|
|
1886
2012
|
alignment = 0n;
|
|
2013
|
+
/**
|
|
2014
|
+
* Alignment multiple defines the number of alignment steps taken per sample. This is
|
|
2015
|
+
* useful for when the samples in a series represent a partial view of the raw data
|
|
2016
|
+
* i.e. decimation or averaging.
|
|
2017
|
+
*/
|
|
2018
|
+
alignmentMultiple = 1n;
|
|
1887
2019
|
/** A cached minimum value. */
|
|
1888
2020
|
cachedMin;
|
|
1889
2021
|
/** A cached maximum value. */
|
|
1890
2022
|
cachedMax;
|
|
1891
2023
|
/** The write position of the buffer. */
|
|
1892
|
-
writePos =
|
|
2024
|
+
writePos = $;
|
|
1893
2025
|
/** Tracks the number of entities currently using this array. */
|
|
1894
2026
|
_refCount = 0;
|
|
1895
2027
|
/** Caches the length of the array for variable length data types. */
|
|
@@ -1900,23 +2032,23 @@ class N {
|
|
|
1900
2032
|
* A zod schema that can be used to validate that a particular value
|
|
1901
2033
|
* can be constructed into a series.
|
|
1902
2034
|
*/
|
|
1903
|
-
static crudeZ =
|
|
1904
|
-
timeRange:
|
|
1905
|
-
dataType:
|
|
1906
|
-
alignment:
|
|
1907
|
-
data:
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2035
|
+
static crudeZ = s.object({
|
|
2036
|
+
timeRange: F.z.optional(),
|
|
2037
|
+
dataType: w.z,
|
|
2038
|
+
alignment: s.coerce.bigint().optional(),
|
|
2039
|
+
data: s.union([
|
|
2040
|
+
Vt,
|
|
2041
|
+
zt,
|
|
2042
|
+
s.instanceof(ArrayBuffer),
|
|
2043
|
+
s.instanceof(Uint8Array)
|
|
1912
2044
|
]),
|
|
1913
|
-
glBufferUsage:
|
|
2045
|
+
glBufferUsage: kt.optional().default("static").optional()
|
|
1914
2046
|
});
|
|
1915
2047
|
/**
|
|
1916
2048
|
* A zod schema that validates and constructs a series from it's crude
|
|
1917
2049
|
* representation.
|
|
1918
2050
|
*/
|
|
1919
|
-
static z =
|
|
2051
|
+
static z = M.crudeZ.transform((e) => new M(e));
|
|
1920
2052
|
/**
|
|
1921
2053
|
* The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
|
|
1922
2054
|
*
|
|
@@ -1991,73 +2123,74 @@ class N {
|
|
|
1991
2123
|
* @throws Error if data type cannot be inferred from input
|
|
1992
2124
|
*/
|
|
1993
2125
|
constructor(e) {
|
|
1994
|
-
|
|
2126
|
+
Jt(e) && (e = { data: e }), e.data ??= [];
|
|
1995
2127
|
const {
|
|
1996
2128
|
dataType: t,
|
|
1997
|
-
timeRange:
|
|
2129
|
+
timeRange: n,
|
|
1998
2130
|
sampleOffset: i = 0,
|
|
1999
|
-
glBufferUsage:
|
|
2000
|
-
alignment:
|
|
2001
|
-
|
|
2131
|
+
glBufferUsage: a = "static",
|
|
2132
|
+
alignment: c = 0n,
|
|
2133
|
+
alignmentMultiple: d = 1n,
|
|
2134
|
+
key: y = Lt(),
|
|
2002
2135
|
data: f
|
|
2003
2136
|
} = e;
|
|
2004
|
-
if (
|
|
2137
|
+
if (Ht(f)) {
|
|
2005
2138
|
const h = f;
|
|
2006
|
-
this.key = h.key, this.dataType = h.dataType, this.sampleOffset = h.sampleOffset, this.gl = h.gl, this._data = h._data, this.timeRange = h.timeRange, this.alignment = h.alignment, this.cachedMin = h.cachedMin, this.cachedMax = h.cachedMax, this.writePos = h.writePos, this._refCount = h._refCount, this.cachedLength = h.cachedLength;
|
|
2139
|
+
this.key = h.key, this.dataType = h.dataType, this.sampleOffset = h.sampleOffset, this.gl = h.gl, this._data = h._data, this.timeRange = h.timeRange, this.alignment = h.alignment, this.alignmentMultiple = h.alignmentMultiple, this.cachedMin = h.cachedMin, this.cachedMax = h.cachedMax, this.writePos = h.writePos, this._refCount = h._refCount, this.cachedLength = h.cachedLength;
|
|
2007
2140
|
return;
|
|
2008
2141
|
}
|
|
2009
|
-
const
|
|
2010
|
-
if (t != null) this.dataType = new
|
|
2142
|
+
const p = Pe(f), b = Array.isArray(f);
|
|
2143
|
+
if (t != null) this.dataType = new w(t);
|
|
2011
2144
|
else {
|
|
2012
2145
|
if (f instanceof ArrayBuffer)
|
|
2013
2146
|
throw new Error(
|
|
2014
2147
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
2015
2148
|
);
|
|
2016
|
-
if (
|
|
2149
|
+
if (b || p) {
|
|
2017
2150
|
let h = f;
|
|
2018
|
-
if (!
|
|
2151
|
+
if (!p) {
|
|
2019
2152
|
if (f.length === 0)
|
|
2020
2153
|
throw new Error(
|
|
2021
2154
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
2022
2155
|
);
|
|
2023
2156
|
h = f[0];
|
|
2024
2157
|
}
|
|
2025
|
-
if (typeof h == "string") this.dataType =
|
|
2026
|
-
else if (typeof h == "number") this.dataType =
|
|
2027
|
-
else if (typeof h == "bigint") this.dataType =
|
|
2028
|
-
else if (typeof h == "boolean") this.dataType =
|
|
2029
|
-
else if (h instanceof
|
|
2030
|
-
this.dataType =
|
|
2031
|
-
else if (typeof h == "object") this.dataType =
|
|
2158
|
+
if (typeof h == "string") this.dataType = w.STRING;
|
|
2159
|
+
else if (typeof h == "number") this.dataType = w.FLOAT64;
|
|
2160
|
+
else if (typeof h == "bigint") this.dataType = w.INT64;
|
|
2161
|
+
else if (typeof h == "boolean") this.dataType = w.BOOLEAN;
|
|
2162
|
+
else if (h instanceof o || h instanceof Date || h instanceof o)
|
|
2163
|
+
this.dataType = w.TIMESTAMP;
|
|
2164
|
+
else if (typeof h == "object") this.dataType = w.JSON;
|
|
2032
2165
|
else
|
|
2033
2166
|
throw new Error(
|
|
2034
2167
|
`cannot infer data type of ${typeof h} when constructing a Series from a JS array`
|
|
2035
2168
|
);
|
|
2036
|
-
} else this.dataType = new
|
|
2169
|
+
} else this.dataType = new w(f);
|
|
2037
2170
|
}
|
|
2038
|
-
if (!
|
|
2039
|
-
else if (
|
|
2171
|
+
if (!b && !p) this._data = f;
|
|
2172
|
+
else if (b && f.length === 0)
|
|
2040
2173
|
this._data = new this.dataType.Array([]).buffer;
|
|
2041
2174
|
else {
|
|
2042
|
-
let h =
|
|
2043
|
-
const
|
|
2044
|
-
(
|
|
2175
|
+
let h = p ? [f] : f;
|
|
2176
|
+
const T = h[0];
|
|
2177
|
+
(T instanceof o || T instanceof Date || T instanceof g) && (h = h.map((x) => new o(x).valueOf())), this.dataType.equals(w.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
|
|
2045
2178
|
`)}
|
|
2046
|
-
`).buffer) : this.dataType.equals(
|
|
2047
|
-
`${h.map((
|
|
2179
|
+
`).buffer) : this.dataType.equals(w.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
|
|
2180
|
+
`${h.map((x) => ae.encodeString(x)).join(`
|
|
2048
2181
|
`)}
|
|
2049
2182
|
`
|
|
2050
|
-
).buffer) : this.dataType.usesBigInt && typeof
|
|
2051
|
-
h.map((
|
|
2052
|
-
).buffer : !this.dataType.usesBigInt && typeof
|
|
2183
|
+
).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
|
|
2184
|
+
h.map((x) => BigInt(Math.round(x)))
|
|
2185
|
+
).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
|
|
2053
2186
|
h.map(Number)
|
|
2054
2187
|
).buffer : this._data = new this.dataType.Array(h).buffer;
|
|
2055
2188
|
}
|
|
2056
|
-
this.key =
|
|
2189
|
+
this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? F.ZERO, this.gl = {
|
|
2057
2190
|
control: null,
|
|
2058
2191
|
buffer: null,
|
|
2059
2192
|
prevBuffer: 0,
|
|
2060
|
-
bufferUsage:
|
|
2193
|
+
bufferUsage: a
|
|
2061
2194
|
};
|
|
2062
2195
|
}
|
|
2063
2196
|
/**
|
|
@@ -2067,11 +2200,11 @@ class N {
|
|
|
2067
2200
|
* @param args.dataType the data type of the series.
|
|
2068
2201
|
* @param args.rest the rest of the arguments to pass to the series constructor.
|
|
2069
2202
|
*/
|
|
2070
|
-
static alloc({ capacity: e, dataType: t, ...
|
|
2203
|
+
static alloc({ capacity: e, dataType: t, ...n }) {
|
|
2071
2204
|
if (e === 0)
|
|
2072
2205
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
2073
|
-
const i = new new
|
|
2074
|
-
return
|
|
2206
|
+
const i = new new w(t).Array(e), a = new M({ data: i.buffer, dataType: t, ...n });
|
|
2207
|
+
return a.writePos = 0, a;
|
|
2075
2208
|
}
|
|
2076
2209
|
/**
|
|
2077
2210
|
* @returns the number of references to this series i.e. the number of times this
|
|
@@ -2113,14 +2246,14 @@ class N {
|
|
|
2113
2246
|
return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
|
|
2114
2247
|
}
|
|
2115
2248
|
writeVariable(e) {
|
|
2116
|
-
if (this.writePos ===
|
|
2117
|
-
const t = this.byteCapacity.valueOf() - this.writePos,
|
|
2118
|
-
return this.writeToUnderlyingData(
|
|
2249
|
+
if (this.writePos === $) return 0;
|
|
2250
|
+
const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
|
|
2251
|
+
return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += n.length, this.calculateCachedLength()), n.length;
|
|
2119
2252
|
}
|
|
2120
2253
|
writeFixed(e) {
|
|
2121
|
-
if (this.writePos ===
|
|
2122
|
-
const t = this.capacity - this.writePos,
|
|
2123
|
-
return this.writeToUnderlyingData(
|
|
2254
|
+
if (this.writePos === $) return 0;
|
|
2255
|
+
const t = this.capacity - this.writePos, n = e.sub(0, t);
|
|
2256
|
+
return this.writeToUnderlyingData(n), this.cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
|
|
2124
2257
|
}
|
|
2125
2258
|
writeToUnderlyingData(e) {
|
|
2126
2259
|
this.underlyingData.set(
|
|
@@ -2141,7 +2274,7 @@ class N {
|
|
|
2141
2274
|
* @returns A typed array containing the series data.
|
|
2142
2275
|
*/
|
|
2143
2276
|
get data() {
|
|
2144
|
-
return this.writePos ===
|
|
2277
|
+
return this.writePos === $ ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
2145
2278
|
}
|
|
2146
2279
|
/**
|
|
2147
2280
|
* Returns an array of the values in the series as strings.
|
|
@@ -2160,16 +2293,16 @@ class N {
|
|
|
2160
2293
|
* @returns An array of values parsed from the JSON series.
|
|
2161
2294
|
*/
|
|
2162
2295
|
parseJSON(e) {
|
|
2163
|
-
if (!this.dataType.equals(
|
|
2296
|
+
if (!this.dataType.equals(w.JSON))
|
|
2164
2297
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
2165
|
-
return this.toStrings().map((t) => e.parse(
|
|
2298
|
+
return this.toStrings().map((t) => e.parse(ae.decodeString(t)));
|
|
2166
2299
|
}
|
|
2167
2300
|
/**
|
|
2168
2301
|
* Returns the capacity of the series in bytes.
|
|
2169
2302
|
* @returns The size of the underlying buffer in bytes.
|
|
2170
2303
|
*/
|
|
2171
2304
|
get byteCapacity() {
|
|
2172
|
-
return new
|
|
2305
|
+
return new oe(this.underlyingData.byteLength);
|
|
2173
2306
|
}
|
|
2174
2307
|
/**
|
|
2175
2308
|
* Returns the capacity of the series in samples.
|
|
@@ -2185,7 +2318,7 @@ class N {
|
|
|
2185
2318
|
* @returns The size of the data in bytes.
|
|
2186
2319
|
*/
|
|
2187
2320
|
get byteLength() {
|
|
2188
|
-
return this.writePos ===
|
|
2321
|
+
return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new oe(this.writePos) : this.dataType.density.size(this.writePos);
|
|
2189
2322
|
}
|
|
2190
2323
|
/**
|
|
2191
2324
|
* Returns the number of samples in this array.
|
|
@@ -2193,15 +2326,15 @@ class N {
|
|
|
2193
2326
|
* @returns The number of samples in the series.
|
|
2194
2327
|
*/
|
|
2195
2328
|
get length() {
|
|
2196
|
-
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos ===
|
|
2329
|
+
return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === $ ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
|
|
2197
2330
|
}
|
|
2198
2331
|
calculateCachedLength() {
|
|
2199
2332
|
if (!this.dataType.isVariable)
|
|
2200
2333
|
throw new Error("cannot calculate length of a non-variable length data type");
|
|
2201
2334
|
let e = 0;
|
|
2202
2335
|
const t = [0];
|
|
2203
|
-
return this.data.forEach((
|
|
2204
|
-
|
|
2336
|
+
return this.data.forEach((n, i) => {
|
|
2337
|
+
n === ue && (e++, t.push(i + 1));
|
|
2205
2338
|
}), this._cachedIndexes = t, this.cachedLength = e, e;
|
|
2206
2339
|
}
|
|
2207
2340
|
/**
|
|
@@ -2215,11 +2348,11 @@ class N {
|
|
|
2215
2348
|
*/
|
|
2216
2349
|
convert(e, t = 0) {
|
|
2217
2350
|
if (this.dataType.equals(e)) return this;
|
|
2218
|
-
const
|
|
2351
|
+
const n = new e.Array(this.length);
|
|
2219
2352
|
for (let i = 0; i < this.length; i++)
|
|
2220
|
-
|
|
2221
|
-
return new
|
|
2222
|
-
data:
|
|
2353
|
+
n[i] = jt(this.dataType, e, this.data[i], t);
|
|
2354
|
+
return new M({
|
|
2355
|
+
data: n.buffer,
|
|
2223
2356
|
dataType: e,
|
|
2224
2357
|
timeRange: this.timeRange,
|
|
2225
2358
|
sampleOffset: t,
|
|
@@ -2229,14 +2362,14 @@ class N {
|
|
|
2229
2362
|
}
|
|
2230
2363
|
calcRawMax() {
|
|
2231
2364
|
if (this.length === 0) return -1 / 0;
|
|
2232
|
-
if (this.dataType.equals(
|
|
2365
|
+
if (this.dataType.equals(w.TIMESTAMP))
|
|
2233
2366
|
this.cachedMax = this.data[this.data.length - 1];
|
|
2234
2367
|
else if (this.dataType.usesBigInt) {
|
|
2235
2368
|
const e = this.data;
|
|
2236
|
-
this.cachedMax = e.reduce((t,
|
|
2369
|
+
this.cachedMax = e.reduce((t, n) => t > n ? t : n);
|
|
2237
2370
|
} else {
|
|
2238
2371
|
const e = this.data;
|
|
2239
|
-
this.cachedMax = e.reduce((t,
|
|
2372
|
+
this.cachedMax = e.reduce((t, n) => t > n ? t : n);
|
|
2240
2373
|
}
|
|
2241
2374
|
return this.cachedMax;
|
|
2242
2375
|
}
|
|
@@ -2247,17 +2380,17 @@ class N {
|
|
|
2247
2380
|
calcMax() {
|
|
2248
2381
|
if (this.dataType.isVariable)
|
|
2249
2382
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
2250
|
-
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(),
|
|
2383
|
+
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), H(this.cachedMax, this.sampleOffset));
|
|
2251
2384
|
}
|
|
2252
2385
|
calcRawMin() {
|
|
2253
2386
|
if (this.length === 0) return 1 / 0;
|
|
2254
|
-
if (this.dataType.equals(
|
|
2387
|
+
if (this.dataType.equals(w.TIMESTAMP)) this.cachedMin = this.data[0];
|
|
2255
2388
|
else if (this.dataType.usesBigInt) {
|
|
2256
2389
|
const e = this.data;
|
|
2257
|
-
this.cachedMin = e.reduce((t,
|
|
2390
|
+
this.cachedMin = e.reduce((t, n) => t < n ? t : n);
|
|
2258
2391
|
} else {
|
|
2259
2392
|
const e = this.data;
|
|
2260
|
-
this.cachedMin = e.reduce((t,
|
|
2393
|
+
this.cachedMin = e.reduce((t, n) => t < n ? t : n);
|
|
2261
2394
|
}
|
|
2262
2395
|
return this.cachedMin;
|
|
2263
2396
|
}
|
|
@@ -2268,11 +2401,11 @@ class N {
|
|
|
2268
2401
|
calcMin() {
|
|
2269
2402
|
if (this.dataType.isVariable)
|
|
2270
2403
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
2271
|
-
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(),
|
|
2404
|
+
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), H(this.cachedMin, this.sampleOffset));
|
|
2272
2405
|
}
|
|
2273
2406
|
/** @returns the bounds of the series. */
|
|
2274
2407
|
get bounds() {
|
|
2275
|
-
return
|
|
2408
|
+
return R(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
2276
2409
|
}
|
|
2277
2410
|
maybeRecomputeMinMax(e) {
|
|
2278
2411
|
if (this.cachedMin != null) {
|
|
@@ -2285,56 +2418,56 @@ class N {
|
|
|
2285
2418
|
}
|
|
2286
2419
|
}
|
|
2287
2420
|
atAlignment(e, t) {
|
|
2288
|
-
const
|
|
2289
|
-
if (
|
|
2290
|
-
if (t === !0) throw new Error(`[series] - no value at index ${
|
|
2421
|
+
const n = Number((e - this.alignment) / this.alignmentMultiple);
|
|
2422
|
+
if (n < 0 || n >= this.length) {
|
|
2423
|
+
if (t === !0) throw new Error(`[series] - no value at index ${n}`);
|
|
2291
2424
|
return;
|
|
2292
2425
|
}
|
|
2293
|
-
return this.at(
|
|
2426
|
+
return this.at(n, t);
|
|
2294
2427
|
}
|
|
2295
2428
|
at(e, t = !1) {
|
|
2296
2429
|
if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
|
|
2297
|
-
if (this.dataType.equals(
|
|
2430
|
+
if (this.dataType.equals(w.UUID)) return this.atUUID(e, t);
|
|
2298
2431
|
e < 0 && (e = this.length + e);
|
|
2299
|
-
const
|
|
2300
|
-
if (
|
|
2432
|
+
const n = this.data[e];
|
|
2433
|
+
if (n == null) {
|
|
2301
2434
|
if (t === !0) throw new Error(`[series] - no value at index ${e}`);
|
|
2302
2435
|
return;
|
|
2303
2436
|
}
|
|
2304
|
-
return
|
|
2437
|
+
return H(n, this.sampleOffset);
|
|
2305
2438
|
}
|
|
2306
2439
|
atUUID(e, t) {
|
|
2307
2440
|
e < 0 && (e = this.length + e);
|
|
2308
|
-
const
|
|
2441
|
+
const n = ke(
|
|
2309
2442
|
new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
|
|
2310
2443
|
);
|
|
2311
|
-
if (
|
|
2444
|
+
if (n == null) {
|
|
2312
2445
|
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
2313
2446
|
return;
|
|
2314
2447
|
}
|
|
2315
|
-
return
|
|
2448
|
+
return n;
|
|
2316
2449
|
}
|
|
2317
2450
|
atVariable(e, t) {
|
|
2318
|
-
let
|
|
2451
|
+
let n = 0, i = 0;
|
|
2319
2452
|
if (this._cachedIndexes != null)
|
|
2320
|
-
|
|
2453
|
+
n = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
|
|
2321
2454
|
else {
|
|
2322
2455
|
e < 0 && (e = this.length + e);
|
|
2323
|
-
for (let
|
|
2324
|
-
if (this.data[
|
|
2456
|
+
for (let c = 0; c < this.data.length; c++)
|
|
2457
|
+
if (this.data[c] === ue) {
|
|
2325
2458
|
if (e === 0) {
|
|
2326
|
-
i =
|
|
2459
|
+
i = c;
|
|
2327
2460
|
break;
|
|
2328
2461
|
}
|
|
2329
|
-
|
|
2462
|
+
n = c + 1, e--;
|
|
2330
2463
|
}
|
|
2331
|
-
if (i === 0 && (i = this.data.length),
|
|
2464
|
+
if (i === 0 && (i = this.data.length), n >= i || e > 0) {
|
|
2332
2465
|
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
2333
2466
|
return;
|
|
2334
2467
|
}
|
|
2335
2468
|
}
|
|
2336
|
-
const
|
|
2337
|
-
return this.dataType.equals(
|
|
2469
|
+
const a = this.data.slice(n, i);
|
|
2470
|
+
return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : Ee(JSON.parse(new TextDecoder().decode(a)));
|
|
2338
2471
|
}
|
|
2339
2472
|
/**
|
|
2340
2473
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
@@ -2342,12 +2475,12 @@ class N {
|
|
|
2342
2475
|
* @param value the value to search for.
|
|
2343
2476
|
*/
|
|
2344
2477
|
binarySearch(e) {
|
|
2345
|
-
let t = 0,
|
|
2346
|
-
const i =
|
|
2347
|
-
for (; t <=
|
|
2348
|
-
const
|
|
2349
|
-
if (
|
|
2350
|
-
|
|
2478
|
+
let t = 0, n = this.length - 1;
|
|
2479
|
+
const i = nt(e);
|
|
2480
|
+
for (; t <= n; ) {
|
|
2481
|
+
const a = Math.floor((t + n) / 2), c = i(this.at(a, !0), e);
|
|
2482
|
+
if (c === 0) return a;
|
|
2483
|
+
c < 0 ? t = a + 1 : n = a - 1;
|
|
2351
2484
|
}
|
|
2352
2485
|
return t;
|
|
2353
2486
|
}
|
|
@@ -2359,23 +2492,23 @@ class N {
|
|
|
2359
2492
|
* be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
|
|
2360
2493
|
*/
|
|
2361
2494
|
updateGLBuffer(e) {
|
|
2362
|
-
if (this.gl.control = e, !this.dataType.equals(
|
|
2495
|
+
if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
|
|
2363
2496
|
throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
|
|
2364
|
-
const { buffer: t, bufferUsage:
|
|
2497
|
+
const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
|
|
2365
2498
|
if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
|
|
2366
|
-
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !==
|
|
2499
|
+
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== $) {
|
|
2367
2500
|
i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
|
|
2368
|
-
const
|
|
2369
|
-
e.bufferSubData(e.ARRAY_BUFFER,
|
|
2501
|
+
const a = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
2502
|
+
e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
|
|
2370
2503
|
} else
|
|
2371
2504
|
e.bufferData(
|
|
2372
2505
|
e.ARRAY_BUFFER,
|
|
2373
2506
|
this.buffer,
|
|
2374
|
-
|
|
2375
|
-
), this.gl.prevBuffer =
|
|
2507
|
+
n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
|
|
2508
|
+
), this.gl.prevBuffer = $;
|
|
2376
2509
|
}
|
|
2377
2510
|
as(e) {
|
|
2378
|
-
return
|
|
2511
|
+
return Gt(e, this.dataType), this;
|
|
2379
2512
|
}
|
|
2380
2513
|
/** @returns a digest containing information about the series. */
|
|
2381
2514
|
get digest() {
|
|
@@ -2384,8 +2517,8 @@ class N {
|
|
|
2384
2517
|
dataType: this.dataType.toString(),
|
|
2385
2518
|
sampleOffset: this.sampleOffset,
|
|
2386
2519
|
alignment: {
|
|
2387
|
-
lower:
|
|
2388
|
-
upper:
|
|
2520
|
+
lower: Ne(this.alignmentBounds.lower),
|
|
2521
|
+
upper: Ne(this.alignmentBounds.upper)
|
|
2389
2522
|
},
|
|
2390
2523
|
timeRange: this.timeRange.toString(),
|
|
2391
2524
|
length: this.length,
|
|
@@ -2402,7 +2535,10 @@ class N {
|
|
|
2402
2535
|
* is exclusive.
|
|
2403
2536
|
*/
|
|
2404
2537
|
get alignmentBounds() {
|
|
2405
|
-
return
|
|
2538
|
+
return R(
|
|
2539
|
+
this.alignment,
|
|
2540
|
+
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2541
|
+
);
|
|
2406
2542
|
}
|
|
2407
2543
|
maybeGarbageCollectGLBuffer(e) {
|
|
2408
2544
|
this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
|
|
@@ -2419,10 +2555,10 @@ class N {
|
|
|
2419
2555
|
}
|
|
2420
2556
|
[Symbol.iterator]() {
|
|
2421
2557
|
if (this.dataType.isVariable) {
|
|
2422
|
-
const e = new
|
|
2423
|
-
return this.dataType.equals(
|
|
2558
|
+
const e = new Xt(this);
|
|
2559
|
+
return this.dataType.equals(w.JSON) ? new Kt(e) : e;
|
|
2424
2560
|
}
|
|
2425
|
-
return this.dataType.equals(
|
|
2561
|
+
return this.dataType.equals(w.UUID) ? new Qt(this) : new _t(this);
|
|
2426
2562
|
}
|
|
2427
2563
|
/**
|
|
2428
2564
|
* Returns a slice of the series from start to end.
|
|
@@ -2449,7 +2585,7 @@ class N {
|
|
|
2449
2585
|
* @returns An iterator over the specified range.
|
|
2450
2586
|
*/
|
|
2451
2587
|
subIterator(e, t) {
|
|
2452
|
-
return new
|
|
2588
|
+
return new Ie(this, e, t ?? this.length);
|
|
2453
2589
|
}
|
|
2454
2590
|
/**
|
|
2455
2591
|
* Returns an iterator over a portion of the series based on alignment.
|
|
@@ -2458,17 +2594,18 @@ class N {
|
|
|
2458
2594
|
* @returns An iterator over the specified alignment range.
|
|
2459
2595
|
*/
|
|
2460
2596
|
subAlignmentIterator(e, t) {
|
|
2461
|
-
|
|
2462
|
-
this
|
|
2463
|
-
|
|
2464
|
-
Number(t - this.alignment)
|
|
2597
|
+
const n = Math.ceil(
|
|
2598
|
+
Number(e - this.alignment) / Number(this.alignmentMultiple)
|
|
2599
|
+
), i = Math.ceil(
|
|
2600
|
+
Number(t - this.alignment) / Number(this.alignmentMultiple)
|
|
2465
2601
|
);
|
|
2602
|
+
return new Ie(this, n, i);
|
|
2466
2603
|
}
|
|
2467
2604
|
subBytes(e, t) {
|
|
2468
2605
|
if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
|
|
2469
|
-
const
|
|
2470
|
-
return new
|
|
2471
|
-
data:
|
|
2606
|
+
const n = this.data.subarray(e, t);
|
|
2607
|
+
return new M({
|
|
2608
|
+
data: n,
|
|
2472
2609
|
dataType: this.dataType,
|
|
2473
2610
|
timeRange: this.timeRange,
|
|
2474
2611
|
sampleOffset: this.sampleOffset,
|
|
@@ -2476,10 +2613,10 @@ class N {
|
|
|
2476
2613
|
alignment: this.alignment + BigInt(e)
|
|
2477
2614
|
});
|
|
2478
2615
|
}
|
|
2479
|
-
sliceSub(e, t,
|
|
2480
|
-
if (t <= 0 && (
|
|
2616
|
+
sliceSub(e, t, n) {
|
|
2617
|
+
if (t <= 0 && (n == null || n >= this.length)) return this;
|
|
2481
2618
|
let i;
|
|
2482
|
-
return e ? i = this.data.subarray(t,
|
|
2619
|
+
return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new M({
|
|
2483
2620
|
data: i,
|
|
2484
2621
|
dataType: this.dataType,
|
|
2485
2622
|
timeRange: this.timeRange,
|
|
@@ -2494,10 +2631,10 @@ class N {
|
|
|
2494
2631
|
* @returns A new series with the specified alignment.
|
|
2495
2632
|
*/
|
|
2496
2633
|
reAlign(e) {
|
|
2497
|
-
return new
|
|
2634
|
+
return new M({
|
|
2498
2635
|
data: this.buffer,
|
|
2499
2636
|
dataType: this.dataType,
|
|
2500
|
-
timeRange:
|
|
2637
|
+
timeRange: F.ZERO,
|
|
2501
2638
|
sampleOffset: this.sampleOffset,
|
|
2502
2639
|
glBufferUsage: "static",
|
|
2503
2640
|
alignment: e
|
|
@@ -2521,20 +2658,21 @@ class N {
|
|
|
2521
2658
|
return e += "])", e;
|
|
2522
2659
|
}
|
|
2523
2660
|
}
|
|
2524
|
-
const
|
|
2525
|
-
|
|
2661
|
+
const Jt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof M ? !0 : Pe(r), Ht = Pt(Ye, M);
|
|
2662
|
+
class Ie {
|
|
2526
2663
|
series;
|
|
2527
2664
|
end;
|
|
2528
2665
|
index;
|
|
2529
|
-
constructor(e, t,
|
|
2666
|
+
constructor(e, t, n) {
|
|
2530
2667
|
this.series = e;
|
|
2531
|
-
const i =
|
|
2532
|
-
this.end =
|
|
2668
|
+
const i = R(0, e.length + 1);
|
|
2669
|
+
this.end = be(i, n), this.index = be(i, t);
|
|
2533
2670
|
}
|
|
2534
2671
|
next() {
|
|
2535
2672
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
2536
2673
|
}
|
|
2537
|
-
}
|
|
2674
|
+
}
|
|
2675
|
+
class Xt {
|
|
2538
2676
|
series;
|
|
2539
2677
|
index;
|
|
2540
2678
|
decoder;
|
|
@@ -2547,14 +2685,14 @@ let we = class {
|
|
|
2547
2685
|
}
|
|
2548
2686
|
next() {
|
|
2549
2687
|
const e = this.index, t = this.series.data;
|
|
2550
|
-
for (; this.index < t.length && t[this.index] !==
|
|
2551
|
-
const
|
|
2552
|
-
return e ===
|
|
2688
|
+
for (; this.index < t.length && t[this.index] !== ue; ) this.index++;
|
|
2689
|
+
const n = this.index;
|
|
2690
|
+
return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
|
|
2553
2691
|
}
|
|
2554
|
-
}
|
|
2555
|
-
class
|
|
2692
|
+
}
|
|
2693
|
+
let Kt = class je {
|
|
2556
2694
|
wrapped;
|
|
2557
|
-
static schema =
|
|
2695
|
+
static schema = s.record(s.string(), s.unknown());
|
|
2558
2696
|
constructor(e) {
|
|
2559
2697
|
this.wrapped = e;
|
|
2560
2698
|
}
|
|
@@ -2562,27 +2700,27 @@ class ae {
|
|
|
2562
2700
|
const e = this.wrapped.next();
|
|
2563
2701
|
return e.done === !0 ? { done: !0, value: void 0 } : {
|
|
2564
2702
|
done: !1,
|
|
2565
|
-
value:
|
|
2703
|
+
value: ae.decodeString(e.value, je.schema)
|
|
2566
2704
|
};
|
|
2567
2705
|
}
|
|
2568
|
-
}
|
|
2569
|
-
class
|
|
2706
|
+
};
|
|
2707
|
+
class Qt {
|
|
2570
2708
|
series;
|
|
2571
2709
|
index;
|
|
2572
2710
|
data;
|
|
2573
2711
|
density;
|
|
2574
2712
|
constructor(e) {
|
|
2575
|
-
if (!e.dataType.equals(
|
|
2713
|
+
if (!e.dataType.equals(w.UUID))
|
|
2576
2714
|
throw new Error("cannot create a UUID series iterator for a non-UUID series");
|
|
2577
|
-
this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density =
|
|
2715
|
+
this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = w.UUID.density.valueOf();
|
|
2578
2716
|
}
|
|
2579
2717
|
next() {
|
|
2580
2718
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2581
|
-
const e =
|
|
2719
|
+
const e = ke(this.data, this.index * this.density);
|
|
2582
2720
|
return this.index++, { done: !1, value: e };
|
|
2583
2721
|
}
|
|
2584
2722
|
}
|
|
2585
|
-
class
|
|
2723
|
+
let _t = class {
|
|
2586
2724
|
series;
|
|
2587
2725
|
index;
|
|
2588
2726
|
constructor(e) {
|
|
@@ -2594,28 +2732,28 @@ class Wt {
|
|
|
2594
2732
|
value: this.series.at(this.index++, !0)
|
|
2595
2733
|
};
|
|
2596
2734
|
}
|
|
2597
|
-
}
|
|
2598
|
-
const
|
|
2599
|
-
const e =
|
|
2735
|
+
};
|
|
2736
|
+
const Ne = (r) => {
|
|
2737
|
+
const e = r >> 32n, t = r & 0xffffffffn;
|
|
2600
2738
|
return { domain: e, sample: t };
|
|
2601
2739
|
};
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2740
|
+
s.object({ key: s.string(), value: s.string() });
|
|
2741
|
+
s.record(
|
|
2742
|
+
s.union([s.number(), s.string(), s.symbol()]),
|
|
2743
|
+
s.unknown()
|
|
2606
2744
|
);
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2609
|
-
const
|
|
2745
|
+
const er = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
|
|
2746
|
+
er();
|
|
2747
|
+
const tr = ["macOS", "Windows", "Linux"], rr = ["macos", "windows", "linux"], nr = {
|
|
2610
2748
|
macos: "macOS",
|
|
2611
2749
|
windows: "Windows",
|
|
2612
2750
|
linux: "Linux"
|
|
2613
2751
|
};
|
|
2614
|
-
|
|
2615
|
-
|
|
2752
|
+
s.enum(tr).or(
|
|
2753
|
+
s.enum(rr).transform((r) => nr[r])
|
|
2616
2754
|
);
|
|
2617
|
-
const
|
|
2618
|
-
class
|
|
2755
|
+
const sr = (...r) => r.map(qe).join(""), qe = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), ir = (r) => r.endsWith("/") ? r.slice(0, -1) : r, ar = (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("&")}`;
|
|
2756
|
+
class Z {
|
|
2619
2757
|
protocol;
|
|
2620
2758
|
host;
|
|
2621
2759
|
port;
|
|
@@ -2626,8 +2764,8 @@ class q {
|
|
|
2626
2764
|
* @param protocol - The protocol to use for all requests. Defaults to "".
|
|
2627
2765
|
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
2628
2766
|
*/
|
|
2629
|
-
constructor({ host: e, port: t, protocol:
|
|
2630
|
-
this.protocol =
|
|
2767
|
+
constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
|
|
2768
|
+
this.protocol = n, this.host = e, this.port = t, this.path = qe(i);
|
|
2631
2769
|
}
|
|
2632
2770
|
/**
|
|
2633
2771
|
* Replaces creates a new URL with the specified properties replaced.
|
|
@@ -2635,7 +2773,7 @@ class q {
|
|
|
2635
2773
|
* @returns a new URL.
|
|
2636
2774
|
*/
|
|
2637
2775
|
replace(e) {
|
|
2638
|
-
return new
|
|
2776
|
+
return new Z({
|
|
2639
2777
|
host: e.host ?? this.host,
|
|
2640
2778
|
port: e.port ?? this.port,
|
|
2641
2779
|
protocol: e.protocol ?? this.protocol,
|
|
@@ -2648,196 +2786,199 @@ class q {
|
|
|
2648
2786
|
* @returns a new URL.
|
|
2649
2787
|
*/
|
|
2650
2788
|
child(e) {
|
|
2651
|
-
return new
|
|
2789
|
+
return new Z({
|
|
2652
2790
|
...this,
|
|
2653
|
-
pathPrefix:
|
|
2791
|
+
pathPrefix: sr(this.path, e)
|
|
2654
2792
|
});
|
|
2655
2793
|
}
|
|
2656
2794
|
/** @returns a string representation of the url */
|
|
2657
2795
|
toString() {
|
|
2658
|
-
return
|
|
2796
|
+
return ir(
|
|
2659
2797
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
2660
2798
|
);
|
|
2661
2799
|
}
|
|
2662
|
-
static UNKNOWN = new
|
|
2800
|
+
static UNKNOWN = new Z({ host: "unknown", port: 0 });
|
|
2663
2801
|
}
|
|
2664
|
-
const
|
|
2665
|
-
(e) => setTimeout(e,
|
|
2802
|
+
const or = async (r) => await new Promise(
|
|
2803
|
+
(e) => setTimeout(e, g.fromMilliseconds(r).milliseconds)
|
|
2666
2804
|
);
|
|
2667
|
-
class
|
|
2805
|
+
class ur {
|
|
2668
2806
|
config;
|
|
2669
2807
|
retries;
|
|
2670
2808
|
interval;
|
|
2671
2809
|
constructor(e) {
|
|
2672
2810
|
this.config = {
|
|
2673
|
-
baseInterval: new
|
|
2811
|
+
baseInterval: new g(e?.baseInterval ?? g.seconds(1)),
|
|
2674
2812
|
maxRetries: e?.maxRetries ?? 5,
|
|
2675
2813
|
scale: e?.scale ?? 1,
|
|
2676
|
-
sleepFn: e?.sleepFn ??
|
|
2677
|
-
}, this.retries = 0, this.interval = new
|
|
2814
|
+
sleepFn: e?.sleepFn ?? or
|
|
2815
|
+
}, this.retries = 0, this.interval = new g(this.config.baseInterval);
|
|
2678
2816
|
}
|
|
2679
2817
|
async wait() {
|
|
2680
|
-
const { maxRetries: e, scale: t, sleepFn:
|
|
2681
|
-
return this.retries >= e ? !1 : (await
|
|
2818
|
+
const { maxRetries: e, scale: t, sleepFn: n } = this.config;
|
|
2819
|
+
return this.retries >= e ? !1 : (await n(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
|
|
2820
|
+
}
|
|
2821
|
+
get retryMessage() {
|
|
2822
|
+
return `breaker triggered ${this.retries + 1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`;
|
|
2682
2823
|
}
|
|
2683
2824
|
reset() {
|
|
2684
2825
|
this.retries = 0, this.interval = this.config.baseInterval;
|
|
2685
2826
|
}
|
|
2686
2827
|
}
|
|
2687
|
-
const
|
|
2688
|
-
baseInterval:
|
|
2689
|
-
maxRetries:
|
|
2690
|
-
scale:
|
|
2691
|
-
}),
|
|
2828
|
+
const lr = s.object({
|
|
2829
|
+
baseInterval: g.z.optional(),
|
|
2830
|
+
maxRetries: s.number().optional(),
|
|
2831
|
+
scale: s.number().optional()
|
|
2832
|
+
}), cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2692
2833
|
__proto__: null,
|
|
2693
|
-
Breaker:
|
|
2694
|
-
breakerConfigZ:
|
|
2695
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2696
|
-
if (
|
|
2697
|
-
if (Array.isArray(
|
|
2698
|
-
if (
|
|
2699
|
-
throw new Error(`Invalid color: [${
|
|
2700
|
-
return
|
|
2701
|
-
}
|
|
2702
|
-
return
|
|
2703
|
-
},
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
]),
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
const
|
|
2712
|
-
key:
|
|
2713
|
-
color:
|
|
2714
|
-
position:
|
|
2715
|
-
switched:
|
|
2834
|
+
Breaker: ur,
|
|
2835
|
+
breakerConfigZ: lr
|
|
2836
|
+
}, Symbol.toStringTag, { value: "Module" })), hr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = s.string().regex(hr), P = s.number().min(0).max(255), We = s.number().min(0).max(1), Ze = s.tuple([P, P, P, We]), fr = s.tuple([P, P, P]), dr = s.object({ rgba255: Ze }), gr = s.number().min(0).max(360), pr = s.number().min(0).max(100), mr = s.number().min(0).max(100), yr = s.tuple([gr, pr, mr, We]), de = s.union([Fe, fr, Ze, yr, dr]), wr = de.transform((r) => ge(r)), ge = (r, e = 1) => {
|
|
2837
|
+
if (r = de.parse(r), typeof r == "string") return br(r, e);
|
|
2838
|
+
if (Array.isArray(r)) {
|
|
2839
|
+
if (r.length < 3 || r.length > 4)
|
|
2840
|
+
throw new Error(`Invalid color: [${r.join(", ")}]`);
|
|
2841
|
+
return r.length === 3 ? [...r, e] : r;
|
|
2842
|
+
}
|
|
2843
|
+
return r.rgba255;
|
|
2844
|
+
}, br = (r, e = 1) => (r = Fe.parse(r), r = Or(r), [
|
|
2845
|
+
J(r, 0),
|
|
2846
|
+
J(r, 2),
|
|
2847
|
+
J(r, 4),
|
|
2848
|
+
r.length === 8 ? J(r, 6) / 255 : e
|
|
2849
|
+
]), J = (r, e) => parseInt(r.slice(e, e + 2), 16), Or = (r) => r.startsWith("#") ? r.slice(1) : r;
|
|
2850
|
+
ge("#000000");
|
|
2851
|
+
ge("#ffffff");
|
|
2852
|
+
const Tr = s.object({
|
|
2853
|
+
key: s.string(),
|
|
2854
|
+
color: de,
|
|
2855
|
+
position: s.number(),
|
|
2856
|
+
switched: s.boolean().optional()
|
|
2716
2857
|
});
|
|
2717
|
-
|
|
2718
|
-
const
|
|
2719
|
-
key:
|
|
2720
|
-
name:
|
|
2721
|
-
color:
|
|
2858
|
+
s.array(Tr);
|
|
2859
|
+
const vr = s.object({
|
|
2860
|
+
key: s.string(),
|
|
2861
|
+
name: s.string(),
|
|
2862
|
+
color: wr
|
|
2722
2863
|
});
|
|
2723
|
-
|
|
2724
|
-
key:
|
|
2725
|
-
name:
|
|
2726
|
-
swatches:
|
|
2864
|
+
s.object({
|
|
2865
|
+
key: s.string(),
|
|
2866
|
+
name: s.string(),
|
|
2867
|
+
swatches: s.array(vr)
|
|
2727
2868
|
});
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
name:
|
|
2731
|
-
key:
|
|
2869
|
+
s.int().min(0).max(255);
|
|
2870
|
+
s.object({
|
|
2871
|
+
name: s.string(),
|
|
2872
|
+
key: s.string()
|
|
2732
2873
|
});
|
|
2733
|
-
const
|
|
2734
|
-
const t = Symbol.for(
|
|
2735
|
-
if (!
|
|
2736
|
-
const
|
|
2737
|
-
Object.defineProperty(globalThis, t, { value:
|
|
2874
|
+
const Ir = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), Nr = (r, e) => {
|
|
2875
|
+
const t = Symbol.for(r);
|
|
2876
|
+
if (!Ir(t)) {
|
|
2877
|
+
const n = e();
|
|
2878
|
+
Object.defineProperty(globalThis, t, { value: n });
|
|
2738
2879
|
}
|
|
2739
2880
|
return () => globalThis[t];
|
|
2740
|
-
},
|
|
2741
|
-
static discriminator =
|
|
2742
|
-
discriminator =
|
|
2743
|
-
static TYPE =
|
|
2744
|
-
type =
|
|
2745
|
-
static matches =
|
|
2746
|
-
matches =
|
|
2747
|
-
constructor(t,
|
|
2748
|
-
super(t,
|
|
2881
|
+
}, Ve = "sy_x_error", Sr = (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), V = (r) => class W extends Error {
|
|
2882
|
+
static discriminator = Ve;
|
|
2883
|
+
discriminator = W.discriminator;
|
|
2884
|
+
static TYPE = r;
|
|
2885
|
+
type = W.TYPE;
|
|
2886
|
+
static matches = Sr(r);
|
|
2887
|
+
matches = W.matches;
|
|
2888
|
+
constructor(t, n) {
|
|
2889
|
+
super(t, n), this.name = W.TYPE;
|
|
2749
2890
|
}
|
|
2750
2891
|
static sub(t) {
|
|
2751
|
-
return
|
|
2892
|
+
return V(`${r}.${t}`);
|
|
2752
2893
|
}
|
|
2753
|
-
},
|
|
2754
|
-
if (
|
|
2755
|
-
const e =
|
|
2756
|
-
if (e.discriminator !==
|
|
2894
|
+
}, ze = (r) => {
|
|
2895
|
+
if (r == null || typeof r != "object") return !1;
|
|
2896
|
+
const e = r;
|
|
2897
|
+
if (e.discriminator !== Ve) return !1;
|
|
2757
2898
|
if (!("type" in e))
|
|
2758
2899
|
throw new Error(
|
|
2759
2900
|
`X Error is missing its type property: ${JSON.stringify(e)}`
|
|
2760
2901
|
);
|
|
2761
2902
|
return !0;
|
|
2762
|
-
},
|
|
2763
|
-
class
|
|
2903
|
+
}, L = "unknown", le = "nil";
|
|
2904
|
+
class Er {
|
|
2764
2905
|
providers = [];
|
|
2765
2906
|
register(e) {
|
|
2766
2907
|
this.providers.push(e);
|
|
2767
2908
|
}
|
|
2768
2909
|
encode(e) {
|
|
2769
|
-
if (e == null) return { type:
|
|
2770
|
-
if (
|
|
2910
|
+
if (e == null) return { type: le, data: "" };
|
|
2911
|
+
if (ze(e))
|
|
2771
2912
|
for (const t of this.providers) {
|
|
2772
|
-
const
|
|
2773
|
-
if (
|
|
2913
|
+
const n = t.encode(e);
|
|
2914
|
+
if (n != null) return n;
|
|
2774
2915
|
}
|
|
2775
|
-
if (e instanceof Error) return { type:
|
|
2776
|
-
if (typeof e == "string") return { type:
|
|
2916
|
+
if (e instanceof Error) return { type: L, data: e.message };
|
|
2917
|
+
if (typeof e == "string") return { type: L, data: e };
|
|
2777
2918
|
try {
|
|
2778
|
-
return { type:
|
|
2919
|
+
return { type: L, data: JSON.stringify(e) };
|
|
2779
2920
|
} catch {
|
|
2780
|
-
return { type:
|
|
2921
|
+
return { type: L, data: "unable to encode error information" };
|
|
2781
2922
|
}
|
|
2782
2923
|
}
|
|
2783
2924
|
decode(e) {
|
|
2784
|
-
if (e == null || e.type ===
|
|
2785
|
-
if (e.type ===
|
|
2925
|
+
if (e == null || e.type === le) return null;
|
|
2926
|
+
if (e.type === L) return new ce(e.data);
|
|
2786
2927
|
for (const t of this.providers) {
|
|
2787
|
-
const
|
|
2788
|
-
if (
|
|
2928
|
+
const n = t.decode(e);
|
|
2929
|
+
if (n != null) return n;
|
|
2789
2930
|
}
|
|
2790
|
-
return new
|
|
2931
|
+
return new ce(e.data);
|
|
2791
2932
|
}
|
|
2792
2933
|
}
|
|
2793
|
-
const
|
|
2794
|
-
class
|
|
2934
|
+
const pe = Nr("synnax-error-registry", () => new Er()), xr = ({ encode: r, decode: e }) => pe().register({ encode: r, decode: e }), Ar = (r) => pe().encode(r), Ur = (r) => r == null ? null : pe().decode(r);
|
|
2935
|
+
class ce extends V("unknown") {
|
|
2795
2936
|
}
|
|
2796
|
-
const
|
|
2797
|
-
class
|
|
2937
|
+
const Mr = s.object({ type: s.string(), data: s.string() });
|
|
2938
|
+
class Cr extends V("canceled") {
|
|
2798
2939
|
}
|
|
2799
|
-
class
|
|
2940
|
+
class $r extends V("not_implemented") {
|
|
2800
2941
|
}
|
|
2801
|
-
const
|
|
2942
|
+
const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2802
2943
|
__proto__: null,
|
|
2803
|
-
Canceled:
|
|
2804
|
-
NONE:
|
|
2805
|
-
NotImplemented:
|
|
2806
|
-
UNKNOWN:
|
|
2807
|
-
Unknown:
|
|
2808
|
-
createTyped:
|
|
2809
|
-
decode:
|
|
2810
|
-
encode:
|
|
2811
|
-
isTyped:
|
|
2812
|
-
payloadZ:
|
|
2813
|
-
register:
|
|
2814
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2815
|
-
jsonrpc:
|
|
2816
|
-
method:
|
|
2944
|
+
Canceled: Cr,
|
|
2945
|
+
NONE: le,
|
|
2946
|
+
NotImplemented: $r,
|
|
2947
|
+
UNKNOWN: L,
|
|
2948
|
+
Unknown: ce,
|
|
2949
|
+
createTyped: V,
|
|
2950
|
+
decode: Ur,
|
|
2951
|
+
encode: Ar,
|
|
2952
|
+
isTyped: ze,
|
|
2953
|
+
payloadZ: Mr,
|
|
2954
|
+
register: xr
|
|
2955
|
+
}, Symbol.toStringTag, { value: "Module" })), Br = O.object({
|
|
2956
|
+
jsonrpc: O.literal("2.0"),
|
|
2957
|
+
method: O.string(),
|
|
2817
2958
|
// params should be z.union([z.record(z.string(), z.json()),
|
|
2818
2959
|
// z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
|
|
2819
2960
|
// definition of params then in the JSON-RPC spec.
|
|
2820
|
-
params:
|
|
2821
|
-
id:
|
|
2822
|
-
}),
|
|
2823
|
-
jsonrpc:
|
|
2824
|
-
id:
|
|
2825
|
-
}),
|
|
2826
|
-
result:
|
|
2827
|
-
}),
|
|
2828
|
-
error:
|
|
2829
|
-
code:
|
|
2961
|
+
params: O.any().optional(),
|
|
2962
|
+
id: O.union([O.string(), O.number(), O.null()]).optional()
|
|
2963
|
+
}), Ge = O.object({
|
|
2964
|
+
jsonrpc: O.literal("2.0"),
|
|
2965
|
+
id: O.union([O.string(), O.number(), O.null()])
|
|
2966
|
+
}), Rr = Ge.extend({
|
|
2967
|
+
result: O.json()
|
|
2968
|
+
}), Dr = Ge.extend({
|
|
2969
|
+
error: O.object({
|
|
2970
|
+
code: O.number().int(),
|
|
2830
2971
|
// This should be z.string(), but the VSCode JSON RPC implementation uses a looser
|
|
2831
2972
|
// definition of error than the JSON-RPC spec.
|
|
2832
|
-
message:
|
|
2833
|
-
data:
|
|
2973
|
+
message: O.string().optional(),
|
|
2974
|
+
data: O.json().optional()
|
|
2834
2975
|
})
|
|
2835
|
-
}),
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
const
|
|
2839
|
-
|
|
2840
|
-
|
|
2976
|
+
}), Lr = O.union([Rr, Dr]);
|
|
2977
|
+
O.union([Br, Lr]);
|
|
2978
|
+
s.string().regex(/^\d+\.\d+\.\d+$/);
|
|
2979
|
+
const Pr = ["standard", "scientific", "engineering"];
|
|
2980
|
+
s.enum(Pr);
|
|
2981
|
+
s.enum([
|
|
2841
2982
|
"success",
|
|
2842
2983
|
"info",
|
|
2843
2984
|
"warning",
|
|
@@ -2845,51 +2986,51 @@ r.enum([
|
|
|
2845
2986
|
"loading",
|
|
2846
2987
|
"disabled"
|
|
2847
2988
|
]);
|
|
2848
|
-
class
|
|
2989
|
+
class z extends B.createTyped("freighter") {
|
|
2849
2990
|
}
|
|
2850
|
-
class
|
|
2991
|
+
class k extends z.sub("eof") {
|
|
2851
2992
|
constructor() {
|
|
2852
2993
|
super("EOF");
|
|
2853
2994
|
}
|
|
2854
2995
|
}
|
|
2855
|
-
class
|
|
2996
|
+
class Y extends z.sub("stream_closed") {
|
|
2856
2997
|
constructor() {
|
|
2857
2998
|
super("StreamClosed");
|
|
2858
2999
|
}
|
|
2859
3000
|
}
|
|
2860
|
-
class
|
|
3001
|
+
class j extends z.sub("unreachable") {
|
|
2861
3002
|
url;
|
|
2862
3003
|
constructor(e = {}) {
|
|
2863
|
-
const { message: t = "Unreachable", url:
|
|
2864
|
-
super(t), this.url =
|
|
3004
|
+
const { message: t = "Unreachable", url: n = Z.UNKNOWN } = e;
|
|
3005
|
+
super(t), this.url = n;
|
|
2865
3006
|
}
|
|
2866
3007
|
}
|
|
2867
|
-
const
|
|
2868
|
-
if (!
|
|
2869
|
-
if (
|
|
2870
|
-
if (
|
|
2871
|
-
return { type:
|
|
2872
|
-
if (
|
|
2873
|
-
return { type:
|
|
2874
|
-
throw new Error(`Unknown error type: ${
|
|
2875
|
-
},
|
|
2876
|
-
if (!
|
|
2877
|
-
switch (
|
|
2878
|
-
case L.TYPE:
|
|
2879
|
-
return new L();
|
|
2880
|
-
case P.TYPE:
|
|
2881
|
-
return new P();
|
|
3008
|
+
const kr = (r) => {
|
|
3009
|
+
if (!r.type.startsWith(z.TYPE)) return null;
|
|
3010
|
+
if (k.matches(r)) return { type: k.TYPE, data: "EOF" };
|
|
3011
|
+
if (Y.matches(r))
|
|
3012
|
+
return { type: Y.TYPE, data: "StreamClosed" };
|
|
3013
|
+
if (j.matches(r))
|
|
3014
|
+
return { type: j.TYPE, data: "Unreachable" };
|
|
3015
|
+
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
3016
|
+
}, Yr = (r) => {
|
|
3017
|
+
if (!r.type.startsWith(z.TYPE)) return null;
|
|
3018
|
+
switch (r.type) {
|
|
2882
3019
|
case k.TYPE:
|
|
2883
3020
|
return new k();
|
|
3021
|
+
case Y.TYPE:
|
|
3022
|
+
return new Y();
|
|
3023
|
+
case j.TYPE:
|
|
3024
|
+
return new j();
|
|
2884
3025
|
default:
|
|
2885
|
-
throw new
|
|
3026
|
+
throw new B.Unknown(`Unknown error type: ${r.data}`);
|
|
2886
3027
|
}
|
|
2887
3028
|
};
|
|
2888
|
-
|
|
2889
|
-
encode:
|
|
2890
|
-
decode:
|
|
3029
|
+
B.register({
|
|
3030
|
+
encode: kr,
|
|
3031
|
+
decode: Yr
|
|
2891
3032
|
});
|
|
2892
|
-
class
|
|
3033
|
+
class Je {
|
|
2893
3034
|
middleware = [];
|
|
2894
3035
|
/** Implements the Transport interface */
|
|
2895
3036
|
use(...e) {
|
|
@@ -2905,78 +3046,94 @@ class Ye {
|
|
|
2905
3046
|
* @returns An error if one was encountered, otherwise undefined.
|
|
2906
3047
|
*/
|
|
2907
3048
|
async executeMiddleware(e, t) {
|
|
2908
|
-
let
|
|
2909
|
-
const i = async (
|
|
2910
|
-
if (
|
|
2911
|
-
const
|
|
2912
|
-
return
|
|
3049
|
+
let n = 0;
|
|
3050
|
+
const i = async (a) => {
|
|
3051
|
+
if (n === this.middleware.length) return await t(a);
|
|
3052
|
+
const c = this.middleware[n];
|
|
3053
|
+
return n++, await c(a, i);
|
|
2913
3054
|
};
|
|
2914
3055
|
return await i(e);
|
|
2915
3056
|
}
|
|
2916
3057
|
}
|
|
2917
|
-
const
|
|
2918
|
-
|
|
3058
|
+
const He = "Content-Type", jr = /* @__PURE__ */ new Set([
|
|
3059
|
+
"ECONNREFUSED",
|
|
3060
|
+
"ECONNRESET",
|
|
3061
|
+
"ETIMEDOUT",
|
|
3062
|
+
"EPIPE",
|
|
3063
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
3064
|
+
"UND_ERR_SOCKET"
|
|
3065
|
+
]), qr = (r) => {
|
|
3066
|
+
const e = r?.cause?.code ?? r?.code ?? r?.errno;
|
|
3067
|
+
if (typeof e == "string" && jr.has(e)) return !0;
|
|
3068
|
+
if (r.name === "TypeError") {
|
|
3069
|
+
const t = String(r.message || "").toLowerCase();
|
|
3070
|
+
if (/load failed|failed to fetch|networkerror|network error/.test(t))
|
|
3071
|
+
return typeof navigator < "u" && navigator.onLine === !1, !0;
|
|
3072
|
+
}
|
|
3073
|
+
return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
|
|
3074
|
+
}, Fr = 400;
|
|
3075
|
+
class Qr extends Je {
|
|
2919
3076
|
endpoint;
|
|
2920
3077
|
encoder;
|
|
2921
|
-
constructor(e, t,
|
|
2922
|
-
return super(), this.endpoint = e.replace({ protocol:
|
|
2923
|
-
get: (i,
|
|
3078
|
+
constructor(e, t, n = !1) {
|
|
3079
|
+
return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
|
|
3080
|
+
get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
|
|
2924
3081
|
});
|
|
2925
3082
|
}
|
|
2926
3083
|
get headers() {
|
|
2927
3084
|
return {
|
|
2928
|
-
[
|
|
3085
|
+
[He]: this.encoder.contentType
|
|
2929
3086
|
};
|
|
2930
3087
|
}
|
|
2931
|
-
async send(e, t,
|
|
2932
|
-
t =
|
|
2933
|
-
let
|
|
2934
|
-
const
|
|
3088
|
+
async send(e, t, n, i) {
|
|
3089
|
+
t = n?.parse(t);
|
|
3090
|
+
let a = null;
|
|
3091
|
+
const c = this.endpoint.child(e), d = {};
|
|
2935
3092
|
d.method = "POST", d.body = this.encoder.encode(t ?? {});
|
|
2936
|
-
const [,
|
|
3093
|
+
const [, y] = await this.executeMiddleware(
|
|
2937
3094
|
{
|
|
2938
|
-
target:
|
|
3095
|
+
target: c.toString(),
|
|
2939
3096
|
protocol: this.endpoint.protocol,
|
|
2940
3097
|
params: {},
|
|
2941
3098
|
role: "client"
|
|
2942
3099
|
},
|
|
2943
|
-
async (
|
|
2944
|
-
const
|
|
3100
|
+
async (f) => {
|
|
3101
|
+
const p = { ...f, params: {} };
|
|
2945
3102
|
d.headers = {
|
|
2946
3103
|
...this.headers,
|
|
2947
|
-
...
|
|
3104
|
+
...f.params
|
|
2948
3105
|
};
|
|
2949
|
-
let
|
|
3106
|
+
let b;
|
|
2950
3107
|
try {
|
|
2951
|
-
|
|
2952
|
-
} catch (
|
|
2953
|
-
if (!(
|
|
2954
|
-
return [
|
|
3108
|
+
b = await fetch(f.target, d);
|
|
3109
|
+
} catch (T) {
|
|
3110
|
+
if (!(T instanceof Error)) throw T;
|
|
3111
|
+
return [p, qr(T) ? new j({ url: c }) : T];
|
|
2955
3112
|
}
|
|
2956
|
-
const
|
|
2957
|
-
if (
|
|
2958
|
-
return i != null && (
|
|
3113
|
+
const h = await b.arrayBuffer();
|
|
3114
|
+
if (b?.ok)
|
|
3115
|
+
return i != null && (a = this.encoder.decode(h, i)), [p, null];
|
|
2959
3116
|
try {
|
|
2960
|
-
if (
|
|
2961
|
-
return [
|
|
2962
|
-
const
|
|
2963
|
-
return [
|
|
2964
|
-
} catch (
|
|
3117
|
+
if (b.status !== Fr)
|
|
3118
|
+
return [p, new Error(b.statusText)];
|
|
3119
|
+
const T = this.encoder.decode(h, B.payloadZ), x = B.decode(T);
|
|
3120
|
+
return [p, x];
|
|
3121
|
+
} catch (T) {
|
|
2965
3122
|
return [
|
|
2966
|
-
|
|
3123
|
+
p,
|
|
2967
3124
|
new Error(
|
|
2968
|
-
`[freighter] - failed to decode error: ${
|
|
3125
|
+
`[freighter] - failed to decode error: ${b.statusText}: ${T.message}`
|
|
2969
3126
|
)
|
|
2970
3127
|
];
|
|
2971
3128
|
}
|
|
2972
3129
|
}
|
|
2973
3130
|
);
|
|
2974
|
-
if (
|
|
2975
|
-
if (
|
|
2976
|
-
return [
|
|
3131
|
+
if (y != null) return [null, y];
|
|
3132
|
+
if (a == null) throw new Error("Response must be defined");
|
|
3133
|
+
return [a, null];
|
|
2977
3134
|
}
|
|
2978
3135
|
}
|
|
2979
|
-
const
|
|
3136
|
+
const _r = (r, e) => {
|
|
2980
3137
|
class t {
|
|
2981
3138
|
wrapped;
|
|
2982
3139
|
constructor(i) {
|
|
@@ -2985,27 +3142,27 @@ const Zn = (n, e) => {
|
|
|
2985
3142
|
use(...i) {
|
|
2986
3143
|
this.wrapped.use(...i);
|
|
2987
3144
|
}
|
|
2988
|
-
async send(i,
|
|
2989
|
-
const
|
|
3145
|
+
async send(i, a, c, d) {
|
|
3146
|
+
const y = new cr.Breaker(e);
|
|
2990
3147
|
do {
|
|
2991
|
-
const [
|
|
2992
|
-
if (
|
|
2993
|
-
if (!
|
|
2994
|
-
if (!await
|
|
3148
|
+
const [f, p] = await this.wrapped.send(i, a, c, d);
|
|
3149
|
+
if (p == null) return [f, null];
|
|
3150
|
+
if (!j.matches(p)) return [null, p];
|
|
3151
|
+
if (console.warn(`[freighter] ${y.retryMessage}`, p), !await y.wait()) return [f, p];
|
|
2995
3152
|
} while (!0);
|
|
2996
3153
|
}
|
|
2997
3154
|
}
|
|
2998
|
-
return new t(
|
|
2999
|
-
},
|
|
3000
|
-
const [
|
|
3001
|
-
if (
|
|
3002
|
-
return
|
|
3003
|
-
},
|
|
3004
|
-
type:
|
|
3005
|
-
payload:
|
|
3006
|
-
error:
|
|
3155
|
+
return new t(r);
|
|
3156
|
+
}, en = async (r, e, t, n, i) => {
|
|
3157
|
+
const [a, c] = await r.send(e, t, n, i);
|
|
3158
|
+
if (c != null) throw c;
|
|
3159
|
+
return a;
|
|
3160
|
+
}, Wr = s.object({
|
|
3161
|
+
type: s.enum(["data", "close", "open"]),
|
|
3162
|
+
payload: s.unknown(),
|
|
3163
|
+
error: s.optional(B.payloadZ)
|
|
3007
3164
|
});
|
|
3008
|
-
class
|
|
3165
|
+
class Zr {
|
|
3009
3166
|
codec;
|
|
3010
3167
|
reqSchema;
|
|
3011
3168
|
resSchema;
|
|
@@ -3014,21 +3171,21 @@ class Rn {
|
|
|
3014
3171
|
sendClosed;
|
|
3015
3172
|
receiveDataQueue = [];
|
|
3016
3173
|
receiveCallbacksQueue = [];
|
|
3017
|
-
constructor(e, t,
|
|
3018
|
-
this.codec = t, this.reqSchema =
|
|
3174
|
+
constructor(e, t, n, i) {
|
|
3175
|
+
this.codec = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
|
|
3019
3176
|
}
|
|
3020
3177
|
async receiveOpenAck() {
|
|
3021
3178
|
const e = await this.receiveMsg();
|
|
3022
3179
|
if (e.type !== "open") {
|
|
3023
3180
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3024
|
-
return
|
|
3181
|
+
return B.decode(e.error);
|
|
3025
3182
|
}
|
|
3026
3183
|
return null;
|
|
3027
3184
|
}
|
|
3028
3185
|
/** Implements the Stream protocol */
|
|
3029
3186
|
send(e) {
|
|
3030
|
-
if (this.serverClosed != null) return new
|
|
3031
|
-
if (this.sendClosed) throw new
|
|
3187
|
+
if (this.serverClosed != null) return new k();
|
|
3188
|
+
if (this.sendClosed) throw new Y();
|
|
3032
3189
|
return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
|
|
3033
3190
|
}
|
|
3034
3191
|
/** Implements the Stream protocol */
|
|
@@ -3037,7 +3194,7 @@ class Rn {
|
|
|
3037
3194
|
const e = await this.receiveMsg();
|
|
3038
3195
|
if (e.type === "close") {
|
|
3039
3196
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3040
|
-
if (this.serverClosed =
|
|
3197
|
+
if (this.serverClosed = B.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
|
|
3041
3198
|
return [null, this.serverClosed];
|
|
3042
3199
|
}
|
|
3043
3200
|
return [this.resSchema.parse(e.payload), null];
|
|
@@ -3059,7 +3216,7 @@ class Rn {
|
|
|
3059
3216
|
async receiveMsg() {
|
|
3060
3217
|
const e = this.receiveDataQueue.shift();
|
|
3061
3218
|
return e ?? await new Promise(
|
|
3062
|
-
(t,
|
|
3219
|
+
(t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
|
|
3063
3220
|
);
|
|
3064
3221
|
}
|
|
3065
3222
|
addMessage(e) {
|
|
@@ -3070,20 +3227,20 @@ class Rn {
|
|
|
3070
3227
|
this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
|
|
3071
3228
|
}
|
|
3072
3229
|
onMessage(e) {
|
|
3073
|
-
this.addMessage(this.codec.decode(e.data,
|
|
3230
|
+
this.addMessage(this.codec.decode(e.data, Wr));
|
|
3074
3231
|
}
|
|
3075
3232
|
onClose(e) {
|
|
3076
3233
|
this.addMessage({
|
|
3077
3234
|
type: "close",
|
|
3078
3235
|
error: {
|
|
3079
|
-
type: e.code ===
|
|
3236
|
+
type: e.code === zr ? k.TYPE : Y.TYPE,
|
|
3080
3237
|
data: ""
|
|
3081
3238
|
}
|
|
3082
3239
|
});
|
|
3083
3240
|
}
|
|
3084
3241
|
}
|
|
3085
|
-
const
|
|
3086
|
-
class
|
|
3242
|
+
const Vr = "freighterctx", zr = 1e3;
|
|
3243
|
+
class he extends Je {
|
|
3087
3244
|
baseUrl;
|
|
3088
3245
|
encoder;
|
|
3089
3246
|
secure;
|
|
@@ -3093,58 +3250,58 @@ class re extends Ye {
|
|
|
3093
3250
|
* responses.
|
|
3094
3251
|
* @param baseEndpoint - A base url to use as a prefix for all requests.
|
|
3095
3252
|
*/
|
|
3096
|
-
constructor(e, t,
|
|
3097
|
-
super(), this.secure =
|
|
3253
|
+
constructor(e, t, n = !1) {
|
|
3254
|
+
super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
|
|
3098
3255
|
}
|
|
3099
3256
|
withCodec(e) {
|
|
3100
|
-
const t = new
|
|
3257
|
+
const t = new he(this.baseUrl, e, this.secure);
|
|
3101
3258
|
return t.use(...this.middleware), t;
|
|
3102
3259
|
}
|
|
3103
3260
|
/** Implements the StreamClient interface. */
|
|
3104
|
-
async stream(e, t,
|
|
3261
|
+
async stream(e, t, n) {
|
|
3105
3262
|
let i;
|
|
3106
|
-
const [,
|
|
3263
|
+
const [, a] = await this.executeMiddleware(
|
|
3107
3264
|
{ target: e, protocol: "websocket", params: {}, role: "client" },
|
|
3108
|
-
async (
|
|
3109
|
-
const d = new WebSocket(this.buildURL(e,
|
|
3110
|
-
d.binaryType =
|
|
3111
|
-
const
|
|
3112
|
-
return
|
|
3265
|
+
async (c) => {
|
|
3266
|
+
const d = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
|
|
3267
|
+
d.binaryType = he.MESSAGE_TYPE;
|
|
3268
|
+
const f = await this.wrapSocket(d, t, n);
|
|
3269
|
+
return f instanceof Error ? [y, f] : (i = f, [y, null]);
|
|
3113
3270
|
}
|
|
3114
3271
|
);
|
|
3115
|
-
if (
|
|
3272
|
+
if (a != null) throw a;
|
|
3116
3273
|
return i;
|
|
3117
3274
|
}
|
|
3118
3275
|
buildURL(e, t) {
|
|
3119
|
-
const
|
|
3276
|
+
const n = ar(
|
|
3120
3277
|
{
|
|
3121
|
-
[
|
|
3278
|
+
[He]: this.encoder.contentType,
|
|
3122
3279
|
...t.params
|
|
3123
3280
|
},
|
|
3124
|
-
|
|
3281
|
+
Vr
|
|
3125
3282
|
);
|
|
3126
|
-
return this.baseUrl.child(e).toString() +
|
|
3283
|
+
return this.baseUrl.child(e).toString() + n;
|
|
3127
3284
|
}
|
|
3128
|
-
async wrapSocket(e, t,
|
|
3285
|
+
async wrapSocket(e, t, n) {
|
|
3129
3286
|
return await new Promise((i) => {
|
|
3130
3287
|
e.onopen = () => {
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
}).catch((
|
|
3135
|
-
}, e.onerror = (
|
|
3136
|
-
const
|
|
3137
|
-
i(new Error(
|
|
3288
|
+
const a = new Zr(e, this.encoder, t, n);
|
|
3289
|
+
a.receiveOpenAck().then((c) => {
|
|
3290
|
+
c != null ? i(c) : i(a);
|
|
3291
|
+
}).catch((c) => i(c));
|
|
3292
|
+
}, e.onerror = (a) => {
|
|
3293
|
+
const c = a;
|
|
3294
|
+
i(new Error(c.message));
|
|
3138
3295
|
};
|
|
3139
3296
|
});
|
|
3140
3297
|
}
|
|
3141
3298
|
}
|
|
3142
3299
|
export {
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3300
|
+
k as EOF,
|
|
3301
|
+
Qr as HTTPClient,
|
|
3302
|
+
Y as StreamClosed,
|
|
3303
|
+
j as Unreachable,
|
|
3304
|
+
he as WebSocketClient,
|
|
3305
|
+
en as sendRequired,
|
|
3306
|
+
_r as unaryWithBreaker
|
|
3150
3307
|
};
|