@ztimson/momentum 0.18.0 → 0.20.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/README.md +1 -1
- package/dist/actions.d.ts +13 -13
- package/dist/actions.d.ts.map +1 -1
- package/dist/email.d.ts +1 -1
- package/dist/email.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/momentum.cjs +3 -3
- package/dist/momentum.cjs.map +1 -1
- package/dist/momentum.d.ts +3 -1
- package/dist/momentum.d.ts.map +1 -1
- package/dist/momentum.mjs +262 -247
- package/dist/momentum.mjs.map +1 -1
- package/dist/pdf.d.ts +24 -0
- package/dist/pdf.d.ts.map +1 -0
- package/package.json +7 -2
package/dist/momentum.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (i, e, t) => (
|
|
4
|
-
var
|
|
5
|
-
function
|
|
1
|
+
var ut = Object.defineProperty;
|
|
2
|
+
var at = (i, e, t) => e in i ? ut(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var a = (i, e, t) => at(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
var ct = Object.defineProperty, ht = (i, e, t) => e in i ? ct(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, h = (i, e, t) => (ht(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
5
|
+
function lt(i, e = !1) {
|
|
6
6
|
if (i == null)
|
|
7
7
|
throw new Error("Cannot clean a NULL value");
|
|
8
8
|
return Array.isArray(i) ? i = i.filter((t) => t != null) : Object.entries(i).forEach(([t, r]) => {
|
|
@@ -13,7 +13,7 @@ function X(i, e) {
|
|
|
13
13
|
const t = typeof i, r = typeof e;
|
|
14
14
|
return t != "object" || i == null || r != "object" || e == null ? t == "function" && r == "function" ? i.toString() == e.toString() : i === e : Object.keys(i).length != Object.keys(e).length ? !1 : Object.keys(i).every((s) => X(i[s], e[s]));
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function Z(i, e) {
|
|
17
17
|
const t = document.createElement("a");
|
|
18
18
|
t.href = i, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
19
19
|
}
|
|
@@ -59,54 +59,7 @@ class d {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
h(d, "listeners", {});
|
|
62
|
-
|
|
63
|
-
constructor(e = {}) {
|
|
64
|
-
h(this, "interceptors", {}), h(this, "headers", {}), this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => b.addInterceptor(t));
|
|
65
|
-
}
|
|
66
|
-
static addInterceptor(e) {
|
|
67
|
-
const t = Object.keys(b.interceptors).length.toString();
|
|
68
|
-
return b.interceptors[t] = e, () => {
|
|
69
|
-
b.interceptors[t] = null;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
addInterceptor(e) {
|
|
73
|
-
const t = Object.keys(this.interceptors).length.toString();
|
|
74
|
-
return this.interceptors[t] = e, () => {
|
|
75
|
-
this.interceptors[t] = null;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async request(e = {}) {
|
|
79
|
-
var t, r;
|
|
80
|
-
if (!this.opts.url && !e.url)
|
|
81
|
-
throw new Error("URL needs to be set");
|
|
82
|
-
const s = ((t = e.url) != null && t.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), n = Et({
|
|
83
|
-
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
84
|
-
...b.headers,
|
|
85
|
-
...this.headers,
|
|
86
|
-
...e.headers
|
|
87
|
-
});
|
|
88
|
-
return fetch(s, {
|
|
89
|
-
headers: n,
|
|
90
|
-
method: e.method || (e.body ? "POST" : "GET"),
|
|
91
|
-
body: (r = n["Content-Type"]) != null && r.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
92
|
-
}).then(async (o) => {
|
|
93
|
-
var u, c;
|
|
94
|
-
for (let f of [...Object.values(b.interceptors), ...Object.values(this.interceptors)])
|
|
95
|
-
await new Promise((w) => f(o, () => w()));
|
|
96
|
-
if (!o.ok)
|
|
97
|
-
throw new Error(o.statusText);
|
|
98
|
-
return !e.skipConverting && (u = o.headers.get("Content-Type")) != null && u.startsWith("application/json") ? await o.json() : !e.skipConverting && (c = o.headers.get("Content-Type")) != null && c.startsWith("text/plain") ? await o.text() : o;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
h(B, "interceptors", {}), h(B, "headers", {});
|
|
103
|
-
let Z = B;
|
|
104
|
-
Z.addInterceptor((i, e) => {
|
|
105
|
-
if (i.status == 200)
|
|
106
|
-
return e();
|
|
107
|
-
throw i.status == 400 ? new tt(i.statusText) : i.status == 401 ? new et(i.statusText) : i.status == 403 ? new rt(i.statusText) : i.status == 404 ? new it(i.statusText) : i.status == 500 ? new st(i.statusText) : new v(i.statusText, i.status);
|
|
108
|
-
});
|
|
109
|
-
class v extends Error {
|
|
62
|
+
class L extends Error {
|
|
110
63
|
constructor(e, t) {
|
|
111
64
|
super(e), h(this, "_code"), t != null && (this._code = t);
|
|
112
65
|
}
|
|
@@ -131,8 +84,8 @@ class v extends Error {
|
|
|
131
84
|
return this.message || super.toString();
|
|
132
85
|
}
|
|
133
86
|
}
|
|
134
|
-
h(
|
|
135
|
-
class
|
|
87
|
+
h(L, "code", 500);
|
|
88
|
+
class pt extends L {
|
|
136
89
|
constructor(e = "Bad Request") {
|
|
137
90
|
super(e);
|
|
138
91
|
}
|
|
@@ -140,8 +93,8 @@ class tt extends v {
|
|
|
140
93
|
return e.constructor.code == this.code;
|
|
141
94
|
}
|
|
142
95
|
}
|
|
143
|
-
h(
|
|
144
|
-
class
|
|
96
|
+
h(pt, "code", 400);
|
|
97
|
+
class dt extends L {
|
|
145
98
|
constructor(e = "Unauthorized") {
|
|
146
99
|
super(e);
|
|
147
100
|
}
|
|
@@ -149,8 +102,8 @@ class et extends v {
|
|
|
149
102
|
return e.constructor.code == this.code;
|
|
150
103
|
}
|
|
151
104
|
}
|
|
152
|
-
h(
|
|
153
|
-
class
|
|
105
|
+
h(dt, "code", 401);
|
|
106
|
+
class ft extends L {
|
|
154
107
|
constructor(e = "Forbidden") {
|
|
155
108
|
super(e);
|
|
156
109
|
}
|
|
@@ -158,8 +111,8 @@ class rt extends v {
|
|
|
158
111
|
return e.constructor.code == this.code;
|
|
159
112
|
}
|
|
160
113
|
}
|
|
161
|
-
h(
|
|
162
|
-
class
|
|
114
|
+
h(ft, "code", 403);
|
|
115
|
+
class mt extends L {
|
|
163
116
|
constructor(e = "Not Found") {
|
|
164
117
|
super(e);
|
|
165
118
|
}
|
|
@@ -167,8 +120,8 @@ class it extends v {
|
|
|
167
120
|
return e.constructor.code == this.code;
|
|
168
121
|
}
|
|
169
122
|
}
|
|
170
|
-
h(
|
|
171
|
-
class
|
|
123
|
+
h(mt, "code", 404);
|
|
124
|
+
class yt extends L {
|
|
172
125
|
constructor(e = "Internal Server Error") {
|
|
173
126
|
super(e);
|
|
174
127
|
}
|
|
@@ -176,7 +129,7 @@ class st extends v {
|
|
|
176
129
|
return e.constructor.code == this.code;
|
|
177
130
|
}
|
|
178
131
|
}
|
|
179
|
-
h(
|
|
132
|
+
h(yt, "code", 500);
|
|
180
133
|
const O = {
|
|
181
134
|
CLEAR: "\x1B[0m",
|
|
182
135
|
BRIGHT: "\x1B[1m",
|
|
@@ -185,7 +138,7 @@ const O = {
|
|
|
185
138
|
BLINK: "\x1B[5m",
|
|
186
139
|
REVERSE: "\x1B[7m",
|
|
187
140
|
HIDDEN: "\x1B[8m"
|
|
188
|
-
},
|
|
141
|
+
}, _ = {
|
|
189
142
|
BLACK: "\x1B[30m",
|
|
190
143
|
RED: "\x1B[31m",
|
|
191
144
|
GREEN: "\x1B[32m",
|
|
@@ -203,7 +156,7 @@ const O = {
|
|
|
203
156
|
LIGHT_CYAN: "\x1B[96m",
|
|
204
157
|
WHITE: "\x1B[97m"
|
|
205
158
|
};
|
|
206
|
-
var
|
|
159
|
+
var S = /* @__PURE__ */ ((i) => (i[i.ERROR = 0] = "ERROR", i[i.WARN = 1] = "WARN", i[i.INFO = 2] = "INFO", i[i.LOG = 3] = "LOG", i[i.DEBUG = 4] = "DEBUG", i))(S || {});
|
|
207
160
|
const gt = class m extends d {
|
|
208
161
|
constructor(e) {
|
|
209
162
|
super(), this.namespace = e;
|
|
@@ -223,7 +176,7 @@ const gt = class m extends d {
|
|
|
223
176
|
if (m.LOG_LEVEL < 4)
|
|
224
177
|
return;
|
|
225
178
|
const t = this.format(...e);
|
|
226
|
-
m.emit(4, t), console.debug(
|
|
179
|
+
m.emit(4, t), console.debug(_.LIGHT_GREY + t + O.CLEAR);
|
|
227
180
|
}
|
|
228
181
|
log(...e) {
|
|
229
182
|
if (m.LOG_LEVEL < 3)
|
|
@@ -235,23 +188,23 @@ const gt = class m extends d {
|
|
|
235
188
|
if (m.LOG_LEVEL < 2)
|
|
236
189
|
return;
|
|
237
190
|
const t = this.format(...e);
|
|
238
|
-
m.emit(2, t), console.info(
|
|
191
|
+
m.emit(2, t), console.info(_.BLUE + t + O.CLEAR);
|
|
239
192
|
}
|
|
240
193
|
warn(...e) {
|
|
241
194
|
if (m.LOG_LEVEL < 1)
|
|
242
195
|
return;
|
|
243
196
|
const t = this.format(...e);
|
|
244
|
-
m.emit(1, t), console.warn(
|
|
197
|
+
m.emit(1, t), console.warn(_.YELLOW + t + O.CLEAR);
|
|
245
198
|
}
|
|
246
199
|
error(...e) {
|
|
247
200
|
if (m.LOG_LEVEL < 0)
|
|
248
201
|
return;
|
|
249
202
|
const t = this.format(...e);
|
|
250
|
-
m.emit(0, t), console.error(
|
|
203
|
+
m.emit(0, t), console.error(_.RED + t + O.CLEAR);
|
|
251
204
|
}
|
|
252
205
|
};
|
|
253
206
|
h(gt, "LOG_LEVEL", 4);
|
|
254
|
-
class
|
|
207
|
+
class Et extends Promise {
|
|
255
208
|
constructor(e) {
|
|
256
209
|
super((t, r) => e(
|
|
257
210
|
(s) => t(s),
|
|
@@ -269,7 +222,58 @@ class bt extends Promise {
|
|
|
269
222
|
return this.listeners.push(e), this;
|
|
270
223
|
}
|
|
271
224
|
}
|
|
272
|
-
|
|
225
|
+
const j = class v {
|
|
226
|
+
constructor(e = {}) {
|
|
227
|
+
h(this, "interceptors", {}), h(this, "headers", {}), this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => v.addInterceptor(t));
|
|
228
|
+
}
|
|
229
|
+
static addInterceptor(e) {
|
|
230
|
+
const t = Object.keys(v.interceptors).length.toString();
|
|
231
|
+
return v.interceptors[t] = e, () => {
|
|
232
|
+
v.interceptors[t] = null;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
addInterceptor(e) {
|
|
236
|
+
const t = Object.keys(this.interceptors).length.toString();
|
|
237
|
+
return this.interceptors[t] = e, () => {
|
|
238
|
+
this.interceptors[t] = null;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async request(e = {}) {
|
|
242
|
+
var t, r;
|
|
243
|
+
if (!this.opts.url && !e.url)
|
|
244
|
+
throw new Error("URL needs to be set");
|
|
245
|
+
let s = ((t = e.url) != null && t.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
246
|
+
if (e.fragment && (s.includes("#") ? s.replace(/#.*(\?|\n)/g, (o, u) => `#${e.fragment}${u}`) : s += "#" + e.fragment), e.query) {
|
|
247
|
+
const o = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((u) => ({ key: u, value: e.query[u] }));
|
|
248
|
+
s += (s.includes("?") ? "&" : "?") + o.map((u) => `${u.key}=${u.value}`).join("&");
|
|
249
|
+
}
|
|
250
|
+
const n = lt({
|
|
251
|
+
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
252
|
+
...v.headers,
|
|
253
|
+
...this.headers,
|
|
254
|
+
...e.headers
|
|
255
|
+
});
|
|
256
|
+
return fetch(s, {
|
|
257
|
+
headers: n,
|
|
258
|
+
method: e.method || (e.body ? "POST" : "GET"),
|
|
259
|
+
body: (r = n["Content-Type"]) != null && r.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
260
|
+
}).then(async (o) => {
|
|
261
|
+
for (let l of [...Object.values(v.interceptors), ...Object.values(this.interceptors)])
|
|
262
|
+
await new Promise((g) => l(o, () => g()));
|
|
263
|
+
const u = await (async () => {
|
|
264
|
+
var l, g;
|
|
265
|
+
return !e.skipConverting && (l = o.headers.get("Content-Type")) != null && l.startsWith("application/json") ? await o.json() : !e.skipConverting && (g = o.headers.get("Content-Type")) != null && g.startsWith("text/plain") ? await o.text() : o;
|
|
266
|
+
})();
|
|
267
|
+
if (o.ok)
|
|
268
|
+
return u;
|
|
269
|
+
const c = o.statusText || (typeof u == "string" ? u : null);
|
|
270
|
+
throw c ? new Error(c) : u;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
h(j, "interceptors", {}), h(j, "headers", {});
|
|
275
|
+
let bt = j;
|
|
276
|
+
class f extends bt {
|
|
273
277
|
constructor(t = location.origin, r = {}) {
|
|
274
278
|
r.url = t;
|
|
275
279
|
super(r);
|
|
@@ -294,71 +298,64 @@ class p extends Z {
|
|
|
294
298
|
return this.emit("REQUEST", r, t), r;
|
|
295
299
|
}
|
|
296
300
|
}
|
|
297
|
-
var
|
|
298
|
-
return
|
|
301
|
+
var k = function(i, e) {
|
|
302
|
+
return k = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
|
|
299
303
|
t.__proto__ = r;
|
|
300
304
|
} || function(t, r) {
|
|
301
|
-
for (var s in r)
|
|
302
|
-
|
|
303
|
-
}, j(i, e);
|
|
305
|
+
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
|
|
306
|
+
}, k(i, e);
|
|
304
307
|
};
|
|
305
|
-
function
|
|
308
|
+
function $(i, e) {
|
|
306
309
|
if (typeof e != "function" && e !== null)
|
|
307
310
|
throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
308
|
-
|
|
311
|
+
k(i, e);
|
|
309
312
|
function t() {
|
|
310
313
|
this.constructor = i;
|
|
311
314
|
}
|
|
312
315
|
i.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
313
316
|
}
|
|
314
|
-
function
|
|
317
|
+
function B(i) {
|
|
315
318
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && i[e], r = 0;
|
|
316
|
-
if (t)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
};
|
|
319
|
+
if (t) return t.call(i);
|
|
320
|
+
if (i && typeof i.length == "number") return {
|
|
321
|
+
next: function() {
|
|
322
|
+
return i && r >= i.length && (i = void 0), { value: i && i[r++], done: !i };
|
|
323
|
+
}
|
|
324
|
+
};
|
|
324
325
|
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
325
326
|
}
|
|
326
327
|
function G(i, e) {
|
|
327
328
|
var t = typeof Symbol == "function" && i[Symbol.iterator];
|
|
328
|
-
if (!t)
|
|
329
|
-
return i;
|
|
329
|
+
if (!t) return i;
|
|
330
330
|
var r = t.call(i), s, n = [], o;
|
|
331
331
|
try {
|
|
332
|
-
for (; (e === void 0 || e-- > 0) && !(s = r.next()).done; )
|
|
333
|
-
n.push(s.value);
|
|
332
|
+
for (; (e === void 0 || e-- > 0) && !(s = r.next()).done; ) n.push(s.value);
|
|
334
333
|
} catch (u) {
|
|
335
334
|
o = { error: u };
|
|
336
335
|
} finally {
|
|
337
336
|
try {
|
|
338
337
|
s && !s.done && (t = r.return) && t.call(r);
|
|
339
338
|
} finally {
|
|
340
|
-
if (o)
|
|
341
|
-
throw o.error;
|
|
339
|
+
if (o) throw o.error;
|
|
342
340
|
}
|
|
343
341
|
}
|
|
344
342
|
return n;
|
|
345
343
|
}
|
|
346
344
|
function N(i, e, t) {
|
|
347
|
-
if (t || arguments.length === 2)
|
|
348
|
-
|
|
349
|
-
(n || !(r in e)) && (n || (n = Array.prototype.slice.call(e, 0, r)), n[r] = e[r]);
|
|
345
|
+
if (t || arguments.length === 2) for (var r = 0, s = e.length, n; r < s; r++)
|
|
346
|
+
(n || !(r in e)) && (n || (n = Array.prototype.slice.call(e, 0, r)), n[r] = e[r]);
|
|
350
347
|
return i.concat(n || Array.prototype.slice.call(e));
|
|
351
348
|
}
|
|
352
|
-
function
|
|
349
|
+
function E(i) {
|
|
353
350
|
return typeof i == "function";
|
|
354
351
|
}
|
|
355
|
-
function
|
|
352
|
+
function tt(i) {
|
|
356
353
|
var e = function(r) {
|
|
357
354
|
Error.call(r), r.stack = new Error().stack;
|
|
358
355
|
}, t = i(e);
|
|
359
356
|
return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
|
|
360
357
|
}
|
|
361
|
-
var
|
|
358
|
+
var I = tt(function(i) {
|
|
362
359
|
return function(t) {
|
|
363
360
|
i(this), this.message = t ? t.length + ` errors occurred during unsubscription:
|
|
364
361
|
` + t.map(function(r, s) {
|
|
@@ -385,54 +382,52 @@ var P = function() {
|
|
|
385
382
|
if (o)
|
|
386
383
|
if (this._parentage = null, Array.isArray(o))
|
|
387
384
|
try {
|
|
388
|
-
for (var u =
|
|
389
|
-
var
|
|
390
|
-
|
|
385
|
+
for (var u = B(o), c = u.next(); !c.done; c = u.next()) {
|
|
386
|
+
var l = c.value;
|
|
387
|
+
l.remove(this);
|
|
391
388
|
}
|
|
392
|
-
} catch (
|
|
393
|
-
e = { error:
|
|
389
|
+
} catch (p) {
|
|
390
|
+
e = { error: p };
|
|
394
391
|
} finally {
|
|
395
392
|
try {
|
|
396
393
|
c && !c.done && (t = u.return) && t.call(u);
|
|
397
394
|
} finally {
|
|
398
|
-
if (e)
|
|
399
|
-
throw e.error;
|
|
395
|
+
if (e) throw e.error;
|
|
400
396
|
}
|
|
401
397
|
}
|
|
402
398
|
else
|
|
403
399
|
o.remove(this);
|
|
404
|
-
var
|
|
405
|
-
if (
|
|
400
|
+
var g = this.initialTeardown;
|
|
401
|
+
if (E(g))
|
|
406
402
|
try {
|
|
407
|
-
|
|
408
|
-
} catch (
|
|
409
|
-
n =
|
|
403
|
+
g();
|
|
404
|
+
} catch (p) {
|
|
405
|
+
n = p instanceof I ? p.errors : [p];
|
|
410
406
|
}
|
|
411
407
|
var T = this._finalizers;
|
|
412
408
|
if (T) {
|
|
413
409
|
this._finalizers = null;
|
|
414
410
|
try {
|
|
415
|
-
for (var
|
|
416
|
-
var
|
|
411
|
+
for (var b = B(T), y = b.next(); !y.done; y = b.next()) {
|
|
412
|
+
var A = y.value;
|
|
417
413
|
try {
|
|
418
|
-
V(
|
|
419
|
-
} catch (
|
|
420
|
-
n = n ?? [],
|
|
414
|
+
V(A);
|
|
415
|
+
} catch (p) {
|
|
416
|
+
n = n ?? [], p instanceof I ? n = N(N([], G(n)), G(p.errors)) : n.push(p);
|
|
421
417
|
}
|
|
422
418
|
}
|
|
423
|
-
} catch (
|
|
424
|
-
r = { error:
|
|
419
|
+
} catch (p) {
|
|
420
|
+
r = { error: p };
|
|
425
421
|
} finally {
|
|
426
422
|
try {
|
|
427
|
-
|
|
423
|
+
y && !y.done && (s = b.return) && s.call(b);
|
|
428
424
|
} finally {
|
|
429
|
-
if (r)
|
|
430
|
-
throw r.error;
|
|
425
|
+
if (r) throw r.error;
|
|
431
426
|
}
|
|
432
427
|
}
|
|
433
428
|
}
|
|
434
429
|
if (n)
|
|
435
|
-
throw new
|
|
430
|
+
throw new I(n);
|
|
436
431
|
}
|
|
437
432
|
}, i.prototype.add = function(e) {
|
|
438
433
|
var t;
|
|
@@ -463,46 +458,46 @@ var P = function() {
|
|
|
463
458
|
var e = new i();
|
|
464
459
|
return e.closed = !0, e;
|
|
465
460
|
}(), i;
|
|
466
|
-
}(),
|
|
467
|
-
function
|
|
468
|
-
return i instanceof P || i && "closed" in i &&
|
|
461
|
+
}(), et = P.EMPTY;
|
|
462
|
+
function rt(i) {
|
|
463
|
+
return i instanceof P || i && "closed" in i && E(i.remove) && E(i.add) && E(i.unsubscribe);
|
|
469
464
|
}
|
|
470
465
|
function V(i) {
|
|
471
|
-
|
|
466
|
+
E(i) ? i() : i.unsubscribe();
|
|
472
467
|
}
|
|
473
|
-
var
|
|
468
|
+
var it = {
|
|
474
469
|
onUnhandledError: null,
|
|
475
470
|
onStoppedNotification: null,
|
|
476
471
|
Promise: void 0,
|
|
477
472
|
useDeprecatedSynchronousErrorHandling: !1,
|
|
478
473
|
useDeprecatedNextContext: !1
|
|
479
|
-
},
|
|
474
|
+
}, st = {
|
|
480
475
|
setTimeout: function(i, e) {
|
|
481
476
|
for (var t = [], r = 2; r < arguments.length; r++)
|
|
482
477
|
t[r - 2] = arguments[r];
|
|
483
478
|
return setTimeout.apply(void 0, N([i, e], G(t)));
|
|
484
479
|
},
|
|
485
480
|
clearTimeout: function(i) {
|
|
486
|
-
var e =
|
|
481
|
+
var e = st.delegate;
|
|
487
482
|
return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(i);
|
|
488
483
|
},
|
|
489
484
|
delegate: void 0
|
|
490
485
|
};
|
|
491
486
|
function vt(i) {
|
|
492
|
-
|
|
487
|
+
st.setTimeout(function() {
|
|
493
488
|
throw i;
|
|
494
489
|
});
|
|
495
490
|
}
|
|
496
491
|
function K() {
|
|
497
492
|
}
|
|
498
|
-
function
|
|
493
|
+
function x(i) {
|
|
499
494
|
i();
|
|
500
495
|
}
|
|
501
|
-
var
|
|
502
|
-
|
|
496
|
+
var nt = function(i) {
|
|
497
|
+
$(e, i);
|
|
503
498
|
function e(t) {
|
|
504
499
|
var r = i.call(this) || this;
|
|
505
|
-
return r.isStopped = !1, t ? (r.destination = t,
|
|
500
|
+
return r.isStopped = !1, t ? (r.destination = t, rt(t) && t.add(r)) : r.destination = Tt, r;
|
|
506
501
|
}
|
|
507
502
|
return e.create = function(t, r, s) {
|
|
508
503
|
return new W(t, r, s);
|
|
@@ -543,7 +538,7 @@ var St = function() {
|
|
|
543
538
|
try {
|
|
544
539
|
t.next(e);
|
|
545
540
|
} catch (r) {
|
|
546
|
-
|
|
541
|
+
R(r);
|
|
547
542
|
}
|
|
548
543
|
}, i.prototype.error = function(e) {
|
|
549
544
|
var t = this.partialObserver;
|
|
@@ -551,24 +546,24 @@ var St = function() {
|
|
|
551
546
|
try {
|
|
552
547
|
t.error(e);
|
|
553
548
|
} catch (r) {
|
|
554
|
-
|
|
549
|
+
R(r);
|
|
555
550
|
}
|
|
556
551
|
else
|
|
557
|
-
|
|
552
|
+
R(e);
|
|
558
553
|
}, i.prototype.complete = function() {
|
|
559
554
|
var e = this.partialObserver;
|
|
560
555
|
if (e.complete)
|
|
561
556
|
try {
|
|
562
557
|
e.complete();
|
|
563
558
|
} catch (t) {
|
|
564
|
-
|
|
559
|
+
R(t);
|
|
565
560
|
}
|
|
566
561
|
}, i;
|
|
567
562
|
}(), W = function(i) {
|
|
568
|
-
|
|
563
|
+
$(e, i);
|
|
569
564
|
function e(t, r, s) {
|
|
570
565
|
var n = i.call(this) || this, o;
|
|
571
|
-
if (
|
|
566
|
+
if (E(t) || !t)
|
|
572
567
|
o = {
|
|
573
568
|
next: t ?? void 0,
|
|
574
569
|
error: r ?? void 0,
|
|
@@ -576,7 +571,7 @@ var St = function() {
|
|
|
576
571
|
};
|
|
577
572
|
else {
|
|
578
573
|
var u;
|
|
579
|
-
n &&
|
|
574
|
+
n && it.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() {
|
|
580
575
|
return n.unsubscribe();
|
|
581
576
|
}, o = {
|
|
582
577
|
next: t.next && C(t.next, u),
|
|
@@ -587,8 +582,8 @@ var St = function() {
|
|
|
587
582
|
return n.destination = new St(o), n;
|
|
588
583
|
}
|
|
589
584
|
return e;
|
|
590
|
-
}(
|
|
591
|
-
function
|
|
585
|
+
}(nt);
|
|
586
|
+
function R(i) {
|
|
592
587
|
vt(i);
|
|
593
588
|
}
|
|
594
589
|
function Lt(i) {
|
|
@@ -602,11 +597,11 @@ var Tt = {
|
|
|
602
597
|
}, Ot = function() {
|
|
603
598
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
604
599
|
}();
|
|
605
|
-
function
|
|
600
|
+
function $t(i) {
|
|
606
601
|
return i;
|
|
607
602
|
}
|
|
608
|
-
function
|
|
609
|
-
return i.length === 0 ?
|
|
603
|
+
function At(i) {
|
|
604
|
+
return i.length === 0 ? $t : i.length === 1 ? i[0] : function(t) {
|
|
610
605
|
return i.reduce(function(r, s) {
|
|
611
606
|
return s(r);
|
|
612
607
|
}, t);
|
|
@@ -620,8 +615,8 @@ var z = function() {
|
|
|
620
615
|
var t = new i();
|
|
621
616
|
return t.source = this, t.operator = e, t;
|
|
622
617
|
}, i.prototype.subscribe = function(e, t, r) {
|
|
623
|
-
var s = this, n =
|
|
624
|
-
return
|
|
618
|
+
var s = this, n = Rt(e) ? e : new W(e, t, r);
|
|
619
|
+
return x(function() {
|
|
625
620
|
var o = s, u = o.operator, c = o.source;
|
|
626
621
|
n.add(u ? u.call(n, c) : c ? s._subscribe(n) : s._trySubscribe(n));
|
|
627
622
|
}), n;
|
|
@@ -655,7 +650,7 @@ var z = function() {
|
|
|
655
650
|
}, i.prototype.pipe = function() {
|
|
656
651
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
657
652
|
e[t] = arguments[t];
|
|
658
|
-
return
|
|
653
|
+
return At(e)(this);
|
|
659
654
|
}, i.prototype.toPromise = function(e) {
|
|
660
655
|
var t = this;
|
|
661
656
|
return e = J(e), new e(function(r, s) {
|
|
@@ -674,20 +669,20 @@ var z = function() {
|
|
|
674
669
|
}();
|
|
675
670
|
function J(i) {
|
|
676
671
|
var e;
|
|
677
|
-
return (e = i ??
|
|
672
|
+
return (e = i ?? it.Promise) !== null && e !== void 0 ? e : Promise;
|
|
678
673
|
}
|
|
679
|
-
function
|
|
680
|
-
return i &&
|
|
674
|
+
function _t(i) {
|
|
675
|
+
return i && E(i.next) && E(i.error) && E(i.complete);
|
|
681
676
|
}
|
|
682
|
-
function
|
|
683
|
-
return i && i instanceof
|
|
677
|
+
function Rt(i) {
|
|
678
|
+
return i && i instanceof nt || _t(i) && rt(i);
|
|
684
679
|
}
|
|
685
|
-
var
|
|
680
|
+
var xt = tt(function(i) {
|
|
686
681
|
return function() {
|
|
687
682
|
i(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
688
683
|
};
|
|
689
|
-
}),
|
|
690
|
-
|
|
684
|
+
}), ot = function(i) {
|
|
685
|
+
$(e, i);
|
|
691
686
|
function e() {
|
|
692
687
|
var t = i.call(this) || this;
|
|
693
688
|
return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
|
|
@@ -697,33 +692,32 @@ var Rt = nt(function(i) {
|
|
|
697
692
|
return r.operator = t, r;
|
|
698
693
|
}, e.prototype._throwIfClosed = function() {
|
|
699
694
|
if (this.closed)
|
|
700
|
-
throw new
|
|
695
|
+
throw new xt();
|
|
701
696
|
}, e.prototype.next = function(t) {
|
|
702
697
|
var r = this;
|
|
703
|
-
|
|
698
|
+
x(function() {
|
|
704
699
|
var s, n;
|
|
705
700
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
706
701
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
707
702
|
try {
|
|
708
|
-
for (var o =
|
|
703
|
+
for (var o = B(r.currentObservers), u = o.next(); !u.done; u = o.next()) {
|
|
709
704
|
var c = u.value;
|
|
710
705
|
c.next(t);
|
|
711
706
|
}
|
|
712
|
-
} catch (
|
|
713
|
-
s = { error:
|
|
707
|
+
} catch (l) {
|
|
708
|
+
s = { error: l };
|
|
714
709
|
} finally {
|
|
715
710
|
try {
|
|
716
711
|
u && !u.done && (n = o.return) && n.call(o);
|
|
717
712
|
} finally {
|
|
718
|
-
if (s)
|
|
719
|
-
throw s.error;
|
|
713
|
+
if (s) throw s.error;
|
|
720
714
|
}
|
|
721
715
|
}
|
|
722
716
|
}
|
|
723
717
|
});
|
|
724
718
|
}, e.prototype.error = function(t) {
|
|
725
719
|
var r = this;
|
|
726
|
-
|
|
720
|
+
x(function() {
|
|
727
721
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
728
722
|
r.hasError = r.isStopped = !0, r.thrownError = t;
|
|
729
723
|
for (var s = r.observers; s.length; )
|
|
@@ -732,7 +726,7 @@ var Rt = nt(function(i) {
|
|
|
732
726
|
});
|
|
733
727
|
}, e.prototype.complete = function() {
|
|
734
728
|
var t = this;
|
|
735
|
-
|
|
729
|
+
x(function() {
|
|
736
730
|
if (t._throwIfClosed(), !t.isStopped) {
|
|
737
731
|
t.isStopped = !0;
|
|
738
732
|
for (var r = t.observers; r.length; )
|
|
@@ -754,7 +748,7 @@ var Rt = nt(function(i) {
|
|
|
754
748
|
return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
|
|
755
749
|
}, e.prototype._innerSubscribe = function(t) {
|
|
756
750
|
var r = this, s = this, n = s.hasError, o = s.isStopped, u = s.observers;
|
|
757
|
-
return n || o ?
|
|
751
|
+
return n || o ? et : (this.currentObservers = null, u.push(t), new P(function() {
|
|
758
752
|
r.currentObservers = null, H(u, t);
|
|
759
753
|
}));
|
|
760
754
|
}, e.prototype._checkFinalizedStatuses = function(t) {
|
|
@@ -767,7 +761,7 @@ var Rt = nt(function(i) {
|
|
|
767
761
|
return new Q(t, r);
|
|
768
762
|
}, e;
|
|
769
763
|
}(z), Q = function(i) {
|
|
770
|
-
|
|
764
|
+
$(e, i);
|
|
771
765
|
function e(t, r) {
|
|
772
766
|
var s = i.call(this) || this;
|
|
773
767
|
return s.destination = t, s.source = r, s;
|
|
@@ -783,10 +777,10 @@ var Rt = nt(function(i) {
|
|
|
783
777
|
(r = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || r === void 0 || r.call(t);
|
|
784
778
|
}, e.prototype._subscribe = function(t) {
|
|
785
779
|
var r, s;
|
|
786
|
-
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t)) !== null && s !== void 0 ? s :
|
|
780
|
+
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t)) !== null && s !== void 0 ? s : et;
|
|
787
781
|
}, e;
|
|
788
|
-
}(
|
|
789
|
-
|
|
782
|
+
}(ot), U = function(i) {
|
|
783
|
+
$(e, i);
|
|
790
784
|
function e(t) {
|
|
791
785
|
var r = i.call(this) || this;
|
|
792
786
|
return r._value = t, r;
|
|
@@ -808,13 +802,13 @@ var Rt = nt(function(i) {
|
|
|
808
802
|
}, e.prototype.next = function(t) {
|
|
809
803
|
i.prototype.next.call(this, this._value = t);
|
|
810
804
|
}, e;
|
|
811
|
-
}(
|
|
805
|
+
}(ot), qt = /* @__PURE__ */ ((i) => (i[i.CRON = 0] = "CRON", i[i.EVENT = 1] = "EVENT", i[i.DELETE = 2] = "DELETE", i[i.GET = 3] = "GET", i[i.PATCH = 4] = "PATCH", i[i.POST = 5] = "POST", i[i.PUT = 6] = "PUT", i))(qt || {});
|
|
812
806
|
class Pt extends d {
|
|
813
807
|
constructor(t) {
|
|
814
808
|
super();
|
|
815
809
|
a(this, "api");
|
|
816
|
-
a(this, "$cache", new
|
|
817
|
-
this.api = typeof t == "string" ? new
|
|
810
|
+
a(this, "$cache", new U([]));
|
|
811
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
818
812
|
}
|
|
819
813
|
get cache() {
|
|
820
814
|
return this.$cache.value;
|
|
@@ -839,7 +833,7 @@ class Pt extends d {
|
|
|
839
833
|
}
|
|
840
834
|
runById(t, r = {}) {
|
|
841
835
|
const s = typeof t == "string" ? t : t._id;
|
|
842
|
-
return this.api.request({ url: "/api/actions/run-by-id/" + s, ...r });
|
|
836
|
+
return this.api.request({ url: "/api/actions/run-by-id/" + s, method: "POST", ...r });
|
|
843
837
|
}
|
|
844
838
|
update(t) {
|
|
845
839
|
return this.api.request({
|
|
@@ -849,14 +843,14 @@ class Pt extends d {
|
|
|
849
843
|
}).then((r) => (r && (this.cache = this.cache.filter((s) => s._id != r._id).concat([r])), this.emit("UPDATE", r), r));
|
|
850
844
|
}
|
|
851
845
|
}
|
|
852
|
-
class
|
|
846
|
+
class Ut extends d {
|
|
853
847
|
constructor(t, r) {
|
|
854
848
|
var s;
|
|
855
849
|
super();
|
|
856
850
|
a(this, "api");
|
|
857
851
|
a(this, "storageKey");
|
|
858
|
-
a(this, "$user", new
|
|
859
|
-
if (this.opts = r, this.api = typeof t == "string" ? new
|
|
852
|
+
a(this, "$user", new U(void 0));
|
|
853
|
+
if (this.opts = r, this.api = typeof t == "string" ? new f(t) : t, (s = this.opts) != null && s.loginUi || (this.opts = { ...this.opts, loginUi: this.api.url + "/ui/login" }), this.storageKey = `momentum:${new URL(this.api.url).host}`, this.api.on("TOKEN", (n) => {
|
|
860
854
|
var o;
|
|
861
855
|
(o = this.opts) != null && o.persist && (n ? localStorage.setItem(this.storageKey, n) : localStorage.removeItem(this.storageKey)), n ? this.whoAmI(n, !0) : this.user = null;
|
|
862
856
|
}), r != null && r.persist) {
|
|
@@ -891,12 +885,10 @@ class It extends d {
|
|
|
891
885
|
return new Promise((r, s) => {
|
|
892
886
|
var o;
|
|
893
887
|
const n = window.open(encodeURI(`${(o = this.opts) == null ? void 0 : o.loginUi}?redirect=postmessage&host=${t}`), "_blank");
|
|
894
|
-
if (!n)
|
|
895
|
-
return s("Unable to open login");
|
|
888
|
+
if (!n) return s("Unable to open login");
|
|
896
889
|
n.addEventListener("message", (u) => {
|
|
897
890
|
var c;
|
|
898
|
-
if (!((c = u == null ? void 0 : u.data) != null && c.token))
|
|
899
|
-
return s("Unknown response from login");
|
|
891
|
+
if (!((c = u == null ? void 0 : u.data) != null && c.token)) return s("Unknown response from login");
|
|
900
892
|
this.api.token = u.data.token, r(u.data.token), n.close();
|
|
901
893
|
});
|
|
902
894
|
});
|
|
@@ -927,11 +919,11 @@ class It extends d {
|
|
|
927
919
|
return r && (this.api.token = t, this.user = (s == null ? void 0 : s.user) || null, s && this.emit("LOGIN", s.user)), s;
|
|
928
920
|
}
|
|
929
921
|
}
|
|
930
|
-
class
|
|
922
|
+
class Dt extends d {
|
|
931
923
|
constructor(t) {
|
|
932
924
|
super();
|
|
933
925
|
a(this, "api");
|
|
934
|
-
this.api = typeof t == "string" ? new
|
|
926
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
935
927
|
}
|
|
936
928
|
delete(t, r) {
|
|
937
929
|
return this.api.request({
|
|
@@ -960,11 +952,11 @@ class qt extends d {
|
|
|
960
952
|
}).then((n) => (this.emit("SET", t, r), n));
|
|
961
953
|
}
|
|
962
954
|
}
|
|
963
|
-
class
|
|
955
|
+
class It extends d {
|
|
964
956
|
constructor(t) {
|
|
965
957
|
super();
|
|
966
958
|
a(this, "api");
|
|
967
|
-
this.api = typeof t == "string" ? new
|
|
959
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
968
960
|
}
|
|
969
961
|
send(t) {
|
|
970
962
|
let r = "/api/email";
|
|
@@ -975,7 +967,7 @@ class Ct extends d {
|
|
|
975
967
|
constructor(t) {
|
|
976
968
|
super();
|
|
977
969
|
a(this, "api");
|
|
978
|
-
this.api = typeof t == "string" ? new
|
|
970
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
979
971
|
}
|
|
980
972
|
create(t) {
|
|
981
973
|
return this.api.request({
|
|
@@ -1004,10 +996,10 @@ class Ct extends d {
|
|
|
1004
996
|
}).then(() => this.emit("DELETE", t));
|
|
1005
997
|
}
|
|
1006
998
|
}
|
|
1007
|
-
class
|
|
999
|
+
class jt {
|
|
1008
1000
|
constructor(e, t) {
|
|
1009
1001
|
a(this, "api");
|
|
1010
|
-
this.api = typeof e == "string" ? new
|
|
1002
|
+
this.api = typeof e == "string" ? new f(e) : e, t != null && t != "NONE" && (window.addEventListener("error", (r) => this.error(r.error.stack)), window.addEventListener("unhandledrejection", async (r) => this.error(r.reason.stack)));
|
|
1011
1003
|
}
|
|
1012
1004
|
buildLog(e, t) {
|
|
1013
1005
|
return {
|
|
@@ -1037,33 +1029,58 @@ class Bt {
|
|
|
1037
1029
|
return this.api.request({ url: `/api/logs/server${r ? `?${r}` : ""}` });
|
|
1038
1030
|
}
|
|
1039
1031
|
debug(...e) {
|
|
1040
|
-
return this.api.request({ url: "/api/logs/client", body: this.buildLog(
|
|
1032
|
+
return this.api.request({ url: "/api/logs/client", body: this.buildLog(S.DEBUG, e) }).catch(() => {
|
|
1041
1033
|
});
|
|
1042
1034
|
}
|
|
1043
1035
|
log(...e) {
|
|
1044
|
-
return this.api.request({ url: "/api/logs/client", body: this.buildLog(
|
|
1036
|
+
return this.api.request({ url: "/api/logs/client", body: this.buildLog(S.LOG, e) }).catch(() => {
|
|
1045
1037
|
});
|
|
1046
1038
|
}
|
|
1047
1039
|
info(...e) {
|
|
1048
|
-
return this.api.request({ url: "/api/logs/client", body: this.buildLog(
|
|
1040
|
+
return this.api.request({ url: "/api/logs/client", body: this.buildLog(S.INFO, e) }).catch(() => {
|
|
1049
1041
|
});
|
|
1050
1042
|
}
|
|
1051
1043
|
warn(...e) {
|
|
1052
|
-
return this.api.request({ url: "/api/logs/client", body: this.buildLog(
|
|
1044
|
+
return this.api.request({ url: "/api/logs/client", body: this.buildLog(S.WARN, e) }).catch(() => {
|
|
1053
1045
|
});
|
|
1054
1046
|
}
|
|
1055
1047
|
error(...e) {
|
|
1056
|
-
return this.api.request({ url: "/api/logs/client", body: this.buildLog(
|
|
1048
|
+
return this.api.request({ url: "/api/logs/client", body: this.buildLog(S.ERROR, e) }).catch(() => {
|
|
1057
1049
|
});
|
|
1058
1050
|
}
|
|
1059
1051
|
}
|
|
1060
|
-
|
|
1052
|
+
class kt extends d {
|
|
1053
|
+
constructor(t) {
|
|
1054
|
+
super();
|
|
1055
|
+
a(this, "api");
|
|
1056
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
1057
|
+
}
|
|
1058
|
+
async handleResponse(t, r) {
|
|
1059
|
+
const s = await t.blob();
|
|
1060
|
+
if (r) {
|
|
1061
|
+
const n = URL.createObjectURL(s);
|
|
1062
|
+
Z(n, r.endsWith(".pdf") ? r : r + ".pdf"), URL.revokeObjectURL(n);
|
|
1063
|
+
}
|
|
1064
|
+
return this.emit("CREATE", s), s;
|
|
1065
|
+
}
|
|
1066
|
+
generate(t, r = {}) {
|
|
1067
|
+
const s = t == null ? void 0 : t.template;
|
|
1068
|
+
return this.api.request({
|
|
1069
|
+
url: `/api/pdf${s ? `/${s}` : ""}`,
|
|
1070
|
+
body: s ? t == null ? void 0 : t.data : { html: t }
|
|
1071
|
+
}).then((n) => this.handleResponse(n, r.download ? r.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1072
|
+
}
|
|
1073
|
+
fromUrl(t, r = {}) {
|
|
1074
|
+
return this.api.request({ url: `/api/pdf?url=${t}` }).then((s) => this.handleResponse(s, r.download ? r.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
const q = class q {
|
|
1061
1078
|
constructor(e) {
|
|
1062
1079
|
a(this, "api");
|
|
1063
1080
|
a(this, "url");
|
|
1064
1081
|
a(this, "connection");
|
|
1065
1082
|
a(this, "open", !1);
|
|
1066
|
-
this.api = typeof e == "string" ? new
|
|
1083
|
+
this.api = typeof e == "string" ? new f(e) : e, this.url = this.api.url.replace("http", "ws"), this.api.on("TOKEN", () => this.connect()), this.api.token || this.connect();
|
|
1067
1084
|
}
|
|
1068
1085
|
close() {
|
|
1069
1086
|
console.debug("Disconnected from Momentum"), this.open = !1, this.connection.close();
|
|
@@ -1073,7 +1090,7 @@ const D = class D {
|
|
|
1073
1090
|
((r = this.connection) == null ? void 0 : r.readyState) < 2 && this.connection.close(), this.connection = new WebSocket(this.url + (this.api.token ? `?token=${this.api.token}` : ""));
|
|
1074
1091
|
const t = setTimeout(() => {
|
|
1075
1092
|
this.open || (this.connection.close(), console.error("Momentum connection timeout"), e > 0 && this.connect(e - 1));
|
|
1076
|
-
},
|
|
1093
|
+
}, q.timeout);
|
|
1077
1094
|
this.connection.onclose = () => this.open = !1, this.connection.onmessage = this.handle, this.connection.onopen = () => {
|
|
1078
1095
|
this.open = !0, clearTimeout(t), console.debug("Connected to Momentum");
|
|
1079
1096
|
};
|
|
@@ -1089,13 +1106,13 @@ const D = class D {
|
|
|
1089
1106
|
}));
|
|
1090
1107
|
}
|
|
1091
1108
|
};
|
|
1092
|
-
a(
|
|
1093
|
-
let
|
|
1094
|
-
class
|
|
1109
|
+
a(q, "timeout", 1e4);
|
|
1110
|
+
let F = q;
|
|
1111
|
+
class Bt extends d {
|
|
1095
1112
|
constructor(t) {
|
|
1096
1113
|
super();
|
|
1097
1114
|
a(this, "api");
|
|
1098
|
-
this.api = typeof t == "string" ? new
|
|
1115
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
1099
1116
|
}
|
|
1100
1117
|
delete(t) {
|
|
1101
1118
|
const r = (t.startsWith("/api/storage/") ? t : "/api/storage/" + t).replaceAll("//", "/");
|
|
@@ -1116,25 +1133,24 @@ class jt extends d {
|
|
|
1116
1133
|
return this.api.request({ url: r + "?directory", method: "POST" });
|
|
1117
1134
|
}
|
|
1118
1135
|
download(t, r = {}) {
|
|
1119
|
-
return new
|
|
1136
|
+
return new Et((s, n, o) => {
|
|
1120
1137
|
const u = ("/api/storage/" + t).replaceAll("//", "/");
|
|
1121
1138
|
this.api.request({ ...r, url: u, skipConverting: !0 }).then((c) => {
|
|
1122
|
-
var
|
|
1123
|
-
if (!c.ok)
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
if (F.done) {
|
|
1139
|
+
var p;
|
|
1140
|
+
if (!c.ok) return n(c.statusText);
|
|
1141
|
+
const l = c.headers.get("Content-Length"), g = l ? parseInt(l, 10) : 0;
|
|
1142
|
+
let T = [], b = 0;
|
|
1143
|
+
const y = (p = c.body) == null ? void 0 : p.getReader(), A = (M) => {
|
|
1144
|
+
if (M.done) {
|
|
1129
1145
|
o(1);
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1146
|
+
const w = new Blob(T), D = r.downloadAs || new URL(c.url).pathname.split("/").pop(), Y = URL.createObjectURL(w);
|
|
1147
|
+
Z(Y, D.includes(".") ? D : D + ".zip"), URL.revokeObjectURL(Y), this.emit("DOWNLOAD", t, w), s(w);
|
|
1132
1148
|
} else {
|
|
1133
|
-
const
|
|
1134
|
-
T.push(
|
|
1149
|
+
const w = M.value;
|
|
1150
|
+
T.push(w), b += w.length, o(b / g), y.read().then(A);
|
|
1135
1151
|
}
|
|
1136
1152
|
};
|
|
1137
|
-
|
|
1153
|
+
y == null || y.read().then(A);
|
|
1138
1154
|
});
|
|
1139
1155
|
});
|
|
1140
1156
|
}
|
|
@@ -1144,19 +1160,18 @@ class jt extends d {
|
|
|
1144
1160
|
c.type = "file", c.accept = (r == null ? void 0 : r.accept) || "*", c.style.display = "none", c.multiple = !!(r != null && r.multiple), c.onblur = c.onchange = async () => {
|
|
1145
1161
|
u(Array.from(c.files)), c.remove();
|
|
1146
1162
|
}, document.body.appendChild(c), c.click();
|
|
1147
|
-
})), !t || Array.isArray(t) && !t.length)
|
|
1148
|
-
return [];
|
|
1163
|
+
})), !t || Array.isArray(t) && !t.length) return [];
|
|
1149
1164
|
const n = new FormData(), o = ("/api/storage/" + (typeof r == "string" ? r : r == null ? void 0 : r.path)).replaceAll("//", "/");
|
|
1150
1165
|
return (Array.isArray(t) ? t : [t]).forEach((u) => n.append("file", u)), this.api.request({ url: o, body: n }).then((u) => (this.emit("UPLOAD", u), u));
|
|
1151
1166
|
}
|
|
1152
1167
|
}
|
|
1153
|
-
class
|
|
1168
|
+
class Gt extends d {
|
|
1154
1169
|
constructor(t) {
|
|
1155
1170
|
super();
|
|
1156
1171
|
a(this, "api");
|
|
1157
1172
|
a(this, "listed", !1);
|
|
1158
|
-
a(this, "$cache", new
|
|
1159
|
-
this.api = typeof t == "string" ? new
|
|
1173
|
+
a(this, "$cache", new U([]));
|
|
1174
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
1160
1175
|
}
|
|
1161
1176
|
get cache() {
|
|
1162
1177
|
return this.$cache.value;
|
|
@@ -1178,8 +1193,7 @@ class kt extends d {
|
|
|
1178
1193
|
read(t, r = !1) {
|
|
1179
1194
|
if (!r) {
|
|
1180
1195
|
const s = this.cache.find((n) => n.username == t);
|
|
1181
|
-
if (s)
|
|
1182
|
-
return Promise.resolve(s);
|
|
1196
|
+
if (s) return Promise.resolve(s);
|
|
1183
1197
|
}
|
|
1184
1198
|
return this.api.request({ url: `/api/users/${t}` }).then((s) => (s && (this.cache = { ...this.cache, [s.username]: s }), this.emit("READ", s), s));
|
|
1185
1199
|
}
|
|
@@ -1191,12 +1205,12 @@ class kt extends d {
|
|
|
1191
1205
|
}).then((r) => (r && (this.cache = this.cache.filter((s) => s.username != t.username).concat([r])), this.emit("UPDATE", r), r));
|
|
1192
1206
|
}
|
|
1193
1207
|
}
|
|
1194
|
-
class
|
|
1208
|
+
class Nt extends d {
|
|
1195
1209
|
constructor(t) {
|
|
1196
1210
|
super();
|
|
1197
1211
|
a(this, "api");
|
|
1198
|
-
a(this, "$cache", new
|
|
1199
|
-
this.api = typeof t == "string" ? new
|
|
1212
|
+
a(this, "$cache", new U({}));
|
|
1213
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
1200
1214
|
}
|
|
1201
1215
|
get cache() {
|
|
1202
1216
|
return this.$cache.value;
|
|
@@ -1219,11 +1233,11 @@ class Gt extends d {
|
|
|
1219
1233
|
return this.api.request({ url: `/api/settings/${t.key}`, body: t }).then((r) => (r && (this.cache = { ...this.cache, [r.key]: r.value }), this.emit("UPDATE", r), r));
|
|
1220
1234
|
}
|
|
1221
1235
|
}
|
|
1222
|
-
class
|
|
1236
|
+
class Ht extends d {
|
|
1223
1237
|
constructor(t) {
|
|
1224
1238
|
super();
|
|
1225
1239
|
a(this, "api");
|
|
1226
|
-
this.api = typeof t == "string" ? new
|
|
1240
|
+
this.api = typeof t == "string" ? new f(t) : t;
|
|
1227
1241
|
}
|
|
1228
1242
|
delete(t) {
|
|
1229
1243
|
return this.api.request({ url: `/api/static/${t}`, method: "DELETE" }).then(() => {
|
|
@@ -1239,7 +1253,7 @@ class Nt extends d {
|
|
|
1239
1253
|
return (Array.isArray(t) ? t : [t]).forEach((n) => s.append("file", n)), this.api.request({ url: "/api/static" + r, body: s }).then((n) => (this.emit("UPLOAD", n), n));
|
|
1240
1254
|
}
|
|
1241
1255
|
}
|
|
1242
|
-
class
|
|
1256
|
+
class Ft extends d {
|
|
1243
1257
|
constructor(t, r) {
|
|
1244
1258
|
super();
|
|
1245
1259
|
a(this, "api");
|
|
@@ -1249,41 +1263,42 @@ class Wt extends d {
|
|
|
1249
1263
|
a(this, "email");
|
|
1250
1264
|
a(this, "groups");
|
|
1251
1265
|
a(this, "logger");
|
|
1266
|
+
a(this, "pdf");
|
|
1252
1267
|
a(this, "settings");
|
|
1253
1268
|
a(this, "socket");
|
|
1254
1269
|
a(this, "static");
|
|
1255
1270
|
a(this, "storage");
|
|
1256
1271
|
a(this, "users");
|
|
1257
|
-
this.api = new
|
|
1272
|
+
this.api = new f(t, r == null ? void 0 : r.api), this.actions = new Pt(this.api), this.auth = new Ut(this.api, {
|
|
1258
1273
|
persist: (r == null ? void 0 : r.persist) ?? !0,
|
|
1259
1274
|
loginUi: r == null ? void 0 : r.loginUi
|
|
1260
|
-
}), this.data = new
|
|
1275
|
+
}), this.data = new Dt(this.api), this.email = new It(this.api), this.groups = new Ct(this.api), this.logger = new jt(this.api, r == null ? void 0 : r.logLevel), this.pdf = new kt(this.api), this.settings = new Nt(this.api), this.static = new Ht(this.api), this.storage = new Bt(this.api), this.users = new Gt(this.api), r != null && r.socket && (this.socket = new F(this.api)), this.api.on("*", (s, ...n) => this.emit(`API::${s}`, ...n)), this.actions.on("*", (s, ...n) => this.emit(`ACTIONS::${s}`, ...n)), this.auth.on("*", (s, ...n) => this.emit(`AUTH::${s}`, ...n)), this.data.on("*", (s, ...n) => this.emit(`DATA::${s}`, ...n)), this.email.on("*", (s, ...n) => this.emit(`EMAIL::${s}`, ...n)), this.groups.on("*", (s, ...n) => this.emit(`GROUPS::${s}`, ...n)), this.pdf.on("*", (s, ...n) => this.emit(`PDF::${s}`, ...n)), this.settings.on("*", (s, ...n) => this.emit(`SETTINGS::${s}`, ...n)), this.static.on("*", (s, ...n) => this.emit(`STATIC::${s}`, ...n)), this.storage.on("*", (s, ...n) => this.emit(`STORAGE::${s}`, ...n)), this.users.on("*", (s, ...n) => this.emit(`USERS::${s}`, ...n)), this.users.on("*", (s, ...n) => {
|
|
1261
1276
|
var o;
|
|
1262
1277
|
if (Array.isArray(n[0])) {
|
|
1263
1278
|
const u = n[0].find((c) => {
|
|
1264
|
-
var
|
|
1265
|
-
return c._id == ((
|
|
1279
|
+
var l;
|
|
1280
|
+
return c._id == ((l = this.auth.user) == null ? void 0 : l._id);
|
|
1266
1281
|
});
|
|
1267
1282
|
u && (this.auth.user = u);
|
|
1268
|
-
} else
|
|
1269
|
-
n[0]._id == ((o = this.auth.user) == null ? void 0 : o._id) && (this.auth.user = n[0]);
|
|
1283
|
+
} else n[0]._id == ((o = this.auth.user) == null ? void 0 : o._id) && (this.auth.user = n[0]);
|
|
1270
1284
|
});
|
|
1271
1285
|
}
|
|
1272
1286
|
}
|
|
1273
1287
|
export {
|
|
1274
|
-
|
|
1288
|
+
qt as ActionType,
|
|
1275
1289
|
Pt as Actions,
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1290
|
+
f as Api,
|
|
1291
|
+
Ut as Auth,
|
|
1292
|
+
Dt as Data,
|
|
1293
|
+
It as Email,
|
|
1280
1294
|
Ct as Groups,
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1295
|
+
jt as Logger,
|
|
1296
|
+
Ft as Momentum,
|
|
1297
|
+
kt as Pdf,
|
|
1298
|
+
Nt as Settings,
|
|
1299
|
+
F as Socket,
|
|
1300
|
+
Ht as Static,
|
|
1301
|
+
Bt as Storage,
|
|
1302
|
+
Gt as Users
|
|
1288
1303
|
};
|
|
1289
1304
|
//# sourceMappingURL=momentum.mjs.map
|