@synnaxlabs/freighter 0.23.0 → 0.25.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/alamos.d.ts +1 -1
- package/dist/errors.d.ts +23 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/freighter.cjs +3 -1
- package/dist/freighter.js +782 -1057
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/unary.d.ts +1 -1
- package/dist/unary.d.ts.map +1 -1
- package/dist/websocket.d.ts +3 -3
- package/package.json +4 -4
- package/src/errors.spec.ts +4 -2
- package/src/errors.ts +41 -11
- package/src/index.ts +2 -1
- package/src/websocket.spec.ts +2 -1
package/dist/freighter.js
CHANGED
|
@@ -1,526 +1,264 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { z as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var le = {};
|
|
24
|
-
Object.defineProperty(le, "__esModule", { value: !0 });
|
|
25
|
-
function jt(t) {
|
|
26
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "$").replace(/[^A-Za-z0-9]+/g, "$").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
27
|
-
return r + "$" + n;
|
|
28
|
-
}).toLowerCase().replace(/(\$)(\w?)/g, function(e, r, n) {
|
|
29
|
-
return n.toUpperCase();
|
|
30
|
-
}) : "";
|
|
31
|
-
}
|
|
32
|
-
le.default = jt;
|
|
33
|
-
var Ie = {};
|
|
34
|
-
Object.defineProperty(Ie, "__esModule", { value: !0 });
|
|
35
|
-
function Rt(t) {
|
|
36
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
37
|
-
return r + "_" + n.toLowerCase();
|
|
38
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, ".").toLowerCase() : "";
|
|
39
|
-
}
|
|
40
|
-
Ie.default = Rt;
|
|
41
|
-
var Ne = {};
|
|
42
|
-
Object.defineProperty(Ne, "__esModule", { value: !0 });
|
|
43
|
-
function Dt(t) {
|
|
44
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
45
|
-
return r + "_" + n.toLowerCase();
|
|
46
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, "/").toLowerCase() : "";
|
|
47
|
-
}
|
|
48
|
-
Ne.default = Dt;
|
|
49
|
-
var Ee = {};
|
|
50
|
-
Object.defineProperty(Ee, "__esModule", { value: !0 });
|
|
51
|
-
function Bt(t) {
|
|
52
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
53
|
-
return r + "_" + n.toLowerCase();
|
|
54
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase() : "";
|
|
55
|
-
}
|
|
56
|
-
Ee.default = Bt;
|
|
57
|
-
var Ce = {};
|
|
58
|
-
Object.defineProperty(Ce, "__esModule", { value: !0 });
|
|
59
|
-
function kt(t) {
|
|
60
|
-
if (t === void 0 && (t = ""), !t)
|
|
61
|
-
return "";
|
|
62
|
-
var e = String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(r, n, s) {
|
|
63
|
-
return n + "_" + s.toLowerCase();
|
|
64
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase();
|
|
65
|
-
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
66
|
-
}
|
|
67
|
-
Ce.default = kt;
|
|
68
|
-
var $e = {};
|
|
69
|
-
Object.defineProperty($e, "__esModule", { value: !0 });
|
|
70
|
-
function Lt(t) {
|
|
71
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
72
|
-
return r + "_" + n.toLowerCase();
|
|
73
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase().replace(/( ?)(\w+)( ?)/g, function(e, r, n, s) {
|
|
74
|
-
return r + n.charAt(0).toUpperCase() + n.slice(1) + s;
|
|
75
|
-
}) : "";
|
|
76
|
-
}
|
|
77
|
-
$e.default = Lt;
|
|
78
|
-
var ce = {};
|
|
79
|
-
Object.defineProperty(ce, "__esModule", { value: !0 });
|
|
80
|
-
function Pt(t) {
|
|
81
|
-
return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
|
|
82
|
-
return r + "_" + n.toLowerCase();
|
|
83
|
-
}).replace(/[^A-Za-z0-9]+|_+/g, "-").toLowerCase() : "";
|
|
84
|
-
}
|
|
85
|
-
ce.default = Pt;
|
|
86
|
-
var Ue = {}, K = {};
|
|
87
|
-
(function(t) {
|
|
88
|
-
Object.defineProperty(t, "__esModule", { value: !0 }), t.belongToTypes = t.isValidObject = t.isArrayObject = t.validateOptions = t.DefaultOption = void 0, t.DefaultOption = {
|
|
89
|
-
recursive: !1,
|
|
90
|
-
recursiveInArray: !1,
|
|
91
|
-
keepTypesOnRecursion: []
|
|
92
|
-
}, t.validateOptions = function(e) {
|
|
93
|
-
return e === void 0 && (e = t.DefaultOption), e.recursive == null ? e = t.DefaultOption : e.recursiveInArray == null && (e.recursiveInArray = !1), e;
|
|
94
|
-
}, t.isArrayObject = function(e) {
|
|
95
|
-
return e != null && Array.isArray(e);
|
|
96
|
-
}, t.isValidObject = function(e) {
|
|
97
|
-
return e != null && typeof e == "object" && !Array.isArray(e);
|
|
98
|
-
}, t.belongToTypes = function(e, r) {
|
|
99
|
-
return (r || []).some(function(n) {
|
|
100
|
-
return e instanceof n;
|
|
101
|
-
});
|
|
1
|
+
var Ze = Object.defineProperty;
|
|
2
|
+
var ze = (r, e, t) => e in r ? Ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var f = (r, e, t) => ze(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { z as s } from "zod";
|
|
5
|
+
const Ve = (r) => {
|
|
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
|
+
}, Ee = (r) => {
|
|
9
|
+
const e = (t, n = oe) => {
|
|
10
|
+
if (typeof t == "string") return r(t);
|
|
11
|
+
if (Array.isArray(t)) return t.map((a) => e(a, n));
|
|
12
|
+
if (!te(t)) return null;
|
|
13
|
+
n = Je(n);
|
|
14
|
+
const i = {};
|
|
15
|
+
return Object.keys(t).forEach((a) => {
|
|
16
|
+
let c = t[a];
|
|
17
|
+
const h = r(a);
|
|
18
|
+
n.recursive && (te(c) ? pe(c, n.keepTypesOnRecursion) || (c = e(c, n)) : n.recursiveInArray && fe(c) && (c = [...c].map((p) => {
|
|
19
|
+
let m = p;
|
|
20
|
+
return te(p) ? pe(m, n.keepTypesOnRecursion) || (m = e(p, n)) : fe(p) && (m = e({ key: p }, n).key), m;
|
|
21
|
+
}))), i[h] = c;
|
|
22
|
+
}), i;
|
|
102
23
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
106
|
-
t += arguments[e].length;
|
|
107
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
108
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
109
|
-
n[s] = a[u];
|
|
110
|
-
return n;
|
|
111
|
-
};
|
|
112
|
-
Object.defineProperty(Ue, "__esModule", { value: !0 });
|
|
113
|
-
var j = K;
|
|
114
|
-
function J(t, e) {
|
|
115
|
-
if (e === void 0 && (e = j.DefaultOption), !j.isValidObject(t))
|
|
116
|
-
return null;
|
|
117
|
-
e = j.validateOptions(e);
|
|
118
|
-
var r = {};
|
|
119
|
-
return Object.keys(t).forEach(function(n) {
|
|
120
|
-
var s = t[n], a = n.toLowerCase();
|
|
121
|
-
e.recursive && (j.isValidObject(s) ? j.belongToTypes(s, e.keepTypesOnRecursion) || (s = J(s, e)) : e.recursiveInArray && j.isArrayObject(s) && (s = Zt(s).map(function(u) {
|
|
122
|
-
var c = u;
|
|
123
|
-
if (j.isValidObject(u))
|
|
124
|
-
j.belongToTypes(c, e.keepTypesOnRecursion) || (c = J(u, e));
|
|
125
|
-
else if (j.isArrayObject(u)) {
|
|
126
|
-
var h = J({ key: u }, e);
|
|
127
|
-
c = h.key;
|
|
128
|
-
}
|
|
129
|
-
return c;
|
|
130
|
-
}))), r[a] = s;
|
|
131
|
-
}), r;
|
|
132
|
-
}
|
|
133
|
-
Ue.default = J;
|
|
134
|
-
var xe = {}, zt = C && C.__spreadArrays || function() {
|
|
135
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
136
|
-
t += arguments[e].length;
|
|
137
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
138
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
139
|
-
n[s] = a[u];
|
|
140
|
-
return n;
|
|
141
|
-
};
|
|
142
|
-
Object.defineProperty(xe, "__esModule", { value: !0 });
|
|
143
|
-
var R = K;
|
|
144
|
-
function Q(t, e) {
|
|
145
|
-
if (e === void 0 && (e = R.DefaultOption), !R.isValidObject(t))
|
|
146
|
-
return null;
|
|
147
|
-
e = R.validateOptions(e);
|
|
148
|
-
var r = {};
|
|
149
|
-
return Object.keys(t).forEach(function(n) {
|
|
150
|
-
var s = t[n], a = n.toUpperCase();
|
|
151
|
-
e.recursive && (R.isValidObject(s) ? R.belongToTypes(s, e.keepTypesOnRecursion) || (s = Q(s, e)) : e.recursiveInArray && R.isArrayObject(s) && (s = zt(s).map(function(u) {
|
|
152
|
-
var c = u;
|
|
153
|
-
if (R.isValidObject(u))
|
|
154
|
-
R.belongToTypes(c, e.keepTypesOnRecursion) || (c = Q(u, e));
|
|
155
|
-
else if (R.isArrayObject(u)) {
|
|
156
|
-
var h = Q({ key: u }, e);
|
|
157
|
-
c = h.key;
|
|
158
|
-
}
|
|
159
|
-
return c;
|
|
160
|
-
}))), r[a] = s;
|
|
161
|
-
}), r;
|
|
162
|
-
}
|
|
163
|
-
xe.default = Q;
|
|
164
|
-
var Me = {}, Yt = C && C.__spreadArrays || function() {
|
|
165
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
166
|
-
t += arguments[e].length;
|
|
167
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
168
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
169
|
-
n[s] = a[u];
|
|
170
|
-
return n;
|
|
171
|
-
};
|
|
172
|
-
Object.defineProperty(Me, "__esModule", { value: !0 });
|
|
173
|
-
var D = K, Kt = oe;
|
|
174
|
-
function _(t, e) {
|
|
175
|
-
if (e === void 0 && (e = D.DefaultOption), !D.isValidObject(t))
|
|
176
|
-
return null;
|
|
177
|
-
e = D.validateOptions(e);
|
|
178
|
-
var r = {};
|
|
179
|
-
return Object.keys(t).forEach(function(n) {
|
|
180
|
-
var s = t[n], a = Kt.default(n);
|
|
181
|
-
e.recursive && (D.isValidObject(s) ? D.belongToTypes(s, e.keepTypesOnRecursion) || (s = _(s, e)) : e.recursiveInArray && D.isArrayObject(s) && (s = Yt(s).map(function(u) {
|
|
182
|
-
var c = u;
|
|
183
|
-
if (D.isValidObject(u))
|
|
184
|
-
D.belongToTypes(c, e.keepTypesOnRecursion) || (c = _(u, e));
|
|
185
|
-
else if (D.isArrayObject(u)) {
|
|
186
|
-
var h = _({ key: u }, e);
|
|
187
|
-
c = h.key;
|
|
188
|
-
}
|
|
189
|
-
return c;
|
|
190
|
-
}))), r[a] = s;
|
|
191
|
-
}), r;
|
|
192
|
-
}
|
|
193
|
-
Me.default = _;
|
|
194
|
-
var je = {}, Vt = C && C.__spreadArrays || function() {
|
|
195
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
196
|
-
t += arguments[e].length;
|
|
197
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
198
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
199
|
-
n[s] = a[u];
|
|
200
|
-
return n;
|
|
201
|
-
};
|
|
202
|
-
Object.defineProperty(je, "__esModule", { value: !0 });
|
|
203
|
-
var B = K, Ft = ue;
|
|
204
|
-
function ee(t, e) {
|
|
205
|
-
if (e === void 0 && (e = B.DefaultOption), !B.isValidObject(t))
|
|
206
|
-
return null;
|
|
207
|
-
e = B.validateOptions(e);
|
|
208
|
-
var r = {};
|
|
209
|
-
return Object.keys(t).forEach(function(n) {
|
|
210
|
-
var s = t[n], a = Ft.default(n);
|
|
211
|
-
e.recursive && (B.isValidObject(s) ? B.belongToTypes(s, e.keepTypesOnRecursion) || (s = ee(s, e)) : e.recursiveInArray && B.isArrayObject(s) && (s = Vt(s).map(function(u) {
|
|
212
|
-
var c = u;
|
|
213
|
-
if (B.isValidObject(u))
|
|
214
|
-
B.belongToTypes(c, e.keepTypesOnRecursion) || (c = ee(u, e));
|
|
215
|
-
else if (B.isArrayObject(u)) {
|
|
216
|
-
var h = ee({ key: u }, e);
|
|
217
|
-
c = h.key;
|
|
218
|
-
}
|
|
219
|
-
return c;
|
|
220
|
-
}))), r[a] = s;
|
|
221
|
-
}), r;
|
|
222
|
-
}
|
|
223
|
-
je.default = ee;
|
|
224
|
-
var Re = {}, Wt = C && C.__spreadArrays || function() {
|
|
225
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
226
|
-
t += arguments[e].length;
|
|
227
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
228
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
229
|
-
n[s] = a[u];
|
|
230
|
-
return n;
|
|
231
|
-
};
|
|
232
|
-
Object.defineProperty(Re, "__esModule", { value: !0 });
|
|
233
|
-
var k = K, qt = le;
|
|
234
|
-
function te(t, e) {
|
|
235
|
-
if (e === void 0 && (e = k.DefaultOption), !k.isValidObject(t))
|
|
236
|
-
return null;
|
|
237
|
-
e = k.validateOptions(e);
|
|
238
|
-
var r = {};
|
|
239
|
-
return Object.keys(t).forEach(function(n) {
|
|
240
|
-
var s = t[n], a = qt.default(n);
|
|
241
|
-
e.recursive && (k.isValidObject(s) ? k.belongToTypes(s, e.keepTypesOnRecursion) || (s = te(s, e)) : e.recursiveInArray && k.isArrayObject(s) && (s = Wt(s).map(function(u) {
|
|
242
|
-
var c = u;
|
|
243
|
-
if (k.isValidObject(u))
|
|
244
|
-
k.belongToTypes(c, e.keepTypesOnRecursion) || (c = te(u, e));
|
|
245
|
-
else if (k.isArrayObject(u)) {
|
|
246
|
-
var h = te({ key: u }, e);
|
|
247
|
-
c = h.key;
|
|
248
|
-
}
|
|
249
|
-
return c;
|
|
250
|
-
}))), r[a] = s;
|
|
251
|
-
}), r;
|
|
252
|
-
}
|
|
253
|
-
Re.default = te;
|
|
254
|
-
var De = {}, Gt = C && C.__spreadArrays || function() {
|
|
255
|
-
for (var t = 0, e = 0, r = arguments.length; e < r; e++)
|
|
256
|
-
t += arguments[e].length;
|
|
257
|
-
for (var n = Array(t), s = 0, e = 0; e < r; e++)
|
|
258
|
-
for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
|
|
259
|
-
n[s] = a[u];
|
|
260
|
-
return n;
|
|
261
|
-
};
|
|
262
|
-
Object.defineProperty(De, "__esModule", { value: !0 });
|
|
263
|
-
var L = K, Ht = ce;
|
|
264
|
-
function re(t, e) {
|
|
265
|
-
if (e === void 0 && (e = L.DefaultOption), !L.isValidObject(t))
|
|
266
|
-
return null;
|
|
267
|
-
e = L.validateOptions(e);
|
|
268
|
-
var r = {};
|
|
269
|
-
return Object.keys(t).forEach(function(n) {
|
|
270
|
-
var s = t[n], a = Ht.default(n);
|
|
271
|
-
e.recursive && (L.isValidObject(s) ? L.belongToTypes(s, e.keepTypesOnRecursion) || (s = re(s, e)) : e.recursiveInArray && L.isArrayObject(s) && (s = Gt(s).map(function(u) {
|
|
272
|
-
var c = u;
|
|
273
|
-
if (L.isValidObject(u))
|
|
274
|
-
L.belongToTypes(c, e.keepTypesOnRecursion) || (c = re(u, e));
|
|
275
|
-
else if (L.isArrayObject(u)) {
|
|
276
|
-
var h = re({ key: u }, e);
|
|
277
|
-
c = h.key;
|
|
278
|
-
}
|
|
279
|
-
return c;
|
|
280
|
-
}))), r[a] = s;
|
|
281
|
-
}), r;
|
|
282
|
-
}
|
|
283
|
-
De.default = re;
|
|
284
|
-
Object.defineProperty(d, "__esModule", { value: !0 });
|
|
285
|
-
d.kebabKeys = d.pascalKeys = d.snakeKeys = d.camelKeys = d.upperKeys = d.lowerKeys = d.toLowerCase = d.toUpperCase = d.toKebabCase = d.toHeaderCase = d.toSentenceCase = d.toTextCase = d.toPathCase = d.toDotCase = d.toPascalCase = d.toSnakeCase = d.toCamelCase = void 0;
|
|
286
|
-
var Ge = oe;
|
|
287
|
-
d.toCamelCase = Ge.default;
|
|
288
|
-
var He = ue;
|
|
289
|
-
d.toSnakeCase = He.default;
|
|
290
|
-
var Xe = le;
|
|
291
|
-
d.toPascalCase = Xe.default;
|
|
292
|
-
var Je = Ie;
|
|
293
|
-
d.toDotCase = Je.default;
|
|
294
|
-
var Qe = Ne;
|
|
295
|
-
d.toPathCase = Qe.default;
|
|
296
|
-
var _e = Ee;
|
|
297
|
-
d.toTextCase = _e.default;
|
|
298
|
-
var et = Ce;
|
|
299
|
-
d.toSentenceCase = et.default;
|
|
300
|
-
var tt = $e;
|
|
301
|
-
d.toHeaderCase = tt.default;
|
|
302
|
-
var rt = ce;
|
|
303
|
-
d.toKebabCase = rt.default;
|
|
304
|
-
var nt = Ue;
|
|
305
|
-
d.lowerKeys = nt.default;
|
|
306
|
-
var st = xe;
|
|
307
|
-
d.upperKeys = st.default;
|
|
308
|
-
var it = Me;
|
|
309
|
-
d.camelKeys = it.default;
|
|
310
|
-
var at = je;
|
|
311
|
-
d.snakeKeys = at.default;
|
|
312
|
-
var ot = Re;
|
|
313
|
-
d.pascalKeys = ot.default;
|
|
314
|
-
var ut = De;
|
|
315
|
-
d.kebabKeys = ut.default;
|
|
316
|
-
var lt = function(t) {
|
|
317
|
-
return String(t || "").toLowerCase();
|
|
318
|
-
};
|
|
319
|
-
d.toLowerCase = lt;
|
|
320
|
-
var ct = function(t) {
|
|
321
|
-
return String(t || "").toUpperCase();
|
|
322
|
-
};
|
|
323
|
-
d.toUpperCase = ct;
|
|
324
|
-
var Xt = {
|
|
325
|
-
toCamelCase: Ge.default,
|
|
326
|
-
toSnakeCase: He.default,
|
|
327
|
-
toPascalCase: Xe.default,
|
|
328
|
-
toDotCase: Je.default,
|
|
329
|
-
toPathCase: Qe.default,
|
|
330
|
-
toTextCase: _e.default,
|
|
331
|
-
toSentenceCase: et.default,
|
|
332
|
-
toHeaderCase: tt.default,
|
|
333
|
-
toKebabCase: rt.default,
|
|
334
|
-
toUpperCase: ct,
|
|
335
|
-
toLowerCase: lt,
|
|
336
|
-
lowerKeys: nt.default,
|
|
337
|
-
upperKeys: st.default,
|
|
338
|
-
camelKeys: it.default,
|
|
339
|
-
snakeKeys: at.default,
|
|
340
|
-
pascalKeys: ot.default,
|
|
341
|
-
kebabKeys: ut.default
|
|
342
|
-
};
|
|
343
|
-
d.default = Xt;
|
|
344
|
-
var ft = d;
|
|
345
|
-
const dt = {
|
|
24
|
+
return e;
|
|
25
|
+
}, He = Ee(Ve), Ke = (r) => r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`), Xe = Ee(Ke), oe = {
|
|
346
26
|
recursive: !0,
|
|
347
27
|
recursiveInArray: !0,
|
|
348
28
|
keepTypesOnRecursion: [Number, String, Uint8Array]
|
|
349
|
-
},
|
|
350
|
-
var
|
|
351
|
-
let
|
|
29
|
+
}, Je = (r = oe) => (r.recursive == null ? r = oe : r.recursiveInArray == null && (r.recursiveInArray = !1), r), fe = (r) => r != null && Array.isArray(r), te = (r) => r != null && typeof r == "object" && !Array.isArray(r), pe = (r, e) => (e || []).some((t) => r instanceof t), Ae = (r) => r != null && typeof r == "object" && !Array.isArray(r);
|
|
30
|
+
var Qe = Object.defineProperty, _e = (r, e, t) => e in r ? Qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, q = (r, e, t) => _e(r, typeof e != "symbol" ? e + "" : e, t);
|
|
31
|
+
let et = class {
|
|
352
32
|
constructor() {
|
|
353
|
-
|
|
33
|
+
q(this, "contentType", "application/json"), q(this, "decoder"), q(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
|
|
354
34
|
}
|
|
355
35
|
encode(e) {
|
|
356
36
|
return this.encoder.encode(this.encodeString(e)).buffer;
|
|
357
37
|
}
|
|
358
|
-
decode(e,
|
|
359
|
-
return this.decodeString(this.decoder.decode(e),
|
|
38
|
+
decode(e, t) {
|
|
39
|
+
return this.decodeString(this.decoder.decode(e), t);
|
|
360
40
|
}
|
|
361
|
-
decodeString(e,
|
|
362
|
-
const n =
|
|
363
|
-
return
|
|
41
|
+
decodeString(e, t) {
|
|
42
|
+
const n = JSON.parse(e), i = He(n);
|
|
43
|
+
return t != null ? t.parse(i) : i;
|
|
364
44
|
}
|
|
365
45
|
encodeString(e) {
|
|
366
|
-
|
|
46
|
+
const t = Xe(e);
|
|
47
|
+
return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : Ae(i) && "encode_value" in i ? typeof i.value == "bigint" ? i.value.toString() : i.value : typeof i == "bigint" ? i.toString() : i);
|
|
367
48
|
}
|
|
368
49
|
static registerCustomType() {
|
|
369
50
|
}
|
|
51
|
+
}, tt = class {
|
|
52
|
+
constructor() {
|
|
53
|
+
q(this, "contentType", "text/csv");
|
|
54
|
+
}
|
|
55
|
+
encode(e) {
|
|
56
|
+
const t = this.encodeString(e);
|
|
57
|
+
return new TextEncoder().encode(t).buffer;
|
|
58
|
+
}
|
|
59
|
+
decode(e, t) {
|
|
60
|
+
const n = new TextDecoder().decode(e);
|
|
61
|
+
return this.decodeString(n, t);
|
|
62
|
+
}
|
|
63
|
+
encodeString(e) {
|
|
64
|
+
if (!Array.isArray(e) || e.length === 0 || !Ae(e[0]))
|
|
65
|
+
throw new Error("Payload must be an array of objects");
|
|
66
|
+
const t = Object.keys(e[0]), n = [t.join(",")];
|
|
67
|
+
return e.forEach((i) => {
|
|
68
|
+
const a = t.map((c) => JSON.stringify(i[c] ?? ""));
|
|
69
|
+
n.push(a.join(","));
|
|
70
|
+
}), n.join(`
|
|
71
|
+
`);
|
|
72
|
+
}
|
|
73
|
+
decodeString(e, t) {
|
|
74
|
+
const [n, ...i] = e.trim().split(`
|
|
75
|
+
`).map((h) => h.trim());
|
|
76
|
+
if (n.length === 0)
|
|
77
|
+
return t != null ? t.parse({}) : {};
|
|
78
|
+
const a = n.split(",").map((h) => h.trim()), c = {};
|
|
79
|
+
return a.forEach((h) => {
|
|
80
|
+
c[h] = [];
|
|
81
|
+
}), i.forEach((h) => {
|
|
82
|
+
const p = h.split(",").map((m) => m.trim());
|
|
83
|
+
a.forEach((m, v) => {
|
|
84
|
+
const w = this.parseValue(p[v]);
|
|
85
|
+
w != null && c[m].push(w);
|
|
86
|
+
});
|
|
87
|
+
}), t != null ? t.parse(c) : c;
|
|
88
|
+
}
|
|
89
|
+
parseValue(e) {
|
|
90
|
+
if (e == null || e.length === 0) return null;
|
|
91
|
+
const t = Number(e);
|
|
92
|
+
return isNaN(t) ? e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e : t;
|
|
93
|
+
}
|
|
94
|
+
static registerCustomType() {
|
|
95
|
+
}
|
|
96
|
+
}, rt = class {
|
|
97
|
+
constructor() {
|
|
98
|
+
q(this, "contentType", "text/plain");
|
|
99
|
+
}
|
|
100
|
+
encode(e) {
|
|
101
|
+
return new TextEncoder().encode(e).buffer;
|
|
102
|
+
}
|
|
103
|
+
decode(e, t) {
|
|
104
|
+
const n = new TextDecoder().decode(e);
|
|
105
|
+
return t != null ? t.parse(n) : n;
|
|
106
|
+
}
|
|
370
107
|
};
|
|
371
|
-
new
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
x:
|
|
406
|
-
y:
|
|
108
|
+
new et();
|
|
109
|
+
new tt();
|
|
110
|
+
new rt();
|
|
111
|
+
const Q = s.tuple([s.number(), s.number()]);
|
|
112
|
+
s.tuple([s.bigint(), s.bigint()]);
|
|
113
|
+
const xe = s.object({ width: s.number(), height: s.number() }), nt = s.object({
|
|
114
|
+
signedWidth: s.number(),
|
|
115
|
+
signedHeight: s.number()
|
|
116
|
+
}), st = ["width", "height"];
|
|
117
|
+
s.enum(st);
|
|
118
|
+
const it = ["start", "center", "end"], ot = ["signedWidth", "signedHeight"];
|
|
119
|
+
s.enum(ot);
|
|
120
|
+
const X = s.object({ x: s.number(), y: s.number() }), at = s.object({ clientX: s.number(), clientY: s.number() }), ut = ["x", "y"], $e = s.enum(ut), Ue = ["top", "right", "bottom", "left"];
|
|
121
|
+
s.enum(Ue);
|
|
122
|
+
const ct = ["left", "right"], Me = s.enum(ct), lt = ["top", "bottom"], Ce = s.enum(lt), Be = ["center"], ye = s.enum(Be), ht = [...Ue, ...Be], Re = s.enum(ht);
|
|
123
|
+
s.enum(it);
|
|
124
|
+
const dt = ["first", "last"];
|
|
125
|
+
s.enum(dt);
|
|
126
|
+
const ft = s.object({ lower: s.number(), upper: s.number() }), pt = s.object({ lower: s.bigint(), upper: s.bigint() });
|
|
127
|
+
s.union([ft, Q]);
|
|
128
|
+
s.union([pt, Q]);
|
|
129
|
+
s.union([$e, Re]);
|
|
130
|
+
s.union([$e, Re, s.instanceof(String)]);
|
|
131
|
+
const re = (r, e) => {
|
|
132
|
+
const t = {};
|
|
133
|
+
if (typeof r == "number" || typeof r == "bigint")
|
|
134
|
+
e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
|
|
135
|
+
else if (Array.isArray(r)) {
|
|
136
|
+
if (r.length !== 2) throw new Error("bounds: expected array of length 2");
|
|
137
|
+
[t.lower, t.upper] = r;
|
|
138
|
+
} else return ge(r);
|
|
139
|
+
return ge(t);
|
|
140
|
+
}, ge = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r;
|
|
141
|
+
s.object({
|
|
142
|
+
x: Me.or(ye),
|
|
143
|
+
y: Ce.or(ye)
|
|
407
144
|
});
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
]),
|
|
416
|
-
if (typeof
|
|
417
|
-
if (e === void 0)
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
height: H
|
|
145
|
+
const yt = s.object({ x: Me, y: Ce }), gt = Object.freeze({ x: "left", y: "top" }), wt = (r, e) => r.x === e.x && r.y === e.y, we = s.union([
|
|
146
|
+
s.number(),
|
|
147
|
+
X,
|
|
148
|
+
Q,
|
|
149
|
+
xe,
|
|
150
|
+
nt,
|
|
151
|
+
at
|
|
152
|
+
]), mt = (r, e) => {
|
|
153
|
+
if (typeof r == "string") {
|
|
154
|
+
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
155
|
+
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
156
|
+
}
|
|
157
|
+
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
|
+
}, me = Object.freeze({ x: 0, y: 0 }), Z = s.union([s.number(), s.string()]);
|
|
159
|
+
s.object({
|
|
160
|
+
top: Z,
|
|
161
|
+
left: Z,
|
|
162
|
+
width: Z,
|
|
163
|
+
height: Z
|
|
428
164
|
});
|
|
429
|
-
|
|
430
|
-
left:
|
|
431
|
-
top:
|
|
432
|
-
right:
|
|
433
|
-
bottom:
|
|
165
|
+
s.object({
|
|
166
|
+
left: s.number(),
|
|
167
|
+
top: s.number(),
|
|
168
|
+
right: s.number(),
|
|
169
|
+
bottom: s.number()
|
|
434
170
|
});
|
|
435
|
-
|
|
436
|
-
one:
|
|
437
|
-
two:
|
|
438
|
-
root:
|
|
171
|
+
s.object({
|
|
172
|
+
one: X,
|
|
173
|
+
two: X,
|
|
174
|
+
root: yt
|
|
439
175
|
});
|
|
440
|
-
const
|
|
176
|
+
const le = (r, e, t = 0, n = 0, i) => {
|
|
441
177
|
const a = {
|
|
442
|
-
one: { ...
|
|
443
|
-
two: { ...
|
|
444
|
-
root:
|
|
178
|
+
one: { ...me },
|
|
179
|
+
two: { ...me },
|
|
180
|
+
root: i ?? gt
|
|
445
181
|
};
|
|
446
|
-
if (typeof
|
|
182
|
+
if (typeof r == "number") {
|
|
447
183
|
if (typeof e != "number")
|
|
448
184
|
throw new Error("Box constructor called with invalid arguments");
|
|
449
|
-
return a.one = { x:
|
|
185
|
+
return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
|
|
450
186
|
}
|
|
451
|
-
return "one" in
|
|
187
|
+
return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (a.one = { x: r.left, y: r.top }, a.two = { x: r.right, y: r.bottom }, a) : (a.one = r, e == null ? a.two = { x: a.one.x + t, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
|
|
452
188
|
x: a.one.x + e.width,
|
|
453
189
|
y: a.one.y + e.height
|
|
454
190
|
} : "signedWidth" in e ? a.two = {
|
|
455
191
|
x: a.one.x + e.signedWidth,
|
|
456
192
|
y: a.one.y + e.signedHeight
|
|
457
193
|
} : a.two = e, a));
|
|
458
|
-
},
|
|
459
|
-
const e =
|
|
194
|
+
}, ne = (r) => {
|
|
195
|
+
const e = le(r);
|
|
460
196
|
return { lower: e.one.x, upper: e.two.x };
|
|
461
|
-
},
|
|
462
|
-
const e =
|
|
197
|
+
}, se = (r) => {
|
|
198
|
+
const e = le(r);
|
|
463
199
|
return { lower: e.one.y, upper: e.two.y };
|
|
464
|
-
},
|
|
465
|
-
var
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return [
|
|
476
|
-
|
|
477
|
-
if (t ===
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
200
|
+
}, Ot = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
|
|
201
|
+
var vt = Object.defineProperty, bt = (r, e, t) => e in r ? vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, C = (r, e, t) => bt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
202
|
+
const Tt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
203
|
+
s.object({ offset: we, scale: we });
|
|
204
|
+
const It = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
|
|
205
|
+
e,
|
|
206
|
+
i ? n - r : n + r
|
|
207
|
+
], St = (r) => (e, t, n, i) => [
|
|
208
|
+
e,
|
|
209
|
+
i ? n / r : n * r
|
|
210
|
+
], Nt = (r) => (e, t, n) => {
|
|
211
|
+
if (e === null) return [r, n];
|
|
212
|
+
const { lower: i, upper: a } = e, { lower: c, upper: h } = r, p = a - i, m = h - c;
|
|
213
|
+
if (t === "dimension") return [r, n * (m / p)];
|
|
214
|
+
const v = (n - i) * (m / p) + c;
|
|
215
|
+
return [r, v];
|
|
216
|
+
}, Et = (r) => (e, t, n) => [r, n], At = () => (r, e, t) => {
|
|
217
|
+
if (r === null) throw new Error("cannot invert without bounds");
|
|
218
|
+
if (e === "dimension") return [r, t];
|
|
219
|
+
const { lower: n, upper: i } = r;
|
|
220
|
+
return [r, i - (t - n)];
|
|
221
|
+
}, xt = (r) => (e, t, n) => {
|
|
222
|
+
const { lower: i, upper: a } = r;
|
|
223
|
+
return n = Tt(n, i, a), [e, n];
|
|
224
|
+
}, ae = class W {
|
|
487
225
|
constructor() {
|
|
488
|
-
|
|
226
|
+
C(this, "ops", []), C(this, "currBounds", null), C(this, "currType", null), C(this, "reversed", !1), this.ops = [];
|
|
489
227
|
}
|
|
490
228
|
static translate(e) {
|
|
491
|
-
return new
|
|
229
|
+
return new W().translate(e);
|
|
492
230
|
}
|
|
493
231
|
static magnify(e) {
|
|
494
|
-
return new
|
|
232
|
+
return new W().magnify(e);
|
|
495
233
|
}
|
|
496
|
-
static scale(e,
|
|
497
|
-
return new
|
|
234
|
+
static scale(e, t) {
|
|
235
|
+
return new W().scale(e, t);
|
|
498
236
|
}
|
|
499
237
|
translate(e) {
|
|
500
|
-
const
|
|
501
|
-
return n.type = "translate",
|
|
238
|
+
const t = this.new(), n = It(e);
|
|
239
|
+
return n.type = "translate", t.ops.push(n), t;
|
|
502
240
|
}
|
|
503
241
|
magnify(e) {
|
|
504
|
-
const
|
|
505
|
-
return n.type = "magnify",
|
|
242
|
+
const t = this.new(), n = St(e);
|
|
243
|
+
return n.type = "magnify", t.ops.push(n), t;
|
|
506
244
|
}
|
|
507
|
-
scale(e,
|
|
508
|
-
const n =
|
|
509
|
-
return a.type = "scale",
|
|
245
|
+
scale(e, t) {
|
|
246
|
+
const n = re(e, t), i = this.new(), a = Nt(n);
|
|
247
|
+
return a.type = "scale", i.ops.push(a), i;
|
|
510
248
|
}
|
|
511
|
-
clamp(e,
|
|
512
|
-
const n =
|
|
513
|
-
return a.type = "clamp",
|
|
249
|
+
clamp(e, t) {
|
|
250
|
+
const n = re(e, t), i = this.new(), a = xt(n);
|
|
251
|
+
return a.type = "clamp", i.ops.push(a), i;
|
|
514
252
|
}
|
|
515
|
-
reBound(e,
|
|
516
|
-
const n =
|
|
517
|
-
return a.type = "re-bound",
|
|
253
|
+
reBound(e, t) {
|
|
254
|
+
const n = re(e, t), i = this.new(), a = Et(n);
|
|
255
|
+
return a.type = "re-bound", i.ops.push(a), i;
|
|
518
256
|
}
|
|
519
257
|
invert() {
|
|
520
|
-
const e =
|
|
258
|
+
const e = At();
|
|
521
259
|
e.type = "invert";
|
|
522
|
-
const
|
|
523
|
-
return
|
|
260
|
+
const t = this.new();
|
|
261
|
+
return t.ops.push(e), t;
|
|
524
262
|
}
|
|
525
263
|
pos(e) {
|
|
526
264
|
return this.exec("position", e);
|
|
@@ -529,91 +267,91 @@ const Sr = (t) => (e, r, n, s) => r === "dimension" ? [e, n] : [e, s ? n - t : n
|
|
|
529
267
|
return this.exec("dimension", e);
|
|
530
268
|
}
|
|
531
269
|
new() {
|
|
532
|
-
const e = new
|
|
270
|
+
const e = new W();
|
|
533
271
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
534
272
|
}
|
|
535
|
-
exec(e,
|
|
273
|
+
exec(e, t) {
|
|
536
274
|
return this.currBounds = null, this.ops.reduce(
|
|
537
|
-
([n,
|
|
538
|
-
[null,
|
|
275
|
+
([n, i], a) => a(n, e, i, this.reversed),
|
|
276
|
+
[null, t]
|
|
539
277
|
)[1];
|
|
540
278
|
}
|
|
541
279
|
reverse() {
|
|
542
280
|
const e = this.new();
|
|
543
281
|
e.ops.reverse();
|
|
544
|
-
const
|
|
545
|
-
return e.ops.forEach((n,
|
|
546
|
-
if (n.type === "scale" ||
|
|
282
|
+
const t = [];
|
|
283
|
+
return e.ops.forEach((n, i) => {
|
|
284
|
+
if (n.type === "scale" || t.some(([c, h]) => i >= c && i <= h))
|
|
547
285
|
return;
|
|
548
|
-
const a = e.ops.findIndex((
|
|
549
|
-
a !== -1 &&
|
|
550
|
-
}),
|
|
551
|
-
const a = e.ops.slice(n,
|
|
552
|
-
a.unshift(e.ops[
|
|
286
|
+
const a = e.ops.findIndex((c, h) => c.type === "scale" && h > i);
|
|
287
|
+
a !== -1 && t.push([i, a]);
|
|
288
|
+
}), t.forEach(([n, i]) => {
|
|
289
|
+
const a = e.ops.slice(n, i);
|
|
290
|
+
a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
|
|
553
291
|
}), e.reversed = !e.reversed, e;
|
|
554
292
|
}
|
|
555
293
|
};
|
|
556
|
-
|
|
557
|
-
let
|
|
558
|
-
const
|
|
559
|
-
constructor(e = new
|
|
560
|
-
|
|
294
|
+
C(ae, "IDENTITY", new ae());
|
|
295
|
+
let Oe = ae;
|
|
296
|
+
const ve = class M {
|
|
297
|
+
constructor(e = new Oe(), t = new Oe(), n = null) {
|
|
298
|
+
C(this, "x"), C(this, "y"), C(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
|
|
561
299
|
}
|
|
562
|
-
static translate(e,
|
|
563
|
-
return new
|
|
300
|
+
static translate(e, t) {
|
|
301
|
+
return new M().translate(e, t);
|
|
564
302
|
}
|
|
565
303
|
static translateX(e) {
|
|
566
|
-
return new
|
|
304
|
+
return new M().translateX(e);
|
|
567
305
|
}
|
|
568
306
|
static translateY(e) {
|
|
569
|
-
return new
|
|
307
|
+
return new M().translateY(e);
|
|
570
308
|
}
|
|
571
309
|
static clamp(e) {
|
|
572
|
-
return new
|
|
310
|
+
return new M().clamp(e);
|
|
573
311
|
}
|
|
574
312
|
static magnify(e) {
|
|
575
|
-
return new
|
|
313
|
+
return new M().magnify(e);
|
|
576
314
|
}
|
|
577
315
|
static scale(e) {
|
|
578
|
-
return new
|
|
316
|
+
return new M().scale(e);
|
|
579
317
|
}
|
|
580
318
|
static reBound(e) {
|
|
581
|
-
return new
|
|
319
|
+
return new M().reBound(e);
|
|
582
320
|
}
|
|
583
|
-
translate(e,
|
|
584
|
-
const n =
|
|
585
|
-
return
|
|
321
|
+
translate(e, t) {
|
|
322
|
+
const n = mt(e, t), i = this.copy();
|
|
323
|
+
return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
|
|
586
324
|
}
|
|
587
325
|
translateX(e) {
|
|
588
|
-
const
|
|
589
|
-
return
|
|
326
|
+
const t = this.copy();
|
|
327
|
+
return t.x = this.x.translate(e), t;
|
|
590
328
|
}
|
|
591
329
|
translateY(e) {
|
|
592
|
-
const
|
|
593
|
-
return
|
|
330
|
+
const t = this.copy();
|
|
331
|
+
return t.y = this.y.translate(e), t;
|
|
594
332
|
}
|
|
595
333
|
magnify(e) {
|
|
596
|
-
const
|
|
597
|
-
return
|
|
334
|
+
const t = this.copy();
|
|
335
|
+
return t.x = this.x.magnify(e.x), t.y = this.y.magnify(e.y), t;
|
|
598
336
|
}
|
|
599
337
|
scale(e) {
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
338
|
+
const t = this.copy();
|
|
339
|
+
if (Ot(e)) {
|
|
602
340
|
const n = this.currRoot;
|
|
603
|
-
return
|
|
341
|
+
return t.currRoot = e.root, n != null && !wt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ne(e)), t.y = t.y.scale(se(e)), t;
|
|
604
342
|
}
|
|
605
|
-
return
|
|
343
|
+
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
606
344
|
}
|
|
607
345
|
reBound(e) {
|
|
608
|
-
const
|
|
609
|
-
return
|
|
346
|
+
const t = this.copy();
|
|
347
|
+
return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
|
|
610
348
|
}
|
|
611
349
|
clamp(e) {
|
|
612
|
-
const
|
|
613
|
-
return
|
|
350
|
+
const t = this.copy();
|
|
351
|
+
return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
|
|
614
352
|
}
|
|
615
353
|
copy() {
|
|
616
|
-
const e = new
|
|
354
|
+
const e = new M();
|
|
617
355
|
return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
|
|
618
356
|
}
|
|
619
357
|
reverse() {
|
|
@@ -624,7 +362,7 @@ const Ke = class P {
|
|
|
624
362
|
return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
|
|
625
363
|
}
|
|
626
364
|
box(e) {
|
|
627
|
-
return
|
|
365
|
+
return le(
|
|
628
366
|
this.pos(e.one),
|
|
629
367
|
this.pos(e.two),
|
|
630
368
|
0,
|
|
@@ -633,70 +371,42 @@ const Ke = class P {
|
|
|
633
371
|
);
|
|
634
372
|
}
|
|
635
373
|
};
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
)
|
|
641
|
-
const
|
|
642
|
-
let we;
|
|
643
|
-
const xr = () => {
|
|
644
|
-
if (typeof window > "u")
|
|
645
|
-
return;
|
|
646
|
-
const t = window.navigator.userAgent.toLowerCase();
|
|
647
|
-
if (t.includes("mac"))
|
|
648
|
-
return "MacOS";
|
|
649
|
-
if (t.includes("win"))
|
|
650
|
-
return "Windows";
|
|
651
|
-
if (t.includes("linux"))
|
|
652
|
-
return "Linux";
|
|
653
|
-
}, Mr = (t = {}) => {
|
|
654
|
-
const { force: e, default: r } = t;
|
|
655
|
-
return e ?? we ?? (we = xr(), we ?? r);
|
|
656
|
-
}, Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
657
|
-
__proto__: null,
|
|
658
|
-
OPERATING_SYSTEMS: mt,
|
|
659
|
-
RUNTIME: $r,
|
|
660
|
-
detect: bt,
|
|
661
|
-
getOS: Mr,
|
|
662
|
-
osZ: Ur
|
|
663
|
-
}, Symbol.toStringTag, { value: "Module" })), jr = i.object({ signedWidth: i.number(), signedHeight: i.number() });
|
|
664
|
-
i.union([ht, jr, ie, fe]);
|
|
665
|
-
var Rr = Object.defineProperty, Dr = (t, e, r) => e in t ? Rr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, l = (t, e, r) => (Dr(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
666
|
-
const St = (t, e) => {
|
|
667
|
-
const r = new m(e);
|
|
374
|
+
C(ve, "IDENTITY", new ve());
|
|
375
|
+
const $t = s.object({ signedWidth: s.number(), signedHeight: s.number() });
|
|
376
|
+
s.union([xe, $t, X, Q]);
|
|
377
|
+
var Ut = Object.defineProperty, Mt = (r, e, t) => e in r ? Ut(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => Mt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
378
|
+
const De = (r, e) => {
|
|
379
|
+
const t = new T(e);
|
|
668
380
|
if (![
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
].some((
|
|
381
|
+
I.DAY,
|
|
382
|
+
I.HOUR,
|
|
383
|
+
I.MINUTE,
|
|
384
|
+
I.SECOND,
|
|
385
|
+
I.MILLISECOND,
|
|
386
|
+
I.MICROSECOND,
|
|
387
|
+
I.NANOSECOND
|
|
388
|
+
].some((i) => i.equals(t)))
|
|
677
389
|
throw new Error(
|
|
678
390
|
"Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
|
|
679
391
|
);
|
|
680
|
-
const n =
|
|
681
|
-
return
|
|
682
|
-
}, y = class
|
|
683
|
-
constructor(e,
|
|
684
|
-
if (
|
|
685
|
-
this.value = f.now().valueOf();
|
|
392
|
+
const n = r.valueOf() % t.valueOf();
|
|
393
|
+
return r instanceof T ? new T(n) : new I(n);
|
|
394
|
+
}, y = class l {
|
|
395
|
+
constructor(e, t = "UTC") {
|
|
396
|
+
if (u(this, "value"), u(this, "encodeValue", !0), e == null) this.value = l.now().valueOf();
|
|
686
397
|
else if (e instanceof Date)
|
|
687
|
-
this.value = BigInt(e.getTime()) *
|
|
398
|
+
this.value = BigInt(e.getTime()) * l.MILLISECOND.valueOf();
|
|
688
399
|
else if (typeof e == "string")
|
|
689
|
-
this.value =
|
|
690
|
-
else if (Array.isArray(e))
|
|
691
|
-
this.value = f.parseDate(e);
|
|
400
|
+
this.value = l.parseDateTimeString(e, t).valueOf();
|
|
401
|
+
else if (Array.isArray(e)) this.value = l.parseDate(e);
|
|
692
402
|
else {
|
|
693
403
|
let n = BigInt(0);
|
|
694
|
-
e instanceof Number && (e = e.valueOf()),
|
|
404
|
+
e instanceof Number && (e = e.valueOf()), t === "local" && (n = l.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = l.MAX : e = l.MIN)), this.value = BigInt(e.valueOf()) + n;
|
|
695
405
|
}
|
|
696
406
|
}
|
|
697
|
-
static parseDate([e = 1970,
|
|
698
|
-
const
|
|
699
|
-
return new
|
|
407
|
+
static parseDate([e = 1970, t = 1, n = 1]) {
|
|
408
|
+
const i = new Date(e, t - 1, n, 0, 0, 0, 0);
|
|
409
|
+
return new l(BigInt(i.getTime()) * l.MILLISECOND.valueOf()).truncate(l.DAY).valueOf();
|
|
700
410
|
}
|
|
701
411
|
encode() {
|
|
702
412
|
return this.value.toString();
|
|
@@ -704,56 +414,56 @@ const St = (t, e) => {
|
|
|
704
414
|
valueOf() {
|
|
705
415
|
return this.value;
|
|
706
416
|
}
|
|
707
|
-
static parseTimeString(e,
|
|
708
|
-
const [n,
|
|
709
|
-
let
|
|
710
|
-
a != null && ([
|
|
711
|
-
let
|
|
712
|
-
return
|
|
417
|
+
static parseTimeString(e, t = "UTC") {
|
|
418
|
+
const [n, i, a] = e.split(":");
|
|
419
|
+
let c = "00", h = "00";
|
|
420
|
+
a != null && ([c, h] = a.split("."));
|
|
421
|
+
let p = l.hours(parseInt(n ?? "00", 10)).add(l.minutes(parseInt(i ?? "00", 10))).add(l.seconds(parseInt(c ?? "00", 10))).add(l.milliseconds(parseInt(h ?? "00", 10)));
|
|
422
|
+
return t === "local" && (p = p.add(l.utcOffset)), p.valueOf();
|
|
713
423
|
}
|
|
714
|
-
static parseDateTimeString(e,
|
|
424
|
+
static parseDateTimeString(e, t = "UTC") {
|
|
715
425
|
if (!e.includes("/") && !e.includes("-"))
|
|
716
|
-
return
|
|
426
|
+
return l.parseTimeString(e, t);
|
|
717
427
|
const n = new Date(e);
|
|
718
|
-
return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new
|
|
719
|
-
BigInt(n.getTime()) *
|
|
720
|
-
|
|
428
|
+
return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new l(
|
|
429
|
+
BigInt(n.getTime()) * l.MILLISECOND.valueOf(),
|
|
430
|
+
t
|
|
721
431
|
).valueOf();
|
|
722
432
|
}
|
|
723
|
-
fString(e = "ISO",
|
|
433
|
+
fString(e = "ISO", t = "UTC") {
|
|
724
434
|
switch (e) {
|
|
725
435
|
case "ISODate":
|
|
726
|
-
return this.toISOString(
|
|
436
|
+
return this.toISOString(t).slice(0, 10);
|
|
727
437
|
case "ISOTime":
|
|
728
|
-
return this.toISOString(
|
|
438
|
+
return this.toISOString(t).slice(11, 23);
|
|
729
439
|
case "time":
|
|
730
|
-
return this.timeString(!1,
|
|
440
|
+
return this.timeString(!1, t);
|
|
731
441
|
case "preciseTime":
|
|
732
|
-
return this.timeString(!0,
|
|
442
|
+
return this.timeString(!0, t);
|
|
733
443
|
case "date":
|
|
734
444
|
return this.dateString();
|
|
735
445
|
case "preciseDate":
|
|
736
|
-
return `${this.dateString()} ${this.timeString(!0,
|
|
446
|
+
return `${this.dateString()} ${this.timeString(!0, t)}`;
|
|
737
447
|
case "dateTime":
|
|
738
|
-
return `${this.dateString()} ${this.timeString(!1,
|
|
448
|
+
return `${this.dateString()} ${this.timeString(!1, t)}`;
|
|
739
449
|
default:
|
|
740
|
-
return this.toISOString(
|
|
450
|
+
return this.toISOString(t);
|
|
741
451
|
}
|
|
742
452
|
}
|
|
743
453
|
toISOString(e = "UTC") {
|
|
744
|
-
return e === "UTC" ? this.date().toISOString() : this.sub(
|
|
454
|
+
return e === "UTC" ? this.date().toISOString() : this.sub(l.utcOffset).date().toISOString();
|
|
745
455
|
}
|
|
746
|
-
timeString(e = !1,
|
|
747
|
-
const n = this.toISOString(
|
|
456
|
+
timeString(e = !1, t = "UTC") {
|
|
457
|
+
const n = this.toISOString(t);
|
|
748
458
|
return e ? n.slice(11, 23) : n.slice(11, 19);
|
|
749
459
|
}
|
|
750
460
|
dateString() {
|
|
751
|
-
const e = this.date(),
|
|
752
|
-
return `${
|
|
461
|
+
const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
|
|
462
|
+
return `${t} ${n}`;
|
|
753
463
|
}
|
|
754
464
|
static get utcOffset() {
|
|
755
|
-
return new
|
|
756
|
-
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) *
|
|
465
|
+
return new I(
|
|
466
|
+
BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * l.MINUTE.valueOf()
|
|
757
467
|
);
|
|
758
468
|
}
|
|
759
469
|
/**
|
|
@@ -762,7 +472,7 @@ const St = (t, e) => {
|
|
|
762
472
|
* @param other - The other timestamp.
|
|
763
473
|
*/
|
|
764
474
|
static since(e) {
|
|
765
|
-
return new
|
|
475
|
+
return new l().span(e);
|
|
766
476
|
}
|
|
767
477
|
/** @returns A JavaScript Date object representing the TimeStamp. */
|
|
768
478
|
date() {
|
|
@@ -775,7 +485,7 @@ const St = (t, e) => {
|
|
|
775
485
|
* @returns True if the TimeStamps are equal, false otherwise.
|
|
776
486
|
*/
|
|
777
487
|
equals(e) {
|
|
778
|
-
return this.valueOf() === new
|
|
488
|
+
return this.valueOf() === new l(e).valueOf();
|
|
779
489
|
}
|
|
780
490
|
/**
|
|
781
491
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -795,7 +505,7 @@ const St = (t, e) => {
|
|
|
795
505
|
* valid, regardless of the TimeStamp order.
|
|
796
506
|
*/
|
|
797
507
|
range(e) {
|
|
798
|
-
return new
|
|
508
|
+
return new Ct(this, e).makeValid();
|
|
799
509
|
}
|
|
800
510
|
/**
|
|
801
511
|
* Creates a TimeRange starting at the TimeStamp and spanning the given
|
|
@@ -824,7 +534,7 @@ const St = (t, e) => {
|
|
|
824
534
|
* otherwise.
|
|
825
535
|
*/
|
|
826
536
|
after(e) {
|
|
827
|
-
return this.valueOf() > new
|
|
537
|
+
return this.valueOf() > new l(e).valueOf();
|
|
828
538
|
}
|
|
829
539
|
/**
|
|
830
540
|
* Checks if the TimeStamp is after or equal to the given TimeStamp.
|
|
@@ -834,7 +544,7 @@ const St = (t, e) => {
|
|
|
834
544
|
* false otherwise.
|
|
835
545
|
*/
|
|
836
546
|
afterEq(e) {
|
|
837
|
-
return this.valueOf() >= new
|
|
547
|
+
return this.valueOf() >= new l(e).valueOf();
|
|
838
548
|
}
|
|
839
549
|
/**
|
|
840
550
|
* Checks if the TimeStamp is before the given TimeStamp.
|
|
@@ -844,7 +554,7 @@ const St = (t, e) => {
|
|
|
844
554
|
* otherwise.
|
|
845
555
|
*/
|
|
846
556
|
before(e) {
|
|
847
|
-
return this.valueOf() < new
|
|
557
|
+
return this.valueOf() < new l(e).valueOf();
|
|
848
558
|
}
|
|
849
559
|
/**
|
|
850
560
|
* Checks if TimeStamp is before or equal to the current timestamp.
|
|
@@ -854,7 +564,7 @@ const St = (t, e) => {
|
|
|
854
564
|
* false otherwise.
|
|
855
565
|
*/
|
|
856
566
|
beforeEq(e) {
|
|
857
|
-
return this.valueOf() <= new
|
|
567
|
+
return this.valueOf() <= new l(e).valueOf();
|
|
858
568
|
}
|
|
859
569
|
/**
|
|
860
570
|
* Adds a TimeSpan to the TimeStamp.
|
|
@@ -864,7 +574,7 @@ const St = (t, e) => {
|
|
|
864
574
|
* TimeSpan.
|
|
865
575
|
*/
|
|
866
576
|
add(e) {
|
|
867
|
-
return new
|
|
577
|
+
return new l(this.valueOf() + BigInt(e.valueOf()));
|
|
868
578
|
}
|
|
869
579
|
/**
|
|
870
580
|
* Subtracts a TimeSpan from the TimeStamp.
|
|
@@ -874,13 +584,13 @@ const St = (t, e) => {
|
|
|
874
584
|
* TimeSpan.
|
|
875
585
|
*/
|
|
876
586
|
sub(e) {
|
|
877
|
-
return new
|
|
587
|
+
return new l(this.valueOf() - BigInt(e.valueOf()));
|
|
878
588
|
}
|
|
879
589
|
/**
|
|
880
590
|
* @returns The number of milliseconds since the unix epoch.
|
|
881
591
|
*/
|
|
882
592
|
milliseconds() {
|
|
883
|
-
return Number(this.valueOf()) / Number(
|
|
593
|
+
return Number(this.valueOf()) / Number(l.MILLISECOND.valueOf());
|
|
884
594
|
}
|
|
885
595
|
toString() {
|
|
886
596
|
return this.date().toISOString();
|
|
@@ -897,11 +607,11 @@ const St = (t, e) => {
|
|
|
897
607
|
* @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
|
|
898
608
|
*/
|
|
899
609
|
remainder(e) {
|
|
900
|
-
return
|
|
610
|
+
return De(this, e);
|
|
901
611
|
}
|
|
902
612
|
/** @returns true if the day portion TimeStamp is today, false otherwise. */
|
|
903
613
|
get isToday() {
|
|
904
|
-
return this.truncate(
|
|
614
|
+
return this.truncate(I.DAY).equals(l.now().truncate(I.DAY));
|
|
905
615
|
}
|
|
906
616
|
truncate(e) {
|
|
907
617
|
return this.sub(this.remainder(e));
|
|
@@ -912,74 +622,74 @@ const St = (t, e) => {
|
|
|
912
622
|
* JavaScript can do).
|
|
913
623
|
*/
|
|
914
624
|
static now() {
|
|
915
|
-
return new
|
|
625
|
+
return new l(/* @__PURE__ */ new Date());
|
|
916
626
|
}
|
|
917
627
|
static max(...e) {
|
|
918
|
-
let
|
|
628
|
+
let t = l.MIN;
|
|
919
629
|
for (const n of e) {
|
|
920
|
-
const
|
|
921
|
-
|
|
630
|
+
const i = new l(n);
|
|
631
|
+
i.after(t) && (t = i);
|
|
922
632
|
}
|
|
923
|
-
return
|
|
633
|
+
return t;
|
|
924
634
|
}
|
|
925
635
|
static min(...e) {
|
|
926
|
-
let
|
|
636
|
+
let t = l.MAX;
|
|
927
637
|
for (const n of e) {
|
|
928
|
-
const
|
|
929
|
-
|
|
638
|
+
const i = new l(n);
|
|
639
|
+
i.before(t) && (t = i);
|
|
930
640
|
}
|
|
931
|
-
return
|
|
641
|
+
return t;
|
|
932
642
|
}
|
|
933
643
|
/** @returns a new TimeStamp n nanoseconds after the unix epoch */
|
|
934
644
|
static nanoseconds(e) {
|
|
935
|
-
return new
|
|
645
|
+
return new l(e);
|
|
936
646
|
}
|
|
937
647
|
/** @returns a new TimeStamp n microseconds after the unix epoch */
|
|
938
648
|
static microseconds(e) {
|
|
939
|
-
return
|
|
649
|
+
return l.nanoseconds(e * 1e3);
|
|
940
650
|
}
|
|
941
651
|
/** @returns a new TimeStamp n milliseconds after the unix epoch */
|
|
942
652
|
static milliseconds(e) {
|
|
943
|
-
return
|
|
653
|
+
return l.microseconds(e * 1e3);
|
|
944
654
|
}
|
|
945
655
|
/** @returns a new TimeStamp n seconds after the unix epoch */
|
|
946
656
|
static seconds(e) {
|
|
947
|
-
return
|
|
657
|
+
return l.milliseconds(e * 1e3);
|
|
948
658
|
}
|
|
949
659
|
/** @returns a new TimeStamp n minutes after the unix epoch */
|
|
950
660
|
static minutes(e) {
|
|
951
|
-
return
|
|
661
|
+
return l.seconds(e * 60);
|
|
952
662
|
}
|
|
953
663
|
/** @returns a new TimeStamp n hours after the unix epoch */
|
|
954
664
|
static hours(e) {
|
|
955
|
-
return
|
|
665
|
+
return l.minutes(e * 60);
|
|
956
666
|
}
|
|
957
667
|
/** @returns a new TimeStamp n days after the unix epoch */
|
|
958
668
|
static days(e) {
|
|
959
|
-
return
|
|
669
|
+
return l.hours(e * 24);
|
|
960
670
|
}
|
|
961
671
|
};
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
672
|
+
u(y, "NANOSECOND", y.nanoseconds(1)), /** One microsecond after the unix epoch */
|
|
673
|
+
u(y, "MICROSECOND", y.microseconds(1)), /** One millisecond after the unix epoch */
|
|
674
|
+
u(y, "MILLISECOND", y.milliseconds(1)), /** One second after the unix epoch */
|
|
675
|
+
u(y, "SECOND", y.seconds(1)), /** One minute after the unix epoch */
|
|
676
|
+
u(y, "MINUTE", y.minutes(1)), /** One hour after the unix epoch */
|
|
677
|
+
u(y, "HOUR", y.hours(1)), /** One day after the unix epoch */
|
|
678
|
+
u(y, "DAY", y.days(1)), /** The maximum possible value for a timestamp */
|
|
679
|
+
u(y, "MAX", new y((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
|
|
680
|
+
u(y, "MIN", new y(0)), /** The unix epoch */
|
|
681
|
+
u(y, "ZERO", new y(0)), /** A zod schema for validating timestamps */
|
|
682
|
+
u(y, "z", s.union([
|
|
683
|
+
s.object({ value: s.bigint() }).transform((r) => new y(r.value)),
|
|
684
|
+
s.string().transform((r) => new y(BigInt(r))),
|
|
685
|
+
s.instanceof(Number).transform((r) => new y(r)),
|
|
686
|
+
s.number().transform((r) => new y(r)),
|
|
687
|
+
s.instanceof(y)
|
|
978
688
|
]));
|
|
979
|
-
let
|
|
980
|
-
const g = class
|
|
689
|
+
let T = y;
|
|
690
|
+
const g = class d {
|
|
981
691
|
constructor(e) {
|
|
982
|
-
|
|
692
|
+
u(this, "value"), u(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
|
|
983
693
|
}
|
|
984
694
|
encode() {
|
|
985
695
|
return this.value.toString();
|
|
@@ -988,52 +698,52 @@ const g = class p {
|
|
|
988
698
|
return this.value;
|
|
989
699
|
}
|
|
990
700
|
lessThan(e) {
|
|
991
|
-
return this.valueOf() < new
|
|
701
|
+
return this.valueOf() < new d(e).valueOf();
|
|
992
702
|
}
|
|
993
703
|
greaterThan(e) {
|
|
994
|
-
return this.valueOf() > new
|
|
704
|
+
return this.valueOf() > new d(e).valueOf();
|
|
995
705
|
}
|
|
996
706
|
lessThanOrEqual(e) {
|
|
997
|
-
return this.valueOf() <= new
|
|
707
|
+
return this.valueOf() <= new d(e).valueOf();
|
|
998
708
|
}
|
|
999
709
|
greaterThanOrEqual(e) {
|
|
1000
|
-
return this.valueOf() >= new
|
|
710
|
+
return this.valueOf() >= new d(e).valueOf();
|
|
1001
711
|
}
|
|
1002
712
|
remainder(e) {
|
|
1003
|
-
return
|
|
713
|
+
return De(this, e);
|
|
1004
714
|
}
|
|
1005
715
|
truncate(e) {
|
|
1006
|
-
return new
|
|
716
|
+
return new d(
|
|
1007
717
|
BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
|
|
1008
718
|
);
|
|
1009
719
|
}
|
|
1010
720
|
toString() {
|
|
1011
|
-
const e = this.truncate(
|
|
1012
|
-
let
|
|
1013
|
-
return
|
|
721
|
+
const e = this.truncate(d.DAY), t = this.truncate(d.HOUR), n = this.truncate(d.MINUTE), i = this.truncate(d.SECOND), a = this.truncate(d.MILLISECOND), c = this.truncate(d.MICROSECOND), h = this.truncate(d.NANOSECOND), p = e, m = t.sub(e), v = n.sub(t), w = i.sub(n), A = a.sub(i), k = c.sub(a), U = h.sub(c);
|
|
722
|
+
let E = "";
|
|
723
|
+
return p.isZero || (E += `${p.days}d `), m.isZero || (E += `${m.hours}h `), v.isZero || (E += `${v.minutes}m `), w.isZero || (E += `${w.seconds}s `), A.isZero || (E += `${A.milliseconds}ms `), k.isZero || (E += `${k.microseconds}µs `), U.isZero || (E += `${U.nanoseconds}ns`), E.trim();
|
|
1014
724
|
}
|
|
1015
725
|
/** @returns the decimal number of days in the timespan */
|
|
1016
726
|
get days() {
|
|
1017
|
-
return Number(this.valueOf()) / Number(
|
|
727
|
+
return Number(this.valueOf()) / Number(d.DAY.valueOf());
|
|
1018
728
|
}
|
|
1019
729
|
/** @returns the decimal number of hours in the timespan */
|
|
1020
730
|
get hours() {
|
|
1021
|
-
return Number(this.valueOf()) / Number(
|
|
731
|
+
return Number(this.valueOf()) / Number(d.HOUR.valueOf());
|
|
1022
732
|
}
|
|
1023
733
|
/** @returns the decimal number of minutes in the timespan */
|
|
1024
734
|
get minutes() {
|
|
1025
|
-
return Number(this.valueOf()) / Number(
|
|
735
|
+
return Number(this.valueOf()) / Number(d.MINUTE.valueOf());
|
|
1026
736
|
}
|
|
1027
737
|
/** @returns The number of seconds in the TimeSpan. */
|
|
1028
738
|
get seconds() {
|
|
1029
|
-
return Number(this.valueOf()) / Number(
|
|
739
|
+
return Number(this.valueOf()) / Number(d.SECOND.valueOf());
|
|
1030
740
|
}
|
|
1031
741
|
/** @returns The number of milliseconds in the TimeSpan. */
|
|
1032
742
|
get milliseconds() {
|
|
1033
|
-
return Number(this.valueOf()) / Number(
|
|
743
|
+
return Number(this.valueOf()) / Number(d.MILLISECOND.valueOf());
|
|
1034
744
|
}
|
|
1035
745
|
get microseconds() {
|
|
1036
|
-
return Number(this.valueOf()) / Number(
|
|
746
|
+
return Number(this.valueOf()) / Number(d.MICROSECOND.valueOf());
|
|
1037
747
|
}
|
|
1038
748
|
get nanoseconds() {
|
|
1039
749
|
return Number(this.valueOf());
|
|
@@ -1052,7 +762,7 @@ const g = class p {
|
|
|
1052
762
|
* @returns True if the TimeSpans are equal, false otherwise.
|
|
1053
763
|
*/
|
|
1054
764
|
equals(e) {
|
|
1055
|
-
return this.valueOf() === new
|
|
765
|
+
return this.valueOf() === new d(e).valueOf();
|
|
1056
766
|
}
|
|
1057
767
|
/**
|
|
1058
768
|
* Adds a TimeSpan to the TimeSpan.
|
|
@@ -1060,7 +770,7 @@ const g = class p {
|
|
|
1060
770
|
* @returns A new TimeSpan representing the sum of the two TimeSpans.
|
|
1061
771
|
*/
|
|
1062
772
|
add(e) {
|
|
1063
|
-
return new
|
|
773
|
+
return new d(this.valueOf() + new d(e).valueOf());
|
|
1064
774
|
}
|
|
1065
775
|
/**
|
|
1066
776
|
* Creates a TimeSpan representing the duration between the two timestamps.
|
|
@@ -1068,7 +778,7 @@ const g = class p {
|
|
|
1068
778
|
* @param other
|
|
1069
779
|
*/
|
|
1070
780
|
sub(e) {
|
|
1071
|
-
return new
|
|
781
|
+
return new d(this.valueOf() - new d(e).valueOf());
|
|
1072
782
|
}
|
|
1073
783
|
/**
|
|
1074
784
|
* Creates a TimeSpan representing the given number of nanoseconds.
|
|
@@ -1077,7 +787,7 @@ const g = class p {
|
|
|
1077
787
|
* @returns A TimeSpan representing the given number of nanoseconds.
|
|
1078
788
|
*/
|
|
1079
789
|
static nanoseconds(e = 1) {
|
|
1080
|
-
return new
|
|
790
|
+
return new d(e);
|
|
1081
791
|
}
|
|
1082
792
|
/**
|
|
1083
793
|
* Creates a TimeSpan representing the given number of microseconds.
|
|
@@ -1086,7 +796,7 @@ const g = class p {
|
|
|
1086
796
|
* @returns A TimeSpan representing the given number of microseconds.
|
|
1087
797
|
*/
|
|
1088
798
|
static microseconds(e = 1) {
|
|
1089
|
-
return
|
|
799
|
+
return d.nanoseconds(e * 1e3);
|
|
1090
800
|
}
|
|
1091
801
|
/**
|
|
1092
802
|
* Creates a TimeSpan representing the given number of milliseconds.
|
|
@@ -1095,7 +805,7 @@ const g = class p {
|
|
|
1095
805
|
* @returns A TimeSpan representing the given number of milliseconds.
|
|
1096
806
|
*/
|
|
1097
807
|
static milliseconds(e = 1) {
|
|
1098
|
-
return
|
|
808
|
+
return d.microseconds(e * 1e3);
|
|
1099
809
|
}
|
|
1100
810
|
/**
|
|
1101
811
|
* Creates a TimeSpan representing the given number of seconds.
|
|
@@ -1104,7 +814,7 @@ const g = class p {
|
|
|
1104
814
|
* @returns A TimeSpan representing the given number of seconds.
|
|
1105
815
|
*/
|
|
1106
816
|
static seconds(e = 1) {
|
|
1107
|
-
return
|
|
817
|
+
return d.milliseconds(e * 1e3);
|
|
1108
818
|
}
|
|
1109
819
|
/**
|
|
1110
820
|
* Creates a TimeSpan representing the given number of minutes.
|
|
@@ -1113,7 +823,7 @@ const g = class p {
|
|
|
1113
823
|
* @returns A TimeSpan representing the given number of minutes.
|
|
1114
824
|
*/
|
|
1115
825
|
static minutes(e) {
|
|
1116
|
-
return
|
|
826
|
+
return d.seconds(e.valueOf() * 60);
|
|
1117
827
|
}
|
|
1118
828
|
/**
|
|
1119
829
|
* Creates a TimeSpan representing the given number of hours.
|
|
@@ -1122,7 +832,7 @@ const g = class p {
|
|
|
1122
832
|
* @returns A TimeSpan representing the given number of hours.
|
|
1123
833
|
*/
|
|
1124
834
|
static hours(e) {
|
|
1125
|
-
return
|
|
835
|
+
return d.minutes(e * 60);
|
|
1126
836
|
}
|
|
1127
837
|
/**
|
|
1128
838
|
* Creates a TimeSpan representing the given number of days.
|
|
@@ -1131,28 +841,28 @@ const g = class p {
|
|
|
1131
841
|
* @returns A TimeSpan representing the given number of days.
|
|
1132
842
|
*/
|
|
1133
843
|
static days(e) {
|
|
1134
|
-
return
|
|
844
|
+
return d.hours(e * 24);
|
|
1135
845
|
}
|
|
1136
846
|
};
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
847
|
+
u(g, "NANOSECOND", g.nanoseconds(1)), /** A microsecond. */
|
|
848
|
+
u(g, "MICROSECOND", g.microseconds(1)), /** A millisecond. */
|
|
849
|
+
u(g, "MILLISECOND", g.milliseconds(1)), /** A second. */
|
|
850
|
+
u(g, "SECOND", g.seconds(1)), /** A minute. */
|
|
851
|
+
u(g, "MINUTE", g.minutes(1)), /** Represents an hour. */
|
|
852
|
+
u(g, "HOUR", g.hours(1)), /** Represents a day. */
|
|
853
|
+
u(g, "DAY", g.days(1)), /** The maximum possible value for a TimeSpan. */
|
|
854
|
+
u(g, "MAX", new g((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
|
|
855
|
+
u(g, "MIN", new g(0)), /** The zero value for a TimeSpan. */
|
|
856
|
+
u(g, "ZERO", new g(0)), /** A zod schema for validating and transforming timespans */
|
|
857
|
+
u(g, "z", s.union([
|
|
858
|
+
s.object({ value: s.bigint() }).transform((r) => new g(r.value)),
|
|
859
|
+
s.string().transform((r) => new g(BigInt(r))),
|
|
860
|
+
s.instanceof(Number).transform((r) => new g(r)),
|
|
861
|
+
s.number().transform((r) => new g(r)),
|
|
862
|
+
s.instanceof(g)
|
|
1153
863
|
]));
|
|
1154
|
-
let
|
|
1155
|
-
const
|
|
864
|
+
let I = g;
|
|
865
|
+
const z = class V extends Number {
|
|
1156
866
|
constructor(e) {
|
|
1157
867
|
e instanceof Number ? super(e.valueOf()) : super(e);
|
|
1158
868
|
}
|
|
@@ -1162,7 +872,7 @@ const X = class ne extends Number {
|
|
|
1162
872
|
}
|
|
1163
873
|
/** @returns The number of seconds in the Rate. */
|
|
1164
874
|
equals(e) {
|
|
1165
|
-
return this.valueOf() === new
|
|
875
|
+
return this.valueOf() === new V(e).valueOf();
|
|
1166
876
|
}
|
|
1167
877
|
/**
|
|
1168
878
|
* Calculates the period of the Rate as a TimeSpan.
|
|
@@ -1170,7 +880,7 @@ const X = class ne extends Number {
|
|
|
1170
880
|
* @returns A TimeSpan representing the period of the Rate.
|
|
1171
881
|
*/
|
|
1172
882
|
get period() {
|
|
1173
|
-
return
|
|
883
|
+
return I.seconds(1 / this.valueOf());
|
|
1174
884
|
}
|
|
1175
885
|
/**
|
|
1176
886
|
* Calculates the number of samples in the given TimeSpan at this rate.
|
|
@@ -1179,7 +889,7 @@ const X = class ne extends Number {
|
|
|
1179
889
|
* @returns The number of samples in the given TimeSpan at this rate.
|
|
1180
890
|
*/
|
|
1181
891
|
sampleCount(e) {
|
|
1182
|
-
return new
|
|
892
|
+
return new I(e).seconds * this.valueOf();
|
|
1183
893
|
}
|
|
1184
894
|
/**
|
|
1185
895
|
* Calculates the number of bytes in the given TimeSpan at this rate.
|
|
@@ -1188,8 +898,8 @@ const X = class ne extends Number {
|
|
|
1188
898
|
* @param density - The density of the data in bytes per sample.
|
|
1189
899
|
* @returns The number of bytes in the given TimeSpan at this rate.
|
|
1190
900
|
*/
|
|
1191
|
-
byteCount(e,
|
|
1192
|
-
return this.sampleCount(e) * new
|
|
901
|
+
byteCount(e, t) {
|
|
902
|
+
return this.sampleCount(e) * new N(t).valueOf();
|
|
1193
903
|
}
|
|
1194
904
|
/**
|
|
1195
905
|
* Calculates a TimeSpan given the number of samples at this rate.
|
|
@@ -1198,7 +908,7 @@ const X = class ne extends Number {
|
|
|
1198
908
|
* @returns A TimeSpan that corresponds to the given number of samples.
|
|
1199
909
|
*/
|
|
1200
910
|
span(e) {
|
|
1201
|
-
return
|
|
911
|
+
return I.seconds(e / this.valueOf());
|
|
1202
912
|
}
|
|
1203
913
|
/**
|
|
1204
914
|
* Calculates a TimeSpan given the number of bytes at this rate.
|
|
@@ -1207,8 +917,8 @@ const X = class ne extends Number {
|
|
|
1207
917
|
* @param density - The density of the data in bytes per sample.
|
|
1208
918
|
* @returns A TimeSpan that corresponds to the given number of bytes.
|
|
1209
919
|
*/
|
|
1210
|
-
byteSpan(e,
|
|
1211
|
-
return this.span(e.valueOf() /
|
|
920
|
+
byteSpan(e, t) {
|
|
921
|
+
return this.span(e.valueOf() / t.valueOf());
|
|
1212
922
|
}
|
|
1213
923
|
/**
|
|
1214
924
|
* Creates a Rate representing the given number of Hz.
|
|
@@ -1217,7 +927,7 @@ const X = class ne extends Number {
|
|
|
1217
927
|
* @returns A Rate representing the given number of Hz.
|
|
1218
928
|
*/
|
|
1219
929
|
static hz(e) {
|
|
1220
|
-
return new
|
|
930
|
+
return new V(e);
|
|
1221
931
|
}
|
|
1222
932
|
/**
|
|
1223
933
|
* Creates a Rate representing the given number of kHz.
|
|
@@ -1226,13 +936,13 @@ const X = class ne extends Number {
|
|
|
1226
936
|
* @returns A Rate representing the given number of kHz.
|
|
1227
937
|
*/
|
|
1228
938
|
static khz(e) {
|
|
1229
|
-
return
|
|
939
|
+
return V.hz(e * 1e3);
|
|
1230
940
|
}
|
|
1231
941
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
942
|
+
u(z, "z", s.union([
|
|
943
|
+
s.number().transform((r) => new z(r)),
|
|
944
|
+
s.instanceof(Number).transform((r) => new z(r)),
|
|
945
|
+
s.instanceof(z)
|
|
1236
946
|
]));
|
|
1237
947
|
const b = class extends Number {
|
|
1238
948
|
/**
|
|
@@ -1249,34 +959,34 @@ const b = class extends Number {
|
|
|
1249
959
|
return e.valueOf() / this.valueOf();
|
|
1250
960
|
}
|
|
1251
961
|
size(e) {
|
|
1252
|
-
return new
|
|
962
|
+
return new Bt(e * this.valueOf());
|
|
1253
963
|
}
|
|
1254
964
|
};
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
965
|
+
u(b, "UNKNOWN", new b(0)), /** 128 bits per value. */
|
|
966
|
+
u(b, "BIT128", new b(16)), /** 64 bits per value. */
|
|
967
|
+
u(b, "BIT64", new b(8)), /** 32 bits per value. */
|
|
968
|
+
u(b, "BIT32", new b(4)), /** 16 bits per value. */
|
|
969
|
+
u(b, "BIT16", new b(2)), /** 8 bits per value. */
|
|
970
|
+
u(b, "BIT8", new b(1)), /** A zod schema for validating and transforming densities */
|
|
971
|
+
u(b, "z", s.union([
|
|
972
|
+
s.number().transform((r) => new b(r)),
|
|
973
|
+
s.instanceof(Number).transform((r) => new b(r)),
|
|
974
|
+
s.instanceof(b)
|
|
1265
975
|
]));
|
|
1266
|
-
let
|
|
1267
|
-
const
|
|
976
|
+
let N = b;
|
|
977
|
+
const x = class H {
|
|
1268
978
|
/**
|
|
1269
979
|
* Creates a TimeRange from the given start and end TimeStamps.
|
|
1270
980
|
*
|
|
1271
981
|
* @param start - A TimeStamp representing the start of the range.
|
|
1272
982
|
* @param end - A TimeStamp representing the end of the range.
|
|
1273
983
|
*/
|
|
1274
|
-
constructor(e,
|
|
1275
|
-
|
|
984
|
+
constructor(e, t) {
|
|
985
|
+
u(this, "start"), u(this, "end"), typeof e == "object" && "start" in e ? (this.start = new T(e.start), this.end = new T(e.end)) : (this.start = new T(e), this.end = new T(t));
|
|
1276
986
|
}
|
|
1277
987
|
/** @returns The TimeSpan occupied by the TimeRange. */
|
|
1278
988
|
get span() {
|
|
1279
|
-
return new
|
|
989
|
+
return new I(this.end.valueOf() - this.start.valueOf());
|
|
1280
990
|
}
|
|
1281
991
|
/**
|
|
1282
992
|
* Checks if the timestamp is valid i.e. the start is before the end.
|
|
@@ -1308,7 +1018,7 @@ const U = class se {
|
|
|
1308
1018
|
* @returns A TimeRange with the start and end swapped.
|
|
1309
1019
|
*/
|
|
1310
1020
|
swap() {
|
|
1311
|
-
return new
|
|
1021
|
+
return new H(this.end, this.start);
|
|
1312
1022
|
}
|
|
1313
1023
|
/**
|
|
1314
1024
|
* Checks if the TimeRange is equal to the given TimeRange.
|
|
@@ -1333,55 +1043,53 @@ const U = class se {
|
|
|
1333
1043
|
* @param other - The other TimeRange to compare to.
|
|
1334
1044
|
* @returns True if the two TimeRanges overlap, false otherwise.
|
|
1335
1045
|
*/
|
|
1336
|
-
overlapsWith(e,
|
|
1046
|
+
overlapsWith(e, t = I.ZERO) {
|
|
1337
1047
|
e = e.makeValid();
|
|
1338
1048
|
const n = this.makeValid();
|
|
1339
|
-
if (this.equals(e))
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
const s = m.max(n.start, e.start), a = m.min(n.end, e.end);
|
|
1344
|
-
return a.before(s) ? !1 : new T(a.sub(s)).greaterThanOrEqual(r);
|
|
1049
|
+
if (this.equals(e)) return !0;
|
|
1050
|
+
if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
|
|
1051
|
+
const i = T.max(n.start, e.start), a = T.min(n.end, e.end);
|
|
1052
|
+
return a.before(i) ? !1 : new I(a.sub(i)).greaterThanOrEqual(t);
|
|
1345
1053
|
}
|
|
1346
|
-
roughlyEquals(e,
|
|
1347
|
-
let n = this.start.sub(e.start).valueOf(),
|
|
1348
|
-
return n < 0 && (n = -n),
|
|
1054
|
+
roughlyEquals(e, t) {
|
|
1055
|
+
let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
|
|
1056
|
+
return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
|
|
1349
1057
|
}
|
|
1350
1058
|
contains(e) {
|
|
1351
|
-
return e instanceof
|
|
1059
|
+
return e instanceof H ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
|
|
1352
1060
|
}
|
|
1353
1061
|
boundBy(e) {
|
|
1354
|
-
const
|
|
1355
|
-
return e.start.after(this.start) && (
|
|
1062
|
+
const t = new H(this.start, this.end);
|
|
1063
|
+
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;
|
|
1356
1064
|
}
|
|
1357
1065
|
};
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1066
|
+
u(x, "MAX", new x(T.MIN, T.MAX)), /** The minimum possible time range. */
|
|
1067
|
+
u(x, "MIN", new x(T.MAX, T.MIN)), /** A zero time range. */
|
|
1068
|
+
u(x, "ZERO", new x(T.ZERO, T.ZERO)), /** A zod schema for validating and transforming time ranges */
|
|
1069
|
+
u(x, "z", s.union([
|
|
1070
|
+
s.object({ start: T.z, end: T.z }).transform((r) => new x(r.start, r.end)),
|
|
1071
|
+
s.instanceof(x)
|
|
1364
1072
|
]));
|
|
1365
|
-
let
|
|
1366
|
-
const o = class
|
|
1073
|
+
let Ct = x;
|
|
1074
|
+
const o = class $ extends String {
|
|
1367
1075
|
constructor(e) {
|
|
1368
|
-
if (e instanceof
|
|
1076
|
+
if (e instanceof $ || typeof e == "string" || typeof e.valueOf() == "string") {
|
|
1369
1077
|
super(e.valueOf());
|
|
1370
1078
|
return;
|
|
1371
1079
|
} else {
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1374
|
-
super(
|
|
1080
|
+
const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
|
|
1081
|
+
if (t != null) {
|
|
1082
|
+
super(t.valueOf());
|
|
1375
1083
|
return;
|
|
1376
1084
|
}
|
|
1377
1085
|
}
|
|
1378
|
-
throw super(
|
|
1086
|
+
throw super($.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
|
|
1379
1087
|
}
|
|
1380
1088
|
/**
|
|
1381
1089
|
* @returns the TypedArray constructor for the DataType.
|
|
1382
1090
|
*/
|
|
1383
1091
|
get Array() {
|
|
1384
|
-
const e =
|
|
1092
|
+
const e = $.ARRAY_CONSTRUCTORS.get(this.toString());
|
|
1385
1093
|
if (e == null)
|
|
1386
1094
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
1387
1095
|
return e;
|
|
@@ -1394,10 +1102,10 @@ const o = class x extends String {
|
|
|
1394
1102
|
return this.valueOf();
|
|
1395
1103
|
}
|
|
1396
1104
|
get isVariable() {
|
|
1397
|
-
return this.equals(
|
|
1105
|
+
return this.equals($.JSON) || this.equals($.STRING);
|
|
1398
1106
|
}
|
|
1399
1107
|
get isNumeric() {
|
|
1400
|
-
return !this.isVariable && !this.equals(
|
|
1108
|
+
return !this.isVariable && !this.equals($.UUID);
|
|
1401
1109
|
}
|
|
1402
1110
|
get isInteger() {
|
|
1403
1111
|
return this.toString().startsWith("int");
|
|
@@ -1406,9 +1114,8 @@ const o = class x extends String {
|
|
|
1406
1114
|
return this.toString().startsWith("float");
|
|
1407
1115
|
}
|
|
1408
1116
|
get density() {
|
|
1409
|
-
const e =
|
|
1410
|
-
if (e == null)
|
|
1411
|
-
throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1117
|
+
const e = $.DENSITIES.get(this.toString());
|
|
1118
|
+
if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
|
|
1412
1119
|
return e;
|
|
1413
1120
|
}
|
|
1414
1121
|
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
@@ -1432,27 +1139,27 @@ const o = class x extends String {
|
|
|
1432
1139
|
return this.toString();
|
|
1433
1140
|
}
|
|
1434
1141
|
get usesBigInt() {
|
|
1435
|
-
return
|
|
1142
|
+
return $.BIG_INT_TYPES.some((e) => e.equals(this));
|
|
1436
1143
|
}
|
|
1437
1144
|
};
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1145
|
+
u(o, "UNKNOWN", new o("unknown")), /** Represents a 64-bit floating point value. */
|
|
1146
|
+
u(o, "FLOAT64", new o("float64")), /** Represents a 32-bit floating point value. */
|
|
1147
|
+
u(o, "FLOAT32", new o("float32")), /** Represents a 64-bit signed integer value. */
|
|
1148
|
+
u(o, "INT64", new o("int64")), /** Represents a 32-bit signed integer value. */
|
|
1149
|
+
u(o, "INT32", new o("int32")), /** Represents a 16-bit signed integer value. */
|
|
1150
|
+
u(o, "INT16", new o("int16")), /** Represents a 8-bit signed integer value. */
|
|
1151
|
+
u(o, "INT8", new o("int8")), /** Represents a 64-bit unsigned integer value. */
|
|
1152
|
+
u(o, "UINT64", new o("uint64")), /** Represents a 32-bit unsigned integer value. */
|
|
1153
|
+
u(o, "UINT32", new o("uint32")), /** Represents a 16-bit unsigned integer value. */
|
|
1154
|
+
u(o, "UINT16", new o("uint16")), /** Represents a 8-bit unsigned integer value. */
|
|
1155
|
+
u(o, "UINT8", new o("uint8")), /** Represents a boolean value. Alias for UINT8. */
|
|
1156
|
+
u(o, "BOOLEAN", o.UINT8), /** Represents a 64-bit unix epoch. */
|
|
1157
|
+
u(o, "TIMESTAMP", new o("timestamp")), /** Represents a UUID data type */
|
|
1158
|
+
u(o, "UUID", new o("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
|
|
1452
1159
|
* by a newline character. */
|
|
1453
|
-
|
|
1160
|
+
u(o, "STRING", new o("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
1454
1161
|
* newline character. */
|
|
1455
|
-
|
|
1162
|
+
u(o, "JSON", new o("json")), u(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
|
|
1456
1163
|
[o.UINT8.toString(), Uint8Array],
|
|
1457
1164
|
[o.UINT16.toString(), Uint16Array],
|
|
1458
1165
|
[o.UINT32.toString(), Uint32Array],
|
|
@@ -1467,7 +1174,7 @@ l(o, "JSON", new o("json")), l(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
|
|
|
1467
1174
|
[o.STRING.toString(), Uint8Array],
|
|
1468
1175
|
[o.JSON.toString(), Uint8Array],
|
|
1469
1176
|
[o.UUID.toString(), Uint8Array]
|
|
1470
|
-
])),
|
|
1177
|
+
])), u(o, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
|
|
1471
1178
|
[Uint8Array.name, o.UINT8],
|
|
1472
1179
|
[Uint16Array.name, o.UINT16],
|
|
1473
1180
|
[Uint32Array.name, o.UINT32],
|
|
@@ -1478,23 +1185,23 @@ l(o, "JSON", new o("json")), l(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
|
|
|
1478
1185
|
[Int16Array.name, o.INT16],
|
|
1479
1186
|
[Int32Array.name, o.INT32],
|
|
1480
1187
|
[BigInt64Array.name, o.INT64]
|
|
1481
|
-
])),
|
|
1482
|
-
[o.UINT8.toString(),
|
|
1483
|
-
[o.UINT16.toString(),
|
|
1484
|
-
[o.UINT32.toString(),
|
|
1485
|
-
[o.UINT64.toString(),
|
|
1486
|
-
[o.FLOAT32.toString(),
|
|
1487
|
-
[o.FLOAT64.toString(),
|
|
1488
|
-
[o.INT8.toString(),
|
|
1489
|
-
[o.INT16.toString(),
|
|
1490
|
-
[o.INT32.toString(),
|
|
1491
|
-
[o.INT64.toString(),
|
|
1492
|
-
[o.TIMESTAMP.toString(),
|
|
1493
|
-
[o.STRING.toString(),
|
|
1494
|
-
[o.JSON.toString(),
|
|
1495
|
-
[o.UUID.toString(),
|
|
1188
|
+
])), u(o, "DENSITIES", /* @__PURE__ */ new Map([
|
|
1189
|
+
[o.UINT8.toString(), N.BIT8],
|
|
1190
|
+
[o.UINT16.toString(), N.BIT16],
|
|
1191
|
+
[o.UINT32.toString(), N.BIT32],
|
|
1192
|
+
[o.UINT64.toString(), N.BIT64],
|
|
1193
|
+
[o.FLOAT32.toString(), N.BIT32],
|
|
1194
|
+
[o.FLOAT64.toString(), N.BIT64],
|
|
1195
|
+
[o.INT8.toString(), N.BIT8],
|
|
1196
|
+
[o.INT16.toString(), N.BIT16],
|
|
1197
|
+
[o.INT32.toString(), N.BIT32],
|
|
1198
|
+
[o.INT64.toString(), N.BIT64],
|
|
1199
|
+
[o.TIMESTAMP.toString(), N.BIT64],
|
|
1200
|
+
[o.STRING.toString(), N.UNKNOWN],
|
|
1201
|
+
[o.JSON.toString(), N.UNKNOWN],
|
|
1202
|
+
[o.UUID.toString(), N.BIT128]
|
|
1496
1203
|
])), /** All the data types. */
|
|
1497
|
-
|
|
1204
|
+
u(o, "ALL", [
|
|
1498
1205
|
o.UNKNOWN,
|
|
1499
1206
|
o.FLOAT64,
|
|
1500
1207
|
o.FLOAT32,
|
|
@@ -1510,12 +1217,12 @@ l(o, "ALL", [
|
|
|
1510
1217
|
o.UUID,
|
|
1511
1218
|
o.STRING,
|
|
1512
1219
|
o.JSON
|
|
1513
|
-
]),
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1220
|
+
]), u(o, "BIG_INT_TYPES", [o.INT64, o.UINT64, o.TIMESTAMP]), /** A zod schema for a DataType. */
|
|
1221
|
+
u(o, "z", s.union([
|
|
1222
|
+
s.string().transform((r) => new o(r)),
|
|
1223
|
+
s.instanceof(o)
|
|
1517
1224
|
]));
|
|
1518
|
-
const S = class
|
|
1225
|
+
const S = class O extends Number {
|
|
1519
1226
|
constructor(e) {
|
|
1520
1227
|
super(e.valueOf());
|
|
1521
1228
|
}
|
|
@@ -1528,33 +1235,33 @@ const S = class w extends Number {
|
|
|
1528
1235
|
return this.valueOf() < e.valueOf();
|
|
1529
1236
|
}
|
|
1530
1237
|
add(e) {
|
|
1531
|
-
return
|
|
1238
|
+
return O.bytes(this.valueOf() + e.valueOf());
|
|
1532
1239
|
}
|
|
1533
1240
|
sub(e) {
|
|
1534
|
-
return
|
|
1241
|
+
return O.bytes(this.valueOf() - e.valueOf());
|
|
1535
1242
|
}
|
|
1536
1243
|
truncate(e) {
|
|
1537
|
-
return new
|
|
1244
|
+
return new O(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
|
|
1538
1245
|
}
|
|
1539
1246
|
remainder(e) {
|
|
1540
|
-
return
|
|
1247
|
+
return O.bytes(this.valueOf() % e.valueOf());
|
|
1541
1248
|
}
|
|
1542
1249
|
get gigabytes() {
|
|
1543
|
-
return this.valueOf() /
|
|
1250
|
+
return this.valueOf() / O.GIGABYTE.valueOf();
|
|
1544
1251
|
}
|
|
1545
1252
|
get megabytes() {
|
|
1546
|
-
return this.valueOf() /
|
|
1253
|
+
return this.valueOf() / O.MEGABYTE.valueOf();
|
|
1547
1254
|
}
|
|
1548
1255
|
get kilobytes() {
|
|
1549
|
-
return this.valueOf() /
|
|
1256
|
+
return this.valueOf() / O.KILOBYTE.valueOf();
|
|
1550
1257
|
}
|
|
1551
1258
|
get terabytes() {
|
|
1552
|
-
return this.valueOf() /
|
|
1259
|
+
return this.valueOf() / O.TERABYTE.valueOf();
|
|
1553
1260
|
}
|
|
1554
1261
|
toString() {
|
|
1555
|
-
const e = this.truncate(
|
|
1556
|
-
let
|
|
1557
|
-
return
|
|
1262
|
+
const e = this.truncate(O.TERABYTE), t = this.truncate(O.GIGABYTE), n = this.truncate(O.MEGABYTE), i = this.truncate(O.KILOBYTE), a = this.truncate(O.BYTE), c = e, h = t.sub(e), p = n.sub(t), m = i.sub(n), v = a.sub(i);
|
|
1263
|
+
let w = "";
|
|
1264
|
+
return c.isZero || (w += `${c.terabytes}TB `), h.isZero || (w += `${h.gigabytes}GB `), p.isZero || (w += `${p.megabytes}MB `), m.isZero || (w += `${m.kilobytes}KB `), (!v.isZero || w === "") && (w += `${v.valueOf()}B`), w.trim();
|
|
1558
1265
|
}
|
|
1559
1266
|
/**
|
|
1560
1267
|
* Creates a Size from the given number of bytes.
|
|
@@ -1563,7 +1270,7 @@ const S = class w extends Number {
|
|
|
1563
1270
|
* @returns A Size representing the given number of bytes.
|
|
1564
1271
|
*/
|
|
1565
1272
|
static bytes(e = 1) {
|
|
1566
|
-
return new
|
|
1273
|
+
return new O(e);
|
|
1567
1274
|
}
|
|
1568
1275
|
/**
|
|
1569
1276
|
* Creates a Size from the given number if kilobytes.
|
|
@@ -1572,7 +1279,7 @@ const S = class w extends Number {
|
|
|
1572
1279
|
* @returns A Size representing the given number of kilobytes.
|
|
1573
1280
|
*/
|
|
1574
1281
|
static kilobytes(e = 1) {
|
|
1575
|
-
return
|
|
1282
|
+
return O.bytes(e.valueOf() * 1e3);
|
|
1576
1283
|
}
|
|
1577
1284
|
/**
|
|
1578
1285
|
* Creates a Size from the given number of megabytes.
|
|
@@ -1581,7 +1288,7 @@ const S = class w extends Number {
|
|
|
1581
1288
|
* @returns A Size representing the given number of megabytes.
|
|
1582
1289
|
*/
|
|
1583
1290
|
static megabytes(e = 1) {
|
|
1584
|
-
return
|
|
1291
|
+
return O.kilobytes(e.valueOf() * 1e3);
|
|
1585
1292
|
}
|
|
1586
1293
|
/**
|
|
1587
1294
|
* Creates a Size from the given number of gigabytes.
|
|
@@ -1590,7 +1297,7 @@ const S = class w extends Number {
|
|
|
1590
1297
|
* @returns A Size representing the given number of gigabytes.
|
|
1591
1298
|
*/
|
|
1592
1299
|
static gigabytes(e = 1) {
|
|
1593
|
-
return
|
|
1300
|
+
return O.megabytes(e.valueOf() * 1e3);
|
|
1594
1301
|
}
|
|
1595
1302
|
/**
|
|
1596
1303
|
* Creates a Size from the given number of terabytes.
|
|
@@ -1599,45 +1306,68 @@ const S = class w extends Number {
|
|
|
1599
1306
|
* @returns A Size representing the given number of terabytes.
|
|
1600
1307
|
*/
|
|
1601
1308
|
static terabytes(e) {
|
|
1602
|
-
return
|
|
1309
|
+
return O.gigabytes(e.valueOf() * 1e3);
|
|
1603
1310
|
}
|
|
1604
1311
|
get isZero() {
|
|
1605
1312
|
return this.valueOf() === 0;
|
|
1606
1313
|
}
|
|
1607
1314
|
};
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1315
|
+
u(S, "BYTE", new S(1)), /** A kilobyte */
|
|
1316
|
+
u(S, "KILOBYTE", S.kilobytes(1)), /** A megabyte */
|
|
1317
|
+
u(S, "MEGABYTE", S.megabytes(1)), /** A gigabyte */
|
|
1318
|
+
u(S, "GIGABYTE", S.gigabytes(1)), /** A terabyte. */
|
|
1319
|
+
u(S, "TERABYTE", S.terabytes(1)), /** The zero value for Size */
|
|
1320
|
+
u(S, "ZERO", new S(0)), /** A zod schema for a Size. */
|
|
1321
|
+
u(S, "z", s.union([
|
|
1322
|
+
s.number().transform((r) => new S(r)),
|
|
1323
|
+
s.instanceof(S)
|
|
1617
1324
|
]));
|
|
1618
|
-
let
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1325
|
+
let Bt = S;
|
|
1326
|
+
s.union([
|
|
1327
|
+
s.instanceof(Uint8Array),
|
|
1328
|
+
s.instanceof(Uint16Array),
|
|
1329
|
+
s.instanceof(Uint32Array),
|
|
1330
|
+
s.instanceof(BigUint64Array),
|
|
1331
|
+
s.instanceof(Float32Array),
|
|
1332
|
+
s.instanceof(Float64Array),
|
|
1333
|
+
s.instanceof(Int8Array),
|
|
1334
|
+
s.instanceof(Int16Array),
|
|
1335
|
+
s.instanceof(Int32Array),
|
|
1336
|
+
s.instanceof(BigInt64Array)
|
|
1630
1337
|
]);
|
|
1631
|
-
|
|
1632
|
-
|
|
1338
|
+
s.record(
|
|
1339
|
+
s.union([s.number(), s.string(), s.symbol()]),
|
|
1340
|
+
s.unknown()
|
|
1341
|
+
);
|
|
1342
|
+
const Ye = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", Rt = Ye(), Le = ["MacOS", "Windows", "Linux", "Docker"], Dt = s.enum(Le);
|
|
1343
|
+
let ie;
|
|
1344
|
+
const Yt = () => {
|
|
1345
|
+
if (typeof window > "u") return;
|
|
1346
|
+
const r = window.navigator.userAgent.toLowerCase();
|
|
1347
|
+
if (r.includes("mac")) return "MacOS";
|
|
1348
|
+
if (r.includes("win")) return "Windows";
|
|
1349
|
+
if (r.includes("linux")) return "Linux";
|
|
1350
|
+
}, Lt = (r = {}) => {
|
|
1351
|
+
const { force: e, default: t } = r;
|
|
1352
|
+
return e ?? ie ?? (ie = Yt(), ie ?? t);
|
|
1353
|
+
}, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1354
|
+
__proto__: null,
|
|
1355
|
+
OPERATING_SYSTEMS: Le,
|
|
1356
|
+
RUNTIME: Rt,
|
|
1357
|
+
detect: Ye,
|
|
1358
|
+
getOS: Lt,
|
|
1359
|
+
osZ: Dt
|
|
1360
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1361
|
+
var Pt = Object.defineProperty, jt = (r, e, t) => e in r ? Pt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, F = (r, e, t) => jt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
1362
|
+
const kt = (...r) => r.map(je).join(""), je = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Wt = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Ft = (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("&"), ue = class ce {
|
|
1633
1363
|
/**
|
|
1634
1364
|
* @param host - The hostname or IP address of the server.
|
|
1635
1365
|
* @param port - The port number of the server.
|
|
1636
1366
|
* @param protocol - The protocol to use for all requests. Defaults to "".
|
|
1637
1367
|
* @param pathPrefix - A path prefix to use for all requests. Defaults to "".
|
|
1638
1368
|
*/
|
|
1639
|
-
constructor({ host: e, port:
|
|
1640
|
-
|
|
1369
|
+
constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
|
|
1370
|
+
F(this, "protocol"), F(this, "host"), F(this, "port"), F(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = je(i);
|
|
1641
1371
|
}
|
|
1642
1372
|
/**
|
|
1643
1373
|
* Replaces creates a new URL with the specified properties replaced.
|
|
@@ -1645,7 +1375,7 @@ const Zr = (...t) => t.map(At).join(""), At = (t) => (t.endsWith("/") || (t += "
|
|
|
1645
1375
|
* @returns a new URL.
|
|
1646
1376
|
*/
|
|
1647
1377
|
replace(e) {
|
|
1648
|
-
return new
|
|
1378
|
+
return new ce({
|
|
1649
1379
|
host: e.host ?? this.host,
|
|
1650
1380
|
port: e.port ?? this.port,
|
|
1651
1381
|
protocol: e.protocol ?? this.protocol,
|
|
@@ -1658,149 +1388,154 @@ const Zr = (...t) => t.map(At).join(""), At = (t) => (t.endsWith("/") || (t += "
|
|
|
1658
1388
|
* @returns a new URL.
|
|
1659
1389
|
*/
|
|
1660
1390
|
child(e) {
|
|
1661
|
-
return new
|
|
1391
|
+
return new ce({
|
|
1662
1392
|
...this,
|
|
1663
|
-
pathPrefix:
|
|
1393
|
+
pathPrefix: kt(this.path, e)
|
|
1664
1394
|
});
|
|
1665
1395
|
}
|
|
1666
1396
|
/** @returns a string representation of the url */
|
|
1667
1397
|
toString() {
|
|
1668
|
-
return
|
|
1398
|
+
return Wt(
|
|
1669
1399
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
1670
1400
|
);
|
|
1671
1401
|
}
|
|
1672
1402
|
};
|
|
1673
|
-
|
|
1674
|
-
let
|
|
1675
|
-
var
|
|
1676
|
-
const
|
|
1403
|
+
F(ue, "UNKNOWN", new ue({ host: "unknown", port: 0 }));
|
|
1404
|
+
let Gt = ue;
|
|
1405
|
+
var qt = Object.defineProperty, Zt = (r, e, t) => e in r ? qt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, K = (r, e, t) => Zt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
1406
|
+
const Y = class extends Number {
|
|
1677
1407
|
};
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1408
|
+
K(Y, "Absolute", 255), K(Y, "Default", 1), K(Y, "z", s.union([
|
|
1409
|
+
s.instanceof(Y),
|
|
1410
|
+
s.number().int().min(0).max(255).transform((r) => new Y(r)),
|
|
1411
|
+
s.instanceof(Number).transform((r) => new Y(r))
|
|
1682
1412
|
]));
|
|
1683
|
-
|
|
1684
|
-
name:
|
|
1685
|
-
key:
|
|
1686
|
-
});
|
|
1687
|
-
const Wr = i.string().regex(/^\d+\.\d+\.\d+$/);
|
|
1688
|
-
i.object({
|
|
1689
|
-
version: Wr
|
|
1413
|
+
s.object({
|
|
1414
|
+
name: s.string(),
|
|
1415
|
+
key: s.string()
|
|
1690
1416
|
});
|
|
1691
|
-
class
|
|
1692
|
-
constructor(
|
|
1693
|
-
super(
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1417
|
+
const ke = class G extends Error {
|
|
1418
|
+
constructor() {
|
|
1419
|
+
super(G.MESSAGE);
|
|
1420
|
+
}
|
|
1421
|
+
/** Returns true if the error or message is a cancellation error" */
|
|
1422
|
+
matches(e) {
|
|
1423
|
+
return typeof e == "string" ? e.includes(G.MESSAGE) : e instanceof G || e.message.includes(G.MESSAGE);
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
K(ke, "MESSAGE", "canceled");
|
|
1427
|
+
let zt = ke;
|
|
1428
|
+
new zt();
|
|
1429
|
+
s.string().regex(/^\d+\.\d+\.\d+$/);
|
|
1430
|
+
const he = (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);
|
|
1431
|
+
class _ extends Error {
|
|
1432
|
+
constructor(t) {
|
|
1433
|
+
super(t);
|
|
1434
|
+
f(this, "discriminator", "FreighterError");
|
|
1435
|
+
f(this, "type", "");
|
|
1697
1436
|
}
|
|
1698
1437
|
}
|
|
1699
|
-
const
|
|
1700
|
-
if (
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
if (e.discriminator !== "FreighterError")
|
|
1704
|
-
return !1;
|
|
1438
|
+
const Vt = (r) => {
|
|
1439
|
+
if (r == null || typeof r != "object") return !1;
|
|
1440
|
+
const e = r;
|
|
1441
|
+
if (e.discriminator !== "FreighterError") return !1;
|
|
1705
1442
|
if (!("type" in e))
|
|
1706
1443
|
throw new Error(
|
|
1707
1444
|
`Freighter error is missing its type property: ${JSON.stringify(e)}`
|
|
1708
1445
|
);
|
|
1709
1446
|
return !0;
|
|
1710
|
-
},
|
|
1711
|
-
class
|
|
1447
|
+
}, be = "unknown", Te = "nil", Ht = "freighter", We = s.object({ type: s.string(), data: s.string() });
|
|
1448
|
+
class Kt {
|
|
1712
1449
|
constructor() {
|
|
1713
|
-
|
|
1450
|
+
f(this, "providers", []);
|
|
1714
1451
|
}
|
|
1715
1452
|
register(e) {
|
|
1716
1453
|
this.providers.push(e);
|
|
1717
1454
|
}
|
|
1718
1455
|
encode(e) {
|
|
1719
|
-
if (e == null)
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
if (n != null)
|
|
1725
|
-
return n;
|
|
1456
|
+
if (e == null) return { type: Te, data: "" };
|
|
1457
|
+
if (Vt(e))
|
|
1458
|
+
for (const t of this.providers) {
|
|
1459
|
+
const n = t.encode(e);
|
|
1460
|
+
if (n != null) return n;
|
|
1726
1461
|
}
|
|
1727
|
-
return { type:
|
|
1462
|
+
return { type: be, data: JSON.stringify(e) };
|
|
1728
1463
|
}
|
|
1729
1464
|
decode(e) {
|
|
1730
|
-
if (e == null || e.type ===
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
const n = r.decode(e);
|
|
1736
|
-
if (n != null)
|
|
1737
|
-
return n;
|
|
1465
|
+
if (e == null || e.type === Te) return null;
|
|
1466
|
+
if (e.type === be) return new Ie(e.data);
|
|
1467
|
+
for (const t of this.providers) {
|
|
1468
|
+
const n = t.decode(e);
|
|
1469
|
+
if (n != null) return n;
|
|
1738
1470
|
}
|
|
1739
|
-
return new
|
|
1471
|
+
return new Ie(e.data);
|
|
1740
1472
|
}
|
|
1741
1473
|
}
|
|
1742
|
-
const
|
|
1743
|
-
encode:
|
|
1474
|
+
const de = new Kt(), Xt = ({
|
|
1475
|
+
encode: r,
|
|
1744
1476
|
decode: e
|
|
1745
|
-
}) =>
|
|
1746
|
-
class
|
|
1747
|
-
constructor(
|
|
1748
|
-
super(
|
|
1477
|
+
}) => de.register({ encode: r, decode: e }), pr = (r) => de.encode(r), Fe = (r) => de.decode(r);
|
|
1478
|
+
class Ie extends _ {
|
|
1479
|
+
constructor(t) {
|
|
1480
|
+
super(t);
|
|
1481
|
+
f(this, "type", "unknown");
|
|
1749
1482
|
}
|
|
1750
1483
|
}
|
|
1751
|
-
const
|
|
1752
|
-
class z extends de {
|
|
1484
|
+
const ee = "freighter.", L = class L extends _ {
|
|
1753
1485
|
constructor() {
|
|
1754
|
-
super("EOF"
|
|
1486
|
+
super("EOF");
|
|
1487
|
+
f(this, "type", L.TYPE);
|
|
1755
1488
|
}
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1489
|
+
};
|
|
1490
|
+
f(L, "TYPE", ee + "eof"), f(L, "matches", he(L.TYPE));
|
|
1491
|
+
let B = L;
|
|
1492
|
+
const P = class P extends _ {
|
|
1759
1493
|
constructor() {
|
|
1760
|
-
super("StreamClosed"
|
|
1494
|
+
super("StreamClosed");
|
|
1495
|
+
f(this, "type", P.TYPE);
|
|
1761
1496
|
}
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
this
|
|
1497
|
+
};
|
|
1498
|
+
f(P, "TYPE", ee + "stream_closed"), f(P, "matches", he(P.TYPE));
|
|
1499
|
+
let R = P;
|
|
1500
|
+
const j = class j extends _ {
|
|
1501
|
+
constructor(t = {}) {
|
|
1502
|
+
const { message: n = "Unreachable", url: i = Gt.UNKNOWN } = t;
|
|
1503
|
+
super(n);
|
|
1504
|
+
f(this, "type", j.TYPE);
|
|
1505
|
+
f(this, "url");
|
|
1506
|
+
this.url = i;
|
|
1770
1507
|
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
case
|
|
1788
|
-
return new
|
|
1789
|
-
case
|
|
1790
|
-
return new
|
|
1791
|
-
case F.TYPE:
|
|
1792
|
-
return new F();
|
|
1508
|
+
};
|
|
1509
|
+
f(j, "TYPE", ee + "unreachable"), f(j, "matches", he(j.TYPE));
|
|
1510
|
+
let D = j;
|
|
1511
|
+
const Jt = (r) => {
|
|
1512
|
+
if (!r.type.startsWith(Ht)) return null;
|
|
1513
|
+
if (B.matches(r)) return { type: B.TYPE, data: "EOF" };
|
|
1514
|
+
if (R.matches(r))
|
|
1515
|
+
return { type: R.TYPE, data: "StreamClosed" };
|
|
1516
|
+
if (D.matches(r))
|
|
1517
|
+
return { type: D.TYPE, data: "Unreachable" };
|
|
1518
|
+
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
1519
|
+
}, Qt = (r) => {
|
|
1520
|
+
if (!r.type.startsWith(ee)) return null;
|
|
1521
|
+
switch (r.type) {
|
|
1522
|
+
case B.TYPE:
|
|
1523
|
+
return new B();
|
|
1524
|
+
case R.TYPE:
|
|
1525
|
+
return new R();
|
|
1526
|
+
case D.TYPE:
|
|
1527
|
+
return new D();
|
|
1793
1528
|
default:
|
|
1794
|
-
throw new Error(`Unknown error type: ${
|
|
1529
|
+
throw new Error(`Unknown error type: ${r.data}`);
|
|
1795
1530
|
}
|
|
1796
1531
|
};
|
|
1797
|
-
|
|
1798
|
-
encode:
|
|
1799
|
-
decode:
|
|
1532
|
+
Xt({
|
|
1533
|
+
encode: Jt,
|
|
1534
|
+
decode: Qt
|
|
1800
1535
|
});
|
|
1801
|
-
class
|
|
1536
|
+
class Ge {
|
|
1802
1537
|
constructor() {
|
|
1803
|
-
|
|
1538
|
+
f(this, "middleware", []);
|
|
1804
1539
|
}
|
|
1805
1540
|
/** Implements the Transport interface */
|
|
1806
1541
|
use(...e) {
|
|
@@ -1815,126 +1550,117 @@ class Et {
|
|
|
1815
1550
|
* @param finalizer - The finalizer to call with the metadata.
|
|
1816
1551
|
* @returns An error if one was encountered, otherwise undefined.
|
|
1817
1552
|
*/
|
|
1818
|
-
async executeMiddleware(e,
|
|
1553
|
+
async executeMiddleware(e, t) {
|
|
1819
1554
|
let n = 0;
|
|
1820
|
-
const
|
|
1821
|
-
if (n === this.middleware.length)
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
return n++, await u(a, s);
|
|
1555
|
+
const i = async (a) => {
|
|
1556
|
+
if (n === this.middleware.length) return await t(a);
|
|
1557
|
+
const c = this.middleware[n];
|
|
1558
|
+
return n++, await c(a, i);
|
|
1825
1559
|
};
|
|
1826
|
-
return await
|
|
1560
|
+
return await i(e);
|
|
1827
1561
|
}
|
|
1828
1562
|
}
|
|
1829
|
-
const
|
|
1830
|
-
if (
|
|
1831
|
-
return fetch;
|
|
1563
|
+
const qe = "Content-Type", Se = (r) => {
|
|
1564
|
+
if (Pe.RUNTIME !== "node") return fetch;
|
|
1832
1565
|
const e = require("node-fetch");
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
return async (s, a) => await e(s, { ...a, agent: n });
|
|
1566
|
+
if (r === "http") return e;
|
|
1567
|
+
const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
|
|
1568
|
+
return async (i, a) => await e(i, { ...a, agent: n });
|
|
1837
1569
|
};
|
|
1838
|
-
class
|
|
1839
|
-
constructor(
|
|
1570
|
+
class yr extends Ge {
|
|
1571
|
+
constructor(t, n, i = !1) {
|
|
1840
1572
|
super();
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
return this.endpoint =
|
|
1845
|
-
get: (a,
|
|
1573
|
+
f(this, "endpoint");
|
|
1574
|
+
f(this, "encoder");
|
|
1575
|
+
f(this, "fetch");
|
|
1576
|
+
return this.endpoint = t.replace({ protocol: i ? "https" : "http" }), this.encoder = n, this.fetch = Se(this.endpoint.protocol), new Proxy(this, {
|
|
1577
|
+
get: (a, c, h) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, h)
|
|
1846
1578
|
});
|
|
1847
1579
|
}
|
|
1848
1580
|
get headers() {
|
|
1849
1581
|
return {
|
|
1850
|
-
[
|
|
1582
|
+
[qe]: this.encoder.contentType
|
|
1851
1583
|
};
|
|
1852
1584
|
}
|
|
1853
|
-
async send(
|
|
1854
|
-
n =
|
|
1855
|
-
let
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
const [,
|
|
1585
|
+
async send(t, n, i, a) {
|
|
1586
|
+
n = i == null ? void 0 : i.parse(n);
|
|
1587
|
+
let c = null;
|
|
1588
|
+
const h = this.endpoint.child(t), p = {};
|
|
1589
|
+
p.method = "POST", p.body = this.encoder.encode(n ?? {});
|
|
1590
|
+
const [, m] = await this.executeMiddleware(
|
|
1859
1591
|
{
|
|
1860
|
-
target:
|
|
1592
|
+
target: h.toString(),
|
|
1861
1593
|
protocol: this.endpoint.protocol,
|
|
1862
1594
|
params: {},
|
|
1863
1595
|
role: "client"
|
|
1864
1596
|
},
|
|
1865
|
-
async (
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1597
|
+
async (v) => {
|
|
1598
|
+
const w = { ...v, params: {} };
|
|
1599
|
+
p.headers = {
|
|
1868
1600
|
...this.headers,
|
|
1869
|
-
...
|
|
1601
|
+
...v.params
|
|
1870
1602
|
};
|
|
1871
|
-
let
|
|
1603
|
+
let A;
|
|
1872
1604
|
try {
|
|
1873
|
-
|
|
1874
|
-
} catch (
|
|
1875
|
-
let
|
|
1876
|
-
return
|
|
1605
|
+
A = await Se(v.protocol)(v.target, p);
|
|
1606
|
+
} catch (U) {
|
|
1607
|
+
let E = U;
|
|
1608
|
+
return E.message === "Load failed" && (E = new D({ url: h })), [w, E];
|
|
1877
1609
|
}
|
|
1878
|
-
const
|
|
1879
|
-
if (
|
|
1880
|
-
return a != null && (
|
|
1610
|
+
const k = await A.arrayBuffer();
|
|
1611
|
+
if (A != null && A.ok)
|
|
1612
|
+
return a != null && (c = this.encoder.decode(k, a)), [w, null];
|
|
1881
1613
|
try {
|
|
1882
|
-
if (
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
} catch (M) {
|
|
1614
|
+
if (A.status !== 400) return [w, new Error(A.statusText)];
|
|
1615
|
+
const U = this.encoder.decode(k, We), E = Fe(U);
|
|
1616
|
+
return [w, E];
|
|
1617
|
+
} catch (U) {
|
|
1887
1618
|
return [
|
|
1888
|
-
|
|
1619
|
+
w,
|
|
1889
1620
|
new Error(
|
|
1890
|
-
`[freighter] - failed to decode error: ${
|
|
1621
|
+
`[freighter] - failed to decode error: ${A.statusText}: ${U.message}`
|
|
1891
1622
|
)
|
|
1892
1623
|
];
|
|
1893
1624
|
}
|
|
1894
1625
|
}
|
|
1895
1626
|
);
|
|
1896
|
-
return [
|
|
1627
|
+
return [c, m];
|
|
1897
1628
|
}
|
|
1898
1629
|
}
|
|
1899
|
-
const
|
|
1900
|
-
const [a,
|
|
1901
|
-
if (
|
|
1902
|
-
throw u;
|
|
1630
|
+
const gr = async (r, e, t, n, i) => {
|
|
1631
|
+
const [a, c] = await r.send(e, t, n, i);
|
|
1632
|
+
if (c != null) throw c;
|
|
1903
1633
|
return a;
|
|
1904
|
-
},
|
|
1905
|
-
type:
|
|
1906
|
-
payload:
|
|
1907
|
-
error:
|
|
1634
|
+
}, _t = () => Pe.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), er = s.object({
|
|
1635
|
+
type: s.union([s.literal("data"), s.literal("close")]),
|
|
1636
|
+
payload: s.unknown().optional(),
|
|
1637
|
+
error: s.optional(We)
|
|
1908
1638
|
});
|
|
1909
|
-
class
|
|
1910
|
-
constructor(e,
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
this.encoder =
|
|
1639
|
+
class tr {
|
|
1640
|
+
constructor(e, t, n, i) {
|
|
1641
|
+
f(this, "encoder");
|
|
1642
|
+
f(this, "reqSchema");
|
|
1643
|
+
f(this, "resSchema");
|
|
1644
|
+
f(this, "ws");
|
|
1645
|
+
f(this, "serverClosed");
|
|
1646
|
+
f(this, "sendClosed");
|
|
1647
|
+
f(this, "receiveDataQueue", []);
|
|
1648
|
+
f(this, "receiveCallbacksQueue", []);
|
|
1649
|
+
this.encoder = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
|
|
1920
1650
|
}
|
|
1921
1651
|
/** Implements the Stream protocol */
|
|
1922
1652
|
send(e) {
|
|
1923
|
-
if (this.serverClosed != null)
|
|
1924
|
-
|
|
1925
|
-
if (this.sendClosed)
|
|
1926
|
-
throw new Y();
|
|
1653
|
+
if (this.serverClosed != null) return new B();
|
|
1654
|
+
if (this.sendClosed) throw new R();
|
|
1927
1655
|
return this.ws.send(this.encoder.encode({ type: "data", payload: e })), null;
|
|
1928
1656
|
}
|
|
1929
1657
|
/** Implements the Stream protocol */
|
|
1930
1658
|
async receive() {
|
|
1931
|
-
if (this.serverClosed != null)
|
|
1932
|
-
return [null, this.serverClosed];
|
|
1659
|
+
if (this.serverClosed != null) return [null, this.serverClosed];
|
|
1933
1660
|
const e = await this.receiveMsg();
|
|
1934
1661
|
if (e.type === "close") {
|
|
1935
|
-
if (e.error == null)
|
|
1936
|
-
|
|
1937
|
-
return this.serverClosed = Nt(e.error), [null, this.serverClosed];
|
|
1662
|
+
if (e.error == null) throw new Error("Message error must be defined");
|
|
1663
|
+
return this.serverClosed = Fe(e.error), [null, this.serverClosed];
|
|
1938
1664
|
}
|
|
1939
1665
|
return [this.resSchema.parse(e.payload), null];
|
|
1940
1666
|
}
|
|
@@ -1944,8 +1670,7 @@ class en {
|
|
|
1944
1670
|
}
|
|
1945
1671
|
/** Implements the Stream protocol */
|
|
1946
1672
|
closeSend() {
|
|
1947
|
-
if (this.sendClosed || this.serverClosed != null)
|
|
1948
|
-
return;
|
|
1673
|
+
if (this.sendClosed || this.serverClosed != null) return;
|
|
1949
1674
|
const e = { type: "close" };
|
|
1950
1675
|
try {
|
|
1951
1676
|
this.ws.send(this.encoder.encode(e));
|
|
@@ -1956,82 +1681,82 @@ class en {
|
|
|
1956
1681
|
async receiveMsg() {
|
|
1957
1682
|
const e = this.receiveDataQueue.shift();
|
|
1958
1683
|
return e ?? await new Promise(
|
|
1959
|
-
(
|
|
1684
|
+
(t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
|
|
1960
1685
|
);
|
|
1961
1686
|
}
|
|
1962
1687
|
addMessage(e) {
|
|
1963
|
-
const
|
|
1964
|
-
|
|
1688
|
+
const t = this.receiveCallbacksQueue.shift();
|
|
1689
|
+
t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
|
|
1965
1690
|
}
|
|
1966
1691
|
listenForMessages() {
|
|
1967
|
-
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data,
|
|
1692
|
+
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, er)), this.ws.onclose = (e) => this.addMessage({
|
|
1968
1693
|
type: "close",
|
|
1969
|
-
error: { type:
|
|
1694
|
+
error: { type: or(e) ? B.TYPE : R.TYPE, data: "" }
|
|
1970
1695
|
});
|
|
1971
1696
|
}
|
|
1972
1697
|
}
|
|
1973
|
-
const
|
|
1698
|
+
const rr = "freighterctx", nr = 1e3, sr = 1001, ir = [nr, sr], or = (r) => ir.includes(r.code), J = class J extends Ge {
|
|
1974
1699
|
/**
|
|
1975
1700
|
* @param encoder - The encoder to use for encoding messages and decoding
|
|
1976
1701
|
* responses.
|
|
1977
1702
|
* @param baseEndpoint - A base url to use as a prefix for all requests.
|
|
1978
1703
|
*/
|
|
1979
|
-
constructor(
|
|
1704
|
+
constructor(t, n, i = !1) {
|
|
1980
1705
|
super();
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
this.baseUrl =
|
|
1706
|
+
f(this, "baseUrl");
|
|
1707
|
+
f(this, "encoder");
|
|
1708
|
+
this.baseUrl = t.replace({ protocol: i ? "wss" : "ws" }), this.encoder = n;
|
|
1984
1709
|
}
|
|
1985
1710
|
/** Implements the StreamClient interface. */
|
|
1986
|
-
async stream(
|
|
1987
|
-
const a =
|
|
1988
|
-
let
|
|
1989
|
-
const [,
|
|
1990
|
-
{ target:
|
|
1991
|
-
async (
|
|
1992
|
-
const
|
|
1993
|
-
|
|
1994
|
-
const
|
|
1995
|
-
return
|
|
1711
|
+
async stream(t, n, i) {
|
|
1712
|
+
const a = _t();
|
|
1713
|
+
let c;
|
|
1714
|
+
const [, h] = await this.executeMiddleware(
|
|
1715
|
+
{ target: t, protocol: "websocket", params: {}, role: "client" },
|
|
1716
|
+
async (p) => {
|
|
1717
|
+
const m = a(this.buildURL(t, p)), v = { ...p, params: {} };
|
|
1718
|
+
m.binaryType = J.MESSAGE_TYPE;
|
|
1719
|
+
const w = await this.wrapSocket(m, n, i);
|
|
1720
|
+
return w instanceof Error ? [v, w] : (c = w, [v, null]);
|
|
1996
1721
|
}
|
|
1997
1722
|
);
|
|
1998
|
-
if (
|
|
1999
|
-
|
|
2000
|
-
return u;
|
|
1723
|
+
if (h != null) throw h;
|
|
1724
|
+
return c;
|
|
2001
1725
|
}
|
|
2002
|
-
buildURL(
|
|
2003
|
-
const
|
|
1726
|
+
buildURL(t, n) {
|
|
1727
|
+
const i = Ft(
|
|
2004
1728
|
{
|
|
2005
|
-
[
|
|
1729
|
+
[qe]: this.encoder.contentType,
|
|
2006
1730
|
...n.params
|
|
2007
1731
|
},
|
|
2008
|
-
|
|
1732
|
+
rr
|
|
2009
1733
|
);
|
|
2010
|
-
return this.baseUrl.child(
|
|
1734
|
+
return this.baseUrl.child(t).toString() + i;
|
|
2011
1735
|
}
|
|
2012
|
-
async wrapSocket(
|
|
1736
|
+
async wrapSocket(t, n, i) {
|
|
2013
1737
|
return await new Promise((a) => {
|
|
2014
|
-
|
|
2015
|
-
a(new
|
|
2016
|
-
},
|
|
2017
|
-
const
|
|
2018
|
-
a(new Error(
|
|
1738
|
+
t.onopen = () => {
|
|
1739
|
+
a(new tr(t, this.encoder, n, i));
|
|
1740
|
+
}, t.onerror = (c) => {
|
|
1741
|
+
const h = c;
|
|
1742
|
+
a(new Error(h.message));
|
|
2019
1743
|
};
|
|
2020
1744
|
});
|
|
2021
1745
|
}
|
|
2022
1746
|
};
|
|
2023
|
-
|
|
2024
|
-
let
|
|
1747
|
+
f(J, "MESSAGE_TYPE", "arraybuffer");
|
|
1748
|
+
let Ne = J;
|
|
2025
1749
|
export {
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
1750
|
+
_ as BaseTypedError,
|
|
1751
|
+
B as EOF,
|
|
1752
|
+
yr as HTTPClient,
|
|
1753
|
+
R as StreamClosed,
|
|
1754
|
+
D as Unreachable,
|
|
1755
|
+
Ne as WebSocketClient,
|
|
1756
|
+
Fe as decodeError,
|
|
1757
|
+
pr as encodeError,
|
|
1758
|
+
he as errorMatcher,
|
|
1759
|
+
We as errorZ,
|
|
1760
|
+
Xt as registerError,
|
|
1761
|
+
gr as sendRequired
|
|
2037
1762
|
};
|