@synnaxlabs/freighter 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/dist/freighter.cjs +4 -4
- package/dist/freighter.js +689 -695
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/websocket.d.ts.map +1 -1
- package/eslint.config.ts +1 -1
- package/package.json +10 -10
- package/src/alamos.ts +1 -1
- package/src/errors.spec.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/http.spec.ts +1 -1
- package/src/http.ts +1 -1
- package/src/index.ts +1 -1
- package/src/middleware.ts +1 -1
- package/src/stream.ts +2 -3
- package/src/transport.ts +1 -1
- package/src/unary.ts +1 -1
- package/src/websocket.spec.ts +1 -1
- package/src/websocket.ts +5 -4
- package/vite.config.ts +1 -1
package/dist/freighter.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import b, { z as s } from "zod";
|
|
2
|
+
const Xe = (r) => {
|
|
3
3
|
const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
4
4
|
return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
|
|
5
|
-
},
|
|
6
|
-
const e = (t, n =
|
|
5
|
+
}, Ne = (r) => {
|
|
6
|
+
const e = (t, n = se) => {
|
|
7
7
|
if (typeof t == "string") return r(t);
|
|
8
8
|
if (Array.isArray(t)) return t.map((c) => e(c, n));
|
|
9
|
-
if (!
|
|
10
|
-
n =
|
|
11
|
-
const i = {},
|
|
12
|
-
return "toJSON" in
|
|
13
|
-
let d =
|
|
9
|
+
if (!te(t)) return t;
|
|
10
|
+
n = tt(n);
|
|
11
|
+
const i = {}, o = t;
|
|
12
|
+
return "toJSON" in o && typeof o.toJSON == "function" ? e(o.toJSON(), n) : (Object.keys(o).forEach((c) => {
|
|
13
|
+
let d = o[c];
|
|
14
14
|
const w = r(c);
|
|
15
|
-
n.recursive && (
|
|
15
|
+
n.recursive && (te(d) ? pe(d) || (d = e(d, n)) : n.recursiveInArray && ye(d) && (d = [...d].map((h) => {
|
|
16
16
|
let g = h;
|
|
17
|
-
return
|
|
17
|
+
return te(h) ? pe(g) || (g = e(h, n)) : ye(h) && (g = e({ key: h }, n).key), g;
|
|
18
18
|
}))), i[w] = d;
|
|
19
19
|
}), i);
|
|
20
20
|
};
|
|
21
21
|
return e;
|
|
22
|
-
},
|
|
22
|
+
}, Ee = Ne(Xe), Qe = (r) => (
|
|
23
23
|
// Don't convert the first character and don't convert a character that is after a
|
|
24
24
|
// non-alphanumeric character
|
|
25
25
|
r.replace(
|
|
26
26
|
/([a-z0-9])([A-Z])/g,
|
|
27
27
|
(e, t, n) => `${t}_${n.toLowerCase()}`
|
|
28
28
|
)
|
|
29
|
-
),
|
|
29
|
+
), _e = Ne(Qe), et = [Number, String, Uint8Array], se = {
|
|
30
30
|
recursive: !0,
|
|
31
31
|
recursiveInArray: !0
|
|
32
|
-
},
|
|
33
|
-
|
|
32
|
+
}, tt = (r = se) => (r.recursive == null ? r = se : r.recursiveInArray ??= !1, r), ye = (r) => r != null && Array.isArray(r), te = (r) => r != null && typeof r == "object" && !Array.isArray(r), pe = (r) => et.some((e) => r instanceof e);
|
|
33
|
+
class rt {
|
|
34
34
|
contentType = "application/json";
|
|
35
35
|
decoder;
|
|
36
36
|
encoder;
|
|
@@ -44,16 +44,16 @@ let st = class {
|
|
|
44
44
|
return this.decodeString(this.decoder.decode(e), t);
|
|
45
45
|
}
|
|
46
46
|
decodeString(e, t) {
|
|
47
|
-
const n = JSON.parse(e), i =
|
|
47
|
+
const n = JSON.parse(e), i = Ee(n);
|
|
48
48
|
return t != null ? t.parse(i) : i;
|
|
49
49
|
}
|
|
50
50
|
encodeString(e) {
|
|
51
|
-
const t =
|
|
51
|
+
const t = _e(e);
|
|
52
52
|
return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
|
|
53
53
|
}
|
|
54
|
-
}
|
|
55
|
-
const
|
|
56
|
-
|
|
54
|
+
}
|
|
55
|
+
const ie = new rt(), A = (r) => r != null && typeof r == "object" && "value" in r;
|
|
56
|
+
class Z {
|
|
57
57
|
/** The underlying primitive value */
|
|
58
58
|
value;
|
|
59
59
|
constructor(e) {
|
|
@@ -72,25 +72,25 @@ let W = class {
|
|
|
72
72
|
toString() {
|
|
73
73
|
return this.value.toString();
|
|
74
74
|
}
|
|
75
|
-
}
|
|
76
|
-
const
|
|
77
|
-
const t =
|
|
75
|
+
}
|
|
76
|
+
const nt = (r) => r != null && typeof r == "object" && "toString" in r, st = (r, e = !1) => {
|
|
77
|
+
const t = nt(r) ? "stringer" : typeof r;
|
|
78
78
|
let n;
|
|
79
79
|
switch (t) {
|
|
80
80
|
case "string":
|
|
81
|
-
n = (i,
|
|
81
|
+
n = (i, o) => i.localeCompare(o);
|
|
82
82
|
break;
|
|
83
83
|
case "stringer":
|
|
84
|
-
n = (i,
|
|
84
|
+
n = (i, o) => i.toString().localeCompare(o.toString());
|
|
85
85
|
break;
|
|
86
86
|
case "number":
|
|
87
|
-
n = (i,
|
|
87
|
+
n = (i, o) => Number(i) - Number(o);
|
|
88
88
|
break;
|
|
89
89
|
case "bigint":
|
|
90
|
-
n = (i,
|
|
90
|
+
n = (i, o) => BigInt(i) - BigInt(o) > 0n ? 1 : -1;
|
|
91
91
|
break;
|
|
92
92
|
case "boolean":
|
|
93
|
-
n = (i,
|
|
93
|
+
n = (i, o) => Number(i) - Number(o);
|
|
94
94
|
break;
|
|
95
95
|
case "undefined":
|
|
96
96
|
n = () => 0;
|
|
@@ -98,38 +98,35 @@ const it = (r) => r != null && typeof r == "object" && "toString" in r, at = (r,
|
|
|
98
98
|
default:
|
|
99
99
|
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
100
100
|
}
|
|
101
|
-
return e ?
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
s.enum(ht);
|
|
111
|
-
const Q = s.object({ x: s.number(), y: s.number() }), ft = s.object({ clientX: s.number(), clientY: s.number() }), dt = ["x", "y"], $e = s.enum(dt), Ce = ["top", "right", "bottom", "left"];
|
|
112
|
-
s.enum(Ce);
|
|
113
|
-
const gt = ["left", "right"], Be = s.enum(gt), pt = ["top", "bottom"], Re = s.enum(pt), De = ["center"], Oe = s.enum(De), mt = [...Ce, ...De], Le = s.enum(mt);
|
|
114
|
-
s.enum(ct);
|
|
115
|
-
const yt = ["first", "last"];
|
|
116
|
-
s.enum(yt);
|
|
117
|
-
const wt = s.object({ lower: s.number(), upper: s.number() }), bt = s.object({ lower: s.bigint(), upper: s.bigint() });
|
|
118
|
-
s.union([wt, _]);
|
|
119
|
-
s.union([bt, _]);
|
|
120
|
-
s.enum([...$e.options, ...Le.options]);
|
|
121
|
-
s.enum(["x", "left", "right"]);
|
|
122
|
-
s.enum(["y", "top", "bottom"]);
|
|
123
|
-
s.union([$e, Le, s.instanceof(String)]);
|
|
124
|
-
const ee = (r) => (e, t) => {
|
|
101
|
+
return e ? it(n) : n;
|
|
102
|
+
}, it = (r) => (e, t) => r(t, e);
|
|
103
|
+
let Ae = (r, e = 21) => (t = e) => {
|
|
104
|
+
let n = "", i = t | 0;
|
|
105
|
+
for (; i--; )
|
|
106
|
+
n += r[Math.random() * r.length | 0];
|
|
107
|
+
return n;
|
|
108
|
+
};
|
|
109
|
+
const xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", at = `0123456789${xe}`, ot = 11, ut = Ae(xe, 1), lt = Ae(at, ot - 1), ct = () => `${ut()}${lt()}`, ht = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, ft = 2 ** 12 - 1, ae = 2n ** 63n - 1n, dt = 2 ** 63 - 1, _ = (r) => (e, t) => {
|
|
125
110
|
if (typeof e == "bigint") {
|
|
126
|
-
if (
|
|
111
|
+
if (gt(t))
|
|
127
112
|
return r(e, BigInt(t));
|
|
128
113
|
const n = r(Number(e), Number(t));
|
|
129
114
|
return typeof n == "number" ? BigInt(Math.round(n)) : n;
|
|
130
115
|
}
|
|
131
116
|
return r(Number(e), Number(t));
|
|
132
|
-
},
|
|
117
|
+
}, V = _((r, e) => r - e), $ = _((r, e) => r + e), gt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), M = _((r, e) => r * e), ee = _((r, e) => r / e), Ue = s.tuple([s.number(), s.number()]), Me = s.object({ width: s.number(), height: s.number() }), mt = s.object({
|
|
118
|
+
signedWidth: s.number(),
|
|
119
|
+
signedHeight: s.number()
|
|
120
|
+
}), yt = ["start", "center", "end"], G = s.object({ x: s.number(), y: s.number() }), pt = s.object({ clientX: s.number(), clientY: s.number() }), wt = ["x", "y"], Ce = s.enum(wt), Be = ["top", "right", "bottom", "left"];
|
|
121
|
+
s.enum(Be);
|
|
122
|
+
const bt = ["left", "right"], Re = s.enum(bt), Ot = ["top", "bottom"], De = s.enum(Ot), Le = ["center"], we = s.enum(Le), Tt = [...Be, ...Le], $e = s.enum(Tt);
|
|
123
|
+
s.enum(yt);
|
|
124
|
+
const vt = ["first", "last"];
|
|
125
|
+
s.enum(vt);
|
|
126
|
+
s.object({ lower: s.number(), upper: s.number() });
|
|
127
|
+
s.enum([...Ce.options, ...$e.options]);
|
|
128
|
+
s.union([Ce, $e, s.instanceof(String)]);
|
|
129
|
+
const k = (r, e, t) => {
|
|
133
130
|
const n = {};
|
|
134
131
|
if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
|
|
135
132
|
e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
|
|
@@ -138,34 +135,34 @@ const ee = (r) => (e, t) => {
|
|
|
138
135
|
[n.lower, n.upper] = r;
|
|
139
136
|
} else
|
|
140
137
|
n.lower = r.lower, n.upper = r.upper;
|
|
141
|
-
return t?.makeValid ?
|
|
142
|
-
},
|
|
143
|
-
const t =
|
|
138
|
+
return t?.makeValid ? St(n) : n;
|
|
139
|
+
}, St = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, be = (r, e) => {
|
|
140
|
+
const t = k(r);
|
|
144
141
|
return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
|
|
145
142
|
};
|
|
146
143
|
s.object({
|
|
147
|
-
x:
|
|
148
|
-
y:
|
|
144
|
+
x: Re.or(we),
|
|
145
|
+
y: De.or(we)
|
|
149
146
|
});
|
|
150
|
-
const
|
|
147
|
+
const ke = s.object({ x: Re, y: De }), It = Object.freeze({ x: "left", y: "top" }), Nt = (r, e) => r.x === e.x && r.y === e.y, Oe = s.union([
|
|
151
148
|
s.number(),
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
G,
|
|
150
|
+
Ue,
|
|
154
151
|
Me,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
]),
|
|
152
|
+
mt,
|
|
153
|
+
pt
|
|
154
|
+
]), Et = (r, e) => {
|
|
158
155
|
if (typeof r == "string") {
|
|
159
156
|
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
160
157
|
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
161
158
|
}
|
|
162
159
|
return typeof r == "number" ? { x: r, y: e ?? r } : Array.isArray(r) ? { x: r[0], y: r[1] } : "signedWidth" in r ? { x: r.signedWidth, y: r.signedHeight } : "clientX" in r ? { x: r.clientX, y: r.clientY } : "width" in r ? { x: r.width, y: r.height } : { x: r.x, y: r.y };
|
|
163
|
-
},
|
|
160
|
+
}, Te = Object.freeze({ x: 0, y: 0 }), K = s.union([s.number(), s.string()]);
|
|
164
161
|
s.object({
|
|
165
|
-
top:
|
|
166
|
-
left:
|
|
167
|
-
width:
|
|
168
|
-
height:
|
|
162
|
+
top: K,
|
|
163
|
+
left: K,
|
|
164
|
+
width: K,
|
|
165
|
+
height: K
|
|
169
166
|
});
|
|
170
167
|
s.object({
|
|
171
168
|
left: s.number(),
|
|
@@ -174,61 +171,61 @@ s.object({
|
|
|
174
171
|
bottom: s.number()
|
|
175
172
|
});
|
|
176
173
|
s.object({
|
|
177
|
-
one:
|
|
178
|
-
two:
|
|
179
|
-
root:
|
|
174
|
+
one: G,
|
|
175
|
+
two: G,
|
|
176
|
+
root: ke
|
|
180
177
|
});
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
one: { ...
|
|
184
|
-
two: { ...
|
|
178
|
+
const he = (r, e, t = 0, n = 0, i) => {
|
|
179
|
+
const o = {
|
|
180
|
+
one: { ...Te },
|
|
181
|
+
two: { ...Te },
|
|
185
182
|
root: i ?? It
|
|
186
183
|
};
|
|
187
184
|
if (typeof r == "number") {
|
|
188
185
|
if (typeof e != "number")
|
|
189
186
|
throw new Error("Box constructor called with invalid arguments");
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (
|
|
193
|
-
x:
|
|
194
|
-
y:
|
|
195
|
-
} : "signedWidth" in e ?
|
|
196
|
-
x:
|
|
197
|
-
y:
|
|
198
|
-
} :
|
|
199
|
-
},
|
|
200
|
-
const e =
|
|
187
|
+
return o.one = { x: r, y: e }, o.two = { x: o.one.x + t, y: o.one.y + n }, o;
|
|
188
|
+
}
|
|
189
|
+
return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (o.one = { x: r.left, y: r.top }, o.two = { x: r.right, y: r.bottom }, o) : (o.one = r, e == null ? o.two = { x: o.one.x + t, y: o.one.y + n } : typeof e == "number" ? o.two = { x: o.one.x + e, y: o.one.y + t } : "width" in e ? o.two = {
|
|
190
|
+
x: o.one.x + e.width,
|
|
191
|
+
y: o.one.y + e.height
|
|
192
|
+
} : "signedWidth" in e ? o.two = {
|
|
193
|
+
x: o.one.x + e.signedWidth,
|
|
194
|
+
y: o.one.y + e.signedHeight
|
|
195
|
+
} : o.two = e, o));
|
|
196
|
+
}, re = (r) => {
|
|
197
|
+
const e = he(r);
|
|
201
198
|
return { lower: e.one.x, upper: e.two.x };
|
|
202
|
-
},
|
|
203
|
-
const e =
|
|
199
|
+
}, ne = (r) => {
|
|
200
|
+
const e = he(r);
|
|
204
201
|
return { lower: e.one.y, upper: e.two.y };
|
|
205
|
-
},
|
|
206
|
-
s.union([Me, xt,
|
|
207
|
-
const
|
|
208
|
-
s.object({ offset:
|
|
202
|
+
}, At = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, xt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
|
|
203
|
+
s.union([Me, xt, G, Ue]);
|
|
204
|
+
const Ut = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
205
|
+
s.object({ offset: Oe, scale: Oe });
|
|
209
206
|
s.object({ offset: s.number(), scale: s.number() });
|
|
210
|
-
const
|
|
207
|
+
const Mt = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
|
|
211
208
|
e,
|
|
212
209
|
i ? n - r : n + r
|
|
213
|
-
],
|
|
210
|
+
], Ct = (r) => (e, t, n, i) => [
|
|
214
211
|
e,
|
|
215
212
|
i ? n / r : n * r
|
|
216
|
-
],
|
|
213
|
+
], Bt = (r) => (e, t, n) => {
|
|
217
214
|
if (e === null) return [r, n];
|
|
218
|
-
const { lower: i, upper:
|
|
215
|
+
const { lower: i, upper: o } = e, { lower: c, upper: d } = r, w = o - i, h = d - c;
|
|
219
216
|
if (t === "dimension") return [r, n * (h / w)];
|
|
220
217
|
const g = (n - i) * (h / w) + c;
|
|
221
218
|
return [r, g];
|
|
222
|
-
},
|
|
219
|
+
}, Rt = (r) => (e, t, n) => [r, n], Dt = () => (r, e, t) => {
|
|
223
220
|
if (r === null) throw new Error("cannot invert without bounds");
|
|
224
221
|
if (e === "dimension") return [r, t];
|
|
225
222
|
const { lower: n, upper: i } = r;
|
|
226
223
|
return [r, i - (t - n)];
|
|
227
|
-
},
|
|
228
|
-
const { lower: i, upper:
|
|
229
|
-
return n =
|
|
224
|
+
}, Lt = (r) => (e, t, n) => {
|
|
225
|
+
const { lower: i, upper: o } = r;
|
|
226
|
+
return n = Ut(n, i, o), [e, n];
|
|
230
227
|
};
|
|
231
|
-
|
|
228
|
+
class R {
|
|
232
229
|
ops = [];
|
|
233
230
|
currBounds = null;
|
|
234
231
|
currType = null;
|
|
@@ -242,7 +239,7 @@ let Se = class P {
|
|
|
242
239
|
* @param value - The amount to translate by.
|
|
243
240
|
*/
|
|
244
241
|
static translate(e) {
|
|
245
|
-
return new
|
|
242
|
+
return new R().translate(e);
|
|
246
243
|
}
|
|
247
244
|
/**
|
|
248
245
|
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
@@ -250,10 +247,10 @@ let Se = class P {
|
|
|
250
247
|
* @param value - The amount to translate by.
|
|
251
248
|
*/
|
|
252
249
|
static magnify(e) {
|
|
253
|
-
return new
|
|
250
|
+
return new R().magnify(e);
|
|
254
251
|
}
|
|
255
252
|
static scale(e, t) {
|
|
256
|
-
return new
|
|
253
|
+
return new R().scale(e, t);
|
|
257
254
|
}
|
|
258
255
|
/**
|
|
259
256
|
* @returns a copy of the scale with a translation as its next operation. Any
|
|
@@ -262,7 +259,7 @@ let Se = class P {
|
|
|
262
259
|
* @param value - The amount to translate by.
|
|
263
260
|
*/
|
|
264
261
|
translate(e) {
|
|
265
|
-
const t = this.new(), n =
|
|
262
|
+
const t = this.new(), n = Mt(e);
|
|
266
263
|
return n.type = "translate", t.ops.push(n), t;
|
|
267
264
|
}
|
|
268
265
|
/**
|
|
@@ -272,23 +269,23 @@ let Se = class P {
|
|
|
272
269
|
* @param value - The amount to magnify by.
|
|
273
270
|
*/
|
|
274
271
|
magnify(e) {
|
|
275
|
-
const t = this.new(), n =
|
|
272
|
+
const t = this.new(), n = Ct(e);
|
|
276
273
|
return n.type = "magnify", t.ops.push(n), t;
|
|
277
274
|
}
|
|
278
275
|
scale(e, t) {
|
|
279
|
-
const n =
|
|
280
|
-
return
|
|
276
|
+
const n = k(e, t), i = this.new(), o = Bt(n);
|
|
277
|
+
return o.type = "scale", i.ops.push(o), i;
|
|
281
278
|
}
|
|
282
279
|
clamp(e, t) {
|
|
283
|
-
const n =
|
|
284
|
-
return
|
|
280
|
+
const n = k(e, t), i = this.new(), o = Lt(n);
|
|
281
|
+
return o.type = "clamp", i.ops.push(o), i;
|
|
285
282
|
}
|
|
286
283
|
reBound(e, t) {
|
|
287
|
-
const n =
|
|
288
|
-
return
|
|
284
|
+
const n = k(e, t), i = this.new(), o = Rt(n);
|
|
285
|
+
return o.type = "re-bound", i.ops.push(o), i;
|
|
289
286
|
}
|
|
290
287
|
invert() {
|
|
291
|
-
const e =
|
|
288
|
+
const e = Dt();
|
|
292
289
|
e.type = "invert";
|
|
293
290
|
const t = this.new();
|
|
294
291
|
return t.ops.push(e), t;
|
|
@@ -300,12 +297,12 @@ let Se = class P {
|
|
|
300
297
|
return this.exec("dimension", e);
|
|
301
298
|
}
|
|
302
299
|
new() {
|
|
303
|
-
const e = new
|
|
300
|
+
const e = new R();
|
|
304
301
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
305
302
|
}
|
|
306
303
|
exec(e, t) {
|
|
307
304
|
return this.currBounds = null, this.ops.reduce(
|
|
308
|
-
([n, i],
|
|
305
|
+
([n, i], o) => o(n, e, i, this.reversed),
|
|
309
306
|
[null, t]
|
|
310
307
|
)[1];
|
|
311
308
|
}
|
|
@@ -316,47 +313,48 @@ let Se = class P {
|
|
|
316
313
|
return e.ops.forEach((n, i) => {
|
|
317
314
|
if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
|
|
318
315
|
return;
|
|
319
|
-
const
|
|
320
|
-
|
|
316
|
+
const o = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
|
|
317
|
+
o !== -1 && t.push([i, o]);
|
|
321
318
|
}), t.forEach(([n, i]) => {
|
|
322
|
-
const
|
|
323
|
-
|
|
319
|
+
const o = e.ops.slice(n, i);
|
|
320
|
+
o.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...o);
|
|
324
321
|
}), e.reversed = !e.reversed, e;
|
|
325
322
|
}
|
|
326
323
|
get transform() {
|
|
327
324
|
return { scale: this.dim(1), offset: this.pos(0) };
|
|
328
325
|
}
|
|
329
|
-
static IDENTITY = new
|
|
330
|
-
}
|
|
326
|
+
static IDENTITY = new R();
|
|
327
|
+
}
|
|
328
|
+
class U {
|
|
331
329
|
x;
|
|
332
330
|
y;
|
|
333
331
|
currRoot;
|
|
334
|
-
constructor(e = new
|
|
332
|
+
constructor(e = new R(), t = new R(), n = null) {
|
|
335
333
|
this.x = e, this.y = t, this.currRoot = n;
|
|
336
334
|
}
|
|
337
335
|
static translate(e, t) {
|
|
338
|
-
return new
|
|
336
|
+
return new U().translate(e, t);
|
|
339
337
|
}
|
|
340
338
|
static translateX(e) {
|
|
341
|
-
return new
|
|
339
|
+
return new U().translateX(e);
|
|
342
340
|
}
|
|
343
341
|
static translateY(e) {
|
|
344
|
-
return new
|
|
342
|
+
return new U().translateY(e);
|
|
345
343
|
}
|
|
346
344
|
static clamp(e) {
|
|
347
|
-
return new
|
|
345
|
+
return new U().clamp(e);
|
|
348
346
|
}
|
|
349
347
|
static magnify(e) {
|
|
350
|
-
return new
|
|
348
|
+
return new U().magnify(e);
|
|
351
349
|
}
|
|
352
350
|
static scale(e) {
|
|
353
|
-
return new
|
|
351
|
+
return new U().scale(e);
|
|
354
352
|
}
|
|
355
353
|
static reBound(e) {
|
|
356
|
-
return new
|
|
354
|
+
return new U().reBound(e);
|
|
357
355
|
}
|
|
358
356
|
translate(e, t) {
|
|
359
|
-
const n =
|
|
357
|
+
const n = Et(e, t), i = this.copy();
|
|
360
358
|
return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
|
|
361
359
|
}
|
|
362
360
|
translateX(e) {
|
|
@@ -373,22 +371,22 @@ let Se = class P {
|
|
|
373
371
|
}
|
|
374
372
|
scale(e) {
|
|
375
373
|
const t = this.copy();
|
|
376
|
-
if (
|
|
374
|
+
if (At(e)) {
|
|
377
375
|
const n = this.currRoot;
|
|
378
|
-
return t.currRoot = e.root, n != null && !
|
|
376
|
+
return t.currRoot = e.root, n != null && !Nt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(re(e)), t.y = t.y.scale(ne(e)), t;
|
|
379
377
|
}
|
|
380
378
|
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
381
379
|
}
|
|
382
380
|
reBound(e) {
|
|
383
381
|
const t = this.copy();
|
|
384
|
-
return t.x = this.x.reBound(
|
|
382
|
+
return t.x = this.x.reBound(re(e)), t.y = this.y.reBound(ne(e)), t;
|
|
385
383
|
}
|
|
386
384
|
clamp(e) {
|
|
387
385
|
const t = this.copy();
|
|
388
|
-
return t.x = this.x.clamp(
|
|
386
|
+
return t.x = this.x.clamp(re(e)), t.y = this.y.clamp(ne(e)), t;
|
|
389
387
|
}
|
|
390
388
|
copy() {
|
|
391
|
-
const e = new
|
|
389
|
+
const e = new U();
|
|
392
390
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
393
391
|
}
|
|
394
392
|
reverse() {
|
|
@@ -402,7 +400,7 @@ let Se = class P {
|
|
|
402
400
|
return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
|
|
403
401
|
}
|
|
404
402
|
box(e) {
|
|
405
|
-
return
|
|
403
|
+
return he(
|
|
406
404
|
this.pos(e.one),
|
|
407
405
|
this.pos(e.two),
|
|
408
406
|
0,
|
|
@@ -416,18 +414,21 @@ let Se = class P {
|
|
|
416
414
|
offset: this.pos({ x: 0, y: 0 })
|
|
417
415
|
};
|
|
418
416
|
}
|
|
419
|
-
static IDENTITY = new
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
417
|
+
static IDENTITY = new U();
|
|
418
|
+
}
|
|
419
|
+
const $t = G.extend({
|
|
420
|
+
root: ke,
|
|
421
|
+
units: b.object({
|
|
422
|
+
x: b.enum(["px", "decimal"]),
|
|
423
|
+
y: b.enum(["px", "decimal"])
|
|
424
|
+
})
|
|
425
|
+
});
|
|
426
|
+
$t.partial({ root: !0, units: !0 });
|
|
427
|
+
const kt = s.enum(["static", "dynamic"]), ve = 365, X = 30, Pt = s.union([
|
|
427
428
|
s.tuple([s.int()]),
|
|
428
429
|
s.tuple([s.int(), s.int().min(1).max(12)]),
|
|
429
430
|
s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
|
|
430
|
-
]),
|
|
431
|
+
]), Pe = (r, e) => {
|
|
431
432
|
const t = new u(e);
|
|
432
433
|
if (![
|
|
433
434
|
l.DAY,
|
|
@@ -444,7 +445,7 @@ const ke = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Dt = `0123456
|
|
|
444
445
|
const n = r.valueOf() % t.valueOf();
|
|
445
446
|
return r instanceof u ? new u(n) : new l(n);
|
|
446
447
|
};
|
|
447
|
-
class u extends
|
|
448
|
+
class u extends Z {
|
|
448
449
|
constructor(e, t = "UTC") {
|
|
449
450
|
if (e == null) super(u.now().valueOf());
|
|
450
451
|
else if (e instanceof Date)
|
|
@@ -454,7 +455,7 @@ class u extends W {
|
|
|
454
455
|
else if (Array.isArray(e)) super(u.parseDate(e));
|
|
455
456
|
else {
|
|
456
457
|
let n = 0n;
|
|
457
|
-
e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e ===
|
|
458
|
+
e instanceof Number && (e = e.valueOf()), t === "local" && (n = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === dt ? e = ae : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), A(e) && (e = e.value), super(BigInt(e.valueOf()) + n);
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
461
|
static parseDate([e = 1970, t = 1, n = 1]) {
|
|
@@ -469,9 +470,9 @@ class u extends W {
|
|
|
469
470
|
return this.value;
|
|
470
471
|
}
|
|
471
472
|
static parseTimeString(e, t = "UTC") {
|
|
472
|
-
const [n, i,
|
|
473
|
+
const [n, i, o] = e.split(":");
|
|
473
474
|
let c = "00", d = "00";
|
|
474
|
-
|
|
475
|
+
o != null && ([c, d] = o.split("."));
|
|
475
476
|
let w = u.hours(parseInt(n ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(d ?? "00")));
|
|
476
477
|
return t === "local" && (w = w.add(u.utcOffset)), w.valueOf();
|
|
477
478
|
}
|
|
@@ -479,14 +480,14 @@ class u extends W {
|
|
|
479
480
|
if (!e.includes("/") && !e.includes("-"))
|
|
480
481
|
return u.parseTimeString(e, t);
|
|
481
482
|
if (e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/) != null) {
|
|
482
|
-
let i = e,
|
|
483
|
+
let i = e, o = 0;
|
|
483
484
|
if (e.includes(".")) {
|
|
484
485
|
const h = e.split(".");
|
|
485
486
|
i = h[0];
|
|
486
487
|
const g = h[1] || "0";
|
|
487
|
-
|
|
488
|
+
o = parseInt(g.padEnd(3, "0").slice(0, 3));
|
|
488
489
|
}
|
|
489
|
-
const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), d = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(
|
|
490
|
+
const c = t === "local" ? new Date(i.replace("T", " ")) : /* @__PURE__ */ new Date(`${i}Z`), d = BigInt(c.getTime()) * u.MILLISECOND.valueOf(), w = BigInt(o) * u.MILLISECOND.valueOf();
|
|
490
491
|
return d + w;
|
|
491
492
|
}
|
|
492
493
|
const n = new Date(e);
|
|
@@ -551,7 +552,7 @@ class u extends W {
|
|
|
551
552
|
* valid, regardless of the TimeStamp order.
|
|
552
553
|
*/
|
|
553
554
|
range(e) {
|
|
554
|
-
return new
|
|
555
|
+
return new I(this, e).makeValid();
|
|
555
556
|
}
|
|
556
557
|
/**
|
|
557
558
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -620,7 +621,7 @@ class u extends W {
|
|
|
620
621
|
* TimeSpan.
|
|
621
622
|
*/
|
|
622
623
|
add(e) {
|
|
623
|
-
return new u(
|
|
624
|
+
return new u($(this.valueOf(), new l(e).valueOf()));
|
|
624
625
|
}
|
|
625
626
|
/**
|
|
626
627
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -630,7 +631,7 @@ class u extends W {
|
|
|
630
631
|
* TimeSpan.
|
|
631
632
|
*/
|
|
632
633
|
sub(e) {
|
|
633
|
-
return new u(
|
|
634
|
+
return new u(V(this.valueOf(), new l(e).valueOf()));
|
|
634
635
|
}
|
|
635
636
|
/**
|
|
636
637
|
* @returns the floating point number of hours since the unix epoch to the timestamp
|
|
@@ -821,7 +822,7 @@ class u extends W {
|
|
|
821
822
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
822
823
|
*/
|
|
823
824
|
remainder(e) {
|
|
824
|
-
return
|
|
825
|
+
return Pe(this, e);
|
|
825
826
|
}
|
|
826
827
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
827
828
|
get isToday() {
|
|
@@ -936,7 +937,7 @@ class u extends W {
|
|
|
936
937
|
/** One day after the unix epoch */
|
|
937
938
|
static DAY = u.days(1);
|
|
938
939
|
/** The maximum possible value for a timestamp */
|
|
939
|
-
static MAX = new u(
|
|
940
|
+
static MAX = new u(ae);
|
|
940
941
|
/** The minimum possible value for a timestamp */
|
|
941
942
|
static MIN = new u(0);
|
|
942
943
|
/** The unix epoch */
|
|
@@ -950,7 +951,7 @@ class u extends W {
|
|
|
950
951
|
s.bigint().transform((e) => new u(e)),
|
|
951
952
|
s.date().transform((e) => new u(e)),
|
|
952
953
|
s.custom((e) => e instanceof l).transform((e) => new u(e)),
|
|
953
|
-
|
|
954
|
+
Pt.transform((e) => new u(e))
|
|
954
955
|
]);
|
|
955
956
|
/**
|
|
956
957
|
* Sorts two timestamps.
|
|
@@ -964,7 +965,7 @@ class u extends W {
|
|
|
964
965
|
return Number(e.valueOf() - t.valueOf());
|
|
965
966
|
}
|
|
966
967
|
}
|
|
967
|
-
class l extends
|
|
968
|
+
class l extends Z {
|
|
968
969
|
constructor(e) {
|
|
969
970
|
typeof e == "number" && (e = Math.trunc(e.valueOf())), A(e) && (e = e.value), super(BigInt(e.valueOf()));
|
|
970
971
|
}
|
|
@@ -1036,7 +1037,7 @@ class l extends W {
|
|
|
1036
1037
|
* @returns A new TimeSpan representing the remainder.
|
|
1037
1038
|
*/
|
|
1038
1039
|
remainder(e) {
|
|
1039
|
-
return
|
|
1040
|
+
return Pe(this, e);
|
|
1040
1041
|
}
|
|
1041
1042
|
/**
|
|
1042
1043
|
* Truncates the TimeSpan to the nearest multiple of the given span.
|
|
@@ -1059,65 +1060,65 @@ class l extends W {
|
|
|
1059
1060
|
*/
|
|
1060
1061
|
toString(e = "full") {
|
|
1061
1062
|
if (e === "semantic") return this.toSemanticString();
|
|
1062
|
-
const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE),
|
|
1063
|
-
let
|
|
1064
|
-
return h.isZero || (
|
|
1063
|
+
const t = this.truncate(l.DAY), n = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), o = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), w = this.truncate(l.NANOSECOND), h = t, g = n.sub(t), O = i.sub(n), f = o.sub(i), T = c.sub(o), E = d.sub(c), x = w.sub(d);
|
|
1064
|
+
let y = "";
|
|
1065
|
+
return h.isZero || (y += `${h.days}d `), g.isZero || (y += `${g.hours}h `), O.isZero || (y += `${O.minutes}m `), f.isZero || (y += `${f.seconds}s `), T.isZero || (y += `${T.milliseconds}ms `), E.isZero || (y += `${E.microseconds}µs `), x.isZero || (y += `${x.nanoseconds}ns`), y.trim();
|
|
1065
1066
|
}
|
|
1066
1067
|
toSemanticString() {
|
|
1067
1068
|
const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), n = this.valueOf() < 0n;
|
|
1068
1069
|
if (t.valueOf() === 0n) return "0s";
|
|
1069
1070
|
if (t.lessThan(l.SECOND)) return "< 1s";
|
|
1070
|
-
const i = t.days,
|
|
1071
|
+
const i = t.days, o = t.hours, c = t.minutes, d = t.seconds, w = Math.floor(i / ve), h = Math.floor(i / X), g = Math.floor(i / 7), O = Math.floor(i), f = Math.floor(o), T = Math.floor(c), E = Math.floor(d), x = n ? "-" : "";
|
|
1071
1072
|
if (w >= 1) {
|
|
1072
|
-
let
|
|
1073
|
+
let y = `${w}y`;
|
|
1073
1074
|
if (w < 2) {
|
|
1074
|
-
const
|
|
1075
|
-
i %
|
|
1075
|
+
const v = Math.floor(
|
|
1076
|
+
i % ve / X
|
|
1076
1077
|
);
|
|
1077
|
-
|
|
1078
|
+
v > 0 && (y += ` ${v}mo`);
|
|
1078
1079
|
}
|
|
1079
|
-
return
|
|
1080
|
+
return x + y;
|
|
1080
1081
|
}
|
|
1081
|
-
if (g >= 1 && i <
|
|
1082
|
-
let
|
|
1083
|
-
const
|
|
1084
|
-
return g < 2 && (
|
|
1082
|
+
if (g >= 1 && i < X && i % 7 === 0) {
|
|
1083
|
+
let y = `${g}w`;
|
|
1084
|
+
const v = Math.floor(i % 7), L = Math.floor(o - g * 7 * 24);
|
|
1085
|
+
return g < 2 && (v > 0 ? y += ` ${v}d` : L > 0 && L < 24 && (y += ` ${L}h`)), x + y;
|
|
1085
1086
|
}
|
|
1086
1087
|
if (h >= 1) {
|
|
1087
|
-
let
|
|
1088
|
+
let y = `${h}mo`;
|
|
1088
1089
|
if (h < 3) {
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1090
|
+
const v = Math.floor(i % X);
|
|
1091
|
+
v > 0 && (y += ` ${v}d`);
|
|
1091
1092
|
}
|
|
1092
|
-
return
|
|
1093
|
+
return x + y;
|
|
1093
1094
|
}
|
|
1094
1095
|
if (g >= 1) {
|
|
1095
|
-
let
|
|
1096
|
-
const
|
|
1097
|
-
return g < 2 && (
|
|
1096
|
+
let y = `${g}w`;
|
|
1097
|
+
const v = Math.floor(i % 7), L = Math.floor(o - g * 7 * 24);
|
|
1098
|
+
return g < 2 && (v > 0 ? y += ` ${v}d` : L > 0 && L < 24 && (y += ` ${L}h`)), x + y;
|
|
1098
1099
|
}
|
|
1099
|
-
if (
|
|
1100
|
-
let
|
|
1101
|
-
const
|
|
1102
|
-
return
|
|
1100
|
+
if (O >= 1) {
|
|
1101
|
+
let y = `${O}d`;
|
|
1102
|
+
const v = Math.floor(o - O * 24);
|
|
1103
|
+
return O < 2 && v > 0 && (y += ` ${v}h`), x + y;
|
|
1103
1104
|
}
|
|
1104
1105
|
if (f >= 1) {
|
|
1105
|
-
let
|
|
1106
|
+
let y = `${f}h`;
|
|
1106
1107
|
if (f < 3) {
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1108
|
+
const v = Math.floor(c - f * 60);
|
|
1109
|
+
v > 0 && (y += ` ${v}m`);
|
|
1109
1110
|
}
|
|
1110
|
-
return
|
|
1111
|
+
return x + y;
|
|
1111
1112
|
}
|
|
1112
|
-
if (
|
|
1113
|
-
let
|
|
1114
|
-
if (
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1113
|
+
if (T >= 1) {
|
|
1114
|
+
let y = `${T}m`;
|
|
1115
|
+
if (T < 5) {
|
|
1116
|
+
const v = Math.floor(d - T * 60);
|
|
1117
|
+
v > 0 && (y += ` ${v}s`);
|
|
1117
1118
|
}
|
|
1118
|
-
return
|
|
1119
|
+
return x + y;
|
|
1119
1120
|
}
|
|
1120
|
-
return `${
|
|
1121
|
+
return `${x}${E}s`;
|
|
1121
1122
|
}
|
|
1122
1123
|
/**
|
|
1123
1124
|
* Multiplies the TimeSpan by a scalar value.
|
|
@@ -1126,7 +1127,7 @@ class l extends W {
|
|
|
1126
1127
|
* @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
|
|
1127
1128
|
*/
|
|
1128
1129
|
mult(e) {
|
|
1129
|
-
return new l(
|
|
1130
|
+
return new l(M(this.valueOf(), e));
|
|
1130
1131
|
}
|
|
1131
1132
|
/**
|
|
1132
1133
|
* Divides the TimeSpan by a scalar value.
|
|
@@ -1135,7 +1136,7 @@ class l extends W {
|
|
|
1135
1136
|
* @returns A new TimeSpan that is this TimeSpan divided by the provided value.
|
|
1136
1137
|
*/
|
|
1137
1138
|
div(e) {
|
|
1138
|
-
return new l(
|
|
1139
|
+
return new l(ee(this.valueOf(), e));
|
|
1139
1140
|
}
|
|
1140
1141
|
/** @returns the decimal number of days in the TimeSpan. */
|
|
1141
1142
|
get days() {
|
|
@@ -1215,7 +1216,7 @@ class l extends W {
|
|
|
1215
1216
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
1216
1217
|
*/
|
|
1217
1218
|
static microseconds(e = 1) {
|
|
1218
|
-
return l.nanoseconds(
|
|
1219
|
+
return l.nanoseconds(M(e, 1e3));
|
|
1219
1220
|
}
|
|
1220
1221
|
/** A microsecond. */
|
|
1221
1222
|
static MICROSECOND = l.microseconds(1);
|
|
@@ -1226,7 +1227,7 @@ class l extends W {
|
|
|
1226
1227
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
1227
1228
|
*/
|
|
1228
1229
|
static milliseconds(e = 1) {
|
|
1229
|
-
return l.microseconds(
|
|
1230
|
+
return l.microseconds(M(e, 1e3));
|
|
1230
1231
|
}
|
|
1231
1232
|
/** A millisecond. */
|
|
1232
1233
|
static MILLISECOND = l.milliseconds(1);
|
|
@@ -1237,7 +1238,7 @@ class l extends W {
|
|
|
1237
1238
|
* @returns A TimeSpan representing the given number of seconds.
|
|
1238
1239
|
*/
|
|
1239
1240
|
static seconds(e = 1) {
|
|
1240
|
-
return l.milliseconds(
|
|
1241
|
+
return l.milliseconds(M(e, 1e3));
|
|
1241
1242
|
}
|
|
1242
1243
|
/** A second. */
|
|
1243
1244
|
static SECOND = l.seconds(1);
|
|
@@ -1248,7 +1249,7 @@ class l extends W {
|
|
|
1248
1249
|
* @returns A TimeSpan representing the given number of minutes.
|
|
1249
1250
|
*/
|
|
1250
1251
|
static minutes(e = 1) {
|
|
1251
|
-
return l.seconds(
|
|
1252
|
+
return l.seconds(M(e, 60));
|
|
1252
1253
|
}
|
|
1253
1254
|
/** A minute. */
|
|
1254
1255
|
static MINUTE = l.minutes(1);
|
|
@@ -1259,7 +1260,7 @@ class l extends W {
|
|
|
1259
1260
|
* @returns A TimeSpan representing the given number of hours.
|
|
1260
1261
|
*/
|
|
1261
1262
|
static hours(e) {
|
|
1262
|
-
return l.minutes(
|
|
1263
|
+
return l.minutes(M(e, 60));
|
|
1263
1264
|
}
|
|
1264
1265
|
/** Represents an hour. */
|
|
1265
1266
|
static HOUR = l.hours(1);
|
|
@@ -1270,12 +1271,12 @@ class l extends W {
|
|
|
1270
1271
|
* @returns A TimeSpan representing the given number of days.
|
|
1271
1272
|
*/
|
|
1272
1273
|
static days(e) {
|
|
1273
|
-
return l.hours(
|
|
1274
|
+
return l.hours(M(e, 24));
|
|
1274
1275
|
}
|
|
1275
1276
|
/** Represents a day. */
|
|
1276
1277
|
static DAY = l.days(1);
|
|
1277
1278
|
/** The maximum possible value for a TimeSpan. */
|
|
1278
|
-
static MAX = new l(
|
|
1279
|
+
static MAX = new l(ae);
|
|
1279
1280
|
/** The minimum possible value for a TimeSpan. */
|
|
1280
1281
|
static MIN = new l(0);
|
|
1281
1282
|
/** The zero value for a TimeSpan. */
|
|
@@ -1291,7 +1292,7 @@ class l extends W {
|
|
|
1291
1292
|
s.custom((e) => e instanceof N).transform((e) => new l(e))
|
|
1292
1293
|
]);
|
|
1293
1294
|
}
|
|
1294
|
-
class N extends
|
|
1295
|
+
class N extends Z {
|
|
1295
1296
|
constructor(e) {
|
|
1296
1297
|
A(e) && (e = e.value), super(e.valueOf());
|
|
1297
1298
|
}
|
|
@@ -1328,7 +1329,7 @@ class N extends W {
|
|
|
1328
1329
|
* @returns The number of bytes in the given TimeSpan at this rate.
|
|
1329
1330
|
*/
|
|
1330
1331
|
byteCount(e, t) {
|
|
1331
|
-
return this.sampleCount(e) * new
|
|
1332
|
+
return this.sampleCount(e) * new p(t).valueOf();
|
|
1332
1333
|
}
|
|
1333
1334
|
/**
|
|
1334
1335
|
* Calculates a TimeSpan given the number of samples at this rate.
|
|
@@ -1347,7 +1348,7 @@ class N extends W {
|
|
|
1347
1348
|
* @returns A TimeSpan that corresponds to the given number of bytes.
|
|
1348
1349
|
*/
|
|
1349
1350
|
byteSpan(e, t) {
|
|
1350
|
-
return this.span(e.valueOf() / new
|
|
1351
|
+
return this.span(e.valueOf() / new p(t).valueOf());
|
|
1351
1352
|
}
|
|
1352
1353
|
/**
|
|
1353
1354
|
* Adds another Rate to this Rate.
|
|
@@ -1356,7 +1357,7 @@ class N extends W {
|
|
|
1356
1357
|
* @returns A new Rate representing the sum of the two rates.
|
|
1357
1358
|
*/
|
|
1358
1359
|
add(e) {
|
|
1359
|
-
return new N(
|
|
1360
|
+
return new N($(this.valueOf(), new N(e).valueOf()));
|
|
1360
1361
|
}
|
|
1361
1362
|
/**
|
|
1362
1363
|
* Subtracts another Rate from this Rate.
|
|
@@ -1365,7 +1366,7 @@ class N extends W {
|
|
|
1365
1366
|
* @returns A new Rate representing the difference of the two rates.
|
|
1366
1367
|
*/
|
|
1367
1368
|
sub(e) {
|
|
1368
|
-
return new N(
|
|
1369
|
+
return new N(V(this.valueOf(), new N(e).valueOf()));
|
|
1369
1370
|
}
|
|
1370
1371
|
/**
|
|
1371
1372
|
* Multiplies this Rate by a scalar value.
|
|
@@ -1374,7 +1375,7 @@ class N extends W {
|
|
|
1374
1375
|
* @returns A new Rate representing this Rate multiplied by the value.
|
|
1375
1376
|
*/
|
|
1376
1377
|
mult(e) {
|
|
1377
|
-
return new N(
|
|
1378
|
+
return new N(M(this.valueOf(), e));
|
|
1378
1379
|
}
|
|
1379
1380
|
/**
|
|
1380
1381
|
* Divides this Rate by a scalar value.
|
|
@@ -1383,7 +1384,7 @@ class N extends W {
|
|
|
1383
1384
|
* @returns A new Rate representing this Rate divided by the value.
|
|
1384
1385
|
*/
|
|
1385
1386
|
div(e) {
|
|
1386
|
-
return new N(
|
|
1387
|
+
return new N(ee(this.valueOf(), e));
|
|
1387
1388
|
}
|
|
1388
1389
|
/**
|
|
1389
1390
|
* Creates a Rate representing the given number of Hz.
|
|
@@ -1409,7 +1410,7 @@ class N extends W {
|
|
|
1409
1410
|
s.instanceof(N)
|
|
1410
1411
|
]);
|
|
1411
1412
|
}
|
|
1412
|
-
class
|
|
1413
|
+
class p extends Z {
|
|
1413
1414
|
/**
|
|
1414
1415
|
* Creates a Density representing the given number of bytes per value.
|
|
1415
1416
|
*
|
|
@@ -1436,7 +1437,7 @@ class y extends W {
|
|
|
1436
1437
|
* @returns A Size representing the given number of values.
|
|
1437
1438
|
*/
|
|
1438
1439
|
size(e) {
|
|
1439
|
-
return new
|
|
1440
|
+
return new m(e * this.valueOf());
|
|
1440
1441
|
}
|
|
1441
1442
|
/**
|
|
1442
1443
|
* Adds another Density to this Density.
|
|
@@ -1445,7 +1446,7 @@ class y extends W {
|
|
|
1445
1446
|
* @returns A new Density representing the sum of the two densities.
|
|
1446
1447
|
*/
|
|
1447
1448
|
add(e) {
|
|
1448
|
-
return new
|
|
1449
|
+
return new p($(this.valueOf(), new p(e).valueOf()));
|
|
1449
1450
|
}
|
|
1450
1451
|
/**
|
|
1451
1452
|
* Subtracts another Density from this Density.
|
|
@@ -1454,7 +1455,7 @@ class y extends W {
|
|
|
1454
1455
|
* @returns A new Density representing the difference of the two densities.
|
|
1455
1456
|
*/
|
|
1456
1457
|
sub(e) {
|
|
1457
|
-
return new
|
|
1458
|
+
return new p(V(this.valueOf(), new p(e).valueOf()));
|
|
1458
1459
|
}
|
|
1459
1460
|
/**
|
|
1460
1461
|
* Multiplies this Density by a scalar value.
|
|
@@ -1463,7 +1464,7 @@ class y extends W {
|
|
|
1463
1464
|
* @returns A new Density representing this Density multiplied by the value.
|
|
1464
1465
|
*/
|
|
1465
1466
|
mult(e) {
|
|
1466
|
-
return new
|
|
1467
|
+
return new p(M(this.valueOf(), e));
|
|
1467
1468
|
}
|
|
1468
1469
|
/**
|
|
1469
1470
|
* Divides this Density by a scalar value.
|
|
@@ -1472,27 +1473,27 @@ class y extends W {
|
|
|
1472
1473
|
* @returns A new Density representing this Density divided by the value.
|
|
1473
1474
|
*/
|
|
1474
1475
|
div(e) {
|
|
1475
|
-
return new
|
|
1476
|
+
return new p(ee(this.valueOf(), e));
|
|
1476
1477
|
}
|
|
1477
1478
|
/** Unknown/Invalid Density. */
|
|
1478
|
-
static UNKNOWN = new
|
|
1479
|
+
static UNKNOWN = new p(0);
|
|
1479
1480
|
/** 128 bits per value. */
|
|
1480
|
-
static BIT128 = new
|
|
1481
|
+
static BIT128 = new p(16);
|
|
1481
1482
|
/** 64 bits per value. */
|
|
1482
|
-
static BIT64 = new
|
|
1483
|
+
static BIT64 = new p(8);
|
|
1483
1484
|
/** 32 bits per value. */
|
|
1484
|
-
static BIT32 = new
|
|
1485
|
+
static BIT32 = new p(4);
|
|
1485
1486
|
/** 16 bits per value. */
|
|
1486
|
-
static BIT16 = new
|
|
1487
|
+
static BIT16 = new p(2);
|
|
1487
1488
|
/** 8 bits per value. */
|
|
1488
|
-
static BIT8 = new
|
|
1489
|
+
static BIT8 = new p(1);
|
|
1489
1490
|
/** A zod schema for validating and transforming densities */
|
|
1490
1491
|
static z = s.union([
|
|
1491
|
-
s.number().transform((e) => new
|
|
1492
|
-
s.instanceof(
|
|
1492
|
+
s.number().transform((e) => new p(e)),
|
|
1493
|
+
s.instanceof(p)
|
|
1493
1494
|
]);
|
|
1494
1495
|
}
|
|
1495
|
-
class
|
|
1496
|
+
class I {
|
|
1496
1497
|
/**
|
|
1497
1498
|
* The starting TimeStamp of the TimeRange.
|
|
1498
1499
|
*
|
|
@@ -1560,7 +1561,7 @@ class E {
|
|
|
1560
1561
|
* @returns A TimeRange with the start and end swapped.
|
|
1561
1562
|
*/
|
|
1562
1563
|
swap() {
|
|
1563
|
-
return new
|
|
1564
|
+
return new I(this.end, this.start);
|
|
1564
1565
|
}
|
|
1565
1566
|
get numericBounds() {
|
|
1566
1567
|
return {
|
|
@@ -1612,11 +1613,11 @@ class E {
|
|
|
1612
1613
|
const n = this.makeValid();
|
|
1613
1614
|
if (this.equals(e)) return !0;
|
|
1614
1615
|
if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
|
|
1615
|
-
const i = u.max(n.start, e.start),
|
|
1616
|
-
return
|
|
1616
|
+
const i = u.max(n.start, e.start), o = u.min(n.end, e.end);
|
|
1617
|
+
return o.before(i) ? !1 : new l(o.sub(i)).greaterThanOrEqual(t);
|
|
1617
1618
|
}
|
|
1618
1619
|
contains(e) {
|
|
1619
|
-
return e instanceof
|
|
1620
|
+
return e instanceof I ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
|
|
1620
1621
|
}
|
|
1621
1622
|
/**
|
|
1622
1623
|
* Returns a new TimeRange that is bound by the given TimeRange.
|
|
@@ -1630,23 +1631,23 @@ class E {
|
|
|
1630
1631
|
* console.log(bounded); // TimeRange(1500, 2000)
|
|
1631
1632
|
*/
|
|
1632
1633
|
boundBy(e) {
|
|
1633
|
-
const t = new
|
|
1634
|
+
const t = new I(this.start, this.end);
|
|
1634
1635
|
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;
|
|
1635
1636
|
}
|
|
1636
1637
|
static max(...e) {
|
|
1637
|
-
return new
|
|
1638
|
+
return new I(
|
|
1638
1639
|
u.min(...e.map((t) => t.start)),
|
|
1639
1640
|
u.max(...e.map((t) => t.end))
|
|
1640
1641
|
);
|
|
1641
1642
|
}
|
|
1642
1643
|
/** The maximum possible time range. */
|
|
1643
|
-
static MAX = new
|
|
1644
|
+
static MAX = new I(u.MIN, u.MAX);
|
|
1644
1645
|
/** A time range whose start and end are both zero. */
|
|
1645
|
-
static ZERO = new
|
|
1646
|
+
static ZERO = new I(u.ZERO, u.ZERO);
|
|
1646
1647
|
/** A zod schema for validating and transforming time ranges */
|
|
1647
1648
|
static z = s.union([
|
|
1648
|
-
s.object({ start: u.z, end: u.z }).transform((e) => new
|
|
1649
|
-
s.instanceof(
|
|
1649
|
+
s.object({ start: u.z, end: u.z }).transform((e) => new I(e.start, e.end)),
|
|
1650
|
+
s.instanceof(I)
|
|
1650
1651
|
]);
|
|
1651
1652
|
/**
|
|
1652
1653
|
* Sorts two time ranges. The range with the earlier start time is considered less than
|
|
@@ -1663,28 +1664,22 @@ class E {
|
|
|
1663
1664
|
return u.sort(e.start, t.start) || u.sort(e.end, t.end);
|
|
1664
1665
|
}
|
|
1665
1666
|
/**
|
|
1666
|
-
*
|
|
1667
|
-
* merges any overlapping ranges.
|
|
1667
|
+
* Merges the given time ranges into a single time range.
|
|
1668
1668
|
*
|
|
1669
|
-
* @param ranges - The list of `
|
|
1670
|
-
* @returns A
|
|
1669
|
+
* @param ranges - The list of `CrudeTimeRange`s to merge.
|
|
1670
|
+
* @returns A new `TimeRange` that is the union of the given time ranges - the start
|
|
1671
|
+
* is the minimum of the start times and the end is the maximum of the end times.
|
|
1671
1672
|
*/
|
|
1672
|
-
static
|
|
1673
|
-
return e.map((t) =>
|
|
1674
|
-
if (n.span.isZero) return t;
|
|
1675
|
-
if (t.length === 0)
|
|
1676
|
-
return t.push(n), t;
|
|
1677
|
-
const i = t[t.length - 1];
|
|
1678
|
-
return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = u.max(i.end, n.end) : t.push(n), t;
|
|
1679
|
-
}, []);
|
|
1673
|
+
static merge(...e) {
|
|
1674
|
+
return I.max(...e.map((t) => new I(t).makeValid()));
|
|
1680
1675
|
}
|
|
1681
1676
|
}
|
|
1682
|
-
|
|
1677
|
+
class a extends Z {
|
|
1683
1678
|
constructor(e) {
|
|
1684
|
-
if (A(e) && (e = e.value), e instanceof
|
|
1679
|
+
if (A(e) && (e = e.value), e instanceof a || typeof e == "string" || typeof e.valueOf() == "string")
|
|
1685
1680
|
super(e.valueOf());
|
|
1686
1681
|
else {
|
|
1687
|
-
const t =
|
|
1682
|
+
const t = a.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
|
|
1688
1683
|
if (t == null)
|
|
1689
1684
|
throw new Error(`unable to find data type for ${e.toString()}`);
|
|
1690
1685
|
super(t.valueOf());
|
|
@@ -1694,7 +1689,7 @@ let T = class o extends W {
|
|
|
1694
1689
|
* @returns the TypedArray constructor for the DataType.
|
|
1695
1690
|
*/
|
|
1696
1691
|
get Array() {
|
|
1697
|
-
const e =
|
|
1692
|
+
const e = a.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
1698
1693
|
if (e == null)
|
|
1699
1694
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
1700
1695
|
return e;
|
|
@@ -1714,7 +1709,7 @@ let T = class o extends W {
|
|
|
1714
1709
|
/** @returns a string representation of the DataType. If short is true, a 1-4
|
|
1715
1710
|
* character representation (i64, str, etc.) is returned instead. */
|
|
1716
1711
|
toString(e = !1) {
|
|
1717
|
-
return e ?
|
|
1712
|
+
return e ? a.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
|
|
1718
1713
|
}
|
|
1719
1714
|
/**
|
|
1720
1715
|
* @returns true if the DataType has a variable density.
|
|
@@ -1722,7 +1717,7 @@ let T = class o extends W {
|
|
|
1722
1717
|
* @example DataType.INT32.isVariable // false
|
|
1723
1718
|
*/
|
|
1724
1719
|
get isVariable() {
|
|
1725
|
-
return this.equals(
|
|
1720
|
+
return this.equals(a.JSON) || this.equals(a.STRING);
|
|
1726
1721
|
}
|
|
1727
1722
|
/**
|
|
1728
1723
|
* @returns true if the DataType is numeric.
|
|
@@ -1730,7 +1725,7 @@ let T = class o extends W {
|
|
|
1730
1725
|
* @example DataType.STRING.isNumeric // false
|
|
1731
1726
|
*/
|
|
1732
1727
|
get isNumeric() {
|
|
1733
|
-
return !this.isVariable && !this.equals(
|
|
1728
|
+
return !this.isVariable && !this.equals(a.UUID);
|
|
1734
1729
|
}
|
|
1735
1730
|
/**
|
|
1736
1731
|
* @returns true if the DataType is an integer.
|
|
@@ -1755,7 +1750,7 @@ let T = class o extends W {
|
|
|
1755
1750
|
* @example DataType.FLOAT32.density // Density.BIT32
|
|
1756
1751
|
*/
|
|
1757
1752
|
get density() {
|
|
1758
|
-
const e =
|
|
1753
|
+
const e = a.DENSITIES.get(this.toString());
|
|
1759
1754
|
if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1760
1755
|
return e;
|
|
1761
1756
|
}
|
|
@@ -1765,7 +1760,7 @@ let T = class o extends W {
|
|
|
1765
1760
|
* @example DataType.INT32.isUnsigned // false
|
|
1766
1761
|
*/
|
|
1767
1762
|
get isUnsignedInteger() {
|
|
1768
|
-
return this.equals(
|
|
1763
|
+
return this.equals(a.UINT8) || this.equals(a.UINT16) || this.equals(a.UINT32) || this.equals(a.UINT64);
|
|
1769
1764
|
}
|
|
1770
1765
|
/**
|
|
1771
1766
|
* @returns true if the DataType is a signed integer.
|
|
@@ -1773,11 +1768,11 @@ let T = class o extends W {
|
|
|
1773
1768
|
* @example DataType.UINT32.isSigned // false
|
|
1774
1769
|
*/
|
|
1775
1770
|
get isSignedInteger() {
|
|
1776
|
-
return this.equals(
|
|
1771
|
+
return this.equals(a.INT8) || this.equals(a.INT16) || this.equals(a.INT32) || this.equals(a.INT64);
|
|
1777
1772
|
}
|
|
1778
1773
|
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
1779
1774
|
canSafelyCastTo(e) {
|
|
1780
|
-
return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(
|
|
1775
|
+
return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(a.INT32) && e.equals(a.FLOAT64) || this.equals(a.INT8) && e.equals(a.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
|
|
1781
1776
|
}
|
|
1782
1777
|
/** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
|
|
1783
1778
|
canCastTo(e) {
|
|
@@ -1794,129 +1789,129 @@ let T = class o extends W {
|
|
|
1794
1789
|
}
|
|
1795
1790
|
/** @returns true if the data type uses bigints to store values. */
|
|
1796
1791
|
get usesBigInt() {
|
|
1797
|
-
return
|
|
1792
|
+
return a.BIG_INT_TYPES.some((e) => e.equals(this));
|
|
1798
1793
|
}
|
|
1799
1794
|
/** Represents an Unknown/Invalid DataType. */
|
|
1800
|
-
static UNKNOWN = new
|
|
1795
|
+
static UNKNOWN = new a("unknown");
|
|
1801
1796
|
/** Represents a 64-bit floating point value. */
|
|
1802
|
-
static FLOAT64 = new
|
|
1797
|
+
static FLOAT64 = new a("float64");
|
|
1803
1798
|
/** Represents a 32-bit floating point value. */
|
|
1804
|
-
static FLOAT32 = new
|
|
1799
|
+
static FLOAT32 = new a("float32");
|
|
1805
1800
|
/** Represents a 64-bit signed integer value. */
|
|
1806
|
-
static INT64 = new
|
|
1801
|
+
static INT64 = new a("int64");
|
|
1807
1802
|
/** Represents a 32-bit signed integer value. */
|
|
1808
|
-
static INT32 = new
|
|
1803
|
+
static INT32 = new a("int32");
|
|
1809
1804
|
/** Represents a 16-bit signed integer value. */
|
|
1810
|
-
static INT16 = new
|
|
1805
|
+
static INT16 = new a("int16");
|
|
1811
1806
|
/** Represents a 8-bit signed integer value. */
|
|
1812
|
-
static INT8 = new
|
|
1807
|
+
static INT8 = new a("int8");
|
|
1813
1808
|
/** Represents a 64-bit unsigned integer value. */
|
|
1814
|
-
static UINT64 = new
|
|
1809
|
+
static UINT64 = new a("uint64");
|
|
1815
1810
|
/** Represents a 32-bit unsigned integer value. */
|
|
1816
|
-
static UINT32 = new
|
|
1811
|
+
static UINT32 = new a("uint32");
|
|
1817
1812
|
/** Represents a 16-bit unsigned integer value. */
|
|
1818
|
-
static UINT16 = new
|
|
1813
|
+
static UINT16 = new a("uint16");
|
|
1819
1814
|
/** Represents a 8-bit unsigned integer value. */
|
|
1820
|
-
static UINT8 = new
|
|
1815
|
+
static UINT8 = new a("uint8");
|
|
1821
1816
|
/** Represents a boolean value. Stored as a 8-bit unsigned integer. */
|
|
1822
|
-
static BOOLEAN = new
|
|
1817
|
+
static BOOLEAN = new a("boolean");
|
|
1823
1818
|
/** Represents a 64-bit unix epoch. */
|
|
1824
|
-
static TIMESTAMP = new
|
|
1819
|
+
static TIMESTAMP = new a("timestamp");
|
|
1825
1820
|
/** Represents a UUID data type. */
|
|
1826
|
-
static UUID = new
|
|
1821
|
+
static UUID = new a("uuid");
|
|
1827
1822
|
/** Represents a string data type. Strings have an unknown density, and are separate
|
|
1828
1823
|
* by a newline character. */
|
|
1829
|
-
static STRING = new
|
|
1824
|
+
static STRING = new a("string");
|
|
1830
1825
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1831
1826
|
* newline character. */
|
|
1832
|
-
static JSON = new
|
|
1827
|
+
static JSON = new a("json");
|
|
1833
1828
|
static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
|
|
1834
|
-
[
|
|
1835
|
-
[
|
|
1836
|
-
[
|
|
1837
|
-
[
|
|
1838
|
-
[
|
|
1839
|
-
[
|
|
1840
|
-
[
|
|
1841
|
-
[
|
|
1842
|
-
[
|
|
1843
|
-
[
|
|
1844
|
-
[
|
|
1845
|
-
[
|
|
1846
|
-
[
|
|
1847
|
-
[
|
|
1829
|
+
[a.UINT8.toString(), Uint8Array],
|
|
1830
|
+
[a.UINT16.toString(), Uint16Array],
|
|
1831
|
+
[a.UINT32.toString(), Uint32Array],
|
|
1832
|
+
[a.UINT64.toString(), BigUint64Array],
|
|
1833
|
+
[a.FLOAT32.toString(), Float32Array],
|
|
1834
|
+
[a.FLOAT64.toString(), Float64Array],
|
|
1835
|
+
[a.INT8.toString(), Int8Array],
|
|
1836
|
+
[a.INT16.toString(), Int16Array],
|
|
1837
|
+
[a.INT32.toString(), Int32Array],
|
|
1838
|
+
[a.INT64.toString(), BigInt64Array],
|
|
1839
|
+
[a.TIMESTAMP.toString(), BigInt64Array],
|
|
1840
|
+
[a.STRING.toString(), Uint8Array],
|
|
1841
|
+
[a.JSON.toString(), Uint8Array],
|
|
1842
|
+
[a.UUID.toString(), Uint8Array]
|
|
1848
1843
|
]);
|
|
1849
1844
|
static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
|
|
1850
|
-
[Uint8Array.name,
|
|
1851
|
-
[Uint16Array.name,
|
|
1852
|
-
[Uint32Array.name,
|
|
1853
|
-
[BigUint64Array.name,
|
|
1854
|
-
[Float32Array.name,
|
|
1855
|
-
[Float64Array.name,
|
|
1856
|
-
[Int8Array.name,
|
|
1857
|
-
[Int16Array.name,
|
|
1858
|
-
[Int32Array.name,
|
|
1859
|
-
[BigInt64Array.name,
|
|
1845
|
+
[Uint8Array.name, a.UINT8],
|
|
1846
|
+
[Uint16Array.name, a.UINT16],
|
|
1847
|
+
[Uint32Array.name, a.UINT32],
|
|
1848
|
+
[BigUint64Array.name, a.UINT64],
|
|
1849
|
+
[Float32Array.name, a.FLOAT32],
|
|
1850
|
+
[Float64Array.name, a.FLOAT64],
|
|
1851
|
+
[Int8Array.name, a.INT8],
|
|
1852
|
+
[Int16Array.name, a.INT16],
|
|
1853
|
+
[Int32Array.name, a.INT32],
|
|
1854
|
+
[BigInt64Array.name, a.INT64]
|
|
1860
1855
|
]);
|
|
1861
1856
|
static DENSITIES = /* @__PURE__ */ new Map([
|
|
1862
|
-
[
|
|
1863
|
-
[
|
|
1864
|
-
[
|
|
1865
|
-
[
|
|
1866
|
-
[
|
|
1867
|
-
[
|
|
1868
|
-
[
|
|
1869
|
-
[
|
|
1870
|
-
[
|
|
1871
|
-
[
|
|
1872
|
-
[
|
|
1873
|
-
[
|
|
1874
|
-
[
|
|
1875
|
-
[
|
|
1857
|
+
[a.UINT8.toString(), p.BIT8],
|
|
1858
|
+
[a.UINT16.toString(), p.BIT16],
|
|
1859
|
+
[a.UINT32.toString(), p.BIT32],
|
|
1860
|
+
[a.UINT64.toString(), p.BIT64],
|
|
1861
|
+
[a.FLOAT32.toString(), p.BIT32],
|
|
1862
|
+
[a.FLOAT64.toString(), p.BIT64],
|
|
1863
|
+
[a.INT8.toString(), p.BIT8],
|
|
1864
|
+
[a.INT16.toString(), p.BIT16],
|
|
1865
|
+
[a.INT32.toString(), p.BIT32],
|
|
1866
|
+
[a.INT64.toString(), p.BIT64],
|
|
1867
|
+
[a.TIMESTAMP.toString(), p.BIT64],
|
|
1868
|
+
[a.STRING.toString(), p.UNKNOWN],
|
|
1869
|
+
[a.JSON.toString(), p.UNKNOWN],
|
|
1870
|
+
[a.UUID.toString(), p.BIT128]
|
|
1876
1871
|
]);
|
|
1877
1872
|
/** All the data types. */
|
|
1878
1873
|
static ALL = [
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1874
|
+
a.UNKNOWN,
|
|
1875
|
+
a.FLOAT64,
|
|
1876
|
+
a.FLOAT32,
|
|
1877
|
+
a.INT64,
|
|
1878
|
+
a.INT32,
|
|
1879
|
+
a.INT16,
|
|
1880
|
+
a.INT8,
|
|
1881
|
+
a.UINT64,
|
|
1882
|
+
a.UINT32,
|
|
1883
|
+
a.UINT16,
|
|
1884
|
+
a.UINT8,
|
|
1885
|
+
a.TIMESTAMP,
|
|
1886
|
+
a.UUID,
|
|
1887
|
+
a.STRING,
|
|
1888
|
+
a.JSON
|
|
1894
1889
|
];
|
|
1895
1890
|
static SHORT_STRINGS = /* @__PURE__ */ new Map([
|
|
1896
|
-
[
|
|
1897
|
-
[
|
|
1898
|
-
[
|
|
1899
|
-
[
|
|
1900
|
-
[
|
|
1901
|
-
[
|
|
1902
|
-
[
|
|
1903
|
-
[
|
|
1904
|
-
[
|
|
1905
|
-
[
|
|
1906
|
-
[
|
|
1907
|
-
[
|
|
1908
|
-
[
|
|
1909
|
-
[
|
|
1910
|
-
[
|
|
1891
|
+
[a.UINT8.toString(), "u8"],
|
|
1892
|
+
[a.UINT16.toString(), "u16"],
|
|
1893
|
+
[a.UINT32.toString(), "u32"],
|
|
1894
|
+
[a.UINT64.toString(), "u64"],
|
|
1895
|
+
[a.INT8.toString(), "i8"],
|
|
1896
|
+
[a.INT16.toString(), "i16"],
|
|
1897
|
+
[a.INT32.toString(), "i32"],
|
|
1898
|
+
[a.INT64.toString(), "i64"],
|
|
1899
|
+
[a.FLOAT32.toString(), "f32"],
|
|
1900
|
+
[a.FLOAT64.toString(), "f64"],
|
|
1901
|
+
[a.BOOLEAN.toString(), "bool"],
|
|
1902
|
+
[a.TIMESTAMP.toString(), "ts"],
|
|
1903
|
+
[a.UUID.toString(), "uuid"],
|
|
1904
|
+
[a.STRING.toString(), "str"],
|
|
1905
|
+
[a.JSON.toString(), "json"]
|
|
1911
1906
|
]);
|
|
1912
|
-
static BIG_INT_TYPES = [
|
|
1907
|
+
static BIG_INT_TYPES = [a.INT64, a.UINT64, a.TIMESTAMP];
|
|
1913
1908
|
/** A zod schema for a DataType. */
|
|
1914
1909
|
static z = s.union([
|
|
1915
|
-
s.string().transform((e) => new
|
|
1916
|
-
s.instanceof(
|
|
1910
|
+
s.string().transform((e) => new a(e)),
|
|
1911
|
+
s.instanceof(a)
|
|
1917
1912
|
]);
|
|
1918
|
-
}
|
|
1919
|
-
class
|
|
1913
|
+
}
|
|
1914
|
+
class m extends Z {
|
|
1920
1915
|
constructor(e) {
|
|
1921
1916
|
A(e) && (e = e.value), super(e.valueOf());
|
|
1922
1917
|
}
|
|
@@ -1930,11 +1925,11 @@ class p extends W {
|
|
|
1930
1925
|
}
|
|
1931
1926
|
/** @returns a new Size representing the sum of the two Sizes. */
|
|
1932
1927
|
add(e) {
|
|
1933
|
-
return A(e) && (e = e.value), new
|
|
1928
|
+
return A(e) && (e = e.value), new m($(this.valueOf(), e.valueOf()));
|
|
1934
1929
|
}
|
|
1935
1930
|
/** @returns a new Size representing the difference of the two Sizes. */
|
|
1936
1931
|
sub(e) {
|
|
1937
|
-
return A(e) && (e = e.value), new
|
|
1932
|
+
return A(e) && (e = e.value), new m(V(this.valueOf(), e.valueOf()));
|
|
1938
1933
|
}
|
|
1939
1934
|
/**
|
|
1940
1935
|
* Multiplies this Size by a scalar value.
|
|
@@ -1943,7 +1938,7 @@ class p extends W {
|
|
|
1943
1938
|
* @returns A new Size representing this Size multiplied by the value.
|
|
1944
1939
|
*/
|
|
1945
1940
|
mult(e) {
|
|
1946
|
-
return new
|
|
1941
|
+
return new m(M(this.valueOf(), e));
|
|
1947
1942
|
}
|
|
1948
1943
|
/**
|
|
1949
1944
|
* Divides this Size by a scalar value.
|
|
@@ -1952,39 +1947,39 @@ class p extends W {
|
|
|
1952
1947
|
* @returns A new Size representing this Size divided by the value.
|
|
1953
1948
|
*/
|
|
1954
1949
|
div(e) {
|
|
1955
|
-
return new
|
|
1950
|
+
return new m(ee(this.valueOf(), e));
|
|
1956
1951
|
}
|
|
1957
1952
|
/** @returns a new Size representing the truncated value of the Size. */
|
|
1958
1953
|
truncate(e) {
|
|
1959
|
-
return new
|
|
1960
|
-
Math.trunc(this.valueOf() / new
|
|
1954
|
+
return new m(
|
|
1955
|
+
Math.trunc(this.valueOf() / new m(e).valueOf()) * new m(e).valueOf()
|
|
1961
1956
|
);
|
|
1962
1957
|
}
|
|
1963
1958
|
/** @returns a new Size representing the remainder of the Size. */
|
|
1964
1959
|
remainder(e) {
|
|
1965
|
-
return
|
|
1960
|
+
return m.bytes(this.valueOf() % new m(e).valueOf());
|
|
1966
1961
|
}
|
|
1967
1962
|
/** @returns the number of gigabytes in the Size. */
|
|
1968
1963
|
get gigabytes() {
|
|
1969
|
-
return this.valueOf() /
|
|
1964
|
+
return this.valueOf() / m.GIGABYTE.valueOf();
|
|
1970
1965
|
}
|
|
1971
1966
|
/** @returns the number of megabytes in the Size. */
|
|
1972
1967
|
get megabytes() {
|
|
1973
|
-
return this.valueOf() /
|
|
1968
|
+
return this.valueOf() / m.MEGABYTE.valueOf();
|
|
1974
1969
|
}
|
|
1975
1970
|
/** @returns the number of kilobytes in the Size. */
|
|
1976
1971
|
get kilobytes() {
|
|
1977
|
-
return this.valueOf() /
|
|
1972
|
+
return this.valueOf() / m.KILOBYTE.valueOf();
|
|
1978
1973
|
}
|
|
1979
1974
|
/** @returns the number of terabytes in the Size. */
|
|
1980
1975
|
get terabytes() {
|
|
1981
|
-
return this.valueOf() /
|
|
1976
|
+
return this.valueOf() / m.TERABYTE.valueOf();
|
|
1982
1977
|
}
|
|
1983
1978
|
/** @returns a nicely formatted string representation of the Size. */
|
|
1984
1979
|
toString() {
|
|
1985
|
-
const e = this.truncate(
|
|
1986
|
-
let
|
|
1987
|
-
return c.isZero || (
|
|
1980
|
+
const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), o = this.truncate(m.BYTE), c = e, d = t.sub(e), w = n.sub(t), h = i.sub(n), g = o.sub(i);
|
|
1981
|
+
let O = "";
|
|
1982
|
+
return c.isZero || (O += `${c.terabytes}TB `), d.isZero || (O += `${d.gigabytes}GB `), w.isZero || (O += `${w.megabytes}MB `), h.isZero || (O += `${h.kilobytes}KB `), (!g.isZero || O === "") && (O += `${g.valueOf()}B`), O.trim();
|
|
1988
1983
|
}
|
|
1989
1984
|
/**
|
|
1990
1985
|
* Creates a Size from the given number of bytes.
|
|
@@ -1993,10 +1988,10 @@ class p extends W {
|
|
|
1993
1988
|
* @returns A Size representing the given number of bytes.
|
|
1994
1989
|
*/
|
|
1995
1990
|
static bytes(e = 1) {
|
|
1996
|
-
return new
|
|
1991
|
+
return new m(e);
|
|
1997
1992
|
}
|
|
1998
1993
|
/** A single byte */
|
|
1999
|
-
static BYTE = new
|
|
1994
|
+
static BYTE = new m(1);
|
|
2000
1995
|
/**
|
|
2001
1996
|
* Creates a Size from the given number if kilobytes.
|
|
2002
1997
|
*
|
|
@@ -2004,10 +1999,10 @@ class p extends W {
|
|
|
2004
1999
|
* @returns A Size representing the given number of kilobytes.
|
|
2005
2000
|
*/
|
|
2006
2001
|
static kilobytes(e = 1) {
|
|
2007
|
-
return
|
|
2002
|
+
return m.bytes(new m(e).valueOf() * 1e3);
|
|
2008
2003
|
}
|
|
2009
2004
|
/** A kilobyte */
|
|
2010
|
-
static KILOBYTE =
|
|
2005
|
+
static KILOBYTE = m.kilobytes(1);
|
|
2011
2006
|
/**
|
|
2012
2007
|
* Creates a Size from the given number of megabytes.
|
|
2013
2008
|
*
|
|
@@ -2015,10 +2010,10 @@ class p extends W {
|
|
|
2015
2010
|
* @returns A Size representing the given number of megabytes.
|
|
2016
2011
|
*/
|
|
2017
2012
|
static megabytes(e = 1) {
|
|
2018
|
-
return
|
|
2013
|
+
return m.kilobytes(new m(e).valueOf() * 1e3);
|
|
2019
2014
|
}
|
|
2020
2015
|
/** A megabyte */
|
|
2021
|
-
static MEGABYTE =
|
|
2016
|
+
static MEGABYTE = m.megabytes(1);
|
|
2022
2017
|
/**
|
|
2023
2018
|
* Creates a Size from the given number of gigabytes.
|
|
2024
2019
|
*
|
|
@@ -2026,10 +2021,10 @@ class p extends W {
|
|
|
2026
2021
|
* @returns A Size representing the given number of gigabytes.
|
|
2027
2022
|
*/
|
|
2028
2023
|
static gigabytes(e = 1) {
|
|
2029
|
-
return
|
|
2024
|
+
return m.megabytes(new m(e).valueOf() * 1e3);
|
|
2030
2025
|
}
|
|
2031
2026
|
/** A gigabyte */
|
|
2032
|
-
static GIGABYTE =
|
|
2027
|
+
static GIGABYTE = m.gigabytes(1);
|
|
2033
2028
|
/**
|
|
2034
2029
|
* Creates a Size from the given number of terabytes.
|
|
2035
2030
|
*
|
|
@@ -2037,16 +2032,16 @@ class p extends W {
|
|
|
2037
2032
|
* @returns A Size representing the given number of terabytes.
|
|
2038
2033
|
*/
|
|
2039
2034
|
static terabytes(e) {
|
|
2040
|
-
return
|
|
2035
|
+
return m.gigabytes(new m(e).valueOf() * 1e3);
|
|
2041
2036
|
}
|
|
2042
2037
|
/** A terabyte. */
|
|
2043
|
-
static TERABYTE =
|
|
2038
|
+
static TERABYTE = m.terabytes(1);
|
|
2044
2039
|
/** The zero value for Size */
|
|
2045
|
-
static ZERO = new
|
|
2040
|
+
static ZERO = new m(0);
|
|
2046
2041
|
/** A zod schema for a Size. */
|
|
2047
2042
|
static z = s.union([
|
|
2048
|
-
s.number().transform((e) => new
|
|
2049
|
-
s.instanceof(
|
|
2043
|
+
s.number().transform((e) => new m(e)),
|
|
2044
|
+
s.instanceof(m)
|
|
2050
2045
|
]);
|
|
2051
2046
|
/** @returns true if the Size is zero. */
|
|
2052
2047
|
get isZero() {
|
|
@@ -2069,36 +2064,36 @@ s.union([
|
|
|
2069
2064
|
s.instanceof(Int32Array),
|
|
2070
2065
|
s.instanceof(BigInt64Array)
|
|
2071
2066
|
]);
|
|
2072
|
-
const
|
|
2067
|
+
const je = (r) => {
|
|
2073
2068
|
const e = typeof r;
|
|
2074
2069
|
return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof u || r instanceof l || r instanceof Date;
|
|
2075
|
-
},
|
|
2076
|
-
function
|
|
2077
|
-
return typeof r == "string" &&
|
|
2070
|
+
}, jt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : V(t, n), Yt = /^(?:[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;
|
|
2071
|
+
function qt(r) {
|
|
2072
|
+
return typeof r == "string" && Yt.test(r);
|
|
2078
2073
|
}
|
|
2079
2074
|
const S = [];
|
|
2080
2075
|
for (let r = 0; r < 256; ++r)
|
|
2081
2076
|
S.push((r + 256).toString(16).slice(1));
|
|
2082
|
-
function
|
|
2077
|
+
function Ft(r, e = 0) {
|
|
2083
2078
|
return (S[r[e + 0]] + S[r[e + 1]] + S[r[e + 2]] + S[r[e + 3]] + "-" + S[r[e + 4]] + S[r[e + 5]] + "-" + S[r[e + 6]] + S[r[e + 7]] + "-" + S[r[e + 8]] + S[r[e + 9]] + "-" + S[r[e + 10]] + S[r[e + 11]] + S[r[e + 12]] + S[r[e + 13]] + S[r[e + 14]] + S[r[e + 15]]).toLowerCase();
|
|
2084
2079
|
}
|
|
2085
|
-
function
|
|
2086
|
-
const t =
|
|
2087
|
-
if (!
|
|
2080
|
+
function Zt(r, e = 0) {
|
|
2081
|
+
const t = Ft(r, e);
|
|
2082
|
+
if (!qt(t))
|
|
2088
2083
|
throw TypeError("Stringified UUID is invalid");
|
|
2089
2084
|
return t;
|
|
2090
2085
|
}
|
|
2091
2086
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
2092
|
-
const
|
|
2087
|
+
const Ye = (r, e) => Zt(r, e), B = -1, Wt = s.string().transform(
|
|
2093
2088
|
(r) => new Uint8Array(
|
|
2094
2089
|
atob(r).split("").map((e) => e.charCodeAt(0))
|
|
2095
2090
|
).buffer
|
|
2096
|
-
),
|
|
2091
|
+
), zt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), oe = 10, Gt = (r, e) => {
|
|
2097
2092
|
if (r === "number" && !e.isNumeric)
|
|
2098
2093
|
throw new Error(`cannot convert series of type ${e.toString()} to number`);
|
|
2099
2094
|
if (r === "bigint" && !e.usesBigInt)
|
|
2100
2095
|
throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
|
|
2101
|
-
},
|
|
2096
|
+
}, qe = "sy_x_telem_series";
|
|
2102
2097
|
class C {
|
|
2103
2098
|
/**
|
|
2104
2099
|
* A unique identifier for the series. If specified by the user, it is their
|
|
@@ -2110,7 +2105,7 @@ class C {
|
|
|
2110
2105
|
* A discriminator used for identifying instances of the series class even
|
|
2111
2106
|
* when bundlers mangle the class name.
|
|
2112
2107
|
*/
|
|
2113
|
-
discriminator =
|
|
2108
|
+
discriminator = qe;
|
|
2114
2109
|
/** The data type of the series. */
|
|
2115
2110
|
dataType;
|
|
2116
2111
|
/**
|
|
@@ -2126,7 +2121,7 @@ class C {
|
|
|
2126
2121
|
/** The underlying data. */
|
|
2127
2122
|
_data;
|
|
2128
2123
|
/** The time range occupied by the series' data. */
|
|
2129
|
-
timeRange =
|
|
2124
|
+
timeRange = I.ZERO;
|
|
2130
2125
|
/**
|
|
2131
2126
|
* Alignment defines the location of the series relative to other series in a logical
|
|
2132
2127
|
* group. Useful for defining the position of the series within a channel's data.
|
|
@@ -2155,16 +2150,16 @@ class C {
|
|
|
2155
2150
|
* can be constructed into a series.
|
|
2156
2151
|
*/
|
|
2157
2152
|
static crudeZ = s.object({
|
|
2158
|
-
timeRange:
|
|
2159
|
-
dataType:
|
|
2153
|
+
timeRange: I.z.optional(),
|
|
2154
|
+
dataType: a.z,
|
|
2160
2155
|
alignment: s.coerce.bigint().optional(),
|
|
2161
2156
|
data: s.union([
|
|
2162
|
-
|
|
2163
|
-
|
|
2157
|
+
Wt,
|
|
2158
|
+
zt,
|
|
2164
2159
|
s.instanceof(ArrayBuffer),
|
|
2165
2160
|
s.instanceof(Uint8Array)
|
|
2166
2161
|
]),
|
|
2167
|
-
glBufferUsage:
|
|
2162
|
+
glBufferUsage: kt.default("static").optional()
|
|
2168
2163
|
});
|
|
2169
2164
|
/**
|
|
2170
2165
|
* A zod schema that validates and constructs a series from it's crude
|
|
@@ -2245,30 +2240,30 @@ class C {
|
|
|
2245
2240
|
* @throws Error if data type cannot be inferred from input
|
|
2246
2241
|
*/
|
|
2247
2242
|
constructor(e) {
|
|
2248
|
-
|
|
2243
|
+
Vt(e) && (e = { data: e }), e.data ??= [];
|
|
2249
2244
|
const {
|
|
2250
2245
|
dataType: t,
|
|
2251
2246
|
timeRange: n,
|
|
2252
2247
|
sampleOffset: i = 0,
|
|
2253
|
-
glBufferUsage:
|
|
2248
|
+
glBufferUsage: o = "static",
|
|
2254
2249
|
alignment: c = 0n,
|
|
2255
2250
|
alignmentMultiple: d = 1n,
|
|
2256
|
-
key: w =
|
|
2251
|
+
key: w = ct(),
|
|
2257
2252
|
data: h
|
|
2258
2253
|
} = e;
|
|
2259
|
-
if (
|
|
2254
|
+
if (Ht(h)) {
|
|
2260
2255
|
const f = h;
|
|
2261
2256
|
this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this.alignmentMultiple = f.alignmentMultiple, this.cachedMin = f.cachedMin, this.cachedMax = f.cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this.cachedLength = f.cachedLength;
|
|
2262
2257
|
return;
|
|
2263
2258
|
}
|
|
2264
|
-
const g =
|
|
2265
|
-
if (t != null) this.dataType = new
|
|
2259
|
+
const g = je(h), O = Array.isArray(h);
|
|
2260
|
+
if (t != null) this.dataType = new a(t);
|
|
2266
2261
|
else {
|
|
2267
2262
|
if (h instanceof ArrayBuffer)
|
|
2268
2263
|
throw new Error(
|
|
2269
2264
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
2270
2265
|
);
|
|
2271
|
-
if (
|
|
2266
|
+
if (O || g) {
|
|
2272
2267
|
let f = h;
|
|
2273
2268
|
if (!g) {
|
|
2274
2269
|
if (h.length === 0)
|
|
@@ -2277,42 +2272,42 @@ class C {
|
|
|
2277
2272
|
);
|
|
2278
2273
|
f = h[0];
|
|
2279
2274
|
}
|
|
2280
|
-
if (typeof f == "string") this.dataType =
|
|
2281
|
-
else if (typeof f == "number") this.dataType =
|
|
2282
|
-
else if (typeof f == "bigint") this.dataType =
|
|
2283
|
-
else if (typeof f == "boolean") this.dataType =
|
|
2275
|
+
if (typeof f == "string") this.dataType = a.STRING;
|
|
2276
|
+
else if (typeof f == "number") this.dataType = a.FLOAT64;
|
|
2277
|
+
else if (typeof f == "bigint") this.dataType = a.INT64;
|
|
2278
|
+
else if (typeof f == "boolean") this.dataType = a.BOOLEAN;
|
|
2284
2279
|
else if (f instanceof u || f instanceof Date || f instanceof u)
|
|
2285
|
-
this.dataType =
|
|
2286
|
-
else if (typeof f == "object") this.dataType =
|
|
2280
|
+
this.dataType = a.TIMESTAMP;
|
|
2281
|
+
else if (typeof f == "object") this.dataType = a.JSON;
|
|
2287
2282
|
else
|
|
2288
2283
|
throw new Error(
|
|
2289
2284
|
`cannot infer data type of ${typeof f} when constructing a Series from a JS array`
|
|
2290
2285
|
);
|
|
2291
|
-
} else this.dataType = new
|
|
2286
|
+
} else this.dataType = new a(h);
|
|
2292
2287
|
}
|
|
2293
|
-
if (!
|
|
2294
|
-
else if (
|
|
2288
|
+
if (!O && !g) this._data = h;
|
|
2289
|
+
else if (O && h.length === 0)
|
|
2295
2290
|
this._data = new this.dataType.Array([]).buffer;
|
|
2296
2291
|
else {
|
|
2297
2292
|
let f = g ? [h] : h;
|
|
2298
|
-
const
|
|
2299
|
-
(
|
|
2293
|
+
const T = f[0];
|
|
2294
|
+
(T instanceof u || T instanceof Date || T instanceof l) && (f = f.map((E) => new u(E).valueOf())), this.dataType.equals(a.STRING) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
|
|
2300
2295
|
`)}
|
|
2301
|
-
`).buffer) : this.dataType.equals(
|
|
2302
|
-
`${f.map((
|
|
2296
|
+
`).buffer) : this.dataType.equals(a.JSON) ? (this.cachedLength = f.length, this._data = new TextEncoder().encode(
|
|
2297
|
+
`${f.map((E) => ie.encodeString(E)).join(`
|
|
2303
2298
|
`)}
|
|
2304
2299
|
`
|
|
2305
|
-
).buffer) : this.dataType.usesBigInt && typeof
|
|
2306
|
-
f.map((
|
|
2307
|
-
).buffer : !this.dataType.usesBigInt && typeof
|
|
2300
|
+
).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
|
|
2301
|
+
f.map((E) => BigInt(Math.round(E)))
|
|
2302
|
+
).buffer : !this.dataType.usesBigInt && typeof T == "bigint" ? this._data = new this.dataType.Array(
|
|
2308
2303
|
f.map(Number)
|
|
2309
2304
|
).buffer : this._data = new this.dataType.Array(f).buffer;
|
|
2310
2305
|
}
|
|
2311
|
-
this.key = w, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ??
|
|
2306
|
+
this.key = w, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? I.ZERO, this.gl = {
|
|
2312
2307
|
control: null,
|
|
2313
2308
|
buffer: null,
|
|
2314
2309
|
prevBuffer: 0,
|
|
2315
|
-
bufferUsage:
|
|
2310
|
+
bufferUsage: o
|
|
2316
2311
|
};
|
|
2317
2312
|
}
|
|
2318
2313
|
/**
|
|
@@ -2325,8 +2320,8 @@ class C {
|
|
|
2325
2320
|
static alloc({ capacity: e, dataType: t, ...n }) {
|
|
2326
2321
|
if (e === 0)
|
|
2327
2322
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
2328
|
-
const i = new new
|
|
2329
|
-
return
|
|
2323
|
+
const i = new new a(t).Array(e), o = new C({ data: i.buffer, dataType: t, ...n });
|
|
2324
|
+
return o.writePos = 0, o;
|
|
2330
2325
|
}
|
|
2331
2326
|
/**
|
|
2332
2327
|
* @returns the number of references to this series i.e. the number of times this
|
|
@@ -2415,16 +2410,16 @@ class C {
|
|
|
2415
2410
|
* @returns An array of values parsed from the JSON series.
|
|
2416
2411
|
*/
|
|
2417
2412
|
parseJSON(e) {
|
|
2418
|
-
if (!this.dataType.equals(
|
|
2413
|
+
if (!this.dataType.equals(a.JSON))
|
|
2419
2414
|
throw new Error("cannot parse non-JSON series as JSON");
|
|
2420
|
-
return this.toStrings().map((t) => e.parse(
|
|
2415
|
+
return this.toStrings().map((t) => e.parse(ie.decodeString(t)));
|
|
2421
2416
|
}
|
|
2422
2417
|
/**
|
|
2423
2418
|
* Returns the capacity of the series in bytes.
|
|
2424
2419
|
* @returns The size of the underlying buffer in bytes.
|
|
2425
2420
|
*/
|
|
2426
2421
|
get byteCapacity() {
|
|
2427
|
-
return new
|
|
2422
|
+
return new m(this.underlyingData.byteLength);
|
|
2428
2423
|
}
|
|
2429
2424
|
/**
|
|
2430
2425
|
* Returns the capacity of the series in samples.
|
|
@@ -2440,7 +2435,7 @@ class C {
|
|
|
2440
2435
|
* @returns The size of the data in bytes.
|
|
2441
2436
|
*/
|
|
2442
2437
|
get byteLength() {
|
|
2443
|
-
return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new
|
|
2438
|
+
return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new m(this.writePos) : this.dataType.density.size(this.writePos);
|
|
2444
2439
|
}
|
|
2445
2440
|
/**
|
|
2446
2441
|
* Returns the number of samples in this array.
|
|
@@ -2456,7 +2451,7 @@ class C {
|
|
|
2456
2451
|
let e = 0;
|
|
2457
2452
|
const t = [0];
|
|
2458
2453
|
return this.data.forEach((n, i) => {
|
|
2459
|
-
n ===
|
|
2454
|
+
n === oe && (e++, t.push(i + 1));
|
|
2460
2455
|
}), this._cachedIndexes = t, this.cachedLength = e, e;
|
|
2461
2456
|
}
|
|
2462
2457
|
/**
|
|
@@ -2472,7 +2467,7 @@ class C {
|
|
|
2472
2467
|
if (this.dataType.equals(e)) return this;
|
|
2473
2468
|
const n = new e.Array(this.length);
|
|
2474
2469
|
for (let i = 0; i < this.length; i++)
|
|
2475
|
-
n[i] =
|
|
2470
|
+
n[i] = jt(this.dataType, e, this.data[i], t);
|
|
2476
2471
|
return new C({
|
|
2477
2472
|
data: n.buffer,
|
|
2478
2473
|
dataType: e,
|
|
@@ -2484,7 +2479,7 @@ class C {
|
|
|
2484
2479
|
}
|
|
2485
2480
|
calcRawMax() {
|
|
2486
2481
|
if (this.length === 0) return -1 / 0;
|
|
2487
|
-
if (this.dataType.equals(
|
|
2482
|
+
if (this.dataType.equals(a.TIMESTAMP))
|
|
2488
2483
|
this.cachedMax = this.data[this.data.length - 1];
|
|
2489
2484
|
else if (this.dataType.usesBigInt) {
|
|
2490
2485
|
const e = this.data;
|
|
@@ -2502,11 +2497,11 @@ class C {
|
|
|
2502
2497
|
calcMax() {
|
|
2503
2498
|
if (this.dataType.isVariable)
|
|
2504
2499
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
2505
|
-
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(),
|
|
2500
|
+
return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), $(this.cachedMax, this.sampleOffset));
|
|
2506
2501
|
}
|
|
2507
2502
|
calcRawMin() {
|
|
2508
2503
|
if (this.length === 0) return 1 / 0;
|
|
2509
|
-
if (this.dataType.equals(
|
|
2504
|
+
if (this.dataType.equals(a.TIMESTAMP)) this.cachedMin = this.data[0];
|
|
2510
2505
|
else if (this.dataType.usesBigInt) {
|
|
2511
2506
|
const e = this.data;
|
|
2512
2507
|
this.cachedMin = e.reduce((t, n) => t < n ? t : n);
|
|
@@ -2523,11 +2518,11 @@ class C {
|
|
|
2523
2518
|
calcMin() {
|
|
2524
2519
|
if (this.dataType.isVariable)
|
|
2525
2520
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
2526
|
-
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(),
|
|
2521
|
+
return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), $(this.cachedMin, this.sampleOffset));
|
|
2527
2522
|
}
|
|
2528
2523
|
/** @returns the bounds of the series. */
|
|
2529
2524
|
get bounds() {
|
|
2530
|
-
return
|
|
2525
|
+
return k(Number(this.min), Number(this.max), { makeValid: !1 });
|
|
2531
2526
|
}
|
|
2532
2527
|
maybeRecomputeMinMax(e) {
|
|
2533
2528
|
if (this.cachedMin != null) {
|
|
@@ -2549,18 +2544,18 @@ class C {
|
|
|
2549
2544
|
}
|
|
2550
2545
|
at(e, t = !1) {
|
|
2551
2546
|
if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
|
|
2552
|
-
if (this.dataType.equals(
|
|
2547
|
+
if (this.dataType.equals(a.UUID)) return this.atUUID(e, t);
|
|
2553
2548
|
e < 0 && (e = this.length + e);
|
|
2554
2549
|
const n = this.data[e];
|
|
2555
2550
|
if (n == null) {
|
|
2556
2551
|
if (t === !0) throw new Error(`[series] - no value at index ${e}`);
|
|
2557
2552
|
return;
|
|
2558
2553
|
}
|
|
2559
|
-
return
|
|
2554
|
+
return $(n, this.sampleOffset);
|
|
2560
2555
|
}
|
|
2561
2556
|
atUUID(e, t) {
|
|
2562
2557
|
e < 0 && (e = this.length + e);
|
|
2563
|
-
const n =
|
|
2558
|
+
const n = Ye(
|
|
2564
2559
|
new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
|
|
2565
2560
|
);
|
|
2566
2561
|
if (n == null) {
|
|
@@ -2576,7 +2571,7 @@ class C {
|
|
|
2576
2571
|
else {
|
|
2577
2572
|
e < 0 && (e = this.length + e);
|
|
2578
2573
|
for (let c = 0; c < this.data.length; c++)
|
|
2579
|
-
if (this.data[c] ===
|
|
2574
|
+
if (this.data[c] === oe) {
|
|
2580
2575
|
if (e === 0) {
|
|
2581
2576
|
i = c;
|
|
2582
2577
|
break;
|
|
@@ -2588,8 +2583,8 @@ class C {
|
|
|
2588
2583
|
return;
|
|
2589
2584
|
}
|
|
2590
2585
|
}
|
|
2591
|
-
const
|
|
2592
|
-
return this.dataType.equals(
|
|
2586
|
+
const o = this.data.slice(n, i);
|
|
2587
|
+
return this.dataType.equals(a.STRING) ? new TextDecoder().decode(o) : Ee(JSON.parse(new TextDecoder().decode(o)));
|
|
2593
2588
|
}
|
|
2594
2589
|
/**
|
|
2595
2590
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
@@ -2598,11 +2593,11 @@ class C {
|
|
|
2598
2593
|
*/
|
|
2599
2594
|
binarySearch(e) {
|
|
2600
2595
|
let t = 0, n = this.length - 1;
|
|
2601
|
-
const i =
|
|
2596
|
+
const i = st(e);
|
|
2602
2597
|
for (; t <= n; ) {
|
|
2603
|
-
const
|
|
2604
|
-
if (c === 0) return
|
|
2605
|
-
c < 0 ? t =
|
|
2598
|
+
const o = Math.floor((t + n) / 2), c = i(this.at(o, !0), e);
|
|
2599
|
+
if (c === 0) return o;
|
|
2600
|
+
c < 0 ? t = o + 1 : n = o - 1;
|
|
2606
2601
|
}
|
|
2607
2602
|
return t;
|
|
2608
2603
|
}
|
|
@@ -2614,14 +2609,14 @@ class C {
|
|
|
2614
2609
|
* be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
|
|
2615
2610
|
*/
|
|
2616
2611
|
updateGLBuffer(e) {
|
|
2617
|
-
if (this.gl.control = e, !this.dataType.equals(
|
|
2612
|
+
if (this.gl.control = e, !this.dataType.equals(a.FLOAT32) && !this.dataType.equals(a.UINT8))
|
|
2618
2613
|
throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
|
|
2619
2614
|
const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
|
|
2620
2615
|
if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
|
|
2621
2616
|
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
|
|
2622
2617
|
i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
|
|
2623
|
-
const
|
|
2624
|
-
e.bufferSubData(e.ARRAY_BUFFER,
|
|
2618
|
+
const o = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
2619
|
+
e.bufferSubData(e.ARRAY_BUFFER, o, c.buffer), this.gl.prevBuffer = this.writePos;
|
|
2625
2620
|
} else
|
|
2626
2621
|
e.bufferData(
|
|
2627
2622
|
e.ARRAY_BUFFER,
|
|
@@ -2630,7 +2625,7 @@ class C {
|
|
|
2630
2625
|
), this.gl.prevBuffer = B;
|
|
2631
2626
|
}
|
|
2632
2627
|
as(e) {
|
|
2633
|
-
return
|
|
2628
|
+
return Gt(e, this.dataType), this;
|
|
2634
2629
|
}
|
|
2635
2630
|
/** @returns a digest containing information about the series. */
|
|
2636
2631
|
get digest() {
|
|
@@ -2639,8 +2634,8 @@ class C {
|
|
|
2639
2634
|
dataType: this.dataType.toString(),
|
|
2640
2635
|
sampleOffset: this.sampleOffset,
|
|
2641
2636
|
alignment: {
|
|
2642
|
-
lower:
|
|
2643
|
-
upper:
|
|
2637
|
+
lower: Ie(this.alignmentBounds.lower),
|
|
2638
|
+
upper: Ie(this.alignmentBounds.upper),
|
|
2644
2639
|
multiple: this.alignmentMultiple
|
|
2645
2640
|
},
|
|
2646
2641
|
timeRange: this.timeRange.toString(),
|
|
@@ -2658,7 +2653,7 @@ class C {
|
|
|
2658
2653
|
* is exclusive.
|
|
2659
2654
|
*/
|
|
2660
2655
|
get alignmentBounds() {
|
|
2661
|
-
return
|
|
2656
|
+
return k(
|
|
2662
2657
|
this.alignment,
|
|
2663
2658
|
this.alignment + BigInt(this.length) * this.alignmentMultiple
|
|
2664
2659
|
);
|
|
@@ -2678,10 +2673,10 @@ class C {
|
|
|
2678
2673
|
}
|
|
2679
2674
|
[Symbol.iterator]() {
|
|
2680
2675
|
if (this.dataType.isVariable) {
|
|
2681
|
-
const e = new
|
|
2682
|
-
return this.dataType.equals(
|
|
2676
|
+
const e = new Jt(this);
|
|
2677
|
+
return this.dataType.equals(a.JSON) ? new fe(e) : e;
|
|
2683
2678
|
}
|
|
2684
|
-
return this.dataType.equals(
|
|
2679
|
+
return this.dataType.equals(a.UUID) ? new Kt(this) : new Xt(this);
|
|
2685
2680
|
}
|
|
2686
2681
|
/**
|
|
2687
2682
|
* Returns a slice of the series from start to end.
|
|
@@ -2708,7 +2703,7 @@ class C {
|
|
|
2708
2703
|
* @returns An iterator over the specified range.
|
|
2709
2704
|
*/
|
|
2710
2705
|
subIterator(e, t) {
|
|
2711
|
-
return new
|
|
2706
|
+
return new Se(this, e, t ?? this.length);
|
|
2712
2707
|
}
|
|
2713
2708
|
/**
|
|
2714
2709
|
* Returns an iterator over a portion of the series based on alignment.
|
|
@@ -2722,7 +2717,7 @@ class C {
|
|
|
2722
2717
|
), i = Math.ceil(
|
|
2723
2718
|
Number(t - this.alignment) / Number(this.alignmentMultiple)
|
|
2724
2719
|
);
|
|
2725
|
-
return new
|
|
2720
|
+
return new Se(this, n, i);
|
|
2726
2721
|
}
|
|
2727
2722
|
subBytes(e, t) {
|
|
2728
2723
|
if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
|
|
@@ -2757,7 +2752,7 @@ class C {
|
|
|
2757
2752
|
return new C({
|
|
2758
2753
|
data: this.buffer,
|
|
2759
2754
|
dataType: this.dataType,
|
|
2760
|
-
timeRange:
|
|
2755
|
+
timeRange: I.ZERO,
|
|
2761
2756
|
sampleOffset: this.sampleOffset,
|
|
2762
2757
|
glBufferUsage: "static",
|
|
2763
2758
|
alignment: e
|
|
@@ -2781,21 +2776,21 @@ class C {
|
|
|
2781
2776
|
return e += "])", e;
|
|
2782
2777
|
}
|
|
2783
2778
|
}
|
|
2784
|
-
const
|
|
2785
|
-
class
|
|
2779
|
+
const Vt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof C ? !0 : je(r), Ht = ht(qe, C);
|
|
2780
|
+
class Se {
|
|
2786
2781
|
series;
|
|
2787
2782
|
end;
|
|
2788
2783
|
index;
|
|
2789
2784
|
constructor(e, t, n) {
|
|
2790
2785
|
this.series = e;
|
|
2791
|
-
const i =
|
|
2792
|
-
this.end =
|
|
2786
|
+
const i = k(0, e.length + 1);
|
|
2787
|
+
this.end = be(i, n), this.index = be(i, t);
|
|
2793
2788
|
}
|
|
2794
2789
|
next() {
|
|
2795
2790
|
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
2796
2791
|
}
|
|
2797
2792
|
}
|
|
2798
|
-
|
|
2793
|
+
class Jt {
|
|
2799
2794
|
series;
|
|
2800
2795
|
index;
|
|
2801
2796
|
decoder;
|
|
@@ -2808,11 +2803,12 @@ let er = class {
|
|
|
2808
2803
|
}
|
|
2809
2804
|
next() {
|
|
2810
2805
|
const e = this.index, t = this.series.data;
|
|
2811
|
-
for (; this.index < t.length && t[this.index] !==
|
|
2806
|
+
for (; this.index < t.length && t[this.index] !== oe; ) this.index++;
|
|
2812
2807
|
const n = this.index;
|
|
2813
2808
|
return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
|
|
2814
2809
|
}
|
|
2815
|
-
}
|
|
2810
|
+
}
|
|
2811
|
+
class fe {
|
|
2816
2812
|
wrapped;
|
|
2817
2813
|
static schema = s.record(s.string(), s.unknown());
|
|
2818
2814
|
constructor(e) {
|
|
@@ -2822,27 +2818,27 @@ let er = class {
|
|
|
2822
2818
|
const e = this.wrapped.next();
|
|
2823
2819
|
return e.done === !0 ? { done: !0, value: void 0 } : {
|
|
2824
2820
|
done: !1,
|
|
2825
|
-
value:
|
|
2821
|
+
value: ie.decodeString(e.value, fe.schema)
|
|
2826
2822
|
};
|
|
2827
2823
|
}
|
|
2828
|
-
}
|
|
2829
|
-
class
|
|
2824
|
+
}
|
|
2825
|
+
class Kt {
|
|
2830
2826
|
series;
|
|
2831
2827
|
index;
|
|
2832
2828
|
data;
|
|
2833
2829
|
density;
|
|
2834
2830
|
constructor(e) {
|
|
2835
|
-
if (!e.dataType.equals(
|
|
2831
|
+
if (!e.dataType.equals(a.UUID))
|
|
2836
2832
|
throw new Error("cannot create a UUID series iterator for a non-UUID series");
|
|
2837
|
-
this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density =
|
|
2833
|
+
this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = a.UUID.density.valueOf();
|
|
2838
2834
|
}
|
|
2839
2835
|
next() {
|
|
2840
2836
|
if (this.index >= this.series.length) return { done: !0, value: void 0 };
|
|
2841
|
-
const e =
|
|
2837
|
+
const e = Ye(this.data, this.index * this.density);
|
|
2842
2838
|
return this.index++, { done: !1, value: e };
|
|
2843
2839
|
}
|
|
2844
2840
|
}
|
|
2845
|
-
|
|
2841
|
+
class Xt {
|
|
2846
2842
|
series;
|
|
2847
2843
|
index;
|
|
2848
2844
|
constructor(e) {
|
|
@@ -2854,77 +2850,14 @@ let nr = class {
|
|
|
2854
2850
|
value: this.series.at(this.index++, !0)
|
|
2855
2851
|
};
|
|
2856
2852
|
}
|
|
2857
|
-
}
|
|
2858
|
-
const
|
|
2853
|
+
}
|
|
2854
|
+
const Ie = (r) => {
|
|
2859
2855
|
const e = r >> 32n, t = r & 0xffffffffn;
|
|
2860
2856
|
return { domain: e, sample: t };
|
|
2861
|
-
}
|
|
2862
|
-
s.object({ key: s.string(), value: s.string() });
|
|
2863
|
-
s.record(
|
|
2864
|
-
s.union([s.number(), s.string(), s.symbol()]),
|
|
2865
|
-
s.unknown()
|
|
2866
|
-
);
|
|
2867
|
-
const sr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
|
|
2868
|
-
sr();
|
|
2869
|
-
const ir = ["macOS", "Windows", "Linux"], ar = ["macos", "windows", "linux"], or = {
|
|
2870
|
-
macos: "macOS",
|
|
2871
|
-
windows: "Windows",
|
|
2872
|
-
linux: "Linux"
|
|
2873
|
-
};
|
|
2874
|
-
s.enum(ir).or(
|
|
2875
|
-
s.enum(ar).transform((r) => or[r])
|
|
2876
|
-
);
|
|
2877
|
-
const ur = (...r) => r.map(Ze).join(""), Ze = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), lr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, cr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
|
|
2878
|
-
class z {
|
|
2879
|
-
protocol;
|
|
2880
|
-
host;
|
|
2881
|
-
port;
|
|
2882
|
-
path;
|
|
2883
|
-
/**
|
|
2884
|
-
* @param host - The hostname or IP address of the server.
|
|
2885
|
-
* @param port - The port number of the server.
|
|
2886
|
-
* @param protocol - The protocol to use for all requests. Defaults to "".
|
|
2887
|
-
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
2888
|
-
*/
|
|
2889
|
-
constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
|
|
2890
|
-
this.protocol = n, this.host = e, this.port = t, this.path = Ze(i);
|
|
2891
|
-
}
|
|
2892
|
-
/**
|
|
2893
|
-
* Replaces creates a new URL with the specified properties replaced.
|
|
2894
|
-
* @param props - The properties to replace.
|
|
2895
|
-
* @returns a new URL.
|
|
2896
|
-
*/
|
|
2897
|
-
replace(e) {
|
|
2898
|
-
return new z({
|
|
2899
|
-
host: e.host ?? this.host,
|
|
2900
|
-
port: e.port ?? this.port,
|
|
2901
|
-
protocol: e.protocol ?? this.protocol,
|
|
2902
|
-
pathPrefix: e.pathPrefix ?? this.path
|
|
2903
|
-
});
|
|
2904
|
-
}
|
|
2905
|
-
/**
|
|
2906
|
-
* Creates a new url with the given path appended to the current path.
|
|
2907
|
-
* @param path - the path to append to the URL.
|
|
2908
|
-
* @returns a new URL.
|
|
2909
|
-
*/
|
|
2910
|
-
child(e) {
|
|
2911
|
-
return new z({
|
|
2912
|
-
...this,
|
|
2913
|
-
pathPrefix: ur(this.path, e)
|
|
2914
|
-
});
|
|
2915
|
-
}
|
|
2916
|
-
/** @returns a string representation of the url */
|
|
2917
|
-
toString() {
|
|
2918
|
-
return lr(
|
|
2919
|
-
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
2920
|
-
);
|
|
2921
|
-
}
|
|
2922
|
-
static UNKNOWN = new z({ host: "unknown", port: 0 });
|
|
2923
|
-
}
|
|
2924
|
-
const hr = async (r) => await new Promise(
|
|
2857
|
+
}, Qt = async (r) => await new Promise(
|
|
2925
2858
|
(e) => setTimeout(e, l.fromMilliseconds(r).milliseconds)
|
|
2926
2859
|
);
|
|
2927
|
-
class
|
|
2860
|
+
class _t {
|
|
2928
2861
|
config;
|
|
2929
2862
|
retries;
|
|
2930
2863
|
interval;
|
|
@@ -2933,7 +2866,7 @@ class fr {
|
|
|
2933
2866
|
baseInterval: new l(e?.baseInterval ?? l.seconds(1)),
|
|
2934
2867
|
maxRetries: e?.maxRetries ?? 5,
|
|
2935
2868
|
scale: e?.scale ?? 1,
|
|
2936
|
-
sleepFn: e?.sleepFn ??
|
|
2869
|
+
sleepFn: e?.sleepFn ?? Qt
|
|
2937
2870
|
}, this.retries = 0, this.interval = new l(this.config.baseInterval);
|
|
2938
2871
|
}
|
|
2939
2872
|
async wait() {
|
|
@@ -2947,165 +2880,178 @@ class fr {
|
|
|
2947
2880
|
this.retries = 0, this.interval = this.config.baseInterval;
|
|
2948
2881
|
}
|
|
2949
2882
|
}
|
|
2950
|
-
const
|
|
2883
|
+
const er = s.object({
|
|
2951
2884
|
baseInterval: l.z.optional(),
|
|
2952
2885
|
maxRetries: s.number().optional(),
|
|
2953
2886
|
scale: s.number().optional()
|
|
2954
|
-
}),
|
|
2887
|
+
}), tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2955
2888
|
__proto__: null,
|
|
2956
|
-
Breaker:
|
|
2957
|
-
breakerConfigZ:
|
|
2958
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
2959
|
-
if (r =
|
|
2889
|
+
Breaker: _t,
|
|
2890
|
+
breakerConfigZ: er
|
|
2891
|
+
}, Symbol.toStringTag, { value: "Module" })), rr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = s.string().regex(rr), j = s.number().min(0).max(255), Ze = s.number().min(0).max(1), We = s.tuple([j, j, j, Ze]), nr = s.tuple([j, j, j]), sr = s.object({ rgba255: We }), ir = s.number().min(0).max(360), ar = s.number().min(0).max(100), or = s.number().min(0).max(100), ur = s.tuple([ir, ar, or, Ze]), de = s.union([Fe, nr, We, ur, sr]), lr = de.transform((r) => ge(r)), ge = (r, e = 1) => {
|
|
2892
|
+
if (r = de.parse(r), typeof r == "string") return cr(r, e);
|
|
2960
2893
|
if (Array.isArray(r)) {
|
|
2961
2894
|
if (r.length < 3 || r.length > 4)
|
|
2962
2895
|
throw new Error(`Invalid color: [${r.join(", ")}]`);
|
|
2963
2896
|
return r.length === 3 ? [...r, e] : r;
|
|
2964
2897
|
}
|
|
2965
2898
|
return r.rgba255;
|
|
2966
|
-
},
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
r.length === 8 ?
|
|
2971
|
-
]),
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
const
|
|
2899
|
+
}, cr = (r, e = 1) => (r = Fe.parse(r), r = hr(r), [
|
|
2900
|
+
Q(r, 0),
|
|
2901
|
+
Q(r, 2),
|
|
2902
|
+
Q(r, 4),
|
|
2903
|
+
r.length === 8 ? Q(r, 6) / 255 : e
|
|
2904
|
+
]), Q = (r, e) => parseInt(r.slice(e, e + 2), 16), hr = (r) => r.startsWith("#") ? r.slice(1) : r;
|
|
2905
|
+
ge("#000000");
|
|
2906
|
+
ge("#ffffff");
|
|
2907
|
+
const fr = s.object({
|
|
2975
2908
|
key: s.string(),
|
|
2976
|
-
color:
|
|
2909
|
+
color: de,
|
|
2977
2910
|
position: s.number(),
|
|
2978
2911
|
switched: s.boolean().optional()
|
|
2979
2912
|
});
|
|
2980
|
-
s.array(
|
|
2981
|
-
const
|
|
2913
|
+
s.array(fr);
|
|
2914
|
+
const dr = s.object({
|
|
2982
2915
|
key: s.string(),
|
|
2983
2916
|
name: s.string(),
|
|
2984
|
-
color:
|
|
2917
|
+
color: lr
|
|
2985
2918
|
});
|
|
2986
2919
|
s.object({
|
|
2987
2920
|
key: s.string(),
|
|
2988
2921
|
name: s.string(),
|
|
2989
|
-
swatches: s.array(
|
|
2922
|
+
swatches: s.array(dr)
|
|
2990
2923
|
});
|
|
2991
2924
|
s.int().min(0).max(255);
|
|
2992
2925
|
s.object({
|
|
2993
2926
|
name: s.string(),
|
|
2994
2927
|
key: s.string()
|
|
2995
2928
|
});
|
|
2996
|
-
const
|
|
2929
|
+
const gr = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), mr = (r, e) => {
|
|
2997
2930
|
const t = Symbol.for(r);
|
|
2998
|
-
if (!
|
|
2931
|
+
if (!gr(t)) {
|
|
2999
2932
|
const n = e();
|
|
3000
2933
|
Object.defineProperty(globalThis, t, { value: n });
|
|
3001
2934
|
}
|
|
3002
2935
|
return () => globalThis[t];
|
|
3003
|
-
},
|
|
3004
|
-
static discriminator =
|
|
3005
|
-
discriminator =
|
|
2936
|
+
}, ze = "sy_x_error", yr = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), H = (r) => class W extends Error {
|
|
2937
|
+
static discriminator = ze;
|
|
2938
|
+
discriminator = W.discriminator;
|
|
3006
2939
|
static TYPE = r;
|
|
3007
|
-
type =
|
|
3008
|
-
static matches =
|
|
3009
|
-
matches =
|
|
2940
|
+
type = W.TYPE;
|
|
2941
|
+
static matches = yr(r);
|
|
2942
|
+
matches = W.matches;
|
|
3010
2943
|
constructor(t, n) {
|
|
3011
|
-
super(t, n), this.name =
|
|
2944
|
+
super(t, n), this.name = W.TYPE;
|
|
3012
2945
|
}
|
|
3013
2946
|
static sub(t) {
|
|
3014
|
-
return
|
|
2947
|
+
return H(`${r}.${t}`);
|
|
3015
2948
|
}
|
|
3016
|
-
},
|
|
2949
|
+
}, Ge = (r) => {
|
|
3017
2950
|
if (r == null || typeof r != "object") return !1;
|
|
3018
2951
|
const e = r;
|
|
3019
|
-
if (e.discriminator !==
|
|
2952
|
+
if (e.discriminator !== ze) return !1;
|
|
3020
2953
|
if (!("type" in e))
|
|
3021
2954
|
throw new Error(
|
|
3022
2955
|
`X Error is missing its type property: ${JSON.stringify(e)}`
|
|
3023
2956
|
);
|
|
3024
2957
|
return !0;
|
|
3025
|
-
},
|
|
3026
|
-
class
|
|
2958
|
+
}, P = "unknown", ue = "nil";
|
|
2959
|
+
class pr {
|
|
3027
2960
|
providers = [];
|
|
3028
2961
|
register(e) {
|
|
3029
2962
|
this.providers.push(e);
|
|
3030
2963
|
}
|
|
3031
2964
|
encode(e) {
|
|
3032
|
-
if (e == null) return { type:
|
|
3033
|
-
if (
|
|
2965
|
+
if (e == null) return { type: ue, data: "" };
|
|
2966
|
+
if (Ge(e))
|
|
3034
2967
|
for (const t of this.providers) {
|
|
3035
2968
|
const n = t.encode(e);
|
|
3036
2969
|
if (n != null) return n;
|
|
3037
2970
|
}
|
|
3038
|
-
if (e instanceof Error) return { type:
|
|
3039
|
-
if (typeof e == "string") return { type:
|
|
2971
|
+
if (e instanceof Error) return { type: P, data: e.message };
|
|
2972
|
+
if (typeof e == "string") return { type: P, data: e };
|
|
3040
2973
|
try {
|
|
3041
|
-
return { type:
|
|
2974
|
+
return { type: P, data: JSON.stringify(e) };
|
|
3042
2975
|
} catch {
|
|
3043
|
-
return { type:
|
|
2976
|
+
return { type: P, data: "unable to encode error information" };
|
|
3044
2977
|
}
|
|
3045
2978
|
}
|
|
3046
2979
|
decode(e) {
|
|
3047
|
-
if (e == null || e.type ===
|
|
3048
|
-
if (e.type ===
|
|
2980
|
+
if (e == null || e.type === ue) return null;
|
|
2981
|
+
if (e.type === P) return new le(e.data);
|
|
3049
2982
|
for (const t of this.providers) {
|
|
3050
2983
|
const n = t.decode(e);
|
|
3051
2984
|
if (n != null) return n;
|
|
3052
2985
|
}
|
|
3053
|
-
return new
|
|
2986
|
+
return new le(e.data);
|
|
3054
2987
|
}
|
|
3055
2988
|
}
|
|
3056
|
-
const
|
|
3057
|
-
class
|
|
2989
|
+
const me = mr("synnax-error-registry", () => new pr()), wr = ({ encode: r, decode: e }) => me().register({ encode: r, decode: e }), br = (r) => me().encode(r), Or = (r) => r == null ? null : me().decode(r);
|
|
2990
|
+
class le extends H("unknown") {
|
|
3058
2991
|
}
|
|
3059
|
-
const
|
|
3060
|
-
class
|
|
2992
|
+
const Tr = s.object({ type: s.string(), data: s.string() });
|
|
2993
|
+
class vr extends H("canceled") {
|
|
3061
2994
|
}
|
|
3062
|
-
class
|
|
2995
|
+
class Sr extends H("not_implemented") {
|
|
3063
2996
|
}
|
|
3064
|
-
const
|
|
2997
|
+
const D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3065
2998
|
__proto__: null,
|
|
3066
|
-
Canceled:
|
|
3067
|
-
NONE:
|
|
3068
|
-
NotImplemented:
|
|
3069
|
-
UNKNOWN:
|
|
3070
|
-
Unknown:
|
|
3071
|
-
createTyped:
|
|
3072
|
-
decode:
|
|
3073
|
-
encode:
|
|
3074
|
-
isTyped:
|
|
3075
|
-
payloadZ:
|
|
3076
|
-
register:
|
|
3077
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3078
|
-
jsonrpc:
|
|
3079
|
-
method:
|
|
2999
|
+
Canceled: vr,
|
|
3000
|
+
NONE: ue,
|
|
3001
|
+
NotImplemented: Sr,
|
|
3002
|
+
UNKNOWN: P,
|
|
3003
|
+
Unknown: le,
|
|
3004
|
+
createTyped: H,
|
|
3005
|
+
decode: Or,
|
|
3006
|
+
encode: br,
|
|
3007
|
+
isTyped: Ge,
|
|
3008
|
+
payloadZ: Tr,
|
|
3009
|
+
register: wr
|
|
3010
|
+
}, Symbol.toStringTag, { value: "Module" })), Ir = b.object({
|
|
3011
|
+
jsonrpc: b.literal("2.0"),
|
|
3012
|
+
method: b.string(),
|
|
3080
3013
|
// params should be z.union([z.record(z.string(), z.json()),
|
|
3081
3014
|
// z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
|
|
3082
3015
|
// definition of params then in the JSON-RPC spec.
|
|
3083
|
-
params:
|
|
3084
|
-
id:
|
|
3085
|
-
}),
|
|
3086
|
-
jsonrpc:
|
|
3087
|
-
id:
|
|
3088
|
-
}),
|
|
3089
|
-
result:
|
|
3090
|
-
}),
|
|
3091
|
-
error:
|
|
3092
|
-
code:
|
|
3016
|
+
params: b.any().optional(),
|
|
3017
|
+
id: b.union([b.string(), b.number(), b.null()]).optional()
|
|
3018
|
+
}), Ve = b.object({
|
|
3019
|
+
jsonrpc: b.literal("2.0"),
|
|
3020
|
+
id: b.union([b.string(), b.number(), b.null()])
|
|
3021
|
+
}), Nr = Ve.extend({
|
|
3022
|
+
result: b.json()
|
|
3023
|
+
}), Er = Ve.extend({
|
|
3024
|
+
error: b.object({
|
|
3025
|
+
code: b.number().int(),
|
|
3093
3026
|
// This should be z.string(), but the VSCode JSON RPC implementation uses a looser
|
|
3094
3027
|
// definition of error than the JSON-RPC spec.
|
|
3095
|
-
message:
|
|
3096
|
-
data:
|
|
3028
|
+
message: b.string().optional(),
|
|
3029
|
+
data: b.json().optional()
|
|
3097
3030
|
})
|
|
3098
|
-
}),
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3031
|
+
}), Ar = b.union([Nr, Er]);
|
|
3032
|
+
b.union([Ir, Ar]);
|
|
3033
|
+
s.object({ key: s.string(), value: s.string() });
|
|
3034
|
+
const xr = b.uuid();
|
|
3035
|
+
b.object({
|
|
3036
|
+
key: xr,
|
|
3037
|
+
name: b.string().min(1),
|
|
3038
|
+
color: b.string()
|
|
3105
3039
|
});
|
|
3106
3040
|
s.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);
|
|
3107
|
-
const
|
|
3108
|
-
s.enum(
|
|
3041
|
+
const Ur = ["standard", "scientific", "engineering"];
|
|
3042
|
+
s.enum(Ur);
|
|
3043
|
+
const Mr = s.union([s.string(), s.number()]);
|
|
3044
|
+
s.record(Mr, s.unknown());
|
|
3045
|
+
const Cr = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
|
|
3046
|
+
Cr();
|
|
3047
|
+
const Br = ["macOS", "Windows", "Linux"], Rr = ["macos", "windows", "linux"], Dr = {
|
|
3048
|
+
macos: "macOS",
|
|
3049
|
+
windows: "Windows",
|
|
3050
|
+
linux: "Linux"
|
|
3051
|
+
};
|
|
3052
|
+
s.enum(Br).or(
|
|
3053
|
+
s.enum(Rr).transform((r) => Dr[r])
|
|
3054
|
+
);
|
|
3109
3055
|
s.enum([
|
|
3110
3056
|
"success",
|
|
3111
3057
|
"info",
|
|
@@ -3118,35 +3064,83 @@ s.object({
|
|
|
3118
3064
|
stack: s.string(),
|
|
3119
3065
|
error: s.instanceof(Error)
|
|
3120
3066
|
});
|
|
3121
|
-
|
|
3067
|
+
const Lr = (...r) => r.map(He).join(""), He = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), $r = (r) => r.endsWith("/") ? r.slice(0, -1) : r, kr = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
|
|
3068
|
+
class z {
|
|
3069
|
+
protocol;
|
|
3070
|
+
host;
|
|
3071
|
+
port;
|
|
3072
|
+
path;
|
|
3073
|
+
/**
|
|
3074
|
+
* @param host - The hostname or IP address of the server.
|
|
3075
|
+
* @param port - The port number of the server.
|
|
3076
|
+
* @param protocol - The protocol to use for all requests. Defaults to "".
|
|
3077
|
+
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
3078
|
+
*/
|
|
3079
|
+
constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
|
|
3080
|
+
this.protocol = n, this.host = e, this.port = t, this.path = He(i);
|
|
3081
|
+
}
|
|
3082
|
+
/**
|
|
3083
|
+
* Replaces creates a new URL with the specified properties replaced.
|
|
3084
|
+
* @param props - The properties to replace.
|
|
3085
|
+
* @returns a new URL.
|
|
3086
|
+
*/
|
|
3087
|
+
replace(e) {
|
|
3088
|
+
return new z({
|
|
3089
|
+
host: e.host ?? this.host,
|
|
3090
|
+
port: e.port ?? this.port,
|
|
3091
|
+
protocol: e.protocol ?? this.protocol,
|
|
3092
|
+
pathPrefix: e.pathPrefix ?? this.path
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Creates a new url with the given path appended to the current path.
|
|
3097
|
+
* @param path - the path to append to the URL.
|
|
3098
|
+
* @returns a new URL.
|
|
3099
|
+
*/
|
|
3100
|
+
child(e) {
|
|
3101
|
+
return new z({
|
|
3102
|
+
...this,
|
|
3103
|
+
pathPrefix: Lr(this.path, e)
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
/** @returns a string representation of the url */
|
|
3107
|
+
toString() {
|
|
3108
|
+
return $r(
|
|
3109
|
+
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
static UNKNOWN = new z({ host: "unknown", port: 0 });
|
|
3113
|
+
}
|
|
3114
|
+
s.int().min(0).max(ft);
|
|
3115
|
+
class J extends D.createTyped("freighter") {
|
|
3122
3116
|
}
|
|
3123
|
-
class Y extends
|
|
3117
|
+
class Y extends J.sub("eof") {
|
|
3124
3118
|
constructor() {
|
|
3125
3119
|
super("EOF");
|
|
3126
3120
|
}
|
|
3127
3121
|
}
|
|
3128
|
-
class q extends
|
|
3122
|
+
class q extends J.sub("stream_closed") {
|
|
3129
3123
|
constructor() {
|
|
3130
3124
|
super("StreamClosed");
|
|
3131
3125
|
}
|
|
3132
3126
|
}
|
|
3133
|
-
class F extends
|
|
3127
|
+
class F extends J.sub("unreachable") {
|
|
3134
3128
|
url;
|
|
3135
3129
|
constructor(e = {}) {
|
|
3136
3130
|
const { message: t = "Unreachable", url: n = z.UNKNOWN } = e;
|
|
3137
3131
|
super(t), this.url = n;
|
|
3138
3132
|
}
|
|
3139
3133
|
}
|
|
3140
|
-
const
|
|
3141
|
-
if (!r.type.startsWith(
|
|
3134
|
+
const Pr = (r) => {
|
|
3135
|
+
if (!r.type.startsWith(J.TYPE)) return null;
|
|
3142
3136
|
if (Y.matches(r)) return { type: Y.TYPE, data: "EOF" };
|
|
3143
3137
|
if (q.matches(r))
|
|
3144
3138
|
return { type: q.TYPE, data: "StreamClosed" };
|
|
3145
3139
|
if (F.matches(r))
|
|
3146
3140
|
return { type: F.TYPE, data: "Unreachable" };
|
|
3147
3141
|
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
3148
|
-
},
|
|
3149
|
-
if (!r.type.startsWith(
|
|
3142
|
+
}, jr = (r) => {
|
|
3143
|
+
if (!r.type.startsWith(J.TYPE)) return null;
|
|
3150
3144
|
switch (r.type) {
|
|
3151
3145
|
case Y.TYPE:
|
|
3152
3146
|
return new Y();
|
|
@@ -3155,14 +3149,14 @@ const Wr = (r) => {
|
|
|
3155
3149
|
case F.TYPE:
|
|
3156
3150
|
return new F();
|
|
3157
3151
|
default:
|
|
3158
|
-
throw new
|
|
3152
|
+
throw new D.Unknown(`Unknown error type: ${r.data}`);
|
|
3159
3153
|
}
|
|
3160
3154
|
};
|
|
3161
|
-
|
|
3162
|
-
encode:
|
|
3163
|
-
decode:
|
|
3155
|
+
D.register({
|
|
3156
|
+
encode: Pr,
|
|
3157
|
+
decode: jr
|
|
3164
3158
|
});
|
|
3165
|
-
class
|
|
3159
|
+
class Je {
|
|
3166
3160
|
middleware = [];
|
|
3167
3161
|
/** Implements the Transport interface */
|
|
3168
3162
|
use(...e) {
|
|
@@ -3179,47 +3173,47 @@ class Xe {
|
|
|
3179
3173
|
*/
|
|
3180
3174
|
async executeMiddleware(e, t) {
|
|
3181
3175
|
let n = 0;
|
|
3182
|
-
const i = async (
|
|
3183
|
-
if (n === this.middleware.length) return await t(
|
|
3176
|
+
const i = async (o) => {
|
|
3177
|
+
if (n === this.middleware.length) return await t(o);
|
|
3184
3178
|
const c = this.middleware[n];
|
|
3185
|
-
return n++, await c(
|
|
3179
|
+
return n++, await c(o, i);
|
|
3186
3180
|
};
|
|
3187
3181
|
return await i(e);
|
|
3188
3182
|
}
|
|
3189
3183
|
}
|
|
3190
|
-
const
|
|
3184
|
+
const Ke = "Content-Type", Yr = /* @__PURE__ */ new Set([
|
|
3191
3185
|
"ECONNREFUSED",
|
|
3192
3186
|
"ECONNRESET",
|
|
3193
3187
|
"ETIMEDOUT",
|
|
3194
3188
|
"EPIPE",
|
|
3195
3189
|
"UND_ERR_CONNECT_TIMEOUT",
|
|
3196
3190
|
"UND_ERR_SOCKET"
|
|
3197
|
-
]),
|
|
3191
|
+
]), qr = (r) => {
|
|
3198
3192
|
const e = r?.cause?.code ?? r?.code ?? r?.errno;
|
|
3199
|
-
if (typeof e == "string" &&
|
|
3193
|
+
if (typeof e == "string" && Yr.has(e)) return !0;
|
|
3200
3194
|
if (r.name === "TypeError") {
|
|
3201
3195
|
const t = String(r.message || "").toLowerCase();
|
|
3202
3196
|
if (/load failed|failed to fetch|networkerror|network error/.test(t))
|
|
3203
3197
|
return typeof navigator < "u" && navigator.onLine === !1, !0;
|
|
3204
3198
|
}
|
|
3205
3199
|
return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
|
|
3206
|
-
},
|
|
3207
|
-
class
|
|
3200
|
+
}, Fr = 400;
|
|
3201
|
+
class Hr extends Je {
|
|
3208
3202
|
endpoint;
|
|
3209
3203
|
encoder;
|
|
3210
3204
|
constructor(e, t, n = !1) {
|
|
3211
3205
|
return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
|
|
3212
|
-
get: (i,
|
|
3206
|
+
get: (i, o, c) => o === "endpoint" ? this.endpoint : Reflect.get(i, o, c)
|
|
3213
3207
|
});
|
|
3214
3208
|
}
|
|
3215
3209
|
get headers() {
|
|
3216
3210
|
return {
|
|
3217
|
-
[
|
|
3211
|
+
[Ke]: this.encoder.contentType
|
|
3218
3212
|
};
|
|
3219
3213
|
}
|
|
3220
3214
|
async send(e, t, n, i) {
|
|
3221
3215
|
t = n?.parse(t);
|
|
3222
|
-
let
|
|
3216
|
+
let o = null;
|
|
3223
3217
|
const c = this.endpoint.child(e), d = {};
|
|
3224
3218
|
d.method = "POST", d.body = this.encoder.encode(t ?? {});
|
|
3225
3219
|
const [, w] = await this.executeMiddleware(
|
|
@@ -3235,37 +3229,37 @@ class sn extends Xe {
|
|
|
3235
3229
|
...this.headers,
|
|
3236
3230
|
...h.params
|
|
3237
3231
|
};
|
|
3238
|
-
let
|
|
3232
|
+
let O;
|
|
3239
3233
|
try {
|
|
3240
|
-
|
|
3241
|
-
} catch (
|
|
3242
|
-
if (!(
|
|
3243
|
-
return [g,
|
|
3234
|
+
O = await fetch(h.target, d);
|
|
3235
|
+
} catch (T) {
|
|
3236
|
+
if (!(T instanceof Error)) throw T;
|
|
3237
|
+
return [g, qr(T) ? new F({ url: c }) : T];
|
|
3244
3238
|
}
|
|
3245
|
-
const f = await
|
|
3246
|
-
if (
|
|
3247
|
-
return i != null && (
|
|
3239
|
+
const f = await O.arrayBuffer();
|
|
3240
|
+
if (O?.ok)
|
|
3241
|
+
return i != null && (o = this.encoder.decode(f, i)), [g, null];
|
|
3248
3242
|
try {
|
|
3249
|
-
if (
|
|
3250
|
-
return [g, new Error(
|
|
3251
|
-
const
|
|
3252
|
-
return [g,
|
|
3253
|
-
} catch (
|
|
3243
|
+
if (O.status !== Fr)
|
|
3244
|
+
return [g, new Error(O.statusText)];
|
|
3245
|
+
const T = this.encoder.decode(f, D.payloadZ), E = D.decode(T);
|
|
3246
|
+
return [g, E];
|
|
3247
|
+
} catch (T) {
|
|
3254
3248
|
return [
|
|
3255
3249
|
g,
|
|
3256
3250
|
new Error(
|
|
3257
|
-
`[freighter] - failed to decode error: ${
|
|
3251
|
+
`[freighter] - failed to decode error: ${O.statusText}: ${T.message}`
|
|
3258
3252
|
)
|
|
3259
3253
|
];
|
|
3260
3254
|
}
|
|
3261
3255
|
}
|
|
3262
3256
|
);
|
|
3263
3257
|
if (w != null) return [null, w];
|
|
3264
|
-
if (
|
|
3265
|
-
return [
|
|
3258
|
+
if (o == null) throw new Error("Response must be defined");
|
|
3259
|
+
return [o, null];
|
|
3266
3260
|
}
|
|
3267
3261
|
}
|
|
3268
|
-
const
|
|
3262
|
+
const Jr = (r, e) => {
|
|
3269
3263
|
class t {
|
|
3270
3264
|
wrapped;
|
|
3271
3265
|
constructor(i) {
|
|
@@ -3274,10 +3268,10 @@ const an = (r, e) => {
|
|
|
3274
3268
|
use(...i) {
|
|
3275
3269
|
this.wrapped.use(...i);
|
|
3276
3270
|
}
|
|
3277
|
-
async send(i,
|
|
3278
|
-
const w = new
|
|
3271
|
+
async send(i, o, c, d) {
|
|
3272
|
+
const w = new tr.Breaker(e);
|
|
3279
3273
|
do {
|
|
3280
|
-
const [h, g] = await this.wrapped.send(i,
|
|
3274
|
+
const [h, g] = await this.wrapped.send(i, o, c, d);
|
|
3281
3275
|
if (g == null) return [h, null];
|
|
3282
3276
|
if (!F.matches(g)) return [null, g];
|
|
3283
3277
|
if (console.warn(`[freighter] ${w.retryMessage}`, g), !await w.wait()) return [h, g];
|
|
@@ -3285,16 +3279,16 @@ const an = (r, e) => {
|
|
|
3285
3279
|
}
|
|
3286
3280
|
}
|
|
3287
3281
|
return new t(r);
|
|
3288
|
-
},
|
|
3289
|
-
const [
|
|
3282
|
+
}, Kr = async (r, e, t, n, i) => {
|
|
3283
|
+
const [o, c] = await r.send(e, t, n, i);
|
|
3290
3284
|
if (c != null) throw c;
|
|
3291
|
-
return
|
|
3292
|
-
},
|
|
3285
|
+
return o;
|
|
3286
|
+
}, Zr = s.object({
|
|
3293
3287
|
type: s.enum(["data", "close", "open"]),
|
|
3294
3288
|
payload: s.unknown(),
|
|
3295
|
-
error: s.optional(
|
|
3289
|
+
error: s.optional(D.payloadZ)
|
|
3296
3290
|
});
|
|
3297
|
-
class
|
|
3291
|
+
class Wr {
|
|
3298
3292
|
codec;
|
|
3299
3293
|
reqSchema;
|
|
3300
3294
|
resSchema;
|
|
@@ -3310,7 +3304,7 @@ class Jr {
|
|
|
3310
3304
|
const e = await this.receiveMsg();
|
|
3311
3305
|
if (e.type !== "open") {
|
|
3312
3306
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3313
|
-
return
|
|
3307
|
+
return D.decode(e.error);
|
|
3314
3308
|
}
|
|
3315
3309
|
return null;
|
|
3316
3310
|
}
|
|
@@ -3326,7 +3320,7 @@ class Jr {
|
|
|
3326
3320
|
const e = await this.receiveMsg();
|
|
3327
3321
|
if (e.type === "close") {
|
|
3328
3322
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
3329
|
-
if (this.serverClosed =
|
|
3323
|
+
if (this.serverClosed = D.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
|
|
3330
3324
|
return [null, this.serverClosed];
|
|
3331
3325
|
}
|
|
3332
3326
|
return [this.resSchema.parse(e.payload), null];
|
|
@@ -3359,20 +3353,20 @@ class Jr {
|
|
|
3359
3353
|
this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
|
|
3360
3354
|
}
|
|
3361
3355
|
onMessage(e) {
|
|
3362
|
-
this.addMessage(this.codec.decode(e.data,
|
|
3356
|
+
this.addMessage(this.codec.decode(e.data, Zr));
|
|
3363
3357
|
}
|
|
3364
3358
|
onClose(e) {
|
|
3365
3359
|
this.addMessage({
|
|
3366
3360
|
type: "close",
|
|
3367
3361
|
error: {
|
|
3368
|
-
type: e.code ===
|
|
3362
|
+
type: e.code === Gr ? Y.TYPE : q.TYPE,
|
|
3369
3363
|
data: ""
|
|
3370
3364
|
}
|
|
3371
3365
|
});
|
|
3372
3366
|
}
|
|
3373
3367
|
}
|
|
3374
|
-
const
|
|
3375
|
-
class
|
|
3368
|
+
const zr = "freighterctx", Gr = 1e3;
|
|
3369
|
+
class ce extends Je {
|
|
3376
3370
|
baseUrl;
|
|
3377
3371
|
encoder;
|
|
3378
3372
|
secure;
|
|
@@ -3386,43 +3380,43 @@ class de extends Xe {
|
|
|
3386
3380
|
super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
|
|
3387
3381
|
}
|
|
3388
3382
|
withCodec(e) {
|
|
3389
|
-
const t = new
|
|
3383
|
+
const t = new ce(this.baseUrl, e, this.secure);
|
|
3390
3384
|
return t.use(...this.middleware), t;
|
|
3391
3385
|
}
|
|
3392
3386
|
/** Implements the StreamClient interface. */
|
|
3393
3387
|
async stream(e, t, n) {
|
|
3394
3388
|
let i;
|
|
3395
|
-
const [,
|
|
3389
|
+
const [, o] = await this.executeMiddleware(
|
|
3396
3390
|
{ target: e, protocol: "websocket", params: {}, role: "client" },
|
|
3397
3391
|
async (c) => {
|
|
3398
3392
|
const d = new WebSocket(this.buildURL(e, c)), w = { ...c, params: {} };
|
|
3399
|
-
d.binaryType =
|
|
3393
|
+
d.binaryType = ce.MESSAGE_TYPE;
|
|
3400
3394
|
const h = await this.wrapSocket(d, t, n);
|
|
3401
3395
|
return h instanceof Error ? [w, h] : (i = h, [w, null]);
|
|
3402
3396
|
}
|
|
3403
3397
|
);
|
|
3404
|
-
if (
|
|
3398
|
+
if (o != null) throw o;
|
|
3405
3399
|
return i;
|
|
3406
3400
|
}
|
|
3407
3401
|
buildURL(e, t) {
|
|
3408
|
-
const n =
|
|
3402
|
+
const n = kr(
|
|
3409
3403
|
{
|
|
3410
|
-
[
|
|
3404
|
+
[Ke]: this.encoder.contentType,
|
|
3411
3405
|
...t.params
|
|
3412
3406
|
},
|
|
3413
|
-
|
|
3407
|
+
zr
|
|
3414
3408
|
);
|
|
3415
3409
|
return this.baseUrl.child(e).toString() + n;
|
|
3416
3410
|
}
|
|
3417
3411
|
async wrapSocket(e, t, n) {
|
|
3418
3412
|
return await new Promise((i) => {
|
|
3419
3413
|
e.onopen = () => {
|
|
3420
|
-
const
|
|
3421
|
-
|
|
3422
|
-
c != null ? i(c) : i(
|
|
3414
|
+
const o = new Wr(e, this.encoder, t, n);
|
|
3415
|
+
o.receiveOpenAck().then((c) => {
|
|
3416
|
+
c != null ? i(c) : i(o);
|
|
3423
3417
|
}).catch((c) => i(c));
|
|
3424
|
-
}, e.onerror = (
|
|
3425
|
-
const c =
|
|
3418
|
+
}, e.onerror = (o) => {
|
|
3419
|
+
const c = o;
|
|
3426
3420
|
i(new Error(c.message));
|
|
3427
3421
|
};
|
|
3428
3422
|
});
|
|
@@ -3430,10 +3424,10 @@ class de extends Xe {
|
|
|
3430
3424
|
}
|
|
3431
3425
|
export {
|
|
3432
3426
|
Y as EOF,
|
|
3433
|
-
|
|
3427
|
+
Hr as HTTPClient,
|
|
3434
3428
|
q as StreamClosed,
|
|
3435
3429
|
F as Unreachable,
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3430
|
+
ce as WebSocketClient,
|
|
3431
|
+
Kr as sendRequired,
|
|
3432
|
+
Jr as unaryWithBreaker
|
|
3439
3433
|
};
|