@synnaxlabs/freighter 0.44.2 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/freighter.cjs +4 -4
- package/dist/freighter.js +642 -626
- package/package.json +5 -5
package/dist/freighter.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import O, { z as s } from "zod";
|
|
2
|
-
const
|
|
3
|
-
const e =
|
|
2
|
+
const Qe = (n) => {
|
|
3
|
+
const e = n.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((c) => e(c,
|
|
5
|
+
}, Ee = (n) => {
|
|
6
|
+
const e = (t, r = ae) => {
|
|
7
|
+
if (typeof t == "string") return n(t);
|
|
8
|
+
if (Array.isArray(t)) return t.map((c) => e(c, r));
|
|
9
9
|
if (!re(t)) return t;
|
|
10
|
-
|
|
10
|
+
r = nt(r);
|
|
11
11
|
const i = {}, a = t;
|
|
12
|
-
return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(),
|
|
13
|
-
let
|
|
14
|
-
const y =
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
return re(f) ?
|
|
18
|
-
}))), i[y] =
|
|
12
|
+
return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), r) : (Object.keys(a).forEach((c) => {
|
|
13
|
+
let g = a[c];
|
|
14
|
+
const y = n(c);
|
|
15
|
+
r.recursive && (re(g) ? we(g) || (g = e(g, r)) : r.recursiveInArray && ye(g) && (g = [...g].map((f) => {
|
|
16
|
+
let m = f;
|
|
17
|
+
return re(f) ? we(m) || (m = e(f, r)) : ye(f) && (m = e({ key: f }, r).key), m;
|
|
18
|
+
}))), i[y] = g;
|
|
19
19
|
}), i);
|
|
20
20
|
};
|
|
21
21
|
return e;
|
|
22
|
-
},
|
|
22
|
+
}, xe = Ee(Qe), _e = (n) => (
|
|
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
|
+
n.replace(
|
|
26
26
|
/([a-z0-9])([A-Z])/g,
|
|
27
|
-
(e, t,
|
|
27
|
+
(e, t, r) => `${t}_${r.toLowerCase()}`
|
|
28
28
|
)
|
|
29
|
-
),
|
|
29
|
+
), et = Ee(_e), tt = [Number, String, Uint8Array], ae = {
|
|
30
30
|
recursive: !0,
|
|
31
31
|
recursiveInArray: !0
|
|
32
|
-
},
|
|
33
|
-
let
|
|
32
|
+
}, nt = (n = ae) => (n.recursive == null ? n = ae : n.recursiveInArray ??= !1, n), ye = (n) => n != null && Array.isArray(n), re = (n) => n != null && typeof n == "object" && !Array.isArray(n), we = (n) => tt.some((e) => n instanceof e);
|
|
33
|
+
let rt = class {
|
|
34
34
|
contentType = "application/json";
|
|
35
35
|
decoder;
|
|
36
36
|
encoder;
|
|
@@ -44,16 +44,16 @@ let tt = class {
|
|
|
44
44
|
return this.decodeString(this.decoder.decode(e), t);
|
|
45
45
|
}
|
|
46
46
|
decodeString(e, t) {
|
|
47
|
-
const
|
|
47
|
+
const r = JSON.parse(e), i = xe(r);
|
|
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 = et(e);
|
|
52
|
+
return JSON.stringify(t, (r, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
const
|
|
56
|
-
let
|
|
55
|
+
const oe = new rt(), E = (n) => n != null && typeof n == "object" && "value" in n;
|
|
56
|
+
let F = class {
|
|
57
57
|
/** The underlying primitive value */
|
|
58
58
|
value;
|
|
59
59
|
constructor(e) {
|
|
@@ -73,99 +73,99 @@ let q = class {
|
|
|
73
73
|
return this.value.toString();
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
const
|
|
77
|
-
const t =
|
|
78
|
-
let
|
|
76
|
+
const st = (n) => n != null && typeof n == "object" && "toString" in n, it = (n, e = !1) => {
|
|
77
|
+
const t = st(n) ? "stringer" : typeof n;
|
|
78
|
+
let r;
|
|
79
79
|
switch (t) {
|
|
80
80
|
case "string":
|
|
81
|
-
|
|
81
|
+
r = (i, a) => i.localeCompare(a);
|
|
82
82
|
break;
|
|
83
83
|
case "stringer":
|
|
84
|
-
|
|
84
|
+
r = (i, a) => i.toString().localeCompare(a.toString());
|
|
85
85
|
break;
|
|
86
86
|
case "number":
|
|
87
|
-
|
|
87
|
+
r = (i, a) => Number(i) - Number(a);
|
|
88
88
|
break;
|
|
89
89
|
case "bigint":
|
|
90
|
-
|
|
90
|
+
r = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
|
|
91
91
|
break;
|
|
92
92
|
case "boolean":
|
|
93
|
-
|
|
93
|
+
r = (i, a) => Number(i) - Number(a);
|
|
94
94
|
break;
|
|
95
95
|
case "undefined":
|
|
96
|
-
|
|
96
|
+
r = () => 0;
|
|
97
97
|
break;
|
|
98
98
|
default:
|
|
99
99
|
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
100
100
|
}
|
|
101
|
-
return e ?
|
|
102
|
-
},
|
|
101
|
+
return e ? at(r) : r;
|
|
102
|
+
}, at = (n) => (e, t) => n(t, e), Q = s.tuple([s.number(), s.number()]);
|
|
103
103
|
s.tuple([s.bigint(), s.bigint()]);
|
|
104
|
-
const
|
|
104
|
+
const Ae = s.object({ width: s.number(), height: s.number() }), ot = s.object({
|
|
105
105
|
signedWidth: s.number(),
|
|
106
106
|
signedHeight: s.number()
|
|
107
|
-
}),
|
|
108
|
-
s.enum(at);
|
|
109
|
-
const ot = ["start", "center", "end"], ut = ["signedWidth", "signedHeight"];
|
|
107
|
+
}), ut = ["width", "height"];
|
|
110
108
|
s.enum(ut);
|
|
111
|
-
const
|
|
112
|
-
s.enum(
|
|
113
|
-
const
|
|
114
|
-
s.enum(
|
|
115
|
-
const gt = ["
|
|
116
|
-
s.enum(
|
|
117
|
-
const
|
|
118
|
-
s.
|
|
119
|
-
s.
|
|
120
|
-
s.
|
|
109
|
+
const lt = ["start", "center", "end"], ct = ["signedWidth", "signedHeight"];
|
|
110
|
+
s.enum(ct);
|
|
111
|
+
const K = s.object({ x: s.number(), y: s.number() }), ht = s.object({ clientX: s.number(), clientY: s.number() }), ft = ["x", "y"], Ue = s.enum(ft), Me = ["top", "right", "bottom", "left"];
|
|
112
|
+
s.enum(Me);
|
|
113
|
+
const dt = ["left", "right"], Ce = s.enum(dt), gt = ["top", "bottom"], $e = s.enum(gt), Be = ["center"], be = s.enum(Be), pt = [...Me, ...Be], Re = s.enum(pt);
|
|
114
|
+
s.enum(lt);
|
|
115
|
+
const mt = ["first", "last"];
|
|
116
|
+
s.enum(mt);
|
|
117
|
+
const yt = s.object({ lower: s.number(), upper: s.number() }), wt = s.object({ lower: s.bigint(), upper: s.bigint() });
|
|
118
|
+
s.union([yt, Q]);
|
|
119
|
+
s.union([wt, Q]);
|
|
120
|
+
s.enum([...Ue.options, ...Re.options]);
|
|
121
121
|
s.enum(["x", "left", "right"]);
|
|
122
122
|
s.enum(["y", "top", "bottom"]);
|
|
123
|
-
s.union([
|
|
124
|
-
const
|
|
123
|
+
s.union([Ue, Re, s.instanceof(String)]);
|
|
124
|
+
const _ = (n) => (e, t) => {
|
|
125
125
|
if (typeof e == "bigint") {
|
|
126
|
-
if (
|
|
127
|
-
return
|
|
128
|
-
const
|
|
129
|
-
return typeof
|
|
130
|
-
}
|
|
131
|
-
return
|
|
132
|
-
},
|
|
133
|
-
const
|
|
134
|
-
if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof
|
|
135
|
-
e != null ? (
|
|
136
|
-
else if (Array.isArray(
|
|
137
|
-
if (
|
|
138
|
-
[
|
|
126
|
+
if (bt(t))
|
|
127
|
+
return n(e, BigInt(t));
|
|
128
|
+
const r = n(Number(e), Number(t));
|
|
129
|
+
return typeof r == "number" ? BigInt(Math.round(r)) : r;
|
|
130
|
+
}
|
|
131
|
+
return n(Number(e), Number(t));
|
|
132
|
+
}, ee = _((n, e) => n - e), te = _((n, e) => n + e), bt = (n) => typeof n == "bigint" ? !0 : Number.isInteger(n), M = _((n, e) => n * e), ne = _((n, e) => n / e), D = (n, e, t) => {
|
|
133
|
+
const r = {};
|
|
134
|
+
if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof n == "number" || typeof n == "bigint")
|
|
135
|
+
e != null ? (r.lower = n, r.upper = e) : (r.lower = typeof n == "bigint" ? 0n : 0, r.upper = n);
|
|
136
|
+
else if (Array.isArray(n)) {
|
|
137
|
+
if (n.length !== 2) throw new Error("bounds: expected array of length 2");
|
|
138
|
+
[r.lower, r.upper] = n;
|
|
139
139
|
} else
|
|
140
|
-
|
|
141
|
-
return t?.makeValid ?
|
|
142
|
-
},
|
|
143
|
-
const t =
|
|
140
|
+
r.lower = n.lower, r.upper = n.upper;
|
|
141
|
+
return t?.makeValid ? Ot(r) : r;
|
|
142
|
+
}, Ot = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, Oe = (n, e) => {
|
|
143
|
+
const t = D(n);
|
|
144
144
|
return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
|
|
145
145
|
};
|
|
146
146
|
s.object({
|
|
147
|
-
x:
|
|
148
|
-
y:
|
|
147
|
+
x: Ce.or(be),
|
|
148
|
+
y: $e.or(be)
|
|
149
149
|
});
|
|
150
|
-
const
|
|
150
|
+
const Tt = s.object({ x: Ce, y: $e }), vt = Object.freeze({ x: "left", y: "top" }), It = (n, e) => n.x === e.x && n.y === e.y, Te = s.union([
|
|
151
151
|
s.number(),
|
|
152
|
-
X,
|
|
153
152
|
K,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
Q,
|
|
154
|
+
Ae,
|
|
155
|
+
ot,
|
|
156
|
+
ht
|
|
157
|
+
]), Nt = (n, e) => {
|
|
158
|
+
if (typeof n == "string") {
|
|
159
159
|
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
160
|
-
return
|
|
160
|
+
return n === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
161
161
|
}
|
|
162
|
-
return typeof
|
|
163
|
-
},
|
|
162
|
+
return typeof n == "number" ? { x: n, y: e ?? n } : Array.isArray(n) ? { x: n[0], y: n[1] } : "signedWidth" in n ? { x: n.signedWidth, y: n.signedHeight } : "clientX" in n ? { x: n.clientX, y: n.clientY } : "width" in n ? { x: n.width, y: n.height } : { x: n.x, y: n.y };
|
|
163
|
+
}, ve = Object.freeze({ x: 0, y: 0 }), H = s.union([s.number(), s.string()]);
|
|
164
164
|
s.object({
|
|
165
|
-
top:
|
|
166
|
-
left:
|
|
167
|
-
width:
|
|
168
|
-
height:
|
|
165
|
+
top: H,
|
|
166
|
+
left: H,
|
|
167
|
+
width: H,
|
|
168
|
+
height: H
|
|
169
169
|
});
|
|
170
170
|
s.object({
|
|
171
171
|
left: s.number(),
|
|
@@ -174,61 +174,61 @@ s.object({
|
|
|
174
174
|
bottom: s.number()
|
|
175
175
|
});
|
|
176
176
|
s.object({
|
|
177
|
-
one:
|
|
178
|
-
two:
|
|
179
|
-
root:
|
|
177
|
+
one: K,
|
|
178
|
+
two: K,
|
|
179
|
+
root: Tt
|
|
180
180
|
});
|
|
181
|
-
const
|
|
181
|
+
const de = (n, e, t = 0, r = 0, i) => {
|
|
182
182
|
const a = {
|
|
183
|
-
one: { ...
|
|
184
|
-
two: { ...
|
|
185
|
-
root: i ??
|
|
183
|
+
one: { ...ve },
|
|
184
|
+
two: { ...ve },
|
|
185
|
+
root: i ?? vt
|
|
186
186
|
};
|
|
187
|
-
if (typeof
|
|
187
|
+
if (typeof n == "number") {
|
|
188
188
|
if (typeof e != "number")
|
|
189
189
|
throw new Error("Box constructor called with invalid arguments");
|
|
190
|
-
return a.one = { x:
|
|
190
|
+
return a.one = { x: n, y: e }, a.two = { x: a.one.x + t, y: a.one.y + r }, a;
|
|
191
191
|
}
|
|
192
|
-
return "one" in
|
|
192
|
+
return "one" in n && "two" in n && "root" in n ? { ...n, root: i ?? n.root } : ("getBoundingClientRect" in n && (n = n.getBoundingClientRect()), "left" in n ? (a.one = { x: n.left, y: n.top }, a.two = { x: n.right, y: n.bottom }, a) : (a.one = n, e == null ? a.two = { x: a.one.x + t, y: a.one.y + r } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
|
|
193
193
|
x: a.one.x + e.width,
|
|
194
194
|
y: a.one.y + e.height
|
|
195
195
|
} : "signedWidth" in e ? a.two = {
|
|
196
196
|
x: a.one.x + e.signedWidth,
|
|
197
197
|
y: a.one.y + e.signedHeight
|
|
198
198
|
} : a.two = e, a));
|
|
199
|
-
},
|
|
200
|
-
const e =
|
|
199
|
+
}, se = (n) => {
|
|
200
|
+
const e = de(n);
|
|
201
201
|
return { lower: e.one.x, upper: e.two.x };
|
|
202
|
-
},
|
|
203
|
-
const e =
|
|
202
|
+
}, ie = (n) => {
|
|
203
|
+
const e = de(n);
|
|
204
204
|
return { lower: e.one.y, upper: e.two.y };
|
|
205
|
-
},
|
|
206
|
-
s.union([
|
|
207
|
-
const
|
|
208
|
-
s.object({ offset:
|
|
205
|
+
}, St = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, Et = s.object({ signedWidth: s.number(), signedHeight: s.number() });
|
|
206
|
+
s.union([Ae, Et, K, Q]);
|
|
207
|
+
const xt = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
|
|
208
|
+
s.object({ offset: Te, scale: Te });
|
|
209
209
|
s.object({ offset: s.number(), scale: s.number() });
|
|
210
|
-
const
|
|
210
|
+
const At = (n) => (e, t, r, i) => t === "dimension" ? [e, r] : [
|
|
211
211
|
e,
|
|
212
|
-
i ?
|
|
213
|
-
],
|
|
212
|
+
i ? r - n : r + n
|
|
213
|
+
], Ut = (n) => (e, t, r, i) => [
|
|
214
214
|
e,
|
|
215
|
-
i ?
|
|
216
|
-
],
|
|
217
|
-
if (e === null) return [
|
|
218
|
-
const { lower: i, upper: a } = e, { lower: c, upper:
|
|
219
|
-
if (t === "dimension") return [
|
|
220
|
-
const
|
|
221
|
-
return [
|
|
222
|
-
},
|
|
223
|
-
if (
|
|
224
|
-
if (e === "dimension") return [
|
|
225
|
-
const { lower:
|
|
226
|
-
return [
|
|
227
|
-
},
|
|
228
|
-
const { lower: i, upper: a } =
|
|
229
|
-
return
|
|
215
|
+
i ? r / n : r * n
|
|
216
|
+
], Mt = (n) => (e, t, r) => {
|
|
217
|
+
if (e === null) return [n, r];
|
|
218
|
+
const { lower: i, upper: a } = e, { lower: c, upper: g } = n, y = a - i, f = g - c;
|
|
219
|
+
if (t === "dimension") return [n, r * (f / y)];
|
|
220
|
+
const m = (r - i) * (f / y) + c;
|
|
221
|
+
return [n, m];
|
|
222
|
+
}, Ct = (n) => (e, t, r) => [n, r], $t = () => (n, e, t) => {
|
|
223
|
+
if (n === null) throw new Error("cannot invert without bounds");
|
|
224
|
+
if (e === "dimension") return [n, t];
|
|
225
|
+
const { lower: r, upper: i } = n;
|
|
226
|
+
return [n, i - (t - r)];
|
|
227
|
+
}, Bt = (n) => (e, t, r) => {
|
|
228
|
+
const { lower: i, upper: a } = n;
|
|
229
|
+
return r = xt(r, i, a), [e, r];
|
|
230
230
|
};
|
|
231
|
-
let
|
|
231
|
+
let Ie = class L {
|
|
232
232
|
ops = [];
|
|
233
233
|
currBounds = null;
|
|
234
234
|
currType = null;
|
|
@@ -242,7 +242,7 @@ let ve = class D {
|
|
|
242
242
|
* @param value - The amount to translate by.
|
|
243
243
|
*/
|
|
244
244
|
static translate(e) {
|
|
245
|
-
return new
|
|
245
|
+
return new L().translate(e);
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
@@ -250,10 +250,10 @@ let ve = class D {
|
|
|
250
250
|
* @param value - The amount to translate by.
|
|
251
251
|
*/
|
|
252
252
|
static magnify(e) {
|
|
253
|
-
return new
|
|
253
|
+
return new L().magnify(e);
|
|
254
254
|
}
|
|
255
255
|
static scale(e, t) {
|
|
256
|
-
return new
|
|
256
|
+
return new L().scale(e, t);
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* @returns a copy of the scale with a translation as its next operation. Any
|
|
@@ -262,8 +262,8 @@ let ve = class D {
|
|
|
262
262
|
* @param value - The amount to translate by.
|
|
263
263
|
*/
|
|
264
264
|
translate(e) {
|
|
265
|
-
const t = this.new(),
|
|
266
|
-
return
|
|
265
|
+
const t = this.new(), r = At(e);
|
|
266
|
+
return r.type = "translate", t.ops.push(r), t;
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* @returns a copy of the scale with a translation as its next operation. Any number
|
|
@@ -272,23 +272,23 @@ let ve = class D {
|
|
|
272
272
|
* @param value - The amount to magnify by.
|
|
273
273
|
*/
|
|
274
274
|
magnify(e) {
|
|
275
|
-
const t = this.new(),
|
|
276
|
-
return
|
|
275
|
+
const t = this.new(), r = Ut(e);
|
|
276
|
+
return r.type = "magnify", t.ops.push(r), t;
|
|
277
277
|
}
|
|
278
278
|
scale(e, t) {
|
|
279
|
-
const
|
|
279
|
+
const r = D(e, t), i = this.new(), a = Mt(r);
|
|
280
280
|
return a.type = "scale", i.ops.push(a), i;
|
|
281
281
|
}
|
|
282
282
|
clamp(e, t) {
|
|
283
|
-
const
|
|
283
|
+
const r = D(e, t), i = this.new(), a = Bt(r);
|
|
284
284
|
return a.type = "clamp", i.ops.push(a), i;
|
|
285
285
|
}
|
|
286
286
|
reBound(e, t) {
|
|
287
|
-
const
|
|
287
|
+
const r = D(e, t), i = this.new(), a = Ct(r);
|
|
288
288
|
return a.type = "re-bound", i.ops.push(a), i;
|
|
289
289
|
}
|
|
290
290
|
invert() {
|
|
291
|
-
const e =
|
|
291
|
+
const e = $t();
|
|
292
292
|
e.type = "invert";
|
|
293
293
|
const t = this.new();
|
|
294
294
|
return t.ops.push(e), t;
|
|
@@ -300,12 +300,12 @@ let ve = class D {
|
|
|
300
300
|
return this.exec("dimension", e);
|
|
301
301
|
}
|
|
302
302
|
new() {
|
|
303
|
-
const e = new
|
|
303
|
+
const e = new L();
|
|
304
304
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
305
305
|
}
|
|
306
306
|
exec(e, t) {
|
|
307
307
|
return this.currBounds = null, this.ops.reduce(
|
|
308
|
-
([
|
|
308
|
+
([r, i], a) => a(r, e, i, this.reversed),
|
|
309
309
|
[null, t]
|
|
310
310
|
)[1];
|
|
311
311
|
}
|
|
@@ -313,51 +313,51 @@ let ve = class D {
|
|
|
313
313
|
const e = this.new();
|
|
314
314
|
e.ops.reverse();
|
|
315
315
|
const t = [];
|
|
316
|
-
return e.ops.forEach((
|
|
317
|
-
if (
|
|
316
|
+
return e.ops.forEach((r, i) => {
|
|
317
|
+
if (r.type === "scale" || t.some(([c, g]) => i >= c && i <= g))
|
|
318
318
|
return;
|
|
319
|
-
const a = e.ops.findIndex((c,
|
|
319
|
+
const a = e.ops.findIndex((c, g) => c.type === "scale" && g > i);
|
|
320
320
|
a !== -1 && t.push([i, a]);
|
|
321
|
-
}), t.forEach(([
|
|
322
|
-
const a = e.ops.slice(
|
|
323
|
-
a.unshift(e.ops[i]), e.ops.splice(
|
|
321
|
+
}), t.forEach(([r, i]) => {
|
|
322
|
+
const a = e.ops.slice(r, i);
|
|
323
|
+
a.unshift(e.ops[i]), e.ops.splice(r, i - r + 1, ...a);
|
|
324
324
|
}), e.reversed = !e.reversed, e;
|
|
325
325
|
}
|
|
326
326
|
get transform() {
|
|
327
327
|
return { scale: this.dim(1), offset: this.pos(0) };
|
|
328
328
|
}
|
|
329
|
-
static IDENTITY = new
|
|
330
|
-
},
|
|
329
|
+
static IDENTITY = new L();
|
|
330
|
+
}, _n = class U {
|
|
331
331
|
x;
|
|
332
332
|
y;
|
|
333
333
|
currRoot;
|
|
334
|
-
constructor(e = new
|
|
335
|
-
this.x = e, this.y = t, this.currRoot =
|
|
334
|
+
constructor(e = new Ie(), t = new Ie(), r = null) {
|
|
335
|
+
this.x = e, this.y = t, this.currRoot = r;
|
|
336
336
|
}
|
|
337
337
|
static translate(e, t) {
|
|
338
|
-
return new
|
|
338
|
+
return new U().translate(e, t);
|
|
339
339
|
}
|
|
340
340
|
static translateX(e) {
|
|
341
|
-
return new
|
|
341
|
+
return new U().translateX(e);
|
|
342
342
|
}
|
|
343
343
|
static translateY(e) {
|
|
344
|
-
return new
|
|
344
|
+
return new U().translateY(e);
|
|
345
345
|
}
|
|
346
346
|
static clamp(e) {
|
|
347
|
-
return new
|
|
347
|
+
return new U().clamp(e);
|
|
348
348
|
}
|
|
349
349
|
static magnify(e) {
|
|
350
|
-
return new
|
|
350
|
+
return new U().magnify(e);
|
|
351
351
|
}
|
|
352
352
|
static scale(e) {
|
|
353
|
-
return new
|
|
353
|
+
return new U().scale(e);
|
|
354
354
|
}
|
|
355
355
|
static reBound(e) {
|
|
356
|
-
return new
|
|
356
|
+
return new U().reBound(e);
|
|
357
357
|
}
|
|
358
358
|
translate(e, t) {
|
|
359
|
-
const
|
|
360
|
-
return i.x = this.x.translate(
|
|
359
|
+
const r = Nt(e, t), i = this.copy();
|
|
360
|
+
return i.x = this.x.translate(r.x), i.y = this.y.translate(r.y), i;
|
|
361
361
|
}
|
|
362
362
|
translateX(e) {
|
|
363
363
|
const t = this.copy();
|
|
@@ -373,22 +373,22 @@ let ve = class D {
|
|
|
373
373
|
}
|
|
374
374
|
scale(e) {
|
|
375
375
|
const t = this.copy();
|
|
376
|
-
if (
|
|
377
|
-
const
|
|
378
|
-
return t.currRoot = e.root,
|
|
376
|
+
if (St(e)) {
|
|
377
|
+
const r = this.currRoot;
|
|
378
|
+
return t.currRoot = e.root, r != null && !It(r, e.root) && (r.x !== e.root.x && (t.x = t.x.invert()), r.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(se(e)), t.y = t.y.scale(ie(e)), t;
|
|
379
379
|
}
|
|
380
380
|
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
381
381
|
}
|
|
382
382
|
reBound(e) {
|
|
383
383
|
const t = this.copy();
|
|
384
|
-
return t.x = this.x.reBound(
|
|
384
|
+
return t.x = this.x.reBound(se(e)), t.y = this.y.reBound(ie(e)), t;
|
|
385
385
|
}
|
|
386
386
|
clamp(e) {
|
|
387
387
|
const t = this.copy();
|
|
388
|
-
return t.x = this.x.clamp(
|
|
388
|
+
return t.x = this.x.clamp(se(e)), t.y = this.y.clamp(ie(e)), t;
|
|
389
389
|
}
|
|
390
390
|
copy() {
|
|
391
|
-
const e = new
|
|
391
|
+
const e = new U();
|
|
392
392
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
393
393
|
}
|
|
394
394
|
reverse() {
|
|
@@ -402,7 +402,7 @@ let ve = class D {
|
|
|
402
402
|
return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
|
|
403
403
|
}
|
|
404
404
|
box(e) {
|
|
405
|
-
return
|
|
405
|
+
return de(
|
|
406
406
|
this.pos(e.one),
|
|
407
407
|
this.pos(e.two),
|
|
408
408
|
0,
|
|
@@ -416,35 +416,35 @@ let ve = class D {
|
|
|
416
416
|
offset: this.pos({ x: 0, y: 0 })
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
|
-
static IDENTITY = new
|
|
420
|
-
},
|
|
421
|
-
let
|
|
419
|
+
static IDENTITY = new U();
|
|
420
|
+
}, De = (n, e = 21) => (t = e) => {
|
|
421
|
+
let r = "", i = t | 0;
|
|
422
422
|
for (; i--; )
|
|
423
|
-
|
|
424
|
-
return
|
|
423
|
+
r += n[Math.random() * n.length | 0];
|
|
424
|
+
return r;
|
|
425
425
|
};
|
|
426
|
-
const
|
|
426
|
+
const Le = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Rt = `0123456789${Le}`, Dt = 11, Lt = De(Le, 1), kt = De(Rt, Dt - 1), Pt = () => `${Lt()}${kt()}`, jt = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Yt = s.enum(["static", "dynamic"]), qt = s.union([
|
|
427
427
|
s.tuple([s.int()]),
|
|
428
428
|
s.tuple([s.int(), s.int().min(1).max(12)]),
|
|
429
429
|
s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
|
|
430
|
-
]),
|
|
430
|
+
]), ke = (n, e) => {
|
|
431
431
|
const t = new o(e);
|
|
432
432
|
if (![
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
433
|
+
p.DAY,
|
|
434
|
+
p.HOUR,
|
|
435
|
+
p.MINUTE,
|
|
436
|
+
p.SECOND,
|
|
437
|
+
p.MILLISECOND,
|
|
438
|
+
p.MICROSECOND,
|
|
439
|
+
p.NANOSECOND
|
|
440
440
|
].some((i) => i.equals(t)))
|
|
441
441
|
throw new Error(
|
|
442
442
|
"Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
|
|
443
443
|
);
|
|
444
|
-
const
|
|
445
|
-
return
|
|
444
|
+
const r = n.valueOf() % t.valueOf();
|
|
445
|
+
return n instanceof o ? new o(r) : new p(r);
|
|
446
446
|
};
|
|
447
|
-
class o extends
|
|
447
|
+
class o extends F {
|
|
448
448
|
constructor(e, t = "UTC") {
|
|
449
449
|
if (e == null) super(o.now().valueOf());
|
|
450
450
|
else if (e instanceof Date)
|
|
@@ -453,12 +453,12 @@ class o extends q {
|
|
|
453
453
|
super(o.parseDateTimeString(e, t).valueOf());
|
|
454
454
|
else if (Array.isArray(e)) super(o.parseDate(e));
|
|
455
455
|
else {
|
|
456
|
-
let
|
|
457
|
-
e instanceof Number && (e = e.valueOf()), t === "local" && (
|
|
456
|
+
let r = 0n;
|
|
457
|
+
e instanceof Number && (e = e.valueOf()), t === "local" && (r = 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)), E(e) && (e = e.value), super(BigInt(e.valueOf()) + r);
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
static parseDate([e = 1970, t = 1,
|
|
461
|
-
const i = new Date(e, t - 1,
|
|
460
|
+
static parseDate([e = 1970, t = 1, r = 1]) {
|
|
461
|
+
const i = new Date(e, t - 1, r, 0, 0, 0, 0);
|
|
462
462
|
return new o(BigInt(i.getTime()) * o.MILLISECOND.valueOf()).truncate(o.DAY).valueOf();
|
|
463
463
|
}
|
|
464
464
|
/**
|
|
@@ -469,18 +469,18 @@ class o extends q {
|
|
|
469
469
|
return this.value;
|
|
470
470
|
}
|
|
471
471
|
static parseTimeString(e, t = "UTC") {
|
|
472
|
-
const [
|
|
473
|
-
let c = "00",
|
|
474
|
-
a != null && ([c,
|
|
475
|
-
let y = o.hours(parseInt(
|
|
472
|
+
const [r, i, a] = e.split(":");
|
|
473
|
+
let c = "00", g = "00";
|
|
474
|
+
a != null && ([c, g] = a.split("."));
|
|
475
|
+
let y = o.hours(parseInt(r ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(g ?? "00")));
|
|
476
476
|
return t === "local" && (y = y.add(o.utcOffset)), y.valueOf();
|
|
477
477
|
}
|
|
478
478
|
static parseDateTimeString(e, t = "UTC") {
|
|
479
479
|
if (!e.includes("/") && !e.includes("-"))
|
|
480
480
|
return o.parseTimeString(e, t);
|
|
481
|
-
const
|
|
482
|
-
return e.includes(":") ||
|
|
483
|
-
BigInt(
|
|
481
|
+
const r = new Date(e);
|
|
482
|
+
return e.includes(":") || r.setUTCHours(0, 0, 0, 0), new o(
|
|
483
|
+
BigInt(r.getTime()) * o.MILLISECOND.valueOf(),
|
|
484
484
|
t
|
|
485
485
|
).valueOf();
|
|
486
486
|
}
|
|
@@ -515,16 +515,16 @@ class o extends q {
|
|
|
515
515
|
return e === "UTC" ? this.date().toISOString() : this.sub(o.utcOffset).date().toISOString();
|
|
516
516
|
}
|
|
517
517
|
timeString(e = !1, t = "UTC") {
|
|
518
|
-
const
|
|
519
|
-
return e ?
|
|
518
|
+
const r = this.toISOString(t);
|
|
519
|
+
return e ? r.slice(11, 23) : r.slice(11, 19);
|
|
520
520
|
}
|
|
521
521
|
dateString() {
|
|
522
|
-
const e = this.date(), t = e.toLocaleString("default", { month: "short" }),
|
|
523
|
-
return `${t} ${
|
|
522
|
+
const e = this.date(), t = e.toLocaleString("default", { month: "short" }), r = e.toLocaleString("default", { day: "numeric" });
|
|
523
|
+
return `${t} ${r}`;
|
|
524
524
|
}
|
|
525
525
|
/** @returns The UTC offset for the time zone of the machine. */
|
|
526
526
|
static get utcOffset() {
|
|
527
|
-
return new
|
|
527
|
+
return new p(
|
|
528
528
|
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * o.MINUTE.valueOf()
|
|
529
529
|
);
|
|
530
530
|
}
|
|
@@ -567,7 +567,7 @@ class o extends q {
|
|
|
567
567
|
* valid, regardless of the TimeStamp order.
|
|
568
568
|
*/
|
|
569
569
|
range(e) {
|
|
570
|
-
return new
|
|
570
|
+
return new W(this, e).makeValid();
|
|
571
571
|
}
|
|
572
572
|
/**
|
|
573
573
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -636,7 +636,7 @@ class o extends q {
|
|
|
636
636
|
* TimeSpan.
|
|
637
637
|
*/
|
|
638
638
|
add(e) {
|
|
639
|
-
return new o(
|
|
639
|
+
return new o(te(this.valueOf(), new p(e).valueOf()));
|
|
640
640
|
}
|
|
641
641
|
/**
|
|
642
642
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -646,35 +646,35 @@ class o extends q {
|
|
|
646
646
|
* TimeSpan.
|
|
647
647
|
*/
|
|
648
648
|
sub(e) {
|
|
649
|
-
return new o(
|
|
649
|
+
return new o(ee(this.valueOf(), new p(e).valueOf()));
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
652
652
|
* @returns the floating point number of hours since the unix epoch to the timestamp
|
|
653
653
|
* value.
|
|
654
654
|
*/
|
|
655
655
|
get hours() {
|
|
656
|
-
return Number(this.valueOf()) / Number(
|
|
656
|
+
return Number(this.valueOf()) / Number(p.HOUR.valueOf());
|
|
657
657
|
}
|
|
658
658
|
/**
|
|
659
659
|
* @returns the floating point number of minutes since the unix epoch to the timestamp
|
|
660
660
|
* value.
|
|
661
661
|
*/
|
|
662
662
|
get minutes() {
|
|
663
|
-
return Number(this.valueOf()) / Number(
|
|
663
|
+
return Number(this.valueOf()) / Number(p.MINUTE.valueOf());
|
|
664
664
|
}
|
|
665
665
|
/**
|
|
666
666
|
* @returns the floating point number of days since the unix epoch to the timestamp
|
|
667
667
|
* value.
|
|
668
668
|
*/
|
|
669
669
|
get days() {
|
|
670
|
-
return Number(this.valueOf()) / Number(
|
|
670
|
+
return Number(this.valueOf()) / Number(p.DAY.valueOf());
|
|
671
671
|
}
|
|
672
672
|
/**
|
|
673
673
|
* @returns the floating point number of seconds since the unix epoch to the timestamp
|
|
674
674
|
* value.
|
|
675
675
|
*/
|
|
676
676
|
get seconds() {
|
|
677
|
-
return Number(this.valueOf()) / Number(
|
|
677
|
+
return Number(this.valueOf()) / Number(p.SECOND.valueOf());
|
|
678
678
|
}
|
|
679
679
|
/** @returns the floating point number of milliseconds since the unix epoch. */
|
|
680
680
|
get milliseconds() {
|
|
@@ -734,13 +734,27 @@ class o extends q {
|
|
|
734
734
|
get hour() {
|
|
735
735
|
return this.date().getUTCHours();
|
|
736
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* @returns the integer hour that the timestamp corresponds to within its day in local time.
|
|
739
|
+
*/
|
|
740
|
+
get localHour() {
|
|
741
|
+
return this.date().getHours();
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* @returns a copy of the timestamp with the hour changed.
|
|
745
|
+
* @param hour the value to set the hour to.
|
|
746
|
+
*/
|
|
747
|
+
setLocalHour(e) {
|
|
748
|
+
const t = this.date();
|
|
749
|
+
return t.setHours(e), new o(t);
|
|
750
|
+
}
|
|
737
751
|
/**
|
|
738
752
|
* @returns a copy of the timestamp with the hour changed.
|
|
739
753
|
* @param hour the value to set the hour to.
|
|
740
754
|
*/
|
|
741
755
|
setHour(e) {
|
|
742
756
|
const t = this.date();
|
|
743
|
-
return t.setUTCHours(e), new o(t
|
|
757
|
+
return t.setUTCHours(e), new o(t);
|
|
744
758
|
}
|
|
745
759
|
/** @returns the integer minute that the timestamp corresponds to within its hour. */
|
|
746
760
|
get minute() {
|
|
@@ -800,11 +814,11 @@ class o extends q {
|
|
|
800
814
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
801
815
|
*/
|
|
802
816
|
remainder(e) {
|
|
803
|
-
return
|
|
817
|
+
return ke(this, e);
|
|
804
818
|
}
|
|
805
819
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
806
820
|
get isToday() {
|
|
807
|
-
return this.truncate(
|
|
821
|
+
return this.truncate(p.DAY).equals(o.now().truncate(p.DAY));
|
|
808
822
|
}
|
|
809
823
|
/**
|
|
810
824
|
* Truncates the TimeStamp to the nearest multiple of the given span.
|
|
@@ -831,8 +845,8 @@ class o extends q {
|
|
|
831
845
|
*/
|
|
832
846
|
static max(...e) {
|
|
833
847
|
let t = o.MIN;
|
|
834
|
-
for (const
|
|
835
|
-
const i = new o(
|
|
848
|
+
for (const r of e) {
|
|
849
|
+
const i = new o(r);
|
|
836
850
|
i.after(t) && (t = i);
|
|
837
851
|
}
|
|
838
852
|
return t;
|
|
@@ -845,8 +859,8 @@ class o extends q {
|
|
|
845
859
|
*/
|
|
846
860
|
static min(...e) {
|
|
847
861
|
let t = o.MAX;
|
|
848
|
-
for (const
|
|
849
|
-
const i = new o(
|
|
862
|
+
for (const r of e) {
|
|
863
|
+
const i = new o(r);
|
|
850
864
|
i.before(t) && (t = i);
|
|
851
865
|
}
|
|
852
866
|
return t;
|
|
@@ -912,8 +926,8 @@ class o extends q {
|
|
|
912
926
|
s.number().transform((e) => new o(e)),
|
|
913
927
|
s.bigint().transform((e) => new o(e)),
|
|
914
928
|
s.date().transform((e) => new o(e)),
|
|
915
|
-
s.custom((e) => e instanceof
|
|
916
|
-
|
|
929
|
+
s.custom((e) => e instanceof p).transform((e) => new o(e)),
|
|
930
|
+
qt.transform((e) => new o(e))
|
|
917
931
|
]);
|
|
918
932
|
/**
|
|
919
933
|
* Sorts two timestamps.
|
|
@@ -927,9 +941,9 @@ class o extends q {
|
|
|
927
941
|
return Number(e.valueOf() - t.valueOf());
|
|
928
942
|
}
|
|
929
943
|
}
|
|
930
|
-
let
|
|
944
|
+
let p = class l extends F {
|
|
931
945
|
constructor(e) {
|
|
932
|
-
typeof e == "number" && (e = Math.trunc(e.valueOf())), super(BigInt(e.valueOf()));
|
|
946
|
+
typeof e == "number" && (e = Math.trunc(e.valueOf())), E(e) && (e = e.value), super(BigInt(e.valueOf()));
|
|
933
947
|
}
|
|
934
948
|
/**
|
|
935
949
|
* Creates a TimeSpan representing the given number of seconds.
|
|
@@ -938,7 +952,7 @@ let g = class l extends q {
|
|
|
938
952
|
* @returns A TimeSpan representing the given number of seconds.
|
|
939
953
|
*/
|
|
940
954
|
static fromSeconds(e) {
|
|
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);
|
|
955
|
+
return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : (E(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e));
|
|
942
956
|
}
|
|
943
957
|
/**
|
|
944
958
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -947,7 +961,7 @@ let g = class l extends q {
|
|
|
947
961
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
948
962
|
*/
|
|
949
963
|
static fromMilliseconds(e) {
|
|
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);
|
|
964
|
+
return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : (E(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e));
|
|
951
965
|
}
|
|
952
966
|
/**
|
|
953
967
|
* @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
|
|
@@ -999,7 +1013,7 @@ let g = class l extends q {
|
|
|
999
1013
|
* @returns A new TimeSpan representing the remainder.
|
|
1000
1014
|
*/
|
|
1001
1015
|
remainder(e) {
|
|
1002
|
-
return
|
|
1016
|
+
return ke(this, e);
|
|
1003
1017
|
}
|
|
1004
1018
|
/**
|
|
1005
1019
|
* Truncates the TimeSpan to the nearest multiple of the given span.
|
|
@@ -1018,9 +1032,9 @@ let g = class l extends q {
|
|
|
1018
1032
|
* @returns A string representation of the TimeSpan.
|
|
1019
1033
|
*/
|
|
1020
1034
|
toString() {
|
|
1021
|
-
const e = this.truncate(l.DAY), t = this.truncate(l.HOUR),
|
|
1035
|
+
const e = this.truncate(l.DAY), t = this.truncate(l.HOUR), r = this.truncate(l.MINUTE), i = this.truncate(l.SECOND), a = this.truncate(l.MILLISECOND), c = this.truncate(l.MICROSECOND), g = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), m = r.sub(t), b = i.sub(r), h = a.sub(i), T = c.sub(a), A = g.sub(c);
|
|
1022
1036
|
let C = "";
|
|
1023
|
-
return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `),
|
|
1037
|
+
return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `), m.isZero || (C += `${m.minutes}m `), b.isZero || (C += `${b.seconds}s `), h.isZero || (C += `${h.milliseconds}ms `), T.isZero || (C += `${T.microseconds}µs `), A.isZero || (C += `${A.nanoseconds}ns`), C.trim();
|
|
1024
1038
|
}
|
|
1025
1039
|
/**
|
|
1026
1040
|
* Multiplies the TimeSpan by a scalar value.
|
|
@@ -1029,7 +1043,7 @@ let g = class l extends q {
|
|
|
1029
1043
|
* @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
|
|
1030
1044
|
*/
|
|
1031
1045
|
mult(e) {
|
|
1032
|
-
return new l(
|
|
1046
|
+
return new l(M(this.valueOf(), e));
|
|
1033
1047
|
}
|
|
1034
1048
|
/**
|
|
1035
1049
|
* Divides the TimeSpan by a scalar value.
|
|
@@ -1038,7 +1052,7 @@ let g = class l extends q {
|
|
|
1038
1052
|
* @returns A new TimeSpan that is this TimeSpan divided by the provided value.
|
|
1039
1053
|
*/
|
|
1040
1054
|
div(e) {
|
|
1041
|
-
return new l(
|
|
1055
|
+
return new l(ne(this.valueOf(), e));
|
|
1042
1056
|
}
|
|
1043
1057
|
/** @returns the decimal number of days in the TimeSpan. */
|
|
1044
1058
|
get days() {
|
|
@@ -1118,7 +1132,7 @@ let g = class l extends q {
|
|
|
1118
1132
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
1119
1133
|
*/
|
|
1120
1134
|
static microseconds(e = 1) {
|
|
1121
|
-
return l.nanoseconds(
|
|
1135
|
+
return l.nanoseconds(M(e, 1e3));
|
|
1122
1136
|
}
|
|
1123
1137
|
/** A microsecond. */
|
|
1124
1138
|
static MICROSECOND = l.microseconds(1);
|
|
@@ -1129,7 +1143,7 @@ let g = class l extends q {
|
|
|
1129
1143
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
1130
1144
|
*/
|
|
1131
1145
|
static milliseconds(e = 1) {
|
|
1132
|
-
return l.microseconds(
|
|
1146
|
+
return l.microseconds(M(e, 1e3));
|
|
1133
1147
|
}
|
|
1134
1148
|
/** A millisecond. */
|
|
1135
1149
|
static MILLISECOND = l.milliseconds(1);
|
|
@@ -1140,7 +1154,7 @@ let g = class l extends q {
|
|
|
1140
1154
|
* @returns A TimeSpan representing the given number of seconds.
|
|
1141
1155
|
*/
|
|
1142
1156
|
static seconds(e = 1) {
|
|
1143
|
-
return l.milliseconds(
|
|
1157
|
+
return l.milliseconds(M(e, 1e3));
|
|
1144
1158
|
}
|
|
1145
1159
|
/** A second. */
|
|
1146
1160
|
static SECOND = l.seconds(1);
|
|
@@ -1151,7 +1165,7 @@ let g = class l extends q {
|
|
|
1151
1165
|
* @returns A TimeSpan representing the given number of minutes.
|
|
1152
1166
|
*/
|
|
1153
1167
|
static minutes(e = 1) {
|
|
1154
|
-
return l.seconds(
|
|
1168
|
+
return l.seconds(M(e, 60));
|
|
1155
1169
|
}
|
|
1156
1170
|
/** A minute. */
|
|
1157
1171
|
static MINUTE = l.minutes(1);
|
|
@@ -1162,7 +1176,7 @@ let g = class l extends q {
|
|
|
1162
1176
|
* @returns A TimeSpan representing the given number of hours.
|
|
1163
1177
|
*/
|
|
1164
1178
|
static hours(e) {
|
|
1165
|
-
return l.minutes(
|
|
1179
|
+
return l.minutes(M(e, 60));
|
|
1166
1180
|
}
|
|
1167
1181
|
/** Represents an hour. */
|
|
1168
1182
|
static HOUR = l.hours(1);
|
|
@@ -1173,7 +1187,7 @@ let g = class l extends q {
|
|
|
1173
1187
|
* @returns A TimeSpan representing the given number of days.
|
|
1174
1188
|
*/
|
|
1175
1189
|
static days(e) {
|
|
1176
|
-
return l.hours(
|
|
1190
|
+
return l.hours(M(e, 24));
|
|
1177
1191
|
}
|
|
1178
1192
|
/** Represents a day. */
|
|
1179
1193
|
static DAY = l.days(1);
|
|
@@ -1194,9 +1208,9 @@ let g = class l extends q {
|
|
|
1194
1208
|
s.custom((e) => e instanceof S).transform((e) => new l(e))
|
|
1195
1209
|
]);
|
|
1196
1210
|
};
|
|
1197
|
-
class S extends
|
|
1211
|
+
class S extends F {
|
|
1198
1212
|
constructor(e) {
|
|
1199
|
-
super(e.valueOf());
|
|
1213
|
+
E(e) && (e = e.value), super(e.valueOf());
|
|
1200
1214
|
}
|
|
1201
1215
|
/** @returns a pretty string representation of the rate in the format "X Hz". */
|
|
1202
1216
|
toString() {
|
|
@@ -1212,7 +1226,7 @@ class S extends q {
|
|
|
1212
1226
|
* @returns A TimeSpan representing the period of the Rate.
|
|
1213
1227
|
*/
|
|
1214
1228
|
get period() {
|
|
1215
|
-
return
|
|
1229
|
+
return p.seconds(1 / this.valueOf());
|
|
1216
1230
|
}
|
|
1217
1231
|
/**
|
|
1218
1232
|
* Calculates the number of samples in the given TimeSpan at this rate.
|
|
@@ -1221,7 +1235,7 @@ class S extends q {
|
|
|
1221
1235
|
* @returns The number of samples in the given TimeSpan at this rate.
|
|
1222
1236
|
*/
|
|
1223
1237
|
sampleCount(e) {
|
|
1224
|
-
return new
|
|
1238
|
+
return new p(e).seconds * this.valueOf();
|
|
1225
1239
|
}
|
|
1226
1240
|
/**
|
|
1227
1241
|
* Calculates the number of bytes in the given TimeSpan at this rate.
|
|
@@ -1240,7 +1254,7 @@ class S extends q {
|
|
|
1240
1254
|
* @returns A TimeSpan that corresponds to the given number of samples.
|
|
1241
1255
|
*/
|
|
1242
1256
|
span(e) {
|
|
1243
|
-
return
|
|
1257
|
+
return p.seconds(e / this.valueOf());
|
|
1244
1258
|
}
|
|
1245
1259
|
/**
|
|
1246
1260
|
* Calculates a TimeSpan given the number of bytes at this rate.
|
|
@@ -1250,7 +1264,7 @@ class S extends q {
|
|
|
1250
1264
|
* @returns A TimeSpan that corresponds to the given number of bytes.
|
|
1251
1265
|
*/
|
|
1252
1266
|
byteSpan(e, t) {
|
|
1253
|
-
return this.span(e.valueOf() / t.valueOf());
|
|
1267
|
+
return this.span(e.valueOf() / new I(t).valueOf());
|
|
1254
1268
|
}
|
|
1255
1269
|
/**
|
|
1256
1270
|
* Adds another Rate to this Rate.
|
|
@@ -1259,7 +1273,7 @@ class S extends q {
|
|
|
1259
1273
|
* @returns A new Rate representing the sum of the two rates.
|
|
1260
1274
|
*/
|
|
1261
1275
|
add(e) {
|
|
1262
|
-
return new S(
|
|
1276
|
+
return new S(te(this.valueOf(), new S(e).valueOf()));
|
|
1263
1277
|
}
|
|
1264
1278
|
/**
|
|
1265
1279
|
* Subtracts another Rate from this Rate.
|
|
@@ -1268,7 +1282,7 @@ class S extends q {
|
|
|
1268
1282
|
* @returns A new Rate representing the difference of the two rates.
|
|
1269
1283
|
*/
|
|
1270
1284
|
sub(e) {
|
|
1271
|
-
return new S(
|
|
1285
|
+
return new S(ee(this.valueOf(), new S(e).valueOf()));
|
|
1272
1286
|
}
|
|
1273
1287
|
/**
|
|
1274
1288
|
* Multiplies this Rate by a scalar value.
|
|
@@ -1277,7 +1291,7 @@ class S extends q {
|
|
|
1277
1291
|
* @returns A new Rate representing this Rate multiplied by the value.
|
|
1278
1292
|
*/
|
|
1279
1293
|
mult(e) {
|
|
1280
|
-
return new S(
|
|
1294
|
+
return new S(M(this.valueOf(), e));
|
|
1281
1295
|
}
|
|
1282
1296
|
/**
|
|
1283
1297
|
* Divides this Rate by a scalar value.
|
|
@@ -1286,7 +1300,7 @@ class S extends q {
|
|
|
1286
1300
|
* @returns A new Rate representing this Rate divided by the value.
|
|
1287
1301
|
*/
|
|
1288
1302
|
div(e) {
|
|
1289
|
-
return new S(
|
|
1303
|
+
return new S(ne(this.valueOf(), e));
|
|
1290
1304
|
}
|
|
1291
1305
|
/**
|
|
1292
1306
|
* Creates a Rate representing the given number of Hz.
|
|
@@ -1312,7 +1326,7 @@ class S extends q {
|
|
|
1312
1326
|
s.instanceof(S)
|
|
1313
1327
|
]);
|
|
1314
1328
|
}
|
|
1315
|
-
let I = class N extends
|
|
1329
|
+
let I = class N extends F {
|
|
1316
1330
|
/**
|
|
1317
1331
|
* Creates a Density representing the given number of bytes per value.
|
|
1318
1332
|
*
|
|
@@ -1321,7 +1335,7 @@ let I = class N extends q {
|
|
|
1321
1335
|
* @returns A Density representing the given number of bytes per value.
|
|
1322
1336
|
*/
|
|
1323
1337
|
constructor(e) {
|
|
1324
|
-
super(e.valueOf());
|
|
1338
|
+
E(e) && (e = e.value), super(e.valueOf());
|
|
1325
1339
|
}
|
|
1326
1340
|
/**
|
|
1327
1341
|
* Calculates the number of values in the given Size.
|
|
@@ -1339,7 +1353,7 @@ let I = class N extends q {
|
|
|
1339
1353
|
* @returns A Size representing the given number of values.
|
|
1340
1354
|
*/
|
|
1341
1355
|
size(e) {
|
|
1342
|
-
return new
|
|
1356
|
+
return new ue(e * this.valueOf());
|
|
1343
1357
|
}
|
|
1344
1358
|
/**
|
|
1345
1359
|
* Adds another Density to this Density.
|
|
@@ -1348,7 +1362,7 @@ let I = class N extends q {
|
|
|
1348
1362
|
* @returns A new Density representing the sum of the two densities.
|
|
1349
1363
|
*/
|
|
1350
1364
|
add(e) {
|
|
1351
|
-
return new N(
|
|
1365
|
+
return new N(te(this.valueOf(), new N(e).valueOf()));
|
|
1352
1366
|
}
|
|
1353
1367
|
/**
|
|
1354
1368
|
* Subtracts another Density from this Density.
|
|
@@ -1357,7 +1371,7 @@ let I = class N extends q {
|
|
|
1357
1371
|
* @returns A new Density representing the difference of the two densities.
|
|
1358
1372
|
*/
|
|
1359
1373
|
sub(e) {
|
|
1360
|
-
return new N(
|
|
1374
|
+
return new N(ee(this.valueOf(), new N(e).valueOf()));
|
|
1361
1375
|
}
|
|
1362
1376
|
/**
|
|
1363
1377
|
* Multiplies this Density by a scalar value.
|
|
@@ -1366,7 +1380,7 @@ let I = class N extends q {
|
|
|
1366
1380
|
* @returns A new Density representing this Density multiplied by the value.
|
|
1367
1381
|
*/
|
|
1368
1382
|
mult(e) {
|
|
1369
|
-
return new N(
|
|
1383
|
+
return new N(M(this.valueOf(), e));
|
|
1370
1384
|
}
|
|
1371
1385
|
/**
|
|
1372
1386
|
* Divides this Density by a scalar value.
|
|
@@ -1375,7 +1389,7 @@ let I = class N extends q {
|
|
|
1375
1389
|
* @returns A new Density representing this Density divided by the value.
|
|
1376
1390
|
*/
|
|
1377
1391
|
div(e) {
|
|
1378
|
-
return new N(
|
|
1392
|
+
return new N(ne(this.valueOf(), e));
|
|
1379
1393
|
}
|
|
1380
1394
|
/** Unknown/Invalid Density. */
|
|
1381
1395
|
static UNKNOWN = new N(0);
|
|
@@ -1394,7 +1408,7 @@ let I = class N extends q {
|
|
|
1394
1408
|
s.number().transform((e) => new N(e)),
|
|
1395
1409
|
s.instanceof(N)
|
|
1396
1410
|
]);
|
|
1397
|
-
},
|
|
1411
|
+
}, W = class x {
|
|
1398
1412
|
/**
|
|
1399
1413
|
* The starting TimeStamp of the TimeRange.
|
|
1400
1414
|
*
|
|
@@ -1424,7 +1438,7 @@ let I = class N extends q {
|
|
|
1424
1438
|
}
|
|
1425
1439
|
/** @returns The TimeSpan occupied by the TimeRange. */
|
|
1426
1440
|
get span() {
|
|
1427
|
-
return new
|
|
1441
|
+
return new p(this.end.valueOf() - this.start.valueOf());
|
|
1428
1442
|
}
|
|
1429
1443
|
/**
|
|
1430
1444
|
* Checks if the timestamp is valid i.e. the start is before the end.
|
|
@@ -1462,7 +1476,7 @@ let I = class N extends q {
|
|
|
1462
1476
|
* @returns A TimeRange with the start and end swapped.
|
|
1463
1477
|
*/
|
|
1464
1478
|
swap() {
|
|
1465
|
-
return new
|
|
1479
|
+
return new x(this.end, this.start);
|
|
1466
1480
|
}
|
|
1467
1481
|
get numericBounds() {
|
|
1468
1482
|
return {
|
|
@@ -1476,11 +1490,11 @@ let I = class N extends q {
|
|
|
1476
1490
|
* @param other - The TimeRange to compare to.
|
|
1477
1491
|
* @returns True if the TimeRange is equal to the given TimeRange.
|
|
1478
1492
|
*/
|
|
1479
|
-
equals(e, t =
|
|
1493
|
+
equals(e, t = p.ZERO) {
|
|
1480
1494
|
if (t.isZero)
|
|
1481
1495
|
return this.start.equals(e.start) && this.end.equals(e.end);
|
|
1482
|
-
let
|
|
1483
|
-
return
|
|
1496
|
+
let r = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
|
|
1497
|
+
return r < 0 && (r = -r), i < 0 && (i = -i), r <= t.valueOf() && i <= t.valueOf();
|
|
1484
1498
|
}
|
|
1485
1499
|
/**
|
|
1486
1500
|
* Returns a string representation of the TimeRange.
|
|
@@ -1509,16 +1523,16 @@ let I = class N extends q {
|
|
|
1509
1523
|
* checking for overlap.
|
|
1510
1524
|
* @returns True if the two TimeRanges overlap, false otherwise.
|
|
1511
1525
|
*/
|
|
1512
|
-
overlapsWith(e, t =
|
|
1526
|
+
overlapsWith(e, t = p.ZERO) {
|
|
1513
1527
|
e = e.makeValid();
|
|
1514
|
-
const
|
|
1528
|
+
const r = this.makeValid();
|
|
1515
1529
|
if (this.equals(e)) return !0;
|
|
1516
|
-
if (e.end.equals(
|
|
1517
|
-
const i = o.max(
|
|
1518
|
-
return a.before(i) ? !1 : new
|
|
1530
|
+
if (e.end.equals(r.start) || r.end.equals(e.start)) return !1;
|
|
1531
|
+
const i = o.max(r.start, e.start), a = o.min(r.end, e.end);
|
|
1532
|
+
return a.before(i) ? !1 : new p(a.sub(i)).greaterThanOrEqual(t);
|
|
1519
1533
|
}
|
|
1520
1534
|
contains(e) {
|
|
1521
|
-
return e instanceof
|
|
1535
|
+
return e instanceof x ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
|
|
1522
1536
|
}
|
|
1523
1537
|
/**
|
|
1524
1538
|
* Returns a new TimeRange that is bound by the given TimeRange.
|
|
@@ -1532,25 +1546,25 @@ let I = class N extends q {
|
|
|
1532
1546
|
* console.log(bounded); // TimeRange(1500, 2000)
|
|
1533
1547
|
*/
|
|
1534
1548
|
boundBy(e) {
|
|
1535
|
-
const t = new
|
|
1549
|
+
const t = new x(this.start, this.end);
|
|
1536
1550
|
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;
|
|
1537
1551
|
}
|
|
1538
1552
|
static max(...e) {
|
|
1539
|
-
return new
|
|
1553
|
+
return new x(
|
|
1540
1554
|
o.min(...e.map((t) => t.start)),
|
|
1541
1555
|
o.max(...e.map((t) => t.end))
|
|
1542
1556
|
);
|
|
1543
1557
|
}
|
|
1544
1558
|
/** The maximum possible time range. */
|
|
1545
|
-
static MAX = new
|
|
1559
|
+
static MAX = new x(o.MIN, o.MAX);
|
|
1546
1560
|
/** The minimum possible time range. */
|
|
1547
|
-
static MIN = new
|
|
1561
|
+
static MIN = new x(o.MAX, o.MIN);
|
|
1548
1562
|
/** A time range whose start and end are both zero. */
|
|
1549
|
-
static ZERO = new
|
|
1563
|
+
static ZERO = new x(o.ZERO, o.ZERO);
|
|
1550
1564
|
/** A zod schema for validating and transforming time ranges */
|
|
1551
1565
|
static z = s.union([
|
|
1552
|
-
s.object({ start: o.z, end: o.z }).transform((e) => new
|
|
1553
|
-
s.instanceof(
|
|
1566
|
+
s.object({ start: o.z, end: o.z }).transform((e) => new x(e.start, e.end)),
|
|
1567
|
+
s.instanceof(x)
|
|
1554
1568
|
]);
|
|
1555
1569
|
/**
|
|
1556
1570
|
* Sorts two time ranges. The range with the earlier start time is considered less than
|
|
@@ -1574,17 +1588,17 @@ let I = class N extends q {
|
|
|
1574
1588
|
* @returns A list of simplified `TimeRange`s.
|
|
1575
1589
|
*/
|
|
1576
1590
|
static simplify(e) {
|
|
1577
|
-
return e.map((t) => t.makeValid()).sort((t,
|
|
1578
|
-
if (
|
|
1591
|
+
return e.map((t) => t.makeValid()).sort((t, r) => x.sort(t, r)).reduce((t, r) => {
|
|
1592
|
+
if (r.isZero) return t;
|
|
1579
1593
|
if (t.length === 0)
|
|
1580
|
-
return t.push(
|
|
1594
|
+
return t.push(r), t;
|
|
1581
1595
|
const i = t[t.length - 1];
|
|
1582
|
-
return i.overlapsWith(
|
|
1596
|
+
return i.overlapsWith(r) || i.end.equals(r.start) ? i.end = o.max(i.end, r.end) : t.push(r), t;
|
|
1583
1597
|
}, []);
|
|
1584
1598
|
}
|
|
1585
|
-
}, w = class u extends
|
|
1599
|
+
}, w = class u extends F {
|
|
1586
1600
|
constructor(e) {
|
|
1587
|
-
if (e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
|
|
1601
|
+
if (E(e) && (e = e.value), e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
|
|
1588
1602
|
super(e.valueOf());
|
|
1589
1603
|
else {
|
|
1590
1604
|
const t = u.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
|
|
@@ -1800,25 +1814,25 @@ let I = class N extends q {
|
|
|
1800
1814
|
s.string().transform((e) => new u(e)),
|
|
1801
1815
|
s.instanceof(u)
|
|
1802
1816
|
]);
|
|
1803
|
-
},
|
|
1817
|
+
}, ue = class d extends F {
|
|
1804
1818
|
constructor(e) {
|
|
1805
|
-
super(e.valueOf());
|
|
1819
|
+
E(e) && (e = e.value), super(e.valueOf());
|
|
1806
1820
|
}
|
|
1807
1821
|
/** @returns true if the Size is larger than the other size. */
|
|
1808
1822
|
largerThan(e) {
|
|
1809
|
-
return this.valueOf() > e.valueOf();
|
|
1823
|
+
return E(e) && (e = e.value), this.valueOf() > e.valueOf();
|
|
1810
1824
|
}
|
|
1811
1825
|
/** @returns true if the Size is smaller than the other size. */
|
|
1812
1826
|
smallerThan(e) {
|
|
1813
|
-
return this.valueOf() < e.valueOf();
|
|
1827
|
+
return E(e) && (e = e.value), this.valueOf() < e.valueOf();
|
|
1814
1828
|
}
|
|
1815
1829
|
/** @returns a new Size representing the sum of the two Sizes. */
|
|
1816
1830
|
add(e) {
|
|
1817
|
-
return new
|
|
1831
|
+
return E(e) && (e = e.value), new d(te(this.valueOf(), e.valueOf()));
|
|
1818
1832
|
}
|
|
1819
1833
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1820
1834
|
sub(e) {
|
|
1821
|
-
return new
|
|
1835
|
+
return E(e) && (e = e.value), new d(ee(this.valueOf(), e.valueOf()));
|
|
1822
1836
|
}
|
|
1823
1837
|
/**
|
|
1824
1838
|
* Multiplies this Size by a scalar value.
|
|
@@ -1827,7 +1841,7 @@ let I = class N extends q {
|
|
|
1827
1841
|
* @returns A new Size representing this Size multiplied by the value.
|
|
1828
1842
|
*/
|
|
1829
1843
|
mult(e) {
|
|
1830
|
-
return new
|
|
1844
|
+
return new d(M(this.valueOf(), e));
|
|
1831
1845
|
}
|
|
1832
1846
|
/**
|
|
1833
1847
|
* Divides this Size by a scalar value.
|
|
@@ -1836,37 +1850,39 @@ let I = class N extends q {
|
|
|
1836
1850
|
* @returns A new Size representing this Size divided by the value.
|
|
1837
1851
|
*/
|
|
1838
1852
|
div(e) {
|
|
1839
|
-
return new
|
|
1853
|
+
return new d(ne(this.valueOf(), e));
|
|
1840
1854
|
}
|
|
1841
1855
|
/** @returns a new Size representing the truncated value of the Size. */
|
|
1842
1856
|
truncate(e) {
|
|
1843
|
-
return new
|
|
1857
|
+
return new d(
|
|
1858
|
+
Math.trunc(this.valueOf() / new d(e).valueOf()) * new d(e).valueOf()
|
|
1859
|
+
);
|
|
1844
1860
|
}
|
|
1845
1861
|
/** @returns a new Size representing the remainder of the Size. */
|
|
1846
1862
|
remainder(e) {
|
|
1847
|
-
return
|
|
1863
|
+
return d.bytes(this.valueOf() % new d(e).valueOf());
|
|
1848
1864
|
}
|
|
1849
1865
|
/** @returns the number of gigabytes in the Size. */
|
|
1850
1866
|
get gigabytes() {
|
|
1851
|
-
return this.valueOf() /
|
|
1867
|
+
return this.valueOf() / d.GIGABYTE.valueOf();
|
|
1852
1868
|
}
|
|
1853
1869
|
/** @returns the number of megabytes in the Size. */
|
|
1854
1870
|
get megabytes() {
|
|
1855
|
-
return this.valueOf() /
|
|
1871
|
+
return this.valueOf() / d.MEGABYTE.valueOf();
|
|
1856
1872
|
}
|
|
1857
1873
|
/** @returns the number of kilobytes in the Size. */
|
|
1858
1874
|
get kilobytes() {
|
|
1859
|
-
return this.valueOf() /
|
|
1875
|
+
return this.valueOf() / d.KILOBYTE.valueOf();
|
|
1860
1876
|
}
|
|
1861
1877
|
/** @returns the number of terabytes in the Size. */
|
|
1862
1878
|
get terabytes() {
|
|
1863
|
-
return this.valueOf() /
|
|
1879
|
+
return this.valueOf() / d.TERABYTE.valueOf();
|
|
1864
1880
|
}
|
|
1865
1881
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1866
1882
|
toString() {
|
|
1867
|
-
const e = this.truncate(
|
|
1883
|
+
const e = this.truncate(d.TERABYTE), t = this.truncate(d.GIGABYTE), r = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), a = this.truncate(d.BYTE), c = e, g = t.sub(e), y = r.sub(t), f = i.sub(r), m = a.sub(i);
|
|
1868
1884
|
let b = "";
|
|
1869
|
-
return c.isZero || (b += `${c.terabytes}TB `),
|
|
1885
|
+
return c.isZero || (b += `${c.terabytes}TB `), g.isZero || (b += `${g.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), f.isZero || (b += `${f.kilobytes}KB `), (!m.isZero || b === "") && (b += `${m.valueOf()}B`), b.trim();
|
|
1870
1886
|
}
|
|
1871
1887
|
/**
|
|
1872
1888
|
* Creates a Size from the given number of bytes.
|
|
@@ -1875,10 +1891,10 @@ let I = class N extends q {
|
|
|
1875
1891
|
* @returns A Size representing the given number of bytes.
|
|
1876
1892
|
*/
|
|
1877
1893
|
static bytes(e = 1) {
|
|
1878
|
-
return new
|
|
1894
|
+
return new d(e);
|
|
1879
1895
|
}
|
|
1880
1896
|
/** A single byte */
|
|
1881
|
-
static BYTE = new
|
|
1897
|
+
static BYTE = new d(1);
|
|
1882
1898
|
/**
|
|
1883
1899
|
* Creates a Size from the given number if kilobytes.
|
|
1884
1900
|
*
|
|
@@ -1886,10 +1902,10 @@ let I = class N extends q {
|
|
|
1886
1902
|
* @returns A Size representing the given number of kilobytes.
|
|
1887
1903
|
*/
|
|
1888
1904
|
static kilobytes(e = 1) {
|
|
1889
|
-
return
|
|
1905
|
+
return d.bytes(new d(e).valueOf() * 1e3);
|
|
1890
1906
|
}
|
|
1891
1907
|
/** A kilobyte */
|
|
1892
|
-
static KILOBYTE =
|
|
1908
|
+
static KILOBYTE = d.kilobytes(1);
|
|
1893
1909
|
/**
|
|
1894
1910
|
* Creates a Size from the given number of megabytes.
|
|
1895
1911
|
*
|
|
@@ -1897,10 +1913,10 @@ let I = class N extends q {
|
|
|
1897
1913
|
* @returns A Size representing the given number of megabytes.
|
|
1898
1914
|
*/
|
|
1899
1915
|
static megabytes(e = 1) {
|
|
1900
|
-
return
|
|
1916
|
+
return d.kilobytes(new d(e).valueOf() * 1e3);
|
|
1901
1917
|
}
|
|
1902
1918
|
/** A megabyte */
|
|
1903
|
-
static MEGABYTE =
|
|
1919
|
+
static MEGABYTE = d.megabytes(1);
|
|
1904
1920
|
/**
|
|
1905
1921
|
* Creates a Size from the given number of gigabytes.
|
|
1906
1922
|
*
|
|
@@ -1908,10 +1924,10 @@ let I = class N extends q {
|
|
|
1908
1924
|
* @returns A Size representing the given number of gigabytes.
|
|
1909
1925
|
*/
|
|
1910
1926
|
static gigabytes(e = 1) {
|
|
1911
|
-
return
|
|
1927
|
+
return d.megabytes(new d(e).valueOf() * 1e3);
|
|
1912
1928
|
}
|
|
1913
1929
|
/** A gigabyte */
|
|
1914
|
-
static GIGABYTE =
|
|
1930
|
+
static GIGABYTE = d.gigabytes(1);
|
|
1915
1931
|
/**
|
|
1916
1932
|
* Creates a Size from the given number of terabytes.
|
|
1917
1933
|
*
|
|
@@ -1919,16 +1935,16 @@ let I = class N extends q {
|
|
|
1919
1935
|
* @returns A Size representing the given number of terabytes.
|
|
1920
1936
|
*/
|
|
1921
1937
|
static terabytes(e) {
|
|
1922
|
-
return
|
|
1938
|
+
return d.gigabytes(new d(e).valueOf() * 1e3);
|
|
1923
1939
|
}
|
|
1924
1940
|
/** A terabyte. */
|
|
1925
|
-
static TERABYTE =
|
|
1941
|
+
static TERABYTE = d.terabytes(1);
|
|
1926
1942
|
/** The zero value for Size */
|
|
1927
|
-
static ZERO = new
|
|
1943
|
+
static ZERO = new d(0);
|
|
1928
1944
|
/** A zod schema for a Size. */
|
|
1929
1945
|
static z = s.union([
|
|
1930
|
-
s.number().transform((e) => new
|
|
1931
|
-
s.instanceof(
|
|
1946
|
+
s.number().transform((e) => new d(e)),
|
|
1947
|
+
s.instanceof(d)
|
|
1932
1948
|
]);
|
|
1933
1949
|
/** @returns true if the Size is zero. */
|
|
1934
1950
|
get isZero() {
|
|
@@ -1947,37 +1963,37 @@ s.union([
|
|
|
1947
1963
|
s.instanceof(Int32Array),
|
|
1948
1964
|
s.instanceof(BigInt64Array)
|
|
1949
1965
|
]);
|
|
1950
|
-
const Pe = (
|
|
1951
|
-
const e = typeof
|
|
1952
|
-
return e === "string" || e === "number" || e === "boolean" || e === "bigint" ||
|
|
1953
|
-
},
|
|
1954
|
-
function
|
|
1955
|
-
return typeof
|
|
1966
|
+
const Pe = (n) => {
|
|
1967
|
+
const e = typeof n;
|
|
1968
|
+
return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof o || n instanceof p || n instanceof Date;
|
|
1969
|
+
}, Ft = (n, e, t, r = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(r) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(r.valueOf()) : X(t, -r), X = (n, e) => e == 0 ? n : n == 0 ? e : typeof n == "bigint" && typeof e == "bigint" || typeof n == "number" && typeof e == "number" ? n + e : Number(n) + Number(e), Wt = /^(?:[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;
|
|
1970
|
+
function Zt(n) {
|
|
1971
|
+
return typeof n == "string" && Wt.test(n);
|
|
1956
1972
|
}
|
|
1957
1973
|
const v = [];
|
|
1958
|
-
for (let
|
|
1959
|
-
v.push((
|
|
1960
|
-
function
|
|
1961
|
-
return (v[
|
|
1974
|
+
for (let n = 0; n < 256; ++n)
|
|
1975
|
+
v.push((n + 256).toString(16).slice(1));
|
|
1976
|
+
function Vt(n, e = 0) {
|
|
1977
|
+
return (v[n[e + 0]] + v[n[e + 1]] + v[n[e + 2]] + v[n[e + 3]] + "-" + v[n[e + 4]] + v[n[e + 5]] + "-" + v[n[e + 6]] + v[n[e + 7]] + "-" + v[n[e + 8]] + v[n[e + 9]] + "-" + v[n[e + 10]] + v[n[e + 11]] + v[n[e + 12]] + v[n[e + 13]] + v[n[e + 14]] + v[n[e + 15]]).toLowerCase();
|
|
1962
1978
|
}
|
|
1963
|
-
function
|
|
1964
|
-
const t =
|
|
1965
|
-
if (!
|
|
1979
|
+
function zt(n, e = 0) {
|
|
1980
|
+
const t = Vt(n, e);
|
|
1981
|
+
if (!Zt(t))
|
|
1966
1982
|
throw TypeError("Stringified UUID is invalid");
|
|
1967
1983
|
return t;
|
|
1968
1984
|
}
|
|
1969
1985
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1970
|
-
const
|
|
1971
|
-
(
|
|
1972
|
-
atob(
|
|
1986
|
+
const je = (n, e) => zt(n, e), $ = -1, Gt = s.string().transform(
|
|
1987
|
+
(n) => new Uint8Array(
|
|
1988
|
+
atob(n).split("").map((e) => e.charCodeAt(0))
|
|
1973
1989
|
).buffer
|
|
1974
|
-
),
|
|
1975
|
-
if (
|
|
1990
|
+
), Ht = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), le = 10, Jt = (n, e) => {
|
|
1991
|
+
if (n === "number" && !e.isNumeric)
|
|
1976
1992
|
throw new Error(`cannot convert series of type ${e.toString()} to number`);
|
|
1977
|
-
if (
|
|
1993
|
+
if (n === "bigint" && !e.usesBigInt)
|
|
1978
1994
|
throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
|
|
1979
1995
|
}, Ye = "sy_x_telem_series";
|
|
1980
|
-
class
|
|
1996
|
+
let qe = class B {
|
|
1981
1997
|
/**
|
|
1982
1998
|
* A unique identifier for the series. If specified by the user, it is their
|
|
1983
1999
|
* responsibility to ensure that it is unique. If not specified, a new ID will be
|
|
@@ -2004,7 +2020,7 @@ class M {
|
|
|
2004
2020
|
/** The underlying data. */
|
|
2005
2021
|
_data;
|
|
2006
2022
|
/** The time range occupied by the series' data. */
|
|
2007
|
-
timeRange =
|
|
2023
|
+
timeRange = W.ZERO;
|
|
2008
2024
|
/**
|
|
2009
2025
|
* Alignment defines the location of the series relative to other series in a logical
|
|
2010
2026
|
* group. Useful for defining the position of the series within a channel's data.
|
|
@@ -2033,22 +2049,22 @@ class M {
|
|
|
2033
2049
|
* can be constructed into a series.
|
|
2034
2050
|
*/
|
|
2035
2051
|
static crudeZ = s.object({
|
|
2036
|
-
timeRange:
|
|
2052
|
+
timeRange: W.z.optional(),
|
|
2037
2053
|
dataType: w.z,
|
|
2038
2054
|
alignment: s.coerce.bigint().optional(),
|
|
2039
2055
|
data: s.union([
|
|
2040
|
-
|
|
2041
|
-
|
|
2056
|
+
Gt,
|
|
2057
|
+
Ht,
|
|
2042
2058
|
s.instanceof(ArrayBuffer),
|
|
2043
2059
|
s.instanceof(Uint8Array)
|
|
2044
2060
|
]),
|
|
2045
|
-
glBufferUsage:
|
|
2061
|
+
glBufferUsage: Yt.optional().default("static").optional()
|
|
2046
2062
|
});
|
|
2047
2063
|
/**
|
|
2048
2064
|
* A zod schema that validates and constructs a series from it's crude
|
|
2049
2065
|
* representation.
|
|
2050
2066
|
*/
|
|
2051
|
-
static z =
|
|
2067
|
+
static z = B.crudeZ.transform((e) => new B(e));
|
|
2052
2068
|
/**
|
|
2053
2069
|
* The Series constructor accepts either a SeriesArgs object or a CrudeSeries value.
|
|
2054
2070
|
*
|
|
@@ -2123,32 +2139,32 @@ class M {
|
|
|
2123
2139
|
* @throws Error if data type cannot be inferred from input
|
|
2124
2140
|
*/
|
|
2125
2141
|
constructor(e) {
|
|
2126
|
-
|
|
2142
|
+
Xt(e) && (e = { data: e }), e.data ??= [];
|
|
2127
2143
|
const {
|
|
2128
2144
|
dataType: t,
|
|
2129
|
-
timeRange:
|
|
2145
|
+
timeRange: r,
|
|
2130
2146
|
sampleOffset: i = 0,
|
|
2131
2147
|
glBufferUsage: a = "static",
|
|
2132
2148
|
alignment: c = 0n,
|
|
2133
|
-
alignmentMultiple:
|
|
2134
|
-
key: y =
|
|
2149
|
+
alignmentMultiple: g = 1n,
|
|
2150
|
+
key: y = Pt(),
|
|
2135
2151
|
data: f
|
|
2136
2152
|
} = e;
|
|
2137
|
-
if (
|
|
2153
|
+
if (Kt(f)) {
|
|
2138
2154
|
const h = f;
|
|
2139
2155
|
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;
|
|
2140
2156
|
return;
|
|
2141
2157
|
}
|
|
2142
|
-
const
|
|
2158
|
+
const m = Pe(f), b = Array.isArray(f);
|
|
2143
2159
|
if (t != null) this.dataType = new w(t);
|
|
2144
2160
|
else {
|
|
2145
2161
|
if (f instanceof ArrayBuffer)
|
|
2146
2162
|
throw new Error(
|
|
2147
2163
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
2148
2164
|
);
|
|
2149
|
-
if (b ||
|
|
2165
|
+
if (b || m) {
|
|
2150
2166
|
let h = f;
|
|
2151
|
-
if (!
|
|
2167
|
+
if (!m) {
|
|
2152
2168
|
if (f.length === 0)
|
|
2153
2169
|
throw new Error(
|
|
2154
2170
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
@@ -2168,25 +2184,25 @@ class M {
|
|
|
2168
2184
|
);
|
|
2169
2185
|
} else this.dataType = new w(f);
|
|
2170
2186
|
}
|
|
2171
|
-
if (!b && !
|
|
2187
|
+
if (!b && !m) this._data = f;
|
|
2172
2188
|
else if (b && f.length === 0)
|
|
2173
2189
|
this._data = new this.dataType.Array([]).buffer;
|
|
2174
2190
|
else {
|
|
2175
|
-
let h =
|
|
2191
|
+
let h = m ? [f] : f;
|
|
2176
2192
|
const T = h[0];
|
|
2177
|
-
(T instanceof o || T instanceof Date || T instanceof
|
|
2193
|
+
(T instanceof o || T instanceof Date || T instanceof p) && (h = h.map((A) => new o(A).valueOf())), this.dataType.equals(w.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
|
|
2178
2194
|
`)}
|
|
2179
2195
|
`).buffer) : this.dataType.equals(w.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
|
|
2180
|
-
`${h.map((
|
|
2196
|
+
`${h.map((A) => oe.encodeString(A)).join(`
|
|
2181
2197
|
`)}
|
|
2182
2198
|
`
|
|
2183
2199
|
).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
|
|
2184
|
-
h.map((
|
|
2200
|
+
h.map((A) => BigInt(Math.round(A)))
|
|
2185
2201
|
).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
|
|
2186
2202
|
h.map(Number)
|
|
2187
2203
|
).buffer : this._data = new this.dataType.Array(h).buffer;
|
|
2188
2204
|
}
|
|
2189
|
-
this.key = y, this.alignment = c, this.alignmentMultiple =
|
|
2205
|
+
this.key = y, this.alignment = c, this.alignmentMultiple = g, this.sampleOffset = i ?? 0, this.timeRange = r ?? W.ZERO, this.gl = {
|
|
2190
2206
|
control: null,
|
|
2191
2207
|
buffer: null,
|
|
2192
2208
|
prevBuffer: 0,
|
|
@@ -2200,10 +2216,10 @@ class M {
|
|
|
2200
2216
|
* @param args.dataType the data type of the series.
|
|
2201
2217
|
* @param args.rest the rest of the arguments to pass to the series constructor.
|
|
2202
2218
|
*/
|
|
2203
|
-
static alloc({ capacity: e, dataType: t, ...
|
|
2219
|
+
static alloc({ capacity: e, dataType: t, ...r }) {
|
|
2204
2220
|
if (e === 0)
|
|
2205
2221
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
2206
|
-
const i = new new w(t).Array(e), a = new
|
|
2222
|
+
const i = new new w(t).Array(e), a = new B({ data: i.buffer, dataType: t, ...r });
|
|
2207
2223
|
return a.writePos = 0, a;
|
|
2208
2224
|
}
|
|
2209
2225
|
/**
|
|
@@ -2247,13 +2263,13 @@ class M {
|
|
|
2247
2263
|
}
|
|
2248
2264
|
writeVariable(e) {
|
|
2249
2265
|
if (this.writePos === $) return 0;
|
|
2250
|
-
const t = this.byteCapacity.valueOf() - this.writePos,
|
|
2251
|
-
return this.writeToUnderlyingData(
|
|
2266
|
+
const t = this.byteCapacity.valueOf() - this.writePos, r = e.subBytes(0, t);
|
|
2267
|
+
return this.writeToUnderlyingData(r), this.writePos += r.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += r.length, this.calculateCachedLength()), r.length;
|
|
2252
2268
|
}
|
|
2253
2269
|
writeFixed(e) {
|
|
2254
2270
|
if (this.writePos === $) return 0;
|
|
2255
|
-
const t = this.capacity - this.writePos,
|
|
2256
|
-
return this.writeToUnderlyingData(
|
|
2271
|
+
const t = this.capacity - this.writePos, r = e.sub(0, t);
|
|
2272
|
+
return this.writeToUnderlyingData(r), this.cachedLength = void 0, this.maybeRecomputeMinMax(r), this.writePos += r.length, r.length;
|
|
2257
2273
|
}
|
|
2258
2274
|
writeToUnderlyingData(e) {
|
|
2259
2275
|
this.underlyingData.set(
|
|
@@ -2295,14 +2311,14 @@ class M {
|
|
|
2295
2311
|
parseJSON(e) {
|
|
2296
2312
|
if (!this.dataType.equals(w.JSON))
|
|
2297
2313
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
2298
|
-
return this.toStrings().map((t) => e.parse(
|
|
2314
|
+
return this.toStrings().map((t) => e.parse(oe.decodeString(t)));
|
|
2299
2315
|
}
|
|
2300
2316
|
/**
|
|
2301
2317
|
* Returns the capacity of the series in bytes.
|
|
2302
2318
|
* @returns The size of the underlying buffer in bytes.
|
|
2303
2319
|
*/
|
|
2304
2320
|
get byteCapacity() {
|
|
2305
|
-
return new
|
|
2321
|
+
return new ue(this.underlyingData.byteLength);
|
|
2306
2322
|
}
|
|
2307
2323
|
/**
|
|
2308
2324
|
* Returns the capacity of the series in samples.
|
|
@@ -2318,7 +2334,7 @@ class M {
|
|
|
2318
2334
|
* @returns The size of the data in bytes.
|
|
2319
2335
|
*/
|
|
2320
2336
|
get byteLength() {
|
|
2321
|
-
return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new
|
|
2337
|
+
return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new ue(this.writePos) : this.dataType.density.size(this.writePos);
|
|
2322
2338
|
}
|
|
2323
2339
|
/**
|
|
2324
2340
|
* Returns the number of samples in this array.
|
|
@@ -2333,8 +2349,8 @@ class M {
|
|
|
2333
2349
|
throw new Error("cannot calculate length of a non-variable length data type");
|
|
2334
2350
|
let e = 0;
|
|
2335
2351
|
const t = [0];
|
|
2336
|
-
return this.data.forEach((
|
|
2337
|
-
|
|
2352
|
+
return this.data.forEach((r, i) => {
|
|
2353
|
+
r === le && (e++, t.push(i + 1));
|
|
2338
2354
|
}), this._cachedIndexes = t, this.cachedLength = e, e;
|
|
2339
2355
|
}
|
|
2340
2356
|
/**
|
|
@@ -2348,11 +2364,11 @@ class M {
|
|
|
2348
2364
|
*/
|
|
2349
2365
|
convert(e, t = 0) {
|
|
2350
2366
|
if (this.dataType.equals(e)) return this;
|
|
2351
|
-
const
|
|
2367
|
+
const r = new e.Array(this.length);
|
|
2352
2368
|
for (let i = 0; i < this.length; i++)
|
|
2353
|
-
|
|
2354
|
-
return new
|
|
2355
|
-
data:
|
|
2369
|
+
r[i] = Ft(this.dataType, e, this.data[i], t);
|
|
2370
|
+
return new B({
|
|
2371
|
+
data: r.buffer,
|
|
2356
2372
|
dataType: e,
|
|
2357
2373
|
timeRange: this.timeRange,
|
|
2358
2374
|
sampleOffset: t,
|
|
@@ -2366,10 +2382,10 @@ class M {
|
|
|
2366
2382
|
this.cachedMax = this.data[this.data.length - 1];
|
|
2367
2383
|
else if (this.dataType.usesBigInt) {
|
|
2368
2384
|
const e = this.data;
|
|
2369
|
-
this.cachedMax = e.reduce((t,
|
|
2385
|
+
this.cachedMax = e.reduce((t, r) => t > r ? t : r);
|
|
2370
2386
|
} else {
|
|
2371
2387
|
const e = this.data;
|
|
2372
|
-
this.cachedMax = e.reduce((t,
|
|
2388
|
+
this.cachedMax = e.reduce((t, r) => t > r ? t : r);
|
|
2373
2389
|
}
|
|
2374
2390
|
return this.cachedMax;
|
|
2375
2391
|
}
|
|
@@ -2380,17 +2396,17 @@ class M {
|
|
|
2380
2396
|
calcMax() {
|
|
2381
2397
|
if (this.dataType.isVariable)
|
|
2382
2398
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
2383
|
-
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(),
|
|
2399
|
+
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), X(this.cachedMax, this.sampleOffset));
|
|
2384
2400
|
}
|
|
2385
2401
|
calcRawMin() {
|
|
2386
2402
|
if (this.length === 0) return 1 / 0;
|
|
2387
2403
|
if (this.dataType.equals(w.TIMESTAMP)) this.cachedMin = this.data[0];
|
|
2388
2404
|
else if (this.dataType.usesBigInt) {
|
|
2389
2405
|
const e = this.data;
|
|
2390
|
-
this.cachedMin = e.reduce((t,
|
|
2406
|
+
this.cachedMin = e.reduce((t, r) => t < r ? t : r);
|
|
2391
2407
|
} else {
|
|
2392
2408
|
const e = this.data;
|
|
2393
|
-
this.cachedMin = e.reduce((t,
|
|
2409
|
+
this.cachedMin = e.reduce((t, r) => t < r ? t : r);
|
|
2394
2410
|
}
|
|
2395
2411
|
return this.cachedMin;
|
|
2396
2412
|
}
|
|
@@ -2401,11 +2417,11 @@ class M {
|
|
|
2401
2417
|
calcMin() {
|
|
2402
2418
|
if (this.dataType.isVariable)
|
|
2403
2419
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
2404
|
-
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(),
|
|
2420
|
+
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), X(this.cachedMin, this.sampleOffset));
|
|
2405
2421
|
}
|
|
2406
2422
|
/** @returns the bounds of the series. */
|
|
2407
2423
|
get bounds() {
|
|
2408
|
-
return
|
|
2424
|
+
return D(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
2409
2425
|
}
|
|
2410
2426
|
maybeRecomputeMinMax(e) {
|
|
2411
2427
|
if (this.cachedMin != null) {
|
|
@@ -2418,56 +2434,56 @@ class M {
|
|
|
2418
2434
|
}
|
|
2419
2435
|
}
|
|
2420
2436
|
atAlignment(e, t) {
|
|
2421
|
-
const
|
|
2422
|
-
if (
|
|
2423
|
-
if (t === !0) throw new Error(`[series] - no value at index ${
|
|
2437
|
+
const r = Number((e - this.alignment) / this.alignmentMultiple);
|
|
2438
|
+
if (r < 0 || r >= this.length) {
|
|
2439
|
+
if (t === !0) throw new Error(`[series] - no value at index ${r}`);
|
|
2424
2440
|
return;
|
|
2425
2441
|
}
|
|
2426
|
-
return this.at(
|
|
2442
|
+
return this.at(r, t);
|
|
2427
2443
|
}
|
|
2428
2444
|
at(e, t = !1) {
|
|
2429
2445
|
if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
|
|
2430
2446
|
if (this.dataType.equals(w.UUID)) return this.atUUID(e, t);
|
|
2431
2447
|
e < 0 && (e = this.length + e);
|
|
2432
|
-
const
|
|
2433
|
-
if (
|
|
2448
|
+
const r = this.data[e];
|
|
2449
|
+
if (r == null) {
|
|
2434
2450
|
if (t === !0) throw new Error(`[series] - no value at index ${e}`);
|
|
2435
2451
|
return;
|
|
2436
2452
|
}
|
|
2437
|
-
return
|
|
2453
|
+
return X(r, this.sampleOffset);
|
|
2438
2454
|
}
|
|
2439
2455
|
atUUID(e, t) {
|
|
2440
2456
|
e < 0 && (e = this.length + e);
|
|
2441
|
-
const
|
|
2457
|
+
const r = je(
|
|
2442
2458
|
new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
|
|
2443
2459
|
);
|
|
2444
|
-
if (
|
|
2460
|
+
if (r == null) {
|
|
2445
2461
|
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
2446
2462
|
return;
|
|
2447
2463
|
}
|
|
2448
|
-
return
|
|
2464
|
+
return r;
|
|
2449
2465
|
}
|
|
2450
2466
|
atVariable(e, t) {
|
|
2451
|
-
let
|
|
2467
|
+
let r = 0, i = 0;
|
|
2452
2468
|
if (this._cachedIndexes != null)
|
|
2453
|
-
|
|
2469
|
+
r = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
|
|
2454
2470
|
else {
|
|
2455
2471
|
e < 0 && (e = this.length + e);
|
|
2456
2472
|
for (let c = 0; c < this.data.length; c++)
|
|
2457
|
-
if (this.data[c] ===
|
|
2473
|
+
if (this.data[c] === le) {
|
|
2458
2474
|
if (e === 0) {
|
|
2459
2475
|
i = c;
|
|
2460
2476
|
break;
|
|
2461
2477
|
}
|
|
2462
|
-
|
|
2478
|
+
r = c + 1, e--;
|
|
2463
2479
|
}
|
|
2464
|
-
if (i === 0 && (i = this.data.length),
|
|
2480
|
+
if (i === 0 && (i = this.data.length), r >= i || e > 0) {
|
|
2465
2481
|
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
2466
2482
|
return;
|
|
2467
2483
|
}
|
|
2468
2484
|
}
|
|
2469
|
-
const a = this.data.slice(
|
|
2470
|
-
return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) :
|
|
2485
|
+
const a = this.data.slice(r, i);
|
|
2486
|
+
return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : xe(JSON.parse(new TextDecoder().decode(a)));
|
|
2471
2487
|
}
|
|
2472
2488
|
/**
|
|
2473
2489
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
@@ -2475,12 +2491,12 @@ class M {
|
|
|
2475
2491
|
* @param value the value to search for.
|
|
2476
2492
|
*/
|
|
2477
2493
|
binarySearch(e) {
|
|
2478
|
-
let t = 0,
|
|
2479
|
-
const i =
|
|
2480
|
-
for (; t <=
|
|
2481
|
-
const a = Math.floor((t +
|
|
2494
|
+
let t = 0, r = this.length - 1;
|
|
2495
|
+
const i = it(e);
|
|
2496
|
+
for (; t <= r; ) {
|
|
2497
|
+
const a = Math.floor((t + r) / 2), c = i(this.at(a, !0), e);
|
|
2482
2498
|
if (c === 0) return a;
|
|
2483
|
-
c < 0 ? t = a + 1 :
|
|
2499
|
+
c < 0 ? t = a + 1 : r = a - 1;
|
|
2484
2500
|
}
|
|
2485
2501
|
return t;
|
|
2486
2502
|
}
|
|
@@ -2494,7 +2510,7 @@ class M {
|
|
|
2494
2510
|
updateGLBuffer(e) {
|
|
2495
2511
|
if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
|
|
2496
2512
|
throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
|
|
2497
|
-
const { buffer: t, bufferUsage:
|
|
2513
|
+
const { buffer: t, bufferUsage: r, prevBuffer: i } = this.gl;
|
|
2498
2514
|
if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
|
|
2499
2515
|
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== $) {
|
|
2500
2516
|
i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
|
|
@@ -2504,11 +2520,11 @@ class M {
|
|
|
2504
2520
|
e.bufferData(
|
|
2505
2521
|
e.ARRAY_BUFFER,
|
|
2506
2522
|
this.buffer,
|
|
2507
|
-
|
|
2523
|
+
r === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
|
|
2508
2524
|
), this.gl.prevBuffer = $;
|
|
2509
2525
|
}
|
|
2510
2526
|
as(e) {
|
|
2511
|
-
return
|
|
2527
|
+
return Jt(e, this.dataType), this;
|
|
2512
2528
|
}
|
|
2513
2529
|
/** @returns a digest containing information about the series. */
|
|
2514
2530
|
get digest() {
|
|
@@ -2517,8 +2533,9 @@ class M {
|
|
|
2517
2533
|
dataType: this.dataType.toString(),
|
|
2518
2534
|
sampleOffset: this.sampleOffset,
|
|
2519
2535
|
alignment: {
|
|
2520
|
-
lower:
|
|
2521
|
-
upper:
|
|
2536
|
+
lower: Se(this.alignmentBounds.lower),
|
|
2537
|
+
upper: Se(this.alignmentBounds.upper),
|
|
2538
|
+
multiple: this.alignmentMultiple
|
|
2522
2539
|
},
|
|
2523
2540
|
timeRange: this.timeRange.toString(),
|
|
2524
2541
|
length: this.length,
|
|
@@ -2535,7 +2552,7 @@ class M {
|
|
|
2535
2552
|
* is exclusive.
|
|
2536
2553
|
*/
|
|
2537
2554
|
get alignmentBounds() {
|
|
2538
|
-
return
|
|
2555
|
+
return D(
|
|
2539
2556
|
this.alignment,
|
|
2540
2557
|
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2541
2558
|
);
|
|
@@ -2555,10 +2572,10 @@ class M {
|
|
|
2555
2572
|
}
|
|
2556
2573
|
[Symbol.iterator]() {
|
|
2557
2574
|
if (this.dataType.isVariable) {
|
|
2558
|
-
const e = new
|
|
2559
|
-
return this.dataType.equals(w.JSON) ? new
|
|
2575
|
+
const e = new Qt(this);
|
|
2576
|
+
return this.dataType.equals(w.JSON) ? new _t(e) : e;
|
|
2560
2577
|
}
|
|
2561
|
-
return this.dataType.equals(w.UUID) ? new
|
|
2578
|
+
return this.dataType.equals(w.UUID) ? new en(this) : new tn(this);
|
|
2562
2579
|
}
|
|
2563
2580
|
/**
|
|
2564
2581
|
* Returns a slice of the series from start to end.
|
|
@@ -2585,7 +2602,7 @@ class M {
|
|
|
2585
2602
|
* @returns An iterator over the specified range.
|
|
2586
2603
|
*/
|
|
2587
2604
|
subIterator(e, t) {
|
|
2588
|
-
return new
|
|
2605
|
+
return new Ne(this, e, t ?? this.length);
|
|
2589
2606
|
}
|
|
2590
2607
|
/**
|
|
2591
2608
|
* Returns an iterator over a portion of the series based on alignment.
|
|
@@ -2594,18 +2611,18 @@ class M {
|
|
|
2594
2611
|
* @returns An iterator over the specified alignment range.
|
|
2595
2612
|
*/
|
|
2596
2613
|
subAlignmentIterator(e, t) {
|
|
2597
|
-
const
|
|
2614
|
+
const r = Math.ceil(
|
|
2598
2615
|
Number(e - this.alignment) / Number(this.alignmentMultiple)
|
|
2599
2616
|
), i = Math.ceil(
|
|
2600
2617
|
Number(t - this.alignment) / Number(this.alignmentMultiple)
|
|
2601
2618
|
);
|
|
2602
|
-
return new
|
|
2619
|
+
return new Ne(this, r, i);
|
|
2603
2620
|
}
|
|
2604
2621
|
subBytes(e, t) {
|
|
2605
2622
|
if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
|
|
2606
|
-
const
|
|
2607
|
-
return new
|
|
2608
|
-
data:
|
|
2623
|
+
const r = this.data.subarray(e, t);
|
|
2624
|
+
return new B({
|
|
2625
|
+
data: r,
|
|
2609
2626
|
dataType: this.dataType,
|
|
2610
2627
|
timeRange: this.timeRange,
|
|
2611
2628
|
sampleOffset: this.sampleOffset,
|
|
@@ -2613,10 +2630,10 @@ class M {
|
|
|
2613
2630
|
alignment: this.alignment + BigInt(e)
|
|
2614
2631
|
});
|
|
2615
2632
|
}
|
|
2616
|
-
sliceSub(e, t,
|
|
2617
|
-
if (t <= 0 && (
|
|
2633
|
+
sliceSub(e, t, r) {
|
|
2634
|
+
if (t <= 0 && (r == null || r >= this.length)) return this;
|
|
2618
2635
|
let i;
|
|
2619
|
-
return e ? i = this.data.subarray(t,
|
|
2636
|
+
return e ? i = this.data.subarray(t, r) : i = this.data.slice(t, r), new B({
|
|
2620
2637
|
data: i,
|
|
2621
2638
|
dataType: this.dataType,
|
|
2622
2639
|
timeRange: this.timeRange,
|
|
@@ -2631,10 +2648,10 @@ class M {
|
|
|
2631
2648
|
* @returns A new series with the specified alignment.
|
|
2632
2649
|
*/
|
|
2633
2650
|
reAlign(e) {
|
|
2634
|
-
return new
|
|
2651
|
+
return new B({
|
|
2635
2652
|
data: this.buffer,
|
|
2636
2653
|
dataType: this.dataType,
|
|
2637
|
-
timeRange:
|
|
2654
|
+
timeRange: W.ZERO,
|
|
2638
2655
|
sampleOffset: this.sampleOffset,
|
|
2639
2656
|
glBufferUsage: "static",
|
|
2640
2657
|
alignment: e
|
|
@@ -2657,22 +2674,22 @@ class M {
|
|
|
2657
2674
|
}
|
|
2658
2675
|
return e += "])", e;
|
|
2659
2676
|
}
|
|
2660
|
-
}
|
|
2661
|
-
const
|
|
2662
|
-
class
|
|
2677
|
+
};
|
|
2678
|
+
const Xt = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof qe ? !0 : Pe(n), Kt = jt(Ye, qe);
|
|
2679
|
+
let Ne = class {
|
|
2663
2680
|
series;
|
|
2664
2681
|
end;
|
|
2665
2682
|
index;
|
|
2666
|
-
constructor(e, t,
|
|
2683
|
+
constructor(e, t, r) {
|
|
2667
2684
|
this.series = e;
|
|
2668
|
-
const i =
|
|
2669
|
-
this.end =
|
|
2685
|
+
const i = D(0, e.length + 1);
|
|
2686
|
+
this.end = Oe(i, r), this.index = Oe(i, t);
|
|
2670
2687
|
}
|
|
2671
2688
|
next() {
|
|
2672
2689
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
2673
2690
|
}
|
|
2674
|
-
}
|
|
2675
|
-
class
|
|
2691
|
+
};
|
|
2692
|
+
class Qt {
|
|
2676
2693
|
series;
|
|
2677
2694
|
index;
|
|
2678
2695
|
decoder;
|
|
@@ -2685,12 +2702,12 @@ class Xt {
|
|
|
2685
2702
|
}
|
|
2686
2703
|
next() {
|
|
2687
2704
|
const e = this.index, t = this.series.data;
|
|
2688
|
-
for (; this.index < t.length && t[this.index] !==
|
|
2689
|
-
const
|
|
2690
|
-
return e ===
|
|
2705
|
+
for (; this.index < t.length && t[this.index] !== le; ) this.index++;
|
|
2706
|
+
const r = this.index;
|
|
2707
|
+
return e === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, r)) });
|
|
2691
2708
|
}
|
|
2692
2709
|
}
|
|
2693
|
-
let
|
|
2710
|
+
let _t = class Fe {
|
|
2694
2711
|
wrapped;
|
|
2695
2712
|
static schema = s.record(s.string(), s.unknown());
|
|
2696
2713
|
constructor(e) {
|
|
@@ -2700,11 +2717,10 @@ let Kt = class je {
|
|
|
2700
2717
|
const e = this.wrapped.next();
|
|
2701
2718
|
return e.done === !0 ? { done: !0, value: void 0 } : {
|
|
2702
2719
|
done: !1,
|
|
2703
|
-
value:
|
|
2720
|
+
value: oe.decodeString(e.value, Fe.schema)
|
|
2704
2721
|
};
|
|
2705
2722
|
}
|
|
2706
|
-
}
|
|
2707
|
-
class Qt {
|
|
2723
|
+
}, en = class {
|
|
2708
2724
|
series;
|
|
2709
2725
|
index;
|
|
2710
2726
|
data;
|
|
@@ -2716,11 +2732,11 @@ class Qt {
|
|
|
2716
2732
|
}
|
|
2717
2733
|
next() {
|
|
2718
2734
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2719
|
-
const e =
|
|
2735
|
+
const e = je(this.data, this.index * this.density);
|
|
2720
2736
|
return this.index++, { done: !1, value: e };
|
|
2721
2737
|
}
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2738
|
+
};
|
|
2739
|
+
class tn {
|
|
2724
2740
|
series;
|
|
2725
2741
|
index;
|
|
2726
2742
|
constructor(e) {
|
|
@@ -2732,9 +2748,9 @@ let _t = class {
|
|
|
2732
2748
|
value: this.series.at(this.index++, !0)
|
|
2733
2749
|
};
|
|
2734
2750
|
}
|
|
2735
|
-
}
|
|
2736
|
-
const
|
|
2737
|
-
const e =
|
|
2751
|
+
}
|
|
2752
|
+
const Se = (n) => {
|
|
2753
|
+
const e = n >> 32n, t = n & 0xffffffffn;
|
|
2738
2754
|
return { domain: e, sample: t };
|
|
2739
2755
|
};
|
|
2740
2756
|
s.object({ key: s.string(), value: s.string() });
|
|
@@ -2742,18 +2758,18 @@ s.record(
|
|
|
2742
2758
|
s.union([s.number(), s.string(), s.symbol()]),
|
|
2743
2759
|
s.unknown()
|
|
2744
2760
|
);
|
|
2745
|
-
const
|
|
2746
|
-
|
|
2747
|
-
const
|
|
2761
|
+
const nn = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
|
|
2762
|
+
nn();
|
|
2763
|
+
const rn = ["macOS", "Windows", "Linux"], sn = ["macos", "windows", "linux"], an = {
|
|
2748
2764
|
macos: "macOS",
|
|
2749
2765
|
windows: "Windows",
|
|
2750
2766
|
linux: "Linux"
|
|
2751
2767
|
};
|
|
2752
|
-
s.enum(
|
|
2753
|
-
s.enum(
|
|
2768
|
+
s.enum(rn).or(
|
|
2769
|
+
s.enum(sn).transform((n) => an[n])
|
|
2754
2770
|
);
|
|
2755
|
-
const
|
|
2756
|
-
class
|
|
2771
|
+
const on = (...n) => n.map(We).join(""), We = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), un = (n) => n.endsWith("/") ? n.slice(0, -1) : n, ln = (n, e = "") => n === null ? "" : `?${Object.entries(n).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, r]) => `${e}${t}=${r}`).join("&")}`;
|
|
2772
|
+
class V {
|
|
2757
2773
|
protocol;
|
|
2758
2774
|
host;
|
|
2759
2775
|
port;
|
|
@@ -2764,8 +2780,8 @@ class Z {
|
|
|
2764
2780
|
* @param protocol - The protocol to use for all requests. Defaults to "".
|
|
2765
2781
|
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
2766
2782
|
*/
|
|
2767
|
-
constructor({ host: e, port: t, protocol:
|
|
2768
|
-
this.protocol =
|
|
2783
|
+
constructor({ host: e, port: t, protocol: r = "", pathPrefix: i = "" }) {
|
|
2784
|
+
this.protocol = r, this.host = e, this.port = t, this.path = We(i);
|
|
2769
2785
|
}
|
|
2770
2786
|
/**
|
|
2771
2787
|
* Replaces creates a new URL with the specified properties replaced.
|
|
@@ -2773,7 +2789,7 @@ class Z {
|
|
|
2773
2789
|
* @returns a new URL.
|
|
2774
2790
|
*/
|
|
2775
2791
|
replace(e) {
|
|
2776
|
-
return new
|
|
2792
|
+
return new V({
|
|
2777
2793
|
host: e.host ?? this.host,
|
|
2778
2794
|
port: e.port ?? this.port,
|
|
2779
2795
|
protocol: e.protocol ?? this.protocol,
|
|
@@ -2786,37 +2802,37 @@ class Z {
|
|
|
2786
2802
|
* @returns a new URL.
|
|
2787
2803
|
*/
|
|
2788
2804
|
child(e) {
|
|
2789
|
-
return new
|
|
2805
|
+
return new V({
|
|
2790
2806
|
...this,
|
|
2791
|
-
pathPrefix:
|
|
2807
|
+
pathPrefix: on(this.path, e)
|
|
2792
2808
|
});
|
|
2793
2809
|
}
|
|
2794
2810
|
/** @returns a string representation of the url */
|
|
2795
2811
|
toString() {
|
|
2796
|
-
return
|
|
2812
|
+
return un(
|
|
2797
2813
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
2798
2814
|
);
|
|
2799
2815
|
}
|
|
2800
|
-
static UNKNOWN = new
|
|
2816
|
+
static UNKNOWN = new V({ host: "unknown", port: 0 });
|
|
2801
2817
|
}
|
|
2802
|
-
const
|
|
2803
|
-
(e) => setTimeout(e,
|
|
2818
|
+
const cn = async (n) => await new Promise(
|
|
2819
|
+
(e) => setTimeout(e, p.fromMilliseconds(n).milliseconds)
|
|
2804
2820
|
);
|
|
2805
|
-
class
|
|
2821
|
+
class hn {
|
|
2806
2822
|
config;
|
|
2807
2823
|
retries;
|
|
2808
2824
|
interval;
|
|
2809
2825
|
constructor(e) {
|
|
2810
2826
|
this.config = {
|
|
2811
|
-
baseInterval: new
|
|
2827
|
+
baseInterval: new p(e?.baseInterval ?? p.seconds(1)),
|
|
2812
2828
|
maxRetries: e?.maxRetries ?? 5,
|
|
2813
2829
|
scale: e?.scale ?? 1,
|
|
2814
|
-
sleepFn: e?.sleepFn ??
|
|
2815
|
-
}, this.retries = 0, this.interval = new
|
|
2830
|
+
sleepFn: e?.sleepFn ?? cn
|
|
2831
|
+
}, this.retries = 0, this.interval = new p(this.config.baseInterval);
|
|
2816
2832
|
}
|
|
2817
2833
|
async wait() {
|
|
2818
|
-
const { maxRetries: e, scale: t, sleepFn:
|
|
2819
|
-
return this.retries >= e ? !1 : (await
|
|
2834
|
+
const { maxRetries: e, scale: t, sleepFn: r } = this.config;
|
|
2835
|
+
return this.retries >= e ? !1 : (await r(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
|
|
2820
2836
|
}
|
|
2821
2837
|
get retryMessage() {
|
|
2822
2838
|
return `breaker triggered ${this.retries + 1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`;
|
|
@@ -2825,134 +2841,134 @@ class ur {
|
|
|
2825
2841
|
this.retries = 0, this.interval = this.config.baseInterval;
|
|
2826
2842
|
}
|
|
2827
2843
|
}
|
|
2828
|
-
const
|
|
2829
|
-
baseInterval:
|
|
2844
|
+
const fn = s.object({
|
|
2845
|
+
baseInterval: p.z.optional(),
|
|
2830
2846
|
maxRetries: s.number().optional(),
|
|
2831
2847
|
scale: s.number().optional()
|
|
2832
|
-
}),
|
|
2848
|
+
}), dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2833
2849
|
__proto__: null,
|
|
2834
|
-
Breaker:
|
|
2835
|
-
breakerConfigZ:
|
|
2836
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2837
|
-
if (
|
|
2838
|
-
if (Array.isArray(
|
|
2839
|
-
if (
|
|
2840
|
-
throw new Error(`Invalid color: [${
|
|
2841
|
-
return
|
|
2842
|
-
}
|
|
2843
|
-
return
|
|
2844
|
-
},
|
|
2845
|
-
J(
|
|
2846
|
-
J(
|
|
2847
|
-
J(
|
|
2848
|
-
|
|
2849
|
-
]), J = (
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
const
|
|
2850
|
+
Breaker: hn,
|
|
2851
|
+
breakerConfigZ: fn
|
|
2852
|
+
}, Symbol.toStringTag, { value: "Module" })), gn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ze = s.string().regex(gn), P = s.number().min(0).max(255), Ve = s.number().min(0).max(1), ze = s.tuple([P, P, P, Ve]), pn = s.tuple([P, P, P]), mn = s.object({ rgba255: ze }), yn = s.number().min(0).max(360), wn = s.number().min(0).max(100), bn = s.number().min(0).max(100), On = s.tuple([yn, wn, bn, Ve]), ge = s.union([Ze, pn, ze, On, mn]), Tn = ge.transform((n) => pe(n)), pe = (n, e = 1) => {
|
|
2853
|
+
if (n = ge.parse(n), typeof n == "string") return vn(n, e);
|
|
2854
|
+
if (Array.isArray(n)) {
|
|
2855
|
+
if (n.length < 3 || n.length > 4)
|
|
2856
|
+
throw new Error(`Invalid color: [${n.join(", ")}]`);
|
|
2857
|
+
return n.length === 3 ? [...n, e] : n;
|
|
2858
|
+
}
|
|
2859
|
+
return n.rgba255;
|
|
2860
|
+
}, vn = (n, e = 1) => (n = Ze.parse(n), n = In(n), [
|
|
2861
|
+
J(n, 0),
|
|
2862
|
+
J(n, 2),
|
|
2863
|
+
J(n, 4),
|
|
2864
|
+
n.length === 8 ? J(n, 6) / 255 : e
|
|
2865
|
+
]), J = (n, e) => parseInt(n.slice(e, e + 2), 16), In = (n) => n.startsWith("#") ? n.slice(1) : n;
|
|
2866
|
+
pe("#000000");
|
|
2867
|
+
pe("#ffffff");
|
|
2868
|
+
const Nn = s.object({
|
|
2853
2869
|
key: s.string(),
|
|
2854
|
-
color:
|
|
2870
|
+
color: ge,
|
|
2855
2871
|
position: s.number(),
|
|
2856
2872
|
switched: s.boolean().optional()
|
|
2857
2873
|
});
|
|
2858
|
-
s.array(
|
|
2859
|
-
const
|
|
2874
|
+
s.array(Nn);
|
|
2875
|
+
const Sn = s.object({
|
|
2860
2876
|
key: s.string(),
|
|
2861
2877
|
name: s.string(),
|
|
2862
|
-
color:
|
|
2878
|
+
color: Tn
|
|
2863
2879
|
});
|
|
2864
2880
|
s.object({
|
|
2865
2881
|
key: s.string(),
|
|
2866
2882
|
name: s.string(),
|
|
2867
|
-
swatches: s.array(
|
|
2883
|
+
swatches: s.array(Sn)
|
|
2868
2884
|
});
|
|
2869
2885
|
s.int().min(0).max(255);
|
|
2870
2886
|
s.object({
|
|
2871
2887
|
name: s.string(),
|
|
2872
2888
|
key: s.string()
|
|
2873
2889
|
});
|
|
2874
|
-
const
|
|
2875
|
-
const t = Symbol.for(
|
|
2876
|
-
if (!
|
|
2877
|
-
const
|
|
2878
|
-
Object.defineProperty(globalThis, t, { value:
|
|
2890
|
+
const En = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), xn = (n, e) => {
|
|
2891
|
+
const t = Symbol.for(n);
|
|
2892
|
+
if (!En(t)) {
|
|
2893
|
+
const r = e();
|
|
2894
|
+
Object.defineProperty(globalThis, t, { value: r });
|
|
2879
2895
|
}
|
|
2880
2896
|
return () => globalThis[t];
|
|
2881
|
-
},
|
|
2882
|
-
static discriminator =
|
|
2883
|
-
discriminator =
|
|
2884
|
-
static TYPE =
|
|
2885
|
-
type =
|
|
2886
|
-
static matches =
|
|
2887
|
-
matches =
|
|
2888
|
-
constructor(t,
|
|
2889
|
-
super(t,
|
|
2897
|
+
}, Ge = "sy_x_error", An = (n) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(n) : e instanceof Error ? e.message.startsWith(n) : typeof e != "string" ? !1 : e.startsWith(n), z = (n) => class Z extends Error {
|
|
2898
|
+
static discriminator = Ge;
|
|
2899
|
+
discriminator = Z.discriminator;
|
|
2900
|
+
static TYPE = n;
|
|
2901
|
+
type = Z.TYPE;
|
|
2902
|
+
static matches = An(n);
|
|
2903
|
+
matches = Z.matches;
|
|
2904
|
+
constructor(t, r) {
|
|
2905
|
+
super(t, r), this.name = Z.TYPE;
|
|
2890
2906
|
}
|
|
2891
2907
|
static sub(t) {
|
|
2892
|
-
return
|
|
2908
|
+
return z(`${n}.${t}`);
|
|
2893
2909
|
}
|
|
2894
|
-
},
|
|
2895
|
-
if (
|
|
2896
|
-
const e =
|
|
2897
|
-
if (e.discriminator !==
|
|
2910
|
+
}, He = (n) => {
|
|
2911
|
+
if (n == null || typeof n != "object") return !1;
|
|
2912
|
+
const e = n;
|
|
2913
|
+
if (e.discriminator !== Ge) return !1;
|
|
2898
2914
|
if (!("type" in e))
|
|
2899
2915
|
throw new Error(
|
|
2900
2916
|
`X Error is missing its type property: ${JSON.stringify(e)}`
|
|
2901
2917
|
);
|
|
2902
2918
|
return !0;
|
|
2903
|
-
},
|
|
2904
|
-
class
|
|
2919
|
+
}, k = "unknown", ce = "nil";
|
|
2920
|
+
class Un {
|
|
2905
2921
|
providers = [];
|
|
2906
2922
|
register(e) {
|
|
2907
2923
|
this.providers.push(e);
|
|
2908
2924
|
}
|
|
2909
2925
|
encode(e) {
|
|
2910
|
-
if (e == null) return { type:
|
|
2911
|
-
if (
|
|
2926
|
+
if (e == null) return { type: ce, data: "" };
|
|
2927
|
+
if (He(e))
|
|
2912
2928
|
for (const t of this.providers) {
|
|
2913
|
-
const
|
|
2914
|
-
if (
|
|
2929
|
+
const r = t.encode(e);
|
|
2930
|
+
if (r != null) return r;
|
|
2915
2931
|
}
|
|
2916
|
-
if (e instanceof Error) return { type:
|
|
2917
|
-
if (typeof e == "string") return { type:
|
|
2932
|
+
if (e instanceof Error) return { type: k, data: e.message };
|
|
2933
|
+
if (typeof e == "string") return { type: k, data: e };
|
|
2918
2934
|
try {
|
|
2919
|
-
return { type:
|
|
2935
|
+
return { type: k, data: JSON.stringify(e) };
|
|
2920
2936
|
} catch {
|
|
2921
|
-
return { type:
|
|
2937
|
+
return { type: k, data: "unable to encode error information" };
|
|
2922
2938
|
}
|
|
2923
2939
|
}
|
|
2924
2940
|
decode(e) {
|
|
2925
|
-
if (e == null || e.type ===
|
|
2926
|
-
if (e.type ===
|
|
2941
|
+
if (e == null || e.type === ce) return null;
|
|
2942
|
+
if (e.type === k) return new he(e.data);
|
|
2927
2943
|
for (const t of this.providers) {
|
|
2928
|
-
const
|
|
2929
|
-
if (
|
|
2944
|
+
const r = t.decode(e);
|
|
2945
|
+
if (r != null) return r;
|
|
2930
2946
|
}
|
|
2931
|
-
return new
|
|
2947
|
+
return new he(e.data);
|
|
2932
2948
|
}
|
|
2933
2949
|
}
|
|
2934
|
-
const
|
|
2935
|
-
class
|
|
2950
|
+
const me = xn("synnax-error-registry", () => new Un()), Mn = ({ encode: n, decode: e }) => me().register({ encode: n, decode: e }), Cn = (n) => me().encode(n), $n = (n) => n == null ? null : me().decode(n);
|
|
2951
|
+
class he extends z("unknown") {
|
|
2936
2952
|
}
|
|
2937
|
-
const
|
|
2938
|
-
class
|
|
2953
|
+
const Bn = s.object({ type: s.string(), data: s.string() });
|
|
2954
|
+
class Rn extends z("canceled") {
|
|
2939
2955
|
}
|
|
2940
|
-
class
|
|
2956
|
+
class Dn extends z("not_implemented") {
|
|
2941
2957
|
}
|
|
2942
|
-
const
|
|
2958
|
+
const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2943
2959
|
__proto__: null,
|
|
2944
|
-
Canceled:
|
|
2945
|
-
NONE:
|
|
2946
|
-
NotImplemented:
|
|
2947
|
-
UNKNOWN:
|
|
2948
|
-
Unknown:
|
|
2949
|
-
createTyped:
|
|
2950
|
-
decode:
|
|
2951
|
-
encode:
|
|
2952
|
-
isTyped:
|
|
2953
|
-
payloadZ:
|
|
2954
|
-
register:
|
|
2955
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2960
|
+
Canceled: Rn,
|
|
2961
|
+
NONE: ce,
|
|
2962
|
+
NotImplemented: Dn,
|
|
2963
|
+
UNKNOWN: k,
|
|
2964
|
+
Unknown: he,
|
|
2965
|
+
createTyped: z,
|
|
2966
|
+
decode: $n,
|
|
2967
|
+
encode: Cn,
|
|
2968
|
+
isTyped: He,
|
|
2969
|
+
payloadZ: Bn,
|
|
2970
|
+
register: Mn
|
|
2971
|
+
}, Symbol.toStringTag, { value: "Module" })), Ln = O.object({
|
|
2956
2972
|
jsonrpc: O.literal("2.0"),
|
|
2957
2973
|
method: O.string(),
|
|
2958
2974
|
// params should be z.union([z.record(z.string(), z.json()),
|
|
@@ -2960,12 +2976,12 @@ const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2960
2976
|
// definition of params then in the JSON-RPC spec.
|
|
2961
2977
|
params: O.any().optional(),
|
|
2962
2978
|
id: O.union([O.string(), O.number(), O.null()]).optional()
|
|
2963
|
-
}),
|
|
2979
|
+
}), Je = O.object({
|
|
2964
2980
|
jsonrpc: O.literal("2.0"),
|
|
2965
2981
|
id: O.union([O.string(), O.number(), O.null()])
|
|
2966
|
-
}),
|
|
2982
|
+
}), kn = Je.extend({
|
|
2967
2983
|
result: O.json()
|
|
2968
|
-
}),
|
|
2984
|
+
}), Pn = Je.extend({
|
|
2969
2985
|
error: O.object({
|
|
2970
2986
|
code: O.number().int(),
|
|
2971
2987
|
// This should be z.string(), but the VSCode JSON RPC implementation uses a looser
|
|
@@ -2973,11 +2989,11 @@ const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2973
2989
|
message: O.string().optional(),
|
|
2974
2990
|
data: O.json().optional()
|
|
2975
2991
|
})
|
|
2976
|
-
}),
|
|
2977
|
-
O.union([
|
|
2992
|
+
}), jn = O.union([kn, Pn]);
|
|
2993
|
+
O.union([Ln, jn]);
|
|
2978
2994
|
s.string().regex(/^\d+\.\d+\.\d+$/);
|
|
2979
|
-
const
|
|
2980
|
-
s.enum(
|
|
2995
|
+
const Yn = ["standard", "scientific", "engineering"];
|
|
2996
|
+
s.enum(Yn);
|
|
2981
2997
|
s.enum([
|
|
2982
2998
|
"success",
|
|
2983
2999
|
"info",
|
|
@@ -2986,51 +3002,51 @@ s.enum([
|
|
|
2986
3002
|
"loading",
|
|
2987
3003
|
"disabled"
|
|
2988
3004
|
]);
|
|
2989
|
-
class
|
|
3005
|
+
class G extends R.createTyped("freighter") {
|
|
2990
3006
|
}
|
|
2991
|
-
class
|
|
3007
|
+
class j extends G.sub("eof") {
|
|
2992
3008
|
constructor() {
|
|
2993
3009
|
super("EOF");
|
|
2994
3010
|
}
|
|
2995
3011
|
}
|
|
2996
|
-
class Y extends
|
|
3012
|
+
class Y extends G.sub("stream_closed") {
|
|
2997
3013
|
constructor() {
|
|
2998
3014
|
super("StreamClosed");
|
|
2999
3015
|
}
|
|
3000
3016
|
}
|
|
3001
|
-
class
|
|
3017
|
+
class q extends G.sub("unreachable") {
|
|
3002
3018
|
url;
|
|
3003
3019
|
constructor(e = {}) {
|
|
3004
|
-
const { message: t = "Unreachable", url:
|
|
3005
|
-
super(t), this.url =
|
|
3020
|
+
const { message: t = "Unreachable", url: r = V.UNKNOWN } = e;
|
|
3021
|
+
super(t), this.url = r;
|
|
3006
3022
|
}
|
|
3007
3023
|
}
|
|
3008
|
-
const
|
|
3009
|
-
if (!
|
|
3010
|
-
if (
|
|
3011
|
-
if (Y.matches(
|
|
3024
|
+
const qn = (n) => {
|
|
3025
|
+
if (!n.type.startsWith(G.TYPE)) return null;
|
|
3026
|
+
if (j.matches(n)) return { type: j.TYPE, data: "EOF" };
|
|
3027
|
+
if (Y.matches(n))
|
|
3012
3028
|
return { type: Y.TYPE, data: "StreamClosed" };
|
|
3013
|
-
if (
|
|
3014
|
-
return { type:
|
|
3015
|
-
throw new Error(`Unknown error type: ${
|
|
3016
|
-
},
|
|
3017
|
-
if (!
|
|
3018
|
-
switch (
|
|
3019
|
-
case k.TYPE:
|
|
3020
|
-
return new k();
|
|
3021
|
-
case Y.TYPE:
|
|
3022
|
-
return new Y();
|
|
3029
|
+
if (q.matches(n))
|
|
3030
|
+
return { type: q.TYPE, data: "Unreachable" };
|
|
3031
|
+
throw new Error(`Unknown error type: ${n.type}: ${n.message}`);
|
|
3032
|
+
}, Fn = (n) => {
|
|
3033
|
+
if (!n.type.startsWith(G.TYPE)) return null;
|
|
3034
|
+
switch (n.type) {
|
|
3023
3035
|
case j.TYPE:
|
|
3024
3036
|
return new j();
|
|
3037
|
+
case Y.TYPE:
|
|
3038
|
+
return new Y();
|
|
3039
|
+
case q.TYPE:
|
|
3040
|
+
return new q();
|
|
3025
3041
|
default:
|
|
3026
|
-
throw new
|
|
3042
|
+
throw new R.Unknown(`Unknown error type: ${n.data}`);
|
|
3027
3043
|
}
|
|
3028
3044
|
};
|
|
3029
|
-
|
|
3030
|
-
encode:
|
|
3031
|
-
decode:
|
|
3045
|
+
R.register({
|
|
3046
|
+
encode: qn,
|
|
3047
|
+
decode: Fn
|
|
3032
3048
|
});
|
|
3033
|
-
class
|
|
3049
|
+
class Xe {
|
|
3034
3050
|
middleware = [];
|
|
3035
3051
|
/** Implements the Transport interface */
|
|
3036
3052
|
use(...e) {
|
|
@@ -3046,50 +3062,50 @@ class Je {
|
|
|
3046
3062
|
* @returns An error if one was encountered, otherwise undefined.
|
|
3047
3063
|
*/
|
|
3048
3064
|
async executeMiddleware(e, t) {
|
|
3049
|
-
let
|
|
3065
|
+
let r = 0;
|
|
3050
3066
|
const i = async (a) => {
|
|
3051
|
-
if (
|
|
3052
|
-
const c = this.middleware[
|
|
3053
|
-
return
|
|
3067
|
+
if (r === this.middleware.length) return await t(a);
|
|
3068
|
+
const c = this.middleware[r];
|
|
3069
|
+
return r++, await c(a, i);
|
|
3054
3070
|
};
|
|
3055
3071
|
return await i(e);
|
|
3056
3072
|
}
|
|
3057
3073
|
}
|
|
3058
|
-
const
|
|
3074
|
+
const Ke = "Content-Type", Wn = /* @__PURE__ */ new Set([
|
|
3059
3075
|
"ECONNREFUSED",
|
|
3060
3076
|
"ECONNRESET",
|
|
3061
3077
|
"ETIMEDOUT",
|
|
3062
3078
|
"EPIPE",
|
|
3063
3079
|
"UND_ERR_CONNECT_TIMEOUT",
|
|
3064
3080
|
"UND_ERR_SOCKET"
|
|
3065
|
-
]),
|
|
3066
|
-
const e =
|
|
3067
|
-
if (typeof e == "string" &&
|
|
3068
|
-
if (
|
|
3069
|
-
const t = String(
|
|
3081
|
+
]), Zn = (n) => {
|
|
3082
|
+
const e = n?.cause?.code ?? n?.code ?? n?.errno;
|
|
3083
|
+
if (typeof e == "string" && Wn.has(e)) return !0;
|
|
3084
|
+
if (n.name === "TypeError") {
|
|
3085
|
+
const t = String(n.message || "").toLowerCase();
|
|
3070
3086
|
if (/load failed|failed to fetch|networkerror|network error/.test(t))
|
|
3071
3087
|
return typeof navigator < "u" && navigator.onLine === !1, !0;
|
|
3072
3088
|
}
|
|
3073
|
-
return
|
|
3074
|
-
},
|
|
3075
|
-
class
|
|
3089
|
+
return n?.name === "AbortError" || n?.code === "ABORT_ERR", !1;
|
|
3090
|
+
}, Vn = 400;
|
|
3091
|
+
class nr extends Xe {
|
|
3076
3092
|
endpoint;
|
|
3077
3093
|
encoder;
|
|
3078
|
-
constructor(e, t,
|
|
3079
|
-
return super(), this.endpoint = e.replace({ protocol:
|
|
3094
|
+
constructor(e, t, r = !1) {
|
|
3095
|
+
return super(), this.endpoint = e.replace({ protocol: r ? "https" : "http" }), this.encoder = t, new Proxy(this, {
|
|
3080
3096
|
get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
|
|
3081
3097
|
});
|
|
3082
3098
|
}
|
|
3083
3099
|
get headers() {
|
|
3084
3100
|
return {
|
|
3085
|
-
[
|
|
3101
|
+
[Ke]: this.encoder.contentType
|
|
3086
3102
|
};
|
|
3087
3103
|
}
|
|
3088
|
-
async send(e, t,
|
|
3089
|
-
t =
|
|
3104
|
+
async send(e, t, r, i) {
|
|
3105
|
+
t = r?.parse(t);
|
|
3090
3106
|
let a = null;
|
|
3091
|
-
const c = this.endpoint.child(e),
|
|
3092
|
-
|
|
3107
|
+
const c = this.endpoint.child(e), g = {};
|
|
3108
|
+
g.method = "POST", g.body = this.encoder.encode(t ?? {});
|
|
3093
3109
|
const [, y] = await this.executeMiddleware(
|
|
3094
3110
|
{
|
|
3095
3111
|
target: c.toString(),
|
|
@@ -3098,29 +3114,29 @@ class Qr extends Je {
|
|
|
3098
3114
|
role: "client"
|
|
3099
3115
|
},
|
|
3100
3116
|
async (f) => {
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3117
|
+
const m = { ...f, params: {} };
|
|
3118
|
+
g.headers = {
|
|
3103
3119
|
...this.headers,
|
|
3104
3120
|
...f.params
|
|
3105
3121
|
};
|
|
3106
3122
|
let b;
|
|
3107
3123
|
try {
|
|
3108
|
-
b = await fetch(f.target,
|
|
3124
|
+
b = await fetch(f.target, g);
|
|
3109
3125
|
} catch (T) {
|
|
3110
3126
|
if (!(T instanceof Error)) throw T;
|
|
3111
|
-
return [
|
|
3127
|
+
return [m, Zn(T) ? new q({ url: c }) : T];
|
|
3112
3128
|
}
|
|
3113
3129
|
const h = await b.arrayBuffer();
|
|
3114
3130
|
if (b?.ok)
|
|
3115
|
-
return i != null && (a = this.encoder.decode(h, i)), [
|
|
3131
|
+
return i != null && (a = this.encoder.decode(h, i)), [m, null];
|
|
3116
3132
|
try {
|
|
3117
|
-
if (b.status !==
|
|
3118
|
-
return [
|
|
3119
|
-
const T = this.encoder.decode(h,
|
|
3120
|
-
return [
|
|
3133
|
+
if (b.status !== Vn)
|
|
3134
|
+
return [m, new Error(b.statusText)];
|
|
3135
|
+
const T = this.encoder.decode(h, R.payloadZ), A = R.decode(T);
|
|
3136
|
+
return [m, A];
|
|
3121
3137
|
} catch (T) {
|
|
3122
3138
|
return [
|
|
3123
|
-
|
|
3139
|
+
m,
|
|
3124
3140
|
new Error(
|
|
3125
3141
|
`[freighter] - failed to decode error: ${b.statusText}: ${T.message}`
|
|
3126
3142
|
)
|
|
@@ -3133,7 +3149,7 @@ class Qr extends Je {
|
|
|
3133
3149
|
return [a, null];
|
|
3134
3150
|
}
|
|
3135
3151
|
}
|
|
3136
|
-
const
|
|
3152
|
+
const rr = (n, e) => {
|
|
3137
3153
|
class t {
|
|
3138
3154
|
wrapped;
|
|
3139
3155
|
constructor(i) {
|
|
@@ -3142,27 +3158,27 @@ const _r = (r, e) => {
|
|
|
3142
3158
|
use(...i) {
|
|
3143
3159
|
this.wrapped.use(...i);
|
|
3144
3160
|
}
|
|
3145
|
-
async send(i, a, c,
|
|
3146
|
-
const y = new
|
|
3161
|
+
async send(i, a, c, g) {
|
|
3162
|
+
const y = new dn.Breaker(e);
|
|
3147
3163
|
do {
|
|
3148
|
-
const [f,
|
|
3149
|
-
if (
|
|
3150
|
-
if (!
|
|
3151
|
-
if (console.warn(`[freighter] ${y.retryMessage}`,
|
|
3164
|
+
const [f, m] = await this.wrapped.send(i, a, c, g);
|
|
3165
|
+
if (m == null) return [f, null];
|
|
3166
|
+
if (!q.matches(m)) return [null, m];
|
|
3167
|
+
if (console.warn(`[freighter] ${y.retryMessage}`, m), !await y.wait()) return [f, m];
|
|
3152
3168
|
} while (!0);
|
|
3153
3169
|
}
|
|
3154
3170
|
}
|
|
3155
|
-
return new t(
|
|
3156
|
-
},
|
|
3157
|
-
const [a, c] = await
|
|
3171
|
+
return new t(n);
|
|
3172
|
+
}, sr = async (n, e, t, r, i) => {
|
|
3173
|
+
const [a, c] = await n.send(e, t, r, i);
|
|
3158
3174
|
if (c != null) throw c;
|
|
3159
3175
|
return a;
|
|
3160
|
-
},
|
|
3176
|
+
}, zn = s.object({
|
|
3161
3177
|
type: s.enum(["data", "close", "open"]),
|
|
3162
3178
|
payload: s.unknown(),
|
|
3163
|
-
error: s.optional(
|
|
3179
|
+
error: s.optional(R.payloadZ)
|
|
3164
3180
|
});
|
|
3165
|
-
class
|
|
3181
|
+
class Gn {
|
|
3166
3182
|
codec;
|
|
3167
3183
|
reqSchema;
|
|
3168
3184
|
resSchema;
|
|
@@ -3171,20 +3187,20 @@ class Zr {
|
|
|
3171
3187
|
sendClosed;
|
|
3172
3188
|
receiveDataQueue = [];
|
|
3173
3189
|
receiveCallbacksQueue = [];
|
|
3174
|
-
constructor(e, t,
|
|
3175
|
-
this.codec = t, this.reqSchema =
|
|
3190
|
+
constructor(e, t, r, i) {
|
|
3191
|
+
this.codec = t, this.reqSchema = r, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
|
|
3176
3192
|
}
|
|
3177
3193
|
async receiveOpenAck() {
|
|
3178
3194
|
const e = await this.receiveMsg();
|
|
3179
3195
|
if (e.type !== "open") {
|
|
3180
3196
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3181
|
-
return
|
|
3197
|
+
return R.decode(e.error);
|
|
3182
3198
|
}
|
|
3183
3199
|
return null;
|
|
3184
3200
|
}
|
|
3185
3201
|
/** Implements the Stream protocol */
|
|
3186
3202
|
send(e) {
|
|
3187
|
-
if (this.serverClosed != null) return new
|
|
3203
|
+
if (this.serverClosed != null) return new j();
|
|
3188
3204
|
if (this.sendClosed) throw new Y();
|
|
3189
3205
|
return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
|
|
3190
3206
|
}
|
|
@@ -3194,7 +3210,7 @@ class Zr {
|
|
|
3194
3210
|
const e = await this.receiveMsg();
|
|
3195
3211
|
if (e.type === "close") {
|
|
3196
3212
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3197
|
-
if (this.serverClosed =
|
|
3213
|
+
if (this.serverClosed = R.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
|
|
3198
3214
|
return [null, this.serverClosed];
|
|
3199
3215
|
}
|
|
3200
3216
|
return [this.resSchema.parse(e.payload), null];
|
|
@@ -3216,7 +3232,7 @@ class Zr {
|
|
|
3216
3232
|
async receiveMsg() {
|
|
3217
3233
|
const e = this.receiveDataQueue.shift();
|
|
3218
3234
|
return e ?? await new Promise(
|
|
3219
|
-
(t,
|
|
3235
|
+
(t, r) => this.receiveCallbacksQueue.push({ resolve: t, reject: r })
|
|
3220
3236
|
);
|
|
3221
3237
|
}
|
|
3222
3238
|
addMessage(e) {
|
|
@@ -3227,20 +3243,20 @@ class Zr {
|
|
|
3227
3243
|
this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
|
|
3228
3244
|
}
|
|
3229
3245
|
onMessage(e) {
|
|
3230
|
-
this.addMessage(this.codec.decode(e.data,
|
|
3246
|
+
this.addMessage(this.codec.decode(e.data, zn));
|
|
3231
3247
|
}
|
|
3232
3248
|
onClose(e) {
|
|
3233
3249
|
this.addMessage({
|
|
3234
3250
|
type: "close",
|
|
3235
3251
|
error: {
|
|
3236
|
-
type: e.code ===
|
|
3252
|
+
type: e.code === Jn ? j.TYPE : Y.TYPE,
|
|
3237
3253
|
data: ""
|
|
3238
3254
|
}
|
|
3239
3255
|
});
|
|
3240
3256
|
}
|
|
3241
3257
|
}
|
|
3242
|
-
const
|
|
3243
|
-
class
|
|
3258
|
+
const Hn = "freighterctx", Jn = 1e3;
|
|
3259
|
+
class fe extends Xe {
|
|
3244
3260
|
baseUrl;
|
|
3245
3261
|
encoder;
|
|
3246
3262
|
secure;
|
|
@@ -3250,22 +3266,22 @@ class he extends Je {
|
|
|
3250
3266
|
* responses.
|
|
3251
3267
|
* @param baseEndpoint - A base url to use as a prefix for all requests.
|
|
3252
3268
|
*/
|
|
3253
|
-
constructor(e, t,
|
|
3254
|
-
super(), this.secure =
|
|
3269
|
+
constructor(e, t, r = !1) {
|
|
3270
|
+
super(), this.secure = r, this.baseUrl = e.replace({ protocol: r ? "wss" : "ws" }), this.encoder = t;
|
|
3255
3271
|
}
|
|
3256
3272
|
withCodec(e) {
|
|
3257
|
-
const t = new
|
|
3273
|
+
const t = new fe(this.baseUrl, e, this.secure);
|
|
3258
3274
|
return t.use(...this.middleware), t;
|
|
3259
3275
|
}
|
|
3260
3276
|
/** Implements the StreamClient interface. */
|
|
3261
|
-
async stream(e, t,
|
|
3277
|
+
async stream(e, t, r) {
|
|
3262
3278
|
let i;
|
|
3263
3279
|
const [, a] = await this.executeMiddleware(
|
|
3264
3280
|
{ target: e, protocol: "websocket", params: {}, role: "client" },
|
|
3265
3281
|
async (c) => {
|
|
3266
|
-
const
|
|
3267
|
-
|
|
3268
|
-
const f = await this.wrapSocket(
|
|
3282
|
+
const g = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
|
|
3283
|
+
g.binaryType = fe.MESSAGE_TYPE;
|
|
3284
|
+
const f = await this.wrapSocket(g, t, r);
|
|
3269
3285
|
return f instanceof Error ? [y, f] : (i = f, [y, null]);
|
|
3270
3286
|
}
|
|
3271
3287
|
);
|
|
@@ -3273,19 +3289,19 @@ class he extends Je {
|
|
|
3273
3289
|
return i;
|
|
3274
3290
|
}
|
|
3275
3291
|
buildURL(e, t) {
|
|
3276
|
-
const
|
|
3292
|
+
const r = ln(
|
|
3277
3293
|
{
|
|
3278
|
-
[
|
|
3294
|
+
[Ke]: this.encoder.contentType,
|
|
3279
3295
|
...t.params
|
|
3280
3296
|
},
|
|
3281
|
-
|
|
3297
|
+
Hn
|
|
3282
3298
|
);
|
|
3283
|
-
return this.baseUrl.child(e).toString() +
|
|
3299
|
+
return this.baseUrl.child(e).toString() + r;
|
|
3284
3300
|
}
|
|
3285
|
-
async wrapSocket(e, t,
|
|
3301
|
+
async wrapSocket(e, t, r) {
|
|
3286
3302
|
return await new Promise((i) => {
|
|
3287
3303
|
e.onopen = () => {
|
|
3288
|
-
const a = new
|
|
3304
|
+
const a = new Gn(e, this.encoder, t, r);
|
|
3289
3305
|
a.receiveOpenAck().then((c) => {
|
|
3290
3306
|
c != null ? i(c) : i(a);
|
|
3291
3307
|
}).catch((c) => i(c));
|
|
@@ -3297,11 +3313,11 @@ class he extends Je {
|
|
|
3297
3313
|
}
|
|
3298
3314
|
}
|
|
3299
3315
|
export {
|
|
3300
|
-
|
|
3301
|
-
|
|
3316
|
+
j as EOF,
|
|
3317
|
+
nr as HTTPClient,
|
|
3302
3318
|
Y as StreamClosed,
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3319
|
+
q as Unreachable,
|
|
3320
|
+
fe as WebSocketClient,
|
|
3321
|
+
sr as sendRequired,
|
|
3322
|
+
rr as unaryWithBreaker
|
|
3307
3323
|
};
|