@synnaxlabs/freighter 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors.d.ts +3 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/freighter.cjs +12 -12
- package/dist/freighter.js +506 -407
- package/dist/http.d.ts.map +1 -1
- package/dist/websocket.d.ts.map +1 -1
- package/package.json +15 -17
- package/src/errors.spec.ts +2 -6
- package/src/errors.ts +7 -18
- package/src/http.ts +2 -2
- package/src/websocket.spec.ts +3 -4
- package/src/websocket.ts +2 -2
package/dist/freighter.js
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (r, e, t) =>
|
|
1
|
+
var lt = Object.defineProperty;
|
|
2
|
+
var ht = (r, e, t) => e in r ? lt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var p = (r, e, t) => ht(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { z as i } from "zod";
|
|
5
|
-
const
|
|
5
|
+
const ft = (r) => {
|
|
6
6
|
const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
7
|
-
return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() ? e : e[0].toLowerCase() + e.slice(1);
|
|
8
|
-
},
|
|
7
|
+
return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
|
|
8
|
+
}, qe = (r) => {
|
|
9
9
|
const e = (t, n = de) => {
|
|
10
10
|
if (typeof t == "string") return r(t);
|
|
11
11
|
if (Array.isArray(t)) return t.map((c) => e(c, n));
|
|
12
|
-
if (!
|
|
13
|
-
n =
|
|
12
|
+
if (!ce(t)) return t;
|
|
13
|
+
n = pt(n);
|
|
14
14
|
const s = {}, a = t;
|
|
15
15
|
return Object.keys(a).forEach((c) => {
|
|
16
|
-
let
|
|
17
|
-
const
|
|
18
|
-
n.recursive && (
|
|
16
|
+
let f = a[c];
|
|
17
|
+
const d = r(c);
|
|
18
|
+
n.recursive && (ce(f) ? Ie(f, n.keepTypesOnRecursion) || (f = e(f, n)) : n.recursiveInArray && Se(f) && (f = [...f].map((y) => {
|
|
19
19
|
let T = y;
|
|
20
|
-
return
|
|
21
|
-
}))), s[
|
|
20
|
+
return ce(y) ? Ie(T, n.keepTypesOnRecursion) || (T = e(y, n)) : Se(y) && (T = e({ key: y }, n).key), T;
|
|
21
|
+
}))), s[d] = f;
|
|
22
22
|
}), s;
|
|
23
23
|
};
|
|
24
24
|
return e;
|
|
25
|
-
},
|
|
25
|
+
}, We = qe(ft), dt = (r) => (
|
|
26
|
+
// Don't convert the first character and don't convert a character that is after a
|
|
27
|
+
// non-alphanumeric character
|
|
28
|
+
r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`)
|
|
29
|
+
), gt = qe(dt), de = {
|
|
26
30
|
recursive: !0,
|
|
27
31
|
recursiveInArray: !0,
|
|
28
32
|
keepTypesOnRecursion: [Number, String, Uint8Array]
|
|
29
|
-
},
|
|
30
|
-
var
|
|
31
|
-
let
|
|
33
|
+
}, pt = (r = de) => (r.recursive == null ? r = de : r.recursiveInArray ?? (r.recursiveInArray = !1), r), Se = (r) => r != null && Array.isArray(r), ce = (r) => r != null && typeof r == "object" && !Array.isArray(r), Ie = (r, e) => (e || []).some((t) => r instanceof t), Ve = (r) => r != null && typeof r == "object" && !Array.isArray(r);
|
|
34
|
+
var yt = Object.defineProperty, mt = (r, e, t) => e in r ? yt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Q = (r, e, t) => mt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
35
|
+
let wt = class {
|
|
32
36
|
constructor() {
|
|
33
|
-
|
|
37
|
+
Q(this, "contentType", "application/json"), Q(this, "decoder"), Q(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
|
|
34
38
|
}
|
|
35
39
|
encode(e) {
|
|
36
40
|
return this.encoder.encode(this.encodeString(e)).buffer;
|
|
@@ -39,18 +43,18 @@ let ft = class {
|
|
|
39
43
|
return this.decodeString(this.decoder.decode(e), t);
|
|
40
44
|
}
|
|
41
45
|
decodeString(e, t) {
|
|
42
|
-
const n = JSON.parse(e), s =
|
|
46
|
+
const n = JSON.parse(e), s = We(n);
|
|
43
47
|
return t != null ? t.parse(s) : s;
|
|
44
48
|
}
|
|
45
49
|
encodeString(e) {
|
|
46
|
-
const t =
|
|
47
|
-
return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) :
|
|
50
|
+
const t = gt(e);
|
|
51
|
+
return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) : Ve(s) && "encode_value" in s ? typeof s.value == "bigint" ? s.value.toString() : s.value : typeof s == "bigint" ? s.toString() : s);
|
|
48
52
|
}
|
|
49
53
|
static registerCustomType() {
|
|
50
54
|
}
|
|
51
|
-
},
|
|
55
|
+
}, bt = class {
|
|
52
56
|
constructor() {
|
|
53
|
-
|
|
57
|
+
Q(this, "contentType", "text/csv");
|
|
54
58
|
}
|
|
55
59
|
encode(e) {
|
|
56
60
|
const t = this.encodeString(e);
|
|
@@ -61,7 +65,7 @@ let ft = class {
|
|
|
61
65
|
return this.decodeString(n, t);
|
|
62
66
|
}
|
|
63
67
|
encodeString(e) {
|
|
64
|
-
if (!Array.isArray(e) || e.length === 0 || !
|
|
68
|
+
if (!Array.isArray(e) || e.length === 0 || !Ve(e[0]))
|
|
65
69
|
throw new Error("Payload must be an array of objects");
|
|
66
70
|
const t = Object.keys(e[0]), n = [t.join(",")];
|
|
67
71
|
return e.forEach((s) => {
|
|
@@ -72,16 +76,16 @@ let ft = class {
|
|
|
72
76
|
}
|
|
73
77
|
decodeString(e, t) {
|
|
74
78
|
const [n, ...s] = e.trim().split(`
|
|
75
|
-
`).map((
|
|
79
|
+
`).map((f) => f.trim());
|
|
76
80
|
if (n.length === 0)
|
|
77
81
|
return t != null ? t.parse({}) : {};
|
|
78
|
-
const a = n.split(",").map((
|
|
79
|
-
return a.forEach((
|
|
80
|
-
c[
|
|
81
|
-
}), s.forEach((
|
|
82
|
-
const
|
|
82
|
+
const a = n.split(",").map((f) => f.trim()), c = {};
|
|
83
|
+
return a.forEach((f) => {
|
|
84
|
+
c[f] = [];
|
|
85
|
+
}), s.forEach((f) => {
|
|
86
|
+
const d = f.split(",").map((y) => y.trim());
|
|
83
87
|
a.forEach((y, T) => {
|
|
84
|
-
const l = this.parseValue(
|
|
88
|
+
const l = this.parseValue(d[T]);
|
|
85
89
|
l != null && c[y].push(l);
|
|
86
90
|
});
|
|
87
91
|
}), t != null ? t.parse(c) : c;
|
|
@@ -93,9 +97,9 @@ let ft = class {
|
|
|
93
97
|
}
|
|
94
98
|
static registerCustomType() {
|
|
95
99
|
}
|
|
96
|
-
},
|
|
100
|
+
}, Tt = class {
|
|
97
101
|
constructor() {
|
|
98
|
-
|
|
102
|
+
Q(this, "contentType", "text/plain");
|
|
99
103
|
}
|
|
100
104
|
encode(e) {
|
|
101
105
|
return new TextEncoder().encode(e).buffer;
|
|
@@ -105,62 +109,65 @@ let ft = class {
|
|
|
105
109
|
return t != null ? t.parse(n) : n;
|
|
106
110
|
}
|
|
107
111
|
};
|
|
108
|
-
const
|
|
109
|
-
new
|
|
110
|
-
new
|
|
111
|
-
const
|
|
112
|
+
const ee = new wt();
|
|
113
|
+
new bt();
|
|
114
|
+
new Tt();
|
|
115
|
+
const ae = i.tuple([i.number(), i.number()]);
|
|
112
116
|
i.tuple([i.bigint(), i.bigint()]);
|
|
113
|
-
const
|
|
117
|
+
const ze = i.object({ width: i.number(), height: i.number() }), Ot = i.object({
|
|
114
118
|
signedWidth: i.number(),
|
|
115
119
|
signedHeight: i.number()
|
|
116
|
-
}),
|
|
117
|
-
i.enum(
|
|
118
|
-
const
|
|
119
|
-
i.enum(
|
|
120
|
-
const
|
|
121
|
-
i.enum(
|
|
122
|
-
const
|
|
123
|
-
i.enum(
|
|
124
|
-
const
|
|
125
|
-
i.enum(
|
|
126
|
-
const
|
|
127
|
-
i.union([
|
|
128
|
-
i.union([
|
|
129
|
-
i.union([
|
|
130
|
-
i.union([
|
|
131
|
-
const
|
|
120
|
+
}), vt = ["width", "height"];
|
|
121
|
+
i.enum(vt);
|
|
122
|
+
const St = ["start", "center", "end"], It = ["signedWidth", "signedHeight"];
|
|
123
|
+
i.enum(It);
|
|
124
|
+
const se = i.object({ x: i.number(), y: i.number() }), Nt = i.object({ clientX: i.number(), clientY: i.number() }), Et = ["x", "y"], Ze = i.enum(Et), Je = ["top", "right", "bottom", "left"];
|
|
125
|
+
i.enum(Je);
|
|
126
|
+
const At = ["left", "right"], He = i.enum(At), xt = ["top", "bottom"], Ke = i.enum(xt), Xe = ["center"], Ne = i.enum(Xe), Mt = [...Je, ...Xe], Qe = i.enum(Mt);
|
|
127
|
+
i.enum(St);
|
|
128
|
+
const $t = ["first", "last"];
|
|
129
|
+
i.enum($t);
|
|
130
|
+
const Bt = i.object({ lower: i.number(), upper: i.number() }), Rt = i.object({ lower: i.bigint(), upper: i.bigint() });
|
|
131
|
+
i.union([Bt, ae]);
|
|
132
|
+
i.union([Rt, ae]);
|
|
133
|
+
i.union([Ze, Qe]);
|
|
134
|
+
i.union([Ze, Qe, i.instanceof(String)]);
|
|
135
|
+
const Ut = (r) => typeof r == "bigint" || r instanceof BigInt, F = (r, e) => Ut(r) ? r.valueOf() * BigInt(e.valueOf()) : r.valueOf() * Number(e.valueOf()), k = (r, e) => {
|
|
132
136
|
const t = {};
|
|
133
137
|
if (typeof r == "number" || typeof r == "bigint")
|
|
134
138
|
e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
|
|
135
139
|
else if (Array.isArray(r)) {
|
|
136
140
|
if (r.length !== 2) throw new Error("bounds: expected array of length 2");
|
|
137
141
|
[t.lower, t.upper] = r;
|
|
138
|
-
} else return
|
|
139
|
-
return
|
|
140
|
-
},
|
|
142
|
+
} else return Ee(r);
|
|
143
|
+
return Ee(t);
|
|
144
|
+
}, Ee = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, Ae = (r, e) => {
|
|
145
|
+
const t = k(r);
|
|
146
|
+
return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
|
|
147
|
+
};
|
|
141
148
|
i.object({
|
|
142
|
-
x:
|
|
143
|
-
y:
|
|
149
|
+
x: He.or(Ne),
|
|
150
|
+
y: Ke.or(Ne)
|
|
144
151
|
});
|
|
145
|
-
const
|
|
152
|
+
const Ct = i.object({ x: He, y: Ke }), Dt = Object.freeze({ x: "left", y: "top" }), Pt = (r, e) => r.x === e.x && r.y === e.y, xe = i.union([
|
|
146
153
|
i.number(),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
]),
|
|
154
|
+
se,
|
|
155
|
+
ae,
|
|
156
|
+
ze,
|
|
157
|
+
Ot,
|
|
158
|
+
Nt
|
|
159
|
+
]), Lt = (r, e) => {
|
|
153
160
|
if (typeof r == "string") {
|
|
154
161
|
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
155
162
|
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
156
163
|
}
|
|
157
164
|
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 };
|
|
158
|
-
},
|
|
165
|
+
}, Me = Object.freeze({ x: 0, y: 0 }), _ = i.union([i.number(), i.string()]);
|
|
159
166
|
i.object({
|
|
160
|
-
top:
|
|
161
|
-
left:
|
|
162
|
-
width:
|
|
163
|
-
height:
|
|
167
|
+
top: _,
|
|
168
|
+
left: _,
|
|
169
|
+
width: _,
|
|
170
|
+
height: _
|
|
164
171
|
});
|
|
165
172
|
i.object({
|
|
166
173
|
left: i.number(),
|
|
@@ -169,15 +176,15 @@ i.object({
|
|
|
169
176
|
bottom: i.number()
|
|
170
177
|
});
|
|
171
178
|
i.object({
|
|
172
|
-
one:
|
|
173
|
-
two:
|
|
174
|
-
root:
|
|
179
|
+
one: se,
|
|
180
|
+
two: se,
|
|
181
|
+
root: Ct
|
|
175
182
|
});
|
|
176
|
-
const
|
|
183
|
+
const be = (r, e, t = 0, n = 0, s) => {
|
|
177
184
|
const a = {
|
|
178
|
-
one: { ...
|
|
179
|
-
two: { ...
|
|
180
|
-
root: s ??
|
|
185
|
+
one: { ...Me },
|
|
186
|
+
two: { ...Me },
|
|
187
|
+
root: s ?? Dt
|
|
181
188
|
};
|
|
182
189
|
if (typeof r == "number") {
|
|
183
190
|
if (typeof e != "number")
|
|
@@ -191,71 +198,93 @@ const ye = (r, e, t = 0, n = 0, s) => {
|
|
|
191
198
|
x: a.one.x + e.signedWidth,
|
|
192
199
|
y: a.one.y + e.signedHeight
|
|
193
200
|
} : a.two = e, a));
|
|
194
|
-
}, ce = (r) => {
|
|
195
|
-
const e = ye(r);
|
|
196
|
-
return { lower: e.one.x, upper: e.two.x };
|
|
197
201
|
}, le = (r) => {
|
|
198
|
-
const e =
|
|
202
|
+
const e = be(r);
|
|
203
|
+
return { lower: e.one.x, upper: e.two.x };
|
|
204
|
+
}, he = (r) => {
|
|
205
|
+
const e = be(r);
|
|
199
206
|
return { lower: e.one.y, upper: e.two.y };
|
|
200
|
-
},
|
|
201
|
-
var
|
|
202
|
-
const
|
|
203
|
-
i.object({ offset:
|
|
204
|
-
const
|
|
207
|
+
}, Yt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
|
|
208
|
+
var kt = Object.defineProperty, jt = (r, e, t) => e in r ? kt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e, t) => jt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
209
|
+
const Ft = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
210
|
+
i.object({ offset: xe, scale: xe });
|
|
211
|
+
const Gt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
205
212
|
e,
|
|
206
213
|
s ? n - r : n + r
|
|
207
|
-
],
|
|
214
|
+
], qt = (r) => (e, t, n, s) => [
|
|
208
215
|
e,
|
|
209
216
|
s ? n / r : n * r
|
|
210
|
-
],
|
|
217
|
+
], Wt = (r) => (e, t, n) => {
|
|
211
218
|
if (e === null) return [r, n];
|
|
212
|
-
const { lower: s, upper: a } = e, { lower: c, upper:
|
|
213
|
-
if (t === "dimension") return [r, n * (y /
|
|
214
|
-
const T = (n - s) * (y /
|
|
219
|
+
const { lower: s, upper: a } = e, { lower: c, upper: f } = r, d = a - s, y = f - c;
|
|
220
|
+
if (t === "dimension") return [r, n * (y / d)];
|
|
221
|
+
const T = (n - s) * (y / d) + c;
|
|
215
222
|
return [r, T];
|
|
216
|
-
},
|
|
223
|
+
}, Vt = (r) => (e, t, n) => [r, n], zt = () => (r, e, t) => {
|
|
217
224
|
if (r === null) throw new Error("cannot invert without bounds");
|
|
218
225
|
if (e === "dimension") return [r, t];
|
|
219
226
|
const { lower: n, upper: s } = r;
|
|
220
227
|
return [r, s - (t - n)];
|
|
221
|
-
},
|
|
228
|
+
}, Zt = (r) => (e, t, n) => {
|
|
222
229
|
const { lower: s, upper: a } = r;
|
|
223
|
-
return n =
|
|
224
|
-
},
|
|
230
|
+
return n = Ft(n, s, a), [e, n];
|
|
231
|
+
}, ge = class z {
|
|
225
232
|
constructor() {
|
|
226
233
|
D(this, "ops", []), D(this, "currBounds", null), D(this, "currType", null), D(this, "reversed", !1), this.ops = [];
|
|
227
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* @returns a new scale with a translation as its first operation. Any number provided
|
|
237
|
+
* to the {@link pos} operation on the scale will be translated by the specified value.
|
|
238
|
+
* @param value - The amount to translate by.
|
|
239
|
+
*/
|
|
228
240
|
static translate(e) {
|
|
229
|
-
return new
|
|
241
|
+
return new z().translate(e);
|
|
230
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
245
|
+
* to the {@link pos} or {@link dim} operation will be multiplied by the specified value.
|
|
246
|
+
* @param value - The amount to translate by.
|
|
247
|
+
*/
|
|
231
248
|
static magnify(e) {
|
|
232
|
-
return new
|
|
249
|
+
return new z().magnify(e);
|
|
233
250
|
}
|
|
234
251
|
static scale(e, t) {
|
|
235
|
-
return new
|
|
252
|
+
return new z().scale(e, t);
|
|
236
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* @returns a copy of the scale with a translation as its next operation. Any
|
|
256
|
+
* number provided to the {@link pos} method on the scale will be translated by the
|
|
257
|
+
* specified value.
|
|
258
|
+
* @param value - The amount to translate by.
|
|
259
|
+
*/
|
|
237
260
|
translate(e) {
|
|
238
|
-
const t = this.new(), n =
|
|
261
|
+
const t = this.new(), n = Gt(e);
|
|
239
262
|
return n.type = "translate", t.ops.push(n), t;
|
|
240
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* @returns a copy of the scale with a translation as its next operation. Any number
|
|
266
|
+
* provided to the {@link pos} or {@link dim} method on the scale will be multiplied
|
|
267
|
+
* by the specified value.
|
|
268
|
+
* @param value - The amount to magnify by.
|
|
269
|
+
*/
|
|
241
270
|
magnify(e) {
|
|
242
|
-
const t = this.new(), n =
|
|
271
|
+
const t = this.new(), n = qt(e);
|
|
243
272
|
return n.type = "magnify", t.ops.push(n), t;
|
|
244
273
|
}
|
|
245
274
|
scale(e, t) {
|
|
246
|
-
const n =
|
|
275
|
+
const n = k(e, t), s = this.new(), a = Wt(n);
|
|
247
276
|
return a.type = "scale", s.ops.push(a), s;
|
|
248
277
|
}
|
|
249
278
|
clamp(e, t) {
|
|
250
|
-
const n =
|
|
279
|
+
const n = k(e, t), s = this.new(), a = Zt(n);
|
|
251
280
|
return a.type = "clamp", s.ops.push(a), s;
|
|
252
281
|
}
|
|
253
282
|
reBound(e, t) {
|
|
254
|
-
const n =
|
|
283
|
+
const n = k(e, t), s = this.new(), a = Vt(n);
|
|
255
284
|
return a.type = "re-bound", s.ops.push(a), s;
|
|
256
285
|
}
|
|
257
286
|
invert() {
|
|
258
|
-
const e =
|
|
287
|
+
const e = zt();
|
|
259
288
|
e.type = "invert";
|
|
260
289
|
const t = this.new();
|
|
261
290
|
return t.ops.push(e), t;
|
|
@@ -267,7 +296,7 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
267
296
|
return this.exec("dimension", e);
|
|
268
297
|
}
|
|
269
298
|
new() {
|
|
270
|
-
const e = new
|
|
299
|
+
const e = new z();
|
|
271
300
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
272
301
|
}
|
|
273
302
|
exec(e, t) {
|
|
@@ -281,9 +310,9 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
281
310
|
e.ops.reverse();
|
|
282
311
|
const t = [];
|
|
283
312
|
return e.ops.forEach((n, s) => {
|
|
284
|
-
if (n.type === "scale" || t.some(([c,
|
|
313
|
+
if (n.type === "scale" || t.some(([c, f]) => s >= c && s <= f))
|
|
285
314
|
return;
|
|
286
|
-
const a = e.ops.findIndex((c,
|
|
315
|
+
const a = e.ops.findIndex((c, f) => c.type === "scale" && f > s);
|
|
287
316
|
a !== -1 && t.push([s, a]);
|
|
288
317
|
}), t.forEach(([n, s]) => {
|
|
289
318
|
const a = e.ops.slice(n, s);
|
|
@@ -291,35 +320,35 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
291
320
|
}), e.reversed = !e.reversed, e;
|
|
292
321
|
}
|
|
293
322
|
};
|
|
294
|
-
D(
|
|
295
|
-
let
|
|
296
|
-
const
|
|
297
|
-
constructor(e = new
|
|
323
|
+
D(ge, "IDENTITY", new ge());
|
|
324
|
+
let $e = ge;
|
|
325
|
+
const Be = class C {
|
|
326
|
+
constructor(e = new $e(), t = new $e(), n = null) {
|
|
298
327
|
D(this, "x"), D(this, "y"), D(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
|
|
299
328
|
}
|
|
300
329
|
static translate(e, t) {
|
|
301
|
-
return new
|
|
330
|
+
return new C().translate(e, t);
|
|
302
331
|
}
|
|
303
332
|
static translateX(e) {
|
|
304
|
-
return new
|
|
333
|
+
return new C().translateX(e);
|
|
305
334
|
}
|
|
306
335
|
static translateY(e) {
|
|
307
|
-
return new
|
|
336
|
+
return new C().translateY(e);
|
|
308
337
|
}
|
|
309
338
|
static clamp(e) {
|
|
310
|
-
return new
|
|
339
|
+
return new C().clamp(e);
|
|
311
340
|
}
|
|
312
341
|
static magnify(e) {
|
|
313
|
-
return new
|
|
342
|
+
return new C().magnify(e);
|
|
314
343
|
}
|
|
315
344
|
static scale(e) {
|
|
316
|
-
return new
|
|
345
|
+
return new C().scale(e);
|
|
317
346
|
}
|
|
318
347
|
static reBound(e) {
|
|
319
|
-
return new
|
|
348
|
+
return new C().reBound(e);
|
|
320
349
|
}
|
|
321
350
|
translate(e, t) {
|
|
322
|
-
const n =
|
|
351
|
+
const n = Lt(e, t), s = this.copy();
|
|
323
352
|
return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
|
|
324
353
|
}
|
|
325
354
|
translateX(e) {
|
|
@@ -336,22 +365,22 @@ const Ae = class U {
|
|
|
336
365
|
}
|
|
337
366
|
scale(e) {
|
|
338
367
|
const t = this.copy();
|
|
339
|
-
if (
|
|
368
|
+
if (Yt(e)) {
|
|
340
369
|
const n = this.currRoot;
|
|
341
|
-
return t.currRoot = e.root, n != null &&
|
|
370
|
+
return t.currRoot = e.root, n != null && !Pt(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(le(e)), t.y = t.y.scale(he(e)), t;
|
|
342
371
|
}
|
|
343
372
|
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
344
373
|
}
|
|
345
374
|
reBound(e) {
|
|
346
375
|
const t = this.copy();
|
|
347
|
-
return t.x = this.x.reBound(
|
|
376
|
+
return t.x = this.x.reBound(le(e)), t.y = this.y.reBound(he(e)), t;
|
|
348
377
|
}
|
|
349
378
|
clamp(e) {
|
|
350
379
|
const t = this.copy();
|
|
351
|
-
return t.x = this.x.clamp(
|
|
380
|
+
return t.x = this.x.clamp(le(e)), t.y = this.y.clamp(he(e)), t;
|
|
352
381
|
}
|
|
353
382
|
copy() {
|
|
354
|
-
const e = new
|
|
383
|
+
const e = new C();
|
|
355
384
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
356
385
|
}
|
|
357
386
|
reverse() {
|
|
@@ -362,7 +391,7 @@ const Ae = class U {
|
|
|
362
391
|
return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
|
|
363
392
|
}
|
|
364
393
|
box(e) {
|
|
365
|
-
return
|
|
394
|
+
return be(
|
|
366
395
|
this.pos(e.one),
|
|
367
396
|
this.pos(e.two),
|
|
368
397
|
0,
|
|
@@ -371,9 +400,9 @@ const Ae = class U {
|
|
|
371
400
|
);
|
|
372
401
|
}
|
|
373
402
|
};
|
|
374
|
-
D(
|
|
375
|
-
const
|
|
376
|
-
const t =
|
|
403
|
+
D(Be, "IDENTITY", new Be());
|
|
404
|
+
const Jt = (r) => r != null && typeof r == "object" && "toString" in r, Ht = (r, e = !1) => {
|
|
405
|
+
const t = Jt(r) ? "stringer" : typeof r;
|
|
377
406
|
let n;
|
|
378
407
|
switch (t) {
|
|
379
408
|
case "string":
|
|
@@ -397,18 +426,18 @@ const Gt = (r) => r != null && typeof r == "object" && "toString" in r, qt = (r,
|
|
|
397
426
|
default:
|
|
398
427
|
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
399
428
|
}
|
|
400
|
-
return e ?
|
|
401
|
-
},
|
|
402
|
-
i.union([
|
|
403
|
-
const
|
|
404
|
-
var
|
|
405
|
-
let
|
|
429
|
+
return e ? Kt(n) : n;
|
|
430
|
+
}, Kt = (r) => (e, t) => r(t, e), Xt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
|
|
431
|
+
i.union([ze, Xt, se, ae]);
|
|
432
|
+
const Qt = i.bigint().or(i.string().transform(BigInt));
|
|
433
|
+
var _t = Object.defineProperty, er = (r, e, t) => e in r ? _t(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => er(r, typeof e != "symbol" ? e + "" : e, t);
|
|
434
|
+
let tr = (r, e = 21) => (t = e) => {
|
|
406
435
|
let n = "", s = t;
|
|
407
436
|
for (; s--; )
|
|
408
437
|
n += r[Math.random() * r.length | 0];
|
|
409
438
|
return n;
|
|
410
439
|
};
|
|
411
|
-
const
|
|
440
|
+
const rr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", nr = tr(rr, 11), sr = i.enum(["static", "dynamic"]), _e = (r, e) => {
|
|
412
441
|
const t = new O(e);
|
|
413
442
|
if (![
|
|
414
443
|
S.DAY,
|
|
@@ -449,10 +478,10 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
|
|
|
449
478
|
}
|
|
450
479
|
static parseTimeString(e, t = "UTC") {
|
|
451
480
|
const [n, s, a] = e.split(":");
|
|
452
|
-
let c = "00",
|
|
453
|
-
a != null && ([c,
|
|
454
|
-
let
|
|
455
|
-
return t === "local" && (
|
|
481
|
+
let c = "00", f = "00";
|
|
482
|
+
a != null && ([c, f] = a.split("."));
|
|
483
|
+
let d = h.hours(parseInt(n ?? "00")).add(h.minutes(parseInt(s ?? "00"))).add(h.seconds(parseInt(c ?? "00"))).add(h.milliseconds(parseInt(f ?? "00")));
|
|
484
|
+
return t === "local" && (d = d.add(h.utcOffset)), d.valueOf();
|
|
456
485
|
}
|
|
457
486
|
static parseDateTimeString(e, t = "UTC") {
|
|
458
487
|
if (!e.includes("/") && !e.includes("-"))
|
|
@@ -538,7 +567,7 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
|
|
|
538
567
|
* valid, regardless of the TimeStamp order.
|
|
539
568
|
*/
|
|
540
569
|
range(e) {
|
|
541
|
-
return new
|
|
570
|
+
return new Te(this, e).makeValid();
|
|
542
571
|
}
|
|
543
572
|
/**
|
|
544
573
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -640,7 +669,7 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
|
|
|
640
669
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
641
670
|
*/
|
|
642
671
|
remainder(e) {
|
|
643
|
-
return
|
|
672
|
+
return _e(this, e);
|
|
644
673
|
}
|
|
645
674
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
646
675
|
get isToday() {
|
|
@@ -724,6 +753,12 @@ const w = class g {
|
|
|
724
753
|
constructor(e) {
|
|
725
754
|
u(this, "value"), u(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
|
|
726
755
|
}
|
|
756
|
+
static fromSeconds(e) {
|
|
757
|
+
return e instanceof g ? e : e instanceof Re ? e.period : e instanceof O ? new g(e) : ["number", "bigint"].includes(typeof e) ? g.seconds(e) : new g(e);
|
|
758
|
+
}
|
|
759
|
+
static fromMilliseconds(e) {
|
|
760
|
+
return e instanceof g ? e : e instanceof Re ? e.period : e instanceof O ? new g(e) : ["number", "bigint"].includes(typeof e) ? g.milliseconds(e) : new g(e);
|
|
761
|
+
}
|
|
727
762
|
encode() {
|
|
728
763
|
return this.value.toString();
|
|
729
764
|
}
|
|
@@ -743,7 +778,7 @@ const w = class g {
|
|
|
743
778
|
return this.valueOf() >= new g(e).valueOf();
|
|
744
779
|
}
|
|
745
780
|
remainder(e) {
|
|
746
|
-
return
|
|
781
|
+
return _e(this, e);
|
|
747
782
|
}
|
|
748
783
|
truncate(e) {
|
|
749
784
|
return new g(
|
|
@@ -751,9 +786,9 @@ const w = class g {
|
|
|
751
786
|
);
|
|
752
787
|
}
|
|
753
788
|
toString() {
|
|
754
|
-
const e = this.truncate(g.DAY), t = this.truncate(g.HOUR), n = this.truncate(g.MINUTE), s = this.truncate(g.SECOND), a = this.truncate(g.MILLISECOND), c = this.truncate(g.MICROSECOND),
|
|
789
|
+
const e = this.truncate(g.DAY), t = this.truncate(g.HOUR), n = this.truncate(g.MINUTE), s = this.truncate(g.SECOND), a = this.truncate(g.MILLISECOND), c = this.truncate(g.MICROSECOND), f = this.truncate(g.NANOSECOND), d = e, y = t.sub(e), T = n.sub(t), l = s.sub(n), E = a.sub(s), R = c.sub(a), U = f.sub(c);
|
|
755
790
|
let x = "";
|
|
756
|
-
return
|
|
791
|
+
return d.isZero || (x += `${d.days}d `), y.isZero || (x += `${y.hours}h `), T.isZero || (x += `${T.minutes}m `), l.isZero || (x += `${l.seconds}s `), E.isZero || (x += `${E.milliseconds}ms `), R.isZero || (x += `${R.microseconds}µs `), U.isZero || (x += `${U.nanoseconds}ns`), x.trim();
|
|
757
792
|
}
|
|
758
793
|
/** @returns the decimal number of days in the timespan */
|
|
759
794
|
get days() {
|
|
@@ -829,7 +864,7 @@ const w = class g {
|
|
|
829
864
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
830
865
|
*/
|
|
831
866
|
static microseconds(e = 1) {
|
|
832
|
-
return g.nanoseconds(e
|
|
867
|
+
return g.nanoseconds(F(e, 1e3));
|
|
833
868
|
}
|
|
834
869
|
/**
|
|
835
870
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -838,7 +873,7 @@ const w = class g {
|
|
|
838
873
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
839
874
|
*/
|
|
840
875
|
static milliseconds(e = 1) {
|
|
841
|
-
return g.microseconds(e
|
|
876
|
+
return g.microseconds(F(e, 1e3));
|
|
842
877
|
}
|
|
843
878
|
/**
|
|
844
879
|
* Creates a TimeSpan representing the given number of seconds.
|
|
@@ -847,7 +882,7 @@ const w = class g {
|
|
|
847
882
|
* @returns A TimeSpan representing the given number of seconds.
|
|
848
883
|
*/
|
|
849
884
|
static seconds(e = 1) {
|
|
850
|
-
return g.milliseconds(e
|
|
885
|
+
return g.milliseconds(F(e, 1e3));
|
|
851
886
|
}
|
|
852
887
|
/**
|
|
853
888
|
* Creates a TimeSpan representing the given number of minutes.
|
|
@@ -855,8 +890,8 @@ const w = class g {
|
|
|
855
890
|
* @param value - The number of minutes.
|
|
856
891
|
* @returns A TimeSpan representing the given number of minutes.
|
|
857
892
|
*/
|
|
858
|
-
static minutes(e) {
|
|
859
|
-
return g.seconds(e
|
|
893
|
+
static minutes(e = 1) {
|
|
894
|
+
return g.seconds(F(e, 60));
|
|
860
895
|
}
|
|
861
896
|
/**
|
|
862
897
|
* Creates a TimeSpan representing the given number of hours.
|
|
@@ -865,7 +900,7 @@ const w = class g {
|
|
|
865
900
|
* @returns A TimeSpan representing the given number of hours.
|
|
866
901
|
*/
|
|
867
902
|
static hours(e) {
|
|
868
|
-
return g.minutes(e
|
|
903
|
+
return g.minutes(F(e, 60));
|
|
869
904
|
}
|
|
870
905
|
/**
|
|
871
906
|
* Creates a TimeSpan representing the given number of days.
|
|
@@ -874,7 +909,7 @@ const w = class g {
|
|
|
874
909
|
* @returns A TimeSpan representing the given number of days.
|
|
875
910
|
*/
|
|
876
911
|
static days(e) {
|
|
877
|
-
return g.hours(e
|
|
912
|
+
return g.hours(F(e, 24));
|
|
878
913
|
}
|
|
879
914
|
};
|
|
880
915
|
u(w, "NANOSECOND", w.nanoseconds(1)), /** A microsecond. */
|
|
@@ -895,7 +930,7 @@ u(w, "z", i.union([
|
|
|
895
930
|
i.instanceof(w)
|
|
896
931
|
]));
|
|
897
932
|
let S = w;
|
|
898
|
-
const
|
|
933
|
+
const Z = class te extends Number {
|
|
899
934
|
constructor(e) {
|
|
900
935
|
e instanceof Number ? super(e.valueOf()) : super(e);
|
|
901
936
|
}
|
|
@@ -905,7 +940,7 @@ const Q = class ee extends Number {
|
|
|
905
940
|
}
|
|
906
941
|
/** @returns The number of seconds in the Rate. */
|
|
907
942
|
equals(e) {
|
|
908
|
-
return this.valueOf() === new
|
|
943
|
+
return this.valueOf() === new te(e).valueOf();
|
|
909
944
|
}
|
|
910
945
|
/**
|
|
911
946
|
* Calculates the period of the Rate as a TimeSpan.
|
|
@@ -960,7 +995,7 @@ const Q = class ee extends Number {
|
|
|
960
995
|
* @returns A Rate representing the given number of Hz.
|
|
961
996
|
*/
|
|
962
997
|
static hz(e) {
|
|
963
|
-
return new
|
|
998
|
+
return new te(e);
|
|
964
999
|
}
|
|
965
1000
|
/**
|
|
966
1001
|
* Creates a Rate representing the given number of kHz.
|
|
@@ -969,14 +1004,15 @@ const Q = class ee extends Number {
|
|
|
969
1004
|
* @returns A Rate representing the given number of kHz.
|
|
970
1005
|
*/
|
|
971
1006
|
static khz(e) {
|
|
972
|
-
return
|
|
1007
|
+
return te.hz(e * 1e3);
|
|
973
1008
|
}
|
|
974
1009
|
};
|
|
975
|
-
u(
|
|
976
|
-
i.number().transform((r) => new
|
|
977
|
-
i.instanceof(Number).transform((r) => new
|
|
978
|
-
i.instanceof(
|
|
1010
|
+
u(Z, "z", i.union([
|
|
1011
|
+
i.number().transform((r) => new Z(r)),
|
|
1012
|
+
i.instanceof(Number).transform((r) => new Z(r)),
|
|
1013
|
+
i.instanceof(Z)
|
|
979
1014
|
]));
|
|
1015
|
+
let Re = Z;
|
|
980
1016
|
const I = class extends Number {
|
|
981
1017
|
/**
|
|
982
1018
|
* Creates a Density representing the given number of bytes per value.
|
|
@@ -992,7 +1028,7 @@ const I = class extends Number {
|
|
|
992
1028
|
return e.valueOf() / this.valueOf();
|
|
993
1029
|
}
|
|
994
1030
|
size(e) {
|
|
995
|
-
return new
|
|
1031
|
+
return new pe(e * this.valueOf());
|
|
996
1032
|
}
|
|
997
1033
|
};
|
|
998
1034
|
u(I, "UNKNOWN", new I(0)), /** 128 bits per value. */
|
|
@@ -1007,7 +1043,7 @@ u(I, "z", i.union([
|
|
|
1007
1043
|
i.instanceof(I)
|
|
1008
1044
|
]));
|
|
1009
1045
|
let A = I;
|
|
1010
|
-
const M = class
|
|
1046
|
+
const M = class re {
|
|
1011
1047
|
/**
|
|
1012
1048
|
* Creates a TimeRange from the given start and end TimeStamps.
|
|
1013
1049
|
*
|
|
@@ -1057,7 +1093,7 @@ const M = class te {
|
|
|
1057
1093
|
* @returns A TimeRange with the start and end swapped.
|
|
1058
1094
|
*/
|
|
1059
1095
|
swap() {
|
|
1060
|
-
return new
|
|
1096
|
+
return new re(this.end, this.start);
|
|
1061
1097
|
}
|
|
1062
1098
|
/**
|
|
1063
1099
|
* Checks if the TimeRange is equal to the given TimeRange.
|
|
@@ -1095,10 +1131,10 @@ const M = class te {
|
|
|
1095
1131
|
return n < 0 && (n = -n), s < 0 && (s = -s), n <= t.valueOf() && s <= t.valueOf();
|
|
1096
1132
|
}
|
|
1097
1133
|
contains(e) {
|
|
1098
|
-
return e instanceof
|
|
1134
|
+
return e instanceof re ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
|
|
1099
1135
|
}
|
|
1100
1136
|
boundBy(e) {
|
|
1101
|
-
const t = new
|
|
1137
|
+
const t = new re(this.start, this.end);
|
|
1102
1138
|
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;
|
|
1103
1139
|
}
|
|
1104
1140
|
};
|
|
@@ -1109,18 +1145,17 @@ u(M, "z", i.union([
|
|
|
1109
1145
|
i.object({ start: O.z, end: O.z }).transform((r) => new M(r.start, r.end)),
|
|
1110
1146
|
i.instanceof(M)
|
|
1111
1147
|
]));
|
|
1112
|
-
let
|
|
1148
|
+
let Te = M;
|
|
1113
1149
|
const o = class $ extends String {
|
|
1114
1150
|
constructor(e) {
|
|
1115
1151
|
if (e instanceof $ || typeof e == "string" || typeof e.valueOf() == "string") {
|
|
1116
1152
|
super(e.valueOf());
|
|
1117
1153
|
return;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1154
|
+
}
|
|
1155
|
+
const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
|
|
1156
|
+
if (t != null) {
|
|
1157
|
+
super(t.valueOf());
|
|
1158
|
+
return;
|
|
1124
1159
|
}
|
|
1125
1160
|
throw super($.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
|
|
1126
1161
|
}
|
|
@@ -1308,9 +1343,9 @@ const N = class v extends Number {
|
|
|
1308
1343
|
return this.valueOf() / v.TERABYTE.valueOf();
|
|
1309
1344
|
}
|
|
1310
1345
|
toString() {
|
|
1311
|
-
const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), s = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e,
|
|
1346
|
+
const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), s = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e, f = t.sub(e), d = n.sub(t), y = s.sub(n), T = a.sub(s);
|
|
1312
1347
|
let l = "";
|
|
1313
|
-
return c.isZero || (l += `${c.terabytes}TB `),
|
|
1348
|
+
return c.isZero || (l += `${c.terabytes}TB `), f.isZero || (l += `${f.gigabytes}GB `), d.isZero || (l += `${d.megabytes}MB `), y.isZero || (l += `${y.kilobytes}KB `), (!T.isZero || l === "") && (l += `${T.valueOf()}B`), l.trim();
|
|
1314
1349
|
}
|
|
1315
1350
|
/**
|
|
1316
1351
|
* Creates a Size from the given number of bytes.
|
|
@@ -1371,7 +1406,7 @@ u(N, "z", i.union([
|
|
|
1371
1406
|
i.number().transform((r) => new N(r)),
|
|
1372
1407
|
i.instanceof(N)
|
|
1373
1408
|
]));
|
|
1374
|
-
let
|
|
1409
|
+
let pe = N;
|
|
1375
1410
|
i.union([
|
|
1376
1411
|
i.instanceof(Uint8Array),
|
|
1377
1412
|
i.instanceof(Uint16Array),
|
|
@@ -1384,44 +1419,44 @@ i.union([
|
|
|
1384
1419
|
i.instanceof(Int32Array),
|
|
1385
1420
|
i.instanceof(BigInt64Array)
|
|
1386
1421
|
]);
|
|
1387
|
-
const
|
|
1422
|
+
const et = (r) => {
|
|
1388
1423
|
const e = typeof r;
|
|
1389
1424
|
return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof O || r instanceof S || r instanceof Date;
|
|
1390
|
-
},
|
|
1425
|
+
}, ir = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : H(t, -n).valueOf(), ar = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof cr ? !0 : et(r), P = -1, or = i.string().transform(
|
|
1391
1426
|
(r) => new Uint8Array(
|
|
1392
1427
|
atob(r).split("").map((e) => e.charCodeAt(0))
|
|
1393
1428
|
).buffer
|
|
1394
|
-
),
|
|
1429
|
+
), ur = i.union([i.null(), i.undefined()]).transform(() => new Uint8Array().buffer), ye = 10, J = class B {
|
|
1395
1430
|
constructor(e) {
|
|
1396
|
-
u(this, "key", ""), u(this, "isSynnaxSeries", !0), u(this, "dataType"), u(this, "sampleOffset"), u(this, "gl"), u(this, "_data"), u(this, "_timeRange"), u(this, "alignment", 0n), u(this, "_cachedMin"), u(this, "_cachedMax"), u(this, "writePos",
|
|
1431
|
+
u(this, "key", ""), u(this, "isSynnaxSeries", !0), u(this, "dataType"), u(this, "sampleOffset"), u(this, "gl"), u(this, "_data"), u(this, "_timeRange"), u(this, "alignment", 0n), u(this, "_cachedMin"), u(this, "_cachedMax"), u(this, "writePos", P), u(this, "_refCount", 0), u(this, "_cachedLength"), u(this, "_cachedIndexes"), ar(e) && (e = { data: e });
|
|
1397
1432
|
const {
|
|
1398
1433
|
dataType: t,
|
|
1399
1434
|
timeRange: n,
|
|
1400
1435
|
sampleOffset: s = 0,
|
|
1401
1436
|
glBufferUsage: a = "static",
|
|
1402
1437
|
alignment: c = 0n,
|
|
1403
|
-
key:
|
|
1404
|
-
} = e,
|
|
1405
|
-
if (
|
|
1406
|
-
const l =
|
|
1438
|
+
key: f = nr()
|
|
1439
|
+
} = e, d = e.data ?? [];
|
|
1440
|
+
if (d instanceof B || typeof d == "object" && "isSynnaxSeries" in d && d.isSynnaxSeries === !0) {
|
|
1441
|
+
const l = d;
|
|
1407
1442
|
this.key = l.key, this.dataType = l.dataType, this.sampleOffset = l.sampleOffset, this.gl = l.gl, this._data = l._data, this._timeRange = l._timeRange, this.alignment = l.alignment, this._cachedMin = l._cachedMin, this._cachedMax = l._cachedMax, this.writePos = l.writePos, this._refCount = l._refCount, this._cachedLength = l._cachedLength;
|
|
1408
1443
|
return;
|
|
1409
1444
|
}
|
|
1410
|
-
const y =
|
|
1445
|
+
const y = et(d), T = Array.isArray(d);
|
|
1411
1446
|
if (t != null) this.dataType = new b(t);
|
|
1412
1447
|
else {
|
|
1413
|
-
if (
|
|
1448
|
+
if (d instanceof ArrayBuffer)
|
|
1414
1449
|
throw new Error(
|
|
1415
1450
|
"cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
|
|
1416
1451
|
);
|
|
1417
1452
|
if (T || y) {
|
|
1418
|
-
let l =
|
|
1453
|
+
let l = d;
|
|
1419
1454
|
if (!y) {
|
|
1420
|
-
if (
|
|
1455
|
+
if (d.length === 0)
|
|
1421
1456
|
throw new Error(
|
|
1422
1457
|
"cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
|
|
1423
1458
|
);
|
|
1424
|
-
l =
|
|
1459
|
+
l = d[0];
|
|
1425
1460
|
}
|
|
1426
1461
|
if (typeof l == "string") this.dataType = b.STRING;
|
|
1427
1462
|
else if (typeof l == "number") this.dataType = b.FLOAT64;
|
|
@@ -1434,21 +1469,21 @@ const He = (r) => {
|
|
|
1434
1469
|
throw new Error(
|
|
1435
1470
|
`cannot infer data type of ${typeof l} when constructing a Series from a JS array`
|
|
1436
1471
|
);
|
|
1437
|
-
} else this.dataType = new b(
|
|
1472
|
+
} else this.dataType = new b(d);
|
|
1438
1473
|
}
|
|
1439
|
-
if (!T && !y) this._data =
|
|
1474
|
+
if (!T && !y) this._data = d;
|
|
1440
1475
|
else {
|
|
1441
|
-
let l = y ? [
|
|
1476
|
+
let l = y ? [d] : d;
|
|
1442
1477
|
const E = l[0];
|
|
1443
|
-
(E instanceof O || E instanceof Date || E instanceof S) && (l = l.map((R) => new O(R).valueOf())), this.dataType.equals(b.STRING) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(l.join(`
|
|
1444
|
-
`)
|
|
1478
|
+
(E instanceof O || E instanceof Date || E instanceof S) && (l = l.map((R) => new O(R).valueOf())), this.dataType.equals(b.STRING) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(`${l.join(`
|
|
1479
|
+
`)}
|
|
1445
1480
|
`)) : this.dataType.equals(b.JSON) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(
|
|
1446
|
-
l.map((R) =>
|
|
1447
|
-
`)
|
|
1481
|
+
`${l.map((R) => ee.encodeString(R)).join(`
|
|
1482
|
+
`)}
|
|
1448
1483
|
`
|
|
1449
1484
|
)) : this._data = new this.dataType.Array(l).buffer;
|
|
1450
1485
|
}
|
|
1451
|
-
this.key =
|
|
1486
|
+
this.key = f, this.alignment = c, this.sampleOffset = s ?? 0, this._timeRange = n, this.gl = {
|
|
1452
1487
|
control: null,
|
|
1453
1488
|
buffer: null,
|
|
1454
1489
|
prevBuffer: 0,
|
|
@@ -1458,7 +1493,7 @@ const He = (r) => {
|
|
|
1458
1493
|
static alloc({ capacity: e, dataType: t, ...n }) {
|
|
1459
1494
|
if (e === 0)
|
|
1460
1495
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
1461
|
-
const s = new new b(t).Array(e), a = new
|
|
1496
|
+
const s = new new b(t).Array(e), a = new B({
|
|
1462
1497
|
data: s.buffer,
|
|
1463
1498
|
dataType: t,
|
|
1464
1499
|
...n
|
|
@@ -1469,24 +1504,24 @@ const He = (r) => {
|
|
|
1469
1504
|
const s = n.spanRange(t.span(e)), a = new BigInt64Array(e);
|
|
1470
1505
|
for (let c = 0; c < e; c++)
|
|
1471
1506
|
a[c] = BigInt(n.add(t.span(c)).valueOf());
|
|
1472
|
-
return new
|
|
1507
|
+
return new B({ data: a, dataType: b.TIMESTAMP, timeRange: s });
|
|
1473
1508
|
}
|
|
1474
1509
|
get refCount() {
|
|
1475
1510
|
return this._refCount;
|
|
1476
1511
|
}
|
|
1477
1512
|
static fromStrings(e, t) {
|
|
1478
|
-
const n = new TextEncoder().encode(e.join(`
|
|
1479
|
-
`)
|
|
1513
|
+
const n = new TextEncoder().encode(`${e.join(`
|
|
1514
|
+
`)}
|
|
1480
1515
|
`);
|
|
1481
|
-
return new
|
|
1516
|
+
return new B({ data: n, dataType: b.STRING, timeRange: t });
|
|
1482
1517
|
}
|
|
1483
1518
|
static fromJSON(e, t) {
|
|
1484
1519
|
const n = new TextEncoder().encode(
|
|
1485
|
-
e.map((s) =>
|
|
1486
|
-
`)
|
|
1520
|
+
`${e.map((s) => ee.encodeString(s)).join(`
|
|
1521
|
+
`)}
|
|
1487
1522
|
`
|
|
1488
1523
|
);
|
|
1489
|
-
return new
|
|
1524
|
+
return new B({ data: n, dataType: b.JSON, timeRange: t });
|
|
1490
1525
|
}
|
|
1491
1526
|
acquire(e) {
|
|
1492
1527
|
this._refCount++, e != null && this.updateGLBuffer(e);
|
|
@@ -1508,28 +1543,39 @@ const He = (r) => {
|
|
|
1508
1543
|
write(e) {
|
|
1509
1544
|
if (!e.dataType.equals(this.dataType))
|
|
1510
1545
|
throw new Error("buffer must be of the same type as this array");
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1546
|
+
return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
|
|
1547
|
+
}
|
|
1548
|
+
writeVariable(e) {
|
|
1549
|
+
if (this.writePos === P) return 0;
|
|
1550
|
+
const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
|
|
1551
|
+
return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += n.length, this.calculateCachedLength()), n.length;
|
|
1552
|
+
}
|
|
1553
|
+
writeFixed(e) {
|
|
1554
|
+
if (this.writePos === P) return 0;
|
|
1555
|
+
const t = this.capacity - this.writePos, n = e.sub(0, t);
|
|
1556
|
+
return this.writeToUnderlyingData(n), this._cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
|
|
1557
|
+
}
|
|
1558
|
+
writeToUnderlyingData(e) {
|
|
1559
|
+
this.underlyingData.set(
|
|
1560
|
+
e.data,
|
|
1515
1561
|
this.writePos
|
|
1516
|
-
)
|
|
1562
|
+
);
|
|
1517
1563
|
}
|
|
1518
1564
|
/** @returns the underlying buffer backing this array. */
|
|
1519
1565
|
get buffer() {
|
|
1520
|
-
return this._data;
|
|
1566
|
+
return this._data instanceof ArrayBuffer || this._data instanceof SharedArrayBuffer ? this._data : this._data.buffer;
|
|
1521
1567
|
}
|
|
1522
1568
|
get underlyingData() {
|
|
1523
1569
|
return new this.dataType.Array(this._data);
|
|
1524
1570
|
}
|
|
1525
1571
|
/** @returns a native typed array with the proper data type. */
|
|
1526
1572
|
get data() {
|
|
1527
|
-
return this.writePos ===
|
|
1573
|
+
return this.writePos === P ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
1528
1574
|
}
|
|
1529
1575
|
toStrings() {
|
|
1530
1576
|
if (!this.dataType.matches(b.STRING, b.UUID))
|
|
1531
1577
|
throw new Error("cannot convert non-string series to strings");
|
|
1532
|
-
return new TextDecoder().decode(this.
|
|
1578
|
+
return new TextDecoder().decode(this.underlyingData).split(`
|
|
1533
1579
|
`).slice(0, -1);
|
|
1534
1580
|
}
|
|
1535
1581
|
toUUIDs() {
|
|
@@ -1537,7 +1583,7 @@ const He = (r) => {
|
|
|
1537
1583
|
throw new Error("cannot convert non-uuid series to uuids");
|
|
1538
1584
|
const e = b.UUID.density.valueOf(), t = Array(this.length);
|
|
1539
1585
|
for (let n = 0; n < this.length; n++) {
|
|
1540
|
-
const s = this.
|
|
1586
|
+
const s = this.underlyingData.slice(n * e, (n + 1) * e), a = Array.from(new Uint8Array(s), (c) => c.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
|
|
1541
1587
|
t[n] = a;
|
|
1542
1588
|
}
|
|
1543
1589
|
return t;
|
|
@@ -1545,8 +1591,8 @@ const He = (r) => {
|
|
|
1545
1591
|
parseJSON(e) {
|
|
1546
1592
|
if (!this.dataType.equals(b.JSON))
|
|
1547
1593
|
throw new Error("cannot convert non-string series to strings");
|
|
1548
|
-
return new TextDecoder().decode(this.
|
|
1549
|
-
`).slice(0, -1).map((t) => e.parse(
|
|
1594
|
+
return new TextDecoder().decode(this.underlyingData).split(`
|
|
1595
|
+
`).slice(0, -1).map((t) => e.parse(ee.decodeString(t)));
|
|
1550
1596
|
}
|
|
1551
1597
|
/** @returns the time range of this array. */
|
|
1552
1598
|
get timeRange() {
|
|
@@ -1555,27 +1601,28 @@ const He = (r) => {
|
|
|
1555
1601
|
}
|
|
1556
1602
|
/** @returns the capacity of the series in bytes. */
|
|
1557
1603
|
get byteCapacity() {
|
|
1558
|
-
return new
|
|
1604
|
+
return new pe(this.underlyingData.byteLength);
|
|
1559
1605
|
}
|
|
1560
1606
|
/** @returns the capacity of the series in samples. */
|
|
1561
1607
|
get capacity() {
|
|
1562
|
-
return this.dataType.density.length(this.byteCapacity);
|
|
1608
|
+
return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
|
|
1563
1609
|
}
|
|
1564
1610
|
/** @returns the length of the series in bytes. */
|
|
1565
1611
|
get byteLength() {
|
|
1566
|
-
return this.writePos ===
|
|
1612
|
+
return this.writePos === P ? this.byteCapacity : this.dataType.isVariable ? new pe(this.writePos) : this.dataType.density.size(this.writePos);
|
|
1567
1613
|
}
|
|
1568
1614
|
/** @returns the number of samples in this array. */
|
|
1569
1615
|
get length() {
|
|
1570
|
-
return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos ===
|
|
1616
|
+
return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === P ? this.data.length : this.writePos;
|
|
1571
1617
|
}
|
|
1572
1618
|
calculateCachedLength() {
|
|
1573
1619
|
if (!this.dataType.isVariable)
|
|
1574
1620
|
throw new Error("cannot calculate length of a non-variable length data type");
|
|
1575
1621
|
let e = 0;
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1622
|
+
const t = [0];
|
|
1623
|
+
return this.data.forEach((n, s) => {
|
|
1624
|
+
n === ye && (e++, t.push(s + 1));
|
|
1625
|
+
}), this._cachedIndexes = t, this._cachedLength = e, e;
|
|
1579
1626
|
}
|
|
1580
1627
|
/**
|
|
1581
1628
|
* Creates a new array with a different data type.
|
|
@@ -1590,8 +1637,8 @@ const He = (r) => {
|
|
|
1590
1637
|
if (this.dataType.equals(e)) return this;
|
|
1591
1638
|
const n = new e.Array(this.length);
|
|
1592
1639
|
for (let s = 0; s < this.length; s++)
|
|
1593
|
-
n[s] =
|
|
1594
|
-
return new
|
|
1640
|
+
n[s] = ir(this.dataType, e, this.data[s], t);
|
|
1641
|
+
return new B({
|
|
1595
1642
|
data: n.buffer,
|
|
1596
1643
|
dataType: e,
|
|
1597
1644
|
timeRange: this._timeRange,
|
|
@@ -1617,12 +1664,11 @@ const He = (r) => {
|
|
|
1617
1664
|
get max() {
|
|
1618
1665
|
if (this.dataType.isVariable)
|
|
1619
1666
|
throw new Error("cannot calculate maximum on a variable length data type");
|
|
1620
|
-
return this.writePos === 0 ? -1 / 0 : (this._cachedMax
|
|
1667
|
+
return this.writePos === 0 ? -1 / 0 : (this._cachedMax ?? (this._cachedMax = this.calcRawMax()), H(this._cachedMax, this.sampleOffset));
|
|
1621
1668
|
}
|
|
1622
1669
|
calcRawMin() {
|
|
1623
1670
|
if (this.length === 0) return 1 / 0;
|
|
1624
|
-
if (this.dataType.equals(b.TIMESTAMP))
|
|
1625
|
-
this._cachedMin = this.data[0];
|
|
1671
|
+
if (this.dataType.equals(b.TIMESTAMP)) this._cachedMin = this.data[0];
|
|
1626
1672
|
else if (this.dataType.usesBigInt) {
|
|
1627
1673
|
const e = this.data;
|
|
1628
1674
|
this._cachedMin = e.reduce((t, n) => t < n ? t : n);
|
|
@@ -1636,11 +1682,11 @@ const He = (r) => {
|
|
|
1636
1682
|
get min() {
|
|
1637
1683
|
if (this.dataType.isVariable)
|
|
1638
1684
|
throw new Error("cannot calculate minimum on a variable length data type");
|
|
1639
|
-
return this.writePos === 0 ? 1 / 0 : (this._cachedMin
|
|
1685
|
+
return this.writePos === 0 ? 1 / 0 : (this._cachedMin ?? (this._cachedMin = this.calcRawMin()), H(this._cachedMin, this.sampleOffset));
|
|
1640
1686
|
}
|
|
1641
1687
|
/** @returns the bounds of this array. */
|
|
1642
1688
|
get bounds() {
|
|
1643
|
-
return
|
|
1689
|
+
return k(Number(this.min), Number(this.max));
|
|
1644
1690
|
}
|
|
1645
1691
|
maybeRecomputeMinMax(e) {
|
|
1646
1692
|
if (this._cachedMin != null) {
|
|
@@ -1656,7 +1702,15 @@ const He = (r) => {
|
|
|
1656
1702
|
this.max, this.min;
|
|
1657
1703
|
}
|
|
1658
1704
|
get range() {
|
|
1659
|
-
return
|
|
1705
|
+
return H(this.max, -this.min);
|
|
1706
|
+
}
|
|
1707
|
+
atAlignment(e, t) {
|
|
1708
|
+
const n = Number(e - this.alignment);
|
|
1709
|
+
if (n < 0 || n >= this.length) {
|
|
1710
|
+
if (t === !0) throw new Error(`[series] - no value at index ${n}`);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
return this.at(n, t);
|
|
1660
1714
|
}
|
|
1661
1715
|
at(e, t) {
|
|
1662
1716
|
if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
|
|
@@ -1666,25 +1720,29 @@ const He = (r) => {
|
|
|
1666
1720
|
if (t === !0) throw new Error(`[series] - no value at index ${e}`);
|
|
1667
1721
|
return;
|
|
1668
1722
|
}
|
|
1669
|
-
return
|
|
1723
|
+
return H(n, this.sampleOffset);
|
|
1670
1724
|
}
|
|
1671
1725
|
atVariable(e, t) {
|
|
1672
|
-
e < 0 && (e = this.length + e);
|
|
1673
1726
|
let n = 0, s = 0;
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1727
|
+
if (this._cachedIndexes != null)
|
|
1728
|
+
n = this._cachedIndexes[e], s = this._cachedIndexes[e + 1] - 1;
|
|
1729
|
+
else {
|
|
1730
|
+
e < 0 && (e = this.length + e);
|
|
1731
|
+
for (let c = 0; c < this.data.length; c++)
|
|
1732
|
+
if (this.data[c] === ye) {
|
|
1733
|
+
if (e === 0) {
|
|
1734
|
+
s = c;
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
n = c + 1, e--;
|
|
1679
1738
|
}
|
|
1680
|
-
|
|
1739
|
+
if (s === 0 && (s = this.data.length), n >= s || e > 0) {
|
|
1740
|
+
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
1741
|
+
return;
|
|
1681
1742
|
}
|
|
1682
|
-
if (s === 0 && (s = this.data.length), n >= s || e > 0) {
|
|
1683
|
-
if (t) throw new Error(`[series] - no value at index ${e}`);
|
|
1684
|
-
return;
|
|
1685
1743
|
}
|
|
1686
1744
|
const a = this.data.slice(n, s);
|
|
1687
|
-
return this.dataType.equals(b.STRING) ? new TextDecoder().decode(a) :
|
|
1745
|
+
return this.dataType.equals(b.STRING) ? new TextDecoder().decode(a) : We(
|
|
1688
1746
|
JSON.parse(new TextDecoder().decode(a))
|
|
1689
1747
|
);
|
|
1690
1748
|
}
|
|
@@ -1695,7 +1753,7 @@ const He = (r) => {
|
|
|
1695
1753
|
*/
|
|
1696
1754
|
binarySearch(e) {
|
|
1697
1755
|
let t = 0, n = this.length - 1;
|
|
1698
|
-
const s =
|
|
1756
|
+
const s = Ht(e);
|
|
1699
1757
|
for (; t <= n; ) {
|
|
1700
1758
|
const a = Math.floor((t + n) / 2), c = s(this.at(a, !0), e);
|
|
1701
1759
|
if (c === 0) return a;
|
|
@@ -1708,16 +1766,16 @@ const He = (r) => {
|
|
|
1708
1766
|
throw new Error("Only FLOAT32 arrays can be used in WebGL");
|
|
1709
1767
|
const { buffer: t, bufferUsage: n, prevBuffer: s } = this.gl;
|
|
1710
1768
|
if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== s)
|
|
1711
|
-
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !==
|
|
1769
|
+
if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== P) {
|
|
1712
1770
|
s === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
|
|
1713
1771
|
const a = this.dataType.density.size(s).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
1714
1772
|
e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
|
|
1715
1773
|
} else
|
|
1716
1774
|
e.bufferData(
|
|
1717
1775
|
e.ARRAY_BUFFER,
|
|
1718
|
-
this.
|
|
1776
|
+
this.underlyingData,
|
|
1719
1777
|
n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
|
|
1720
|
-
), this.gl.prevBuffer =
|
|
1778
|
+
), this.gl.prevBuffer = P;
|
|
1721
1779
|
}
|
|
1722
1780
|
as(e) {
|
|
1723
1781
|
if (e === "string") {
|
|
@@ -1764,7 +1822,7 @@ const He = (r) => {
|
|
|
1764
1822
|
};
|
|
1765
1823
|
}
|
|
1766
1824
|
get alignmentBounds() {
|
|
1767
|
-
return
|
|
1825
|
+
return k(this.alignment, this.alignment + BigInt(this.length));
|
|
1768
1826
|
}
|
|
1769
1827
|
maybeGarbageCollectGLBuffer(e) {
|
|
1770
1828
|
this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
|
|
@@ -1775,15 +1833,31 @@ const He = (r) => {
|
|
|
1775
1833
|
}
|
|
1776
1834
|
[Symbol.iterator]() {
|
|
1777
1835
|
if (this.dataType.isVariable) {
|
|
1778
|
-
const e = new
|
|
1779
|
-
return this.dataType.equals(b.JSON) ? new
|
|
1836
|
+
const e = new lr(this);
|
|
1837
|
+
return this.dataType.equals(b.JSON) ? new hr(e) : e;
|
|
1780
1838
|
}
|
|
1781
|
-
return new
|
|
1839
|
+
return new fr(this);
|
|
1782
1840
|
}
|
|
1783
1841
|
slice(e, t) {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1842
|
+
return this.sliceSub(!1, e, t);
|
|
1843
|
+
}
|
|
1844
|
+
sub(e, t) {
|
|
1845
|
+
return this.sliceSub(!0, e, t);
|
|
1846
|
+
}
|
|
1847
|
+
subIterator(e, t) {
|
|
1848
|
+
return new Ue(this, e, t ?? this.length);
|
|
1849
|
+
}
|
|
1850
|
+
subAlignmentIterator(e, t) {
|
|
1851
|
+
return new Ue(
|
|
1852
|
+
this,
|
|
1853
|
+
Number(e - this.alignment),
|
|
1854
|
+
Number(t - this.alignment)
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
subBytes(e, t) {
|
|
1858
|
+
if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
|
|
1859
|
+
const n = this.data.subarray(e, t);
|
|
1860
|
+
return new B({
|
|
1787
1861
|
data: n,
|
|
1788
1862
|
dataType: this.dataType,
|
|
1789
1863
|
timeRange: this._timeRange,
|
|
@@ -1792,26 +1866,51 @@ const He = (r) => {
|
|
|
1792
1866
|
alignment: this.alignment + BigInt(e)
|
|
1793
1867
|
});
|
|
1794
1868
|
}
|
|
1869
|
+
sliceSub(e, t, n) {
|
|
1870
|
+
if (t <= 0 && (n == null || n >= this.length)) return this;
|
|
1871
|
+
let s;
|
|
1872
|
+
return e ? s = this.data.subarray(t, n) : s = this.data.slice(t, n), new B({
|
|
1873
|
+
data: s,
|
|
1874
|
+
dataType: this.dataType,
|
|
1875
|
+
timeRange: this._timeRange,
|
|
1876
|
+
sampleOffset: this.sampleOffset,
|
|
1877
|
+
glBufferUsage: this.gl.bufferUsage,
|
|
1878
|
+
alignment: this.alignment + BigInt(t)
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1795
1881
|
reAlign(e) {
|
|
1796
|
-
return new
|
|
1882
|
+
return new B({
|
|
1797
1883
|
data: this.buffer,
|
|
1798
1884
|
dataType: this.dataType,
|
|
1799
|
-
timeRange:
|
|
1885
|
+
timeRange: Te.ZERO,
|
|
1800
1886
|
sampleOffset: this.sampleOffset,
|
|
1801
1887
|
glBufferUsage: "static",
|
|
1802
1888
|
alignment: e
|
|
1803
1889
|
});
|
|
1804
1890
|
}
|
|
1805
1891
|
};
|
|
1806
|
-
u(
|
|
1807
|
-
timeRange:
|
|
1892
|
+
u(J, "crudeZ", i.object({
|
|
1893
|
+
timeRange: Te.z.optional(),
|
|
1808
1894
|
dataType: b.z,
|
|
1809
|
-
alignment:
|
|
1810
|
-
data: i.union([
|
|
1811
|
-
glBufferUsage:
|
|
1812
|
-
})), u(
|
|
1813
|
-
let
|
|
1814
|
-
class
|
|
1895
|
+
alignment: Qt.optional(),
|
|
1896
|
+
data: i.union([or, ur, i.instanceof(ArrayBuffer)]),
|
|
1897
|
+
glBufferUsage: sr.optional().default("static").optional()
|
|
1898
|
+
})), u(J, "z", J.crudeZ.transform((r) => new J(r)));
|
|
1899
|
+
let cr = J;
|
|
1900
|
+
class Ue {
|
|
1901
|
+
constructor(e, t, n) {
|
|
1902
|
+
u(this, "series"), u(this, "end"), u(this, "index"), this.series = e;
|
|
1903
|
+
const s = k(0, e.length);
|
|
1904
|
+
this.end = Ae(s, n), this.index = Ae(s, t);
|
|
1905
|
+
}
|
|
1906
|
+
next() {
|
|
1907
|
+
return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
|
|
1908
|
+
}
|
|
1909
|
+
[Symbol.iterator]() {
|
|
1910
|
+
return this;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
class lr {
|
|
1815
1914
|
constructor(e) {
|
|
1816
1915
|
if (u(this, "series"), u(this, "index"), u(this, "decoder"), !e.dataType.isVariable)
|
|
1817
1916
|
throw new Error(
|
|
@@ -1821,7 +1920,7 @@ class sr {
|
|
|
1821
1920
|
}
|
|
1822
1921
|
next() {
|
|
1823
1922
|
const e = this.index, t = this.series.data;
|
|
1824
|
-
for (; this.index < t.length && t[this.index] !==
|
|
1923
|
+
for (; this.index < t.length && t[this.index] !== ye; ) this.index++;
|
|
1825
1924
|
const n = this.index;
|
|
1826
1925
|
return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
|
|
1827
1926
|
}
|
|
@@ -1829,26 +1928,26 @@ class sr {
|
|
|
1829
1928
|
return this;
|
|
1830
1929
|
}
|
|
1831
1930
|
}
|
|
1832
|
-
var
|
|
1833
|
-
class
|
|
1931
|
+
var Ce, De;
|
|
1932
|
+
class hr {
|
|
1834
1933
|
constructor(e) {
|
|
1835
|
-
u(this, "wrapped"), u(this,
|
|
1934
|
+
u(this, "wrapped"), u(this, Ce, "JSONSeriesIterator"), this.wrapped = e;
|
|
1836
1935
|
}
|
|
1837
1936
|
next() {
|
|
1838
1937
|
const e = this.wrapped.next();
|
|
1839
1938
|
return e.done === !0 ? { done: !0, value: void 0 } : {
|
|
1840
1939
|
done: !1,
|
|
1841
|
-
value:
|
|
1940
|
+
value: ee.decodeString(e.value)
|
|
1842
1941
|
};
|
|
1843
1942
|
}
|
|
1844
|
-
[(
|
|
1943
|
+
[(De = Symbol.iterator, Ce = Symbol.toStringTag, De)]() {
|
|
1845
1944
|
return this;
|
|
1846
1945
|
}
|
|
1847
1946
|
}
|
|
1848
|
-
var
|
|
1849
|
-
class
|
|
1947
|
+
var Pe, Le;
|
|
1948
|
+
class fr {
|
|
1850
1949
|
constructor(e) {
|
|
1851
|
-
u(this, "series"), u(this, "index"), u(this,
|
|
1950
|
+
u(this, "series"), u(this, "index"), u(this, Pe, "SeriesIterator"), this.series = e, this.index = 0;
|
|
1852
1951
|
}
|
|
1853
1952
|
next() {
|
|
1854
1953
|
return this.index >= this.series.length ? { done: !0, value: void 0 } : {
|
|
@@ -1856,11 +1955,11 @@ class ar {
|
|
|
1856
1955
|
value: this.series.at(this.index++, !0)
|
|
1857
1956
|
};
|
|
1858
1957
|
}
|
|
1859
|
-
[(
|
|
1958
|
+
[(Le = Symbol.iterator, Pe = Symbol.toStringTag, Le)]() {
|
|
1860
1959
|
return this;
|
|
1861
1960
|
}
|
|
1862
1961
|
}
|
|
1863
|
-
const
|
|
1962
|
+
const H = (r, e) => typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : e === 0 ? r : r === 0 ? e : Number(r) + Number(e);
|
|
1864
1963
|
i.object({
|
|
1865
1964
|
key: i.string(),
|
|
1866
1965
|
value: i.string()
|
|
@@ -1869,27 +1968,27 @@ i.record(
|
|
|
1869
1968
|
i.union([i.number(), i.string(), i.symbol()]),
|
|
1870
1969
|
i.unknown()
|
|
1871
1970
|
);
|
|
1872
|
-
const
|
|
1873
|
-
let
|
|
1874
|
-
const
|
|
1971
|
+
const tt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", dr = tt(), rt = ["MacOS", "Windows", "Linux", "Docker"], gr = i.enum(rt);
|
|
1972
|
+
let fe;
|
|
1973
|
+
const pr = () => {
|
|
1875
1974
|
if (typeof window > "u") return;
|
|
1876
1975
|
const r = window.navigator.userAgent.toLowerCase();
|
|
1877
1976
|
if (r.includes("mac")) return "MacOS";
|
|
1878
1977
|
if (r.includes("win")) return "Windows";
|
|
1879
1978
|
if (r.includes("linux")) return "Linux";
|
|
1880
|
-
},
|
|
1979
|
+
}, yr = (r = {}) => {
|
|
1881
1980
|
const { force: e, default: t } = r;
|
|
1882
|
-
return e ??
|
|
1883
|
-
},
|
|
1981
|
+
return e ?? fe ?? (fe = pr(), fe ?? t);
|
|
1982
|
+
}, nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1884
1983
|
__proto__: null,
|
|
1885
|
-
OPERATING_SYSTEMS:
|
|
1886
|
-
RUNTIME:
|
|
1887
|
-
detect:
|
|
1888
|
-
getOS:
|
|
1889
|
-
osZ:
|
|
1984
|
+
OPERATING_SYSTEMS: rt,
|
|
1985
|
+
RUNTIME: dr,
|
|
1986
|
+
detect: tt,
|
|
1987
|
+
getOS: yr,
|
|
1988
|
+
osZ: gr
|
|
1890
1989
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1891
|
-
var
|
|
1892
|
-
const
|
|
1990
|
+
var mr = Object.defineProperty, wr = (r, e, t) => e in r ? mr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, K = (r, e, t) => wr(r, typeof e != "symbol" ? e + "" : e, t);
|
|
1991
|
+
const br = (...r) => r.map(st).join(""), st = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Tr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Or = (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("&")}`, me = class we {
|
|
1893
1992
|
/**
|
|
1894
1993
|
* @param host - The hostname or IP address of the server.
|
|
1895
1994
|
* @param port - The port number of the server.
|
|
@@ -1897,7 +1996,7 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
|
|
|
1897
1996
|
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
1898
1997
|
*/
|
|
1899
1998
|
constructor({ host: e, port: t, protocol: n = "", pathPrefix: s = "" }) {
|
|
1900
|
-
|
|
1999
|
+
K(this, "protocol"), K(this, "host"), K(this, "port"), K(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = st(s);
|
|
1901
2000
|
}
|
|
1902
2001
|
/**
|
|
1903
2002
|
* Replaces creates a new URL with the specified properties replaced.
|
|
@@ -1905,7 +2004,7 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
|
|
|
1905
2004
|
* @returns a new URL.
|
|
1906
2005
|
*/
|
|
1907
2006
|
replace(e) {
|
|
1908
|
-
return new
|
|
2007
|
+
return new we({
|
|
1909
2008
|
host: e.host ?? this.host,
|
|
1910
2009
|
port: e.port ?? this.port,
|
|
1911
2010
|
protocol: e.protocol ?? this.protocol,
|
|
@@ -1918,54 +2017,54 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
|
|
|
1918
2017
|
* @returns a new URL.
|
|
1919
2018
|
*/
|
|
1920
2019
|
child(e) {
|
|
1921
|
-
return new
|
|
2020
|
+
return new we({
|
|
1922
2021
|
...this,
|
|
1923
|
-
pathPrefix:
|
|
2022
|
+
pathPrefix: br(this.path, e)
|
|
1924
2023
|
});
|
|
1925
2024
|
}
|
|
1926
2025
|
/** @returns a string representation of the url */
|
|
1927
2026
|
toString() {
|
|
1928
|
-
return
|
|
2027
|
+
return Tr(
|
|
1929
2028
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
1930
2029
|
);
|
|
1931
2030
|
}
|
|
1932
2031
|
};
|
|
1933
|
-
|
|
1934
|
-
let
|
|
1935
|
-
var
|
|
1936
|
-
const
|
|
2032
|
+
K(me, "UNKNOWN", new me({ host: "unknown", port: 0 }));
|
|
2033
|
+
let vr = me;
|
|
2034
|
+
var Sr = Object.defineProperty, Ir = (r, e, t) => e in r ? Sr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ne = (r, e, t) => Ir(r, typeof e != "symbol" ? e + "" : e, t);
|
|
2035
|
+
const G = class extends Number {
|
|
1937
2036
|
};
|
|
1938
|
-
|
|
1939
|
-
i.instanceof(
|
|
1940
|
-
i.number().int().min(0).max(255).transform((r) => new
|
|
1941
|
-
i.instanceof(Number).transform((r) => new
|
|
2037
|
+
ne(G, "Absolute", 255), ne(G, "Default", 1), ne(G, "z", i.union([
|
|
2038
|
+
i.instanceof(G),
|
|
2039
|
+
i.number().int().min(0).max(255).transform((r) => new G(r)),
|
|
2040
|
+
i.instanceof(Number).transform((r) => new G(r))
|
|
1942
2041
|
]));
|
|
1943
2042
|
i.object({
|
|
1944
2043
|
name: i.string(),
|
|
1945
2044
|
key: i.string()
|
|
1946
2045
|
});
|
|
1947
|
-
const
|
|
2046
|
+
const it = class X extends Error {
|
|
1948
2047
|
constructor() {
|
|
1949
|
-
super(
|
|
2048
|
+
super(X.MESSAGE);
|
|
1950
2049
|
}
|
|
1951
2050
|
/** Returns true if the error or message is a cancellation error" */
|
|
1952
2051
|
matches(e) {
|
|
1953
|
-
return typeof e == "string" ? e.includes(
|
|
2052
|
+
return typeof e == "string" ? e.includes(X.MESSAGE) : e instanceof X || e.message.includes(X.MESSAGE);
|
|
1954
2053
|
}
|
|
1955
2054
|
};
|
|
1956
|
-
|
|
1957
|
-
let
|
|
1958
|
-
new
|
|
2055
|
+
ne(it, "MESSAGE", "canceled");
|
|
2056
|
+
let Nr = it;
|
|
2057
|
+
new Nr();
|
|
1959
2058
|
i.string().regex(/^\d+\.\d+\.\d+$/);
|
|
1960
|
-
const
|
|
1961
|
-
class
|
|
1962
|
-
constructor(
|
|
1963
|
-
super(
|
|
2059
|
+
const Oe = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
|
|
2060
|
+
class oe extends Error {
|
|
2061
|
+
constructor() {
|
|
2062
|
+
super(...arguments);
|
|
1964
2063
|
p(this, "discriminator", "FreighterError");
|
|
1965
2064
|
p(this, "type", "");
|
|
1966
2065
|
}
|
|
1967
2066
|
}
|
|
1968
|
-
const
|
|
2067
|
+
const Er = (r) => {
|
|
1969
2068
|
if (r == null || typeof r != "object") return !1;
|
|
1970
2069
|
const e = r;
|
|
1971
2070
|
if (e.discriminator !== "FreighterError") return !1;
|
|
@@ -1974,8 +2073,8 @@ const Tr = (r) => {
|
|
|
1974
2073
|
`Freighter error is missing its type property: ${JSON.stringify(e)}`
|
|
1975
2074
|
);
|
|
1976
2075
|
return !0;
|
|
1977
|
-
},
|
|
1978
|
-
class
|
|
2076
|
+
}, Ye = "unknown", ke = "nil", Ar = "freighter", at = i.object({ type: i.string(), data: i.string() });
|
|
2077
|
+
class xr {
|
|
1979
2078
|
constructor() {
|
|
1980
2079
|
p(this, "providers", []);
|
|
1981
2080
|
}
|
|
@@ -1983,87 +2082,87 @@ class vr {
|
|
|
1983
2082
|
this.providers.push(e);
|
|
1984
2083
|
}
|
|
1985
2084
|
encode(e) {
|
|
1986
|
-
if (e == null) return { type:
|
|
1987
|
-
if (
|
|
2085
|
+
if (e == null) return { type: ke, data: "" };
|
|
2086
|
+
if (Er(e))
|
|
1988
2087
|
for (const t of this.providers) {
|
|
1989
2088
|
const n = t.encode(e);
|
|
1990
2089
|
if (n != null) return n;
|
|
1991
2090
|
}
|
|
1992
|
-
return { type:
|
|
2091
|
+
return { type: Ye, data: JSON.stringify(e) };
|
|
1993
2092
|
}
|
|
1994
2093
|
decode(e) {
|
|
1995
|
-
if (e == null || e.type ===
|
|
1996
|
-
if (e.type ===
|
|
2094
|
+
if (e == null || e.type === ke) return null;
|
|
2095
|
+
if (e.type === Ye) return new je(e.data);
|
|
1997
2096
|
for (const t of this.providers) {
|
|
1998
2097
|
const n = t.decode(e);
|
|
1999
2098
|
if (n != null) return n;
|
|
2000
2099
|
}
|
|
2001
|
-
return new
|
|
2100
|
+
return new je(e.data);
|
|
2002
2101
|
}
|
|
2003
2102
|
}
|
|
2004
|
-
const
|
|
2103
|
+
const ve = new xr(), Mr = ({
|
|
2005
2104
|
encode: r,
|
|
2006
2105
|
decode: e
|
|
2007
|
-
}) =>
|
|
2008
|
-
class
|
|
2009
|
-
constructor(
|
|
2010
|
-
super(
|
|
2106
|
+
}) => ve.register({ encode: r, decode: e }), Zr = (r) => ve.encode(r), ot = (r) => ve.decode(r);
|
|
2107
|
+
class je extends oe {
|
|
2108
|
+
constructor() {
|
|
2109
|
+
super(...arguments);
|
|
2011
2110
|
p(this, "type", "unknown");
|
|
2012
2111
|
}
|
|
2013
2112
|
}
|
|
2014
|
-
const
|
|
2113
|
+
const ue = "freighter.", q = class q extends oe {
|
|
2015
2114
|
constructor() {
|
|
2016
2115
|
super("EOF");
|
|
2017
|
-
p(this, "type",
|
|
2116
|
+
p(this, "type", q.TYPE);
|
|
2018
2117
|
}
|
|
2019
2118
|
};
|
|
2020
|
-
p(
|
|
2021
|
-
let
|
|
2022
|
-
const
|
|
2119
|
+
p(q, "TYPE", `${ue}eof`), p(q, "matches", Oe(q.TYPE));
|
|
2120
|
+
let L = q;
|
|
2121
|
+
const W = class W extends oe {
|
|
2023
2122
|
constructor() {
|
|
2024
2123
|
super("StreamClosed");
|
|
2025
|
-
p(this, "type",
|
|
2124
|
+
p(this, "type", W.TYPE);
|
|
2026
2125
|
}
|
|
2027
2126
|
};
|
|
2028
|
-
p(
|
|
2029
|
-
let
|
|
2030
|
-
const
|
|
2127
|
+
p(W, "TYPE", `${ue}stream_closed`), p(W, "matches", Oe(W.TYPE));
|
|
2128
|
+
let Y = W;
|
|
2129
|
+
const V = class V extends oe {
|
|
2031
2130
|
constructor(t = {}) {
|
|
2032
|
-
const { message: n = "Unreachable", url: s =
|
|
2131
|
+
const { message: n = "Unreachable", url: s = vr.UNKNOWN } = t;
|
|
2033
2132
|
super(n);
|
|
2034
|
-
p(this, "type",
|
|
2133
|
+
p(this, "type", V.TYPE);
|
|
2035
2134
|
p(this, "url");
|
|
2036
2135
|
this.url = s;
|
|
2037
2136
|
}
|
|
2038
2137
|
};
|
|
2039
|
-
p(
|
|
2040
|
-
let
|
|
2041
|
-
const
|
|
2042
|
-
if (!r.type.startsWith(
|
|
2043
|
-
if (
|
|
2044
|
-
if (
|
|
2045
|
-
return { type:
|
|
2046
|
-
if (
|
|
2047
|
-
return { type:
|
|
2138
|
+
p(V, "TYPE", `${ue}unreachable`), p(V, "matches", Oe(V.TYPE));
|
|
2139
|
+
let j = V;
|
|
2140
|
+
const $r = (r) => {
|
|
2141
|
+
if (!r.type.startsWith(Ar)) return null;
|
|
2142
|
+
if (L.matches(r)) return { type: L.TYPE, data: "EOF" };
|
|
2143
|
+
if (Y.matches(r))
|
|
2144
|
+
return { type: Y.TYPE, data: "StreamClosed" };
|
|
2145
|
+
if (j.matches(r))
|
|
2146
|
+
return { type: j.TYPE, data: "Unreachable" };
|
|
2048
2147
|
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
2049
|
-
},
|
|
2050
|
-
if (!r.type.startsWith(
|
|
2148
|
+
}, Br = (r) => {
|
|
2149
|
+
if (!r.type.startsWith(ue)) return null;
|
|
2051
2150
|
switch (r.type) {
|
|
2052
|
-
case P.TYPE:
|
|
2053
|
-
return new P();
|
|
2054
2151
|
case L.TYPE:
|
|
2055
2152
|
return new L();
|
|
2056
|
-
case
|
|
2057
|
-
return new
|
|
2153
|
+
case Y.TYPE:
|
|
2154
|
+
return new Y();
|
|
2155
|
+
case j.TYPE:
|
|
2156
|
+
return new j();
|
|
2058
2157
|
default:
|
|
2059
2158
|
throw new Error(`Unknown error type: ${r.data}`);
|
|
2060
2159
|
}
|
|
2061
2160
|
};
|
|
2062
|
-
|
|
2063
|
-
encode:
|
|
2064
|
-
decode:
|
|
2161
|
+
Mr({
|
|
2162
|
+
encode: $r,
|
|
2163
|
+
decode: Br
|
|
2065
2164
|
});
|
|
2066
|
-
class
|
|
2165
|
+
class ut {
|
|
2067
2166
|
constructor() {
|
|
2068
2167
|
p(this, "middleware", []);
|
|
2069
2168
|
}
|
|
@@ -2090,65 +2189,65 @@ class nt {
|
|
|
2090
2189
|
return await s(e);
|
|
2091
2190
|
}
|
|
2092
2191
|
}
|
|
2093
|
-
const
|
|
2094
|
-
if (
|
|
2192
|
+
const ct = "Content-Type", Fe = (r) => {
|
|
2193
|
+
if (nt.RUNTIME !== "node") return fetch;
|
|
2095
2194
|
const e = require("node-fetch");
|
|
2096
2195
|
if (r === "http") return e;
|
|
2097
2196
|
const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
|
|
2098
2197
|
return async (s, a) => await e(s, { ...a, agent: n });
|
|
2099
2198
|
};
|
|
2100
|
-
class
|
|
2199
|
+
class Jr extends ut {
|
|
2101
2200
|
constructor(t, n, s = !1) {
|
|
2102
2201
|
super();
|
|
2103
2202
|
p(this, "endpoint");
|
|
2104
2203
|
p(this, "encoder");
|
|
2105
2204
|
p(this, "fetch");
|
|
2106
|
-
return this.endpoint = t.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch =
|
|
2107
|
-
get: (a, c,
|
|
2205
|
+
return this.endpoint = t.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch = Fe(this.endpoint.protocol), new Proxy(this, {
|
|
2206
|
+
get: (a, c, f) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, f)
|
|
2108
2207
|
});
|
|
2109
2208
|
}
|
|
2110
2209
|
get headers() {
|
|
2111
2210
|
return {
|
|
2112
|
-
[
|
|
2211
|
+
[ct]: this.encoder.contentType
|
|
2113
2212
|
};
|
|
2114
2213
|
}
|
|
2115
2214
|
async send(t, n, s, a) {
|
|
2116
2215
|
n = s == null ? void 0 : s.parse(n);
|
|
2117
2216
|
let c = null;
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2217
|
+
const f = this.endpoint.child(t), d = {};
|
|
2218
|
+
d.method = "POST", d.body = this.encoder.encode(n ?? {});
|
|
2120
2219
|
const [, y] = await this.executeMiddleware(
|
|
2121
2220
|
{
|
|
2122
|
-
target:
|
|
2221
|
+
target: f.toString(),
|
|
2123
2222
|
protocol: this.endpoint.protocol,
|
|
2124
2223
|
params: {},
|
|
2125
2224
|
role: "client"
|
|
2126
2225
|
},
|
|
2127
2226
|
async (T) => {
|
|
2128
2227
|
const l = { ...T, params: {} };
|
|
2129
|
-
|
|
2228
|
+
d.headers = {
|
|
2130
2229
|
...this.headers,
|
|
2131
2230
|
...T.params
|
|
2132
2231
|
};
|
|
2133
2232
|
let E;
|
|
2134
2233
|
try {
|
|
2135
|
-
E = await
|
|
2136
|
-
} catch (
|
|
2137
|
-
let x =
|
|
2138
|
-
return x.message === "Load failed" && (x = new
|
|
2234
|
+
E = await Fe(T.protocol)(T.target, d);
|
|
2235
|
+
} catch (U) {
|
|
2236
|
+
let x = U;
|
|
2237
|
+
return x.message === "Load failed" && (x = new j({ url: f })), [l, x];
|
|
2139
2238
|
}
|
|
2140
2239
|
const R = await E.arrayBuffer();
|
|
2141
2240
|
if (E != null && E.ok)
|
|
2142
2241
|
return a != null && (c = this.encoder.decode(R, a)), [l, null];
|
|
2143
2242
|
try {
|
|
2144
2243
|
if (E.status !== 400) return [l, new Error(E.statusText)];
|
|
2145
|
-
const
|
|
2244
|
+
const U = this.encoder.decode(R, at), x = ot(U);
|
|
2146
2245
|
return [l, x];
|
|
2147
|
-
} catch (
|
|
2246
|
+
} catch (U) {
|
|
2148
2247
|
return [
|
|
2149
2248
|
l,
|
|
2150
2249
|
new Error(
|
|
2151
|
-
`[freighter] - failed to decode error: ${E.statusText}: ${
|
|
2250
|
+
`[freighter] - failed to decode error: ${E.statusText}: ${U.message}`
|
|
2152
2251
|
)
|
|
2153
2252
|
];
|
|
2154
2253
|
}
|
|
@@ -2157,16 +2256,16 @@ class Gr extends nt {
|
|
|
2157
2256
|
return [c, y];
|
|
2158
2257
|
}
|
|
2159
2258
|
}
|
|
2160
|
-
const
|
|
2259
|
+
const Hr = async (r, e, t, n, s) => {
|
|
2161
2260
|
const [a, c] = await r.send(e, t, n, s);
|
|
2162
2261
|
if (c != null) throw c;
|
|
2163
2262
|
return a;
|
|
2164
|
-
},
|
|
2263
|
+
}, Rr = () => nt.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), Ur = i.object({
|
|
2165
2264
|
type: i.union([i.literal("data"), i.literal("close")]),
|
|
2166
2265
|
payload: i.unknown().optional(),
|
|
2167
|
-
error: i.optional(
|
|
2266
|
+
error: i.optional(at)
|
|
2168
2267
|
});
|
|
2169
|
-
class
|
|
2268
|
+
class Cr {
|
|
2170
2269
|
constructor(e, t, n, s) {
|
|
2171
2270
|
p(this, "encoder");
|
|
2172
2271
|
p(this, "reqSchema");
|
|
@@ -2180,8 +2279,8 @@ class xr {
|
|
|
2180
2279
|
}
|
|
2181
2280
|
/** Implements the Stream protocol */
|
|
2182
2281
|
send(e) {
|
|
2183
|
-
if (this.serverClosed != null) return new
|
|
2184
|
-
if (this.sendClosed) throw new
|
|
2282
|
+
if (this.serverClosed != null) return new L();
|
|
2283
|
+
if (this.sendClosed) throw new Y();
|
|
2185
2284
|
return this.ws.send(this.encoder.encode({ type: "data", payload: e })), null;
|
|
2186
2285
|
}
|
|
2187
2286
|
/** Implements the Stream protocol */
|
|
@@ -2190,7 +2289,7 @@ class xr {
|
|
|
2190
2289
|
const e = await this.receiveMsg();
|
|
2191
2290
|
if (e.type === "close") {
|
|
2192
2291
|
if (e.error == null) throw new Error("Message error must be defined");
|
|
2193
|
-
return this.serverClosed =
|
|
2292
|
+
return this.serverClosed = ot(e.error), [null, this.serverClosed];
|
|
2194
2293
|
}
|
|
2195
2294
|
return [this.resSchema.parse(e.payload), null];
|
|
2196
2295
|
}
|
|
@@ -2219,13 +2318,13 @@ class xr {
|
|
|
2219
2318
|
t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
|
|
2220
2319
|
}
|
|
2221
2320
|
listenForMessages() {
|
|
2222
|
-
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data,
|
|
2321
|
+
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, Ur)), this.ws.onclose = (e) => this.addMessage({
|
|
2223
2322
|
type: "close",
|
|
2224
|
-
error: { type:
|
|
2323
|
+
error: { type: kr(e) ? L.TYPE : Y.TYPE, data: "" }
|
|
2225
2324
|
});
|
|
2226
2325
|
}
|
|
2227
2326
|
}
|
|
2228
|
-
const
|
|
2327
|
+
const Dr = "freighterctx", Pr = 1e3, Lr = 1001, Yr = [Pr, Lr], kr = (r) => Yr.includes(r.code), ie = class ie extends ut {
|
|
2229
2328
|
/**
|
|
2230
2329
|
* @param encoder - The encoder to use for encoding messages and decoding
|
|
2231
2330
|
* responses.
|
|
@@ -2239,54 +2338,54 @@ const Mr = "freighterctx", $r = 1e3, Rr = 1001, Br = [$r, Rr], Ur = (r) => Br.in
|
|
|
2239
2338
|
}
|
|
2240
2339
|
/** Implements the StreamClient interface. */
|
|
2241
2340
|
async stream(t, n, s) {
|
|
2242
|
-
const a =
|
|
2341
|
+
const a = Rr();
|
|
2243
2342
|
let c;
|
|
2244
|
-
const [,
|
|
2343
|
+
const [, f] = await this.executeMiddleware(
|
|
2245
2344
|
{ target: t, protocol: "websocket", params: {}, role: "client" },
|
|
2246
|
-
async (
|
|
2247
|
-
const y = a(this.buildURL(t,
|
|
2248
|
-
y.binaryType =
|
|
2345
|
+
async (d) => {
|
|
2346
|
+
const y = a(this.buildURL(t, d)), T = { ...d, params: {} };
|
|
2347
|
+
y.binaryType = ie.MESSAGE_TYPE;
|
|
2249
2348
|
const l = await this.wrapSocket(y, n, s);
|
|
2250
2349
|
return l instanceof Error ? [T, l] : (c = l, [T, null]);
|
|
2251
2350
|
}
|
|
2252
2351
|
);
|
|
2253
|
-
if (
|
|
2352
|
+
if (f != null) throw f;
|
|
2254
2353
|
return c;
|
|
2255
2354
|
}
|
|
2256
2355
|
buildURL(t, n) {
|
|
2257
|
-
const s =
|
|
2356
|
+
const s = Or(
|
|
2258
2357
|
{
|
|
2259
|
-
[
|
|
2358
|
+
[ct]: this.encoder.contentType,
|
|
2260
2359
|
...n.params
|
|
2261
2360
|
},
|
|
2262
|
-
|
|
2361
|
+
Dr
|
|
2263
2362
|
);
|
|
2264
2363
|
return this.baseUrl.child(t).toString() + s;
|
|
2265
2364
|
}
|
|
2266
2365
|
async wrapSocket(t, n, s) {
|
|
2267
2366
|
return await new Promise((a) => {
|
|
2268
2367
|
t.onopen = () => {
|
|
2269
|
-
a(new
|
|
2368
|
+
a(new Cr(t, this.encoder, n, s));
|
|
2270
2369
|
}, t.onerror = (c) => {
|
|
2271
|
-
const
|
|
2272
|
-
a(new Error(
|
|
2370
|
+
const f = c;
|
|
2371
|
+
a(new Error(f.message));
|
|
2273
2372
|
};
|
|
2274
2373
|
});
|
|
2275
2374
|
}
|
|
2276
2375
|
};
|
|
2277
|
-
p(
|
|
2278
|
-
let
|
|
2376
|
+
p(ie, "MESSAGE_TYPE", "arraybuffer");
|
|
2377
|
+
let Ge = ie;
|
|
2279
2378
|
export {
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2379
|
+
oe as BaseTypedError,
|
|
2380
|
+
L as EOF,
|
|
2381
|
+
Jr as HTTPClient,
|
|
2382
|
+
Y as StreamClosed,
|
|
2383
|
+
j as Unreachable,
|
|
2384
|
+
Ge as WebSocketClient,
|
|
2385
|
+
ot as decodeError,
|
|
2386
|
+
Zr as encodeError,
|
|
2387
|
+
Oe as errorMatcher,
|
|
2388
|
+
at as errorZ,
|
|
2389
|
+
Mr as registerError,
|
|
2390
|
+
Hr as sendRequired
|
|
2292
2391
|
};
|