@ztimson/momentum 0.28.3 → 0.28.5

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/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 Y = Object.defineProperty;
9
- var v = (n, e, t) => e in n ? Y(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
10
- var a = (n, e, t) => (v(n, typeof e != "symbol" ? e + "" : e, t), t);
11
- function F(n, e = false) {
8
+ var v = Object.defineProperty;
9
+ var F = (n, e, t) => e in n ? v(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
10
+ var a = (n, e, t) => (F(n, typeof e != "symbol" ? e + "" : e, t), t);
11
+ function W(n, e = 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((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
@@ -19,6 +19,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
19
19
  const t = typeof n, r = typeof e;
20
20
  return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? false : Object.keys(n).every((s) => b(n[s], e[s]));
21
21
  }
22
+ function q(n) {
23
+ try {
24
+ return JSON.parse(n);
25
+ } catch {
26
+ return n;
27
+ }
28
+ }
22
29
  class E extends Promise {
23
30
  constructor(t) {
24
31
  super((r, o) => t(
@@ -56,15 +63,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
56
63
  return this.from(super.finally(t));
57
64
  }
58
65
  }
59
- function V(n, e) {
66
+ function Z(n, e) {
60
67
  const t = document.createElement("a");
61
68
  t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
62
69
  }
63
- function wt(n, e) {
70
+ function Bt(n, e) {
64
71
  const t = URL.createObjectURL(n);
65
- V(t, e), URL.revokeObjectURL(t);
72
+ Z(t, e), URL.revokeObjectURL(t);
66
73
  }
67
- function xt(n = {}) {
74
+ function bt(n = {}) {
68
75
  return new Promise((e) => {
69
76
  const t = document.createElement("input");
70
77
  t.type = "file", t.accept = n.accept || "*", t.style.display = "none", t.multiple = !!n.multiple, t.onblur = t.onchange = async () => {
@@ -72,13 +79,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
72
79
  }, document.body.appendChild(t), t.click();
73
80
  });
74
81
  }
75
- function At(n) {
82
+ function Rt(n) {
76
83
  return new E((e, t, r) => {
77
84
  const o = new XMLHttpRequest(), s = new FormData();
78
- n.files.forEach((i) => s.append("file", i)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (i) => i.lengthComputable ? r(i.loaded / i.total) : null), o.upload.addEventListener("load", (i) => e(i)), o.upload.addEventListener("error", (i) => t(i)), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([i, y]) => o.setRequestHeader(i, y)), o.send(s);
85
+ n.files.forEach((i) => s.append("file", i)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (i) => i.lengthComputable ? r(i.loaded / i.total) : null), o.addEventListener("loadend", () => e(q(o.responseText))), o.addEventListener("error", () => t(q(o.responseText))), o.addEventListener("timeout", () => t({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([i, p]) => o.setRequestHeader(i, p)), o.send(s);
79
86
  });
80
87
  }
81
- class P {
88
+ class H {
82
89
  constructor() {
83
90
  a(this, "listeners", {});
84
91
  }
@@ -119,7 +126,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
119
126
  });
120
127
  }
121
128
  }
122
- a(P, "listeners", {});
129
+ a(H, "listeners", {});
123
130
  class w extends Error {
124
131
  constructor(t, r) {
125
132
  super(t);
@@ -148,7 +155,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
148
155
  }
149
156
  }
150
157
  a(w, "code", 500);
151
- class Z extends w {
158
+ class X extends w {
152
159
  constructor(e = "Bad Request") {
153
160
  super(e);
154
161
  }
@@ -156,8 +163,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
156
163
  return e.constructor.code == this.code;
157
164
  }
158
165
  }
159
- a(Z, "code", 400);
160
- class X extends w {
166
+ a(X, "code", 400);
167
+ class Q extends w {
161
168
  constructor(e = "Unauthorized") {
162
169
  super(e);
163
170
  }
@@ -165,8 +172,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
165
172
  return e.constructor.code == this.code;
166
173
  }
167
174
  }
168
- a(X, "code", 401);
169
- class Q extends w {
175
+ a(Q, "code", 401);
176
+ class _ extends w {
170
177
  constructor(e = "Forbidden") {
171
178
  super(e);
172
179
  }
@@ -174,8 +181,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
174
181
  return e.constructor.code == this.code;
175
182
  }
176
183
  }
177
- a(Q, "code", 403);
178
- class _ extends w {
184
+ a(_, "code", 403);
185
+ class tt extends w {
179
186
  constructor(e = "Not Found") {
180
187
  super(e);
181
188
  }
@@ -183,8 +190,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
183
190
  return e.constructor.code == this.code;
184
191
  }
185
192
  }
186
- a(_, "code", 404);
187
- class tt extends w {
193
+ a(tt, "code", 404);
194
+ class et extends w {
188
195
  constructor(e = "Internal Server Error") {
189
196
  super(e);
190
197
  }
@@ -192,7 +199,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
192
199
  return e.constructor.code == this.code;
193
200
  }
194
201
  }
195
- a(tt, "code", 500);
202
+ a(et, "code", 500);
196
203
  const g = class g2 {
197
204
  constructor(e = {}) {
198
205
  a(this, "interceptors", {});
@@ -221,36 +228,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
221
228
  const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((i) => ({ key: i, value: e.query[i] }));
222
229
  t += (t.includes("?") ? "&" : "?") + s.map((i) => `${i.key}=${i.value}`).join("&");
223
230
  }
224
- const r = F({
231
+ const r = W({
225
232
  "Content-Type": e.body ? e.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
226
233
  ...g2.headers,
227
234
  ...this.headers,
228
235
  ...e.headers
229
236
  });
230
- return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, y) => {
237
+ return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, p) => {
231
238
  fetch(t, {
232
239
  headers: r,
233
240
  method: e.method || (e.body ? "POST" : "GET"),
234
241
  body: e.body
235
242
  }).then(async (c) => {
236
- var k, G;
243
+ var j, G;
237
244
  for (let u of [...Object.values(g2.interceptors), ...Object.values(this.interceptors)])
238
- await new Promise((L) => u(c, () => L()));
245
+ await new Promise((O) => u(c, () => O()));
239
246
  const R = c.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
240
- let j = 0;
241
- const I = (k = c.body) == null ? void 0 : k.getReader(), H = new ReadableStream({
247
+ let k = 0;
248
+ const T = (j = c.body) == null ? void 0 : j.getReader(), Y = new ReadableStream({
242
249
  start(u) {
243
- function L() {
244
- I == null || I.read().then((x) => {
250
+ function O() {
251
+ T == null || T.read().then((x) => {
245
252
  if (x.done)
246
253
  return u.close();
247
- j += x.value.byteLength, y(j / N), u.enqueue(x.value), L();
254
+ k += x.value.byteLength, p(k / N), u.enqueue(x.value), O();
248
255
  }).catch((x) => u.error(x));
249
256
  }
250
- L();
257
+ O();
251
258
  }
252
259
  });
253
- if (c.data = new Response(H), e.decode == null || e.decode) {
260
+ if (c.data = new Response(Y), e.decode == null || e.decode) {
254
261
  const u = (G = c.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
255
262
  u != null && u.includes("form") ? c.data = await c.data.formData() : u != null && u.includes("json") ? c.data = await c.data.json() : u != null && u.includes("text") ? c.data = await c.data.text() : u != null && u.includes("application") && (c.data = await c.data.blob());
256
263
  }
@@ -269,7 +276,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
269
276
  BLINK: "\x1B[5m",
270
277
  REVERSE: "\x1B[7m",
271
278
  HIDDEN: "\x1B[8m"
272
- }, O = {
279
+ }, L = {
273
280
  BLACK: "\x1B[30m",
274
281
  RED: "\x1B[31m",
275
282
  GREEN: "\x1B[32m",
@@ -287,8 +294,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
287
294
  LIGHT_CYAN: "\x1B[96m",
288
295
  WHITE: "\x1B[97m"
289
296
  };
290
- var et = /* @__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))(et || {});
291
- const p = class p2 extends P {
297
+ var nt = /* @__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))(nt || {});
298
+ const y = class y2 extends H {
292
299
  constructor(e) {
293
300
  super(), this.namespace = e;
294
301
  }
@@ -296,50 +303,50 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
296
303
  const s = e.toString(), i = t - s.length;
297
304
  if (i <= 0)
298
305
  return s;
299
- const y = Array(~~(i / r.length)).fill(r).join("");
300
- return o ? s + y : y + s;
306
+ const p = Array(~~(i / r.length)).fill(r).join("");
307
+ return o ? s + p : p + s;
301
308
  }
302
309
  format(...e) {
303
310
  const t = /* @__PURE__ */ new Date();
304
311
  return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${e.join(" ")}`;
305
312
  }
306
313
  debug(...e) {
307
- if (p2.LOG_LEVEL < 4)
314
+ if (y2.LOG_LEVEL < 4)
308
315
  return;
309
316
  const t = this.format(...e);
310
- p2.emit(4, t), console.debug(O.LIGHT_GREY + t + A.CLEAR);
317
+ y2.emit(4, t), console.debug(L.LIGHT_GREY + t + A.CLEAR);
311
318
  }
312
319
  log(...e) {
313
- if (p2.LOG_LEVEL < 3)
320
+ if (y2.LOG_LEVEL < 3)
314
321
  return;
315
322
  const t = this.format(...e);
316
- p2.emit(3, t), console.log(A.CLEAR + t);
323
+ y2.emit(3, t), console.log(A.CLEAR + t);
317
324
  }
318
325
  info(...e) {
319
- if (p2.LOG_LEVEL < 2)
326
+ if (y2.LOG_LEVEL < 2)
320
327
  return;
321
328
  const t = this.format(...e);
322
- p2.emit(2, t), console.info(O.BLUE + t + A.CLEAR);
329
+ y2.emit(2, t), console.info(L.BLUE + t + A.CLEAR);
323
330
  }
324
331
  warn(...e) {
325
- if (p2.LOG_LEVEL < 1)
332
+ if (y2.LOG_LEVEL < 1)
326
333
  return;
327
334
  const t = this.format(...e);
328
- p2.emit(1, t), console.warn(O.YELLOW + t + A.CLEAR);
335
+ y2.emit(1, t), console.warn(L.YELLOW + t + A.CLEAR);
329
336
  }
330
337
  error(...e) {
331
- if (p2.LOG_LEVEL < 0)
338
+ if (y2.LOG_LEVEL < 0)
332
339
  return;
333
340
  const t = this.format(...e);
334
- p2.emit(0, t), console.error(O.RED + t + A.CLEAR);
341
+ y2.emit(0, t), console.error(L.RED + t + A.CLEAR);
335
342
  }
336
343
  };
337
- a(p, "LOG_LEVEL", 4);
344
+ a(y, "LOG_LEVEL", 4);
338
345
  class Api extends M {
339
346
  constructor(url = location.origin, opts = {}) {
340
347
  opts.url = url;
341
348
  super(opts);
342
- __publicField(this, "emitter", new P());
349
+ __publicField(this, "emitter", new H());
343
350
  __publicField(this, "_token", null);
344
351
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
345
352
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -377,7 +384,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
377
384
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
378
385
  d2.__proto__ = b3;
379
386
  } || function(d2, b3) {
380
- for (var p2 in b3) if (Object.prototype.hasOwnProperty.call(b3, p2)) d2[p2] = b3[p2];
387
+ for (var p in b3) if (Object.prototype.hasOwnProperty.call(b3, p)) d2[p] = b3[p];
381
388
  };
382
389
  return extendStatics(d, b2);
383
390
  };
@@ -1089,7 +1096,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1089
1096
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1090
1097
  return ActionType2;
1091
1098
  })(ActionType || {});
1092
- class Actions extends P {
1099
+ class Actions extends H {
1093
1100
  constructor(api) {
1094
1101
  super();
1095
1102
  __publicField(this, "api");
@@ -1155,13 +1162,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1155
1162
  return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1156
1163
  }
1157
1164
  setup(username, method = "app", totp) {
1158
- return this.api.request({ url: `/api/auth/totp/${username}`, body: F({
1165
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: W({
1159
1166
  method,
1160
1167
  totp
1161
1168
  }) });
1162
1169
  }
1163
1170
  }
1164
- class Auth extends P {
1171
+ class Auth extends H {
1165
1172
  constructor(api, opts) {
1166
1173
  var _a;
1167
1174
  super();
@@ -1292,7 +1299,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1292
1299
  });
1293
1300
  }
1294
1301
  }
1295
- class Data extends P {
1302
+ class Data extends H {
1296
1303
  constructor(api) {
1297
1304
  super();
1298
1305
  __publicField(this, "api");
@@ -1334,7 +1341,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1334
1341
  });
1335
1342
  }
1336
1343
  }
1337
- class Email extends P {
1344
+ class Email extends H {
1338
1345
  constructor(api) {
1339
1346
  super();
1340
1347
  __publicField(this, "api");
@@ -1349,7 +1356,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1349
1356
  });
1350
1357
  }
1351
1358
  }
1352
- class Groups extends P {
1359
+ class Groups extends H {
1353
1360
  constructor(api) {
1354
1361
  super();
1355
1362
  __publicField(this, "api");
@@ -1431,32 +1438,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1431
1438
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1432
1439
  }
1433
1440
  debug(...logs) {
1434
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(et.DEBUG, logs) }).then(() => {
1441
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.DEBUG, logs) }).then(() => {
1435
1442
  }).catch(() => {
1436
1443
  });
1437
1444
  }
1438
1445
  log(...logs) {
1439
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(et.LOG, logs) }).then(() => {
1446
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.LOG, logs) }).then(() => {
1440
1447
  }).catch(() => {
1441
1448
  });
1442
1449
  }
1443
1450
  info(...logs) {
1444
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(et.INFO, logs) }).then(() => {
1451
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.INFO, logs) }).then(() => {
1445
1452
  }).catch(() => {
1446
1453
  });
1447
1454
  }
1448
1455
  warn(...logs) {
1449
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(et.WARN, logs) }).then(() => {
1456
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.WARN, logs) }).then(() => {
1450
1457
  }).catch(() => {
1451
1458
  });
1452
1459
  }
1453
1460
  error(...logs) {
1454
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(et.ERROR, logs) }).then(() => {
1461
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(nt.ERROR, logs) }).then(() => {
1455
1462
  }).catch(() => {
1456
1463
  });
1457
1464
  }
1458
1465
  }
1459
- class Payments extends P {
1466
+ class Payments extends H {
1460
1467
  constructor(api, secret) {
1461
1468
  super();
1462
1469
  __publicField(this, "api");
@@ -1497,7 +1504,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1497
1504
  return history;
1498
1505
  }
1499
1506
  }
1500
- class Pdf extends P {
1507
+ class Pdf extends H {
1501
1508
  constructor(api) {
1502
1509
  super();
1503
1510
  __publicField(this, "api");
@@ -1507,7 +1514,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1507
1514
  const blob = await resp.blob();
1508
1515
  if (fileName) {
1509
1516
  const url = URL.createObjectURL(blob);
1510
- V(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1517
+ Z(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1511
1518
  URL.revokeObjectURL(url);
1512
1519
  }
1513
1520
  this.emit("CREATE", blob);
@@ -1570,7 +1577,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1570
1577
  };
1571
1578
  __publicField(_Socket, "timeout", 1e4);
1572
1579
  let Socket = _Socket;
1573
- class Storage extends P {
1580
+ class Storage extends H {
1574
1581
  constructor(api) {
1575
1582
  super();
1576
1583
  __publicField(this, "api");
@@ -1590,37 +1597,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1590
1597
  });
1591
1598
  }
1592
1599
  open(path, target = "_blank") {
1593
- const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1594
- const link = `${this.api.url}${p2}${this.api.token ? `?token=${this.api.token}` : ""}`;
1600
+ const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1601
+ const link = `${this.api.url}${p}${this.api.token ? `?token=${this.api.token}` : ""}`;
1595
1602
  if (!target) return link;
1596
1603
  this.emit("OPEN", path);
1597
1604
  return window.open(link, target);
1598
1605
  }
1599
1606
  mkdir(path) {
1600
- const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1601
- return this.api.request({ url: p2 + "?directory", method: "POST" });
1607
+ const p = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1608
+ return this.api.request({ url: p + "?directory", method: "POST" });
1602
1609
  }
1603
1610
  download(path, opts = {}) {
1604
- const p2 = ("/api/storage/" + path).replaceAll("//", "/");
1605
- return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
1611
+ const p = ("/api/storage/" + path).replaceAll("//", "/");
1612
+ return this.api.request({ ...opts, url: p, decode: false }).then(async (response) => {
1606
1613
  const blob = await response.blob();
1607
1614
  const name = opts.downloadAs || new URL(path).pathname.split("/").pop();
1608
1615
  this.emit("DOWNLOAD", path, blob);
1609
- wt(blob, name);
1616
+ Bt(blob, name);
1610
1617
  return response;
1611
1618
  });
1612
1619
  }
1613
1620
  upload(files, opts = "") {
1614
1621
  return new E(async (res, rej, prog) => {
1615
- if (!files) files = await xt();
1622
+ if (!files) files = await bt();
1616
1623
  if (!files || Array.isArray(files) && !files.length) return [];
1617
1624
  const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
1618
- return At({
1625
+ return Rt({
1619
1626
  url,
1620
1627
  files: Array.isArray(files) ? files : [files],
1621
1628
  headers: this.api.headers
1622
- }).onProgress((p2) => {
1623
- prog(p2);
1629
+ }).onProgress((p) => {
1630
+ prog(p);
1624
1631
  }).then((resp) => {
1625
1632
  this.emit("UPLOAD", resp);
1626
1633
  res(resp);
@@ -1634,6 +1641,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1634
1641
  }
1635
1642
  async inject(reload = false) {
1636
1643
  if (!Object.keys(this.settings.cache).length || reload) await this.settings.list();
1644
+ if (!document.querySelector('meta[name="apple-mobile-web-app-capable"]')) {
1645
+ const meta = document.createElement("meta");
1646
+ meta.name = "apple-mobile-web-app-capable";
1647
+ meta.content = "yes";
1648
+ document.head.append(meta);
1649
+ }
1650
+ if (!document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]')) {
1651
+ const meta = document.createElement("meta");
1652
+ meta.name = "apple-mobile-web-app-status-bar-style";
1653
+ meta.content = "default";
1654
+ document.head.append(meta);
1655
+ }
1656
+ if (!document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
1657
+ const meta = document.createElement("meta");
1658
+ meta.name = "apple-mobile-web-app-title";
1659
+ meta.content = this.settings.cache.title;
1660
+ document.head.append(meta);
1661
+ }
1662
+ if (!document.querySelector('link[rel="apple-touch-icon"]')) {
1663
+ const meta = document.createElement("link");
1664
+ meta.rel = "apple-touch-icon";
1665
+ meta.href = this.settings.cache.logo;
1666
+ document.head.append(meta);
1667
+ }
1668
+ if (!document.querySelector('link[rel="apple-touch-startup-image"]')) {
1669
+ const meta = document.createElement("link");
1670
+ meta.rel = "apple-touch-startup-image";
1671
+ meta.href = this.settings.cache.logo;
1672
+ document.head.append(meta);
1673
+ }
1637
1674
  window.document.body.classList.add(this.settings.cache.theme.darkMode ? "theme-dark" : "theme-light");
1638
1675
  window.document.body.classList.remove(this.settings.cache.theme.darkMode ? "theme-light" : "theme-dark");
1639
1676
  if (this.settings.cache.title)
@@ -1670,10 +1707,139 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1670
1707
  link.setAttribute("rel", "manifest");
1671
1708
  link.setAttribute("href", this.settings.api.url + "/manifest.json");
1672
1709
  window.document.head.append(link);
1710
+ this.iosPrompt();
1711
+ }
1712
+ }
1713
+ iosPrompt() {
1714
+ const url = this.settings.api.url;
1715
+ const settings = this.settings.cache;
1716
+ let dismissed = !!localStorage.getItem("ios-prompt");
1717
+ const ios = /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
1718
+ const pwa = window.matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
1719
+ function open() {
1720
+ let style = document.querySelector("style.ios-prompt");
1721
+ if (!style) {
1722
+ style = document.createElement("style");
1723
+ style.innerHTML = `
1724
+ .ios-prompt-backdrop {
1725
+ position: fixed;
1726
+ display: relative;
1727
+ left: 0;
1728
+ top: 0;
1729
+ right: 0;
1730
+ bottom: 0;
1731
+ background: rgba(0,0,0,.5);
1732
+ z-index: 9999;
1733
+ animation: fadeIn 0.5s ease-in-out forwards;
1734
+ opacity: 0;
1735
+ }
1736
+ .ios-prompt-backdrop.exit {
1737
+ animation: fadeOut 0.5s ease-in-out forwards !important;
1738
+ }
1739
+ .ios-prompt {
1740
+ position: fixed;
1741
+ background: #fff;
1742
+ color: black;
1743
+ bottom: 0;
1744
+ left: 50%;
1745
+ width: min(100vw, 450px);
1746
+ transform: translate(-50%, 0);
1747
+ animation: slideUp 0.5s ease-in-out forwards;
1748
+ }
1749
+ .ios-prompt.exit {
1750
+ animation: slideDown 0.5s ease-in-out forwards !important;
1751
+ }
1752
+ .ios-prompt img {
1753
+ width: 18px;
1754
+ height: 18px;
1755
+ }
1756
+ .ios-prompt h1 {
1757
+ font-size: 1.25rem;
1758
+ font-weight: bold;
1759
+ }
1760
+ .ios-prompt-close {
1761
+ position: absolute;
1762
+ right: 5px;
1763
+ top: 10px;
1764
+ background: transparent;
1765
+ border: none;
1766
+ cursor: pointer;
1767
+ }
1768
+
1769
+ @keyframes fadeIn {
1770
+ from { opacity: 0; }
1771
+ to { opacity: 1; }
1772
+ }
1773
+ @keyframes fadeOut {
1774
+ from { opacity: 1; }
1775
+ to { opacity: 0; }
1776
+ }
1777
+
1778
+ @keyframes slideUp {
1779
+ from { transform: translate(-50%, 100%); }
1780
+ to { transform: translate(-50%, 0); }
1781
+ }
1782
+ @keyframes slideDown {
1783
+ from { transform: translate(-50%, 0); }
1784
+ to { transform: translate(-50%, 100%); }
1785
+ }
1786
+ `;
1787
+ document.head.append(style);
1788
+ }
1789
+ const backdrop = document.createElement("div");
1790
+ backdrop.classList.add("ios-prompt-backdrop");
1791
+ const prompt = document.createElement("div");
1792
+ prompt.classList.add("ios-prompt");
1793
+ prompt.innerHTML = `
1794
+ <div style="display: flex; padding: 1rem; align-items: center">
1795
+ <img src="${url}${settings.logo}" alt="Logo" style="height: 30px; width: auto; margin-right: .5rem;" />
1796
+ <h1 style="margin: 0">Install ${settings.title}</h1>
1797
+ </div>
1798
+ <div style="display: flex; flex-direction: column; align-items: center">
1799
+ <div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
1800
+ <p style="margin-top: 1rem; text-align: center">This website can be installed as an App! Add it to your home screen for quick access & fullscreen use.</p>
1801
+ </div>
1802
+ <table style="margin: 1.5rem 0">
1803
+ <tr>
1804
+ <td style="width: 50px">
1805
+ <svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px"><path d="M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z" /><path d="M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z" /></svg>
1806
+ </td>
1807
+ <td>
1808
+ <p style="margin: 1rem 0">1) Press the "Share" button</p>
1809
+ </td>
1810
+ </tr>
1811
+ <tr>
1812
+ <td>
1813
+ <svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px"><path d="M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z" /><path d="M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z" /></svg>
1814
+ </td>
1815
+ <td>
1816
+ <p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
1817
+ </td>
1818
+ </tr>
1819
+ </table>
1820
+ </div>`;
1821
+ const close = document.createElement("button");
1822
+ close.classList.add("ios-prompt-close");
1823
+ close.innerText = "X";
1824
+ close.onclick = () => {
1825
+ prompt.classList.add("exit");
1826
+ backdrop.classList.add("exit");
1827
+ localStorage.setItem("ios-prompt", "dismissed");
1828
+ setTimeout(() => {
1829
+ prompt.remove();
1830
+ backdrop.remove();
1831
+ }, 500);
1832
+ };
1833
+ prompt.append(close);
1834
+ backdrop.append(prompt);
1835
+ document.body.append(backdrop);
1673
1836
  }
1837
+ setTimeout(() => {
1838
+ if (ios && !dismissed && !pwa) open();
1839
+ }, 1e3);
1674
1840
  }
1675
1841
  }
1676
- class Users extends P {
1842
+ class Users extends H {
1677
1843
  constructor(api) {
1678
1844
  super();
1679
1845
  __publicField(this, "api");
@@ -1738,7 +1904,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1738
1904
  });
1739
1905
  }
1740
1906
  uploadImage(username, file) {
1741
- return At({
1907
+ return Rt({
1742
1908
  url: this.api.url + `/api/users/${username}/image`,
1743
1909
  files: [file],
1744
1910
  headers: this.api.headers
@@ -1748,7 +1914,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1748
1914
  });
1749
1915
  }
1750
1916
  }
1751
- class Settings extends P {
1917
+ class Settings extends H {
1752
1918
  constructor(api) {
1753
1919
  super();
1754
1920
  __publicField(this, "api");
@@ -1790,7 +1956,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1790
1956
  });
1791
1957
  }
1792
1958
  }
1793
- class Static extends P {
1959
+ class Static extends H {
1794
1960
  constructor(api) {
1795
1961
  super();
1796
1962
  __publicField(this, "api");
@@ -1810,12 +1976,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1810
1976
  }
1811
1977
  upload(files, path = "/") {
1812
1978
  return new E(async (res, rej, prog) => {
1813
- return At({
1979
+ return Rt({
1814
1980
  url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
1815
1981
  files: Array.isArray(files) ? files : [files],
1816
1982
  headers: this.api.headers
1817
- }).onProgress((p2) => {
1818
- prog(p2);
1983
+ }).onProgress((p) => {
1984
+ prog(p);
1819
1985
  }).then((resp) => {
1820
1986
  this.emit("UPLOAD", resp);
1821
1987
  res(resp);
@@ -1823,7 +1989,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1823
1989
  });
1824
1990
  }
1825
1991
  }
1826
- class Momentum extends P {
1992
+ class Momentum extends H {
1827
1993
  constructor(url, opts) {
1828
1994
  super();
1829
1995
  __publicField(this, "api");