@ztimson/momentum 0.39.1 → 0.39.3

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/ai.d.ts CHANGED
@@ -7,5 +7,6 @@ export declare class Ai extends TypedEmitter<AiEvents> {
7
7
  private readonly api;
8
8
  constructor(api: Api | string);
9
9
  ask(question: string, context?: any): import('@ztimson/utils').PromiseProgress<any>;
10
+ clear(): import('@ztimson/utils').PromiseProgress<void>;
10
11
  }
11
12
  //# sourceMappingURL=ai.d.ts.map
package/dist/ai.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG;IACpC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,CAAC;CACpD,CAAC;AAEF,qBAAa,EAAG,SAAQ,YAAY,CAAC,QAAQ,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CASnC"}
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG;IACpC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,CAAC;CACpD,CAAC;AAEF,qBAAa,EAAG,SAAQ,YAAY,CAAC,QAAQ,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAUnC,KAAK;CAGL"}
package/dist/index.cjs CHANGED
@@ -5,10 +5,10 @@
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 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) {
8
+ var nt = Object.defineProperty;
9
+ var rt = (n, t, e) => t in n ? nt(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
10
+ var i = (n, t, e) => (rt(n, typeof t != "symbol" ? t + "" : t, e), e);
11
+ function ot(n, t = false) {
12
12
  if (n == null)
13
13
  throw new Error("Cannot clean a NULL value");
14
14
  return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
@@ -26,6 +26,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
26
26
  return n;
27
27
  }
28
28
  }
29
+ function ut(n) {
30
+ return Array.isArray(n) ? n : [n];
31
+ }
29
32
  class m extends Promise {
30
33
  constructor(e) {
31
34
  super((r, o) => e(
@@ -63,14 +66,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
63
66
  return this.from(super.finally(e));
64
67
  }
65
68
  }
66
- function at(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
- }
70
69
  function Tt(n, t) {
70
+ n instanceof Blob || (n = new Blob(ut(n)));
71
71
  const e = URL.createObjectURL(n);
72
72
  at(e, t), URL.revokeObjectURL(e);
73
73
  }
74
+ function at(n, t) {
75
+ const e = document.createElement("a");
76
+ e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
77
+ }
74
78
  function It(n = {}) {
75
79
  return new Promise((t) => {
76
80
  const e = document.createElement("input");
@@ -79,13 +83,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
79
83
  }, document.body.appendChild(e), e.click();
80
84
  });
81
85
  }
82
- function $t(n) {
86
+ function Dt(n) {
83
87
  return new m((t, e, r) => {
84
88
  const o = new XMLHttpRequest(), s = new FormData();
85
89
  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(U(o.responseText))), o.addEventListener("error", () => e(U(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
90
  });
87
91
  }
88
- class F {
92
+ class v {
89
93
  constructor() {
90
94
  i(this, "listeners", {});
91
95
  }
@@ -126,7 +130,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
126
130
  });
127
131
  }
128
132
  }
129
- i(F, "listeners", {});
133
+ i(v, "listeners", {});
130
134
  class p extends Error {
131
135
  constructor(e, r) {
132
136
  super(e);
@@ -155,7 +159,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
155
159
  }
156
160
  }
157
161
  i(p, "code", 500);
158
- class v extends p {
162
+ class Y extends p {
159
163
  constructor(t = "Bad Request") {
160
164
  super(t);
161
165
  }
@@ -163,8 +167,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
163
167
  return t.constructor.code == this.code;
164
168
  }
165
169
  }
166
- i(v, "code", 400);
167
- class Y extends p {
170
+ i(Y, "code", 400);
171
+ class H extends p {
168
172
  constructor(t = "Unauthorized") {
169
173
  super(t);
170
174
  }
@@ -172,8 +176,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
172
176
  return t.constructor.code == this.code;
173
177
  }
174
178
  }
175
- i(Y, "code", 401);
176
- class H extends p {
179
+ i(H, "code", 401);
180
+ class W extends p {
177
181
  constructor(t = "Payment Required") {
178
182
  super(t);
179
183
  }
@@ -181,8 +185,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
181
185
  return t.constructor.code == this.code;
182
186
  }
183
187
  }
184
- i(H, "code", 402);
185
- class W extends p {
188
+ i(W, "code", 402);
189
+ class z extends p {
186
190
  constructor(t = "Forbidden") {
187
191
  super(t);
188
192
  }
@@ -190,8 +194,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
190
194
  return t.constructor.code == this.code;
191
195
  }
192
196
  }
193
- i(W, "code", 403);
194
- class z extends p {
197
+ i(z, "code", 403);
198
+ class J extends p {
195
199
  constructor(t = "Not Found") {
196
200
  super(t);
197
201
  }
@@ -199,8 +203,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
199
203
  return t.constructor.code == this.code;
200
204
  }
201
205
  }
202
- i(z, "code", 404);
203
- class J extends p {
206
+ i(J, "code", 404);
207
+ class K extends p {
204
208
  constructor(t = "Method Not Allowed") {
205
209
  super(t);
206
210
  }
@@ -208,8 +212,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
208
212
  return t.constructor.code == this.code;
209
213
  }
210
214
  }
211
- i(J, "code", 405);
212
- class K extends p {
215
+ i(K, "code", 405);
216
+ class Z extends p {
213
217
  constructor(t = "Not Acceptable") {
214
218
  super(t);
215
219
  }
@@ -217,8 +221,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
217
221
  return t.constructor.code == this.code;
218
222
  }
219
223
  }
220
- i(K, "code", 406);
221
- class Z extends p {
224
+ i(Z, "code", 406);
225
+ class V extends p {
222
226
  constructor(t = "Internal Server Error") {
223
227
  super(t);
224
228
  }
@@ -226,8 +230,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
226
230
  return t.constructor.code == this.code;
227
231
  }
228
232
  }
229
- i(Z, "code", 500);
230
- class V extends p {
233
+ i(V, "code", 500);
234
+ class X extends p {
231
235
  constructor(t = "Not Implemented") {
232
236
  super(t);
233
237
  }
@@ -235,8 +239,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
235
239
  return t.constructor.code == this.code;
236
240
  }
237
241
  }
238
- i(V, "code", 501);
239
- class X extends p {
242
+ i(X, "code", 501);
243
+ class Q extends p {
240
244
  constructor(t = "Bad Gateway") {
241
245
  super(t);
242
246
  }
@@ -244,8 +248,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
244
248
  return t.constructor.code == this.code;
245
249
  }
246
250
  }
247
- i(X, "code", 502);
248
- class Q extends p {
251
+ i(Q, "code", 502);
252
+ class _ extends p {
249
253
  constructor(t = "Service Unavailable") {
250
254
  super(t);
251
255
  }
@@ -253,8 +257,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
253
257
  return t.constructor.code == this.code;
254
258
  }
255
259
  }
256
- i(Q, "code", 503);
257
- class _ extends p {
260
+ i(_, "code", 503);
261
+ class tt extends p {
258
262
  constructor(t = "Gateway Timeout") {
259
263
  super(t);
260
264
  }
@@ -262,7 +266,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
262
266
  return t.constructor.code == this.code;
263
267
  }
264
268
  }
265
- i(_, "code", 504);
269
+ i(tt, "code", 504);
266
270
  const w = class w2 {
267
271
  constructor(t = {}) {
268
272
  i(this, "interceptors", {});
@@ -291,7 +295,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
291
295
  const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
292
296
  e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
293
297
  }
294
- const r = rt({
298
+ const r = ot({
295
299
  "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
296
300
  ...w2.headers,
297
301
  ...this.headers,
@@ -302,36 +306,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
302
306
  headers: r,
303
307
  method: t.method || (t.body ? "POST" : "GET"),
304
308
  body: t.body
305
- }).then(async (a) => {
306
- var M, j;
307
- for (let u of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
308
- await new Promise((O) => u(a, () => O()));
309
- const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
310
- let k = 0;
311
- const T = (M = a.body) == null ? void 0 : M.getReader(), tt = new ReadableStream({
312
- start(u) {
309
+ }).then(async (u) => {
310
+ var j, k;
311
+ for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
312
+ await new Promise((O) => a(u, () => O()));
313
+ const R = u.headers.get("Content-Length"), C = R ? parseInt(R, 10) : 0;
314
+ let D = 0;
315
+ const N = (j = u.body) == null ? void 0 : j.getReader(), et = new ReadableStream({
316
+ start(a) {
313
317
  function O() {
314
- T == null || T.read().then((x) => {
315
- if (x.done)
316
- return u.close();
317
- k += x.value.byteLength, y(k / N), u.enqueue(x.value), O();
318
- }).catch((x) => u.error(x));
318
+ N == null || N.read().then((B) => {
319
+ if (B.done)
320
+ return a.close();
321
+ D += B.value.byteLength, y(D / C), a.enqueue(B.value), O();
322
+ }).catch((B) => a.error(B));
319
323
  }
320
324
  O();
321
325
  }
322
326
  });
323
- if (a.data = new Response(tt), t.decode == null || t.decode) {
324
- const u = (j = a.headers.get("Content-Type")) == null ? void 0 : j.toLowerCase();
325
- u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
327
+ if (u.data = new Response(et), t.decode == null || t.decode) {
328
+ const a = (k = u.headers.get("Content-Type")) == null ? void 0 : k.toLowerCase();
329
+ 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());
326
330
  }
327
- a.ok ? s(a) : c(a);
331
+ u.ok ? s(u) : c(u);
328
332
  });
329
333
  });
330
334
  }
331
335
  };
332
336
  i(w, "interceptors", {}), i(w, "headers", {});
333
337
  let q = w;
334
- const B = {
338
+ const S = {
335
339
  CLEAR: "\x1B[0m",
336
340
  BRIGHT: "\x1B[1m",
337
341
  DIM: "\x1B[2m",
@@ -339,7 +343,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
339
343
  BLINK: "\x1B[5m",
340
344
  REVERSE: "\x1B[7m",
341
345
  HIDDEN: "\x1B[8m"
342
- }, L = {
346
+ }, $ = {
343
347
  BLACK: "\x1B[30m",
344
348
  RED: "\x1B[31m",
345
349
  GREEN: "\x1B[32m",
@@ -357,8 +361,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
357
361
  LIGHT_CYAN: "\x1B[96m",
358
362
  WHITE: "\x1B[97m"
359
363
  };
360
- var ut = /* @__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))(ut || {});
361
- const g = class g2 extends F {
364
+ var lt = /* @__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))(lt || {});
365
+ const g = class g2 extends v {
362
366
  constructor(t) {
363
367
  super(), this.namespace = t;
364
368
  }
@@ -377,31 +381,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
377
381
  if (g2.LOG_LEVEL < 4)
378
382
  return;
379
383
  const e = this.format(...t);
380
- g2.emit(4, e), console.debug(L.LIGHT_GREY + e + B.CLEAR);
384
+ g2.emit(4, e), console.debug($.LIGHT_GREY + e + S.CLEAR);
381
385
  }
382
386
  log(...t) {
383
387
  if (g2.LOG_LEVEL < 3)
384
388
  return;
385
389
  const e = this.format(...t);
386
- g2.emit(3, e), console.log(B.CLEAR + e);
390
+ g2.emit(3, e), console.log(S.CLEAR + e);
387
391
  }
388
392
  info(...t) {
389
393
  if (g2.LOG_LEVEL < 2)
390
394
  return;
391
395
  const e = this.format(...t);
392
- g2.emit(2, e), console.info(L.BLUE + e + B.CLEAR);
396
+ g2.emit(2, e), console.info($.BLUE + e + S.CLEAR);
393
397
  }
394
398
  warn(...t) {
395
399
  if (g2.LOG_LEVEL < 1)
396
400
  return;
397
401
  const e = this.format(...t);
398
- g2.emit(1, e), console.warn(L.YELLOW + e + B.CLEAR);
402
+ g2.emit(1, e), console.warn($.YELLOW + e + S.CLEAR);
399
403
  }
400
404
  error(...t) {
401
405
  if (g2.LOG_LEVEL < 0)
402
406
  return;
403
407
  const e = this.format(...t);
404
- g2.emit(0, e), console.error(L.RED + e + B.CLEAR);
408
+ g2.emit(0, e), console.error($.RED + e + S.CLEAR);
405
409
  }
406
410
  };
407
411
  i(g, "LOG_LEVEL", 4);
@@ -409,7 +413,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
409
413
  constructor(url = location.origin, opts = {}) {
410
414
  opts.url = url;
411
415
  super(opts);
412
- __publicField(this, "emitter", new F());
416
+ __publicField(this, "emitter", new v());
413
417
  __publicField(this, "_token", null);
414
418
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
415
419
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -1162,7 +1166,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1162
1166
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1163
1167
  return ActionType2;
1164
1168
  })(ActionType || {});
1165
- class Actions extends F {
1169
+ class Actions extends v {
1166
1170
  constructor(api) {
1167
1171
  super();
1168
1172
  __publicField(this, "api");
@@ -1222,7 +1226,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1222
1226
  });
1223
1227
  }
1224
1228
  }
1225
- class Ai extends F {
1229
+ class Ai extends v {
1226
1230
  constructor(api) {
1227
1231
  super();
1228
1232
  __publicField(this, "api");
@@ -1237,8 +1241,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1237
1241
  return resp;
1238
1242
  });
1239
1243
  }
1244
+ clear() {
1245
+ return this.api.request({ url: "/api/ai", method: "DELETE" });
1246
+ }
1240
1247
  }
1241
- class Analytics extends F {
1248
+ class Analytics extends v {
1242
1249
  constructor(api) {
1243
1250
  super();
1244
1251
  __publicField(this, "api");
@@ -1263,13 +1270,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1263
1270
  return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1264
1271
  }
1265
1272
  setup(username, method = "app", totp) {
1266
- return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
1273
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: ot({
1267
1274
  method,
1268
1275
  totp
1269
1276
  }) });
1270
1277
  }
1271
1278
  }
1272
- class Auth extends F {
1279
+ class Auth extends v {
1273
1280
  constructor(api, opts = {}) {
1274
1281
  super();
1275
1282
  __publicField(this, "api");
@@ -1409,7 +1416,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1409
1416
  });
1410
1417
  }
1411
1418
  }
1412
- class Data extends F {
1419
+ class Data extends v {
1413
1420
  constructor(api) {
1414
1421
  super();
1415
1422
  __publicField(this, "api");
@@ -1453,7 +1460,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1453
1460
  });
1454
1461
  }
1455
1462
  }
1456
- class Email extends F {
1463
+ class Email extends v {
1457
1464
  constructor(api) {
1458
1465
  super();
1459
1466
  __publicField(this, "api");
@@ -1468,7 +1475,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1468
1475
  });
1469
1476
  }
1470
1477
  }
1471
- class Groups extends F {
1478
+ class Groups extends v {
1472
1479
  constructor(api) {
1473
1480
  super();
1474
1481
  __publicField(this, "api");
@@ -1561,32 +1568,32 @@ ${log}`;
1561
1568
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1562
1569
  }
1563
1570
  debug(...logs) {
1564
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.DEBUG, logs) }).then(() => {
1571
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.DEBUG, logs) }).then(() => {
1565
1572
  }).catch(() => {
1566
1573
  });
1567
1574
  }
1568
1575
  log(...logs) {
1569
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.LOG, logs) }).then(() => {
1576
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.LOG, logs) }).then(() => {
1570
1577
  }).catch(() => {
1571
1578
  });
1572
1579
  }
1573
1580
  info(...logs) {
1574
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.INFO, logs) }).then(() => {
1581
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.INFO, logs) }).then(() => {
1575
1582
  }).catch(() => {
1576
1583
  });
1577
1584
  }
1578
1585
  warn(...logs) {
1579
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.WARN, logs) }).then(() => {
1586
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.WARN, logs) }).then(() => {
1580
1587
  }).catch(() => {
1581
1588
  });
1582
1589
  }
1583
1590
  error(...logs) {
1584
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.ERROR, logs) }).then(() => {
1591
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.ERROR, logs) }).then(() => {
1585
1592
  }).catch(() => {
1586
1593
  });
1587
1594
  }
1588
1595
  }
1589
- class Payments extends F {
1596
+ class Payments extends v {
1590
1597
  constructor(api, secret) {
1591
1598
  super();
1592
1599
  __publicField(this, "api");
@@ -1627,7 +1634,7 @@ ${log}`;
1627
1634
  return history;
1628
1635
  }
1629
1636
  }
1630
- class Pdf extends F {
1637
+ class Pdf extends v {
1631
1638
  constructor(api) {
1632
1639
  super();
1633
1640
  __publicField(this, "api");
@@ -1700,7 +1707,7 @@ ${log}`;
1700
1707
  };
1701
1708
  __publicField(_Socket, "timeout", 1e4);
1702
1709
  let Socket = _Socket;
1703
- class Storage extends F {
1710
+ class Storage extends v {
1704
1711
  constructor(api) {
1705
1712
  super();
1706
1713
  __publicField(this, "api");
@@ -1763,9 +1770,9 @@ ${log}`;
1763
1770
  if (!files) files = await It(typeof opts == "object" ? opts : void 0);
1764
1771
  if (!files || Array.isArray(files) && !files.length) return [];
1765
1772
  const path = this.api.path("/api/storage/", typeof opts == "string" ? opts : opts.path || "");
1766
- return $t({
1773
+ return Dt({
1767
1774
  url: `${this.api.url}${path}`,
1768
- files: Array.isArray(files) ? files : [files],
1775
+ files: ut(files),
1769
1776
  headers: this.api.headers
1770
1777
  }).onProgress((p2) => {
1771
1778
  prog(p2);
@@ -1980,7 +1987,7 @@ ${log}`;
1980
1987
  }, 1e3);
1981
1988
  }
1982
1989
  }
1983
- class Users extends F {
1990
+ class Users extends v {
1984
1991
  constructor(api) {
1985
1992
  super();
1986
1993
  __publicField(this, "api");
@@ -2045,7 +2052,7 @@ ${log}`;
2045
2052
  });
2046
2053
  }
2047
2054
  uploadImage(username, file) {
2048
- return $t({
2055
+ return Dt({
2049
2056
  url: this.api.url + `/api/users/${username}/image`,
2050
2057
  files: [file],
2051
2058
  headers: this.api.headers
@@ -2055,7 +2062,7 @@ ${log}`;
2055
2062
  });
2056
2063
  }
2057
2064
  }
2058
- class Settings extends F {
2065
+ class Settings extends v {
2059
2066
  constructor(api) {
2060
2067
  super();
2061
2068
  __publicField(this, "api");
@@ -2097,7 +2104,7 @@ ${log}`;
2097
2104
  });
2098
2105
  }
2099
2106
  }
2100
- class Static extends F {
2107
+ class Static extends v {
2101
2108
  constructor(api) {
2102
2109
  super();
2103
2110
  __publicField(this, "api");
@@ -2110,9 +2117,9 @@ ${log}`;
2110
2117
  }
2111
2118
  upload(files, path = "/") {
2112
2119
  return new m(async (res, rej, prog) => {
2113
- return $t({
2120
+ return Dt({
2114
2121
  url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
2115
- files: Array.isArray(files) ? files : [files],
2122
+ files: ut(files),
2116
2123
  headers: this.api.headers
2117
2124
  }).onProgress((p2) => {
2118
2125
  prog(p2);
@@ -2123,7 +2130,7 @@ ${log}`;
2123
2130
  });
2124
2131
  }
2125
2132
  }
2126
- class Momentum extends F {
2133
+ class Momentum extends v {
2127
2134
  constructor(url, opts) {
2128
2135
  super();
2129
2136
  __publicField(this, "api");
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
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 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) {
4
+ var nt = Object.defineProperty;
5
+ var rt = (n, t, e) => t in n ? nt(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
6
+ var i = (n, t, e) => (rt(n, typeof t != "symbol" ? t + "" : t, e), e);
7
+ function ot(n, t = false) {
8
8
  if (n == null)
9
9
  throw new Error("Cannot clean a NULL value");
10
10
  return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
@@ -22,6 +22,9 @@ function U(n) {
22
22
  return n;
23
23
  }
24
24
  }
25
+ function ut(n) {
26
+ return Array.isArray(n) ? n : [n];
27
+ }
25
28
  class m extends Promise {
26
29
  constructor(e) {
27
30
  super((r, o) => e(
@@ -59,14 +62,15 @@ class m extends Promise {
59
62
  return this.from(super.finally(e));
60
63
  }
61
64
  }
62
- function at(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
- }
66
65
  function Tt(n, t) {
66
+ n instanceof Blob || (n = new Blob(ut(n)));
67
67
  const e = URL.createObjectURL(n);
68
68
  at(e, t), URL.revokeObjectURL(e);
69
69
  }
70
+ function at(n, t) {
71
+ const e = document.createElement("a");
72
+ e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
73
+ }
70
74
  function It(n = {}) {
71
75
  return new Promise((t) => {
72
76
  const e = document.createElement("input");
@@ -75,13 +79,13 @@ function It(n = {}) {
75
79
  }, document.body.appendChild(e), e.click();
76
80
  });
77
81
  }
78
- function $t(n) {
82
+ function Dt(n) {
79
83
  return new m((t, e, r) => {
80
84
  const o = new XMLHttpRequest(), s = new FormData();
81
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(U(o.responseText))), o.addEventListener("error", () => e(U(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
86
  });
83
87
  }
84
- class F {
88
+ class v {
85
89
  constructor() {
86
90
  i(this, "listeners", {});
87
91
  }
@@ -122,7 +126,7 @@ class F {
122
126
  });
123
127
  }
124
128
  }
125
- i(F, "listeners", {});
129
+ i(v, "listeners", {});
126
130
  class p extends Error {
127
131
  constructor(e, r) {
128
132
  super(e);
@@ -151,7 +155,7 @@ class p extends Error {
151
155
  }
152
156
  }
153
157
  i(p, "code", 500);
154
- class v extends p {
158
+ class Y extends p {
155
159
  constructor(t = "Bad Request") {
156
160
  super(t);
157
161
  }
@@ -159,8 +163,8 @@ class v extends p {
159
163
  return t.constructor.code == this.code;
160
164
  }
161
165
  }
162
- i(v, "code", 400);
163
- class Y extends p {
166
+ i(Y, "code", 400);
167
+ class H extends p {
164
168
  constructor(t = "Unauthorized") {
165
169
  super(t);
166
170
  }
@@ -168,8 +172,8 @@ class Y extends p {
168
172
  return t.constructor.code == this.code;
169
173
  }
170
174
  }
171
- i(Y, "code", 401);
172
- class H extends p {
175
+ i(H, "code", 401);
176
+ class W extends p {
173
177
  constructor(t = "Payment Required") {
174
178
  super(t);
175
179
  }
@@ -177,8 +181,8 @@ class H extends p {
177
181
  return t.constructor.code == this.code;
178
182
  }
179
183
  }
180
- i(H, "code", 402);
181
- class W extends p {
184
+ i(W, "code", 402);
185
+ class z extends p {
182
186
  constructor(t = "Forbidden") {
183
187
  super(t);
184
188
  }
@@ -186,8 +190,8 @@ class W extends p {
186
190
  return t.constructor.code == this.code;
187
191
  }
188
192
  }
189
- i(W, "code", 403);
190
- class z extends p {
193
+ i(z, "code", 403);
194
+ class J extends p {
191
195
  constructor(t = "Not Found") {
192
196
  super(t);
193
197
  }
@@ -195,8 +199,8 @@ class z extends p {
195
199
  return t.constructor.code == this.code;
196
200
  }
197
201
  }
198
- i(z, "code", 404);
199
- class J extends p {
202
+ i(J, "code", 404);
203
+ class K extends p {
200
204
  constructor(t = "Method Not Allowed") {
201
205
  super(t);
202
206
  }
@@ -204,8 +208,8 @@ class J extends p {
204
208
  return t.constructor.code == this.code;
205
209
  }
206
210
  }
207
- i(J, "code", 405);
208
- class K extends p {
211
+ i(K, "code", 405);
212
+ class Z extends p {
209
213
  constructor(t = "Not Acceptable") {
210
214
  super(t);
211
215
  }
@@ -213,8 +217,8 @@ class K extends p {
213
217
  return t.constructor.code == this.code;
214
218
  }
215
219
  }
216
- i(K, "code", 406);
217
- class Z extends p {
220
+ i(Z, "code", 406);
221
+ class V extends p {
218
222
  constructor(t = "Internal Server Error") {
219
223
  super(t);
220
224
  }
@@ -222,8 +226,8 @@ class Z extends p {
222
226
  return t.constructor.code == this.code;
223
227
  }
224
228
  }
225
- i(Z, "code", 500);
226
- class V extends p {
229
+ i(V, "code", 500);
230
+ class X extends p {
227
231
  constructor(t = "Not Implemented") {
228
232
  super(t);
229
233
  }
@@ -231,8 +235,8 @@ class V extends p {
231
235
  return t.constructor.code == this.code;
232
236
  }
233
237
  }
234
- i(V, "code", 501);
235
- class X extends p {
238
+ i(X, "code", 501);
239
+ class Q extends p {
236
240
  constructor(t = "Bad Gateway") {
237
241
  super(t);
238
242
  }
@@ -240,8 +244,8 @@ class X extends p {
240
244
  return t.constructor.code == this.code;
241
245
  }
242
246
  }
243
- i(X, "code", 502);
244
- class Q extends p {
247
+ i(Q, "code", 502);
248
+ class _ extends p {
245
249
  constructor(t = "Service Unavailable") {
246
250
  super(t);
247
251
  }
@@ -249,8 +253,8 @@ class Q extends p {
249
253
  return t.constructor.code == this.code;
250
254
  }
251
255
  }
252
- i(Q, "code", 503);
253
- class _ extends p {
256
+ i(_, "code", 503);
257
+ class tt extends p {
254
258
  constructor(t = "Gateway Timeout") {
255
259
  super(t);
256
260
  }
@@ -258,7 +262,7 @@ class _ extends p {
258
262
  return t.constructor.code == this.code;
259
263
  }
260
264
  }
261
- i(_, "code", 504);
265
+ i(tt, "code", 504);
262
266
  const w = class w2 {
263
267
  constructor(t = {}) {
264
268
  i(this, "interceptors", {});
@@ -287,7 +291,7 @@ const w = class w2 {
287
291
  const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
288
292
  e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
289
293
  }
290
- const r = rt({
294
+ const r = ot({
291
295
  "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
292
296
  ...w2.headers,
293
297
  ...this.headers,
@@ -298,36 +302,36 @@ const w = class w2 {
298
302
  headers: r,
299
303
  method: t.method || (t.body ? "POST" : "GET"),
300
304
  body: t.body
301
- }).then(async (a) => {
302
- var M, j;
303
- for (let u of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
304
- await new Promise((O) => u(a, () => O()));
305
- const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
306
- let k = 0;
307
- const T = (M = a.body) == null ? void 0 : M.getReader(), tt = new ReadableStream({
308
- start(u) {
305
+ }).then(async (u) => {
306
+ var j, k;
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"), C = R ? parseInt(R, 10) : 0;
310
+ let D = 0;
311
+ const N = (j = u.body) == null ? void 0 : j.getReader(), et = new ReadableStream({
312
+ start(a) {
309
313
  function O() {
310
- T == null || T.read().then((x) => {
311
- if (x.done)
312
- return u.close();
313
- k += x.value.byteLength, y(k / N), u.enqueue(x.value), O();
314
- }).catch((x) => u.error(x));
314
+ N == null || N.read().then((B) => {
315
+ if (B.done)
316
+ return a.close();
317
+ D += B.value.byteLength, y(D / C), a.enqueue(B.value), O();
318
+ }).catch((B) => a.error(B));
315
319
  }
316
320
  O();
317
321
  }
318
322
  });
319
- if (a.data = new Response(tt), t.decode == null || t.decode) {
320
- const u = (j = a.headers.get("Content-Type")) == null ? void 0 : j.toLowerCase();
321
- u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
323
+ if (u.data = new Response(et), t.decode == null || t.decode) {
324
+ const a = (k = u.headers.get("Content-Type")) == null ? void 0 : k.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());
322
326
  }
323
- a.ok ? s(a) : c(a);
327
+ u.ok ? s(u) : c(u);
324
328
  });
325
329
  });
326
330
  }
327
331
  };
328
332
  i(w, "interceptors", {}), i(w, "headers", {});
329
333
  let q = w;
330
- const B = {
334
+ const S = {
331
335
  CLEAR: "\x1B[0m",
332
336
  BRIGHT: "\x1B[1m",
333
337
  DIM: "\x1B[2m",
@@ -335,7 +339,7 @@ const B = {
335
339
  BLINK: "\x1B[5m",
336
340
  REVERSE: "\x1B[7m",
337
341
  HIDDEN: "\x1B[8m"
338
- }, L = {
342
+ }, $ = {
339
343
  BLACK: "\x1B[30m",
340
344
  RED: "\x1B[31m",
341
345
  GREEN: "\x1B[32m",
@@ -353,8 +357,8 @@ const B = {
353
357
  LIGHT_CYAN: "\x1B[96m",
354
358
  WHITE: "\x1B[97m"
355
359
  };
356
- var ut = /* @__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))(ut || {});
357
- const g = class g2 extends F {
360
+ var lt = /* @__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))(lt || {});
361
+ const g = class g2 extends v {
358
362
  constructor(t) {
359
363
  super(), this.namespace = t;
360
364
  }
@@ -373,31 +377,31 @@ const g = class g2 extends F {
373
377
  if (g2.LOG_LEVEL < 4)
374
378
  return;
375
379
  const e = this.format(...t);
376
- g2.emit(4, e), console.debug(L.LIGHT_GREY + e + B.CLEAR);
380
+ g2.emit(4, e), console.debug($.LIGHT_GREY + e + S.CLEAR);
377
381
  }
378
382
  log(...t) {
379
383
  if (g2.LOG_LEVEL < 3)
380
384
  return;
381
385
  const e = this.format(...t);
382
- g2.emit(3, e), console.log(B.CLEAR + e);
386
+ g2.emit(3, e), console.log(S.CLEAR + e);
383
387
  }
384
388
  info(...t) {
385
389
  if (g2.LOG_LEVEL < 2)
386
390
  return;
387
391
  const e = this.format(...t);
388
- g2.emit(2, e), console.info(L.BLUE + e + B.CLEAR);
392
+ g2.emit(2, e), console.info($.BLUE + e + S.CLEAR);
389
393
  }
390
394
  warn(...t) {
391
395
  if (g2.LOG_LEVEL < 1)
392
396
  return;
393
397
  const e = this.format(...t);
394
- g2.emit(1, e), console.warn(L.YELLOW + e + B.CLEAR);
398
+ g2.emit(1, e), console.warn($.YELLOW + e + S.CLEAR);
395
399
  }
396
400
  error(...t) {
397
401
  if (g2.LOG_LEVEL < 0)
398
402
  return;
399
403
  const e = this.format(...t);
400
- g2.emit(0, e), console.error(L.RED + e + B.CLEAR);
404
+ g2.emit(0, e), console.error($.RED + e + S.CLEAR);
401
405
  }
402
406
  };
403
407
  i(g, "LOG_LEVEL", 4);
@@ -405,7 +409,7 @@ class Api extends q {
405
409
  constructor(url = location.origin, opts = {}) {
406
410
  opts.url = url;
407
411
  super(opts);
408
- __publicField(this, "emitter", new F());
412
+ __publicField(this, "emitter", new v());
409
413
  __publicField(this, "_token", null);
410
414
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
411
415
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -1158,7 +1162,7 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
1158
1162
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1159
1163
  return ActionType2;
1160
1164
  })(ActionType || {});
1161
- class Actions extends F {
1165
+ class Actions extends v {
1162
1166
  constructor(api) {
1163
1167
  super();
1164
1168
  __publicField(this, "api");
@@ -1218,7 +1222,7 @@ class Actions extends F {
1218
1222
  });
1219
1223
  }
1220
1224
  }
1221
- class Ai extends F {
1225
+ class Ai extends v {
1222
1226
  constructor(api) {
1223
1227
  super();
1224
1228
  __publicField(this, "api");
@@ -1233,8 +1237,11 @@ class Ai extends F {
1233
1237
  return resp;
1234
1238
  });
1235
1239
  }
1240
+ clear() {
1241
+ return this.api.request({ url: "/api/ai", method: "DELETE" });
1242
+ }
1236
1243
  }
1237
- class Analytics extends F {
1244
+ class Analytics extends v {
1238
1245
  constructor(api) {
1239
1246
  super();
1240
1247
  __publicField(this, "api");
@@ -1259,13 +1266,13 @@ class Totp {
1259
1266
  return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1260
1267
  }
1261
1268
  setup(username, method = "app", totp) {
1262
- return this.api.request({ url: `/api/auth/totp/${username}`, body: rt({
1269
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: ot({
1263
1270
  method,
1264
1271
  totp
1265
1272
  }) });
1266
1273
  }
1267
1274
  }
1268
- class Auth extends F {
1275
+ class Auth extends v {
1269
1276
  constructor(api, opts = {}) {
1270
1277
  super();
1271
1278
  __publicField(this, "api");
@@ -1405,7 +1412,7 @@ class Auth extends F {
1405
1412
  });
1406
1413
  }
1407
1414
  }
1408
- class Data extends F {
1415
+ class Data extends v {
1409
1416
  constructor(api) {
1410
1417
  super();
1411
1418
  __publicField(this, "api");
@@ -1449,7 +1456,7 @@ class Data extends F {
1449
1456
  });
1450
1457
  }
1451
1458
  }
1452
- class Email extends F {
1459
+ class Email extends v {
1453
1460
  constructor(api) {
1454
1461
  super();
1455
1462
  __publicField(this, "api");
@@ -1464,7 +1471,7 @@ class Email extends F {
1464
1471
  });
1465
1472
  }
1466
1473
  }
1467
- class Groups extends F {
1474
+ class Groups extends v {
1468
1475
  constructor(api) {
1469
1476
  super();
1470
1477
  __publicField(this, "api");
@@ -1557,32 +1564,32 @@ ${log}`;
1557
1564
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1558
1565
  }
1559
1566
  debug(...logs) {
1560
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.DEBUG, logs) }).then(() => {
1567
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.DEBUG, logs) }).then(() => {
1561
1568
  }).catch(() => {
1562
1569
  });
1563
1570
  }
1564
1571
  log(...logs) {
1565
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.LOG, logs) }).then(() => {
1572
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.LOG, logs) }).then(() => {
1566
1573
  }).catch(() => {
1567
1574
  });
1568
1575
  }
1569
1576
  info(...logs) {
1570
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.INFO, logs) }).then(() => {
1577
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.INFO, logs) }).then(() => {
1571
1578
  }).catch(() => {
1572
1579
  });
1573
1580
  }
1574
1581
  warn(...logs) {
1575
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.WARN, logs) }).then(() => {
1582
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.WARN, logs) }).then(() => {
1576
1583
  }).catch(() => {
1577
1584
  });
1578
1585
  }
1579
1586
  error(...logs) {
1580
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.ERROR, logs) }).then(() => {
1587
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(lt.ERROR, logs) }).then(() => {
1581
1588
  }).catch(() => {
1582
1589
  });
1583
1590
  }
1584
1591
  }
1585
- class Payments extends F {
1592
+ class Payments extends v {
1586
1593
  constructor(api, secret) {
1587
1594
  super();
1588
1595
  __publicField(this, "api");
@@ -1623,7 +1630,7 @@ class Payments extends F {
1623
1630
  return history;
1624
1631
  }
1625
1632
  }
1626
- class Pdf extends F {
1633
+ class Pdf extends v {
1627
1634
  constructor(api) {
1628
1635
  super();
1629
1636
  __publicField(this, "api");
@@ -1696,7 +1703,7 @@ const _Socket = class _Socket {
1696
1703
  };
1697
1704
  __publicField(_Socket, "timeout", 1e4);
1698
1705
  let Socket = _Socket;
1699
- class Storage extends F {
1706
+ class Storage extends v {
1700
1707
  constructor(api) {
1701
1708
  super();
1702
1709
  __publicField(this, "api");
@@ -1759,9 +1766,9 @@ class Storage extends F {
1759
1766
  if (!files) files = await It(typeof opts == "object" ? opts : void 0);
1760
1767
  if (!files || Array.isArray(files) && !files.length) return [];
1761
1768
  const path = this.api.path("/api/storage/", typeof opts == "string" ? opts : opts.path || "");
1762
- return $t({
1769
+ return Dt({
1763
1770
  url: `${this.api.url}${path}`,
1764
- files: Array.isArray(files) ? files : [files],
1771
+ files: ut(files),
1765
1772
  headers: this.api.headers
1766
1773
  }).onProgress((p2) => {
1767
1774
  prog(p2);
@@ -1976,7 +1983,7 @@ class UI {
1976
1983
  }, 1e3);
1977
1984
  }
1978
1985
  }
1979
- class Users extends F {
1986
+ class Users extends v {
1980
1987
  constructor(api) {
1981
1988
  super();
1982
1989
  __publicField(this, "api");
@@ -2041,7 +2048,7 @@ class Users extends F {
2041
2048
  });
2042
2049
  }
2043
2050
  uploadImage(username, file) {
2044
- return $t({
2051
+ return Dt({
2045
2052
  url: this.api.url + `/api/users/${username}/image`,
2046
2053
  files: [file],
2047
2054
  headers: this.api.headers
@@ -2051,7 +2058,7 @@ class Users extends F {
2051
2058
  });
2052
2059
  }
2053
2060
  }
2054
- class Settings extends F {
2061
+ class Settings extends v {
2055
2062
  constructor(api) {
2056
2063
  super();
2057
2064
  __publicField(this, "api");
@@ -2093,7 +2100,7 @@ class Settings extends F {
2093
2100
  });
2094
2101
  }
2095
2102
  }
2096
- class Static extends F {
2103
+ class Static extends v {
2097
2104
  constructor(api) {
2098
2105
  super();
2099
2106
  __publicField(this, "api");
@@ -2106,9 +2113,9 @@ class Static extends F {
2106
2113
  }
2107
2114
  upload(files, path = "/") {
2108
2115
  return new m(async (res, rej, prog) => {
2109
- return $t({
2116
+ return Dt({
2110
2117
  url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
2111
- files: Array.isArray(files) ? files : [files],
2118
+ files: ut(files),
2112
2119
  headers: this.api.headers
2113
2120
  }).onProgress((p2) => {
2114
2121
  prog(p2);
@@ -2119,7 +2126,7 @@ class Static extends F {
2119
2126
  });
2120
2127
  }
2121
2128
  }
2122
- class Momentum extends F {
2129
+ class Momentum extends v {
2123
2130
  constructor(url, opts) {
2124
2131
  super();
2125
2132
  __publicField(this, "api");
package/dist/pdf.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../src/pdf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAW,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG;IACrC,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,CAAC;CAC3B,CAAA;AAED,qBAAa,GAAI,SAAQ,YAAY,CAAC,SAAS,CAAC;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;YAKf,cAAc;IAW5B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe;IAK/C,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe;IAKlE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe;CAI1C"}
1
+ {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../src/pdf.ts"],"names":[],"mappings":"AAAA,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AK7B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnC,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,SAAM,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;CAcnE"}
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAY,eAAe,EAAE,YAAY,EAAE,KAAK,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAE9G,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACxC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC;CACjC,CAAC;AAEF,qBAAa,MAAO,SAAQ,YAAY,CAAC,YAAY,CAAC;IACrD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnC,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,SAAM,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;CAcnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,IAAI,EAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,EACN,eAAe,EACf,YAAY,EACZ,KAAK,WAAW,EAChB,kBAAkB,EAElB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,CAAC,OAAO,GAAG,QAAQ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vD,QAAQ,CAAC,GAAG,EAAG,GAAG,CAAC;gBAEP,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAQ/C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAkB,GAAG;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAM,GAAG,eAAe,CAAC,IAAI,CAAC;IAWtG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAQ/C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,MAAM;IACzC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAS9D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAS3D,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,GAAE,MAAM,GAAG;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;CAkB3I"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.39.1",
3
+ "version": "0.39.3",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": ["Momentum"],
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
@@ -24,7 +24,7 @@
24
24
  "postbuild": "node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.cjs','../server/public/momentum.js')\""
25
25
  },
26
26
  "dependencies": {
27
- "@ztimson/utils": "0.15.6",
27
+ "@ztimson/utils": "0.16.1",
28
28
  "rxjs": "^7.8.1"
29
29
  },
30
30
  "devDependencies": {