@ztimson/momentum 0.32.0 → 0.33.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 +2 -0
- 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.cjs
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function
|
|
8
|
+
var et = Object.defineProperty;
|
|
9
|
+
var nt = (n, t, e) => t in n ? et(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
|
|
10
|
+
var i = (n, t, e) => (nt(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
11
|
+
function rt(n, t = false) {
|
|
12
12
|
if (n == null)
|
|
13
13
|
throw new Error("Cannot clean a NULL value");
|
|
14
|
-
return Array.isArray(n) ? n = n.filter((
|
|
15
|
-
(
|
|
14
|
+
return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
|
|
15
|
+
(t && r === void 0 || !t && r == null) && delete n[e];
|
|
16
16
|
}), n;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
return
|
|
18
|
+
function B(n, t) {
|
|
19
|
+
const e = typeof n, r = typeof t;
|
|
20
|
+
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]));
|
|
21
21
|
}
|
|
22
22
|
function q(n) {
|
|
23
23
|
try {
|
|
@@ -26,248 +26,311 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
26
26
|
return n;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
class
|
|
30
|
-
constructor(
|
|
31
|
-
super((r, o) =>
|
|
29
|
+
class m extends Promise {
|
|
30
|
+
constructor(e) {
|
|
31
|
+
super((r, o) => e(
|
|
32
32
|
(s) => r(s),
|
|
33
33
|
(s) => o(s),
|
|
34
34
|
(s) => this.progress = s
|
|
35
35
|
));
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
i(this, "listeners", []);
|
|
37
|
+
i(this, "_progress", 0);
|
|
38
38
|
}
|
|
39
39
|
get progress() {
|
|
40
40
|
return this._progress;
|
|
41
41
|
}
|
|
42
|
-
set progress(
|
|
43
|
-
|
|
42
|
+
set progress(e) {
|
|
43
|
+
e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
|
|
44
44
|
}
|
|
45
|
-
static from(
|
|
46
|
-
return
|
|
45
|
+
static from(e) {
|
|
46
|
+
return e instanceof m ? e : new m((r, o) => e.then((...s) => r(...s)).catch((...s) => o(...s)));
|
|
47
47
|
}
|
|
48
|
-
from(
|
|
49
|
-
const r =
|
|
48
|
+
from(e) {
|
|
49
|
+
const r = m.from(e);
|
|
50
50
|
return this.onProgress((o) => r.progress = o), r;
|
|
51
51
|
}
|
|
52
|
-
onProgress(
|
|
53
|
-
return this.listeners.push(
|
|
52
|
+
onProgress(e) {
|
|
53
|
+
return this.listeners.push(e), this;
|
|
54
54
|
}
|
|
55
|
-
then(
|
|
56
|
-
const o = super.then(
|
|
55
|
+
then(e, r) {
|
|
56
|
+
const o = super.then(e, r);
|
|
57
57
|
return this.from(o);
|
|
58
58
|
}
|
|
59
|
-
catch(
|
|
60
|
-
return this.from(super.catch(
|
|
59
|
+
catch(e) {
|
|
60
|
+
return this.from(super.catch(e));
|
|
61
61
|
}
|
|
62
|
-
finally(
|
|
63
|
-
return this.from(super.finally(
|
|
62
|
+
finally(e) {
|
|
63
|
+
return this.from(super.finally(e));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
|
|
66
|
+
function ut(n, t) {
|
|
67
|
+
const e = document.createElement("a");
|
|
68
|
+
e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
|
|
70
|
+
function Tt(n, t) {
|
|
71
|
+
const e = URL.createObjectURL(n);
|
|
72
|
+
ut(e, t), URL.revokeObjectURL(e);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return new Promise((
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, document.body.appendChild(
|
|
74
|
+
function It(n = {}) {
|
|
75
|
+
return new Promise((t) => {
|
|
76
|
+
const e = document.createElement("input");
|
|
77
|
+
e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
|
|
78
|
+
t(Array.from(e.files)), e.remove();
|
|
79
|
+
}, document.body.appendChild(e), e.click();
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return new
|
|
82
|
+
function $t(n) {
|
|
83
|
+
return new m((t, e, r) => {
|
|
84
84
|
const o = new XMLHttpRequest(), s = new FormData();
|
|
85
|
-
n.files.forEach((
|
|
85
|
+
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);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
class
|
|
88
|
+
class v {
|
|
89
89
|
constructor() {
|
|
90
|
-
|
|
90
|
+
i(this, "listeners", {});
|
|
91
91
|
}
|
|
92
|
-
static emit(
|
|
93
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
92
|
+
static emit(t, ...e) {
|
|
93
|
+
(this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t.toString()] || []).forEach((r) => r(...e));
|
|
94
94
|
}
|
|
95
|
-
static off(
|
|
96
|
-
const r =
|
|
97
|
-
this.listeners[r] = (this.listeners[r] || []).filter((o) => o ===
|
|
95
|
+
static off(t, e) {
|
|
96
|
+
const r = t.toString();
|
|
97
|
+
this.listeners[r] = (this.listeners[r] || []).filter((o) => o === e);
|
|
98
98
|
}
|
|
99
|
-
static on(
|
|
99
|
+
static on(t, e) {
|
|
100
100
|
var o;
|
|
101
|
-
const r =
|
|
102
|
-
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(
|
|
101
|
+
const r = t.toString();
|
|
102
|
+
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(e), () => this.off(t, e);
|
|
103
103
|
}
|
|
104
|
-
static once(
|
|
104
|
+
static once(t, e) {
|
|
105
105
|
return new Promise((r) => {
|
|
106
|
-
const o = this.on(
|
|
107
|
-
r(s.length == 1 ? s[0] : s),
|
|
106
|
+
const o = this.on(t, (...s) => {
|
|
107
|
+
r(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
emit(
|
|
112
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
111
|
+
emit(t, ...e) {
|
|
112
|
+
(this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t] || []).forEach((r) => r(...e));
|
|
113
113
|
}
|
|
114
|
-
off(
|
|
115
|
-
this.listeners[
|
|
114
|
+
off(t, e) {
|
|
115
|
+
this.listeners[t] = (this.listeners[t] || []).filter((r) => r === e);
|
|
116
116
|
}
|
|
117
|
-
on(
|
|
117
|
+
on(t, e) {
|
|
118
118
|
var r;
|
|
119
|
-
return this.listeners[
|
|
119
|
+
return this.listeners[t] || (this.listeners[t] = []), (r = this.listeners[t]) == null || r.push(e), () => this.off(t, e);
|
|
120
120
|
}
|
|
121
|
-
once(
|
|
121
|
+
once(t, e) {
|
|
122
122
|
return new Promise((r) => {
|
|
123
|
-
const o = this.on(
|
|
124
|
-
r(s.length == 1 ? s[0] : s),
|
|
123
|
+
const o = this.on(t, (...s) => {
|
|
124
|
+
r(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
class
|
|
131
|
-
constructor(
|
|
132
|
-
super(
|
|
133
|
-
|
|
129
|
+
i(v, "listeners", {});
|
|
130
|
+
class p extends Error {
|
|
131
|
+
constructor(e, r) {
|
|
132
|
+
super(e);
|
|
133
|
+
i(this, "_code");
|
|
134
134
|
r != null && (this._code = r);
|
|
135
135
|
}
|
|
136
136
|
get code() {
|
|
137
137
|
return this._code || this.constructor.code;
|
|
138
138
|
}
|
|
139
|
-
set code(
|
|
140
|
-
this._code =
|
|
139
|
+
set code(e) {
|
|
140
|
+
this._code = e;
|
|
141
141
|
}
|
|
142
|
-
static from(
|
|
143
|
-
const r = Number(
|
|
142
|
+
static from(e) {
|
|
143
|
+
const r = Number(e.statusCode) ?? Number(e.code), o = new this(e.message || e.toString());
|
|
144
144
|
return Object.assign(o, {
|
|
145
|
-
stack:
|
|
146
|
-
...
|
|
145
|
+
stack: e.stack,
|
|
146
|
+
...e,
|
|
147
147
|
code: r ?? void 0
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
static instanceof(
|
|
151
|
-
return
|
|
150
|
+
static instanceof(e) {
|
|
151
|
+
return e.constructor.code != null;
|
|
152
152
|
}
|
|
153
153
|
toString() {
|
|
154
154
|
return this.message || super.toString();
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
class
|
|
159
|
-
constructor(
|
|
160
|
-
super(
|
|
157
|
+
i(p, "code", 500);
|
|
158
|
+
class F extends p {
|
|
159
|
+
constructor(t = "Bad Request") {
|
|
160
|
+
super(t);
|
|
161
161
|
}
|
|
162
|
-
static instanceof(
|
|
163
|
-
return
|
|
162
|
+
static instanceof(t) {
|
|
163
|
+
return t.constructor.code == this.code;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
class
|
|
168
|
-
constructor(
|
|
169
|
-
super(
|
|
166
|
+
i(F, "code", 400);
|
|
167
|
+
class H extends p {
|
|
168
|
+
constructor(t = "Unauthorized") {
|
|
169
|
+
super(t);
|
|
170
170
|
}
|
|
171
|
-
static instanceof(
|
|
172
|
-
return
|
|
171
|
+
static instanceof(t) {
|
|
172
|
+
return t.constructor.code == this.code;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
class
|
|
177
|
-
constructor(
|
|
178
|
-
super(
|
|
175
|
+
i(H, "code", 401);
|
|
176
|
+
class Y extends p {
|
|
177
|
+
constructor(t = "Payment Required") {
|
|
178
|
+
super(t);
|
|
179
179
|
}
|
|
180
|
-
static instanceof(
|
|
181
|
-
return
|
|
180
|
+
static instanceof(t) {
|
|
181
|
+
return t.constructor.code == this.code;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
class
|
|
186
|
-
constructor(
|
|
187
|
-
super(
|
|
184
|
+
i(Y, "code", 402);
|
|
185
|
+
class W extends p {
|
|
186
|
+
constructor(t = "Forbidden") {
|
|
187
|
+
super(t);
|
|
188
188
|
}
|
|
189
|
-
static instanceof(
|
|
190
|
-
return
|
|
189
|
+
static instanceof(t) {
|
|
190
|
+
return t.constructor.code == this.code;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
class
|
|
195
|
-
constructor(
|
|
196
|
-
super(
|
|
193
|
+
i(W, "code", 403);
|
|
194
|
+
class J extends p {
|
|
195
|
+
constructor(t = "Not Found") {
|
|
196
|
+
super(t);
|
|
197
197
|
}
|
|
198
|
-
static instanceof(
|
|
199
|
-
return
|
|
198
|
+
static instanceof(t) {
|
|
199
|
+
return t.constructor.code == this.code;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
i(J, "code", 404);
|
|
203
|
+
class z extends p {
|
|
204
|
+
constructor(t = "Method Not Allowed") {
|
|
205
|
+
super(t);
|
|
206
|
+
}
|
|
207
|
+
static instanceof(t) {
|
|
208
|
+
return t.constructor.code == this.code;
|
|
200
209
|
}
|
|
201
210
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
constructor(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
i(z, "code", 405);
|
|
212
|
+
class K extends p {
|
|
213
|
+
constructor(t = "Not Acceptable") {
|
|
214
|
+
super(t);
|
|
215
|
+
}
|
|
216
|
+
static instanceof(t) {
|
|
217
|
+
return t.constructor.code == this.code;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
i(K, "code", 406);
|
|
221
|
+
class V extends p {
|
|
222
|
+
constructor(t = "Internal Server Error") {
|
|
223
|
+
super(t);
|
|
224
|
+
}
|
|
225
|
+
static instanceof(t) {
|
|
226
|
+
return t.constructor.code == this.code;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
i(V, "code", 500);
|
|
230
|
+
class Z extends p {
|
|
231
|
+
constructor(t = "Not Implemented") {
|
|
232
|
+
super(t);
|
|
233
|
+
}
|
|
234
|
+
static instanceof(t) {
|
|
235
|
+
return t.constructor.code == this.code;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
i(Z, "code", 501);
|
|
239
|
+
class X extends p {
|
|
240
|
+
constructor(t = "Bad Gateway") {
|
|
241
|
+
super(t);
|
|
242
|
+
}
|
|
243
|
+
static instanceof(t) {
|
|
244
|
+
return t.constructor.code == this.code;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
i(X, "code", 502);
|
|
248
|
+
class Q extends p {
|
|
249
|
+
constructor(t = "Service Unavailable") {
|
|
250
|
+
super(t);
|
|
251
|
+
}
|
|
252
|
+
static instanceof(t) {
|
|
253
|
+
return t.constructor.code == this.code;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
i(Q, "code", 503);
|
|
257
|
+
class _ extends p {
|
|
258
|
+
constructor(t = "Gateway Timeout") {
|
|
259
|
+
super(t);
|
|
260
|
+
}
|
|
261
|
+
static instanceof(t) {
|
|
262
|
+
return t.constructor.code == this.code;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
i(_, "code", 504);
|
|
266
|
+
const w = class w2 {
|
|
267
|
+
constructor(t = {}) {
|
|
268
|
+
i(this, "interceptors", {});
|
|
269
|
+
i(this, "headers", {});
|
|
270
|
+
i(this, "url");
|
|
271
|
+
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
|
|
272
|
+
}
|
|
273
|
+
static addInterceptor(t) {
|
|
274
|
+
const e = Object.keys(w2.interceptors).length.toString();
|
|
275
|
+
return w2.interceptors[e] = t, () => {
|
|
276
|
+
w2.interceptors[e] = null;
|
|
214
277
|
};
|
|
215
278
|
}
|
|
216
|
-
addInterceptor(
|
|
217
|
-
const
|
|
218
|
-
return this.interceptors[
|
|
219
|
-
this.interceptors[
|
|
279
|
+
addInterceptor(t) {
|
|
280
|
+
const e = Object.keys(this.interceptors).length.toString();
|
|
281
|
+
return this.interceptors[e] = t, () => {
|
|
282
|
+
this.interceptors[e] = null;
|
|
220
283
|
};
|
|
221
284
|
}
|
|
222
|
-
request(
|
|
285
|
+
request(t = {}) {
|
|
223
286
|
var o;
|
|
224
|
-
if (!this.url && !
|
|
287
|
+
if (!this.url && !t.url)
|
|
225
288
|
throw new Error("URL needs to be set");
|
|
226
|
-
let
|
|
227
|
-
if (
|
|
228
|
-
const s = Array.isArray(
|
|
229
|
-
|
|
289
|
+
let e = ((o = t.url) != null && o.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
290
|
+
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s, c) => `#${t.fragment}${c}`) : e += "#" + t.fragment), t.query) {
|
|
291
|
+
const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
|
|
292
|
+
e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
|
|
230
293
|
}
|
|
231
|
-
const r =
|
|
232
|
-
"Content-Type":
|
|
233
|
-
...
|
|
294
|
+
const r = rt({
|
|
295
|
+
"Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
|
|
296
|
+
...w2.headers,
|
|
234
297
|
...this.headers,
|
|
235
|
-
...
|
|
298
|
+
...t.headers
|
|
236
299
|
});
|
|
237
|
-
return typeof
|
|
238
|
-
fetch(
|
|
300
|
+
return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new m((s, c, y) => {
|
|
301
|
+
fetch(e, {
|
|
239
302
|
headers: r,
|
|
240
|
-
method:
|
|
241
|
-
body:
|
|
242
|
-
}).then(async (
|
|
303
|
+
method: t.method || (t.body ? "POST" : "GET"),
|
|
304
|
+
body: t.body
|
|
305
|
+
}).then(async (u) => {
|
|
243
306
|
var j, G;
|
|
244
|
-
for (let
|
|
245
|
-
await new Promise((O) => u
|
|
246
|
-
const R =
|
|
307
|
+
for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
|
|
308
|
+
await new Promise((O) => a(u, () => O()));
|
|
309
|
+
const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
|
|
247
310
|
let k = 0;
|
|
248
|
-
const T = (j =
|
|
249
|
-
start(
|
|
311
|
+
const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
|
|
312
|
+
start(a) {
|
|
250
313
|
function O() {
|
|
251
314
|
T == null || T.read().then((x) => {
|
|
252
315
|
if (x.done)
|
|
253
|
-
return
|
|
254
|
-
k += x.value.byteLength,
|
|
255
|
-
}).catch((x) =>
|
|
316
|
+
return a.close();
|
|
317
|
+
k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
|
|
318
|
+
}).catch((x) => a.error(x));
|
|
256
319
|
}
|
|
257
320
|
O();
|
|
258
321
|
}
|
|
259
322
|
});
|
|
260
|
-
if (
|
|
261
|
-
const
|
|
262
|
-
|
|
323
|
+
if (u.data = new Response(tt), t.decode == null || t.decode) {
|
|
324
|
+
const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
|
|
325
|
+
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());
|
|
263
326
|
}
|
|
264
|
-
|
|
327
|
+
u.ok ? s(u) : c(u);
|
|
265
328
|
});
|
|
266
329
|
});
|
|
267
330
|
}
|
|
268
331
|
};
|
|
269
|
-
|
|
270
|
-
let M =
|
|
332
|
+
i(w, "interceptors", {}), i(w, "headers", {});
|
|
333
|
+
let M = w;
|
|
271
334
|
const A = {
|
|
272
335
|
CLEAR: "\x1B[0m",
|
|
273
336
|
BRIGHT: "\x1B[1m",
|
|
@@ -294,59 +357,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
294
357
|
LIGHT_CYAN: "\x1B[96m",
|
|
295
358
|
WHITE: "\x1B[97m"
|
|
296
359
|
};
|
|
297
|
-
var
|
|
298
|
-
const
|
|
299
|
-
constructor(
|
|
300
|
-
super(), this.namespace =
|
|
360
|
+
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 || {});
|
|
361
|
+
const g = class g2 extends v {
|
|
362
|
+
constructor(t) {
|
|
363
|
+
super(), this.namespace = t;
|
|
301
364
|
}
|
|
302
|
-
pad(
|
|
303
|
-
const s =
|
|
304
|
-
if (
|
|
365
|
+
pad(t, e, r, o = false) {
|
|
366
|
+
const s = t.toString(), c = e - s.length;
|
|
367
|
+
if (c <= 0)
|
|
305
368
|
return s;
|
|
306
|
-
const
|
|
307
|
-
return o ? s +
|
|
369
|
+
const y = Array(~~(c / r.length)).fill(r).join("");
|
|
370
|
+
return o ? s + y : y + s;
|
|
308
371
|
}
|
|
309
|
-
format(...
|
|
310
|
-
const
|
|
311
|
-
return `${`${
|
|
372
|
+
format(...t) {
|
|
373
|
+
const e = /* @__PURE__ */ new Date();
|
|
374
|
+
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(" ")}`;
|
|
312
375
|
}
|
|
313
|
-
debug(...
|
|
314
|
-
if (
|
|
376
|
+
debug(...t) {
|
|
377
|
+
if (g2.LOG_LEVEL < 4)
|
|
315
378
|
return;
|
|
316
|
-
const
|
|
317
|
-
|
|
379
|
+
const e = this.format(...t);
|
|
380
|
+
g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
|
|
318
381
|
}
|
|
319
|
-
log(...
|
|
320
|
-
if (
|
|
382
|
+
log(...t) {
|
|
383
|
+
if (g2.LOG_LEVEL < 3)
|
|
321
384
|
return;
|
|
322
|
-
const
|
|
323
|
-
|
|
385
|
+
const e = this.format(...t);
|
|
386
|
+
g2.emit(3, e), console.log(A.CLEAR + e);
|
|
324
387
|
}
|
|
325
|
-
info(...
|
|
326
|
-
if (
|
|
388
|
+
info(...t) {
|
|
389
|
+
if (g2.LOG_LEVEL < 2)
|
|
327
390
|
return;
|
|
328
|
-
const
|
|
329
|
-
|
|
391
|
+
const e = this.format(...t);
|
|
392
|
+
g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
|
|
330
393
|
}
|
|
331
|
-
warn(...
|
|
332
|
-
if (
|
|
394
|
+
warn(...t) {
|
|
395
|
+
if (g2.LOG_LEVEL < 1)
|
|
333
396
|
return;
|
|
334
|
-
const
|
|
335
|
-
|
|
397
|
+
const e = this.format(...t);
|
|
398
|
+
g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
|
|
336
399
|
}
|
|
337
|
-
error(...
|
|
338
|
-
if (
|
|
400
|
+
error(...t) {
|
|
401
|
+
if (g2.LOG_LEVEL < 0)
|
|
339
402
|
return;
|
|
340
|
-
const
|
|
341
|
-
|
|
403
|
+
const e = this.format(...t);
|
|
404
|
+
g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
|
|
342
405
|
}
|
|
343
406
|
};
|
|
344
|
-
|
|
407
|
+
i(g, "LOG_LEVEL", 4);
|
|
345
408
|
class Api extends M {
|
|
346
409
|
constructor(url = location.origin, opts = {}) {
|
|
347
410
|
opts.url = url;
|
|
348
411
|
super(opts);
|
|
349
|
-
__publicField(this, "emitter", new
|
|
412
|
+
__publicField(this, "emitter", new v());
|
|
350
413
|
__publicField(this, "_token", null);
|
|
351
414
|
__publicField(this, "emit", this.emitter.emit.bind(this.emitter));
|
|
352
415
|
__publicField(this, "off", this.emitter.off.bind(this.emitter));
|
|
@@ -380,45 +443,45 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
380
443
|
return req;
|
|
381
444
|
}
|
|
382
445
|
}
|
|
383
|
-
var extendStatics = function(d,
|
|
384
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2,
|
|
385
|
-
d2.__proto__ =
|
|
386
|
-
} || function(d2,
|
|
387
|
-
for (var
|
|
446
|
+
var extendStatics = function(d, b) {
|
|
447
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
448
|
+
d2.__proto__ = b2;
|
|
449
|
+
} || function(d2, b2) {
|
|
450
|
+
for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
|
|
388
451
|
};
|
|
389
|
-
return extendStatics(d,
|
|
452
|
+
return extendStatics(d, b);
|
|
390
453
|
};
|
|
391
|
-
function __extends(d,
|
|
392
|
-
if (typeof
|
|
393
|
-
throw new TypeError("Class extends value " + String(
|
|
394
|
-
extendStatics(d,
|
|
454
|
+
function __extends(d, b) {
|
|
455
|
+
if (typeof b !== "function" && b !== null)
|
|
456
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
457
|
+
extendStatics(d, b);
|
|
395
458
|
function __() {
|
|
396
459
|
this.constructor = d;
|
|
397
460
|
}
|
|
398
|
-
d.prototype =
|
|
461
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
399
462
|
}
|
|
400
463
|
function __values(o) {
|
|
401
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
402
|
-
if (
|
|
464
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
|
|
465
|
+
if (m2) return m2.call(o);
|
|
403
466
|
if (o && typeof o.length === "number") return {
|
|
404
467
|
next: function() {
|
|
405
|
-
if (o &&
|
|
406
|
-
return { value: o && o[
|
|
468
|
+
if (o && i2 >= o.length) o = void 0;
|
|
469
|
+
return { value: o && o[i2++], done: !o };
|
|
407
470
|
}
|
|
408
471
|
};
|
|
409
472
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
410
473
|
}
|
|
411
474
|
function __read(o, n) {
|
|
412
|
-
var
|
|
413
|
-
if (!
|
|
414
|
-
var
|
|
475
|
+
var m2 = typeof Symbol === "function" && o[Symbol.iterator];
|
|
476
|
+
if (!m2) return o;
|
|
477
|
+
var i2 = m2.call(o), r, ar = [], e;
|
|
415
478
|
try {
|
|
416
|
-
while ((n === void 0 || n-- > 0) && !(r =
|
|
479
|
+
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done) ar.push(r.value);
|
|
417
480
|
} catch (error) {
|
|
418
481
|
e = { error };
|
|
419
482
|
} finally {
|
|
420
483
|
try {
|
|
421
|
-
if (r && !r.done && (
|
|
484
|
+
if (r && !r.done && (m2 = i2["return"])) m2.call(i2);
|
|
422
485
|
} finally {
|
|
423
486
|
if (e) throw e.error;
|
|
424
487
|
}
|
|
@@ -426,10 +489,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
426
489
|
return ar;
|
|
427
490
|
}
|
|
428
491
|
function __spreadArray(to, from, pack) {
|
|
429
|
-
if (pack || arguments.length === 2) for (var
|
|
430
|
-
if (ar || !(
|
|
431
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0,
|
|
432
|
-
ar[
|
|
492
|
+
if (pack || arguments.length === 2) for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
493
|
+
if (ar || !(i2 in from)) {
|
|
494
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i2);
|
|
495
|
+
ar[i2] = from[i2];
|
|
433
496
|
}
|
|
434
497
|
}
|
|
435
498
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
@@ -454,8 +517,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
454
517
|
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
455
518
|
return function UnsubscriptionErrorImpl(errors) {
|
|
456
519
|
_super(this);
|
|
457
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err,
|
|
458
|
-
return
|
|
520
|
+
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i2) {
|
|
521
|
+
return i2 + 1 + ") " + err.toString();
|
|
459
522
|
}).join("\n ") : "";
|
|
460
523
|
this.name = "UnsubscriptionError";
|
|
461
524
|
this.errors = errors;
|
|
@@ -1096,7 +1159,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1096
1159
|
ActionType2[ActionType2["PUT"] = 6] = "PUT";
|
|
1097
1160
|
return ActionType2;
|
|
1098
1161
|
})(ActionType || {});
|
|
1099
|
-
class Actions extends
|
|
1162
|
+
class Actions extends v {
|
|
1100
1163
|
constructor(api) {
|
|
1101
1164
|
super();
|
|
1102
1165
|
__publicField(this, "api");
|
|
@@ -1111,7 +1174,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1111
1174
|
}
|
|
1112
1175
|
delete(id) {
|
|
1113
1176
|
return this.api.request({ url: `/api/actions/${id}`, method: "DELETE" }).then(() => {
|
|
1114
|
-
this.cache = this.cache.filter((
|
|
1177
|
+
this.cache = this.cache.filter((a) => a._id != id);
|
|
1115
1178
|
this.emit("DELETE", id);
|
|
1116
1179
|
});
|
|
1117
1180
|
}
|
|
@@ -1123,10 +1186,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1123
1186
|
});
|
|
1124
1187
|
}
|
|
1125
1188
|
read(id, reload = false) {
|
|
1126
|
-
const cached = this.cache.find((
|
|
1189
|
+
const cached = this.cache.find((a) => a._id == id);
|
|
1127
1190
|
if (!reload && cached) return Promise.resolve(cached);
|
|
1128
1191
|
return this.api.request({ url: `/api/actions/${id}` }).then((action) => {
|
|
1129
|
-
if (action) this.cache = this.cache.filter((
|
|
1192
|
+
if (action) this.cache = this.cache.filter((a) => a._id != id).concat([action]);
|
|
1130
1193
|
this.emit("READ", action);
|
|
1131
1194
|
return action;
|
|
1132
1195
|
});
|
|
@@ -1144,13 +1207,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1144
1207
|
method: "POST",
|
|
1145
1208
|
body: action
|
|
1146
1209
|
}).then((action2) => {
|
|
1147
|
-
if (action2) this.cache = this.cache.filter((
|
|
1210
|
+
if (action2) this.cache = this.cache.filter((a) => a._id != (action2 == null ? void 0 : action2._id)).concat([action2]);
|
|
1148
1211
|
this.emit("UPDATE", action2);
|
|
1149
1212
|
return action2;
|
|
1150
1213
|
});
|
|
1151
1214
|
}
|
|
1152
1215
|
}
|
|
1153
|
-
class Ai extends
|
|
1216
|
+
class Ai extends v {
|
|
1154
1217
|
constructor(api) {
|
|
1155
1218
|
super();
|
|
1156
1219
|
__publicField(this, "api");
|
|
@@ -1166,7 +1229,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1166
1229
|
});
|
|
1167
1230
|
}
|
|
1168
1231
|
}
|
|
1169
|
-
class Analytics extends
|
|
1232
|
+
class Analytics extends v {
|
|
1170
1233
|
constructor(api) {
|
|
1171
1234
|
super();
|
|
1172
1235
|
__publicField(this, "api");
|
|
@@ -1191,13 +1254,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1191
1254
|
return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
|
|
1192
1255
|
}
|
|
1193
1256
|
setup(username, method = "app", totp) {
|
|
1194
|
-
return this.api.request({ url: `/api/auth/totp/${username}`, body:
|
|
1257
|
+
return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
|
|
1195
1258
|
method,
|
|
1196
1259
|
totp
|
|
1197
1260
|
}) });
|
|
1198
1261
|
}
|
|
1199
1262
|
}
|
|
1200
|
-
class Auth extends
|
|
1263
|
+
class Auth extends v {
|
|
1201
1264
|
constructor(api, opts) {
|
|
1202
1265
|
var _a;
|
|
1203
1266
|
super();
|
|
@@ -1242,7 +1305,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1242
1305
|
return this.$user.value;
|
|
1243
1306
|
}
|
|
1244
1307
|
set user(user) {
|
|
1245
|
-
if (!
|
|
1308
|
+
if (!B(this.user, user)) {
|
|
1246
1309
|
const u = user ? user : null;
|
|
1247
1310
|
this.$user.next(u);
|
|
1248
1311
|
this.emit("USER", u);
|
|
@@ -1328,7 +1391,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1328
1391
|
});
|
|
1329
1392
|
}
|
|
1330
1393
|
}
|
|
1331
|
-
class Data extends
|
|
1394
|
+
class Data extends v {
|
|
1332
1395
|
constructor(api) {
|
|
1333
1396
|
super();
|
|
1334
1397
|
__publicField(this, "api");
|
|
@@ -1373,7 +1436,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1373
1436
|
});
|
|
1374
1437
|
}
|
|
1375
1438
|
}
|
|
1376
|
-
class Email extends
|
|
1439
|
+
class Email extends v {
|
|
1377
1440
|
constructor(api) {
|
|
1378
1441
|
super();
|
|
1379
1442
|
__publicField(this, "api");
|
|
@@ -1388,7 +1451,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1388
1451
|
});
|
|
1389
1452
|
}
|
|
1390
1453
|
}
|
|
1391
|
-
class Groups extends
|
|
1454
|
+
class Groups extends v {
|
|
1392
1455
|
constructor(api) {
|
|
1393
1456
|
super();
|
|
1394
1457
|
__publicField(this, "api");
|
|
@@ -1470,32 +1533,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1470
1533
|
return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
|
|
1471
1534
|
}
|
|
1472
1535
|
debug(...logs) {
|
|
1473
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1536
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
|
|
1474
1537
|
}).catch(() => {
|
|
1475
1538
|
});
|
|
1476
1539
|
}
|
|
1477
1540
|
log(...logs) {
|
|
1478
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1541
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
|
|
1479
1542
|
}).catch(() => {
|
|
1480
1543
|
});
|
|
1481
1544
|
}
|
|
1482
1545
|
info(...logs) {
|
|
1483
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1546
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
|
|
1484
1547
|
}).catch(() => {
|
|
1485
1548
|
});
|
|
1486
1549
|
}
|
|
1487
1550
|
warn(...logs) {
|
|
1488
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1551
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
|
|
1489
1552
|
}).catch(() => {
|
|
1490
1553
|
});
|
|
1491
1554
|
}
|
|
1492
1555
|
error(...logs) {
|
|
1493
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1556
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
|
|
1494
1557
|
}).catch(() => {
|
|
1495
1558
|
});
|
|
1496
1559
|
}
|
|
1497
1560
|
}
|
|
1498
|
-
class Payments extends
|
|
1561
|
+
class Payments extends v {
|
|
1499
1562
|
constructor(api, secret) {
|
|
1500
1563
|
super();
|
|
1501
1564
|
__publicField(this, "api");
|
|
@@ -1536,7 +1599,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1536
1599
|
return history;
|
|
1537
1600
|
}
|
|
1538
1601
|
}
|
|
1539
|
-
class Pdf extends
|
|
1602
|
+
class Pdf extends v {
|
|
1540
1603
|
constructor(api) {
|
|
1541
1604
|
super();
|
|
1542
1605
|
__publicField(this, "api");
|
|
@@ -1546,20 +1609,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1546
1609
|
const blob = await resp.blob();
|
|
1547
1610
|
if (fileName) {
|
|
1548
1611
|
const url = URL.createObjectURL(blob);
|
|
1549
|
-
|
|
1612
|
+
ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
|
|
1550
1613
|
URL.revokeObjectURL(url);
|
|
1551
1614
|
}
|
|
1552
1615
|
this.emit("CREATE", blob);
|
|
1553
1616
|
return blob;
|
|
1554
1617
|
}
|
|
1555
1618
|
fromHtml(content, opts = {}) {
|
|
1556
|
-
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));
|
|
1619
|
+
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));
|
|
1557
1620
|
}
|
|
1558
1621
|
fromTemplate(template, data, opts = {}) {
|
|
1559
|
-
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));
|
|
1622
|
+
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));
|
|
1560
1623
|
}
|
|
1561
1624
|
fromUrl(url, opts = {}) {
|
|
1562
|
-
return this.api.request({ url: `/api/pdf
|
|
1625
|
+
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));
|
|
1563
1626
|
}
|
|
1564
1627
|
}
|
|
1565
1628
|
const _Socket = class _Socket {
|
|
@@ -1609,7 +1672,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1609
1672
|
};
|
|
1610
1673
|
__publicField(_Socket, "timeout", 1e4);
|
|
1611
1674
|
let Socket = _Socket;
|
|
1612
|
-
class Storage extends
|
|
1675
|
+
class Storage extends v {
|
|
1613
1676
|
constructor(api) {
|
|
1614
1677
|
super();
|
|
1615
1678
|
__publicField(this, "api");
|
|
@@ -1629,37 +1692,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1629
1692
|
});
|
|
1630
1693
|
}
|
|
1631
1694
|
open(path, target = "_blank") {
|
|
1632
|
-
const
|
|
1633
|
-
const link = `${this.api.url}${
|
|
1695
|
+
const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
|
|
1696
|
+
const link = `${this.api.url}${p2}${this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1634
1697
|
if (!target) return link;
|
|
1635
1698
|
this.emit("OPEN", path);
|
|
1636
1699
|
return window.open(link, target);
|
|
1637
1700
|
}
|
|
1638
1701
|
mkdir(path) {
|
|
1639
|
-
const
|
|
1640
|
-
return this.api.request({ url:
|
|
1702
|
+
const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
|
|
1703
|
+
return this.api.request({ url: p2 + "?directory", method: "POST" });
|
|
1641
1704
|
}
|
|
1642
1705
|
download(path, opts = {}) {
|
|
1643
|
-
const
|
|
1644
|
-
return this.api.request({ ...opts, url:
|
|
1706
|
+
const p2 = ("/api/storage/" + path).replaceAll("//", "/");
|
|
1707
|
+
return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
|
|
1645
1708
|
const blob = await response.blob();
|
|
1646
1709
|
const name = opts.downloadAs || path.split("/").pop();
|
|
1647
1710
|
this.emit("DOWNLOAD", path, blob);
|
|
1648
|
-
|
|
1711
|
+
Tt(blob, name);
|
|
1649
1712
|
return response;
|
|
1650
1713
|
});
|
|
1651
1714
|
}
|
|
1652
1715
|
upload(files, opts = "") {
|
|
1653
|
-
return new
|
|
1654
|
-
if (!files) files = await
|
|
1716
|
+
return new m(async (res, rej, prog) => {
|
|
1717
|
+
if (!files) files = await It();
|
|
1655
1718
|
if (!files || Array.isArray(files) && !files.length) return [];
|
|
1656
1719
|
const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
|
|
1657
|
-
return
|
|
1720
|
+
return $t({
|
|
1658
1721
|
url,
|
|
1659
1722
|
files: Array.isArray(files) ? files : [files],
|
|
1660
1723
|
headers: this.api.headers
|
|
1661
|
-
}).onProgress((
|
|
1662
|
-
prog(
|
|
1724
|
+
}).onProgress((p2) => {
|
|
1725
|
+
prog(p2);
|
|
1663
1726
|
}).then((resp) => {
|
|
1664
1727
|
this.emit("UPLOAD", resp);
|
|
1665
1728
|
res(resp);
|
|
@@ -1871,7 +1934,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1871
1934
|
}, 1e3);
|
|
1872
1935
|
}
|
|
1873
1936
|
}
|
|
1874
|
-
class Users extends
|
|
1937
|
+
class Users extends v {
|
|
1875
1938
|
constructor(api) {
|
|
1876
1939
|
super();
|
|
1877
1940
|
__publicField(this, "api");
|
|
@@ -1936,7 +1999,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1936
1999
|
});
|
|
1937
2000
|
}
|
|
1938
2001
|
uploadImage(username, file) {
|
|
1939
|
-
return
|
|
2002
|
+
return $t({
|
|
1940
2003
|
url: this.api.url + `/api/users/${username}/image`,
|
|
1941
2004
|
files: [file],
|
|
1942
2005
|
headers: this.api.headers
|
|
@@ -1946,7 +2009,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1946
2009
|
});
|
|
1947
2010
|
}
|
|
1948
2011
|
}
|
|
1949
|
-
class Settings extends
|
|
2012
|
+
class Settings extends v {
|
|
1950
2013
|
constructor(api) {
|
|
1951
2014
|
super();
|
|
1952
2015
|
__publicField(this, "api");
|
|
@@ -1988,7 +2051,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1988
2051
|
});
|
|
1989
2052
|
}
|
|
1990
2053
|
}
|
|
1991
|
-
class Static extends
|
|
2054
|
+
class Static extends v {
|
|
1992
2055
|
constructor(api) {
|
|
1993
2056
|
super();
|
|
1994
2057
|
__publicField(this, "api");
|
|
@@ -2007,13 +2070,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2007
2070
|
});
|
|
2008
2071
|
}
|
|
2009
2072
|
upload(files, path = "/") {
|
|
2010
|
-
return new
|
|
2011
|
-
return
|
|
2073
|
+
return new m(async (res, rej, prog) => {
|
|
2074
|
+
return $t({
|
|
2012
2075
|
url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
|
|
2013
2076
|
files: Array.isArray(files) ? files : [files],
|
|
2014
2077
|
headers: this.api.headers
|
|
2015
|
-
}).onProgress((
|
|
2016
|
-
prog(
|
|
2078
|
+
}).onProgress((p2) => {
|
|
2079
|
+
prog(p2);
|
|
2017
2080
|
}).then((resp) => {
|
|
2018
2081
|
this.emit("UPLOAD", resp);
|
|
2019
2082
|
res(resp);
|
|
@@ -2021,7 +2084,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2021
2084
|
});
|
|
2022
2085
|
}
|
|
2023
2086
|
}
|
|
2024
|
-
class Momentum extends
|
|
2087
|
+
class Momentum extends v {
|
|
2025
2088
|
constructor(url, opts) {
|
|
2026
2089
|
super();
|
|
2027
2090
|
__publicField(this, "api");
|