@openc3/js-common 6.2.0 → 6.3.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/services.cjs +16 -0
- package/dist/services.cjs.map +1 -0
- package/dist/services.js +4213 -0
- package/dist/services.js.map +1 -0
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -0
- package/package.json +12 -12
package/dist/services.js
ADDED
|
@@ -0,0 +1,4213 @@
|
|
|
1
|
+
var Kt = Object.defineProperty;
|
|
2
|
+
var Xt = (s, e, t) => e in s ? Kt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var v = (s, e, t) => Xt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
function pt(s, e) {
|
|
5
|
+
return function() {
|
|
6
|
+
return s.apply(e, arguments);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const { toString: Gt } = Object.prototype, { getPrototypeOf: $e } = Object, de = /* @__PURE__ */ ((s) => (e) => {
|
|
10
|
+
const t = Gt.call(e);
|
|
11
|
+
return s[t] || (s[t] = t.slice(8, -1).toLowerCase());
|
|
12
|
+
})(/* @__PURE__ */ Object.create(null)), j = (s) => (s = s.toLowerCase(), (e) => de(e) === s), fe = (s) => (e) => typeof e === s, { isArray: K } = Array, Y = fe("undefined");
|
|
13
|
+
function Zt(s) {
|
|
14
|
+
return s !== null && !Y(s) && s.constructor !== null && !Y(s.constructor) && N(s.constructor.isBuffer) && s.constructor.isBuffer(s);
|
|
15
|
+
}
|
|
16
|
+
const mt = j("ArrayBuffer");
|
|
17
|
+
function Qt(s) {
|
|
18
|
+
let e;
|
|
19
|
+
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(s) : e = s && s.buffer && mt(s.buffer), e;
|
|
20
|
+
}
|
|
21
|
+
const Yt = fe("string"), N = fe("function"), gt = fe("number"), pe = (s) => s !== null && typeof s == "object", en = (s) => s === !0 || s === !1, ce = (s) => {
|
|
22
|
+
if (de(s) !== "object")
|
|
23
|
+
return !1;
|
|
24
|
+
const e = $e(s);
|
|
25
|
+
return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in s) && !(Symbol.iterator in s);
|
|
26
|
+
}, tn = j("Date"), nn = j("File"), sn = j("Blob"), rn = j("FileList"), on = (s) => pe(s) && N(s.pipe), cn = (s) => {
|
|
27
|
+
let e;
|
|
28
|
+
return s && (typeof FormData == "function" && s instanceof FormData || N(s.append) && ((e = de(s)) === "formdata" || // detect form-data instance
|
|
29
|
+
e === "object" && N(s.toString) && s.toString() === "[object FormData]"));
|
|
30
|
+
}, an = j("URLSearchParams"), [ln, un, hn, dn] = ["ReadableStream", "Request", "Response", "Headers"].map(j), fn = (s) => s.trim ? s.trim() : s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
31
|
+
function ee(s, e, { allOwnKeys: t = !1 } = {}) {
|
|
32
|
+
if (s === null || typeof s > "u")
|
|
33
|
+
return;
|
|
34
|
+
let n, r;
|
|
35
|
+
if (typeof s != "object" && (s = [s]), K(s))
|
|
36
|
+
for (n = 0, r = s.length; n < r; n++)
|
|
37
|
+
e.call(null, s[n], n, s);
|
|
38
|
+
else {
|
|
39
|
+
const i = t ? Object.getOwnPropertyNames(s) : Object.keys(s), o = i.length;
|
|
40
|
+
let c;
|
|
41
|
+
for (n = 0; n < o; n++)
|
|
42
|
+
c = i[n], e.call(null, s[c], c, s);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function bt(s, e) {
|
|
46
|
+
e = e.toLowerCase();
|
|
47
|
+
const t = Object.keys(s);
|
|
48
|
+
let n = t.length, r;
|
|
49
|
+
for (; n-- > 0; )
|
|
50
|
+
if (r = t[n], e === r.toLowerCase())
|
|
51
|
+
return r;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const H = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, wt = (s) => !Y(s) && s !== H;
|
|
55
|
+
function Oe() {
|
|
56
|
+
const { caseless: s } = wt(this) && this || {}, e = {}, t = (n, r) => {
|
|
57
|
+
const i = s && bt(e, r) || r;
|
|
58
|
+
ce(e[i]) && ce(n) ? e[i] = Oe(e[i], n) : ce(n) ? e[i] = Oe({}, n) : K(n) ? e[i] = n.slice() : e[i] = n;
|
|
59
|
+
};
|
|
60
|
+
for (let n = 0, r = arguments.length; n < r; n++)
|
|
61
|
+
arguments[n] && ee(arguments[n], t);
|
|
62
|
+
return e;
|
|
63
|
+
}
|
|
64
|
+
const pn = (s, e, t, { allOwnKeys: n } = {}) => (ee(e, (r, i) => {
|
|
65
|
+
t && N(r) ? s[i] = pt(r, t) : s[i] = r;
|
|
66
|
+
}, { allOwnKeys: n }), s), mn = (s) => (s.charCodeAt(0) === 65279 && (s = s.slice(1)), s), gn = (s, e, t, n) => {
|
|
67
|
+
s.prototype = Object.create(e.prototype, n), s.prototype.constructor = s, Object.defineProperty(s, "super", {
|
|
68
|
+
value: e.prototype
|
|
69
|
+
}), t && Object.assign(s.prototype, t);
|
|
70
|
+
}, bn = (s, e, t, n) => {
|
|
71
|
+
let r, i, o;
|
|
72
|
+
const c = {};
|
|
73
|
+
if (e = e || {}, s == null) return e;
|
|
74
|
+
do {
|
|
75
|
+
for (r = Object.getOwnPropertyNames(s), i = r.length; i-- > 0; )
|
|
76
|
+
o = r[i], (!n || n(o, s, e)) && !c[o] && (e[o] = s[o], c[o] = !0);
|
|
77
|
+
s = t !== !1 && $e(s);
|
|
78
|
+
} while (s && (!t || t(s, e)) && s !== Object.prototype);
|
|
79
|
+
return e;
|
|
80
|
+
}, wn = (s, e, t) => {
|
|
81
|
+
s = String(s), (t === void 0 || t > s.length) && (t = s.length), t -= e.length;
|
|
82
|
+
const n = s.indexOf(e, t);
|
|
83
|
+
return n !== -1 && n === t;
|
|
84
|
+
}, yn = (s) => {
|
|
85
|
+
if (!s) return null;
|
|
86
|
+
if (K(s)) return s;
|
|
87
|
+
let e = s.length;
|
|
88
|
+
if (!gt(e)) return null;
|
|
89
|
+
const t = new Array(e);
|
|
90
|
+
for (; e-- > 0; )
|
|
91
|
+
t[e] = s[e];
|
|
92
|
+
return t;
|
|
93
|
+
}, _n = /* @__PURE__ */ ((s) => (e) => s && e instanceof s)(typeof Uint8Array < "u" && $e(Uint8Array)), En = (s, e) => {
|
|
94
|
+
const n = (s && s[Symbol.iterator]).call(s);
|
|
95
|
+
let r;
|
|
96
|
+
for (; (r = n.next()) && !r.done; ) {
|
|
97
|
+
const i = r.value;
|
|
98
|
+
e.call(s, i[0], i[1]);
|
|
99
|
+
}
|
|
100
|
+
}, Sn = (s, e) => {
|
|
101
|
+
let t;
|
|
102
|
+
const n = [];
|
|
103
|
+
for (; (t = s.exec(e)) !== null; )
|
|
104
|
+
n.push(t);
|
|
105
|
+
return n;
|
|
106
|
+
}, xn = j("HTMLFormElement"), Rn = (s) => s.toLowerCase().replace(
|
|
107
|
+
/[-_\s]([a-z\d])(\w*)/g,
|
|
108
|
+
function(t, n, r) {
|
|
109
|
+
return n.toUpperCase() + r;
|
|
110
|
+
}
|
|
111
|
+
), Ve = (({ hasOwnProperty: s }) => (e, t) => s.call(e, t))(Object.prototype), An = j("RegExp"), yt = (s, e) => {
|
|
112
|
+
const t = Object.getOwnPropertyDescriptors(s), n = {};
|
|
113
|
+
ee(t, (r, i) => {
|
|
114
|
+
let o;
|
|
115
|
+
(o = e(r, i, s)) !== !1 && (n[i] = o || r);
|
|
116
|
+
}), Object.defineProperties(s, n);
|
|
117
|
+
}, On = (s) => {
|
|
118
|
+
yt(s, (e, t) => {
|
|
119
|
+
if (N(s) && ["arguments", "caller", "callee"].indexOf(t) !== -1)
|
|
120
|
+
return !1;
|
|
121
|
+
const n = s[t];
|
|
122
|
+
if (N(n)) {
|
|
123
|
+
if (e.enumerable = !1, "writable" in e) {
|
|
124
|
+
e.writable = !1;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
e.set || (e.set = () => {
|
|
128
|
+
throw Error("Can not rewrite read-only method '" + t + "'");
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}, Cn = (s, e) => {
|
|
133
|
+
const t = {}, n = (r) => {
|
|
134
|
+
r.forEach((i) => {
|
|
135
|
+
t[i] = !0;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
return K(s) ? n(s) : n(String(s).split(e)), t;
|
|
139
|
+
}, Tn = () => {
|
|
140
|
+
}, kn = (s, e) => s != null && Number.isFinite(s = +s) ? s : e;
|
|
141
|
+
function Nn(s) {
|
|
142
|
+
return !!(s && N(s.append) && s[Symbol.toStringTag] === "FormData" && s[Symbol.iterator]);
|
|
143
|
+
}
|
|
144
|
+
const Pn = (s) => {
|
|
145
|
+
const e = new Array(10), t = (n, r) => {
|
|
146
|
+
if (pe(n)) {
|
|
147
|
+
if (e.indexOf(n) >= 0)
|
|
148
|
+
return;
|
|
149
|
+
if (!("toJSON" in n)) {
|
|
150
|
+
e[r] = n;
|
|
151
|
+
const i = K(n) ? [] : {};
|
|
152
|
+
return ee(n, (o, c) => {
|
|
153
|
+
const h = t(o, r + 1);
|
|
154
|
+
!Y(h) && (i[c] = h);
|
|
155
|
+
}), e[r] = void 0, i;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return n;
|
|
159
|
+
};
|
|
160
|
+
return t(s, 0);
|
|
161
|
+
}, In = j("AsyncFunction"), Ln = (s) => s && (pe(s) || N(s)) && N(s.then) && N(s.catch), _t = ((s, e) => s ? setImmediate : e ? ((t, n) => (H.addEventListener("message", ({ source: r, data: i }) => {
|
|
162
|
+
r === H && i === t && n.length && n.shift()();
|
|
163
|
+
}, !1), (r) => {
|
|
164
|
+
n.push(r), H.postMessage(t, "*");
|
|
165
|
+
}))(`axios@${Math.random()}`, []) : (t) => setTimeout(t))(
|
|
166
|
+
typeof setImmediate == "function",
|
|
167
|
+
N(H.postMessage)
|
|
168
|
+
), vn = typeof queueMicrotask < "u" ? queueMicrotask.bind(H) : typeof process < "u" && process.nextTick || _t, l = {
|
|
169
|
+
isArray: K,
|
|
170
|
+
isArrayBuffer: mt,
|
|
171
|
+
isBuffer: Zt,
|
|
172
|
+
isFormData: cn,
|
|
173
|
+
isArrayBufferView: Qt,
|
|
174
|
+
isString: Yt,
|
|
175
|
+
isNumber: gt,
|
|
176
|
+
isBoolean: en,
|
|
177
|
+
isObject: pe,
|
|
178
|
+
isPlainObject: ce,
|
|
179
|
+
isReadableStream: ln,
|
|
180
|
+
isRequest: un,
|
|
181
|
+
isResponse: hn,
|
|
182
|
+
isHeaders: dn,
|
|
183
|
+
isUndefined: Y,
|
|
184
|
+
isDate: tn,
|
|
185
|
+
isFile: nn,
|
|
186
|
+
isBlob: sn,
|
|
187
|
+
isRegExp: An,
|
|
188
|
+
isFunction: N,
|
|
189
|
+
isStream: on,
|
|
190
|
+
isURLSearchParams: an,
|
|
191
|
+
isTypedArray: _n,
|
|
192
|
+
isFileList: rn,
|
|
193
|
+
forEach: ee,
|
|
194
|
+
merge: Oe,
|
|
195
|
+
extend: pn,
|
|
196
|
+
trim: fn,
|
|
197
|
+
stripBOM: mn,
|
|
198
|
+
inherits: gn,
|
|
199
|
+
toFlatObject: bn,
|
|
200
|
+
kindOf: de,
|
|
201
|
+
kindOfTest: j,
|
|
202
|
+
endsWith: wn,
|
|
203
|
+
toArray: yn,
|
|
204
|
+
forEachEntry: En,
|
|
205
|
+
matchAll: Sn,
|
|
206
|
+
isHTMLForm: xn,
|
|
207
|
+
hasOwnProperty: Ve,
|
|
208
|
+
hasOwnProp: Ve,
|
|
209
|
+
// an alias to avoid ESLint no-prototype-builtins detection
|
|
210
|
+
reduceDescriptors: yt,
|
|
211
|
+
freezeMethods: On,
|
|
212
|
+
toObjectSet: Cn,
|
|
213
|
+
toCamelCase: Rn,
|
|
214
|
+
noop: Tn,
|
|
215
|
+
toFiniteNumber: kn,
|
|
216
|
+
findKey: bt,
|
|
217
|
+
global: H,
|
|
218
|
+
isContextDefined: wt,
|
|
219
|
+
isSpecCompliantForm: Nn,
|
|
220
|
+
toJSONObject: Pn,
|
|
221
|
+
isAsyncFn: In,
|
|
222
|
+
isThenable: Ln,
|
|
223
|
+
setImmediate: _t,
|
|
224
|
+
asap: vn
|
|
225
|
+
};
|
|
226
|
+
function w(s, e, t, n, r) {
|
|
227
|
+
Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = s, this.name = "AxiosError", e && (this.code = e), t && (this.config = t), n && (this.request = n), r && (this.response = r, this.status = r.status ? r.status : null);
|
|
228
|
+
}
|
|
229
|
+
l.inherits(w, Error, {
|
|
230
|
+
toJSON: function() {
|
|
231
|
+
return {
|
|
232
|
+
// Standard
|
|
233
|
+
message: this.message,
|
|
234
|
+
name: this.name,
|
|
235
|
+
// Microsoft
|
|
236
|
+
description: this.description,
|
|
237
|
+
number: this.number,
|
|
238
|
+
// Mozilla
|
|
239
|
+
fileName: this.fileName,
|
|
240
|
+
lineNumber: this.lineNumber,
|
|
241
|
+
columnNumber: this.columnNumber,
|
|
242
|
+
stack: this.stack,
|
|
243
|
+
// Axios
|
|
244
|
+
config: l.toJSONObject(this.config),
|
|
245
|
+
code: this.code,
|
|
246
|
+
status: this.status
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
const Et = w.prototype, St = {};
|
|
251
|
+
[
|
|
252
|
+
"ERR_BAD_OPTION_VALUE",
|
|
253
|
+
"ERR_BAD_OPTION",
|
|
254
|
+
"ECONNABORTED",
|
|
255
|
+
"ETIMEDOUT",
|
|
256
|
+
"ERR_NETWORK",
|
|
257
|
+
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
258
|
+
"ERR_DEPRECATED",
|
|
259
|
+
"ERR_BAD_RESPONSE",
|
|
260
|
+
"ERR_BAD_REQUEST",
|
|
261
|
+
"ERR_CANCELED",
|
|
262
|
+
"ERR_NOT_SUPPORT",
|
|
263
|
+
"ERR_INVALID_URL"
|
|
264
|
+
// eslint-disable-next-line func-names
|
|
265
|
+
].forEach((s) => {
|
|
266
|
+
St[s] = { value: s };
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperties(w, St);
|
|
269
|
+
Object.defineProperty(Et, "isAxiosError", { value: !0 });
|
|
270
|
+
w.from = (s, e, t, n, r, i) => {
|
|
271
|
+
const o = Object.create(Et);
|
|
272
|
+
return l.toFlatObject(s, o, function(h) {
|
|
273
|
+
return h !== Error.prototype;
|
|
274
|
+
}, (c) => c !== "isAxiosError"), w.call(o, s.message, e, t, n, r), o.cause = s, o.name = s.name, i && Object.assign(o, i), o;
|
|
275
|
+
};
|
|
276
|
+
const $n = null;
|
|
277
|
+
function Ce(s) {
|
|
278
|
+
return l.isPlainObject(s) || l.isArray(s);
|
|
279
|
+
}
|
|
280
|
+
function xt(s) {
|
|
281
|
+
return l.endsWith(s, "[]") ? s.slice(0, -2) : s;
|
|
282
|
+
}
|
|
283
|
+
function Je(s, e, t) {
|
|
284
|
+
return s ? s.concat(e).map(function(r, i) {
|
|
285
|
+
return r = xt(r), !t && i ? "[" + r + "]" : r;
|
|
286
|
+
}).join(t ? "." : "") : e;
|
|
287
|
+
}
|
|
288
|
+
function jn(s) {
|
|
289
|
+
return l.isArray(s) && !s.some(Ce);
|
|
290
|
+
}
|
|
291
|
+
const Fn = l.toFlatObject(l, {}, null, function(e) {
|
|
292
|
+
return /^is[A-Z]/.test(e);
|
|
293
|
+
});
|
|
294
|
+
function me(s, e, t) {
|
|
295
|
+
if (!l.isObject(s))
|
|
296
|
+
throw new TypeError("target must be an object");
|
|
297
|
+
e = e || new FormData(), t = l.toFlatObject(t, {
|
|
298
|
+
metaTokens: !0,
|
|
299
|
+
dots: !1,
|
|
300
|
+
indexes: !1
|
|
301
|
+
}, !1, function(m, p) {
|
|
302
|
+
return !l.isUndefined(p[m]);
|
|
303
|
+
});
|
|
304
|
+
const n = t.metaTokens, r = t.visitor || a, i = t.dots, o = t.indexes, h = (t.Blob || typeof Blob < "u" && Blob) && l.isSpecCompliantForm(e);
|
|
305
|
+
if (!l.isFunction(r))
|
|
306
|
+
throw new TypeError("visitor must be a function");
|
|
307
|
+
function u(f) {
|
|
308
|
+
if (f === null) return "";
|
|
309
|
+
if (l.isDate(f))
|
|
310
|
+
return f.toISOString();
|
|
311
|
+
if (!h && l.isBlob(f))
|
|
312
|
+
throw new w("Blob is not supported. Use a Buffer instead.");
|
|
313
|
+
return l.isArrayBuffer(f) || l.isTypedArray(f) ? h && typeof Blob == "function" ? new Blob([f]) : Buffer.from(f) : f;
|
|
314
|
+
}
|
|
315
|
+
function a(f, m, p) {
|
|
316
|
+
let _ = f;
|
|
317
|
+
if (f && !p && typeof f == "object") {
|
|
318
|
+
if (l.endsWith(m, "{}"))
|
|
319
|
+
m = n ? m : m.slice(0, -2), f = JSON.stringify(f);
|
|
320
|
+
else if (l.isArray(f) && jn(f) || (l.isFileList(f) || l.endsWith(m, "[]")) && (_ = l.toArray(f)))
|
|
321
|
+
return m = xt(m), _.forEach(function(S, k) {
|
|
322
|
+
!(l.isUndefined(S) || S === null) && e.append(
|
|
323
|
+
// eslint-disable-next-line no-nested-ternary
|
|
324
|
+
o === !0 ? Je([m], k, i) : o === null ? m : m + "[]",
|
|
325
|
+
u(S)
|
|
326
|
+
);
|
|
327
|
+
}), !1;
|
|
328
|
+
}
|
|
329
|
+
return Ce(f) ? !0 : (e.append(Je(p, m, i), u(f)), !1);
|
|
330
|
+
}
|
|
331
|
+
const d = [], g = Object.assign(Fn, {
|
|
332
|
+
defaultVisitor: a,
|
|
333
|
+
convertValue: u,
|
|
334
|
+
isVisitable: Ce
|
|
335
|
+
});
|
|
336
|
+
function b(f, m) {
|
|
337
|
+
if (!l.isUndefined(f)) {
|
|
338
|
+
if (d.indexOf(f) !== -1)
|
|
339
|
+
throw Error("Circular reference detected in " + m.join("."));
|
|
340
|
+
d.push(f), l.forEach(f, function(_, E) {
|
|
341
|
+
(!(l.isUndefined(_) || _ === null) && r.call(
|
|
342
|
+
e,
|
|
343
|
+
_,
|
|
344
|
+
l.isString(E) ? E.trim() : E,
|
|
345
|
+
m,
|
|
346
|
+
g
|
|
347
|
+
)) === !0 && b(_, m ? m.concat(E) : [E]);
|
|
348
|
+
}), d.pop();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!l.isObject(s))
|
|
352
|
+
throw new TypeError("data must be an object");
|
|
353
|
+
return b(s), e;
|
|
354
|
+
}
|
|
355
|
+
function We(s) {
|
|
356
|
+
const e = {
|
|
357
|
+
"!": "%21",
|
|
358
|
+
"'": "%27",
|
|
359
|
+
"(": "%28",
|
|
360
|
+
")": "%29",
|
|
361
|
+
"~": "%7E",
|
|
362
|
+
"%20": "+",
|
|
363
|
+
"%00": "\0"
|
|
364
|
+
};
|
|
365
|
+
return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g, function(n) {
|
|
366
|
+
return e[n];
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function je(s, e) {
|
|
370
|
+
this._pairs = [], s && me(s, this, e);
|
|
371
|
+
}
|
|
372
|
+
const Rt = je.prototype;
|
|
373
|
+
Rt.append = function(e, t) {
|
|
374
|
+
this._pairs.push([e, t]);
|
|
375
|
+
};
|
|
376
|
+
Rt.toString = function(e) {
|
|
377
|
+
const t = e ? function(n) {
|
|
378
|
+
return e.call(this, n, We);
|
|
379
|
+
} : We;
|
|
380
|
+
return this._pairs.map(function(r) {
|
|
381
|
+
return t(r[0]) + "=" + t(r[1]);
|
|
382
|
+
}, "").join("&");
|
|
383
|
+
};
|
|
384
|
+
function Un(s) {
|
|
385
|
+
return encodeURIComponent(s).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
386
|
+
}
|
|
387
|
+
function At(s, e, t) {
|
|
388
|
+
if (!e)
|
|
389
|
+
return s;
|
|
390
|
+
const n = t && t.encode || Un;
|
|
391
|
+
l.isFunction(t) && (t = {
|
|
392
|
+
serialize: t
|
|
393
|
+
});
|
|
394
|
+
const r = t && t.serialize;
|
|
395
|
+
let i;
|
|
396
|
+
if (r ? i = r(e, t) : i = l.isURLSearchParams(e) ? e.toString() : new je(e, t).toString(n), i) {
|
|
397
|
+
const o = s.indexOf("#");
|
|
398
|
+
o !== -1 && (s = s.slice(0, o)), s += (s.indexOf("?") === -1 ? "?" : "&") + i;
|
|
399
|
+
}
|
|
400
|
+
return s;
|
|
401
|
+
}
|
|
402
|
+
class Ke {
|
|
403
|
+
constructor() {
|
|
404
|
+
this.handlers = [];
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Add a new interceptor to the stack
|
|
408
|
+
*
|
|
409
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
410
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
411
|
+
*
|
|
412
|
+
* @return {Number} An ID used to remove interceptor later
|
|
413
|
+
*/
|
|
414
|
+
use(e, t, n) {
|
|
415
|
+
return this.handlers.push({
|
|
416
|
+
fulfilled: e,
|
|
417
|
+
rejected: t,
|
|
418
|
+
synchronous: n ? n.synchronous : !1,
|
|
419
|
+
runWhen: n ? n.runWhen : null
|
|
420
|
+
}), this.handlers.length - 1;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Remove an interceptor from the stack
|
|
424
|
+
*
|
|
425
|
+
* @param {Number} id The ID that was returned by `use`
|
|
426
|
+
*
|
|
427
|
+
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
428
|
+
*/
|
|
429
|
+
eject(e) {
|
|
430
|
+
this.handlers[e] && (this.handlers[e] = null);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Clear all interceptors from the stack
|
|
434
|
+
*
|
|
435
|
+
* @returns {void}
|
|
436
|
+
*/
|
|
437
|
+
clear() {
|
|
438
|
+
this.handlers && (this.handlers = []);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Iterate over all the registered interceptors
|
|
442
|
+
*
|
|
443
|
+
* This method is particularly useful for skipping over any
|
|
444
|
+
* interceptors that may have become `null` calling `eject`.
|
|
445
|
+
*
|
|
446
|
+
* @param {Function} fn The function to call for each interceptor
|
|
447
|
+
*
|
|
448
|
+
* @returns {void}
|
|
449
|
+
*/
|
|
450
|
+
forEach(e) {
|
|
451
|
+
l.forEach(this.handlers, function(n) {
|
|
452
|
+
n !== null && e(n);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const Ot = {
|
|
457
|
+
silentJSONParsing: !0,
|
|
458
|
+
forcedJSONParsing: !0,
|
|
459
|
+
clarifyTimeoutError: !1
|
|
460
|
+
}, Dn = typeof URLSearchParams < "u" ? URLSearchParams : je, qn = typeof FormData < "u" ? FormData : null, Bn = typeof Blob < "u" ? Blob : null, Mn = {
|
|
461
|
+
isBrowser: !0,
|
|
462
|
+
classes: {
|
|
463
|
+
URLSearchParams: Dn,
|
|
464
|
+
FormData: qn,
|
|
465
|
+
Blob: Bn
|
|
466
|
+
},
|
|
467
|
+
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
468
|
+
}, Fe = typeof window < "u" && typeof document < "u", Te = typeof navigator == "object" && navigator || void 0, Hn = Fe && (!Te || ["ReactNative", "NativeScript", "NS"].indexOf(Te.product) < 0), zn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
469
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Vn = Fe && window.location.href || "http://localhost", Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
470
|
+
__proto__: null,
|
|
471
|
+
hasBrowserEnv: Fe,
|
|
472
|
+
hasStandardBrowserEnv: Hn,
|
|
473
|
+
hasStandardBrowserWebWorkerEnv: zn,
|
|
474
|
+
navigator: Te,
|
|
475
|
+
origin: Vn
|
|
476
|
+
}, Symbol.toStringTag, { value: "Module" })), O = {
|
|
477
|
+
...Jn,
|
|
478
|
+
...Mn
|
|
479
|
+
};
|
|
480
|
+
function Wn(s, e) {
|
|
481
|
+
return me(s, new O.classes.URLSearchParams(), Object.assign({
|
|
482
|
+
visitor: function(t, n, r, i) {
|
|
483
|
+
return O.isNode && l.isBuffer(t) ? (this.append(n, t.toString("base64")), !1) : i.defaultVisitor.apply(this, arguments);
|
|
484
|
+
}
|
|
485
|
+
}, e));
|
|
486
|
+
}
|
|
487
|
+
function Kn(s) {
|
|
488
|
+
return l.matchAll(/\w+|\[(\w*)]/g, s).map((e) => e[0] === "[]" ? "" : e[1] || e[0]);
|
|
489
|
+
}
|
|
490
|
+
function Xn(s) {
|
|
491
|
+
const e = {}, t = Object.keys(s);
|
|
492
|
+
let n;
|
|
493
|
+
const r = t.length;
|
|
494
|
+
let i;
|
|
495
|
+
for (n = 0; n < r; n++)
|
|
496
|
+
i = t[n], e[i] = s[i];
|
|
497
|
+
return e;
|
|
498
|
+
}
|
|
499
|
+
function Ct(s) {
|
|
500
|
+
function e(t, n, r, i) {
|
|
501
|
+
let o = t[i++];
|
|
502
|
+
if (o === "__proto__") return !0;
|
|
503
|
+
const c = Number.isFinite(+o), h = i >= t.length;
|
|
504
|
+
return o = !o && l.isArray(r) ? r.length : o, h ? (l.hasOwnProp(r, o) ? r[o] = [r[o], n] : r[o] = n, !c) : ((!r[o] || !l.isObject(r[o])) && (r[o] = []), e(t, n, r[o], i) && l.isArray(r[o]) && (r[o] = Xn(r[o])), !c);
|
|
505
|
+
}
|
|
506
|
+
if (l.isFormData(s) && l.isFunction(s.entries)) {
|
|
507
|
+
const t = {};
|
|
508
|
+
return l.forEachEntry(s, (n, r) => {
|
|
509
|
+
e(Kn(n), r, t, 0);
|
|
510
|
+
}), t;
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
function Gn(s, e, t) {
|
|
515
|
+
if (l.isString(s))
|
|
516
|
+
try {
|
|
517
|
+
return (e || JSON.parse)(s), l.trim(s);
|
|
518
|
+
} catch (n) {
|
|
519
|
+
if (n.name !== "SyntaxError")
|
|
520
|
+
throw n;
|
|
521
|
+
}
|
|
522
|
+
return (t || JSON.stringify)(s);
|
|
523
|
+
}
|
|
524
|
+
const te = {
|
|
525
|
+
transitional: Ot,
|
|
526
|
+
adapter: ["xhr", "http", "fetch"],
|
|
527
|
+
transformRequest: [function(e, t) {
|
|
528
|
+
const n = t.getContentType() || "", r = n.indexOf("application/json") > -1, i = l.isObject(e);
|
|
529
|
+
if (i && l.isHTMLForm(e) && (e = new FormData(e)), l.isFormData(e))
|
|
530
|
+
return r ? JSON.stringify(Ct(e)) : e;
|
|
531
|
+
if (l.isArrayBuffer(e) || l.isBuffer(e) || l.isStream(e) || l.isFile(e) || l.isBlob(e) || l.isReadableStream(e))
|
|
532
|
+
return e;
|
|
533
|
+
if (l.isArrayBufferView(e))
|
|
534
|
+
return e.buffer;
|
|
535
|
+
if (l.isURLSearchParams(e))
|
|
536
|
+
return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString();
|
|
537
|
+
let c;
|
|
538
|
+
if (i) {
|
|
539
|
+
if (n.indexOf("application/x-www-form-urlencoded") > -1)
|
|
540
|
+
return Wn(e, this.formSerializer).toString();
|
|
541
|
+
if ((c = l.isFileList(e)) || n.indexOf("multipart/form-data") > -1) {
|
|
542
|
+
const h = this.env && this.env.FormData;
|
|
543
|
+
return me(
|
|
544
|
+
c ? { "files[]": e } : e,
|
|
545
|
+
h && new h(),
|
|
546
|
+
this.formSerializer
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return i || r ? (t.setContentType("application/json", !1), Gn(e)) : e;
|
|
551
|
+
}],
|
|
552
|
+
transformResponse: [function(e) {
|
|
553
|
+
const t = this.transitional || te.transitional, n = t && t.forcedJSONParsing, r = this.responseType === "json";
|
|
554
|
+
if (l.isResponse(e) || l.isReadableStream(e))
|
|
555
|
+
return e;
|
|
556
|
+
if (e && l.isString(e) && (n && !this.responseType || r)) {
|
|
557
|
+
const o = !(t && t.silentJSONParsing) && r;
|
|
558
|
+
try {
|
|
559
|
+
return JSON.parse(e);
|
|
560
|
+
} catch (c) {
|
|
561
|
+
if (o)
|
|
562
|
+
throw c.name === "SyntaxError" ? w.from(c, w.ERR_BAD_RESPONSE, this, null, this.response) : c;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return e;
|
|
566
|
+
}],
|
|
567
|
+
/**
|
|
568
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
569
|
+
* timeout is not created.
|
|
570
|
+
*/
|
|
571
|
+
timeout: 0,
|
|
572
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
573
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
574
|
+
maxContentLength: -1,
|
|
575
|
+
maxBodyLength: -1,
|
|
576
|
+
env: {
|
|
577
|
+
FormData: O.classes.FormData,
|
|
578
|
+
Blob: O.classes.Blob
|
|
579
|
+
},
|
|
580
|
+
validateStatus: function(e) {
|
|
581
|
+
return e >= 200 && e < 300;
|
|
582
|
+
},
|
|
583
|
+
headers: {
|
|
584
|
+
common: {
|
|
585
|
+
Accept: "application/json, text/plain, */*",
|
|
586
|
+
"Content-Type": void 0
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
l.forEach(["delete", "get", "head", "post", "put", "patch"], (s) => {
|
|
591
|
+
te.headers[s] = {};
|
|
592
|
+
});
|
|
593
|
+
const Zn = l.toObjectSet([
|
|
594
|
+
"age",
|
|
595
|
+
"authorization",
|
|
596
|
+
"content-length",
|
|
597
|
+
"content-type",
|
|
598
|
+
"etag",
|
|
599
|
+
"expires",
|
|
600
|
+
"from",
|
|
601
|
+
"host",
|
|
602
|
+
"if-modified-since",
|
|
603
|
+
"if-unmodified-since",
|
|
604
|
+
"last-modified",
|
|
605
|
+
"location",
|
|
606
|
+
"max-forwards",
|
|
607
|
+
"proxy-authorization",
|
|
608
|
+
"referer",
|
|
609
|
+
"retry-after",
|
|
610
|
+
"user-agent"
|
|
611
|
+
]), Qn = (s) => {
|
|
612
|
+
const e = {};
|
|
613
|
+
let t, n, r;
|
|
614
|
+
return s && s.split(`
|
|
615
|
+
`).forEach(function(o) {
|
|
616
|
+
r = o.indexOf(":"), t = o.substring(0, r).trim().toLowerCase(), n = o.substring(r + 1).trim(), !(!t || e[t] && Zn[t]) && (t === "set-cookie" ? e[t] ? e[t].push(n) : e[t] = [n] : e[t] = e[t] ? e[t] + ", " + n : n);
|
|
617
|
+
}), e;
|
|
618
|
+
}, Xe = Symbol("internals");
|
|
619
|
+
function Z(s) {
|
|
620
|
+
return s && String(s).trim().toLowerCase();
|
|
621
|
+
}
|
|
622
|
+
function ae(s) {
|
|
623
|
+
return s === !1 || s == null ? s : l.isArray(s) ? s.map(ae) : String(s);
|
|
624
|
+
}
|
|
625
|
+
function Yn(s) {
|
|
626
|
+
const e = /* @__PURE__ */ Object.create(null), t = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
627
|
+
let n;
|
|
628
|
+
for (; n = t.exec(s); )
|
|
629
|
+
e[n[1]] = n[2];
|
|
630
|
+
return e;
|
|
631
|
+
}
|
|
632
|
+
const es = (s) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());
|
|
633
|
+
function Se(s, e, t, n, r) {
|
|
634
|
+
if (l.isFunction(n))
|
|
635
|
+
return n.call(this, e, t);
|
|
636
|
+
if (r && (e = t), !!l.isString(e)) {
|
|
637
|
+
if (l.isString(n))
|
|
638
|
+
return e.indexOf(n) !== -1;
|
|
639
|
+
if (l.isRegExp(n))
|
|
640
|
+
return n.test(e);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function ts(s) {
|
|
644
|
+
return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, t, n) => t.toUpperCase() + n);
|
|
645
|
+
}
|
|
646
|
+
function ns(s, e) {
|
|
647
|
+
const t = l.toCamelCase(" " + e);
|
|
648
|
+
["get", "set", "has"].forEach((n) => {
|
|
649
|
+
Object.defineProperty(s, n + t, {
|
|
650
|
+
value: function(r, i, o) {
|
|
651
|
+
return this[n].call(this, e, r, i, o);
|
|
652
|
+
},
|
|
653
|
+
configurable: !0
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
let T = class {
|
|
658
|
+
constructor(e) {
|
|
659
|
+
e && this.set(e);
|
|
660
|
+
}
|
|
661
|
+
set(e, t, n) {
|
|
662
|
+
const r = this;
|
|
663
|
+
function i(c, h, u) {
|
|
664
|
+
const a = Z(h);
|
|
665
|
+
if (!a)
|
|
666
|
+
throw new Error("header name must be a non-empty string");
|
|
667
|
+
const d = l.findKey(r, a);
|
|
668
|
+
(!d || r[d] === void 0 || u === !0 || u === void 0 && r[d] !== !1) && (r[d || h] = ae(c));
|
|
669
|
+
}
|
|
670
|
+
const o = (c, h) => l.forEach(c, (u, a) => i(u, a, h));
|
|
671
|
+
if (l.isPlainObject(e) || e instanceof this.constructor)
|
|
672
|
+
o(e, t);
|
|
673
|
+
else if (l.isString(e) && (e = e.trim()) && !es(e))
|
|
674
|
+
o(Qn(e), t);
|
|
675
|
+
else if (l.isHeaders(e))
|
|
676
|
+
for (const [c, h] of e.entries())
|
|
677
|
+
i(h, c, n);
|
|
678
|
+
else
|
|
679
|
+
e != null && i(t, e, n);
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
682
|
+
get(e, t) {
|
|
683
|
+
if (e = Z(e), e) {
|
|
684
|
+
const n = l.findKey(this, e);
|
|
685
|
+
if (n) {
|
|
686
|
+
const r = this[n];
|
|
687
|
+
if (!t)
|
|
688
|
+
return r;
|
|
689
|
+
if (t === !0)
|
|
690
|
+
return Yn(r);
|
|
691
|
+
if (l.isFunction(t))
|
|
692
|
+
return t.call(this, r, n);
|
|
693
|
+
if (l.isRegExp(t))
|
|
694
|
+
return t.exec(r);
|
|
695
|
+
throw new TypeError("parser must be boolean|regexp|function");
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
has(e, t) {
|
|
700
|
+
if (e = Z(e), e) {
|
|
701
|
+
const n = l.findKey(this, e);
|
|
702
|
+
return !!(n && this[n] !== void 0 && (!t || Se(this, this[n], n, t)));
|
|
703
|
+
}
|
|
704
|
+
return !1;
|
|
705
|
+
}
|
|
706
|
+
delete(e, t) {
|
|
707
|
+
const n = this;
|
|
708
|
+
let r = !1;
|
|
709
|
+
function i(o) {
|
|
710
|
+
if (o = Z(o), o) {
|
|
711
|
+
const c = l.findKey(n, o);
|
|
712
|
+
c && (!t || Se(n, n[c], c, t)) && (delete n[c], r = !0);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return l.isArray(e) ? e.forEach(i) : i(e), r;
|
|
716
|
+
}
|
|
717
|
+
clear(e) {
|
|
718
|
+
const t = Object.keys(this);
|
|
719
|
+
let n = t.length, r = !1;
|
|
720
|
+
for (; n--; ) {
|
|
721
|
+
const i = t[n];
|
|
722
|
+
(!e || Se(this, this[i], i, e, !0)) && (delete this[i], r = !0);
|
|
723
|
+
}
|
|
724
|
+
return r;
|
|
725
|
+
}
|
|
726
|
+
normalize(e) {
|
|
727
|
+
const t = this, n = {};
|
|
728
|
+
return l.forEach(this, (r, i) => {
|
|
729
|
+
const o = l.findKey(n, i);
|
|
730
|
+
if (o) {
|
|
731
|
+
t[o] = ae(r), delete t[i];
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const c = e ? ts(i) : String(i).trim();
|
|
735
|
+
c !== i && delete t[i], t[c] = ae(r), n[c] = !0;
|
|
736
|
+
}), this;
|
|
737
|
+
}
|
|
738
|
+
concat(...e) {
|
|
739
|
+
return this.constructor.concat(this, ...e);
|
|
740
|
+
}
|
|
741
|
+
toJSON(e) {
|
|
742
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
743
|
+
return l.forEach(this, (n, r) => {
|
|
744
|
+
n != null && n !== !1 && (t[r] = e && l.isArray(n) ? n.join(", ") : n);
|
|
745
|
+
}), t;
|
|
746
|
+
}
|
|
747
|
+
[Symbol.iterator]() {
|
|
748
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
749
|
+
}
|
|
750
|
+
toString() {
|
|
751
|
+
return Object.entries(this.toJSON()).map(([e, t]) => e + ": " + t).join(`
|
|
752
|
+
`);
|
|
753
|
+
}
|
|
754
|
+
get [Symbol.toStringTag]() {
|
|
755
|
+
return "AxiosHeaders";
|
|
756
|
+
}
|
|
757
|
+
static from(e) {
|
|
758
|
+
return e instanceof this ? e : new this(e);
|
|
759
|
+
}
|
|
760
|
+
static concat(e, ...t) {
|
|
761
|
+
const n = new this(e);
|
|
762
|
+
return t.forEach((r) => n.set(r)), n;
|
|
763
|
+
}
|
|
764
|
+
static accessor(e) {
|
|
765
|
+
const n = (this[Xe] = this[Xe] = {
|
|
766
|
+
accessors: {}
|
|
767
|
+
}).accessors, r = this.prototype;
|
|
768
|
+
function i(o) {
|
|
769
|
+
const c = Z(o);
|
|
770
|
+
n[c] || (ns(r, o), n[c] = !0);
|
|
771
|
+
}
|
|
772
|
+
return l.isArray(e) ? e.forEach(i) : i(e), this;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
T.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
776
|
+
l.reduceDescriptors(T.prototype, ({ value: s }, e) => {
|
|
777
|
+
let t = e[0].toUpperCase() + e.slice(1);
|
|
778
|
+
return {
|
|
779
|
+
get: () => s,
|
|
780
|
+
set(n) {
|
|
781
|
+
this[t] = n;
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
});
|
|
785
|
+
l.freezeMethods(T);
|
|
786
|
+
function xe(s, e) {
|
|
787
|
+
const t = this || te, n = e || t, r = T.from(n.headers);
|
|
788
|
+
let i = n.data;
|
|
789
|
+
return l.forEach(s, function(c) {
|
|
790
|
+
i = c.call(t, i, r.normalize(), e ? e.status : void 0);
|
|
791
|
+
}), r.normalize(), i;
|
|
792
|
+
}
|
|
793
|
+
function Tt(s) {
|
|
794
|
+
return !!(s && s.__CANCEL__);
|
|
795
|
+
}
|
|
796
|
+
function X(s, e, t) {
|
|
797
|
+
w.call(this, s ?? "canceled", w.ERR_CANCELED, e, t), this.name = "CanceledError";
|
|
798
|
+
}
|
|
799
|
+
l.inherits(X, w, {
|
|
800
|
+
__CANCEL__: !0
|
|
801
|
+
});
|
|
802
|
+
function kt(s, e, t) {
|
|
803
|
+
const n = t.config.validateStatus;
|
|
804
|
+
!t.status || !n || n(t.status) ? s(t) : e(new w(
|
|
805
|
+
"Request failed with status code " + t.status,
|
|
806
|
+
[w.ERR_BAD_REQUEST, w.ERR_BAD_RESPONSE][Math.floor(t.status / 100) - 4],
|
|
807
|
+
t.config,
|
|
808
|
+
t.request,
|
|
809
|
+
t
|
|
810
|
+
));
|
|
811
|
+
}
|
|
812
|
+
function ss(s) {
|
|
813
|
+
const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(s);
|
|
814
|
+
return e && e[1] || "";
|
|
815
|
+
}
|
|
816
|
+
function rs(s, e) {
|
|
817
|
+
s = s || 10;
|
|
818
|
+
const t = new Array(s), n = new Array(s);
|
|
819
|
+
let r = 0, i = 0, o;
|
|
820
|
+
return e = e !== void 0 ? e : 1e3, function(h) {
|
|
821
|
+
const u = Date.now(), a = n[i];
|
|
822
|
+
o || (o = u), t[r] = h, n[r] = u;
|
|
823
|
+
let d = i, g = 0;
|
|
824
|
+
for (; d !== r; )
|
|
825
|
+
g += t[d++], d = d % s;
|
|
826
|
+
if (r = (r + 1) % s, r === i && (i = (i + 1) % s), u - o < e)
|
|
827
|
+
return;
|
|
828
|
+
const b = a && u - a;
|
|
829
|
+
return b ? Math.round(g * 1e3 / b) : void 0;
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function is(s, e) {
|
|
833
|
+
let t = 0, n = 1e3 / e, r, i;
|
|
834
|
+
const o = (u, a = Date.now()) => {
|
|
835
|
+
t = a, r = null, i && (clearTimeout(i), i = null), s.apply(null, u);
|
|
836
|
+
};
|
|
837
|
+
return [(...u) => {
|
|
838
|
+
const a = Date.now(), d = a - t;
|
|
839
|
+
d >= n ? o(u, a) : (r = u, i || (i = setTimeout(() => {
|
|
840
|
+
i = null, o(r);
|
|
841
|
+
}, n - d)));
|
|
842
|
+
}, () => r && o(r)];
|
|
843
|
+
}
|
|
844
|
+
const ue = (s, e, t = 3) => {
|
|
845
|
+
let n = 0;
|
|
846
|
+
const r = rs(50, 250);
|
|
847
|
+
return is((i) => {
|
|
848
|
+
const o = i.loaded, c = i.lengthComputable ? i.total : void 0, h = o - n, u = r(h), a = o <= c;
|
|
849
|
+
n = o;
|
|
850
|
+
const d = {
|
|
851
|
+
loaded: o,
|
|
852
|
+
total: c,
|
|
853
|
+
progress: c ? o / c : void 0,
|
|
854
|
+
bytes: h,
|
|
855
|
+
rate: u || void 0,
|
|
856
|
+
estimated: u && c && a ? (c - o) / u : void 0,
|
|
857
|
+
event: i,
|
|
858
|
+
lengthComputable: c != null,
|
|
859
|
+
[e ? "download" : "upload"]: !0
|
|
860
|
+
};
|
|
861
|
+
s(d);
|
|
862
|
+
}, t);
|
|
863
|
+
}, Ge = (s, e) => {
|
|
864
|
+
const t = s != null;
|
|
865
|
+
return [(n) => e[0]({
|
|
866
|
+
lengthComputable: t,
|
|
867
|
+
total: s,
|
|
868
|
+
loaded: n
|
|
869
|
+
}), e[1]];
|
|
870
|
+
}, Ze = (s) => (...e) => l.asap(() => s(...e)), os = O.hasStandardBrowserEnv ? /* @__PURE__ */ ((s, e) => (t) => (t = new URL(t, O.origin), s.protocol === t.protocol && s.host === t.host && (e || s.port === t.port)))(
|
|
871
|
+
new URL(O.origin),
|
|
872
|
+
O.navigator && /(msie|trident)/i.test(O.navigator.userAgent)
|
|
873
|
+
) : () => !0, cs = O.hasStandardBrowserEnv ? (
|
|
874
|
+
// Standard browser envs support document.cookie
|
|
875
|
+
{
|
|
876
|
+
write(s, e, t, n, r, i) {
|
|
877
|
+
const o = [s + "=" + encodeURIComponent(e)];
|
|
878
|
+
l.isNumber(t) && o.push("expires=" + new Date(t).toGMTString()), l.isString(n) && o.push("path=" + n), l.isString(r) && o.push("domain=" + r), i === !0 && o.push("secure"), document.cookie = o.join("; ");
|
|
879
|
+
},
|
|
880
|
+
read(s) {
|
|
881
|
+
const e = document.cookie.match(new RegExp("(^|;\\s*)(" + s + ")=([^;]*)"));
|
|
882
|
+
return e ? decodeURIComponent(e[3]) : null;
|
|
883
|
+
},
|
|
884
|
+
remove(s) {
|
|
885
|
+
this.write(s, "", Date.now() - 864e5);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
) : (
|
|
889
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
890
|
+
{
|
|
891
|
+
write() {
|
|
892
|
+
},
|
|
893
|
+
read() {
|
|
894
|
+
return null;
|
|
895
|
+
},
|
|
896
|
+
remove() {
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
);
|
|
900
|
+
function as(s) {
|
|
901
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(s);
|
|
902
|
+
}
|
|
903
|
+
function ls(s, e) {
|
|
904
|
+
return e ? s.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : s;
|
|
905
|
+
}
|
|
906
|
+
function Nt(s, e, t) {
|
|
907
|
+
let n = !as(e);
|
|
908
|
+
return s && (n || t == !1) ? ls(s, e) : e;
|
|
909
|
+
}
|
|
910
|
+
const Qe = (s) => s instanceof T ? { ...s } : s;
|
|
911
|
+
function V(s, e) {
|
|
912
|
+
e = e || {};
|
|
913
|
+
const t = {};
|
|
914
|
+
function n(u, a, d, g) {
|
|
915
|
+
return l.isPlainObject(u) && l.isPlainObject(a) ? l.merge.call({ caseless: g }, u, a) : l.isPlainObject(a) ? l.merge({}, a) : l.isArray(a) ? a.slice() : a;
|
|
916
|
+
}
|
|
917
|
+
function r(u, a, d, g) {
|
|
918
|
+
if (l.isUndefined(a)) {
|
|
919
|
+
if (!l.isUndefined(u))
|
|
920
|
+
return n(void 0, u, d, g);
|
|
921
|
+
} else return n(u, a, d, g);
|
|
922
|
+
}
|
|
923
|
+
function i(u, a) {
|
|
924
|
+
if (!l.isUndefined(a))
|
|
925
|
+
return n(void 0, a);
|
|
926
|
+
}
|
|
927
|
+
function o(u, a) {
|
|
928
|
+
if (l.isUndefined(a)) {
|
|
929
|
+
if (!l.isUndefined(u))
|
|
930
|
+
return n(void 0, u);
|
|
931
|
+
} else return n(void 0, a);
|
|
932
|
+
}
|
|
933
|
+
function c(u, a, d) {
|
|
934
|
+
if (d in e)
|
|
935
|
+
return n(u, a);
|
|
936
|
+
if (d in s)
|
|
937
|
+
return n(void 0, u);
|
|
938
|
+
}
|
|
939
|
+
const h = {
|
|
940
|
+
url: i,
|
|
941
|
+
method: i,
|
|
942
|
+
data: i,
|
|
943
|
+
baseURL: o,
|
|
944
|
+
transformRequest: o,
|
|
945
|
+
transformResponse: o,
|
|
946
|
+
paramsSerializer: o,
|
|
947
|
+
timeout: o,
|
|
948
|
+
timeoutMessage: o,
|
|
949
|
+
withCredentials: o,
|
|
950
|
+
withXSRFToken: o,
|
|
951
|
+
adapter: o,
|
|
952
|
+
responseType: o,
|
|
953
|
+
xsrfCookieName: o,
|
|
954
|
+
xsrfHeaderName: o,
|
|
955
|
+
onUploadProgress: o,
|
|
956
|
+
onDownloadProgress: o,
|
|
957
|
+
decompress: o,
|
|
958
|
+
maxContentLength: o,
|
|
959
|
+
maxBodyLength: o,
|
|
960
|
+
beforeRedirect: o,
|
|
961
|
+
transport: o,
|
|
962
|
+
httpAgent: o,
|
|
963
|
+
httpsAgent: o,
|
|
964
|
+
cancelToken: o,
|
|
965
|
+
socketPath: o,
|
|
966
|
+
responseEncoding: o,
|
|
967
|
+
validateStatus: c,
|
|
968
|
+
headers: (u, a, d) => r(Qe(u), Qe(a), d, !0)
|
|
969
|
+
};
|
|
970
|
+
return l.forEach(Object.keys(Object.assign({}, s, e)), function(a) {
|
|
971
|
+
const d = h[a] || r, g = d(s[a], e[a], a);
|
|
972
|
+
l.isUndefined(g) && d !== c || (t[a] = g);
|
|
973
|
+
}), t;
|
|
974
|
+
}
|
|
975
|
+
const Pt = (s) => {
|
|
976
|
+
const e = V({}, s);
|
|
977
|
+
let { data: t, withXSRFToken: n, xsrfHeaderName: r, xsrfCookieName: i, headers: o, auth: c } = e;
|
|
978
|
+
e.headers = o = T.from(o), e.url = At(Nt(e.baseURL, e.url, e.allowAbsoluteUrls), s.params, s.paramsSerializer), c && o.set(
|
|
979
|
+
"Authorization",
|
|
980
|
+
"Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
|
|
981
|
+
);
|
|
982
|
+
let h;
|
|
983
|
+
if (l.isFormData(t)) {
|
|
984
|
+
if (O.hasStandardBrowserEnv || O.hasStandardBrowserWebWorkerEnv)
|
|
985
|
+
o.setContentType(void 0);
|
|
986
|
+
else if ((h = o.getContentType()) !== !1) {
|
|
987
|
+
const [u, ...a] = h ? h.split(";").map((d) => d.trim()).filter(Boolean) : [];
|
|
988
|
+
o.setContentType([u || "multipart/form-data", ...a].join("; "));
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (O.hasStandardBrowserEnv && (n && l.isFunction(n) && (n = n(e)), n || n !== !1 && os(e.url))) {
|
|
992
|
+
const u = r && i && cs.read(i);
|
|
993
|
+
u && o.set(r, u);
|
|
994
|
+
}
|
|
995
|
+
return e;
|
|
996
|
+
}, us = typeof XMLHttpRequest < "u", hs = us && function(s) {
|
|
997
|
+
return new Promise(function(t, n) {
|
|
998
|
+
const r = Pt(s);
|
|
999
|
+
let i = r.data;
|
|
1000
|
+
const o = T.from(r.headers).normalize();
|
|
1001
|
+
let { responseType: c, onUploadProgress: h, onDownloadProgress: u } = r, a, d, g, b, f;
|
|
1002
|
+
function m() {
|
|
1003
|
+
b && b(), f && f(), r.cancelToken && r.cancelToken.unsubscribe(a), r.signal && r.signal.removeEventListener("abort", a);
|
|
1004
|
+
}
|
|
1005
|
+
let p = new XMLHttpRequest();
|
|
1006
|
+
p.open(r.method.toUpperCase(), r.url, !0), p.timeout = r.timeout;
|
|
1007
|
+
function _() {
|
|
1008
|
+
if (!p)
|
|
1009
|
+
return;
|
|
1010
|
+
const S = T.from(
|
|
1011
|
+
"getAllResponseHeaders" in p && p.getAllResponseHeaders()
|
|
1012
|
+
), x = {
|
|
1013
|
+
data: !c || c === "text" || c === "json" ? p.responseText : p.response,
|
|
1014
|
+
status: p.status,
|
|
1015
|
+
statusText: p.statusText,
|
|
1016
|
+
headers: S,
|
|
1017
|
+
config: s,
|
|
1018
|
+
request: p
|
|
1019
|
+
};
|
|
1020
|
+
kt(function(I) {
|
|
1021
|
+
t(I), m();
|
|
1022
|
+
}, function(I) {
|
|
1023
|
+
n(I), m();
|
|
1024
|
+
}, x), p = null;
|
|
1025
|
+
}
|
|
1026
|
+
"onloadend" in p ? p.onloadend = _ : p.onreadystatechange = function() {
|
|
1027
|
+
!p || p.readyState !== 4 || p.status === 0 && !(p.responseURL && p.responseURL.indexOf("file:") === 0) || setTimeout(_);
|
|
1028
|
+
}, p.onabort = function() {
|
|
1029
|
+
p && (n(new w("Request aborted", w.ECONNABORTED, s, p)), p = null);
|
|
1030
|
+
}, p.onerror = function() {
|
|
1031
|
+
n(new w("Network Error", w.ERR_NETWORK, s, p)), p = null;
|
|
1032
|
+
}, p.ontimeout = function() {
|
|
1033
|
+
let k = r.timeout ? "timeout of " + r.timeout + "ms exceeded" : "timeout exceeded";
|
|
1034
|
+
const x = r.transitional || Ot;
|
|
1035
|
+
r.timeoutErrorMessage && (k = r.timeoutErrorMessage), n(new w(
|
|
1036
|
+
k,
|
|
1037
|
+
x.clarifyTimeoutError ? w.ETIMEDOUT : w.ECONNABORTED,
|
|
1038
|
+
s,
|
|
1039
|
+
p
|
|
1040
|
+
)), p = null;
|
|
1041
|
+
}, i === void 0 && o.setContentType(null), "setRequestHeader" in p && l.forEach(o.toJSON(), function(k, x) {
|
|
1042
|
+
p.setRequestHeader(x, k);
|
|
1043
|
+
}), l.isUndefined(r.withCredentials) || (p.withCredentials = !!r.withCredentials), c && c !== "json" && (p.responseType = r.responseType), u && ([g, f] = ue(u, !0), p.addEventListener("progress", g)), h && p.upload && ([d, b] = ue(h), p.upload.addEventListener("progress", d), p.upload.addEventListener("loadend", b)), (r.cancelToken || r.signal) && (a = (S) => {
|
|
1044
|
+
p && (n(!S || S.type ? new X(null, s, p) : S), p.abort(), p = null);
|
|
1045
|
+
}, r.cancelToken && r.cancelToken.subscribe(a), r.signal && (r.signal.aborted ? a() : r.signal.addEventListener("abort", a)));
|
|
1046
|
+
const E = ss(r.url);
|
|
1047
|
+
if (E && O.protocols.indexOf(E) === -1) {
|
|
1048
|
+
n(new w("Unsupported protocol " + E + ":", w.ERR_BAD_REQUEST, s));
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
p.send(i || null);
|
|
1052
|
+
});
|
|
1053
|
+
}, ds = (s, e) => {
|
|
1054
|
+
const { length: t } = s = s ? s.filter(Boolean) : [];
|
|
1055
|
+
if (e || t) {
|
|
1056
|
+
let n = new AbortController(), r;
|
|
1057
|
+
const i = function(u) {
|
|
1058
|
+
if (!r) {
|
|
1059
|
+
r = !0, c();
|
|
1060
|
+
const a = u instanceof Error ? u : this.reason;
|
|
1061
|
+
n.abort(a instanceof w ? a : new X(a instanceof Error ? a.message : a));
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
let o = e && setTimeout(() => {
|
|
1065
|
+
o = null, i(new w(`timeout ${e} of ms exceeded`, w.ETIMEDOUT));
|
|
1066
|
+
}, e);
|
|
1067
|
+
const c = () => {
|
|
1068
|
+
s && (o && clearTimeout(o), o = null, s.forEach((u) => {
|
|
1069
|
+
u.unsubscribe ? u.unsubscribe(i) : u.removeEventListener("abort", i);
|
|
1070
|
+
}), s = null);
|
|
1071
|
+
};
|
|
1072
|
+
s.forEach((u) => u.addEventListener("abort", i));
|
|
1073
|
+
const { signal: h } = n;
|
|
1074
|
+
return h.unsubscribe = () => l.asap(c), h;
|
|
1075
|
+
}
|
|
1076
|
+
}, fs = function* (s, e) {
|
|
1077
|
+
let t = s.byteLength;
|
|
1078
|
+
if (t < e) {
|
|
1079
|
+
yield s;
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
let n = 0, r;
|
|
1083
|
+
for (; n < t; )
|
|
1084
|
+
r = n + e, yield s.slice(n, r), n = r;
|
|
1085
|
+
}, ps = async function* (s, e) {
|
|
1086
|
+
for await (const t of ms(s))
|
|
1087
|
+
yield* fs(t, e);
|
|
1088
|
+
}, ms = async function* (s) {
|
|
1089
|
+
if (s[Symbol.asyncIterator]) {
|
|
1090
|
+
yield* s;
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const e = s.getReader();
|
|
1094
|
+
try {
|
|
1095
|
+
for (; ; ) {
|
|
1096
|
+
const { done: t, value: n } = await e.read();
|
|
1097
|
+
if (t)
|
|
1098
|
+
break;
|
|
1099
|
+
yield n;
|
|
1100
|
+
}
|
|
1101
|
+
} finally {
|
|
1102
|
+
await e.cancel();
|
|
1103
|
+
}
|
|
1104
|
+
}, Ye = (s, e, t, n) => {
|
|
1105
|
+
const r = ps(s, e);
|
|
1106
|
+
let i = 0, o, c = (h) => {
|
|
1107
|
+
o || (o = !0, n && n(h));
|
|
1108
|
+
};
|
|
1109
|
+
return new ReadableStream({
|
|
1110
|
+
async pull(h) {
|
|
1111
|
+
try {
|
|
1112
|
+
const { done: u, value: a } = await r.next();
|
|
1113
|
+
if (u) {
|
|
1114
|
+
c(), h.close();
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
let d = a.byteLength;
|
|
1118
|
+
if (t) {
|
|
1119
|
+
let g = i += d;
|
|
1120
|
+
t(g);
|
|
1121
|
+
}
|
|
1122
|
+
h.enqueue(new Uint8Array(a));
|
|
1123
|
+
} catch (u) {
|
|
1124
|
+
throw c(u), u;
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
cancel(h) {
|
|
1128
|
+
return c(h), r.return();
|
|
1129
|
+
}
|
|
1130
|
+
}, {
|
|
1131
|
+
highWaterMark: 2
|
|
1132
|
+
});
|
|
1133
|
+
}, ge = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", It = ge && typeof ReadableStream == "function", gs = ge && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((s) => (e) => s.encode(e))(new TextEncoder()) : async (s) => new Uint8Array(await new Response(s).arrayBuffer())), Lt = (s, ...e) => {
|
|
1134
|
+
try {
|
|
1135
|
+
return !!s(...e);
|
|
1136
|
+
} catch {
|
|
1137
|
+
return !1;
|
|
1138
|
+
}
|
|
1139
|
+
}, bs = It && Lt(() => {
|
|
1140
|
+
let s = !1;
|
|
1141
|
+
const e = new Request(O.origin, {
|
|
1142
|
+
body: new ReadableStream(),
|
|
1143
|
+
method: "POST",
|
|
1144
|
+
get duplex() {
|
|
1145
|
+
return s = !0, "half";
|
|
1146
|
+
}
|
|
1147
|
+
}).headers.has("Content-Type");
|
|
1148
|
+
return s && !e;
|
|
1149
|
+
}), et = 64 * 1024, ke = It && Lt(() => l.isReadableStream(new Response("").body)), he = {
|
|
1150
|
+
stream: ke && ((s) => s.body)
|
|
1151
|
+
};
|
|
1152
|
+
ge && ((s) => {
|
|
1153
|
+
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e) => {
|
|
1154
|
+
!he[e] && (he[e] = l.isFunction(s[e]) ? (t) => t[e]() : (t, n) => {
|
|
1155
|
+
throw new w(`Response type '${e}' is not supported`, w.ERR_NOT_SUPPORT, n);
|
|
1156
|
+
});
|
|
1157
|
+
});
|
|
1158
|
+
})(new Response());
|
|
1159
|
+
const ws = async (s) => {
|
|
1160
|
+
if (s == null)
|
|
1161
|
+
return 0;
|
|
1162
|
+
if (l.isBlob(s))
|
|
1163
|
+
return s.size;
|
|
1164
|
+
if (l.isSpecCompliantForm(s))
|
|
1165
|
+
return (await new Request(O.origin, {
|
|
1166
|
+
method: "POST",
|
|
1167
|
+
body: s
|
|
1168
|
+
}).arrayBuffer()).byteLength;
|
|
1169
|
+
if (l.isArrayBufferView(s) || l.isArrayBuffer(s))
|
|
1170
|
+
return s.byteLength;
|
|
1171
|
+
if (l.isURLSearchParams(s) && (s = s + ""), l.isString(s))
|
|
1172
|
+
return (await gs(s)).byteLength;
|
|
1173
|
+
}, ys = async (s, e) => {
|
|
1174
|
+
const t = l.toFiniteNumber(s.getContentLength());
|
|
1175
|
+
return t ?? ws(e);
|
|
1176
|
+
}, _s = ge && (async (s) => {
|
|
1177
|
+
let {
|
|
1178
|
+
url: e,
|
|
1179
|
+
method: t,
|
|
1180
|
+
data: n,
|
|
1181
|
+
signal: r,
|
|
1182
|
+
cancelToken: i,
|
|
1183
|
+
timeout: o,
|
|
1184
|
+
onDownloadProgress: c,
|
|
1185
|
+
onUploadProgress: h,
|
|
1186
|
+
responseType: u,
|
|
1187
|
+
headers: a,
|
|
1188
|
+
withCredentials: d = "same-origin",
|
|
1189
|
+
fetchOptions: g
|
|
1190
|
+
} = Pt(s);
|
|
1191
|
+
u = u ? (u + "").toLowerCase() : "text";
|
|
1192
|
+
let b = ds([r, i && i.toAbortSignal()], o), f;
|
|
1193
|
+
const m = b && b.unsubscribe && (() => {
|
|
1194
|
+
b.unsubscribe();
|
|
1195
|
+
});
|
|
1196
|
+
let p;
|
|
1197
|
+
try {
|
|
1198
|
+
if (h && bs && t !== "get" && t !== "head" && (p = await ys(a, n)) !== 0) {
|
|
1199
|
+
let x = new Request(e, {
|
|
1200
|
+
method: "POST",
|
|
1201
|
+
body: n,
|
|
1202
|
+
duplex: "half"
|
|
1203
|
+
}), P;
|
|
1204
|
+
if (l.isFormData(n) && (P = x.headers.get("content-type")) && a.setContentType(P), x.body) {
|
|
1205
|
+
const [I, D] = Ge(
|
|
1206
|
+
p,
|
|
1207
|
+
ue(Ze(h))
|
|
1208
|
+
);
|
|
1209
|
+
n = Ye(x.body, et, I, D);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
l.isString(d) || (d = d ? "include" : "omit");
|
|
1213
|
+
const _ = "credentials" in Request.prototype;
|
|
1214
|
+
f = new Request(e, {
|
|
1215
|
+
...g,
|
|
1216
|
+
signal: b,
|
|
1217
|
+
method: t.toUpperCase(),
|
|
1218
|
+
headers: a.normalize().toJSON(),
|
|
1219
|
+
body: n,
|
|
1220
|
+
duplex: "half",
|
|
1221
|
+
credentials: _ ? d : void 0
|
|
1222
|
+
});
|
|
1223
|
+
let E = await fetch(f);
|
|
1224
|
+
const S = ke && (u === "stream" || u === "response");
|
|
1225
|
+
if (ke && (c || S && m)) {
|
|
1226
|
+
const x = {};
|
|
1227
|
+
["status", "statusText", "headers"].forEach((U) => {
|
|
1228
|
+
x[U] = E[U];
|
|
1229
|
+
});
|
|
1230
|
+
const P = l.toFiniteNumber(E.headers.get("content-length")), [I, D] = c && Ge(
|
|
1231
|
+
P,
|
|
1232
|
+
ue(Ze(c), !0)
|
|
1233
|
+
) || [];
|
|
1234
|
+
E = new Response(
|
|
1235
|
+
Ye(E.body, et, I, () => {
|
|
1236
|
+
D && D(), m && m();
|
|
1237
|
+
}),
|
|
1238
|
+
x
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
u = u || "text";
|
|
1242
|
+
let k = await he[l.findKey(he, u) || "text"](E, s);
|
|
1243
|
+
return !S && m && m(), await new Promise((x, P) => {
|
|
1244
|
+
kt(x, P, {
|
|
1245
|
+
data: k,
|
|
1246
|
+
headers: T.from(E.headers),
|
|
1247
|
+
status: E.status,
|
|
1248
|
+
statusText: E.statusText,
|
|
1249
|
+
config: s,
|
|
1250
|
+
request: f
|
|
1251
|
+
});
|
|
1252
|
+
});
|
|
1253
|
+
} catch (_) {
|
|
1254
|
+
throw m && m(), _ && _.name === "TypeError" && /fetch/i.test(_.message) ? Object.assign(
|
|
1255
|
+
new w("Network Error", w.ERR_NETWORK, s, f),
|
|
1256
|
+
{
|
|
1257
|
+
cause: _.cause || _
|
|
1258
|
+
}
|
|
1259
|
+
) : w.from(_, _ && _.code, s, f);
|
|
1260
|
+
}
|
|
1261
|
+
}), Ne = {
|
|
1262
|
+
http: $n,
|
|
1263
|
+
xhr: hs,
|
|
1264
|
+
fetch: _s
|
|
1265
|
+
};
|
|
1266
|
+
l.forEach(Ne, (s, e) => {
|
|
1267
|
+
if (s) {
|
|
1268
|
+
try {
|
|
1269
|
+
Object.defineProperty(s, "name", { value: e });
|
|
1270
|
+
} catch {
|
|
1271
|
+
}
|
|
1272
|
+
Object.defineProperty(s, "adapterName", { value: e });
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
const tt = (s) => `- ${s}`, Es = (s) => l.isFunction(s) || s === null || s === !1, vt = {
|
|
1276
|
+
getAdapter: (s) => {
|
|
1277
|
+
s = l.isArray(s) ? s : [s];
|
|
1278
|
+
const { length: e } = s;
|
|
1279
|
+
let t, n;
|
|
1280
|
+
const r = {};
|
|
1281
|
+
for (let i = 0; i < e; i++) {
|
|
1282
|
+
t = s[i];
|
|
1283
|
+
let o;
|
|
1284
|
+
if (n = t, !Es(t) && (n = Ne[(o = String(t)).toLowerCase()], n === void 0))
|
|
1285
|
+
throw new w(`Unknown adapter '${o}'`);
|
|
1286
|
+
if (n)
|
|
1287
|
+
break;
|
|
1288
|
+
r[o || "#" + i] = n;
|
|
1289
|
+
}
|
|
1290
|
+
if (!n) {
|
|
1291
|
+
const i = Object.entries(r).map(
|
|
1292
|
+
([c, h]) => `adapter ${c} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
|
|
1293
|
+
);
|
|
1294
|
+
let o = e ? i.length > 1 ? `since :
|
|
1295
|
+
` + i.map(tt).join(`
|
|
1296
|
+
`) : " " + tt(i[0]) : "as no adapter specified";
|
|
1297
|
+
throw new w(
|
|
1298
|
+
"There is no suitable adapter to dispatch the request " + o,
|
|
1299
|
+
"ERR_NOT_SUPPORT"
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
return n;
|
|
1303
|
+
},
|
|
1304
|
+
adapters: Ne
|
|
1305
|
+
};
|
|
1306
|
+
function Re(s) {
|
|
1307
|
+
if (s.cancelToken && s.cancelToken.throwIfRequested(), s.signal && s.signal.aborted)
|
|
1308
|
+
throw new X(null, s);
|
|
1309
|
+
}
|
|
1310
|
+
function nt(s) {
|
|
1311
|
+
return Re(s), s.headers = T.from(s.headers), s.data = xe.call(
|
|
1312
|
+
s,
|
|
1313
|
+
s.transformRequest
|
|
1314
|
+
), ["post", "put", "patch"].indexOf(s.method) !== -1 && s.headers.setContentType("application/x-www-form-urlencoded", !1), vt.getAdapter(s.adapter || te.adapter)(s).then(function(n) {
|
|
1315
|
+
return Re(s), n.data = xe.call(
|
|
1316
|
+
s,
|
|
1317
|
+
s.transformResponse,
|
|
1318
|
+
n
|
|
1319
|
+
), n.headers = T.from(n.headers), n;
|
|
1320
|
+
}, function(n) {
|
|
1321
|
+
return Tt(n) || (Re(s), n && n.response && (n.response.data = xe.call(
|
|
1322
|
+
s,
|
|
1323
|
+
s.transformResponse,
|
|
1324
|
+
n.response
|
|
1325
|
+
), n.response.headers = T.from(n.response.headers))), Promise.reject(n);
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
const $t = "1.8.4", be = {};
|
|
1329
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach((s, e) => {
|
|
1330
|
+
be[s] = function(n) {
|
|
1331
|
+
return typeof n === s || "a" + (e < 1 ? "n " : " ") + s;
|
|
1332
|
+
};
|
|
1333
|
+
});
|
|
1334
|
+
const st = {};
|
|
1335
|
+
be.transitional = function(e, t, n) {
|
|
1336
|
+
function r(i, o) {
|
|
1337
|
+
return "[Axios v" + $t + "] Transitional option '" + i + "'" + o + (n ? ". " + n : "");
|
|
1338
|
+
}
|
|
1339
|
+
return (i, o, c) => {
|
|
1340
|
+
if (e === !1)
|
|
1341
|
+
throw new w(
|
|
1342
|
+
r(o, " has been removed" + (t ? " in " + t : "")),
|
|
1343
|
+
w.ERR_DEPRECATED
|
|
1344
|
+
);
|
|
1345
|
+
return t && !st[o] && (st[o] = !0, console.warn(
|
|
1346
|
+
r(
|
|
1347
|
+
o,
|
|
1348
|
+
" has been deprecated since v" + t + " and will be removed in the near future"
|
|
1349
|
+
)
|
|
1350
|
+
)), e ? e(i, o, c) : !0;
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
be.spelling = function(e) {
|
|
1354
|
+
return (t, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0);
|
|
1355
|
+
};
|
|
1356
|
+
function Ss(s, e, t) {
|
|
1357
|
+
if (typeof s != "object")
|
|
1358
|
+
throw new w("options must be an object", w.ERR_BAD_OPTION_VALUE);
|
|
1359
|
+
const n = Object.keys(s);
|
|
1360
|
+
let r = n.length;
|
|
1361
|
+
for (; r-- > 0; ) {
|
|
1362
|
+
const i = n[r], o = e[i];
|
|
1363
|
+
if (o) {
|
|
1364
|
+
const c = s[i], h = c === void 0 || o(c, i, s);
|
|
1365
|
+
if (h !== !0)
|
|
1366
|
+
throw new w("option " + i + " must be " + h, w.ERR_BAD_OPTION_VALUE);
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
if (t !== !0)
|
|
1370
|
+
throw new w("Unknown option " + i, w.ERR_BAD_OPTION);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
const le = {
|
|
1374
|
+
assertOptions: Ss,
|
|
1375
|
+
validators: be
|
|
1376
|
+
}, F = le.validators;
|
|
1377
|
+
let z = class {
|
|
1378
|
+
constructor(e) {
|
|
1379
|
+
this.defaults = e, this.interceptors = {
|
|
1380
|
+
request: new Ke(),
|
|
1381
|
+
response: new Ke()
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Dispatch a request
|
|
1386
|
+
*
|
|
1387
|
+
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
1388
|
+
* @param {?Object} config
|
|
1389
|
+
*
|
|
1390
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
1391
|
+
*/
|
|
1392
|
+
async request(e, t) {
|
|
1393
|
+
try {
|
|
1394
|
+
return await this._request(e, t);
|
|
1395
|
+
} catch (n) {
|
|
1396
|
+
if (n instanceof Error) {
|
|
1397
|
+
let r = {};
|
|
1398
|
+
Error.captureStackTrace ? Error.captureStackTrace(r) : r = new Error();
|
|
1399
|
+
const i = r.stack ? r.stack.replace(/^.+\n/, "") : "";
|
|
1400
|
+
try {
|
|
1401
|
+
n.stack ? i && !String(n.stack).endsWith(i.replace(/^.+\n.+\n/, "")) && (n.stack += `
|
|
1402
|
+
` + i) : n.stack = i;
|
|
1403
|
+
} catch {
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
throw n;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
_request(e, t) {
|
|
1410
|
+
typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = V(this.defaults, t);
|
|
1411
|
+
const { transitional: n, paramsSerializer: r, headers: i } = t;
|
|
1412
|
+
n !== void 0 && le.assertOptions(n, {
|
|
1413
|
+
silentJSONParsing: F.transitional(F.boolean),
|
|
1414
|
+
forcedJSONParsing: F.transitional(F.boolean),
|
|
1415
|
+
clarifyTimeoutError: F.transitional(F.boolean)
|
|
1416
|
+
}, !1), r != null && (l.isFunction(r) ? t.paramsSerializer = {
|
|
1417
|
+
serialize: r
|
|
1418
|
+
} : le.assertOptions(r, {
|
|
1419
|
+
encode: F.function,
|
|
1420
|
+
serialize: F.function
|
|
1421
|
+
}, !0)), t.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? t.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : t.allowAbsoluteUrls = !0), le.assertOptions(t, {
|
|
1422
|
+
baseUrl: F.spelling("baseURL"),
|
|
1423
|
+
withXsrfToken: F.spelling("withXSRFToken")
|
|
1424
|
+
}, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase();
|
|
1425
|
+
let o = i && l.merge(
|
|
1426
|
+
i.common,
|
|
1427
|
+
i[t.method]
|
|
1428
|
+
);
|
|
1429
|
+
i && l.forEach(
|
|
1430
|
+
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
1431
|
+
(f) => {
|
|
1432
|
+
delete i[f];
|
|
1433
|
+
}
|
|
1434
|
+
), t.headers = T.concat(o, i);
|
|
1435
|
+
const c = [];
|
|
1436
|
+
let h = !0;
|
|
1437
|
+
this.interceptors.request.forEach(function(m) {
|
|
1438
|
+
typeof m.runWhen == "function" && m.runWhen(t) === !1 || (h = h && m.synchronous, c.unshift(m.fulfilled, m.rejected));
|
|
1439
|
+
});
|
|
1440
|
+
const u = [];
|
|
1441
|
+
this.interceptors.response.forEach(function(m) {
|
|
1442
|
+
u.push(m.fulfilled, m.rejected);
|
|
1443
|
+
});
|
|
1444
|
+
let a, d = 0, g;
|
|
1445
|
+
if (!h) {
|
|
1446
|
+
const f = [nt.bind(this), void 0];
|
|
1447
|
+
for (f.unshift.apply(f, c), f.push.apply(f, u), g = f.length, a = Promise.resolve(t); d < g; )
|
|
1448
|
+
a = a.then(f[d++], f[d++]);
|
|
1449
|
+
return a;
|
|
1450
|
+
}
|
|
1451
|
+
g = c.length;
|
|
1452
|
+
let b = t;
|
|
1453
|
+
for (d = 0; d < g; ) {
|
|
1454
|
+
const f = c[d++], m = c[d++];
|
|
1455
|
+
try {
|
|
1456
|
+
b = f(b);
|
|
1457
|
+
} catch (p) {
|
|
1458
|
+
m.call(this, p);
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
try {
|
|
1463
|
+
a = nt.call(this, b);
|
|
1464
|
+
} catch (f) {
|
|
1465
|
+
return Promise.reject(f);
|
|
1466
|
+
}
|
|
1467
|
+
for (d = 0, g = u.length; d < g; )
|
|
1468
|
+
a = a.then(u[d++], u[d++]);
|
|
1469
|
+
return a;
|
|
1470
|
+
}
|
|
1471
|
+
getUri(e) {
|
|
1472
|
+
e = V(this.defaults, e);
|
|
1473
|
+
const t = Nt(e.baseURL, e.url, e.allowAbsoluteUrls);
|
|
1474
|
+
return At(t, e.params, e.paramsSerializer);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
l.forEach(["delete", "get", "head", "options"], function(e) {
|
|
1478
|
+
z.prototype[e] = function(t, n) {
|
|
1479
|
+
return this.request(V(n || {}, {
|
|
1480
|
+
method: e,
|
|
1481
|
+
url: t,
|
|
1482
|
+
data: (n || {}).data
|
|
1483
|
+
}));
|
|
1484
|
+
};
|
|
1485
|
+
});
|
|
1486
|
+
l.forEach(["post", "put", "patch"], function(e) {
|
|
1487
|
+
function t(n) {
|
|
1488
|
+
return function(i, o, c) {
|
|
1489
|
+
return this.request(V(c || {}, {
|
|
1490
|
+
method: e,
|
|
1491
|
+
headers: n ? {
|
|
1492
|
+
"Content-Type": "multipart/form-data"
|
|
1493
|
+
} : {},
|
|
1494
|
+
url: i,
|
|
1495
|
+
data: o
|
|
1496
|
+
}));
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
z.prototype[e] = t(), z.prototype[e + "Form"] = t(!0);
|
|
1500
|
+
});
|
|
1501
|
+
let xs = class jt {
|
|
1502
|
+
constructor(e) {
|
|
1503
|
+
if (typeof e != "function")
|
|
1504
|
+
throw new TypeError("executor must be a function.");
|
|
1505
|
+
let t;
|
|
1506
|
+
this.promise = new Promise(function(i) {
|
|
1507
|
+
t = i;
|
|
1508
|
+
});
|
|
1509
|
+
const n = this;
|
|
1510
|
+
this.promise.then((r) => {
|
|
1511
|
+
if (!n._listeners) return;
|
|
1512
|
+
let i = n._listeners.length;
|
|
1513
|
+
for (; i-- > 0; )
|
|
1514
|
+
n._listeners[i](r);
|
|
1515
|
+
n._listeners = null;
|
|
1516
|
+
}), this.promise.then = (r) => {
|
|
1517
|
+
let i;
|
|
1518
|
+
const o = new Promise((c) => {
|
|
1519
|
+
n.subscribe(c), i = c;
|
|
1520
|
+
}).then(r);
|
|
1521
|
+
return o.cancel = function() {
|
|
1522
|
+
n.unsubscribe(i);
|
|
1523
|
+
}, o;
|
|
1524
|
+
}, e(function(i, o, c) {
|
|
1525
|
+
n.reason || (n.reason = new X(i, o, c), t(n.reason));
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Throws a `CanceledError` if cancellation has been requested.
|
|
1530
|
+
*/
|
|
1531
|
+
throwIfRequested() {
|
|
1532
|
+
if (this.reason)
|
|
1533
|
+
throw this.reason;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Subscribe to the cancel signal
|
|
1537
|
+
*/
|
|
1538
|
+
subscribe(e) {
|
|
1539
|
+
if (this.reason) {
|
|
1540
|
+
e(this.reason);
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
this._listeners ? this._listeners.push(e) : this._listeners = [e];
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Unsubscribe from the cancel signal
|
|
1547
|
+
*/
|
|
1548
|
+
unsubscribe(e) {
|
|
1549
|
+
if (!this._listeners)
|
|
1550
|
+
return;
|
|
1551
|
+
const t = this._listeners.indexOf(e);
|
|
1552
|
+
t !== -1 && this._listeners.splice(t, 1);
|
|
1553
|
+
}
|
|
1554
|
+
toAbortSignal() {
|
|
1555
|
+
const e = new AbortController(), t = (n) => {
|
|
1556
|
+
e.abort(n);
|
|
1557
|
+
};
|
|
1558
|
+
return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
1562
|
+
* cancels the `CancelToken`.
|
|
1563
|
+
*/
|
|
1564
|
+
static source() {
|
|
1565
|
+
let e;
|
|
1566
|
+
return {
|
|
1567
|
+
token: new jt(function(r) {
|
|
1568
|
+
e = r;
|
|
1569
|
+
}),
|
|
1570
|
+
cancel: e
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
function Rs(s) {
|
|
1575
|
+
return function(t) {
|
|
1576
|
+
return s.apply(null, t);
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
function As(s) {
|
|
1580
|
+
return l.isObject(s) && s.isAxiosError === !0;
|
|
1581
|
+
}
|
|
1582
|
+
const Pe = {
|
|
1583
|
+
Continue: 100,
|
|
1584
|
+
SwitchingProtocols: 101,
|
|
1585
|
+
Processing: 102,
|
|
1586
|
+
EarlyHints: 103,
|
|
1587
|
+
Ok: 200,
|
|
1588
|
+
Created: 201,
|
|
1589
|
+
Accepted: 202,
|
|
1590
|
+
NonAuthoritativeInformation: 203,
|
|
1591
|
+
NoContent: 204,
|
|
1592
|
+
ResetContent: 205,
|
|
1593
|
+
PartialContent: 206,
|
|
1594
|
+
MultiStatus: 207,
|
|
1595
|
+
AlreadyReported: 208,
|
|
1596
|
+
ImUsed: 226,
|
|
1597
|
+
MultipleChoices: 300,
|
|
1598
|
+
MovedPermanently: 301,
|
|
1599
|
+
Found: 302,
|
|
1600
|
+
SeeOther: 303,
|
|
1601
|
+
NotModified: 304,
|
|
1602
|
+
UseProxy: 305,
|
|
1603
|
+
Unused: 306,
|
|
1604
|
+
TemporaryRedirect: 307,
|
|
1605
|
+
PermanentRedirect: 308,
|
|
1606
|
+
BadRequest: 400,
|
|
1607
|
+
Unauthorized: 401,
|
|
1608
|
+
PaymentRequired: 402,
|
|
1609
|
+
Forbidden: 403,
|
|
1610
|
+
NotFound: 404,
|
|
1611
|
+
MethodNotAllowed: 405,
|
|
1612
|
+
NotAcceptable: 406,
|
|
1613
|
+
ProxyAuthenticationRequired: 407,
|
|
1614
|
+
RequestTimeout: 408,
|
|
1615
|
+
Conflict: 409,
|
|
1616
|
+
Gone: 410,
|
|
1617
|
+
LengthRequired: 411,
|
|
1618
|
+
PreconditionFailed: 412,
|
|
1619
|
+
PayloadTooLarge: 413,
|
|
1620
|
+
UriTooLong: 414,
|
|
1621
|
+
UnsupportedMediaType: 415,
|
|
1622
|
+
RangeNotSatisfiable: 416,
|
|
1623
|
+
ExpectationFailed: 417,
|
|
1624
|
+
ImATeapot: 418,
|
|
1625
|
+
MisdirectedRequest: 421,
|
|
1626
|
+
UnprocessableEntity: 422,
|
|
1627
|
+
Locked: 423,
|
|
1628
|
+
FailedDependency: 424,
|
|
1629
|
+
TooEarly: 425,
|
|
1630
|
+
UpgradeRequired: 426,
|
|
1631
|
+
PreconditionRequired: 428,
|
|
1632
|
+
TooManyRequests: 429,
|
|
1633
|
+
RequestHeaderFieldsTooLarge: 431,
|
|
1634
|
+
UnavailableForLegalReasons: 451,
|
|
1635
|
+
InternalServerError: 500,
|
|
1636
|
+
NotImplemented: 501,
|
|
1637
|
+
BadGateway: 502,
|
|
1638
|
+
ServiceUnavailable: 503,
|
|
1639
|
+
GatewayTimeout: 504,
|
|
1640
|
+
HttpVersionNotSupported: 505,
|
|
1641
|
+
VariantAlsoNegotiates: 506,
|
|
1642
|
+
InsufficientStorage: 507,
|
|
1643
|
+
LoopDetected: 508,
|
|
1644
|
+
NotExtended: 510,
|
|
1645
|
+
NetworkAuthenticationRequired: 511
|
|
1646
|
+
};
|
|
1647
|
+
Object.entries(Pe).forEach(([s, e]) => {
|
|
1648
|
+
Pe[e] = s;
|
|
1649
|
+
});
|
|
1650
|
+
function Ft(s) {
|
|
1651
|
+
const e = new z(s), t = pt(z.prototype.request, e);
|
|
1652
|
+
return l.extend(t, z.prototype, e, { allOwnKeys: !0 }), l.extend(t, e, null, { allOwnKeys: !0 }), t.create = function(r) {
|
|
1653
|
+
return Ft(V(s, r));
|
|
1654
|
+
}, t;
|
|
1655
|
+
}
|
|
1656
|
+
const R = Ft(te);
|
|
1657
|
+
R.Axios = z;
|
|
1658
|
+
R.CanceledError = X;
|
|
1659
|
+
R.CancelToken = xs;
|
|
1660
|
+
R.isCancel = Tt;
|
|
1661
|
+
R.VERSION = $t;
|
|
1662
|
+
R.toFormData = me;
|
|
1663
|
+
R.AxiosError = w;
|
|
1664
|
+
R.Cancel = R.CanceledError;
|
|
1665
|
+
R.all = function(e) {
|
|
1666
|
+
return Promise.all(e);
|
|
1667
|
+
};
|
|
1668
|
+
R.spread = Rs;
|
|
1669
|
+
R.isAxiosError = As;
|
|
1670
|
+
R.mergeConfig = V;
|
|
1671
|
+
R.AxiosHeaders = T;
|
|
1672
|
+
R.formToJSON = (s) => Ct(l.isHTMLForm(s) ? new FormData(s) : s);
|
|
1673
|
+
R.getAdapter = vt.getAdapter;
|
|
1674
|
+
R.HttpStatusCode = Pe;
|
|
1675
|
+
R.default = R;
|
|
1676
|
+
const {
|
|
1677
|
+
Axios: zr,
|
|
1678
|
+
AxiosError: Vr,
|
|
1679
|
+
CanceledError: Jr,
|
|
1680
|
+
isCancel: Wr,
|
|
1681
|
+
CancelToken: Kr,
|
|
1682
|
+
VERSION: Xr,
|
|
1683
|
+
all: Gr,
|
|
1684
|
+
Cancel: Zr,
|
|
1685
|
+
isAxiosError: Qr,
|
|
1686
|
+
spread: Yr,
|
|
1687
|
+
toFormData: ei,
|
|
1688
|
+
AxiosHeaders: ti,
|
|
1689
|
+
HttpStatusCode: ni,
|
|
1690
|
+
formToJSON: si,
|
|
1691
|
+
getAdapter: ri,
|
|
1692
|
+
mergeConfig: ii
|
|
1693
|
+
} = R, Ue = R.create({
|
|
1694
|
+
baseURL: location.origin,
|
|
1695
|
+
timeout: 6e4,
|
|
1696
|
+
params: {}
|
|
1697
|
+
});
|
|
1698
|
+
Ue.interceptors.response.use(
|
|
1699
|
+
(s) => s,
|
|
1700
|
+
(s) => {
|
|
1701
|
+
var e, t, n, r, i, o, c, h, u, a, d;
|
|
1702
|
+
if (s.response) {
|
|
1703
|
+
if (s.response.status === 401 && OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity, !0).then(
|
|
1704
|
+
function(f) {
|
|
1705
|
+
f && OpenC3Auth.setTokens();
|
|
1706
|
+
}
|
|
1707
|
+
), s.response.config.headers["Ignore-Errors"] && s.response.config.headers["Ignore-Errors"].includes(
|
|
1708
|
+
s.response.status.toString()
|
|
1709
|
+
))
|
|
1710
|
+
return Promise.reject(s);
|
|
1711
|
+
let g = `HTTP ${s.response.status} - `;
|
|
1712
|
+
(e = s.response) != null && e.statusText && (g += `${s.response.statusText} `), (n = (t = s.response) == null ? void 0 : t.config) != null && n.data && (g += `${s.response.config.data} `), (i = (r = s.response) == null ? void 0 : r.data) != null && i.message ? g += `${s.response.data.message}` : (c = (o = s.response) == null ? void 0 : o.data) != null && c.exception ? g += `${s.response.data.exception}` : (a = (u = (h = s.response) == null ? void 0 : h.data) == null ? void 0 : u.error) != null && a.message ? (s.response.data.error.class && (g += `${s.response.data.error.class} `), g += `${s.response.data.error.message}`) : g += `${(d = s.response) == null ? void 0 : d.data}`;
|
|
1713
|
+
const { $cosmosNotify: b } = window;
|
|
1714
|
+
throw b && b.serious({
|
|
1715
|
+
title: "Network error",
|
|
1716
|
+
body: g
|
|
1717
|
+
}), s;
|
|
1718
|
+
} else
|
|
1719
|
+
throw s;
|
|
1720
|
+
}
|
|
1721
|
+
);
|
|
1722
|
+
const re = async function(s, e, {
|
|
1723
|
+
data: t,
|
|
1724
|
+
params: n = {},
|
|
1725
|
+
headers: r,
|
|
1726
|
+
noAuth: i = !1,
|
|
1727
|
+
noScope: o = !1,
|
|
1728
|
+
onUploadProgress: c = !1
|
|
1729
|
+
} = {}) {
|
|
1730
|
+
if (!i) {
|
|
1731
|
+
try {
|
|
1732
|
+
await OpenC3Auth.updateToken(
|
|
1733
|
+
OpenC3Auth.defaultMinValidity
|
|
1734
|
+
) && OpenC3Auth.setTokens();
|
|
1735
|
+
} catch {
|
|
1736
|
+
OpenC3Auth.login();
|
|
1737
|
+
}
|
|
1738
|
+
r.Authorization = localStorage.openc3Token;
|
|
1739
|
+
}
|
|
1740
|
+
return r.manual = !0, !o && !n.scope && (n.scope = window.openc3Scope), Ue({
|
|
1741
|
+
method: s,
|
|
1742
|
+
url: e,
|
|
1743
|
+
data: t,
|
|
1744
|
+
params: n,
|
|
1745
|
+
headers: r,
|
|
1746
|
+
onUploadProgress: c
|
|
1747
|
+
});
|
|
1748
|
+
}, Ie = {
|
|
1749
|
+
Accept: "application/json"
|
|
1750
|
+
}, rt = {
|
|
1751
|
+
...Ie,
|
|
1752
|
+
"Content-Type": "application/json"
|
|
1753
|
+
}, oi = {
|
|
1754
|
+
get: function(s, {
|
|
1755
|
+
params: e,
|
|
1756
|
+
headers: t = Ie,
|
|
1757
|
+
noScope: n,
|
|
1758
|
+
noAuth: r,
|
|
1759
|
+
onUploadProgress: i
|
|
1760
|
+
} = {}) {
|
|
1761
|
+
return re("get", s, {
|
|
1762
|
+
params: e,
|
|
1763
|
+
headers: t,
|
|
1764
|
+
noScope: n,
|
|
1765
|
+
noAuth: r,
|
|
1766
|
+
onUploadProgress: i
|
|
1767
|
+
});
|
|
1768
|
+
},
|
|
1769
|
+
put: function(s, {
|
|
1770
|
+
data: e,
|
|
1771
|
+
params: t,
|
|
1772
|
+
headers: n = rt,
|
|
1773
|
+
noScope: r,
|
|
1774
|
+
noAuth: i,
|
|
1775
|
+
onUploadProgress: o
|
|
1776
|
+
} = {}) {
|
|
1777
|
+
return re("put", s, {
|
|
1778
|
+
data: e,
|
|
1779
|
+
params: t,
|
|
1780
|
+
headers: n,
|
|
1781
|
+
noScope: r,
|
|
1782
|
+
noAuth: i,
|
|
1783
|
+
onUploadProgress: o
|
|
1784
|
+
});
|
|
1785
|
+
},
|
|
1786
|
+
post: function(s, {
|
|
1787
|
+
data: e,
|
|
1788
|
+
params: t,
|
|
1789
|
+
headers: n = rt,
|
|
1790
|
+
noScope: r,
|
|
1791
|
+
noAuth: i,
|
|
1792
|
+
onUploadProgress: o
|
|
1793
|
+
} = {}) {
|
|
1794
|
+
return re("post", s, {
|
|
1795
|
+
data: e,
|
|
1796
|
+
params: t,
|
|
1797
|
+
headers: n,
|
|
1798
|
+
noScope: r,
|
|
1799
|
+
noAuth: i,
|
|
1800
|
+
onUploadProgress: o
|
|
1801
|
+
});
|
|
1802
|
+
},
|
|
1803
|
+
delete: function(s, {
|
|
1804
|
+
params: e,
|
|
1805
|
+
headers: t = Ie,
|
|
1806
|
+
noScope: n,
|
|
1807
|
+
noAuth: r,
|
|
1808
|
+
onUploadProgress: i
|
|
1809
|
+
} = {}) {
|
|
1810
|
+
return re("delete", s, {
|
|
1811
|
+
params: e,
|
|
1812
|
+
headers: t,
|
|
1813
|
+
noScope: n,
|
|
1814
|
+
noAuth: r,
|
|
1815
|
+
onUploadProgress: i
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
let we = () => ({
|
|
1820
|
+
emit(s, ...e) {
|
|
1821
|
+
for (let t = this.events[s] || [], n = 0, r = t.length; n < r; n++)
|
|
1822
|
+
t[n](...e);
|
|
1823
|
+
},
|
|
1824
|
+
events: {},
|
|
1825
|
+
on(s, e) {
|
|
1826
|
+
var t;
|
|
1827
|
+
return ((t = this.events)[s] || (t[s] = [])).push(e), () => {
|
|
1828
|
+
var n;
|
|
1829
|
+
this.events[s] = (n = this.events[s]) == null ? void 0 : n.filter((r) => e !== r);
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
class ne extends Error {
|
|
1834
|
+
constructor(e, t) {
|
|
1835
|
+
e instanceof Error ? (super(e.message), this.cause = e) : super(e), this.reason = t, this.name = "ReasonError";
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
class De extends ne {
|
|
1839
|
+
constructor(e) {
|
|
1840
|
+
super("Rejected", e), this.name = "SubscriptionRejectedError";
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
class Os extends ne {
|
|
1844
|
+
constructor(e) {
|
|
1845
|
+
super(e || "Timed out to receive subscription ack"), this.name = "SubscriptionTimeoutError";
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
class $ extends ne {
|
|
1849
|
+
constructor(e, t) {
|
|
1850
|
+
t ? super(e, t) : super("Disconnected", e), this.name = "DisconnectedError";
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
class Cs extends $ {
|
|
1854
|
+
constructor(e) {
|
|
1855
|
+
super(e, "stale_connection"), this.name = "StaleConnectionError";
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
function Ut(s) {
|
|
1859
|
+
return s ? `{${Object.keys(s).sort().filter((t) => s[t] !== void 0).map((t) => {
|
|
1860
|
+
let n = JSON.stringify(s[t]);
|
|
1861
|
+
return `${JSON.stringify(t)}:${n}`;
|
|
1862
|
+
}).join(",")}}` : "";
|
|
1863
|
+
}
|
|
1864
|
+
class Ts {
|
|
1865
|
+
constructor(e) {
|
|
1866
|
+
this.channel = e, this.listeners = [];
|
|
1867
|
+
}
|
|
1868
|
+
watch() {
|
|
1869
|
+
this.listeners.push(
|
|
1870
|
+
this.channel.on("presence", (e) => {
|
|
1871
|
+
if (e.type === "info") {
|
|
1872
|
+
this._state || (this._state = this.stateFromInfo(e));
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
this._state && (e.type === "join" ? this._state[e.id] = e.info : e.type === "leave" && delete this._state[e.id]);
|
|
1876
|
+
})
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
// Reset the state to make sure the fresh one is
|
|
1880
|
+
// requested the next time info() is called
|
|
1881
|
+
reset() {
|
|
1882
|
+
delete this._state;
|
|
1883
|
+
}
|
|
1884
|
+
dispose() {
|
|
1885
|
+
delete this._info, delete this._state, this.listeners.forEach((e) => e()), this.listeners.length = 0;
|
|
1886
|
+
}
|
|
1887
|
+
async join(e, t) {
|
|
1888
|
+
if (!this._info)
|
|
1889
|
+
return this._info = { id: e, info: t }, this.channel.perform("$presence:join", this._info);
|
|
1890
|
+
}
|
|
1891
|
+
async leave() {
|
|
1892
|
+
if (!this._info) return;
|
|
1893
|
+
let e = await this.channel.perform("$presence:leave");
|
|
1894
|
+
return delete this._info, e;
|
|
1895
|
+
}
|
|
1896
|
+
async info() {
|
|
1897
|
+
return this._state ? this._state : (this._promise || (this._promise = this._sync()), await this._promise, this._state);
|
|
1898
|
+
}
|
|
1899
|
+
async _sync() {
|
|
1900
|
+
this.watch();
|
|
1901
|
+
try {
|
|
1902
|
+
let e = await this.channel.perform("$presence:info", {});
|
|
1903
|
+
return this._state = this.stateFromInfo(e), this._state;
|
|
1904
|
+
} finally {
|
|
1905
|
+
delete this._promise;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
stateFromInfo(e) {
|
|
1909
|
+
return e.records.reduce((t, { id: n, info: r }) => (t[n] = r, t), {});
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
const B = Symbol("state");
|
|
1913
|
+
class Dt {
|
|
1914
|
+
// Unique channel identifier
|
|
1915
|
+
// static identifier = ''
|
|
1916
|
+
constructor(e = {}) {
|
|
1917
|
+
this.emitter = we(), this.params = Object.freeze(e), this.presence = new Ts(this), this.initialConnect = !0, this[B] = "idle";
|
|
1918
|
+
}
|
|
1919
|
+
get identifier() {
|
|
1920
|
+
return this._identifier ? this._identifier : (this._identifier = Ut({
|
|
1921
|
+
channel: this.channelId,
|
|
1922
|
+
...this.params
|
|
1923
|
+
}), this._identifier);
|
|
1924
|
+
}
|
|
1925
|
+
get channelId() {
|
|
1926
|
+
return this.constructor.identifier;
|
|
1927
|
+
}
|
|
1928
|
+
get state() {
|
|
1929
|
+
return this[B];
|
|
1930
|
+
}
|
|
1931
|
+
attached(e) {
|
|
1932
|
+
if (this.receiver) {
|
|
1933
|
+
if (this.receiver !== e)
|
|
1934
|
+
throw Error("Already connected to a different receiver");
|
|
1935
|
+
return !1;
|
|
1936
|
+
}
|
|
1937
|
+
return this.receiver = e, !0;
|
|
1938
|
+
}
|
|
1939
|
+
connecting() {
|
|
1940
|
+
this[B] = "connecting";
|
|
1941
|
+
}
|
|
1942
|
+
connected() {
|
|
1943
|
+
if (this.state === "connected" || this.state === "closed") return;
|
|
1944
|
+
this[B] = "connected";
|
|
1945
|
+
let e = !1;
|
|
1946
|
+
this.initialConnect ? (this.initialConnect = !1, this.emit("connect", { reconnect: !1, restored: e })) : this.emit("connect", { reconnect: !0, restored: e });
|
|
1947
|
+
}
|
|
1948
|
+
restored() {
|
|
1949
|
+
if (this.state === "connected") throw Error("Already connected");
|
|
1950
|
+
this[B] = "connected";
|
|
1951
|
+
let e = !0, t = !0;
|
|
1952
|
+
this.initialConnect = !1, this.emit("connect", { reconnect: t, restored: e });
|
|
1953
|
+
}
|
|
1954
|
+
disconnected(e) {
|
|
1955
|
+
this.state === "disconnected" || this.state === "closed" || (this[B] = "disconnected", this.presence.reset(), this.emit("disconnect", e));
|
|
1956
|
+
}
|
|
1957
|
+
closed(e) {
|
|
1958
|
+
this.state !== "closed" && (this[B] = "closed", delete this.receiver, this.initialConnect = !0, this.presence.dispose(), this.emit("close", e));
|
|
1959
|
+
}
|
|
1960
|
+
disconnect() {
|
|
1961
|
+
this.state === "idle" || this.state === "closed" || this.receiver.unsubscribe(this);
|
|
1962
|
+
}
|
|
1963
|
+
async perform(e, t) {
|
|
1964
|
+
if (this.state === "idle" || this.state === "closed")
|
|
1965
|
+
throw Error("Channel is not subscribed");
|
|
1966
|
+
return this.receiver.perform(this.identifier, e, t);
|
|
1967
|
+
}
|
|
1968
|
+
async send(e) {
|
|
1969
|
+
return this.perform(void 0, e);
|
|
1970
|
+
}
|
|
1971
|
+
async whisper(e) {
|
|
1972
|
+
try {
|
|
1973
|
+
await this.perform("$whisper", e);
|
|
1974
|
+
} catch (t) {
|
|
1975
|
+
let n = this.receiver ? this.receiver.logger : null;
|
|
1976
|
+
n && n.warn("whisper failed: ", t);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
receive(e, t) {
|
|
1980
|
+
this.emit("message", e, t);
|
|
1981
|
+
}
|
|
1982
|
+
on(e, t) {
|
|
1983
|
+
return this.emitter.on(e, t);
|
|
1984
|
+
}
|
|
1985
|
+
once(e, t) {
|
|
1986
|
+
let n = this.emitter.on(e, (...r) => {
|
|
1987
|
+
n(), t(...r);
|
|
1988
|
+
});
|
|
1989
|
+
return n;
|
|
1990
|
+
}
|
|
1991
|
+
emit(e, ...t) {
|
|
1992
|
+
return this.emitter.emit(e, ...t);
|
|
1993
|
+
}
|
|
1994
|
+
ensureSubscribed() {
|
|
1995
|
+
return this.state === "connected" ? Promise.resolve() : this.state === "closed" ? Promise.reject(Error("Channel is unsubscribed")) : this.pendingSubscribe();
|
|
1996
|
+
}
|
|
1997
|
+
// This promise resolves when subscription is confirmed
|
|
1998
|
+
// and rejects when rejected or closed.
|
|
1999
|
+
// It ignores disconnect events.
|
|
2000
|
+
pendingSubscribe() {
|
|
2001
|
+
return this._pendingSubscribe ? this._pendingSubscribe : (this._pendingSubscribe = new Promise((e, t) => {
|
|
2002
|
+
let n = [() => delete this._pendingSubscribe];
|
|
2003
|
+
n.push(
|
|
2004
|
+
this.on("connect", () => {
|
|
2005
|
+
n.forEach((r) => r()), e();
|
|
2006
|
+
})
|
|
2007
|
+
), n.push(
|
|
2008
|
+
this.on("close", (r) => {
|
|
2009
|
+
n.forEach((i) => i()), t(
|
|
2010
|
+
r || new ne(
|
|
2011
|
+
"Channel was disconnected before subscribing",
|
|
2012
|
+
"canceled"
|
|
2013
|
+
)
|
|
2014
|
+
);
|
|
2015
|
+
})
|
|
2016
|
+
);
|
|
2017
|
+
}), this._pendingSubscribe);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
class ks {
|
|
2021
|
+
constructor(e) {
|
|
2022
|
+
this.id = e, this.intent = "unsubscribed", this.state = "idle", this.channels = [], this.disposed = !1, this._pendings = [];
|
|
2023
|
+
}
|
|
2024
|
+
add(e) {
|
|
2025
|
+
this.channels.includes(e) || this.channels.push(e);
|
|
2026
|
+
}
|
|
2027
|
+
remove(e) {
|
|
2028
|
+
let t = this.channels.indexOf(e);
|
|
2029
|
+
t > -1 && this.channels.splice(t, 1);
|
|
2030
|
+
}
|
|
2031
|
+
notify(e, ...t) {
|
|
2032
|
+
this.state = e === "restored" ? "connected" : e, t.length === 1 ? this.channels.forEach((n) => n[e](t[0])) : this.channels.forEach((n) => n[e]());
|
|
2033
|
+
}
|
|
2034
|
+
pending(e) {
|
|
2035
|
+
this._checkIntent(e);
|
|
2036
|
+
let t = this._pendings[0];
|
|
2037
|
+
return !t || t.intent !== e ? Promise.resolve() : t.promise;
|
|
2038
|
+
}
|
|
2039
|
+
ensureResubscribed() {
|
|
2040
|
+
this.disposed || (this.intent = void 0, this.ensureSubscribed());
|
|
2041
|
+
}
|
|
2042
|
+
ensureSubscribed() {
|
|
2043
|
+
if (this.intent === "subscribed") return;
|
|
2044
|
+
if (this.disposed) throw Error("Subscription is disposed");
|
|
2045
|
+
this.intent = "subscribed", !this._mergeWithPending("unsubscribed") && this.subscriber(this);
|
|
2046
|
+
}
|
|
2047
|
+
maybeUnsubscribe() {
|
|
2048
|
+
this.disposed || this.intent === "unsubscribed" || this.channels.length > 0 || (this.intent = "unsubscribed", this._mergeWithPending("subscribed")) || this.unsubscriber(this);
|
|
2049
|
+
}
|
|
2050
|
+
async acquire(e) {
|
|
2051
|
+
this._checkIntent(e);
|
|
2052
|
+
let t, r = {
|
|
2053
|
+
promise: new Promise((o) => {
|
|
2054
|
+
t = o;
|
|
2055
|
+
}),
|
|
2056
|
+
intent: e,
|
|
2057
|
+
release: () => {
|
|
2058
|
+
this._pendings.splice(this._pendings.indexOf(r), 1), t(r);
|
|
2059
|
+
},
|
|
2060
|
+
canceled: !1,
|
|
2061
|
+
acquired: !1
|
|
2062
|
+
}, i = this._pendingTop;
|
|
2063
|
+
return this._pendings.push(r), i && await i.promise, this.gvl && await this.gvl.acquire(r, e), r.acquired = !0, r;
|
|
2064
|
+
}
|
|
2065
|
+
close(e) {
|
|
2066
|
+
this.disposed = !0, this.intent = void 0, this.notify("closed", e);
|
|
2067
|
+
}
|
|
2068
|
+
_checkIntent(e) {
|
|
2069
|
+
if (!(e === "unsubscribed" || e === "subscribed"))
|
|
2070
|
+
throw Error(`Unknown subscription intent: ${e}`);
|
|
2071
|
+
}
|
|
2072
|
+
get _pendingTop() {
|
|
2073
|
+
return this._pendings.length ? this._pendings[this._pendings.length - 1] : void 0;
|
|
2074
|
+
}
|
|
2075
|
+
_mergeWithPending(e) {
|
|
2076
|
+
let t = this._pendingTop;
|
|
2077
|
+
return !t || t.acquired || t.intent !== e ? !1 : (this._pendings.pop(), t.canceled = !0, !0);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
class Ns {
|
|
2081
|
+
constructor() {
|
|
2082
|
+
this.queue = [];
|
|
2083
|
+
}
|
|
2084
|
+
async acquire(e, t) {
|
|
2085
|
+
t === "subscribed" && (this.queue.push(
|
|
2086
|
+
e.promise.then(() => {
|
|
2087
|
+
this.queue.splice(this.queue.indexOf(e), 1);
|
|
2088
|
+
})
|
|
2089
|
+
), this.queue.length > 1 && await this.queue[this.queue.length - 2]);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
class Ps {
|
|
2093
|
+
constructor(e) {
|
|
2094
|
+
e.concurrentSubscribes === !1 && (this.glv = new Ns()), this._subscriptions = {}, this._localToRemote = {};
|
|
2095
|
+
}
|
|
2096
|
+
all() {
|
|
2097
|
+
return Object.values(this._subscriptions);
|
|
2098
|
+
}
|
|
2099
|
+
get(e) {
|
|
2100
|
+
return this._subscriptions[e];
|
|
2101
|
+
}
|
|
2102
|
+
create(e, { subscribe: t, unsubscribe: n }) {
|
|
2103
|
+
let r = this._subscriptions[e] = new ks(e);
|
|
2104
|
+
return r.remoteId = this._localToRemote[e], r.subscriber = t, r.unsubscriber = n, r.gvl = this.glv, r;
|
|
2105
|
+
}
|
|
2106
|
+
remove(e) {
|
|
2107
|
+
delete this._subscriptions[e], delete this._localToRemote[e];
|
|
2108
|
+
}
|
|
2109
|
+
storeRemoteId(e, t) {
|
|
2110
|
+
this._localToRemote[e] = t;
|
|
2111
|
+
let n = this.get(e);
|
|
2112
|
+
n && (n.remoteId = t);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
class Is {
|
|
2116
|
+
constructor(e = {}) {
|
|
2117
|
+
this.subscriptions = new Ps(e), this._pendingMessages = [], this._remoteToLocal = {};
|
|
2118
|
+
}
|
|
2119
|
+
subscribe(e, t) {
|
|
2120
|
+
this._remoteToLocal[t] = e, this.subscriptions.storeRemoteId(e, t), this.flush(t);
|
|
2121
|
+
}
|
|
2122
|
+
unsubscribe(e) {
|
|
2123
|
+
let t = this.subscriptions.get(e);
|
|
2124
|
+
if (!t) return;
|
|
2125
|
+
let n = t.remoteId;
|
|
2126
|
+
n && delete this._remoteToLocal[n], this.subscriptions.remove(e);
|
|
2127
|
+
}
|
|
2128
|
+
transmit(e, t, n) {
|
|
2129
|
+
let r = this._remoteToLocal[e];
|
|
2130
|
+
if (!r) {
|
|
2131
|
+
this._pendingMessages.push([e, t, n]);
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
let i = this.subscriptions.get(r);
|
|
2135
|
+
i && i.channels.forEach((o) => {
|
|
2136
|
+
o.receive(t, n);
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
notify(e, t, n) {
|
|
2140
|
+
let r = this._remoteToLocal[e];
|
|
2141
|
+
if (!r)
|
|
2142
|
+
return;
|
|
2143
|
+
let i = this.subscriptions.get(r);
|
|
2144
|
+
i && i.channels.forEach((o) => o.emit(t, n));
|
|
2145
|
+
}
|
|
2146
|
+
close() {
|
|
2147
|
+
this._pendingMessages.length = 0;
|
|
2148
|
+
}
|
|
2149
|
+
get size() {
|
|
2150
|
+
return this.channels.length;
|
|
2151
|
+
}
|
|
2152
|
+
get channels() {
|
|
2153
|
+
return this.subscriptions.all().flatMap((e) => e.channels);
|
|
2154
|
+
}
|
|
2155
|
+
flush(e) {
|
|
2156
|
+
let t = [];
|
|
2157
|
+
for (let n of this._pendingMessages)
|
|
2158
|
+
n[0] === e ? this.transmit(n[0], n[1], n[2]) : t.push(n);
|
|
2159
|
+
this._pendingMessages = t;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
const it = {
|
|
2163
|
+
debug: 0,
|
|
2164
|
+
info: 1,
|
|
2165
|
+
warn: 2,
|
|
2166
|
+
error: 3
|
|
2167
|
+
};
|
|
2168
|
+
class qt {
|
|
2169
|
+
constructor(e) {
|
|
2170
|
+
this.level = e || "warn";
|
|
2171
|
+
}
|
|
2172
|
+
log(e, t, n) {
|
|
2173
|
+
it[e] < it[this.level] || this.writeLogEntry(e, t, n);
|
|
2174
|
+
}
|
|
2175
|
+
writeLogEntry() {
|
|
2176
|
+
throw Error("Not implemented");
|
|
2177
|
+
}
|
|
2178
|
+
debug(e, t) {
|
|
2179
|
+
this.log("debug", e, t);
|
|
2180
|
+
}
|
|
2181
|
+
info(e, t) {
|
|
2182
|
+
this.log("info", e, t);
|
|
2183
|
+
}
|
|
2184
|
+
warn(e, t) {
|
|
2185
|
+
this.log("warn", e, t);
|
|
2186
|
+
}
|
|
2187
|
+
error(e, t) {
|
|
2188
|
+
this.log("error", e, t);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
class se extends qt {
|
|
2192
|
+
writeLogEntry() {
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
class Ls {
|
|
2196
|
+
encode(e) {
|
|
2197
|
+
return JSON.stringify(e);
|
|
2198
|
+
}
|
|
2199
|
+
decode(e) {
|
|
2200
|
+
try {
|
|
2201
|
+
return JSON.parse(e);
|
|
2202
|
+
} catch {
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
let vs = 0;
|
|
2207
|
+
class Bt {
|
|
2208
|
+
constructor(e = {}) {
|
|
2209
|
+
let { logger: t } = e;
|
|
2210
|
+
this.logger = t || new se(), this.pendingSubscriptions = {}, this.pendingUnsubscriptions = {}, this.subscribeCooldownInterval = e.subscribeCooldownInterval || 250, this.subscribeRetryInterval = e.subscribeRetryInterval || 5e3;
|
|
2211
|
+
}
|
|
2212
|
+
attached(e) {
|
|
2213
|
+
this.cable = e;
|
|
2214
|
+
}
|
|
2215
|
+
subscribe(e, t) {
|
|
2216
|
+
let n = { channel: e };
|
|
2217
|
+
t && Object.assign(n, t);
|
|
2218
|
+
let r = Ut(n);
|
|
2219
|
+
if (this.pendingUnsubscriptions[r]) {
|
|
2220
|
+
let o = this.subscribeCooldownInterval * 1.5;
|
|
2221
|
+
return this.logger.debug(
|
|
2222
|
+
`unsubscribed recently, cooldown for ${o}`,
|
|
2223
|
+
r
|
|
2224
|
+
), new Promise((c) => {
|
|
2225
|
+
setTimeout(() => {
|
|
2226
|
+
c(this.subscribe(e, t));
|
|
2227
|
+
}, o);
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
if (this.pendingSubscriptions[r])
|
|
2231
|
+
return this.logger.warn("subscription is already pending, skipping", r), Promise.reject(Error("Already subscribing"));
|
|
2232
|
+
let i = this.subscribeRetryInterval;
|
|
2233
|
+
return new Promise((o, c) => {
|
|
2234
|
+
let h = ++vs;
|
|
2235
|
+
this.pendingSubscriptions[r] = {
|
|
2236
|
+
resolve: o,
|
|
2237
|
+
reject: c,
|
|
2238
|
+
id: h
|
|
2239
|
+
}, this.cable.send(this.buildSubscribeRequest(r)), this.maybeRetrySubscribe(h, r, i);
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
buildSubscribeRequest(e) {
|
|
2243
|
+
return {
|
|
2244
|
+
command: "subscribe",
|
|
2245
|
+
identifier: e
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
maybeRetrySubscribe(e, t, n) {
|
|
2249
|
+
setTimeout(() => {
|
|
2250
|
+
let r = this.pendingSubscriptions[t];
|
|
2251
|
+
r && r.id === e && (this.logger.warn(
|
|
2252
|
+
`no subscription ack received in ${n}ms, retrying subscribe`,
|
|
2253
|
+
t
|
|
2254
|
+
), this.cable.send(this.buildSubscribeRequest(t)), this.maybeExpireSubscribe(e, t, n));
|
|
2255
|
+
}, n);
|
|
2256
|
+
}
|
|
2257
|
+
maybeExpireSubscribe(e, t, n) {
|
|
2258
|
+
setTimeout(() => {
|
|
2259
|
+
let r = this.pendingSubscriptions[t];
|
|
2260
|
+
r && r.id === e && (delete this.pendingSubscriptions[t], r.reject(
|
|
2261
|
+
new Os(
|
|
2262
|
+
`Haven't received subscription ack in ${n * 2}ms for ${t}`
|
|
2263
|
+
)
|
|
2264
|
+
));
|
|
2265
|
+
}, n);
|
|
2266
|
+
}
|
|
2267
|
+
unsubscribe(e) {
|
|
2268
|
+
return this.cable.send({
|
|
2269
|
+
command: "unsubscribe",
|
|
2270
|
+
identifier: e
|
|
2271
|
+
}), this.pendingUnsubscriptions[e] = !0, setTimeout(() => {
|
|
2272
|
+
delete this.pendingUnsubscriptions[e];
|
|
2273
|
+
}, this.subscribeCooldownInterval), Promise.resolve();
|
|
2274
|
+
}
|
|
2275
|
+
perform(e, t, n) {
|
|
2276
|
+
return t === "$whisper" ? this.whisper(e, n) : (n || (n = {}), n.action = t, this.cable.send({
|
|
2277
|
+
command: "message",
|
|
2278
|
+
identifier: e,
|
|
2279
|
+
data: JSON.stringify(n)
|
|
2280
|
+
}), Promise.resolve());
|
|
2281
|
+
}
|
|
2282
|
+
whisper(e, t) {
|
|
2283
|
+
return this.cable.send({
|
|
2284
|
+
command: "whisper",
|
|
2285
|
+
identifier: e,
|
|
2286
|
+
data: t
|
|
2287
|
+
}), Promise.resolve();
|
|
2288
|
+
}
|
|
2289
|
+
receive(e) {
|
|
2290
|
+
if (typeof e != "object") {
|
|
2291
|
+
this.logger.error("unsupported message format", { message: e });
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
let { type: t, identifier: n, message: r, reason: i, reconnect: o } = e;
|
|
2295
|
+
if (t === "ping")
|
|
2296
|
+
return this.cable.keepalive(e.message);
|
|
2297
|
+
if (this.cable.keepalive(), t === "welcome") {
|
|
2298
|
+
let c = e.sid;
|
|
2299
|
+
return c && this.cable.setSessionId(c), this.cable.connected();
|
|
2300
|
+
}
|
|
2301
|
+
if (t === "disconnect") {
|
|
2302
|
+
let c = new $(i);
|
|
2303
|
+
this.reset(c), o === !1 ? this.cable.closed(c) : this.cable.disconnected(c);
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
if (t === "confirm_subscription") {
|
|
2307
|
+
let c = this.pendingSubscriptions[n];
|
|
2308
|
+
if (!c) {
|
|
2309
|
+
this.logger.error("subscription not found, unsubscribing", {
|
|
2310
|
+
type: t,
|
|
2311
|
+
identifier: n
|
|
2312
|
+
}), this.unsubscribe(n);
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
return delete this.pendingSubscriptions[n], c.resolve(n);
|
|
2316
|
+
}
|
|
2317
|
+
if (t === "reject_subscription") {
|
|
2318
|
+
let c = this.pendingSubscriptions[n];
|
|
2319
|
+
return c ? (delete this.pendingSubscriptions[n], c.reject(new De())) : this.logger.error("subscription not found", { type: t, identifier: n });
|
|
2320
|
+
}
|
|
2321
|
+
if (r)
|
|
2322
|
+
return { identifier: n, message: r };
|
|
2323
|
+
this.logger.warn(`unknown message type: ${t}`, { message: e });
|
|
2324
|
+
}
|
|
2325
|
+
reset(e) {
|
|
2326
|
+
for (let t in this.pendingSubscriptions)
|
|
2327
|
+
this.pendingSubscriptions[t].reject(e);
|
|
2328
|
+
this.pendingSubscriptions = {};
|
|
2329
|
+
}
|
|
2330
|
+
recoverableClosure() {
|
|
2331
|
+
return !1;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
const ot = () => Date.now() / 1e3 | 0;
|
|
2335
|
+
class $s extends Bt {
|
|
2336
|
+
constructor(e = {}) {
|
|
2337
|
+
super(e), this.streamsPositions = {}, this.subscriptionStreams = {}, this.pendingHistory = {}, this.pendingPresence = {}, this.presenceInfo = {}, this.restoreSince = e.historyTimestamp, this.restoreSince === void 0 && (this.restoreSince = ot()), this.sessionId = void 0, this.sendPongs = e.pongs;
|
|
2338
|
+
}
|
|
2339
|
+
reset(e) {
|
|
2340
|
+
for (let t in this.pendingPresence)
|
|
2341
|
+
this.pendingPresence[t].reject(e);
|
|
2342
|
+
return this.pendingPresence = {}, super.reset();
|
|
2343
|
+
}
|
|
2344
|
+
receive(e) {
|
|
2345
|
+
if (typeof e != "object") {
|
|
2346
|
+
this.logger.error("unsupported message format", { message: e });
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
let { type: t, identifier: n, message: r } = e;
|
|
2350
|
+
if (t === "disconnect" || t === "reject_subscription")
|
|
2351
|
+
return super.receive(e);
|
|
2352
|
+
if (t === "confirm_subscription")
|
|
2353
|
+
return this.subscriptionStreams[n] || (this.subscriptionStreams[n] = /* @__PURE__ */ new Set()), super.receive(e);
|
|
2354
|
+
if (t === "ping")
|
|
2355
|
+
return this.restoreSince && (this.restoreSince = ot()), this.sendPongs && this.sendPong(), this.cable.keepalive(e.message);
|
|
2356
|
+
if (this.cable.keepalive(), t === "confirm_history") {
|
|
2357
|
+
this.logger.debug("history result received", e), this.cable.notify("history_received", n);
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
if (t === "reject_history") {
|
|
2361
|
+
this.logger.warn("failed to retrieve history", e), this.cable.notify("history_not_found", n);
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
if (t === "welcome") {
|
|
2365
|
+
if (this.sessionId = e.sid, this.sessionId && this.cable.setSessionId(this.sessionId), e.restored) {
|
|
2366
|
+
let i = e.restored_ids || Object.keys(this.subscriptionStreams);
|
|
2367
|
+
for (let o of i)
|
|
2368
|
+
this.cable.send({
|
|
2369
|
+
identifier: o,
|
|
2370
|
+
command: "history",
|
|
2371
|
+
history: this.historyRequestFor(o)
|
|
2372
|
+
}), this.presenceInfo[o] && this.cable.send({
|
|
2373
|
+
identifier: o,
|
|
2374
|
+
command: "join",
|
|
2375
|
+
presence: this.presenceInfo[o]
|
|
2376
|
+
});
|
|
2377
|
+
return this.cable.restored(i);
|
|
2378
|
+
}
|
|
2379
|
+
return this.cable.connected(this.sessionId);
|
|
2380
|
+
}
|
|
2381
|
+
if (t === "presence") {
|
|
2382
|
+
let i = r.type;
|
|
2383
|
+
if (i === "info") {
|
|
2384
|
+
let o = this.pendingPresence[n];
|
|
2385
|
+
o && (delete this.pendingPresence[n], o.resolve(r));
|
|
2386
|
+
} else if (i === "error") {
|
|
2387
|
+
let o = this.pendingPresence[n];
|
|
2388
|
+
o && (delete this.pendingPresence[n], o.reject(new Error("failed to retrieve presence")));
|
|
2389
|
+
}
|
|
2390
|
+
return {
|
|
2391
|
+
type: t,
|
|
2392
|
+
identifier: n,
|
|
2393
|
+
message: r
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
if (r) {
|
|
2397
|
+
let i = this.trackStreamPosition(
|
|
2398
|
+
n,
|
|
2399
|
+
e.stream_id,
|
|
2400
|
+
e.epoch,
|
|
2401
|
+
e.offset
|
|
2402
|
+
);
|
|
2403
|
+
return { identifier: n, message: r, meta: i };
|
|
2404
|
+
}
|
|
2405
|
+
this.logger.warn(`unknown message type: ${t}`, { message: e });
|
|
2406
|
+
}
|
|
2407
|
+
perform(e, t, n) {
|
|
2408
|
+
switch (t) {
|
|
2409
|
+
case "$presence:join":
|
|
2410
|
+
return this.join(e, n);
|
|
2411
|
+
case "$presence:leave":
|
|
2412
|
+
return this.leave(e, n);
|
|
2413
|
+
case "$presence:info":
|
|
2414
|
+
return this.presence(e, n);
|
|
2415
|
+
}
|
|
2416
|
+
return super.perform(e, t, n);
|
|
2417
|
+
}
|
|
2418
|
+
unsubscribe(e) {
|
|
2419
|
+
return delete this.presenceInfo[e], super.unsubscribe(e);
|
|
2420
|
+
}
|
|
2421
|
+
buildSubscribeRequest(e) {
|
|
2422
|
+
let t = super.buildSubscribeRequest(e), n = this.historyRequestFor(e);
|
|
2423
|
+
n && (t.history = n, this.pendingHistory[e] = !0);
|
|
2424
|
+
let r = this.presenceInfo[e];
|
|
2425
|
+
return r && (t.presence = r), t;
|
|
2426
|
+
}
|
|
2427
|
+
// TODO: Which error can be non-recoverable?
|
|
2428
|
+
recoverableClosure() {
|
|
2429
|
+
return !!this.sessionId;
|
|
2430
|
+
}
|
|
2431
|
+
historyRequestFor(e) {
|
|
2432
|
+
let t = {}, n = !1;
|
|
2433
|
+
if (this.subscriptionStreams[e])
|
|
2434
|
+
for (let r of this.subscriptionStreams[e]) {
|
|
2435
|
+
let i = this.streamsPositions[r];
|
|
2436
|
+
i && (n = !0, t[r] = i);
|
|
2437
|
+
}
|
|
2438
|
+
if (!(!n && !this.restoreSince))
|
|
2439
|
+
return { since: this.restoreSince, streams: t };
|
|
2440
|
+
}
|
|
2441
|
+
trackStreamPosition(e, t, n, r) {
|
|
2442
|
+
if (!(!t || !n))
|
|
2443
|
+
return this.subscriptionStreams[e] || (this.subscriptionStreams[e] = /* @__PURE__ */ new Set()), this.subscriptionStreams[e].add(t), this.streamsPositions[t] = { epoch: n, offset: r }, { stream: t, epoch: n, offset: r };
|
|
2444
|
+
}
|
|
2445
|
+
// Send pongs asynchrounously—no need to block the main thread
|
|
2446
|
+
async sendPong() {
|
|
2447
|
+
await new Promise((e) => setTimeout(e, 0)), this.cable.state === "connected" && this.cable.send({ command: "pong" });
|
|
2448
|
+
}
|
|
2449
|
+
async join(e, t) {
|
|
2450
|
+
return this.presenceInfo[e] = t, this.cable.send({
|
|
2451
|
+
command: "join",
|
|
2452
|
+
identifier: e,
|
|
2453
|
+
presence: t
|
|
2454
|
+
}), Promise.resolve();
|
|
2455
|
+
}
|
|
2456
|
+
async leave(e, t) {
|
|
2457
|
+
return delete this.presenceInfo[e], this.cable.send({
|
|
2458
|
+
command: "leave",
|
|
2459
|
+
identifier: e,
|
|
2460
|
+
presence: t
|
|
2461
|
+
}), Promise.resolve();
|
|
2462
|
+
}
|
|
2463
|
+
presence(e, t) {
|
|
2464
|
+
return this.pendingPresence[e] ? (this.logger.warn("presence is already pending, skipping", e), Promise.reject(Error("presence request is already pending"))) : new Promise((n, r) => {
|
|
2465
|
+
this.pendingPresence[e] = {
|
|
2466
|
+
resolve: n,
|
|
2467
|
+
reject: r
|
|
2468
|
+
}, this.cable.send({
|
|
2469
|
+
command: "presence",
|
|
2470
|
+
identifier: e,
|
|
2471
|
+
data: t
|
|
2472
|
+
});
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
class js extends ne {
|
|
2477
|
+
constructor() {
|
|
2478
|
+
super("No connection", "closed"), this.name = "NoConnectionError";
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
class qe extends Dt {
|
|
2482
|
+
constructor(e, t) {
|
|
2483
|
+
super(t), this.channelId = e;
|
|
2484
|
+
}
|
|
2485
|
+
set channelId(e) {
|
|
2486
|
+
this._channelId = e;
|
|
2487
|
+
}
|
|
2488
|
+
get channelId() {
|
|
2489
|
+
return this._channelId;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
v(qe, "identifier", "__ghost__");
|
|
2493
|
+
const Fs = "$pubsub";
|
|
2494
|
+
class Le extends Dt {
|
|
2495
|
+
async perform(e, t) {
|
|
2496
|
+
if (e.startsWith("$"))
|
|
2497
|
+
return super.perform(e, t);
|
|
2498
|
+
throw Error("not implemented");
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
v(Le, "identifier", Fs);
|
|
2502
|
+
const M = Symbol("state");
|
|
2503
|
+
let Us = class {
|
|
2504
|
+
constructor({
|
|
2505
|
+
transport: e,
|
|
2506
|
+
protocol: t,
|
|
2507
|
+
encoder: n,
|
|
2508
|
+
logger: r,
|
|
2509
|
+
lazy: i,
|
|
2510
|
+
hubOptions: o,
|
|
2511
|
+
performFailures: c,
|
|
2512
|
+
transportConfigurator: h
|
|
2513
|
+
}) {
|
|
2514
|
+
this.emitter = we(), this.transport = e, this.encoder = n, this.logger = r || new se(), this.protocol = t, this.performFailures = c || "throw", this.protocol.attached(this), this.hub = new Is(o || {}), this[M] = "idle", this.handleClose = this.handleClose.bind(this), this.handleIncoming = this.handleIncoming.bind(this), this.transportConfigurator = h, this.transport.on("close", this.handleClose), this.transport.on("data", this.handleIncoming), this.initialConnect = !0, this.recovering = !1, i === !1 && this.connect().catch(() => {
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
get state() {
|
|
2518
|
+
return this[M];
|
|
2519
|
+
}
|
|
2520
|
+
async connect() {
|
|
2521
|
+
if (this.state === "connected") return Promise.resolve();
|
|
2522
|
+
if (this.state === "connecting")
|
|
2523
|
+
return this.pendingConnect();
|
|
2524
|
+
let e = this.state === "idle";
|
|
2525
|
+
this[M] = "connecting";
|
|
2526
|
+
let t = this.pendingConnect();
|
|
2527
|
+
this.logger.debug("connecting");
|
|
2528
|
+
try {
|
|
2529
|
+
this.transportConfigurator && await this.transportConfigurator(this.transport, {
|
|
2530
|
+
initial: e
|
|
2531
|
+
}), await this.transport.open();
|
|
2532
|
+
} catch (n) {
|
|
2533
|
+
this.handleClose(n);
|
|
2534
|
+
}
|
|
2535
|
+
return t;
|
|
2536
|
+
}
|
|
2537
|
+
setSessionId(e) {
|
|
2538
|
+
this.sessionId = e, this.transport.setParam("sid", e);
|
|
2539
|
+
}
|
|
2540
|
+
connected() {
|
|
2541
|
+
if (this.state === "connected") return;
|
|
2542
|
+
this.logger.info("connected"), this[M] = "connected", this.recovering && this.hub.subscriptions.all().forEach(
|
|
2543
|
+
(t) => t.notify(
|
|
2544
|
+
"disconnected",
|
|
2545
|
+
new $("recovery_failed")
|
|
2546
|
+
)
|
|
2547
|
+
), this.hub.subscriptions.all().forEach((t) => this._resubscribe(t));
|
|
2548
|
+
let e = !1;
|
|
2549
|
+
this.recovering = !1, this.initialConnect ? (this.initialConnect = !1, this.emit("connect", { reconnect: !1, restored: e })) : this.emit("connect", { reconnect: !0, restored: e });
|
|
2550
|
+
}
|
|
2551
|
+
restored(e) {
|
|
2552
|
+
this.logger.info("connection recovered", { remoteIds: e }), this[M] = "connected", this.hub.subscriptions.all().forEach((r) => {
|
|
2553
|
+
e && r.remoteId && e.includes(r.remoteId) ? r.notify("restored") : (r.notify(
|
|
2554
|
+
"disconnected",
|
|
2555
|
+
new $("recovery_failed")
|
|
2556
|
+
), this._resubscribe(r));
|
|
2557
|
+
});
|
|
2558
|
+
let t = !this.initialConnect, n = !0;
|
|
2559
|
+
this.recovering = !1, this.initialConnect = !1, this.emit("connect", { reconnect: t, restored: n });
|
|
2560
|
+
}
|
|
2561
|
+
notify(e, t, n) {
|
|
2562
|
+
t && typeof t != "string" && (n = t, t = void 0), t ? this.hub.notify(t, "info", { type: e, data: n }) : this.emit("info", { type: e, data: n });
|
|
2563
|
+
}
|
|
2564
|
+
handleClose(e) {
|
|
2565
|
+
this.logger.debug("transport closed", { error: e }), this.disconnected(new $(e, "transport_closed"));
|
|
2566
|
+
}
|
|
2567
|
+
disconnected(e) {
|
|
2568
|
+
(this.state === "connected" || this.state === "connecting") && (this.logger.info("disconnected", { reason: e }), this[M] = "disconnected", this.recovering = this.protocol.recoverableClosure(e), this.recovering ? this.hub.subscriptions.all().forEach((t) => t.notify("connecting")) : this.hub.subscriptions.all().forEach((t) => {
|
|
2569
|
+
t.notify("disconnected", e);
|
|
2570
|
+
}), this.protocol.reset(e), this.hub.close(), this.transport.close(), this.emit("disconnect", e));
|
|
2571
|
+
}
|
|
2572
|
+
closed(e) {
|
|
2573
|
+
if (this.state === "closed" || this.state === "idle") return;
|
|
2574
|
+
let t;
|
|
2575
|
+
e && (t = e instanceof $ ? e : new $(e, void 0)), this.logger.info("closed", { reason: e || "user" }), this[M] = "closed";
|
|
2576
|
+
let n = t || new $("cable_closed");
|
|
2577
|
+
this.hub.subscriptions.all().forEach((r) => r.notify("disconnected", n)), this.hub.close(), this.protocol.reset(), this.transport.close(), this.initialConnect = !0, this.emit("close", t);
|
|
2578
|
+
}
|
|
2579
|
+
disconnect() {
|
|
2580
|
+
this.closed();
|
|
2581
|
+
}
|
|
2582
|
+
handleIncoming(e) {
|
|
2583
|
+
if (this.state === "closed" || this.state === "idle")
|
|
2584
|
+
return;
|
|
2585
|
+
let t = this.encoder.decode(e);
|
|
2586
|
+
if (t === void 0) {
|
|
2587
|
+
this.logger.error("failed to decode message", { message: e });
|
|
2588
|
+
return;
|
|
2589
|
+
}
|
|
2590
|
+
this.logger.debug("incoming data", t);
|
|
2591
|
+
let n = this.protocol.receive(t);
|
|
2592
|
+
if (n) {
|
|
2593
|
+
this.logger.debug("processed incoming message", n);
|
|
2594
|
+
let { type: r, identifier: i, message: o, meta: c } = n;
|
|
2595
|
+
r ? this.hub.notify(i, r, o) : this.hub.transmit(i, o, c);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
send(e) {
|
|
2599
|
+
if (this.state === "closed")
|
|
2600
|
+
throw Error("Cable is closed");
|
|
2601
|
+
let t = this.encoder.encode(e);
|
|
2602
|
+
if (t === void 0) {
|
|
2603
|
+
this.logger.error("failed to encode message", { message: e });
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
this.logger.debug("outgoing message", e), this.transport.send(t);
|
|
2607
|
+
}
|
|
2608
|
+
keepalive(e) {
|
|
2609
|
+
this.emit("keepalive", e);
|
|
2610
|
+
}
|
|
2611
|
+
streamFrom(e) {
|
|
2612
|
+
let t = new Le({ stream_name: e });
|
|
2613
|
+
return this.subscribe(t);
|
|
2614
|
+
}
|
|
2615
|
+
streamFromSigned(e) {
|
|
2616
|
+
let t = new Le({ signed_stream_name: e });
|
|
2617
|
+
return this.subscribe(t);
|
|
2618
|
+
}
|
|
2619
|
+
subscribeTo(e, t) {
|
|
2620
|
+
let n, r;
|
|
2621
|
+
return typeof e == "string" && (r = e, e = qe), n = r ? new e(r, t) : new e(t), this.subscribe(n);
|
|
2622
|
+
}
|
|
2623
|
+
subscribe(e) {
|
|
2624
|
+
if (!e.attached(this)) return e;
|
|
2625
|
+
let t = e.identifier;
|
|
2626
|
+
e.connecting();
|
|
2627
|
+
let n = this.hub.subscriptions.get(t) || this.hub.subscriptions.create(t, {
|
|
2628
|
+
subscribe: (r) => this._subscribe(r, e.channelId, e.params),
|
|
2629
|
+
unsubscribe: (r) => this._unsubscribe(r)
|
|
2630
|
+
});
|
|
2631
|
+
return n.add(e), n.intent === "subscribed" && n.state === "connected" && e.connected(), n.ensureSubscribed(), e;
|
|
2632
|
+
}
|
|
2633
|
+
async _resubscribe(e) {
|
|
2634
|
+
e.intent !== "subscribed" || !e.channels[0] || (e.notify("connecting"), e.ensureResubscribed());
|
|
2635
|
+
}
|
|
2636
|
+
async _subscribe(e, t, n) {
|
|
2637
|
+
let r = e.id;
|
|
2638
|
+
if (this.state === "idle" && this.connect().catch(() => {
|
|
2639
|
+
}), this.state !== "connected") {
|
|
2640
|
+
this.logger.debug("cancel subscribe, no connection", { identifier: r });
|
|
2641
|
+
return;
|
|
2642
|
+
}
|
|
2643
|
+
this.logger.debug("acquiring subscribe lock", { identifier: r });
|
|
2644
|
+
let i = await e.acquire("subscribed");
|
|
2645
|
+
if (i.canceled) {
|
|
2646
|
+
this.logger.debug("subscribe lock has been canceled", { identifier: r }), i.release();
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
if (this.logger.debug("subscribe lock has been acquired", { identifier: r }), e.intent !== "subscribed") {
|
|
2650
|
+
this.logger.debug("cancel subscribe request, already unsubscribed"), i.release();
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
if (this.state !== "connected") {
|
|
2654
|
+
this.logger.debug("cancel subscribe, no connection", { identifier: r }), i.release();
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
if (e.state === "connected") {
|
|
2658
|
+
this.logger.debug("already connected, skip subscribe command", {
|
|
2659
|
+
identifier: r
|
|
2660
|
+
}), e.notify("connected"), i.release();
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
let o = {
|
|
2664
|
+
identifier: t,
|
|
2665
|
+
params: n
|
|
2666
|
+
};
|
|
2667
|
+
this.logger.debug("subscribing", o);
|
|
2668
|
+
try {
|
|
2669
|
+
let c = await this.protocol.subscribe(t, n);
|
|
2670
|
+
this.hub.subscribe(r, c), this.logger.debug("subscribed", { ...o, remoteId: c }), e.notify("connected");
|
|
2671
|
+
} catch (c) {
|
|
2672
|
+
if (c) {
|
|
2673
|
+
if (c instanceof De && this.logger.warn("rejected", o), c instanceof $) {
|
|
2674
|
+
this.logger.debug(
|
|
2675
|
+
"disconnected during subscription; will retry on connect",
|
|
2676
|
+
o
|
|
2677
|
+
), i.release();
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
this.logger.error("failed to subscribe", {
|
|
2681
|
+
error: c,
|
|
2682
|
+
...o
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
e.close(c), this.hub.unsubscribe(r);
|
|
2686
|
+
}
|
|
2687
|
+
i.release();
|
|
2688
|
+
}
|
|
2689
|
+
unsubscribe(e) {
|
|
2690
|
+
let t = e.identifier, n = this.hub.subscriptions.get(t);
|
|
2691
|
+
if (!n)
|
|
2692
|
+
throw Error(`Subscription not found: ${t}`);
|
|
2693
|
+
n.remove(e), e.closed(), n.maybeUnsubscribe();
|
|
2694
|
+
}
|
|
2695
|
+
async _unsubscribe(e) {
|
|
2696
|
+
let t = e.id;
|
|
2697
|
+
this.logger.debug("acquiring unsubscribe lock", { identifier: t });
|
|
2698
|
+
let n = await e.acquire("unsubscribed");
|
|
2699
|
+
if (n.canceled) {
|
|
2700
|
+
this.logger.debug("unsubscribe lock has been canceled", { identifier: t }), n.release();
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
if (this.logger.debug("unsubscribe lock has been acquired", { identifier: t }), e.intent !== "unsubscribed") {
|
|
2704
|
+
this.logger.debug("cancel unsubscribe, no longer needed", {
|
|
2705
|
+
identifier: t,
|
|
2706
|
+
intent: e.intent
|
|
2707
|
+
}), n.release();
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
if (e.state === "disconnected" || e.state === "closed") {
|
|
2711
|
+
this.logger.debug(
|
|
2712
|
+
`already ${e.state} connected, skip unsubscribe command`,
|
|
2713
|
+
{ identifier: t }
|
|
2714
|
+
), n.release();
|
|
2715
|
+
return;
|
|
2716
|
+
}
|
|
2717
|
+
let r = e.remoteId;
|
|
2718
|
+
if (this.logger.debug("unsubscribing...", { remoteId: r }), this.state !== "connected") {
|
|
2719
|
+
this.logger.debug("unsubscribe skipped (cable is not connected)", {
|
|
2720
|
+
id: t
|
|
2721
|
+
}), e.close(), this.hub.unsubscribe(t), n.release();
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
try {
|
|
2725
|
+
await this.protocol.unsubscribe(r), this.logger.debug("unsubscribed remotely", { id: t });
|
|
2726
|
+
} catch (i) {
|
|
2727
|
+
i && (i instanceof $ ? this.logger.debug(
|
|
2728
|
+
"cable disconnected during the unsubscribe command execution",
|
|
2729
|
+
{ id: t, error: i }
|
|
2730
|
+
) : this.logger.error("unsubscribe failed", {
|
|
2731
|
+
id: t,
|
|
2732
|
+
error: i
|
|
2733
|
+
}));
|
|
2734
|
+
}
|
|
2735
|
+
e.intent === "unsubscribed" ? (e.close(), this.hub.unsubscribe(t)) : e.state = "closed", n.release();
|
|
2736
|
+
}
|
|
2737
|
+
async perform(e, t, n) {
|
|
2738
|
+
if (this.performFailures === "throw")
|
|
2739
|
+
return this._perform(e, t, n);
|
|
2740
|
+
try {
|
|
2741
|
+
return await this._perform(e, t, n);
|
|
2742
|
+
} catch (r) {
|
|
2743
|
+
this.performFailures === "warn" && this.logger.warn("perform failed", { error: r });
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
async _perform(e, t, n) {
|
|
2748
|
+
if (this.state === "connecting" && await this.pendingConnect(), this.state === "closed" || this.state === "disconnected")
|
|
2749
|
+
throw new js();
|
|
2750
|
+
let r = this.hub.subscriptions.get(e);
|
|
2751
|
+
if (!r)
|
|
2752
|
+
throw Error(`Subscription not found: ${e}`);
|
|
2753
|
+
if (await r.pending("subscribed"), r.intent !== "subscribed")
|
|
2754
|
+
throw Error(`Subscription is closed: ${e}`);
|
|
2755
|
+
let i = r.remoteId, o = {
|
|
2756
|
+
id: i,
|
|
2757
|
+
action: t,
|
|
2758
|
+
payload: n
|
|
2759
|
+
};
|
|
2760
|
+
this.logger.debug("perform", o);
|
|
2761
|
+
try {
|
|
2762
|
+
let c = await this.protocol.perform(i, t, n);
|
|
2763
|
+
return c && this.logger.debug("perform result", {
|
|
2764
|
+
message: c,
|
|
2765
|
+
request: o
|
|
2766
|
+
}), c;
|
|
2767
|
+
} catch (c) {
|
|
2768
|
+
throw this.logger.error("perform failed", {
|
|
2769
|
+
error: c,
|
|
2770
|
+
request: o
|
|
2771
|
+
}), c;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
on(e, t) {
|
|
2775
|
+
return this.emitter.on(e, t);
|
|
2776
|
+
}
|
|
2777
|
+
once(e, t) {
|
|
2778
|
+
let n = this.emitter.on(e, (...r) => {
|
|
2779
|
+
n(), t(...r);
|
|
2780
|
+
});
|
|
2781
|
+
return n;
|
|
2782
|
+
}
|
|
2783
|
+
emit(e, ...t) {
|
|
2784
|
+
return this.emitter.emit(e, ...t);
|
|
2785
|
+
}
|
|
2786
|
+
pendingConnect() {
|
|
2787
|
+
return this._pendingConnect ? this._pendingConnect : (this._pendingConnect = new Promise((e, t) => {
|
|
2788
|
+
let n = [() => delete this._pendingConnect];
|
|
2789
|
+
n.push(
|
|
2790
|
+
this.on("connect", () => {
|
|
2791
|
+
n.forEach((r) => r()), e();
|
|
2792
|
+
})
|
|
2793
|
+
), n.push(
|
|
2794
|
+
this.on("close", (r) => {
|
|
2795
|
+
n.forEach((i) => i()), t(r);
|
|
2796
|
+
})
|
|
2797
|
+
), n.push(
|
|
2798
|
+
this.on("disconnect", (r) => {
|
|
2799
|
+
n.forEach((i) => i()), t(r);
|
|
2800
|
+
})
|
|
2801
|
+
);
|
|
2802
|
+
}), this._pendingConnect);
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
const Ds = {
|
|
2806
|
+
maxMissingPings: 2,
|
|
2807
|
+
maxReconnectAttempts: 1 / 0
|
|
2808
|
+
}, W = () => Date.now(), Mt = (s, e) => {
|
|
2809
|
+
e = e || {};
|
|
2810
|
+
let { backoffRate: t, jitterRatio: n, maxInterval: r } = e;
|
|
2811
|
+
return t = t || 2, n === void 0 && (n = 0.5), (i) => {
|
|
2812
|
+
let o = s * t ** i, c = o * t, h = o + (c - o) * Math.random(), u = 2 * (Math.random() - 0.5) * n;
|
|
2813
|
+
return h = h * (1 + u), r && r < h && (h = r), h;
|
|
2814
|
+
};
|
|
2815
|
+
};
|
|
2816
|
+
let Ht = class {
|
|
2817
|
+
constructor({ pingInterval: e, ...t }) {
|
|
2818
|
+
if (this.pingInterval = e, !this.pingInterval)
|
|
2819
|
+
throw Error(`Incorrect pingInterval is provided: ${e}`);
|
|
2820
|
+
if (t = Object.assign({}, Ds, t), this.strategy = t.reconnectStrategy, !this.strategy)
|
|
2821
|
+
throw Error("Reconnect strategy must be provided");
|
|
2822
|
+
this.maxMissingPings = t.maxMissingPings, this.maxReconnectAttempts = t.maxReconnectAttempts, this.logger = t.logger || new se(), this.state = "pending_connect", this.attempts = 0, this.disconnectedAt = W();
|
|
2823
|
+
}
|
|
2824
|
+
watch(e) {
|
|
2825
|
+
this.target = e, this.initListeners();
|
|
2826
|
+
}
|
|
2827
|
+
reconnectNow() {
|
|
2828
|
+
return this.state === "connected" || this.state === "pending_connect" || this.state === "closed" ? !1 : (this.cancelReconnect(), this.state = "pending_connect", this.target.connect().catch((e) => {
|
|
2829
|
+
this.logger.info("Failed at reconnecting: " + e);
|
|
2830
|
+
}), !0);
|
|
2831
|
+
}
|
|
2832
|
+
initListeners() {
|
|
2833
|
+
this.unbind = [], this.unbind.push(
|
|
2834
|
+
this.target.on("connect", () => {
|
|
2835
|
+
this.attempts = 0, this.pingedAt = W(), this.state = "connected", this.cancelReconnect(), this.startPolling();
|
|
2836
|
+
})
|
|
2837
|
+
), this.unbind.push(
|
|
2838
|
+
this.target.on("disconnect", () => {
|
|
2839
|
+
this.disconnectedAt = W(), this.state = "disconnected", this.stopPolling(), this.scheduleReconnect();
|
|
2840
|
+
})
|
|
2841
|
+
), this.unbind.push(
|
|
2842
|
+
this.target.on("close", () => {
|
|
2843
|
+
this.disconnectedAt = W(), this.state = "closed", this.cancelReconnect(), this.stopPolling();
|
|
2844
|
+
})
|
|
2845
|
+
), this.unbind.push(
|
|
2846
|
+
this.target.on("keepalive", () => {
|
|
2847
|
+
this.pingedAt = W();
|
|
2848
|
+
})
|
|
2849
|
+
), this.unbind.push(() => {
|
|
2850
|
+
this.cancelReconnect(), this.stopPolling();
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
dispose() {
|
|
2854
|
+
delete this.target, this.unbind && this.unbind.forEach((e) => e()), delete this.unbind;
|
|
2855
|
+
}
|
|
2856
|
+
startPolling() {
|
|
2857
|
+
this.pollId && clearTimeout(this.pollId);
|
|
2858
|
+
let e = this.pingInterval + (Math.random() - 0.5) * this.pingInterval * 0.5;
|
|
2859
|
+
this.pollId = setTimeout(() => {
|
|
2860
|
+
this.checkStale(), this.state === "connected" && this.startPolling();
|
|
2861
|
+
}, e);
|
|
2862
|
+
}
|
|
2863
|
+
stopPolling() {
|
|
2864
|
+
this.pollId && clearTimeout(this.pollId);
|
|
2865
|
+
}
|
|
2866
|
+
checkStale() {
|
|
2867
|
+
let e = W() - this.pingedAt;
|
|
2868
|
+
e > this.maxMissingPings * this.pingInterval && (this.logger.warn(`Stale connection: ${e}ms without pings`), this.state = "pending_disconnect", this.target.disconnected(new Cs()));
|
|
2869
|
+
}
|
|
2870
|
+
scheduleReconnect() {
|
|
2871
|
+
if (this.attempts >= this.maxReconnectAttempts) {
|
|
2872
|
+
this.target.close();
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
let e = this.strategy(this.attempts);
|
|
2876
|
+
this.attempts++, this.logger.info(`Reconnecting in ${e}ms (${this.attempts} attempt)`), this.state = "pending_reconnect", this.reconnnectId = setTimeout(() => this.reconnectNow(), e);
|
|
2877
|
+
}
|
|
2878
|
+
cancelReconnect() {
|
|
2879
|
+
this.reconnnectId && (clearTimeout(this.reconnnectId), delete this.reconnnectId);
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
class qs {
|
|
2883
|
+
constructor(e, t = {}) {
|
|
2884
|
+
this.transports = e, this.transport = null, this.emitter = we(), this.unbind = [], this.logger = t.logger || new se();
|
|
2885
|
+
}
|
|
2886
|
+
displayName() {
|
|
2887
|
+
return "fallbacked transport";
|
|
2888
|
+
}
|
|
2889
|
+
async open() {
|
|
2890
|
+
for (let e = 0; e < this.transports.length; e++) {
|
|
2891
|
+
let t = this.transports[e];
|
|
2892
|
+
try {
|
|
2893
|
+
this.transport = t, this.resetListeners(), this.logger.debug(`Trying to connect via ${t.displayName()}`), await t.open(), this.logger.debug(`Connected via ${t.displayName()}`);
|
|
2894
|
+
return;
|
|
2895
|
+
} catch (n) {
|
|
2896
|
+
this.logger.debug(
|
|
2897
|
+
`Failed to connect via ${t.displayName()}: ${n.message}`
|
|
2898
|
+
);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
throw this.transport = null, this.resetListeners(), new Error("Couldn't connect via any available transport");
|
|
2902
|
+
}
|
|
2903
|
+
send(e) {
|
|
2904
|
+
if (!this.transport)
|
|
2905
|
+
throw new Error("No transport is open");
|
|
2906
|
+
this.transport.send(e);
|
|
2907
|
+
}
|
|
2908
|
+
async close() {
|
|
2909
|
+
if (!this.transport)
|
|
2910
|
+
throw new Error("No transport is open");
|
|
2911
|
+
await this.transport.close(), this.transport = null;
|
|
2912
|
+
}
|
|
2913
|
+
setURL() {
|
|
2914
|
+
throw new Error("Not implemented. Set URL for each transport separately");
|
|
2915
|
+
}
|
|
2916
|
+
setParam(e, t) {
|
|
2917
|
+
this.transports.forEach((n) => {
|
|
2918
|
+
n.setParam(e, t);
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
setToken(e, t) {
|
|
2922
|
+
this.transports.forEach((n) => {
|
|
2923
|
+
n.setToken(e, t);
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
on(e, t) {
|
|
2927
|
+
return this.emitter.on(e, t);
|
|
2928
|
+
}
|
|
2929
|
+
once(e, t) {
|
|
2930
|
+
let n = this.emitter.on(e, (...r) => {
|
|
2931
|
+
n(), t(...r);
|
|
2932
|
+
});
|
|
2933
|
+
return n;
|
|
2934
|
+
}
|
|
2935
|
+
get url() {
|
|
2936
|
+
return this.transport ? this.transport.url : "";
|
|
2937
|
+
}
|
|
2938
|
+
resetListeners() {
|
|
2939
|
+
this.unbind.forEach((e) => e()), this.unbind.length = 0, this.transport && this.unbind.push(
|
|
2940
|
+
this.transport.on("open", () => {
|
|
2941
|
+
this.emitter.emit("open");
|
|
2942
|
+
}),
|
|
2943
|
+
this.transport.on("data", (e) => {
|
|
2944
|
+
this.emitter.emit("data", e);
|
|
2945
|
+
}),
|
|
2946
|
+
this.transport.on("close", (e) => {
|
|
2947
|
+
this.emitter.emit("close", e);
|
|
2948
|
+
}),
|
|
2949
|
+
this.transport.on("error", (e) => {
|
|
2950
|
+
this.emitter.emit("error", e);
|
|
2951
|
+
})
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
class Bs {
|
|
2956
|
+
constructor(e, t = {}) {
|
|
2957
|
+
this.url = e;
|
|
2958
|
+
let n = t.websocketImplementation;
|
|
2959
|
+
if (n)
|
|
2960
|
+
this.Impl = n;
|
|
2961
|
+
else if (typeof WebSocket < "u")
|
|
2962
|
+
this.Impl = WebSocket;
|
|
2963
|
+
else
|
|
2964
|
+
throw new Error("No WebSocket support");
|
|
2965
|
+
this.connected = !1, this.emitter = we();
|
|
2966
|
+
let { format: r, subprotocol: i, authStrategy: o } = t;
|
|
2967
|
+
this.format = r || "text", this.connectionOptions = t.websocketOptions, this.authStrategy = o || "param", this.authProtocol = "", this.subprotocol = i;
|
|
2968
|
+
}
|
|
2969
|
+
displayName() {
|
|
2970
|
+
return "WebSocket(" + this.url + ")";
|
|
2971
|
+
}
|
|
2972
|
+
open() {
|
|
2973
|
+
let e = this.subprotocol;
|
|
2974
|
+
return this.authStrategy === "sub-protocol" && (e = [this.subprotocol, this.authProtocol]), this.connectionOptions ? this.ws = new this.Impl(this.url, e, this.connectionOptions) : this.ws = new this.Impl(this.url, e), this.ws.binaryType = "arraybuffer", this.initListeners(), new Promise((t, n) => {
|
|
2975
|
+
let r = [];
|
|
2976
|
+
r.push(
|
|
2977
|
+
this.once("open", () => {
|
|
2978
|
+
r.forEach((i) => i()), t();
|
|
2979
|
+
})
|
|
2980
|
+
), r.push(
|
|
2981
|
+
this.once("close", () => {
|
|
2982
|
+
r.forEach((i) => i()), n(Error("WS connection closed"));
|
|
2983
|
+
})
|
|
2984
|
+
);
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
setURL(e) {
|
|
2988
|
+
this.url = e;
|
|
2989
|
+
}
|
|
2990
|
+
setParam(e, t) {
|
|
2991
|
+
let n = new URL(this.url);
|
|
2992
|
+
n.searchParams.set(e, t);
|
|
2993
|
+
let r = `${n.protocol}//${n.host}${n.pathname}?${n.searchParams}`;
|
|
2994
|
+
this.setURL(r);
|
|
2995
|
+
}
|
|
2996
|
+
setToken(e, t = "jid") {
|
|
2997
|
+
if (this.authStrategy === "param")
|
|
2998
|
+
this.setParam(t, e);
|
|
2999
|
+
else if (this.authStrategy === "header") {
|
|
3000
|
+
this.connectionOptions = this.connectionOptions || {}, this.connectionOptions.headers = this.connectionOptions.headers || {};
|
|
3001
|
+
let n = `x-${t}`.toLowerCase();
|
|
3002
|
+
n = Object.keys(this.connectionOptions.headers).find(
|
|
3003
|
+
(i) => i.toLowerCase() === n
|
|
3004
|
+
) || n, this.connectionOptions.headers[n] = e;
|
|
3005
|
+
} else if (this.authStrategy === "sub-protocol")
|
|
3006
|
+
this.authProtocol = `anycable-token.${e}`;
|
|
3007
|
+
else
|
|
3008
|
+
throw new Error("Unknown auth strategy: " + this.authStrategy);
|
|
3009
|
+
}
|
|
3010
|
+
send(e) {
|
|
3011
|
+
if (!this.ws || !this.connected)
|
|
3012
|
+
throw Error("WebSocket is not connected");
|
|
3013
|
+
this.ws.send(e);
|
|
3014
|
+
}
|
|
3015
|
+
close() {
|
|
3016
|
+
this.ws ? this.onclose() : this.connected = !1;
|
|
3017
|
+
}
|
|
3018
|
+
on(e, t) {
|
|
3019
|
+
return this.emitter.on(e, t);
|
|
3020
|
+
}
|
|
3021
|
+
once(e, t) {
|
|
3022
|
+
let n = this.emitter.on(e, (...r) => {
|
|
3023
|
+
n(), t(...r);
|
|
3024
|
+
});
|
|
3025
|
+
return n;
|
|
3026
|
+
}
|
|
3027
|
+
initListeners() {
|
|
3028
|
+
this.ws.onerror = (e) => {
|
|
3029
|
+
this.connected && this.emitter.emit("error", e.error || new Error("WS Error"));
|
|
3030
|
+
}, this.ws.onclose = () => {
|
|
3031
|
+
this.onclose();
|
|
3032
|
+
}, this.ws.onmessage = (e) => {
|
|
3033
|
+
let t = e.data;
|
|
3034
|
+
this.format === "binary" && (t = new Uint8Array(t)), this.emitter.emit("data", t);
|
|
3035
|
+
}, this.ws.onopen = () => {
|
|
3036
|
+
this.connected = !0, this.emitter.emit("open");
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
onclose() {
|
|
3040
|
+
this.ws.onclose = void 0, this.ws.onmessage = void 0, this.ws.onopen = void 0, this.ws.close(), delete this.ws, this.connected = !1, this.emitter.emit("close");
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
const zt = {
|
|
3044
|
+
protocol: "actioncable-v1-json",
|
|
3045
|
+
pingInterval: 3e3,
|
|
3046
|
+
maxReconnectAttempts: 1 / 0,
|
|
3047
|
+
maxMissingPings: 2,
|
|
3048
|
+
logLevel: "warn",
|
|
3049
|
+
lazy: !0
|
|
3050
|
+
};
|
|
3051
|
+
function Ms(s, e) {
|
|
3052
|
+
if (typeof s == "object" && typeof e > "u" && (e = s, s = void 0), e = e || {}, !s && !e.transport) throw Error("URL or transport must be specified");
|
|
3053
|
+
e = Object.assign({}, zt, e);
|
|
3054
|
+
let {
|
|
3055
|
+
protocol: t,
|
|
3056
|
+
websocketImplementation: n,
|
|
3057
|
+
websocketFormat: r,
|
|
3058
|
+
websocketOptions: i,
|
|
3059
|
+
websocketAuthStrategy: o,
|
|
3060
|
+
fallbacks: c,
|
|
3061
|
+
logLevel: h,
|
|
3062
|
+
logger: u,
|
|
3063
|
+
transport: a,
|
|
3064
|
+
encoder: d,
|
|
3065
|
+
lazy: g,
|
|
3066
|
+
monitor: b,
|
|
3067
|
+
pingInterval: f,
|
|
3068
|
+
reconnectStrategy: m,
|
|
3069
|
+
maxMissingPings: p,
|
|
3070
|
+
maxReconnectAttempts: _,
|
|
3071
|
+
subprotocol: E,
|
|
3072
|
+
tokenRefresher: S,
|
|
3073
|
+
historyTimestamp: k,
|
|
3074
|
+
protocolOptions: x,
|
|
3075
|
+
concurrentSubscribes: P,
|
|
3076
|
+
performFailures: I,
|
|
3077
|
+
transportConfigurator: D,
|
|
3078
|
+
auth: U
|
|
3079
|
+
} = e;
|
|
3080
|
+
if (u = u || new se(h), typeof t == "string") {
|
|
3081
|
+
E = E || t;
|
|
3082
|
+
let J = t.substring(0, t.lastIndexOf("-")), C = t.substring(t.lastIndexOf("-") + 1);
|
|
3083
|
+
if (x = x || {}, J === "actioncable-v1")
|
|
3084
|
+
t = new Bt({ logger: u, ...x });
|
|
3085
|
+
else if (J === "actioncable-v1-ext")
|
|
3086
|
+
t = new $s({
|
|
3087
|
+
logger: u,
|
|
3088
|
+
historyTimestamp: k,
|
|
3089
|
+
...x
|
|
3090
|
+
});
|
|
3091
|
+
else
|
|
3092
|
+
throw Error(`Protocol is not supported yet: ${t}`);
|
|
3093
|
+
if (C === "json")
|
|
3094
|
+
d = d || new Ls(), r = r || "text";
|
|
3095
|
+
else if (C === "msgpack") {
|
|
3096
|
+
if (r = "binary", !d)
|
|
3097
|
+
throw Error(
|
|
3098
|
+
"Msgpack encoder must be specified explicitly. Use `@anycable/msgpack-encoder` package or build your own"
|
|
3099
|
+
);
|
|
3100
|
+
} else if (C === "protobuf") {
|
|
3101
|
+
if (r = r || "binary", !d)
|
|
3102
|
+
throw Error(
|
|
3103
|
+
"Protobuf encoder must be specified explicitly. Use `@anycable/protobuf-encoder` package or build your own"
|
|
3104
|
+
);
|
|
3105
|
+
} else
|
|
3106
|
+
throw Error(`Protocol is not supported yet: ${t}`);
|
|
3107
|
+
}
|
|
3108
|
+
if (!t) throw Error("Protocol must be specified");
|
|
3109
|
+
a = a || new Bs(s, {
|
|
3110
|
+
websocketImplementation: n,
|
|
3111
|
+
websocketOptions: i,
|
|
3112
|
+
subprotocol: E,
|
|
3113
|
+
authStrategy: o,
|
|
3114
|
+
format: r
|
|
3115
|
+
}), c && (a = new qs([a, ...c], { logger: u })), U && U.token && a.setToken(U.token, U.param || "jid"), m = m || Mt(f), b !== !1 && (b = b || new Ht({
|
|
3116
|
+
pingInterval: f,
|
|
3117
|
+
reconnectStrategy: m,
|
|
3118
|
+
maxMissingPings: p,
|
|
3119
|
+
maxReconnectAttempts: _,
|
|
3120
|
+
logger: u
|
|
3121
|
+
}));
|
|
3122
|
+
let _e = { concurrentSubscribes: P }, L = new Us({
|
|
3123
|
+
protocol: t,
|
|
3124
|
+
transport: a,
|
|
3125
|
+
encoder: d,
|
|
3126
|
+
logger: u,
|
|
3127
|
+
lazy: g,
|
|
3128
|
+
hubOptions: _e,
|
|
3129
|
+
performFailures: I,
|
|
3130
|
+
transportConfigurator: D
|
|
3131
|
+
});
|
|
3132
|
+
return b && (b.watch(L), L.monitor = b), S && Hs(L, async () => {
|
|
3133
|
+
try {
|
|
3134
|
+
await S(a);
|
|
3135
|
+
} catch (J) {
|
|
3136
|
+
return u.error("Failed to refresh authentication token: " + J), !1;
|
|
3137
|
+
}
|
|
3138
|
+
return L.connect().catch(() => {
|
|
3139
|
+
}), !0;
|
|
3140
|
+
}), L;
|
|
3141
|
+
}
|
|
3142
|
+
function Hs(s, e) {
|
|
3143
|
+
let t = !1;
|
|
3144
|
+
s.on("connect", () => t = !1), s.on("close", async (n) => {
|
|
3145
|
+
if (n) {
|
|
3146
|
+
if (t) {
|
|
3147
|
+
s.logger.warn("Token auto-refresh is disabled", n);
|
|
3148
|
+
return;
|
|
3149
|
+
}
|
|
3150
|
+
n.reason === "token_expired" && (t = !0, await e());
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
class zs {
|
|
3155
|
+
constructor(e) {
|
|
3156
|
+
this.channel = e;
|
|
3157
|
+
}
|
|
3158
|
+
notify(e, ...t) {
|
|
3159
|
+
typeof this[e] == "function" && this[e](...t);
|
|
3160
|
+
}
|
|
3161
|
+
perform(e, t = {}) {
|
|
3162
|
+
this.channel.perform(e, t);
|
|
3163
|
+
}
|
|
3164
|
+
send(e) {
|
|
3165
|
+
this.channel.send(e);
|
|
3166
|
+
}
|
|
3167
|
+
get identifier() {
|
|
3168
|
+
return this.channel.identifier;
|
|
3169
|
+
}
|
|
3170
|
+
unsubscribe() {
|
|
3171
|
+
return this.channel.disconnect();
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
class Vs extends qe {
|
|
3175
|
+
constructor(e, t, n) {
|
|
3176
|
+
super(e, t), this.subscription = new zs(this), Object.assign(this.subscription, n), this.on(
|
|
3177
|
+
"connect",
|
|
3178
|
+
({ reconnect: r }) => this.subscription.notify("connected", { reconnected: r })
|
|
3179
|
+
), this.on(
|
|
3180
|
+
"disconnect",
|
|
3181
|
+
() => this.subscription.notify("disconnected", { allowReconnect: !0 })
|
|
3182
|
+
), this.on("message", (r) => this.subscription.notify("received", r)), this.on("close", (r) => {
|
|
3183
|
+
r && r instanceof De ? this.subscription.notify("rejected") : this.subscription.notify("disconnected", { allowReconnect: !1 });
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
class Js {
|
|
3188
|
+
constructor(e) {
|
|
3189
|
+
this.cable = e;
|
|
3190
|
+
}
|
|
3191
|
+
create(e, t) {
|
|
3192
|
+
let n, r;
|
|
3193
|
+
typeof e == "object" ? (n = e.channel, delete e.channel, r = e) : (n = e, r = {});
|
|
3194
|
+
let i = new Vs(n, r, t);
|
|
3195
|
+
return i.subscription.notify("initialized"), this.cable.subscribe(i), i.subscription;
|
|
3196
|
+
}
|
|
3197
|
+
findAll(e) {
|
|
3198
|
+
return this.cable.hub.channels.filter((t) => t.identifier === e).map((t) => t.subscription);
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
class Ws {
|
|
3202
|
+
constructor(e) {
|
|
3203
|
+
this.cable = e, this.subscriptions = new Js(e);
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
class Ks extends qt {
|
|
3207
|
+
writeLogEntry(e, t, n) {
|
|
3208
|
+
n ? console[e](t, n) : console[e](t);
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
class Xs extends Ht {
|
|
3212
|
+
watch(e) {
|
|
3213
|
+
super.watch(e), this.initActivityListeners();
|
|
3214
|
+
}
|
|
3215
|
+
initActivityListeners() {
|
|
3216
|
+
if (typeof document < "u" && typeof window < "u" && document.addEventListener && window.addEventListener) {
|
|
3217
|
+
let e = () => {
|
|
3218
|
+
document.hidden || this.reconnectNow() && this.logger.debug("Trigger reconnect due to visibility change");
|
|
3219
|
+
}, t = (r) => {
|
|
3220
|
+
this.reconnectNow() && this.logger.debug("Trigger reconnect", { event: r });
|
|
3221
|
+
}, n = () => this.disconnect(new $("page_frozen"));
|
|
3222
|
+
document.addEventListener("visibilitychange", e, !1), window.addEventListener("focus", t, !1), window.addEventListener("online", t, !1), window.addEventListener("resume", t, !1), window.addEventListener("freeze", n, !1), this.unbind.push(() => {
|
|
3223
|
+
document.removeEventListener("visibilitychange", e, !1), window.removeEventListener("focus", t, !1), window.removeEventListener("online", t, !1), window.removeEventListener("resume", t, !1), window.removeEventListener("freeze", n, !1);
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
disconnect(e) {
|
|
3228
|
+
this.state === "disconnected" || this.state === "closed" || (this.logger.info("Disconnecting", { reason: e.message }), this.cancelReconnect(), this.stopPolling(), this.state = "pending_disconnect", this.target.disconnected(e));
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
const Gs = ["cable", "action-cable"], Zs = "/cable", ye = (s, e) => {
|
|
3232
|
+
for (let t of Gs) {
|
|
3233
|
+
let n = s.head.querySelector(`meta[name='${t}-${e}']`);
|
|
3234
|
+
if (n)
|
|
3235
|
+
return n.getAttribute("content");
|
|
3236
|
+
}
|
|
3237
|
+
}, ct = (s) => s.match(/wss?:\/\//) ? s : typeof window < "u" ? `${window.location.protocol.replace("http", "ws")}//${window.location.host}${s}` : s, Qs = () => {
|
|
3238
|
+
if (typeof document < "u" && document.head) {
|
|
3239
|
+
let s = ye(document, "url");
|
|
3240
|
+
if (s)
|
|
3241
|
+
return ct(s);
|
|
3242
|
+
}
|
|
3243
|
+
return ct(Zs);
|
|
3244
|
+
}, Ys = () => {
|
|
3245
|
+
if (typeof document < "u" && document.head) {
|
|
3246
|
+
let s = ye(document, "history-timestamp");
|
|
3247
|
+
if (s)
|
|
3248
|
+
return s | 0;
|
|
3249
|
+
}
|
|
3250
|
+
}, er = () => {
|
|
3251
|
+
if (typeof document < "u" && document.head)
|
|
3252
|
+
return ye(document, "token");
|
|
3253
|
+
}, tr = () => {
|
|
3254
|
+
if (typeof document < "u" && document.head)
|
|
3255
|
+
return ye(document, "token-param");
|
|
3256
|
+
};
|
|
3257
|
+
function nr(s, e) {
|
|
3258
|
+
typeof s == "object" && typeof e > "u" && (e = s, s = void 0), s = s || Qs(), e = e || {}, e.historyTimestamp || (e.historyTimestamp = Ys());
|
|
3259
|
+
let t = er();
|
|
3260
|
+
if (t) {
|
|
3261
|
+
let u = tr();
|
|
3262
|
+
e.auth = Object.assign({ token: t, param: u }, e.auth || {});
|
|
3263
|
+
}
|
|
3264
|
+
e = Object.assign({}, zt, e);
|
|
3265
|
+
let {
|
|
3266
|
+
logLevel: n,
|
|
3267
|
+
logger: r,
|
|
3268
|
+
pingInterval: i,
|
|
3269
|
+
reconnectStrategy: o,
|
|
3270
|
+
maxMissingPings: c,
|
|
3271
|
+
maxReconnectAttempts: h
|
|
3272
|
+
} = e;
|
|
3273
|
+
return r = e.logger = e.logger || new Ks(n), o = e.reconnectStrategy = e.reconnectStrategy || Mt(i), e.monitor !== !1 && (e.monitor = e.monitor || new Xs({
|
|
3274
|
+
pingInterval: i,
|
|
3275
|
+
reconnectStrategy: o,
|
|
3276
|
+
maxMissingPings: c,
|
|
3277
|
+
maxReconnectAttempts: h,
|
|
3278
|
+
logger: r
|
|
3279
|
+
})), Ms(s, e);
|
|
3280
|
+
}
|
|
3281
|
+
function sr(s, e) {
|
|
3282
|
+
let t = nr(s, e);
|
|
3283
|
+
return new Ws(t);
|
|
3284
|
+
}
|
|
3285
|
+
class li {
|
|
3286
|
+
constructor(e = "/openc3-api/cable") {
|
|
3287
|
+
this._cable = null, this._url = e;
|
|
3288
|
+
}
|
|
3289
|
+
disconnect() {
|
|
3290
|
+
this._cable && (this._cable.cable.disconnect(), this._cable = null);
|
|
3291
|
+
}
|
|
3292
|
+
createSubscription(e, t, n = {}, r = {}) {
|
|
3293
|
+
return OpenC3Auth.updateToken(OpenC3Auth.defaultMinValidity).then(
|
|
3294
|
+
(i) => {
|
|
3295
|
+
if (i && OpenC3Auth.setTokens(), this._cable == null) {
|
|
3296
|
+
let o = this._url + "?scope=" + encodeURIComponent(window.openc3Scope) + "&authorization=" + encodeURIComponent(localStorage.openc3Token);
|
|
3297
|
+
o = new URL(o, document.baseURI).href, this._cable = sr(o);
|
|
3298
|
+
}
|
|
3299
|
+
return this._cable.subscriptions.create(
|
|
3300
|
+
{
|
|
3301
|
+
channel: e,
|
|
3302
|
+
...r
|
|
3303
|
+
},
|
|
3304
|
+
n
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
);
|
|
3308
|
+
}
|
|
3309
|
+
recordPing() {
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
class at {
|
|
3313
|
+
constructor(e, t, n = "", r = "") {
|
|
3314
|
+
this.keyword = e.keyword, this.parameters = e.parameters, this.filename = e.filename, this.line = e.line, this.lineNumber = e.lineNumber, this.message = t, this.usage = n, this.url = r;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
class ui {
|
|
3318
|
+
constructor() {
|
|
3319
|
+
v(this, "keyword", null);
|
|
3320
|
+
v(this, "parameters", []);
|
|
3321
|
+
v(this, "filename", "");
|
|
3322
|
+
v(this, "line", "");
|
|
3323
|
+
v(this, "lineNumber", 0);
|
|
3324
|
+
v(this, "url", "https://docs.openc3.com/docs/configuration");
|
|
3325
|
+
}
|
|
3326
|
+
verify_num_parameters(e, t, n = "") {
|
|
3327
|
+
for (let r = 1; r <= e; r++)
|
|
3328
|
+
if (this.parameters[r - 1] === void 0)
|
|
3329
|
+
throw new at(
|
|
3330
|
+
this,
|
|
3331
|
+
`Not enough parameters for ${this.keyword}.`,
|
|
3332
|
+
n,
|
|
3333
|
+
this.url
|
|
3334
|
+
);
|
|
3335
|
+
if (t && this.parameters[t] !== void 0)
|
|
3336
|
+
throw new at(
|
|
3337
|
+
this,
|
|
3338
|
+
`Too many parameters for ${this.keyword}.`,
|
|
3339
|
+
n,
|
|
3340
|
+
this.url
|
|
3341
|
+
);
|
|
3342
|
+
}
|
|
3343
|
+
remove_quotes(e) {
|
|
3344
|
+
if (e.length < 2)
|
|
3345
|
+
return e;
|
|
3346
|
+
let t = e.charAt(0);
|
|
3347
|
+
if (t !== '"' && t !== "'")
|
|
3348
|
+
return e;
|
|
3349
|
+
let n = e.charAt(e.length - 1);
|
|
3350
|
+
return t !== n ? e : e.substring(1, e.length - 1);
|
|
3351
|
+
}
|
|
3352
|
+
scan_string(e, t) {
|
|
3353
|
+
if (!t.global) throw "rx must have 'global' flag set";
|
|
3354
|
+
let n = [];
|
|
3355
|
+
return e.replace(t, function(r) {
|
|
3356
|
+
return n.push(r), r;
|
|
3357
|
+
}), n;
|
|
3358
|
+
}
|
|
3359
|
+
parse_string(e, t, n, r, i) {
|
|
3360
|
+
let o = !1;
|
|
3361
|
+
this.line = "", this.keyword = null, this.parameters = [], this.filename = t;
|
|
3362
|
+
let c = e.split(`
|
|
3363
|
+
`), h = c.length;
|
|
3364
|
+
for (let u = 0; u < h; u++) {
|
|
3365
|
+
this.lineNumber = u + 1;
|
|
3366
|
+
let a = c[u].trim();
|
|
3367
|
+
if (a.length === 0) {
|
|
3368
|
+
n && i(null, [], this.line, this.lineNumber);
|
|
3369
|
+
continue;
|
|
3370
|
+
}
|
|
3371
|
+
if (o === !0) {
|
|
3372
|
+
if (a[0] === "#")
|
|
3373
|
+
continue;
|
|
3374
|
+
a = a.substring(1, a.length);
|
|
3375
|
+
}
|
|
3376
|
+
let d = a.charAt(a.length - 1), g = !1;
|
|
3377
|
+
switch (d) {
|
|
3378
|
+
case "+":
|
|
3379
|
+
g = !0;
|
|
3380
|
+
// Deliberate fall through
|
|
3381
|
+
case "\\":
|
|
3382
|
+
let _ = a.substring(0, a.length - 1).trim();
|
|
3383
|
+
this.line += _.substring(0, _.length - 1), g && (this.line += `
|
|
3384
|
+
`), o = !0;
|
|
3385
|
+
continue;
|
|
3386
|
+
case "&":
|
|
3387
|
+
this.line += a.substring(0, a.length - 1);
|
|
3388
|
+
continue;
|
|
3389
|
+
default:
|
|
3390
|
+
this.line += a;
|
|
3391
|
+
}
|
|
3392
|
+
o = !1;
|
|
3393
|
+
let b = /("([^\\"]|\\.)*")|('([^\\']|\\.)*')|\S+/g, f = this.scan_string(this.line, b), m = "";
|
|
3394
|
+
if (f.length > 0 && (m = m + f[0]), m.length === 0 || m.charAt(0) === "#" ? this.keyword = null : this.keyword = m.toUpperCase(), this.parameters = [], this.keyword === null) {
|
|
3395
|
+
n && i(this.keyword, this.parameters, this.line, this.lineNumber), this.line = "";
|
|
3396
|
+
continue;
|
|
3397
|
+
}
|
|
3398
|
+
let p = f.length;
|
|
3399
|
+
if (p > 1)
|
|
3400
|
+
for (let _ = 1; _ < p; _++) {
|
|
3401
|
+
let E = f[_];
|
|
3402
|
+
if (E.length > 0 && E.charAt(0) === "#")
|
|
3403
|
+
break;
|
|
3404
|
+
r ? this.parameters.push(this.remove_quotes(E)) : this.parameters.push(E);
|
|
3405
|
+
}
|
|
3406
|
+
i(this.keyword, this.parameters, this.line, this.lineNumber), this.line = "";
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
// parse_string
|
|
3410
|
+
}
|
|
3411
|
+
function Be(s) {
|
|
3412
|
+
return rr.test(s);
|
|
3413
|
+
}
|
|
3414
|
+
const rr = /^-?[0-9]+$/;
|
|
3415
|
+
function Vt(s) {
|
|
3416
|
+
return ir.test(s);
|
|
3417
|
+
}
|
|
3418
|
+
const ir = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
3419
|
+
function Jt(s, e) {
|
|
3420
|
+
const t = Number.parseFloat(s), n = String(t), r = lt(s), i = lt(n);
|
|
3421
|
+
return !!(r === i || (e == null ? void 0 : e.approx) === !0 && !Be(s) && i.length >= 14 && r.startsWith(i.substring(0, 14)));
|
|
3422
|
+
}
|
|
3423
|
+
let Q = /* @__PURE__ */ function(s) {
|
|
3424
|
+
return s.underflow = "underflow", s.overflow = "overflow", s.truncate_integer = "truncate_integer", s.truncate_float = "truncate_float", s;
|
|
3425
|
+
}({});
|
|
3426
|
+
function or(s) {
|
|
3427
|
+
if (Jt(s, {
|
|
3428
|
+
approx: !1
|
|
3429
|
+
}))
|
|
3430
|
+
return;
|
|
3431
|
+
if (Be(s))
|
|
3432
|
+
return Q.truncate_integer;
|
|
3433
|
+
const e = Number.parseFloat(s);
|
|
3434
|
+
return Number.isFinite(e) ? e === 0 ? Q.underflow : Q.truncate_float : Q.overflow;
|
|
3435
|
+
}
|
|
3436
|
+
function lt(s) {
|
|
3437
|
+
return s.replace(cr, "").replace(lr, "").replace(ur, "").replace(ar, "");
|
|
3438
|
+
}
|
|
3439
|
+
const cr = /[eE][+-]?\d+$/, ar = /^-?(0*)?/, lr = /\./, ur = /0+$/;
|
|
3440
|
+
class hr {
|
|
3441
|
+
constructor(e) {
|
|
3442
|
+
// numeric value as string
|
|
3443
|
+
// type information
|
|
3444
|
+
v(this, "isLosslessNumber", !0);
|
|
3445
|
+
if (!Vt(e))
|
|
3446
|
+
throw new Error(`Invalid number (value: "${e}")`);
|
|
3447
|
+
this.value = e;
|
|
3448
|
+
}
|
|
3449
|
+
/**
|
|
3450
|
+
* Get the value of the LosslessNumber as number or bigint.
|
|
3451
|
+
*
|
|
3452
|
+
* - a number is returned for safe numbers and decimal values that only lose some insignificant digits
|
|
3453
|
+
* - a bigint is returned for big integer numbers
|
|
3454
|
+
* - an Error is thrown for values that will overflow or underflow
|
|
3455
|
+
*
|
|
3456
|
+
* Note that you can implement your own strategy for conversion by just getting the value as string
|
|
3457
|
+
* via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,
|
|
3458
|
+
* and toSafeNumberOrThrow to convert it to a numeric value.
|
|
3459
|
+
*/
|
|
3460
|
+
valueOf() {
|
|
3461
|
+
const e = or(this.value);
|
|
3462
|
+
if (e === void 0 || e === Q.truncate_float)
|
|
3463
|
+
return Number.parseFloat(this.value);
|
|
3464
|
+
if (Be(this.value))
|
|
3465
|
+
return BigInt(this.value);
|
|
3466
|
+
throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${e} and become ${Number.parseFloat(this.value)}`);
|
|
3467
|
+
}
|
|
3468
|
+
/**
|
|
3469
|
+
* Get the value of the LosslessNumber as string.
|
|
3470
|
+
*/
|
|
3471
|
+
toString() {
|
|
3472
|
+
return this.value;
|
|
3473
|
+
}
|
|
3474
|
+
// Note: we do NOT implement a .toJSON() method, and you should not implement
|
|
3475
|
+
// or use that, it cannot safely turn the numeric value in the string into
|
|
3476
|
+
// stringified JSON since it has to be parsed into a number first.
|
|
3477
|
+
}
|
|
3478
|
+
function dr(s) {
|
|
3479
|
+
return s && typeof s == "object" && s.isLosslessNumber === !0 || !1;
|
|
3480
|
+
}
|
|
3481
|
+
function fr(s) {
|
|
3482
|
+
return new hr(s);
|
|
3483
|
+
}
|
|
3484
|
+
function pr(s, e) {
|
|
3485
|
+
return Me({
|
|
3486
|
+
"": s
|
|
3487
|
+
}, "", s, e);
|
|
3488
|
+
}
|
|
3489
|
+
function Me(s, e, t, n) {
|
|
3490
|
+
return Array.isArray(t) ? n.call(s, e, gr(t, n)) : t && typeof t == "object" && !dr(t) ? n.call(s, e, mr(t, n)) : n.call(s, e, t);
|
|
3491
|
+
}
|
|
3492
|
+
function mr(s, e) {
|
|
3493
|
+
for (const t of Object.keys(s)) {
|
|
3494
|
+
const n = Me(s, t, s[t], e);
|
|
3495
|
+
n !== void 0 ? s[t] = n : delete s[t];
|
|
3496
|
+
}
|
|
3497
|
+
return s;
|
|
3498
|
+
}
|
|
3499
|
+
function gr(s, e) {
|
|
3500
|
+
for (let t = 0; t < s.length; t++)
|
|
3501
|
+
s[t] = Me(s, String(t), s[t], e);
|
|
3502
|
+
return s;
|
|
3503
|
+
}
|
|
3504
|
+
function br(s, e) {
|
|
3505
|
+
let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : fr, n = 0;
|
|
3506
|
+
const r = c();
|
|
3507
|
+
return f(r), p(), e ? pr(r, e) : r;
|
|
3508
|
+
function i() {
|
|
3509
|
+
if (s.charCodeAt(n) === xr) {
|
|
3510
|
+
n++, u();
|
|
3511
|
+
const y = {};
|
|
3512
|
+
let A = !0;
|
|
3513
|
+
for (; n < s.length && s.charCodeAt(n) !== ht; ) {
|
|
3514
|
+
A ? A = !1 : (g(), u());
|
|
3515
|
+
const q = n, G = a();
|
|
3516
|
+
if (G === void 0) {
|
|
3517
|
+
S();
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3520
|
+
u(), b();
|
|
3521
|
+
const Ee = c();
|
|
3522
|
+
if (Ee === void 0) {
|
|
3523
|
+
U();
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
Object.prototype.hasOwnProperty.call(y, G) && !ve(Ee, y[G]) && k(G, q + 1), y[G] = Ee;
|
|
3527
|
+
}
|
|
3528
|
+
return s.charCodeAt(n) !== ht && x(), n++, y;
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
function o() {
|
|
3532
|
+
if (s.charCodeAt(n) === Rr) {
|
|
3533
|
+
n++, u();
|
|
3534
|
+
const y = [];
|
|
3535
|
+
let A = !0;
|
|
3536
|
+
for (; n < s.length && s.charCodeAt(n) !== dt; ) {
|
|
3537
|
+
A ? A = !1 : g();
|
|
3538
|
+
const q = c();
|
|
3539
|
+
m(q), y.push(q);
|
|
3540
|
+
}
|
|
3541
|
+
return s.charCodeAt(n) !== dt && P(), n++, y;
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
function c() {
|
|
3545
|
+
u();
|
|
3546
|
+
const y = a() ?? d() ?? i() ?? o() ?? h("true", !0) ?? h("false", !1) ?? h("null", null);
|
|
3547
|
+
return u(), y;
|
|
3548
|
+
}
|
|
3549
|
+
function h(y, A) {
|
|
3550
|
+
if (s.slice(n, n + y.length) === y)
|
|
3551
|
+
return n += y.length, A;
|
|
3552
|
+
}
|
|
3553
|
+
function u() {
|
|
3554
|
+
for (; wr(s.charCodeAt(n)); )
|
|
3555
|
+
n++;
|
|
3556
|
+
}
|
|
3557
|
+
function a() {
|
|
3558
|
+
if (s.charCodeAt(n) === Ae) {
|
|
3559
|
+
n++;
|
|
3560
|
+
let y = "";
|
|
3561
|
+
for (; n < s.length && s.charCodeAt(n) !== Ae; ) {
|
|
3562
|
+
if (s.charCodeAt(n) === Sr) {
|
|
3563
|
+
const A = s[n + 1], q = Er[A];
|
|
3564
|
+
q !== void 0 ? (y += q, n++) : A === "u" ? ie(s.charCodeAt(n + 2)) && ie(s.charCodeAt(n + 3)) && ie(s.charCodeAt(n + 4)) && ie(s.charCodeAt(n + 5)) ? (y += String.fromCharCode(Number.parseInt(s.slice(n + 2, n + 6), 16)), n += 5) : _e(n) : D(n);
|
|
3565
|
+
} else
|
|
3566
|
+
_r(s.charCodeAt(n)) ? y += s[n] : I(s[n]);
|
|
3567
|
+
n++;
|
|
3568
|
+
}
|
|
3569
|
+
return E(), n++, y;
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
function d() {
|
|
3573
|
+
const y = n;
|
|
3574
|
+
if (s.charCodeAt(n) === ft && (n++, _(y)), s.charCodeAt(n) === He)
|
|
3575
|
+
n++;
|
|
3576
|
+
else if (yr(s.charCodeAt(n)))
|
|
3577
|
+
for (n++; oe(s.charCodeAt(n)); )
|
|
3578
|
+
n++;
|
|
3579
|
+
if (s.charCodeAt(n) === Ir)
|
|
3580
|
+
for (n++, _(y); oe(s.charCodeAt(n)); )
|
|
3581
|
+
n++;
|
|
3582
|
+
if (s.charCodeAt(n) === Fr || s.charCodeAt(n) === jr)
|
|
3583
|
+
for (n++, (s.charCodeAt(n) === ft || s.charCodeAt(n) === kr) && n++, _(y); oe(s.charCodeAt(n)); )
|
|
3584
|
+
n++;
|
|
3585
|
+
if (n > y)
|
|
3586
|
+
return t(s.slice(y, n));
|
|
3587
|
+
}
|
|
3588
|
+
function g() {
|
|
3589
|
+
if (s.charCodeAt(n) !== Pr)
|
|
3590
|
+
throw new SyntaxError(`Comma ',' expected after value ${C()}`);
|
|
3591
|
+
n++;
|
|
3592
|
+
}
|
|
3593
|
+
function b() {
|
|
3594
|
+
if (s.charCodeAt(n) !== Lr)
|
|
3595
|
+
throw new SyntaxError(`Colon ':' expected after property name ${C()}`);
|
|
3596
|
+
n++;
|
|
3597
|
+
}
|
|
3598
|
+
function f(y) {
|
|
3599
|
+
if (y === void 0)
|
|
3600
|
+
throw new SyntaxError(`JSON value expected ${C()}`);
|
|
3601
|
+
}
|
|
3602
|
+
function m(y) {
|
|
3603
|
+
if (y === void 0)
|
|
3604
|
+
throw new SyntaxError(`Array item expected ${C()}`);
|
|
3605
|
+
}
|
|
3606
|
+
function p() {
|
|
3607
|
+
if (n < s.length)
|
|
3608
|
+
throw new SyntaxError(`Expected end of input ${C()}`);
|
|
3609
|
+
}
|
|
3610
|
+
function _(y) {
|
|
3611
|
+
if (!oe(s.charCodeAt(n))) {
|
|
3612
|
+
const A = s.slice(y, n);
|
|
3613
|
+
throw new SyntaxError(`Invalid number '${A}', expecting a digit ${C()}`);
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
function E() {
|
|
3617
|
+
if (s.charCodeAt(n) !== Ae)
|
|
3618
|
+
throw new SyntaxError(`End of string '"' expected ${C()}`);
|
|
3619
|
+
}
|
|
3620
|
+
function S() {
|
|
3621
|
+
throw new SyntaxError(`Quoted object key expected ${C()}`);
|
|
3622
|
+
}
|
|
3623
|
+
function k(y, A) {
|
|
3624
|
+
throw new SyntaxError(`Duplicate key '${y}' encountered at position ${A}`);
|
|
3625
|
+
}
|
|
3626
|
+
function x() {
|
|
3627
|
+
throw new SyntaxError(`Quoted object key or end of object '}' expected ${C()}`);
|
|
3628
|
+
}
|
|
3629
|
+
function P() {
|
|
3630
|
+
throw new SyntaxError(`Array item or end of array ']' expected ${C()}`);
|
|
3631
|
+
}
|
|
3632
|
+
function I(y) {
|
|
3633
|
+
throw new SyntaxError(`Invalid character '${y}' ${L()}`);
|
|
3634
|
+
}
|
|
3635
|
+
function D(y) {
|
|
3636
|
+
const A = s.slice(y, y + 2);
|
|
3637
|
+
throw new SyntaxError(`Invalid escape character '${A}' ${L()}`);
|
|
3638
|
+
}
|
|
3639
|
+
function U() {
|
|
3640
|
+
throw new SyntaxError(`Object value expected after ':' ${L()}`);
|
|
3641
|
+
}
|
|
3642
|
+
function _e(y) {
|
|
3643
|
+
const A = s.slice(y, y + 6);
|
|
3644
|
+
throw new SyntaxError(`Invalid unicode character '${A}' ${L()}`);
|
|
3645
|
+
}
|
|
3646
|
+
function L() {
|
|
3647
|
+
return `at position ${n}`;
|
|
3648
|
+
}
|
|
3649
|
+
function J() {
|
|
3650
|
+
return n < s.length ? `but got '${s[n]}'` : "but reached end of input";
|
|
3651
|
+
}
|
|
3652
|
+
function C() {
|
|
3653
|
+
return `${J()} ${L()}`;
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
function wr(s) {
|
|
3657
|
+
return s === Ar || s === Or || s === Cr || s === Tr;
|
|
3658
|
+
}
|
|
3659
|
+
function ie(s) {
|
|
3660
|
+
return s >= He && s <= ze || s >= vr && s <= Ur || s >= $r && s <= Dr;
|
|
3661
|
+
}
|
|
3662
|
+
function oe(s) {
|
|
3663
|
+
return s >= He && s <= ze;
|
|
3664
|
+
}
|
|
3665
|
+
function yr(s) {
|
|
3666
|
+
return s >= Nr && s <= ze;
|
|
3667
|
+
}
|
|
3668
|
+
function _r(s) {
|
|
3669
|
+
return s >= 32 && s <= 1114111;
|
|
3670
|
+
}
|
|
3671
|
+
function ve(s, e) {
|
|
3672
|
+
return s === e ? !0 : Array.isArray(s) && Array.isArray(e) ? s.length === e.length && s.every((t, n) => ve(t, e[n])) : ut(s) && ut(e) ? [.../* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(e)])].every((n) => ve(s[n], e[n])) : !1;
|
|
3673
|
+
}
|
|
3674
|
+
function ut(s) {
|
|
3675
|
+
return typeof s == "object" && s !== null;
|
|
3676
|
+
}
|
|
3677
|
+
const Er = {
|
|
3678
|
+
'"': '"',
|
|
3679
|
+
"\\": "\\",
|
|
3680
|
+
"/": "/",
|
|
3681
|
+
b: "\b",
|
|
3682
|
+
f: "\f",
|
|
3683
|
+
n: `
|
|
3684
|
+
`,
|
|
3685
|
+
r: "\r",
|
|
3686
|
+
t: " "
|
|
3687
|
+
// note that \u is handled separately in parseString()
|
|
3688
|
+
}, Sr = 92, xr = 123, ht = 125, Rr = 91, dt = 93, Ar = 32, Or = 10, Cr = 9, Tr = 13, Ae = 34, kr = 43, ft = 45, He = 48, Nr = 49, ze = 57, Pr = 44, Ir = 46, Lr = 58, vr = 65, $r = 97, jr = 69, Fr = 101, Ur = 70, Dr = 102;
|
|
3689
|
+
function Wt(s, e, t, n) {
|
|
3690
|
+
const r = void 0;
|
|
3691
|
+
return o(s, "");
|
|
3692
|
+
function o(a, d) {
|
|
3693
|
+
if (Array.isArray(n)) {
|
|
3694
|
+
const g = n.find((b) => b.test(a));
|
|
3695
|
+
if (g) {
|
|
3696
|
+
const b = g.stringify(a);
|
|
3697
|
+
if (typeof b != "string" || !Vt(b))
|
|
3698
|
+
throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${b})`);
|
|
3699
|
+
return b;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
if (typeof a == "boolean" || typeof a == "number" || typeof a == "string" || a === null || a instanceof Date || a instanceof Boolean || a instanceof Number || a instanceof String)
|
|
3703
|
+
return JSON.stringify(a);
|
|
3704
|
+
if (a != null && a.isLosslessNumber || typeof a == "bigint")
|
|
3705
|
+
return a.toString();
|
|
3706
|
+
if (Array.isArray(a))
|
|
3707
|
+
return c(a, d);
|
|
3708
|
+
if (a && typeof a == "object")
|
|
3709
|
+
return h(a, d);
|
|
3710
|
+
}
|
|
3711
|
+
function c(a, d) {
|
|
3712
|
+
if (a.length === 0)
|
|
3713
|
+
return "[]";
|
|
3714
|
+
const g = r ? d + r : void 0;
|
|
3715
|
+
let b = r ? `[
|
|
3716
|
+
` : "[";
|
|
3717
|
+
for (let f = 0; f < a.length; f++) {
|
|
3718
|
+
const m = a[f];
|
|
3719
|
+
r && (b += g), typeof m < "u" && typeof m != "function" ? b += o(m, g) : b += "null", f < a.length - 1 && (b += r ? `,
|
|
3720
|
+
` : ",");
|
|
3721
|
+
}
|
|
3722
|
+
return b += r ? `
|
|
3723
|
+
${d}]` : "]", b;
|
|
3724
|
+
}
|
|
3725
|
+
function h(a, d) {
|
|
3726
|
+
if (typeof a.toJSON == "function")
|
|
3727
|
+
return Wt(a.toJSON(), e, t, void 0);
|
|
3728
|
+
const g = Array.isArray(e) ? e.map(String) : Object.keys(a);
|
|
3729
|
+
if (g.length === 0)
|
|
3730
|
+
return "{}";
|
|
3731
|
+
const b = r ? d + r : void 0;
|
|
3732
|
+
let f = !0, m = r ? `{
|
|
3733
|
+
` : "{";
|
|
3734
|
+
for (const p of g) {
|
|
3735
|
+
const _ = a[p];
|
|
3736
|
+
if (u(p, _)) {
|
|
3737
|
+
f ? f = !1 : m += r ? `,
|
|
3738
|
+
` : ",";
|
|
3739
|
+
const E = JSON.stringify(p);
|
|
3740
|
+
m += r ? `${b + E}: ` : `${E}:`, m += o(_, b);
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
return m += r ? `
|
|
3744
|
+
${d}}` : "}", m;
|
|
3745
|
+
}
|
|
3746
|
+
function u(a, d) {
|
|
3747
|
+
return typeof d < "u" && typeof d != "function" && typeof d != "symbol";
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
function qr(s) {
|
|
3751
|
+
return Jt(s) ? parseFloat(s) : BigInt(s);
|
|
3752
|
+
}
|
|
3753
|
+
class hi {
|
|
3754
|
+
constructor() {
|
|
3755
|
+
v(this, "id", 1);
|
|
3756
|
+
}
|
|
3757
|
+
async exec(e, t, n = {}, r = {}, i = 6e4) {
|
|
3758
|
+
try {
|
|
3759
|
+
await OpenC3Auth.updateToken(
|
|
3760
|
+
OpenC3Auth.defaultMinValidity
|
|
3761
|
+
) && OpenC3Auth.setTokens();
|
|
3762
|
+
} catch {
|
|
3763
|
+
OpenC3Auth.login();
|
|
3764
|
+
}
|
|
3765
|
+
this.id = this.id + 1;
|
|
3766
|
+
try {
|
|
3767
|
+
return n.scope = window.openc3Scope, r.manual = !0, (await Ue.post(
|
|
3768
|
+
"/openc3-api/api",
|
|
3769
|
+
{
|
|
3770
|
+
jsonrpc: "2.0",
|
|
3771
|
+
method: e,
|
|
3772
|
+
params: t,
|
|
3773
|
+
id: this.id,
|
|
3774
|
+
keyword_params: n
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
headers: {
|
|
3778
|
+
Authorization: localStorage.openc3Token,
|
|
3779
|
+
"Content-Type": "application/json-rpc",
|
|
3780
|
+
...r
|
|
3781
|
+
},
|
|
3782
|
+
timeout: i,
|
|
3783
|
+
transformRequest: [
|
|
3784
|
+
(c, h) => Wt(c)
|
|
3785
|
+
],
|
|
3786
|
+
transformResponse: [
|
|
3787
|
+
(c) => br(c, void 0, qr)
|
|
3788
|
+
]
|
|
3789
|
+
}
|
|
3790
|
+
)).data.result;
|
|
3791
|
+
} catch (o) {
|
|
3792
|
+
let c = new Error();
|
|
3793
|
+
throw o.response ? (c.name = o.response.data.error.data.class, c.message = o.response.data.error.data.message, c.object = o.response.data.error) : o.request ? (c.name = "Request error", c.message = "Request error, no response received") : c.name = "Unknown error", c;
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
decode_openc3_type(e) {
|
|
3797
|
+
if (e !== null && typeof e == "object" && e.json_class == "Float" && e.raw) {
|
|
3798
|
+
if (e.raw == "NaN")
|
|
3799
|
+
return NaN;
|
|
3800
|
+
if (e.raw == "Infinity")
|
|
3801
|
+
return 1 / 0;
|
|
3802
|
+
if (e.raw == "-Infinity")
|
|
3803
|
+
return -1 / 0;
|
|
3804
|
+
}
|
|
3805
|
+
return null;
|
|
3806
|
+
}
|
|
3807
|
+
encode_openc3_type(e) {
|
|
3808
|
+
return Number.isNaN(e) ? { json_class: "Float", raw: "NaN" } : e == Number.POSITIVE_INFINITY ? { json_class: "Float", raw: "Infinity" } : e == Number.NEGATIVE_INFINITY ? { json_class: "Float", raw: "-Infinity" } : null;
|
|
3809
|
+
}
|
|
3810
|
+
ensure_offline_access() {
|
|
3811
|
+
this.offline_access_needed().then((e) => {
|
|
3812
|
+
e && (localStorage.openc3OfflineToken ? this.set_offline_access(localStorage.openc3OfflineToken).then(() => {
|
|
3813
|
+
delete localStorage.openc3OfflineToken;
|
|
3814
|
+
}) : OpenC3Auth.getOfflineAccess());
|
|
3815
|
+
});
|
|
3816
|
+
}
|
|
3817
|
+
// ***********************************************
|
|
3818
|
+
// The following APIs are used by the CmdTlmServer
|
|
3819
|
+
// ***********************************************
|
|
3820
|
+
offline_access_needed() {
|
|
3821
|
+
return this.exec("offline_access_needed", []);
|
|
3822
|
+
}
|
|
3823
|
+
set_offline_access(e) {
|
|
3824
|
+
return this.exec("set_offline_access", [e]);
|
|
3825
|
+
}
|
|
3826
|
+
get_all_interface_info() {
|
|
3827
|
+
return this.exec("get_all_interface_info", []);
|
|
3828
|
+
}
|
|
3829
|
+
map_target_to_interface(e, t) {
|
|
3830
|
+
return this.exec("map_target_to_interface", [e, t]);
|
|
3831
|
+
}
|
|
3832
|
+
connect_interface(e, ...t) {
|
|
3833
|
+
return t.length > 0 ? this.exec("connect_interface", [
|
|
3834
|
+
e,
|
|
3835
|
+
...t
|
|
3836
|
+
]) : this.exec("connect_interface", [e]);
|
|
3837
|
+
}
|
|
3838
|
+
disconnect_interface(e) {
|
|
3839
|
+
return this.exec("disconnect_interface", [e]);
|
|
3840
|
+
}
|
|
3841
|
+
interface_cmd(e, t, ...n) {
|
|
3842
|
+
return this.exec("interface_cmd", [
|
|
3843
|
+
e,
|
|
3844
|
+
t,
|
|
3845
|
+
...n
|
|
3846
|
+
]);
|
|
3847
|
+
}
|
|
3848
|
+
get_all_router_info() {
|
|
3849
|
+
return this.exec("get_all_router_info", []);
|
|
3850
|
+
}
|
|
3851
|
+
connect_router(e) {
|
|
3852
|
+
return this.exec("connect_router", [e]);
|
|
3853
|
+
}
|
|
3854
|
+
disconnect_router(e) {
|
|
3855
|
+
return this.exec("disconnect_router", [e]);
|
|
3856
|
+
}
|
|
3857
|
+
get_target_interfaces() {
|
|
3858
|
+
return this.exec("get_target_interfaces", []);
|
|
3859
|
+
}
|
|
3860
|
+
get_tlm_cnts(e) {
|
|
3861
|
+
return this.exec("get_tlm_cnts", [e]);
|
|
3862
|
+
}
|
|
3863
|
+
get_item(e, t, n) {
|
|
3864
|
+
return this.exec("get_item", [e, t, n]);
|
|
3865
|
+
}
|
|
3866
|
+
get_param(e, t, n) {
|
|
3867
|
+
return this.exec("get_param", [e, t, n]);
|
|
3868
|
+
}
|
|
3869
|
+
// DEPRECATED for get_param
|
|
3870
|
+
get_parameter(e, t, n) {
|
|
3871
|
+
return this.exec("get_param", [e, t, n]);
|
|
3872
|
+
}
|
|
3873
|
+
get_limits_sets() {
|
|
3874
|
+
return this.exec("get_limits_sets", []);
|
|
3875
|
+
}
|
|
3876
|
+
get_limits_set() {
|
|
3877
|
+
return this.exec("get_limits_set", []);
|
|
3878
|
+
}
|
|
3879
|
+
set_limits_set(e) {
|
|
3880
|
+
return this.exec("set_limits_set", [e]);
|
|
3881
|
+
}
|
|
3882
|
+
// ***********************************************
|
|
3883
|
+
// End CmdTlmServer APIs
|
|
3884
|
+
// ***********************************************
|
|
3885
|
+
get_target(e) {
|
|
3886
|
+
return this.exec("get_target", [e]);
|
|
3887
|
+
}
|
|
3888
|
+
get_target_names() {
|
|
3889
|
+
return this.exec("get_target_names", []);
|
|
3890
|
+
}
|
|
3891
|
+
// DEPRECATED for get_target_names
|
|
3892
|
+
get_target_list() {
|
|
3893
|
+
return this.exec("get_target_names", []);
|
|
3894
|
+
}
|
|
3895
|
+
get_tlm(e, t) {
|
|
3896
|
+
return this.exec("get_tlm", [e, t]);
|
|
3897
|
+
}
|
|
3898
|
+
// DEPRECATED for get_tlm
|
|
3899
|
+
get_telemetry(e, t) {
|
|
3900
|
+
return this.exec("get_tlm", [e, t]);
|
|
3901
|
+
}
|
|
3902
|
+
get_all_tlm(e) {
|
|
3903
|
+
return this.exec("get_all_tlm", [e]);
|
|
3904
|
+
}
|
|
3905
|
+
// DEPRECATED for get_all_tlm
|
|
3906
|
+
get_all_telemetry(e) {
|
|
3907
|
+
return this.exec("get_all_tlm", [e]);
|
|
3908
|
+
}
|
|
3909
|
+
get_all_tlm_names(e, t = !1) {
|
|
3910
|
+
return this.exec("get_all_tlm_names", [e], { hidden: t });
|
|
3911
|
+
}
|
|
3912
|
+
// DEPRECATED for get_all_tlm_names
|
|
3913
|
+
get_all_telemetry_names(e) {
|
|
3914
|
+
return this.exec("get_all_tlm_names", [e]);
|
|
3915
|
+
}
|
|
3916
|
+
get_all_tlm_item_names(e) {
|
|
3917
|
+
return this.exec("get_all_tlm_item_names", [e]);
|
|
3918
|
+
}
|
|
3919
|
+
async get_tlm_packet(e, t, n, r = 30) {
|
|
3920
|
+
const i = await this.exec("get_tlm_packet", [e, t], {
|
|
3921
|
+
type: n,
|
|
3922
|
+
stale_time: r
|
|
3923
|
+
});
|
|
3924
|
+
if (i != null) {
|
|
3925
|
+
let o = i.length, c = null;
|
|
3926
|
+
for (let h = 0; h < o; h++)
|
|
3927
|
+
c = this.decode_openc3_type(i[h][1]), c !== null && (i[h][1] = c);
|
|
3928
|
+
}
|
|
3929
|
+
return i;
|
|
3930
|
+
}
|
|
3931
|
+
get_packet_derived_items(e, t) {
|
|
3932
|
+
return this.exec("get_packet_derived_items", [e, t]);
|
|
3933
|
+
}
|
|
3934
|
+
get_tlm_buffer(e, t) {
|
|
3935
|
+
return this.exec("get_tlm_buffer", [e, t]);
|
|
3936
|
+
}
|
|
3937
|
+
async get_tlm_values(e, t = 30, n = null) {
|
|
3938
|
+
let r = {
|
|
3939
|
+
stale_time: t
|
|
3940
|
+
};
|
|
3941
|
+
n !== null && (r.cache_timeout = n);
|
|
3942
|
+
const i = await this.exec(
|
|
3943
|
+
"get_tlm_values",
|
|
3944
|
+
[e],
|
|
3945
|
+
r,
|
|
3946
|
+
{},
|
|
3947
|
+
1e4
|
|
3948
|
+
// 10s timeout ... should never be this long
|
|
3949
|
+
);
|
|
3950
|
+
let o = i[0].length, c = null;
|
|
3951
|
+
for (let h = 0; h < o; h++)
|
|
3952
|
+
c = this.decode_openc3_type(i[0][h]), c !== null && (i[0][h] = c);
|
|
3953
|
+
return i;
|
|
3954
|
+
}
|
|
3955
|
+
get_limits(e, t, n) {
|
|
3956
|
+
return this.exec("get_limits", [e, t, n]);
|
|
3957
|
+
}
|
|
3958
|
+
async tlm(e, t, n, r = "CONVERTED") {
|
|
3959
|
+
let i = null;
|
|
3960
|
+
if (t === void 0)
|
|
3961
|
+
i = await this.exec("tlm", [e]);
|
|
3962
|
+
else if (n === void 0)
|
|
3963
|
+
if (["RAW", "CONVERTED", "FORMATTED", "WITH_UNITS"].includes(t))
|
|
3964
|
+
i = await this.exec("tlm", [e], { type: t });
|
|
3965
|
+
else {
|
|
3966
|
+
let c = new Error();
|
|
3967
|
+
throw c.name = "TypeError", c.message = `Invalid data type ${t}. Valid options are RAW, CONVERTED, FORMATTED, and WITH_UNITS.`, c;
|
|
3968
|
+
}
|
|
3969
|
+
else
|
|
3970
|
+
i = await this.exec("tlm", [e, t, n], {
|
|
3971
|
+
type: r
|
|
3972
|
+
});
|
|
3973
|
+
let o = this.decode_openc3_type(i);
|
|
3974
|
+
return o !== null && (i = o), i;
|
|
3975
|
+
}
|
|
3976
|
+
async inject_tlm(e, t, n = null, r = "CONVERTED") {
|
|
3977
|
+
await this.exec("inject_tlm", [e, t, n], {
|
|
3978
|
+
type: r
|
|
3979
|
+
});
|
|
3980
|
+
}
|
|
3981
|
+
set_tlm(e, t, n, r) {
|
|
3982
|
+
return this.exec("set_tlm", [e, t, n], {
|
|
3983
|
+
type: r
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
override_tlm(e, t, n, r) {
|
|
3987
|
+
return this.exec("override_tlm", [e, t, n], {
|
|
3988
|
+
type: r
|
|
3989
|
+
});
|
|
3990
|
+
}
|
|
3991
|
+
get_overrides() {
|
|
3992
|
+
return this.exec("get_overrides");
|
|
3993
|
+
}
|
|
3994
|
+
normalize_tlm(e, t, n, r) {
|
|
3995
|
+
return this.exec("normalize_tlm", [e, t, n], {
|
|
3996
|
+
type: r
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3999
|
+
get_all_cmds(e) {
|
|
4000
|
+
return this.exec("get_all_cmds", [e]);
|
|
4001
|
+
}
|
|
4002
|
+
// DEPRECATED for get_all_cmds
|
|
4003
|
+
get_all_commands(e) {
|
|
4004
|
+
return this.exec("get_all_cmds", [e]);
|
|
4005
|
+
}
|
|
4006
|
+
get_all_cmd_names(e, t = !1) {
|
|
4007
|
+
return this.exec("get_all_cmd_names", [e], { hidden: t });
|
|
4008
|
+
}
|
|
4009
|
+
// DEPRECATED for get_all_cmd_names
|
|
4010
|
+
get_all_command_names(e) {
|
|
4011
|
+
return this.exec("get_all_cmd_names", [e]);
|
|
4012
|
+
}
|
|
4013
|
+
get_cmd(e, t) {
|
|
4014
|
+
return this.exec("get_cmd", [e, t]);
|
|
4015
|
+
}
|
|
4016
|
+
// DEPRECATED for get_cmd
|
|
4017
|
+
get_command(e, t) {
|
|
4018
|
+
return this.exec("get_cmd", [e, t]);
|
|
4019
|
+
}
|
|
4020
|
+
get_cmd_cnts(e) {
|
|
4021
|
+
return this.exec("get_cmd_cnts", [e]);
|
|
4022
|
+
}
|
|
4023
|
+
get_cmd_value(e, t, n, r = "CONVERTED") {
|
|
4024
|
+
return this.exec("get_cmd_value", [
|
|
4025
|
+
e,
|
|
4026
|
+
t,
|
|
4027
|
+
n,
|
|
4028
|
+
r
|
|
4029
|
+
]);
|
|
4030
|
+
}
|
|
4031
|
+
get_cmd_buffer(e, t) {
|
|
4032
|
+
return this.exec("get_cmd_buffer", [e, t]);
|
|
4033
|
+
}
|
|
4034
|
+
// Implementation of functionality shared by cmd methods with param_lists.
|
|
4035
|
+
_cmd(e, t, n, r, i) {
|
|
4036
|
+
let o = null;
|
|
4037
|
+
for (let c in r)
|
|
4038
|
+
Object.prototype.hasOwnProperty.call(r, c) && (o = this.encode_openc3_type(r[c]), o !== null && (r[c] = o));
|
|
4039
|
+
return this.exec(
|
|
4040
|
+
e,
|
|
4041
|
+
[t, n, r],
|
|
4042
|
+
{},
|
|
4043
|
+
i
|
|
4044
|
+
);
|
|
4045
|
+
}
|
|
4046
|
+
get_cmd_hazardous(e, t, n, r = {}) {
|
|
4047
|
+
return t === void 0 ? this.exec("get_cmd_hazardous", e, {}, r) : this._cmd(
|
|
4048
|
+
"get_cmd_hazardous",
|
|
4049
|
+
e,
|
|
4050
|
+
t,
|
|
4051
|
+
n,
|
|
4052
|
+
r
|
|
4053
|
+
);
|
|
4054
|
+
}
|
|
4055
|
+
cmd(e, t, n, r = {}) {
|
|
4056
|
+
return t === void 0 ? this.exec("cmd", e, {}, r) : this._cmd(
|
|
4057
|
+
"cmd",
|
|
4058
|
+
e,
|
|
4059
|
+
t,
|
|
4060
|
+
n,
|
|
4061
|
+
r
|
|
4062
|
+
);
|
|
4063
|
+
}
|
|
4064
|
+
cmd_no_range_check(e, t, n, r = {}) {
|
|
4065
|
+
return t === void 0 ? this.exec("cmd_no_range_check", e, {}, r) : this._cmd(
|
|
4066
|
+
"cmd_no_range_check",
|
|
4067
|
+
e,
|
|
4068
|
+
t,
|
|
4069
|
+
n,
|
|
4070
|
+
r
|
|
4071
|
+
);
|
|
4072
|
+
}
|
|
4073
|
+
cmd_raw(e, t, n, r = {}) {
|
|
4074
|
+
return t === void 0 ? this.exec("cmd_raw", e, {}, r) : this._cmd(
|
|
4075
|
+
"cmd_raw",
|
|
4076
|
+
e,
|
|
4077
|
+
t,
|
|
4078
|
+
n,
|
|
4079
|
+
r
|
|
4080
|
+
);
|
|
4081
|
+
}
|
|
4082
|
+
cmd_raw_no_range_check(e, t, n, r = {}) {
|
|
4083
|
+
return t === void 0 ? this.exec("cmd_raw_no_range_check", e, {}, r) : this._cmd(
|
|
4084
|
+
"cmd_raw_no_range_check",
|
|
4085
|
+
e,
|
|
4086
|
+
t,
|
|
4087
|
+
n,
|
|
4088
|
+
r
|
|
4089
|
+
);
|
|
4090
|
+
}
|
|
4091
|
+
cmd_no_hazardous_check(e, t, n, r = {}) {
|
|
4092
|
+
return t === void 0 ? this.exec("cmd_no_hazardous_check", e, {}, r) : this._cmd(
|
|
4093
|
+
"cmd_no_hazardous_check",
|
|
4094
|
+
e,
|
|
4095
|
+
t,
|
|
4096
|
+
n,
|
|
4097
|
+
r
|
|
4098
|
+
);
|
|
4099
|
+
}
|
|
4100
|
+
cmd_no_checks(e, t, n, r = {}) {
|
|
4101
|
+
return t === void 0 ? this.exec("cmd_no_checks", e, {}, r) : this._cmd(
|
|
4102
|
+
"cmd_no_checks",
|
|
4103
|
+
e,
|
|
4104
|
+
t,
|
|
4105
|
+
n,
|
|
4106
|
+
r
|
|
4107
|
+
);
|
|
4108
|
+
}
|
|
4109
|
+
cmd_raw_no_hazardous_check(e, t, n, r = {}) {
|
|
4110
|
+
return t === void 0 ? this.exec(
|
|
4111
|
+
"cmd_raw_no_hazardous_check",
|
|
4112
|
+
e,
|
|
4113
|
+
{},
|
|
4114
|
+
r
|
|
4115
|
+
) : this._cmd(
|
|
4116
|
+
"cmd_raw_no_hazardous_check",
|
|
4117
|
+
e,
|
|
4118
|
+
t,
|
|
4119
|
+
n,
|
|
4120
|
+
r
|
|
4121
|
+
);
|
|
4122
|
+
}
|
|
4123
|
+
cmd_raw_no_checks(e, t, n, r = {}) {
|
|
4124
|
+
return t === void 0 ? this.exec("cmd_raw_no_checks", e, {}, r) : this._cmd(
|
|
4125
|
+
"cmd_raw_no_checks",
|
|
4126
|
+
e,
|
|
4127
|
+
t,
|
|
4128
|
+
n,
|
|
4129
|
+
r
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
build_cmd(e, t, n) {
|
|
4133
|
+
return t === void 0 ? this.exec("build_cmd", e) : this._cmd("build_cmd", e, t, n);
|
|
4134
|
+
}
|
|
4135
|
+
// DEPRECATED for build_cmd
|
|
4136
|
+
build_command(e, t, n) {
|
|
4137
|
+
return t === void 0 ? this.exec("build_cmd", e) : this._cmd("build_cmd", e, t, n);
|
|
4138
|
+
}
|
|
4139
|
+
get_interface_names() {
|
|
4140
|
+
return this.exec("get_interface_names", []);
|
|
4141
|
+
}
|
|
4142
|
+
send_raw(e, t) {
|
|
4143
|
+
return this.exec("send_raw", [e, t]);
|
|
4144
|
+
}
|
|
4145
|
+
list_configs(e) {
|
|
4146
|
+
return this.exec("list_configs", [e]);
|
|
4147
|
+
}
|
|
4148
|
+
load_config(e, t) {
|
|
4149
|
+
return this.exec("load_config", [e, t]);
|
|
4150
|
+
}
|
|
4151
|
+
save_config(e, t, n) {
|
|
4152
|
+
return this.exec("save_config", [e, t, n]);
|
|
4153
|
+
}
|
|
4154
|
+
delete_config(e, t) {
|
|
4155
|
+
return this.exec("delete_config", [e, t]);
|
|
4156
|
+
}
|
|
4157
|
+
enable_limits(e, t, n) {
|
|
4158
|
+
return this.exec("enable_limits", [e, t, n]);
|
|
4159
|
+
}
|
|
4160
|
+
disable_limits(e, t, n) {
|
|
4161
|
+
return this.exec("disable_limits", [e, t, n]);
|
|
4162
|
+
}
|
|
4163
|
+
get_out_of_limits() {
|
|
4164
|
+
return this.exec("get_out_of_limits", []);
|
|
4165
|
+
}
|
|
4166
|
+
get_overall_limits_state(e) {
|
|
4167
|
+
return this.exec("get_overall_limits_state", [e]);
|
|
4168
|
+
}
|
|
4169
|
+
list_settings() {
|
|
4170
|
+
return this.exec("list_settings", []);
|
|
4171
|
+
}
|
|
4172
|
+
get_all_settings() {
|
|
4173
|
+
return this.exec("get_all_settings", []);
|
|
4174
|
+
}
|
|
4175
|
+
get_setting(e) {
|
|
4176
|
+
return this.exec("get_setting", [e]);
|
|
4177
|
+
}
|
|
4178
|
+
get_settings(e) {
|
|
4179
|
+
return this.exec("get_settings", e);
|
|
4180
|
+
}
|
|
4181
|
+
set_setting(e, t) {
|
|
4182
|
+
return this.exec("set_setting", [e, t]);
|
|
4183
|
+
}
|
|
4184
|
+
update_news() {
|
|
4185
|
+
return this.exec("update_news", []);
|
|
4186
|
+
}
|
|
4187
|
+
// DEPRECATED for set_setting
|
|
4188
|
+
save_setting(e, t) {
|
|
4189
|
+
return this.exec("set_setting", [e, t]);
|
|
4190
|
+
}
|
|
4191
|
+
get_metrics() {
|
|
4192
|
+
return this.exec("get_metrics", []);
|
|
4193
|
+
}
|
|
4194
|
+
// TODO: Currently unused but seemed like a useful function
|
|
4195
|
+
async hashString(e) {
|
|
4196
|
+
if (window.isSecureContext) {
|
|
4197
|
+
const t = new TextEncoder().encode(e), n = await crypto.subtle.digest(
|
|
4198
|
+
"SHA-256",
|
|
4199
|
+
t
|
|
4200
|
+
), r = new Uint8Array(n);
|
|
4201
|
+
return Array.from(r).map((i) => i.toString(16).padStart(2, "0")).join("");
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
4205
|
+
export {
|
|
4206
|
+
oi as Api,
|
|
4207
|
+
li as Cable,
|
|
4208
|
+
at as ConfigParserError,
|
|
4209
|
+
ui as ConfigParserService,
|
|
4210
|
+
hi as OpenC3Api,
|
|
4211
|
+
Ue as axios
|
|
4212
|
+
};
|
|
4213
|
+
//# sourceMappingURL=services.js.map
|