@ztimson/momentum 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +8 -6
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +322 -259
- package/dist/index.mjs +322 -259
- package/package.json +7 -9
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
function
|
|
4
|
+
var et = Object.defineProperty;
|
|
5
|
+
var nt = (n, t, e) => t in n ? et(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
|
|
6
|
+
var i = (n, t, e) => (nt(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
7
|
+
function rt(n, t = false) {
|
|
8
8
|
if (n == null)
|
|
9
9
|
throw new Error("Cannot clean a NULL value");
|
|
10
|
-
return Array.isArray(n) ? n = n.filter((
|
|
11
|
-
(
|
|
10
|
+
return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
|
|
11
|
+
(t && r === void 0 || !t && r == null) && delete n[e];
|
|
12
12
|
}), n;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
return
|
|
14
|
+
function B(n, t) {
|
|
15
|
+
const e = typeof n, r = typeof t;
|
|
16
|
+
return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => B(n[s], t[s]));
|
|
17
17
|
}
|
|
18
18
|
function q(n) {
|
|
19
19
|
try {
|
|
@@ -22,248 +22,311 @@ function q(n) {
|
|
|
22
22
|
return n;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
class
|
|
26
|
-
constructor(
|
|
27
|
-
super((r, o) =>
|
|
25
|
+
class m extends Promise {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super((r, o) => e(
|
|
28
28
|
(s) => r(s),
|
|
29
29
|
(s) => o(s),
|
|
30
30
|
(s) => this.progress = s
|
|
31
31
|
));
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
i(this, "listeners", []);
|
|
33
|
+
i(this, "_progress", 0);
|
|
34
34
|
}
|
|
35
35
|
get progress() {
|
|
36
36
|
return this._progress;
|
|
37
37
|
}
|
|
38
|
-
set progress(
|
|
39
|
-
|
|
38
|
+
set progress(e) {
|
|
39
|
+
e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
|
|
40
40
|
}
|
|
41
|
-
static from(
|
|
42
|
-
return
|
|
41
|
+
static from(e) {
|
|
42
|
+
return e instanceof m ? e : new m((r, o) => e.then((...s) => r(...s)).catch((...s) => o(...s)));
|
|
43
43
|
}
|
|
44
|
-
from(
|
|
45
|
-
const r =
|
|
44
|
+
from(e) {
|
|
45
|
+
const r = m.from(e);
|
|
46
46
|
return this.onProgress((o) => r.progress = o), r;
|
|
47
47
|
}
|
|
48
|
-
onProgress(
|
|
49
|
-
return this.listeners.push(
|
|
48
|
+
onProgress(e) {
|
|
49
|
+
return this.listeners.push(e), this;
|
|
50
50
|
}
|
|
51
|
-
then(
|
|
52
|
-
const o = super.then(
|
|
51
|
+
then(e, r) {
|
|
52
|
+
const o = super.then(e, r);
|
|
53
53
|
return this.from(o);
|
|
54
54
|
}
|
|
55
|
-
catch(
|
|
56
|
-
return this.from(super.catch(
|
|
55
|
+
catch(e) {
|
|
56
|
+
return this.from(super.catch(e));
|
|
57
57
|
}
|
|
58
|
-
finally(
|
|
59
|
-
return this.from(super.finally(
|
|
58
|
+
finally(e) {
|
|
59
|
+
return this.from(super.finally(e));
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
function ut(n, t) {
|
|
63
|
+
const e = document.createElement("a");
|
|
64
|
+
e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
|
|
66
|
+
function Tt(n, t) {
|
|
67
|
+
const e = URL.createObjectURL(n);
|
|
68
|
+
ut(e, t), URL.revokeObjectURL(e);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return new Promise((
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}, document.body.appendChild(
|
|
70
|
+
function It(n = {}) {
|
|
71
|
+
return new Promise((t) => {
|
|
72
|
+
const e = document.createElement("input");
|
|
73
|
+
e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
|
|
74
|
+
t(Array.from(e.files)), e.remove();
|
|
75
|
+
}, document.body.appendChild(e), e.click();
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return new
|
|
78
|
+
function $t(n) {
|
|
79
|
+
return new m((t, e, r) => {
|
|
80
80
|
const o = new XMLHttpRequest(), s = new FormData();
|
|
81
|
-
n.files.forEach((
|
|
81
|
+
n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(q(o.responseText))), o.addEventListener("error", () => e(q(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class v {
|
|
85
85
|
constructor() {
|
|
86
|
-
|
|
86
|
+
i(this, "listeners", {});
|
|
87
87
|
}
|
|
88
|
-
static emit(
|
|
89
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
88
|
+
static emit(t, ...e) {
|
|
89
|
+
(this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t.toString()] || []).forEach((r) => r(...e));
|
|
90
90
|
}
|
|
91
|
-
static off(
|
|
92
|
-
const r =
|
|
93
|
-
this.listeners[r] = (this.listeners[r] || []).filter((o) => o ===
|
|
91
|
+
static off(t, e) {
|
|
92
|
+
const r = t.toString();
|
|
93
|
+
this.listeners[r] = (this.listeners[r] || []).filter((o) => o === e);
|
|
94
94
|
}
|
|
95
|
-
static on(
|
|
95
|
+
static on(t, e) {
|
|
96
96
|
var o;
|
|
97
|
-
const r =
|
|
98
|
-
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(
|
|
97
|
+
const r = t.toString();
|
|
98
|
+
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(e), () => this.off(t, e);
|
|
99
99
|
}
|
|
100
|
-
static once(
|
|
100
|
+
static once(t, e) {
|
|
101
101
|
return new Promise((r) => {
|
|
102
|
-
const o = this.on(
|
|
103
|
-
r(s.length == 1 ? s[0] : s),
|
|
102
|
+
const o = this.on(t, (...s) => {
|
|
103
|
+
r(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
emit(
|
|
108
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
107
|
+
emit(t, ...e) {
|
|
108
|
+
(this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t] || []).forEach((r) => r(...e));
|
|
109
109
|
}
|
|
110
|
-
off(
|
|
111
|
-
this.listeners[
|
|
110
|
+
off(t, e) {
|
|
111
|
+
this.listeners[t] = (this.listeners[t] || []).filter((r) => r === e);
|
|
112
112
|
}
|
|
113
|
-
on(
|
|
113
|
+
on(t, e) {
|
|
114
114
|
var r;
|
|
115
|
-
return this.listeners[
|
|
115
|
+
return this.listeners[t] || (this.listeners[t] = []), (r = this.listeners[t]) == null || r.push(e), () => this.off(t, e);
|
|
116
116
|
}
|
|
117
|
-
once(
|
|
117
|
+
once(t, e) {
|
|
118
118
|
return new Promise((r) => {
|
|
119
|
-
const o = this.on(
|
|
120
|
-
r(s.length == 1 ? s[0] : s),
|
|
119
|
+
const o = this.on(t, (...s) => {
|
|
120
|
+
r(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
class
|
|
127
|
-
constructor(
|
|
128
|
-
super(
|
|
129
|
-
|
|
125
|
+
i(v, "listeners", {});
|
|
126
|
+
class p extends Error {
|
|
127
|
+
constructor(e, r) {
|
|
128
|
+
super(e);
|
|
129
|
+
i(this, "_code");
|
|
130
130
|
r != null && (this._code = r);
|
|
131
131
|
}
|
|
132
132
|
get code() {
|
|
133
133
|
return this._code || this.constructor.code;
|
|
134
134
|
}
|
|
135
|
-
set code(
|
|
136
|
-
this._code =
|
|
135
|
+
set code(e) {
|
|
136
|
+
this._code = e;
|
|
137
137
|
}
|
|
138
|
-
static from(
|
|
139
|
-
const r = Number(
|
|
138
|
+
static from(e) {
|
|
139
|
+
const r = Number(e.statusCode) ?? Number(e.code), o = new this(e.message || e.toString());
|
|
140
140
|
return Object.assign(o, {
|
|
141
|
-
stack:
|
|
142
|
-
...
|
|
141
|
+
stack: e.stack,
|
|
142
|
+
...e,
|
|
143
143
|
code: r ?? void 0
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
static instanceof(
|
|
147
|
-
return
|
|
146
|
+
static instanceof(e) {
|
|
147
|
+
return e.constructor.code != null;
|
|
148
148
|
}
|
|
149
149
|
toString() {
|
|
150
150
|
return this.message || super.toString();
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
class
|
|
155
|
-
constructor(
|
|
156
|
-
super(
|
|
153
|
+
i(p, "code", 500);
|
|
154
|
+
class F extends p {
|
|
155
|
+
constructor(t = "Bad Request") {
|
|
156
|
+
super(t);
|
|
157
157
|
}
|
|
158
|
-
static instanceof(
|
|
159
|
-
return
|
|
158
|
+
static instanceof(t) {
|
|
159
|
+
return t.constructor.code == this.code;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
163
|
-
class
|
|
164
|
-
constructor(
|
|
165
|
-
super(
|
|
162
|
+
i(F, "code", 400);
|
|
163
|
+
class H extends p {
|
|
164
|
+
constructor(t = "Unauthorized") {
|
|
165
|
+
super(t);
|
|
166
166
|
}
|
|
167
|
-
static instanceof(
|
|
168
|
-
return
|
|
167
|
+
static instanceof(t) {
|
|
168
|
+
return t.constructor.code == this.code;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
class
|
|
173
|
-
constructor(
|
|
174
|
-
super(
|
|
171
|
+
i(H, "code", 401);
|
|
172
|
+
class Y extends p {
|
|
173
|
+
constructor(t = "Payment Required") {
|
|
174
|
+
super(t);
|
|
175
175
|
}
|
|
176
|
-
static instanceof(
|
|
177
|
-
return
|
|
176
|
+
static instanceof(t) {
|
|
177
|
+
return t.constructor.code == this.code;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
class
|
|
182
|
-
constructor(
|
|
183
|
-
super(
|
|
180
|
+
i(Y, "code", 402);
|
|
181
|
+
class W extends p {
|
|
182
|
+
constructor(t = "Forbidden") {
|
|
183
|
+
super(t);
|
|
184
184
|
}
|
|
185
|
-
static instanceof(
|
|
186
|
-
return
|
|
185
|
+
static instanceof(t) {
|
|
186
|
+
return t.constructor.code == this.code;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
|
|
190
|
-
class
|
|
191
|
-
constructor(
|
|
192
|
-
super(
|
|
189
|
+
i(W, "code", 403);
|
|
190
|
+
class J extends p {
|
|
191
|
+
constructor(t = "Not Found") {
|
|
192
|
+
super(t);
|
|
193
193
|
}
|
|
194
|
-
static instanceof(
|
|
195
|
-
return
|
|
194
|
+
static instanceof(t) {
|
|
195
|
+
return t.constructor.code == this.code;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
i(J, "code", 404);
|
|
199
|
+
class z extends p {
|
|
200
|
+
constructor(t = "Method Not Allowed") {
|
|
201
|
+
super(t);
|
|
202
|
+
}
|
|
203
|
+
static instanceof(t) {
|
|
204
|
+
return t.constructor.code == this.code;
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
constructor(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
i(z, "code", 405);
|
|
208
|
+
class K extends p {
|
|
209
|
+
constructor(t = "Not Acceptable") {
|
|
210
|
+
super(t);
|
|
211
|
+
}
|
|
212
|
+
static instanceof(t) {
|
|
213
|
+
return t.constructor.code == this.code;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
i(K, "code", 406);
|
|
217
|
+
class V extends p {
|
|
218
|
+
constructor(t = "Internal Server Error") {
|
|
219
|
+
super(t);
|
|
220
|
+
}
|
|
221
|
+
static instanceof(t) {
|
|
222
|
+
return t.constructor.code == this.code;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
i(V, "code", 500);
|
|
226
|
+
class Z extends p {
|
|
227
|
+
constructor(t = "Not Implemented") {
|
|
228
|
+
super(t);
|
|
229
|
+
}
|
|
230
|
+
static instanceof(t) {
|
|
231
|
+
return t.constructor.code == this.code;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
i(Z, "code", 501);
|
|
235
|
+
class X extends p {
|
|
236
|
+
constructor(t = "Bad Gateway") {
|
|
237
|
+
super(t);
|
|
238
|
+
}
|
|
239
|
+
static instanceof(t) {
|
|
240
|
+
return t.constructor.code == this.code;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
i(X, "code", 502);
|
|
244
|
+
class Q extends p {
|
|
245
|
+
constructor(t = "Service Unavailable") {
|
|
246
|
+
super(t);
|
|
247
|
+
}
|
|
248
|
+
static instanceof(t) {
|
|
249
|
+
return t.constructor.code == this.code;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
i(Q, "code", 503);
|
|
253
|
+
class _ extends p {
|
|
254
|
+
constructor(t = "Gateway Timeout") {
|
|
255
|
+
super(t);
|
|
256
|
+
}
|
|
257
|
+
static instanceof(t) {
|
|
258
|
+
return t.constructor.code == this.code;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
i(_, "code", 504);
|
|
262
|
+
const w = class w2 {
|
|
263
|
+
constructor(t = {}) {
|
|
264
|
+
i(this, "interceptors", {});
|
|
265
|
+
i(this, "headers", {});
|
|
266
|
+
i(this, "url");
|
|
267
|
+
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
|
|
268
|
+
}
|
|
269
|
+
static addInterceptor(t) {
|
|
270
|
+
const e = Object.keys(w2.interceptors).length.toString();
|
|
271
|
+
return w2.interceptors[e] = t, () => {
|
|
272
|
+
w2.interceptors[e] = null;
|
|
210
273
|
};
|
|
211
274
|
}
|
|
212
|
-
addInterceptor(
|
|
213
|
-
const
|
|
214
|
-
return this.interceptors[
|
|
215
|
-
this.interceptors[
|
|
275
|
+
addInterceptor(t) {
|
|
276
|
+
const e = Object.keys(this.interceptors).length.toString();
|
|
277
|
+
return this.interceptors[e] = t, () => {
|
|
278
|
+
this.interceptors[e] = null;
|
|
216
279
|
};
|
|
217
280
|
}
|
|
218
|
-
request(
|
|
281
|
+
request(t = {}) {
|
|
219
282
|
var o;
|
|
220
|
-
if (!this.url && !
|
|
283
|
+
if (!this.url && !t.url)
|
|
221
284
|
throw new Error("URL needs to be set");
|
|
222
|
-
let
|
|
223
|
-
if (
|
|
224
|
-
const s = Array.isArray(
|
|
225
|
-
|
|
285
|
+
let e = ((o = t.url) != null && o.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
286
|
+
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s, c) => `#${t.fragment}${c}`) : e += "#" + t.fragment), t.query) {
|
|
287
|
+
const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
|
|
288
|
+
e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
|
|
226
289
|
}
|
|
227
|
-
const r =
|
|
228
|
-
"Content-Type":
|
|
229
|
-
...
|
|
290
|
+
const r = rt({
|
|
291
|
+
"Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
|
|
292
|
+
...w2.headers,
|
|
230
293
|
...this.headers,
|
|
231
|
-
...
|
|
294
|
+
...t.headers
|
|
232
295
|
});
|
|
233
|
-
return typeof
|
|
234
|
-
fetch(
|
|
296
|
+
return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new m((s, c, y) => {
|
|
297
|
+
fetch(e, {
|
|
235
298
|
headers: r,
|
|
236
|
-
method:
|
|
237
|
-
body:
|
|
238
|
-
}).then(async (
|
|
299
|
+
method: t.method || (t.body ? "POST" : "GET"),
|
|
300
|
+
body: t.body
|
|
301
|
+
}).then(async (u) => {
|
|
239
302
|
var j, G;
|
|
240
|
-
for (let
|
|
241
|
-
await new Promise((O) => u
|
|
242
|
-
const R =
|
|
303
|
+
for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
|
|
304
|
+
await new Promise((O) => a(u, () => O()));
|
|
305
|
+
const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
|
|
243
306
|
let k = 0;
|
|
244
|
-
const T = (j =
|
|
245
|
-
start(
|
|
307
|
+
const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
|
|
308
|
+
start(a) {
|
|
246
309
|
function O() {
|
|
247
310
|
T == null || T.read().then((x) => {
|
|
248
311
|
if (x.done)
|
|
249
|
-
return
|
|
250
|
-
k += x.value.byteLength,
|
|
251
|
-
}).catch((x) =>
|
|
312
|
+
return a.close();
|
|
313
|
+
k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
|
|
314
|
+
}).catch((x) => a.error(x));
|
|
252
315
|
}
|
|
253
316
|
O();
|
|
254
317
|
}
|
|
255
318
|
});
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
258
|
-
|
|
319
|
+
if (u.data = new Response(tt), t.decode == null || t.decode) {
|
|
320
|
+
const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
|
|
321
|
+
a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
|
|
259
322
|
}
|
|
260
|
-
|
|
323
|
+
u.ok ? s(u) : c(u);
|
|
261
324
|
});
|
|
262
325
|
});
|
|
263
326
|
}
|
|
264
327
|
};
|
|
265
|
-
|
|
266
|
-
let M =
|
|
328
|
+
i(w, "interceptors", {}), i(w, "headers", {});
|
|
329
|
+
let M = w;
|
|
267
330
|
const A = {
|
|
268
331
|
CLEAR: "\x1B[0m",
|
|
269
332
|
BRIGHT: "\x1B[1m",
|
|
@@ -290,59 +353,59 @@ const A = {
|
|
|
290
353
|
LIGHT_CYAN: "\x1B[96m",
|
|
291
354
|
WHITE: "\x1B[97m"
|
|
292
355
|
};
|
|
293
|
-
var
|
|
294
|
-
const
|
|
295
|
-
constructor(
|
|
296
|
-
super(), this.namespace =
|
|
356
|
+
var at = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(at || {});
|
|
357
|
+
const g = class g2 extends v {
|
|
358
|
+
constructor(t) {
|
|
359
|
+
super(), this.namespace = t;
|
|
297
360
|
}
|
|
298
|
-
pad(
|
|
299
|
-
const s =
|
|
300
|
-
if (
|
|
361
|
+
pad(t, e, r, o = false) {
|
|
362
|
+
const s = t.toString(), c = e - s.length;
|
|
363
|
+
if (c <= 0)
|
|
301
364
|
return s;
|
|
302
|
-
const
|
|
303
|
-
return o ? s +
|
|
365
|
+
const y = Array(~~(c / r.length)).fill(r).join("");
|
|
366
|
+
return o ? s + y : y + s;
|
|
304
367
|
}
|
|
305
|
-
format(...
|
|
306
|
-
const
|
|
307
|
-
return `${`${
|
|
368
|
+
format(...t) {
|
|
369
|
+
const e = /* @__PURE__ */ new Date();
|
|
370
|
+
return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
|
|
308
371
|
}
|
|
309
|
-
debug(...
|
|
310
|
-
if (
|
|
372
|
+
debug(...t) {
|
|
373
|
+
if (g2.LOG_LEVEL < 4)
|
|
311
374
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
375
|
+
const e = this.format(...t);
|
|
376
|
+
g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
|
|
314
377
|
}
|
|
315
|
-
log(...
|
|
316
|
-
if (
|
|
378
|
+
log(...t) {
|
|
379
|
+
if (g2.LOG_LEVEL < 3)
|
|
317
380
|
return;
|
|
318
|
-
const
|
|
319
|
-
|
|
381
|
+
const e = this.format(...t);
|
|
382
|
+
g2.emit(3, e), console.log(A.CLEAR + e);
|
|
320
383
|
}
|
|
321
|
-
info(...
|
|
322
|
-
if (
|
|
384
|
+
info(...t) {
|
|
385
|
+
if (g2.LOG_LEVEL < 2)
|
|
323
386
|
return;
|
|
324
|
-
const
|
|
325
|
-
|
|
387
|
+
const e = this.format(...t);
|
|
388
|
+
g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
|
|
326
389
|
}
|
|
327
|
-
warn(...
|
|
328
|
-
if (
|
|
390
|
+
warn(...t) {
|
|
391
|
+
if (g2.LOG_LEVEL < 1)
|
|
329
392
|
return;
|
|
330
|
-
const
|
|
331
|
-
|
|
393
|
+
const e = this.format(...t);
|
|
394
|
+
g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
|
|
332
395
|
}
|
|
333
|
-
error(...
|
|
334
|
-
if (
|
|
396
|
+
error(...t) {
|
|
397
|
+
if (g2.LOG_LEVEL < 0)
|
|
335
398
|
return;
|
|
336
|
-
const
|
|
337
|
-
|
|
399
|
+
const e = this.format(...t);
|
|
400
|
+
g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
|
|
338
401
|
}
|
|
339
402
|
};
|
|
340
|
-
|
|
403
|
+
i(g, "LOG_LEVEL", 4);
|
|
341
404
|
class Api extends M {
|
|
342
405
|
constructor(url = location.origin, opts = {}) {
|
|
343
406
|
opts.url = url;
|
|
344
407
|
super(opts);
|
|
345
|
-
__publicField(this, "emitter", new
|
|
408
|
+
__publicField(this, "emitter", new v());
|
|
346
409
|
__publicField(this, "_token", null);
|
|
347
410
|
__publicField(this, "emit", this.emitter.emit.bind(this.emitter));
|
|
348
411
|
__publicField(this, "off", this.emitter.off.bind(this.emitter));
|
|
@@ -376,45 +439,45 @@ class Api extends M {
|
|
|
376
439
|
return req;
|
|
377
440
|
}
|
|
378
441
|
}
|
|
379
|
-
var extendStatics = function(d,
|
|
380
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2,
|
|
381
|
-
d2.__proto__ =
|
|
382
|
-
} || function(d2,
|
|
383
|
-
for (var
|
|
442
|
+
var extendStatics = function(d, b) {
|
|
443
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
444
|
+
d2.__proto__ = b2;
|
|
445
|
+
} || function(d2, b2) {
|
|
446
|
+
for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
|
|
384
447
|
};
|
|
385
|
-
return extendStatics(d,
|
|
448
|
+
return extendStatics(d, b);
|
|
386
449
|
};
|
|
387
|
-
function __extends(d,
|
|
388
|
-
if (typeof
|
|
389
|
-
throw new TypeError("Class extends value " + String(
|
|
390
|
-
extendStatics(d,
|
|
450
|
+
function __extends(d, b) {
|
|
451
|
+
if (typeof b !== "function" && b !== null)
|
|
452
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
453
|
+
extendStatics(d, b);
|
|
391
454
|
function __() {
|
|
392
455
|
this.constructor = d;
|
|
393
456
|
}
|
|
394
|
-
d.prototype =
|
|
457
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
395
458
|
}
|
|
396
459
|
function __values(o) {
|
|
397
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
398
|
-
if (
|
|
460
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
|
|
461
|
+
if (m2) return m2.call(o);
|
|
399
462
|
if (o && typeof o.length === "number") return {
|
|
400
463
|
next: function() {
|
|
401
|
-
if (o &&
|
|
402
|
-
return { value: o && o[
|
|
464
|
+
if (o && i2 >= o.length) o = void 0;
|
|
465
|
+
return { value: o && o[i2++], done: !o };
|
|
403
466
|
}
|
|
404
467
|
};
|
|
405
468
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
406
469
|
}
|
|
407
470
|
function __read(o, n) {
|
|
408
|
-
var
|
|
409
|
-
if (!
|
|
410
|
-
var
|
|
471
|
+
var m2 = typeof Symbol === "function" && o[Symbol.iterator];
|
|
472
|
+
if (!m2) return o;
|
|
473
|
+
var i2 = m2.call(o), r, ar = [], e;
|
|
411
474
|
try {
|
|
412
|
-
while ((n === void 0 || n-- > 0) && !(r =
|
|
475
|
+
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done) ar.push(r.value);
|
|
413
476
|
} catch (error) {
|
|
414
477
|
e = { error };
|
|
415
478
|
} finally {
|
|
416
479
|
try {
|
|
417
|
-
if (r && !r.done && (
|
|
480
|
+
if (r && !r.done && (m2 = i2["return"])) m2.call(i2);
|
|
418
481
|
} finally {
|
|
419
482
|
if (e) throw e.error;
|
|
420
483
|
}
|
|
@@ -422,10 +485,10 @@ function __read(o, n) {
|
|
|
422
485
|
return ar;
|
|
423
486
|
}
|
|
424
487
|
function __spreadArray(to, from, pack) {
|
|
425
|
-
if (pack || arguments.length === 2) for (var
|
|
426
|
-
if (ar || !(
|
|
427
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0,
|
|
428
|
-
ar[
|
|
488
|
+
if (pack || arguments.length === 2) for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
489
|
+
if (ar || !(i2 in from)) {
|
|
490
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i2);
|
|
491
|
+
ar[i2] = from[i2];
|
|
429
492
|
}
|
|
430
493
|
}
|
|
431
494
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
@@ -450,8 +513,8 @@ function createErrorClass(createImpl) {
|
|
|
450
513
|
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
451
514
|
return function UnsubscriptionErrorImpl(errors) {
|
|
452
515
|
_super(this);
|
|
453
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err,
|
|
454
|
-
return
|
|
516
|
+
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i2) {
|
|
517
|
+
return i2 + 1 + ") " + err.toString();
|
|
455
518
|
}).join("\n ") : "";
|
|
456
519
|
this.name = "UnsubscriptionError";
|
|
457
520
|
this.errors = errors;
|
|
@@ -1092,7 +1155,7 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
|
1092
1155
|
ActionType2[ActionType2["PUT"] = 6] = "PUT";
|
|
1093
1156
|
return ActionType2;
|
|
1094
1157
|
})(ActionType || {});
|
|
1095
|
-
class Actions extends
|
|
1158
|
+
class Actions extends v {
|
|
1096
1159
|
constructor(api) {
|
|
1097
1160
|
super();
|
|
1098
1161
|
__publicField(this, "api");
|
|
@@ -1107,7 +1170,7 @@ class Actions extends H {
|
|
|
1107
1170
|
}
|
|
1108
1171
|
delete(id) {
|
|
1109
1172
|
return this.api.request({ url: `/api/actions/${id}`, method: "DELETE" }).then(() => {
|
|
1110
|
-
this.cache = this.cache.filter((
|
|
1173
|
+
this.cache = this.cache.filter((a) => a._id != id);
|
|
1111
1174
|
this.emit("DELETE", id);
|
|
1112
1175
|
});
|
|
1113
1176
|
}
|
|
@@ -1119,10 +1182,10 @@ class Actions extends H {
|
|
|
1119
1182
|
});
|
|
1120
1183
|
}
|
|
1121
1184
|
read(id, reload = false) {
|
|
1122
|
-
const cached = this.cache.find((
|
|
1185
|
+
const cached = this.cache.find((a) => a._id == id);
|
|
1123
1186
|
if (!reload && cached) return Promise.resolve(cached);
|
|
1124
1187
|
return this.api.request({ url: `/api/actions/${id}` }).then((action) => {
|
|
1125
|
-
if (action) this.cache = this.cache.filter((
|
|
1188
|
+
if (action) this.cache = this.cache.filter((a) => a._id != id).concat([action]);
|
|
1126
1189
|
this.emit("READ", action);
|
|
1127
1190
|
return action;
|
|
1128
1191
|
});
|
|
@@ -1140,13 +1203,13 @@ class Actions extends H {
|
|
|
1140
1203
|
method: "POST",
|
|
1141
1204
|
body: action
|
|
1142
1205
|
}).then((action2) => {
|
|
1143
|
-
if (action2) this.cache = this.cache.filter((
|
|
1206
|
+
if (action2) this.cache = this.cache.filter((a) => a._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
|
|
1144
1207
|
this.emit("UPDATE", action2);
|
|
1145
1208
|
return action2;
|
|
1146
1209
|
});
|
|
1147
1210
|
}
|
|
1148
1211
|
}
|
|
1149
|
-
class Ai extends
|
|
1212
|
+
class Ai extends v {
|
|
1150
1213
|
constructor(api) {
|
|
1151
1214
|
super();
|
|
1152
1215
|
__publicField(this, "api");
|
|
@@ -1162,7 +1225,7 @@ class Ai extends H {
|
|
|
1162
1225
|
});
|
|
1163
1226
|
}
|
|
1164
1227
|
}
|
|
1165
|
-
class Analytics extends
|
|
1228
|
+
class Analytics extends v {
|
|
1166
1229
|
constructor(api) {
|
|
1167
1230
|
super();
|
|
1168
1231
|
__publicField(this, "api");
|
|
@@ -1187,13 +1250,13 @@ class Totp {
|
|
|
1187
1250
|
return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
|
|
1188
1251
|
}
|
|
1189
1252
|
setup(username, method = "app", totp) {
|
|
1190
|
-
return this.api.request({ url: `/api/auth/totp/${username}`, body:
|
|
1253
|
+
return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
|
|
1191
1254
|
method,
|
|
1192
1255
|
totp
|
|
1193
1256
|
}) });
|
|
1194
1257
|
}
|
|
1195
1258
|
}
|
|
1196
|
-
class Auth extends
|
|
1259
|
+
class Auth extends v {
|
|
1197
1260
|
constructor(api, opts) {
|
|
1198
1261
|
var _a;
|
|
1199
1262
|
super();
|
|
@@ -1238,7 +1301,7 @@ class Auth extends H {
|
|
|
1238
1301
|
return this.$user.value;
|
|
1239
1302
|
}
|
|
1240
1303
|
set user(user) {
|
|
1241
|
-
if (!
|
|
1304
|
+
if (!B(this.user, user)) {
|
|
1242
1305
|
const u = user ? user : null;
|
|
1243
1306
|
this.$user.next(u);
|
|
1244
1307
|
this.emit("USER", u);
|
|
@@ -1324,7 +1387,7 @@ class Auth extends H {
|
|
|
1324
1387
|
});
|
|
1325
1388
|
}
|
|
1326
1389
|
}
|
|
1327
|
-
class Data extends
|
|
1390
|
+
class Data extends v {
|
|
1328
1391
|
constructor(api) {
|
|
1329
1392
|
super();
|
|
1330
1393
|
__publicField(this, "api");
|
|
@@ -1369,7 +1432,7 @@ class Data extends H {
|
|
|
1369
1432
|
});
|
|
1370
1433
|
}
|
|
1371
1434
|
}
|
|
1372
|
-
class Email extends
|
|
1435
|
+
class Email extends v {
|
|
1373
1436
|
constructor(api) {
|
|
1374
1437
|
super();
|
|
1375
1438
|
__publicField(this, "api");
|
|
@@ -1384,7 +1447,7 @@ class Email extends H {
|
|
|
1384
1447
|
});
|
|
1385
1448
|
}
|
|
1386
1449
|
}
|
|
1387
|
-
class Groups extends
|
|
1450
|
+
class Groups extends v {
|
|
1388
1451
|
constructor(api) {
|
|
1389
1452
|
super();
|
|
1390
1453
|
__publicField(this, "api");
|
|
@@ -1466,32 +1529,32 @@ class Logger {
|
|
|
1466
1529
|
return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
|
|
1467
1530
|
}
|
|
1468
1531
|
debug(...logs) {
|
|
1469
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1532
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
|
|
1470
1533
|
}).catch(() => {
|
|
1471
1534
|
});
|
|
1472
1535
|
}
|
|
1473
1536
|
log(...logs) {
|
|
1474
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1537
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
|
|
1475
1538
|
}).catch(() => {
|
|
1476
1539
|
});
|
|
1477
1540
|
}
|
|
1478
1541
|
info(...logs) {
|
|
1479
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1542
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
|
|
1480
1543
|
}).catch(() => {
|
|
1481
1544
|
});
|
|
1482
1545
|
}
|
|
1483
1546
|
warn(...logs) {
|
|
1484
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1547
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
|
|
1485
1548
|
}).catch(() => {
|
|
1486
1549
|
});
|
|
1487
1550
|
}
|
|
1488
1551
|
error(...logs) {
|
|
1489
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1552
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
|
|
1490
1553
|
}).catch(() => {
|
|
1491
1554
|
});
|
|
1492
1555
|
}
|
|
1493
1556
|
}
|
|
1494
|
-
class Payments extends
|
|
1557
|
+
class Payments extends v {
|
|
1495
1558
|
constructor(api, secret) {
|
|
1496
1559
|
super();
|
|
1497
1560
|
__publicField(this, "api");
|
|
@@ -1532,7 +1595,7 @@ class Payments extends H {
|
|
|
1532
1595
|
return history;
|
|
1533
1596
|
}
|
|
1534
1597
|
}
|
|
1535
|
-
class Pdf extends
|
|
1598
|
+
class Pdf extends v {
|
|
1536
1599
|
constructor(api) {
|
|
1537
1600
|
super();
|
|
1538
1601
|
__publicField(this, "api");
|
|
@@ -1542,20 +1605,20 @@ class Pdf extends H {
|
|
|
1542
1605
|
const blob = await resp.blob();
|
|
1543
1606
|
if (fileName) {
|
|
1544
1607
|
const url = URL.createObjectURL(blob);
|
|
1545
|
-
|
|
1608
|
+
ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
|
|
1546
1609
|
URL.revokeObjectURL(url);
|
|
1547
1610
|
}
|
|
1548
1611
|
this.emit("CREATE", blob);
|
|
1549
1612
|
return blob;
|
|
1550
1613
|
}
|
|
1551
1614
|
fromHtml(content, opts = {}) {
|
|
1552
|
-
return this.api.request({ url: `/api/pdf`, body: { html: content } }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1615
|
+
return this.api.request({ url: `/api/pdf`, body: { html: content }, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1553
1616
|
}
|
|
1554
1617
|
fromTemplate(template, data, opts = {}) {
|
|
1555
|
-
return this.api.request({ url: `/api/pdf${template}`, body: data }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1618
|
+
return this.api.request({ url: `/api/pdf${template}`, body: data, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1556
1619
|
}
|
|
1557
1620
|
fromUrl(url, opts = {}) {
|
|
1558
|
-
return this.api.request({ url: `/api/pdf
|
|
1621
|
+
return this.api.request({ url: `/api/pdf`, body: { url }, decode: false }).then((resp) => this.handleResponse(resp, opts.download ? opts.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1559
1622
|
}
|
|
1560
1623
|
}
|
|
1561
1624
|
const _Socket = class _Socket {
|
|
@@ -1605,7 +1668,7 @@ const _Socket = class _Socket {
|
|
|
1605
1668
|
};
|
|
1606
1669
|
__publicField(_Socket, "timeout", 1e4);
|
|
1607
1670
|
let Socket = _Socket;
|
|
1608
|
-
class Storage extends
|
|
1671
|
+
class Storage extends v {
|
|
1609
1672
|
constructor(api) {
|
|
1610
1673
|
super();
|
|
1611
1674
|
__publicField(this, "api");
|
|
@@ -1625,37 +1688,37 @@ class Storage extends H {
|
|
|
1625
1688
|
});
|
|
1626
1689
|
}
|
|
1627
1690
|
open(path, target = "_blank") {
|
|
1628
|
-
const
|
|
1629
|
-
const link = `${this.api.url}${
|
|
1691
|
+
const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
|
|
1692
|
+
const link = `${this.api.url}${p2}${this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1630
1693
|
if (!target) return link;
|
|
1631
1694
|
this.emit("OPEN", path);
|
|
1632
1695
|
return window.open(link, target);
|
|
1633
1696
|
}
|
|
1634
1697
|
mkdir(path) {
|
|
1635
|
-
const
|
|
1636
|
-
return this.api.request({ url:
|
|
1698
|
+
const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
|
|
1699
|
+
return this.api.request({ url: p2 + "?directory", method: "POST" });
|
|
1637
1700
|
}
|
|
1638
1701
|
download(path, opts = {}) {
|
|
1639
|
-
const
|
|
1640
|
-
return this.api.request({ ...opts, url:
|
|
1702
|
+
const p2 = ("/api/storage/" + path).replaceAll("//", "/");
|
|
1703
|
+
return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
|
|
1641
1704
|
const blob = await response.blob();
|
|
1642
1705
|
const name = opts.downloadAs || path.split("/").pop();
|
|
1643
1706
|
this.emit("DOWNLOAD", path, blob);
|
|
1644
|
-
|
|
1707
|
+
Tt(blob, name);
|
|
1645
1708
|
return response;
|
|
1646
1709
|
});
|
|
1647
1710
|
}
|
|
1648
1711
|
upload(files, opts = "") {
|
|
1649
|
-
return new
|
|
1650
|
-
if (!files) files = await
|
|
1712
|
+
return new m(async (res, rej, prog) => {
|
|
1713
|
+
if (!files) files = await It();
|
|
1651
1714
|
if (!files || Array.isArray(files) && !files.length) return [];
|
|
1652
1715
|
const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
|
|
1653
|
-
return
|
|
1716
|
+
return $t({
|
|
1654
1717
|
url,
|
|
1655
1718
|
files: Array.isArray(files) ? files : [files],
|
|
1656
1719
|
headers: this.api.headers
|
|
1657
|
-
}).onProgress((
|
|
1658
|
-
prog(
|
|
1720
|
+
}).onProgress((p2) => {
|
|
1721
|
+
prog(p2);
|
|
1659
1722
|
}).then((resp) => {
|
|
1660
1723
|
this.emit("UPLOAD", resp);
|
|
1661
1724
|
res(resp);
|
|
@@ -1867,7 +1930,7 @@ class UI {
|
|
|
1867
1930
|
}, 1e3);
|
|
1868
1931
|
}
|
|
1869
1932
|
}
|
|
1870
|
-
class Users extends
|
|
1933
|
+
class Users extends v {
|
|
1871
1934
|
constructor(api) {
|
|
1872
1935
|
super();
|
|
1873
1936
|
__publicField(this, "api");
|
|
@@ -1932,7 +1995,7 @@ class Users extends H {
|
|
|
1932
1995
|
});
|
|
1933
1996
|
}
|
|
1934
1997
|
uploadImage(username, file) {
|
|
1935
|
-
return
|
|
1998
|
+
return $t({
|
|
1936
1999
|
url: this.api.url + `/api/users/${username}/image`,
|
|
1937
2000
|
files: [file],
|
|
1938
2001
|
headers: this.api.headers
|
|
@@ -1942,7 +2005,7 @@ class Users extends H {
|
|
|
1942
2005
|
});
|
|
1943
2006
|
}
|
|
1944
2007
|
}
|
|
1945
|
-
class Settings extends
|
|
2008
|
+
class Settings extends v {
|
|
1946
2009
|
constructor(api) {
|
|
1947
2010
|
super();
|
|
1948
2011
|
__publicField(this, "api");
|
|
@@ -1984,7 +2047,7 @@ class Settings extends H {
|
|
|
1984
2047
|
});
|
|
1985
2048
|
}
|
|
1986
2049
|
}
|
|
1987
|
-
class Static extends
|
|
2050
|
+
class Static extends v {
|
|
1988
2051
|
constructor(api) {
|
|
1989
2052
|
super();
|
|
1990
2053
|
__publicField(this, "api");
|
|
@@ -2003,13 +2066,13 @@ class Static extends H {
|
|
|
2003
2066
|
});
|
|
2004
2067
|
}
|
|
2005
2068
|
upload(files, path = "/") {
|
|
2006
|
-
return new
|
|
2007
|
-
return
|
|
2069
|
+
return new m(async (res, rej, prog) => {
|
|
2070
|
+
return $t({
|
|
2008
2071
|
url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
|
|
2009
2072
|
files: Array.isArray(files) ? files : [files],
|
|
2010
2073
|
headers: this.api.headers
|
|
2011
|
-
}).onProgress((
|
|
2012
|
-
prog(
|
|
2074
|
+
}).onProgress((p2) => {
|
|
2075
|
+
prog(p2);
|
|
2013
2076
|
}).then((resp) => {
|
|
2014
2077
|
this.emit("UPLOAD", resp);
|
|
2015
2078
|
res(resp);
|
|
@@ -2017,7 +2080,7 @@ class Static extends H {
|
|
|
2017
2080
|
});
|
|
2018
2081
|
}
|
|
2019
2082
|
}
|
|
2020
|
-
class Momentum extends
|
|
2083
|
+
class Momentum extends v {
|
|
2021
2084
|
constructor(url, opts) {
|
|
2022
2085
|
super();
|
|
2023
2086
|
__publicField(this, "api");
|