@ztimson/momentum 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +2 -5
- package/dist/actions.d.ts.map +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts +1 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.cjs +686 -1157
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +684 -1155
- package/dist/momentum.d.ts +4 -4
- package/dist/momentum.d.ts.map +1 -1
- package/dist/settings.d.ts +4 -13
- package/dist/settings.d.ts.map +1 -1
- package/dist/users.d.ts +2 -5
- package/dist/users.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/ui.d.ts +0 -8
- package/dist/ui.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,59 +1,170 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}), n;
|
|
4
|
+
var it = Object.defineProperty;
|
|
5
|
+
var ct = (r, t, e) => t in r ? it(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
|
|
6
|
+
var c = (r, t, e) => ct(r, typeof t != "symbol" ? t + "" : t, e);
|
|
7
|
+
function ut(r, t = false) {
|
|
8
|
+
if (r == null) throw new Error("Cannot clean a NULL value");
|
|
9
|
+
return Array.isArray(r) ? r = r.filter((e) => e != null) : Object.entries(r).forEach(([e, n]) => {
|
|
10
|
+
(t && n === void 0 || !t && n == null) && delete r[e];
|
|
11
|
+
}), r;
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
const e = typeof
|
|
16
|
-
return e != "object" ||
|
|
13
|
+
function A(r, t) {
|
|
14
|
+
const e = typeof r, n = typeof t;
|
|
15
|
+
return e != "object" || r == null || n != "object" || t == null ? e == "function" && n == "function" ? r.toString() == t.toString() : r === t : Object.keys(r).length != Object.keys(t).length ? false : Object.keys(r).every((o) => A(r[o], t[o]));
|
|
17
16
|
}
|
|
18
|
-
function
|
|
17
|
+
function M(r) {
|
|
19
18
|
try {
|
|
20
|
-
return JSON.parse(
|
|
19
|
+
return JSON.parse(r);
|
|
21
20
|
} catch {
|
|
22
|
-
return
|
|
21
|
+
return r;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
24
|
+
function Lt(r, t) {
|
|
25
|
+
let e = [];
|
|
26
|
+
return JSON.stringify(r, (n, s) => {
|
|
27
|
+
if (typeof s == "object" && s !== null) {
|
|
28
|
+
if (e.includes(s)) return;
|
|
29
|
+
e.push(s);
|
|
30
|
+
}
|
|
31
|
+
return s;
|
|
32
|
+
}, t);
|
|
33
|
+
}
|
|
34
|
+
function ft(r) {
|
|
35
|
+
return Array.isArray(r) ? r : [r];
|
|
36
|
+
}
|
|
37
|
+
class Dt {
|
|
38
|
+
/**
|
|
39
|
+
* Create new cache
|
|
40
|
+
*
|
|
41
|
+
* @param {keyof T} key Default property to use as primary key
|
|
42
|
+
* @param {number} ttl Default expiry in milliseconds
|
|
43
|
+
*/
|
|
44
|
+
constructor(t, e) {
|
|
45
|
+
c(this, "store", {});
|
|
46
|
+
c(this, "complete", false);
|
|
47
|
+
c(this, "values", this.all());
|
|
48
|
+
return this.key = t, this.ttl = e, new Proxy(this, {
|
|
49
|
+
get: (n, s) => s in n ? n[s] : n.store[s],
|
|
50
|
+
set: (n, s, o) => (s in n ? n[s] = o : n.store[s] = o, true)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getKey(t) {
|
|
54
|
+
if (!this.key) throw new Error("No key defined");
|
|
55
|
+
return t[this.key];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all cached items
|
|
59
|
+
*
|
|
60
|
+
* @return {T[]} Array of items
|
|
61
|
+
*/
|
|
62
|
+
all() {
|
|
63
|
+
return Object.values(this.store);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Add a new item to the cache. Like set, but finds key automatically
|
|
67
|
+
*
|
|
68
|
+
* @param {T} value Item to add to cache
|
|
69
|
+
* @param {number | undefined} ttl Override default expiry
|
|
70
|
+
* @return {this}
|
|
71
|
+
*/
|
|
72
|
+
add(t, e = this.ttl) {
|
|
73
|
+
const n = this.getKey(t);
|
|
74
|
+
return this.set(n, t, e), this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Add several rows to the cache
|
|
78
|
+
*
|
|
79
|
+
* @param {T[]} rows Several items that will be cached using the default key
|
|
80
|
+
* @param complete Mark cache as complete & reliable, defaults to true
|
|
81
|
+
* @return {this}
|
|
82
|
+
*/
|
|
83
|
+
addAll(t, e = true) {
|
|
84
|
+
return t.forEach((n) => this.add(n)), this.complete = e, this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Delete an item from the cache
|
|
88
|
+
*
|
|
89
|
+
* @param {K} key Item's primary key
|
|
90
|
+
*/
|
|
91
|
+
delete(t) {
|
|
92
|
+
delete this.store[t];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Return cache as an array of key-value pairs
|
|
96
|
+
* @return {[K, T][]} Key-value pairs array
|
|
97
|
+
*/
|
|
98
|
+
entries() {
|
|
99
|
+
return Object.entries(this.store);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get item from the cache
|
|
103
|
+
* @param {K} key Key to lookup
|
|
104
|
+
* @return {T} Cached item
|
|
105
|
+
*/
|
|
106
|
+
get(t) {
|
|
107
|
+
return this.store[t];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get a list of cached keys
|
|
111
|
+
*
|
|
112
|
+
* @return {K[]} Array of keys
|
|
113
|
+
*/
|
|
114
|
+
keys() {
|
|
115
|
+
return Object.keys(this.store);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get map of cached items
|
|
119
|
+
*
|
|
120
|
+
* @return {Record<K, T>}
|
|
121
|
+
*/
|
|
122
|
+
map() {
|
|
123
|
+
return structuredClone(this.store);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Add an item to the cache manually specifying the key
|
|
127
|
+
*
|
|
128
|
+
* @param {K} key Key item will be cached under
|
|
129
|
+
* @param {T} value Item to cache
|
|
130
|
+
* @param {number | undefined} ttl Override default expiry
|
|
131
|
+
* @return {this}
|
|
132
|
+
*/
|
|
133
|
+
set(t, e, n = this.ttl) {
|
|
134
|
+
return this.store[t] = e, n && setTimeout(() => {
|
|
135
|
+
this.complete = false, this.delete(t);
|
|
136
|
+
}, n), this;
|
|
137
|
+
}
|
|
27
138
|
}
|
|
28
|
-
class
|
|
139
|
+
class E extends Promise {
|
|
29
140
|
constructor(e) {
|
|
30
|
-
super((
|
|
31
|
-
(
|
|
32
|
-
(
|
|
33
|
-
(
|
|
141
|
+
super((n, s) => e(
|
|
142
|
+
(o) => n(o),
|
|
143
|
+
(o) => s(o),
|
|
144
|
+
(o) => this.progress = o
|
|
34
145
|
));
|
|
35
|
-
|
|
36
|
-
|
|
146
|
+
c(this, "listeners", []);
|
|
147
|
+
c(this, "_progress", 0);
|
|
37
148
|
}
|
|
38
149
|
get progress() {
|
|
39
150
|
return this._progress;
|
|
40
151
|
}
|
|
41
152
|
set progress(e) {
|
|
42
|
-
e != this._progress && (this._progress = e, this.listeners.forEach((
|
|
153
|
+
e != this._progress && (this._progress = e, this.listeners.forEach((n) => n(e)));
|
|
43
154
|
}
|
|
44
155
|
static from(e) {
|
|
45
|
-
return e instanceof
|
|
156
|
+
return e instanceof E ? e : new E((n, s) => e.then((...o) => n(...o)).catch((...o) => s(...o)));
|
|
46
157
|
}
|
|
47
158
|
from(e) {
|
|
48
|
-
const
|
|
49
|
-
return this.onProgress((
|
|
159
|
+
const n = E.from(e);
|
|
160
|
+
return this.onProgress((s) => n.progress = s), n;
|
|
50
161
|
}
|
|
51
162
|
onProgress(e) {
|
|
52
163
|
return this.listeners.push(e), this;
|
|
53
164
|
}
|
|
54
|
-
then(e,
|
|
55
|
-
const
|
|
56
|
-
return this.from(
|
|
165
|
+
then(e, n) {
|
|
166
|
+
const s = super.then(e, n);
|
|
167
|
+
return this.from(s);
|
|
57
168
|
}
|
|
58
169
|
catch(e) {
|
|
59
170
|
return this.from(super.catch(e));
|
|
@@ -62,76 +173,76 @@ class m extends Promise {
|
|
|
62
173
|
return this.from(super.finally(e));
|
|
63
174
|
}
|
|
64
175
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
const e = URL.createObjectURL(
|
|
68
|
-
|
|
176
|
+
function Gt(r, t) {
|
|
177
|
+
r instanceof Blob || (r = new Blob(ft(r)));
|
|
178
|
+
const e = URL.createObjectURL(r);
|
|
179
|
+
dt(e, t), URL.revokeObjectURL(e);
|
|
69
180
|
}
|
|
70
|
-
function
|
|
181
|
+
function dt(r, t) {
|
|
71
182
|
const e = document.createElement("a");
|
|
72
|
-
e.href =
|
|
183
|
+
e.href = r, e.download = t || r.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
73
184
|
}
|
|
74
|
-
function
|
|
185
|
+
function Ut(r = {}) {
|
|
75
186
|
return new Promise((t) => {
|
|
76
187
|
const e = document.createElement("input");
|
|
77
|
-
e.type = "file", e.accept =
|
|
188
|
+
e.type = "file", e.accept = r.accept || "*", e.style.display = "none", e.multiple = !!r.multiple, e.onblur = e.onchange = async () => {
|
|
78
189
|
t(Array.from(e.files)), e.remove();
|
|
79
190
|
}, document.body.appendChild(e), e.click();
|
|
80
191
|
});
|
|
81
192
|
}
|
|
82
|
-
function
|
|
83
|
-
return new
|
|
84
|
-
const
|
|
85
|
-
|
|
193
|
+
function Ft(r) {
|
|
194
|
+
return new E((t, e, n) => {
|
|
195
|
+
const s = new XMLHttpRequest(), o = new FormData();
|
|
196
|
+
r.files.forEach((i) => o.append("file", i)), s.withCredentials = !!r.withCredentials, s.upload.addEventListener("progress", (i) => i.lengthComputable ? n(i.loaded / i.total) : null), s.addEventListener("loadend", () => t(M(s.responseText))), s.addEventListener("error", () => e(M(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", r.url), Object.entries(r.headers || {}).forEach(([i, a]) => s.setRequestHeader(i, a)), s.send(o);
|
|
86
197
|
});
|
|
87
198
|
}
|
|
88
|
-
class
|
|
199
|
+
class _ {
|
|
89
200
|
constructor() {
|
|
90
|
-
|
|
201
|
+
c(this, "listeners", {});
|
|
91
202
|
}
|
|
92
203
|
static emit(t, ...e) {
|
|
93
|
-
(this.listeners["*"] || []).forEach((
|
|
204
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t.toString()] || []).forEach((n) => n(...e));
|
|
94
205
|
}
|
|
95
206
|
static off(t, e) {
|
|
96
|
-
const
|
|
97
|
-
this.listeners[
|
|
207
|
+
const n = t.toString();
|
|
208
|
+
this.listeners[n] = (this.listeners[n] || []).filter((s) => s === e);
|
|
98
209
|
}
|
|
99
210
|
static on(t, e) {
|
|
100
|
-
var
|
|
101
|
-
const
|
|
102
|
-
return this.listeners[
|
|
211
|
+
var s;
|
|
212
|
+
const n = t.toString();
|
|
213
|
+
return this.listeners[n] || (this.listeners[n] = []), (s = this.listeners[n]) == null || s.push(e), () => this.off(t, e);
|
|
103
214
|
}
|
|
104
215
|
static once(t, e) {
|
|
105
|
-
return new Promise((
|
|
106
|
-
const
|
|
107
|
-
|
|
216
|
+
return new Promise((n) => {
|
|
217
|
+
const s = this.on(t, (...o) => {
|
|
218
|
+
n(o.length == 1 ? o[0] : o), e && e(...o), s();
|
|
108
219
|
});
|
|
109
220
|
});
|
|
110
221
|
}
|
|
111
222
|
emit(t, ...e) {
|
|
112
|
-
(this.listeners["*"] || []).forEach((
|
|
223
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t] || []).forEach((n) => n(...e));
|
|
113
224
|
}
|
|
114
225
|
off(t, e) {
|
|
115
|
-
this.listeners[t] = (this.listeners[t] || []).filter((
|
|
226
|
+
this.listeners[t] = (this.listeners[t] || []).filter((n) => n === e);
|
|
116
227
|
}
|
|
117
228
|
on(t, e) {
|
|
118
|
-
var
|
|
119
|
-
return this.listeners[t] || (this.listeners[t] = []), (
|
|
229
|
+
var n;
|
|
230
|
+
return this.listeners[t] || (this.listeners[t] = []), (n = this.listeners[t]) == null || n.push(e), () => this.off(t, e);
|
|
120
231
|
}
|
|
121
232
|
once(t, e) {
|
|
122
|
-
return new Promise((
|
|
123
|
-
const
|
|
124
|
-
|
|
233
|
+
return new Promise((n) => {
|
|
234
|
+
const s = this.on(t, (...o) => {
|
|
235
|
+
n(o.length == 1 ? o[0] : o), e && e(...o), s();
|
|
125
236
|
});
|
|
126
237
|
});
|
|
127
238
|
}
|
|
128
239
|
}
|
|
129
|
-
|
|
240
|
+
c(_, "listeners", {});
|
|
130
241
|
class p extends Error {
|
|
131
|
-
constructor(e,
|
|
242
|
+
constructor(e, n) {
|
|
132
243
|
super(e);
|
|
133
|
-
|
|
134
|
-
|
|
244
|
+
c(this, "_code");
|
|
245
|
+
n != null && (this._code = n);
|
|
135
246
|
}
|
|
136
247
|
get code() {
|
|
137
248
|
return this._code || this.constructor.code;
|
|
@@ -140,11 +251,11 @@ class p extends Error {
|
|
|
140
251
|
this._code = e;
|
|
141
252
|
}
|
|
142
253
|
static from(e) {
|
|
143
|
-
const
|
|
144
|
-
return Object.assign(
|
|
254
|
+
const n = Number(e.statusCode) ?? Number(e.code), s = new this(e.message || e.toString());
|
|
255
|
+
return Object.assign(s, {
|
|
145
256
|
stack: e.stack,
|
|
146
257
|
...e,
|
|
147
|
-
code:
|
|
258
|
+
code: n ?? void 0
|
|
148
259
|
});
|
|
149
260
|
}
|
|
150
261
|
static instanceof(e) {
|
|
@@ -154,8 +265,8 @@ class p extends Error {
|
|
|
154
265
|
return this.message || super.toString();
|
|
155
266
|
}
|
|
156
267
|
}
|
|
157
|
-
|
|
158
|
-
class
|
|
268
|
+
c(p, "code", 500);
|
|
269
|
+
class W extends p {
|
|
159
270
|
constructor(t = "Bad Request") {
|
|
160
271
|
super(t);
|
|
161
272
|
}
|
|
@@ -163,8 +274,8 @@ class Y extends p {
|
|
|
163
274
|
return t.constructor.code == this.code;
|
|
164
275
|
}
|
|
165
276
|
}
|
|
166
|
-
|
|
167
|
-
class
|
|
277
|
+
c(W, "code", 400);
|
|
278
|
+
class J extends p {
|
|
168
279
|
constructor(t = "Unauthorized") {
|
|
169
280
|
super(t);
|
|
170
281
|
}
|
|
@@ -172,8 +283,8 @@ class H extends p {
|
|
|
172
283
|
return t.constructor.code == this.code;
|
|
173
284
|
}
|
|
174
285
|
}
|
|
175
|
-
|
|
176
|
-
class
|
|
286
|
+
c(J, "code", 401);
|
|
287
|
+
class z extends p {
|
|
177
288
|
constructor(t = "Payment Required") {
|
|
178
289
|
super(t);
|
|
179
290
|
}
|
|
@@ -181,8 +292,8 @@ class W extends p {
|
|
|
181
292
|
return t.constructor.code == this.code;
|
|
182
293
|
}
|
|
183
294
|
}
|
|
184
|
-
|
|
185
|
-
class
|
|
295
|
+
c(z, "code", 402);
|
|
296
|
+
class K extends p {
|
|
186
297
|
constructor(t = "Forbidden") {
|
|
187
298
|
super(t);
|
|
188
299
|
}
|
|
@@ -190,8 +301,8 @@ class z extends p {
|
|
|
190
301
|
return t.constructor.code == this.code;
|
|
191
302
|
}
|
|
192
303
|
}
|
|
193
|
-
|
|
194
|
-
class
|
|
304
|
+
c(K, "code", 403);
|
|
305
|
+
class Z extends p {
|
|
195
306
|
constructor(t = "Not Found") {
|
|
196
307
|
super(t);
|
|
197
308
|
}
|
|
@@ -199,8 +310,8 @@ class J extends p {
|
|
|
199
310
|
return t.constructor.code == this.code;
|
|
200
311
|
}
|
|
201
312
|
}
|
|
202
|
-
|
|
203
|
-
class
|
|
313
|
+
c(Z, "code", 404);
|
|
314
|
+
class V extends p {
|
|
204
315
|
constructor(t = "Method Not Allowed") {
|
|
205
316
|
super(t);
|
|
206
317
|
}
|
|
@@ -208,8 +319,8 @@ class K extends p {
|
|
|
208
319
|
return t.constructor.code == this.code;
|
|
209
320
|
}
|
|
210
321
|
}
|
|
211
|
-
|
|
212
|
-
class
|
|
322
|
+
c(V, "code", 405);
|
|
323
|
+
class X extends p {
|
|
213
324
|
constructor(t = "Not Acceptable") {
|
|
214
325
|
super(t);
|
|
215
326
|
}
|
|
@@ -217,8 +328,8 @@ class Z extends p {
|
|
|
217
328
|
return t.constructor.code == this.code;
|
|
218
329
|
}
|
|
219
330
|
}
|
|
220
|
-
|
|
221
|
-
class
|
|
331
|
+
c(X, "code", 406);
|
|
332
|
+
class Q extends p {
|
|
222
333
|
constructor(t = "Internal Server Error") {
|
|
223
334
|
super(t);
|
|
224
335
|
}
|
|
@@ -226,8 +337,8 @@ class V extends p {
|
|
|
226
337
|
return t.constructor.code == this.code;
|
|
227
338
|
}
|
|
228
339
|
}
|
|
229
|
-
|
|
230
|
-
class
|
|
340
|
+
c(Q, "code", 500);
|
|
341
|
+
class tt extends p {
|
|
231
342
|
constructor(t = "Not Implemented") {
|
|
232
343
|
super(t);
|
|
233
344
|
}
|
|
@@ -235,8 +346,8 @@ class X extends p {
|
|
|
235
346
|
return t.constructor.code == this.code;
|
|
236
347
|
}
|
|
237
348
|
}
|
|
238
|
-
|
|
239
|
-
class
|
|
349
|
+
c(tt, "code", 501);
|
|
350
|
+
class et extends p {
|
|
240
351
|
constructor(t = "Bad Gateway") {
|
|
241
352
|
super(t);
|
|
242
353
|
}
|
|
@@ -244,8 +355,8 @@ class Q extends p {
|
|
|
244
355
|
return t.constructor.code == this.code;
|
|
245
356
|
}
|
|
246
357
|
}
|
|
247
|
-
|
|
248
|
-
class
|
|
358
|
+
c(et, "code", 502);
|
|
359
|
+
class rt extends p {
|
|
249
360
|
constructor(t = "Service Unavailable") {
|
|
250
361
|
super(t);
|
|
251
362
|
}
|
|
@@ -253,8 +364,8 @@ class _ extends p {
|
|
|
253
364
|
return t.constructor.code == this.code;
|
|
254
365
|
}
|
|
255
366
|
}
|
|
256
|
-
|
|
257
|
-
class
|
|
367
|
+
c(rt, "code", 503);
|
|
368
|
+
class nt extends p {
|
|
258
369
|
constructor(t = "Gateway Timeout") {
|
|
259
370
|
super(t);
|
|
260
371
|
}
|
|
@@ -262,12 +373,12 @@ class tt extends p {
|
|
|
262
373
|
return t.constructor.code == this.code;
|
|
263
374
|
}
|
|
264
375
|
}
|
|
265
|
-
|
|
376
|
+
c(nt, "code", 504);
|
|
266
377
|
const w = class w2 {
|
|
267
378
|
constructor(t = {}) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
379
|
+
c(this, "interceptors", {});
|
|
380
|
+
c(this, "headers", {});
|
|
381
|
+
c(this, "url");
|
|
271
382
|
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
|
|
272
383
|
}
|
|
273
384
|
static addInterceptor(t) {
|
|
@@ -283,55 +394,53 @@ const w = class w2 {
|
|
|
283
394
|
};
|
|
284
395
|
}
|
|
285
396
|
request(t = {}) {
|
|
286
|
-
var
|
|
287
|
-
if (!this.url && !t.url)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
|
|
397
|
+
var s;
|
|
398
|
+
if (!this.url && !t.url) throw new Error("URL needs to be set");
|
|
399
|
+
let e = ((s = t.url) != null && s.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
400
|
+
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (o, i) => `#${t.fragment}${i}`) : e += "#" + t.fragment), t.query) {
|
|
401
|
+
const o = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((i) => ({ key: i, value: t.query[i] }));
|
|
402
|
+
e += (e.includes("?") ? "&" : "?") + o.map((i) => `${i.key}=${i.value}`).join("&");
|
|
293
403
|
}
|
|
294
|
-
const
|
|
404
|
+
const n = ut({
|
|
295
405
|
"Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
|
|
296
406
|
...w2.headers,
|
|
297
407
|
...this.headers,
|
|
298
408
|
...t.headers
|
|
299
409
|
});
|
|
300
|
-
return typeof t.body == "object" && t.body != null &&
|
|
410
|
+
return typeof t.body == "object" && t.body != null && n["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new E((o, i, a) => {
|
|
301
411
|
fetch(e, {
|
|
302
|
-
headers:
|
|
412
|
+
headers: n,
|
|
303
413
|
method: t.method || (t.body ? "POST" : "GET"),
|
|
304
414
|
body: t.body
|
|
305
415
|
}).then(async (u) => {
|
|
306
|
-
var
|
|
307
|
-
for (let
|
|
308
|
-
await new Promise((
|
|
309
|
-
const
|
|
310
|
-
let
|
|
311
|
-
const
|
|
312
|
-
start(
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}).catch((B) => a.error(B));
|
|
416
|
+
var G, U;
|
|
417
|
+
for (let l of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
|
|
418
|
+
await new Promise((R) => l(u, () => R()));
|
|
419
|
+
const v = u.headers.get("Content-Length"), N = v ? parseInt(v, 10) : 0;
|
|
420
|
+
let P = 0;
|
|
421
|
+
const I = (G = u.body) == null ? void 0 : G.getReader(), ot = new ReadableStream({
|
|
422
|
+
start(l) {
|
|
423
|
+
function R() {
|
|
424
|
+
I == null || I.read().then((O) => {
|
|
425
|
+
if (O.done) return l.close();
|
|
426
|
+
P += O.value.byteLength, a(P / N), l.enqueue(O.value), R();
|
|
427
|
+
}).catch((O) => l.error(O));
|
|
319
428
|
}
|
|
320
|
-
|
|
429
|
+
R();
|
|
321
430
|
}
|
|
322
431
|
});
|
|
323
|
-
if (u.data = new Response(
|
|
324
|
-
const
|
|
325
|
-
|
|
432
|
+
if (u.data = new Response(ot), t.decode == null || t.decode) {
|
|
433
|
+
const l = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
|
|
434
|
+
l != null && l.includes("form") ? u.data = await u.data.formData() : l != null && l.includes("json") ? u.data = await u.data.json() : l != null && l.includes("text") ? u.data = await u.data.text() : l != null && l.includes("application") && (u.data = await u.data.blob());
|
|
326
435
|
}
|
|
327
|
-
u.ok ?
|
|
436
|
+
u.ok ? o(u) : i(u);
|
|
328
437
|
});
|
|
329
438
|
});
|
|
330
439
|
}
|
|
331
440
|
};
|
|
332
|
-
|
|
333
|
-
let
|
|
334
|
-
const
|
|
441
|
+
c(w, "interceptors", {}), c(w, "headers", {});
|
|
442
|
+
let F = w;
|
|
443
|
+
const x = {
|
|
335
444
|
CLEAR: "\x1B[0m",
|
|
336
445
|
BRIGHT: "\x1B[1m",
|
|
337
446
|
DIM: "\x1B[2m",
|
|
@@ -339,7 +448,7 @@ const S = {
|
|
|
339
448
|
BLINK: "\x1B[5m",
|
|
340
449
|
REVERSE: "\x1B[7m",
|
|
341
450
|
HIDDEN: "\x1B[8m"
|
|
342
|
-
},
|
|
451
|
+
}, j = {
|
|
343
452
|
BLACK: "\x1B[30m",
|
|
344
453
|
RED: "\x1B[31m",
|
|
345
454
|
GREEN: "\x1B[32m",
|
|
@@ -357,59 +466,187 @@ const S = {
|
|
|
357
466
|
LIGHT_CYAN: "\x1B[96m",
|
|
358
467
|
WHITE: "\x1B[97m"
|
|
359
468
|
};
|
|
360
|
-
var
|
|
361
|
-
const g = class g2 extends
|
|
469
|
+
var yt = /* @__PURE__ */ ((r) => (r[r.ERROR = 0] = "ERROR", r[r.WARN = 1] = "WARN", r[r.INFO = 2] = "INFO", r[r.LOG = 3] = "LOG", r[r.DEBUG = 4] = "DEBUG", r))(yt || {});
|
|
470
|
+
const g = class g2 extends _ {
|
|
362
471
|
constructor(t) {
|
|
363
472
|
super(), this.namespace = t;
|
|
364
473
|
}
|
|
365
|
-
pad(t, e,
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return o ? s + y : y + s;
|
|
474
|
+
pad(t, e, n, s = false) {
|
|
475
|
+
const o = t.toString(), i = e - o.length;
|
|
476
|
+
if (i <= 0) return o;
|
|
477
|
+
const a = Array(~~(i / n.length)).fill(n).join("");
|
|
478
|
+
return s ? o + a : a + o;
|
|
371
479
|
}
|
|
372
480
|
format(...t) {
|
|
373
481
|
const e = /* @__PURE__ */ new Date();
|
|
374
482
|
return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
|
|
375
483
|
}
|
|
376
484
|
debug(...t) {
|
|
377
|
-
if (g2.LOG_LEVEL < 4)
|
|
378
|
-
return;
|
|
485
|
+
if (g2.LOG_LEVEL < 4) return;
|
|
379
486
|
const e = this.format(...t);
|
|
380
|
-
g2.emit(4, e), console.debug(
|
|
487
|
+
g2.emit(4, e), console.debug(j.LIGHT_GREY + e + x.CLEAR);
|
|
381
488
|
}
|
|
382
489
|
log(...t) {
|
|
383
|
-
if (g2.LOG_LEVEL < 3)
|
|
384
|
-
return;
|
|
490
|
+
if (g2.LOG_LEVEL < 3) return;
|
|
385
491
|
const e = this.format(...t);
|
|
386
|
-
g2.emit(3, e), console.log(
|
|
492
|
+
g2.emit(3, e), console.log(x.CLEAR + e);
|
|
387
493
|
}
|
|
388
494
|
info(...t) {
|
|
389
|
-
if (g2.LOG_LEVEL < 2)
|
|
390
|
-
return;
|
|
495
|
+
if (g2.LOG_LEVEL < 2) return;
|
|
391
496
|
const e = this.format(...t);
|
|
392
|
-
g2.emit(2, e), console.info(
|
|
497
|
+
g2.emit(2, e), console.info(j.BLUE + e + x.CLEAR);
|
|
393
498
|
}
|
|
394
499
|
warn(...t) {
|
|
395
|
-
if (g2.LOG_LEVEL < 1)
|
|
396
|
-
return;
|
|
500
|
+
if (g2.LOG_LEVEL < 1) return;
|
|
397
501
|
const e = this.format(...t);
|
|
398
|
-
g2.emit(1, e), console.warn(
|
|
502
|
+
g2.emit(1, e), console.warn(j.YELLOW + e + x.CLEAR);
|
|
399
503
|
}
|
|
400
504
|
error(...t) {
|
|
401
|
-
if (g2.LOG_LEVEL < 0)
|
|
402
|
-
return;
|
|
505
|
+
if (g2.LOG_LEVEL < 0) return;
|
|
403
506
|
const e = this.format(...t);
|
|
404
|
-
g2.emit(0, e), console.error(
|
|
507
|
+
g2.emit(0, e), console.error(j.RED + e + x.CLEAR);
|
|
405
508
|
}
|
|
406
509
|
};
|
|
407
|
-
|
|
408
|
-
|
|
510
|
+
c(g, "LOG_LEVEL", 4);
|
|
511
|
+
var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, xt = {}, S = {};
|
|
512
|
+
Object.defineProperty(S, "__esModule", { value: true });
|
|
513
|
+
S.persist = S.Persist = void 0;
|
|
514
|
+
class st {
|
|
515
|
+
/**
|
|
516
|
+
* @param {string} key Primary key value will be stored under
|
|
517
|
+
* @param {PersistOptions<T>} options Configure using {@link PersistOptions}
|
|
518
|
+
*/
|
|
519
|
+
constructor(t, e = {}) {
|
|
520
|
+
c(this, "key");
|
|
521
|
+
c(this, "options");
|
|
522
|
+
c(this, "storage");
|
|
523
|
+
c(this, "watches", {});
|
|
524
|
+
c(this, "_value");
|
|
525
|
+
this.key = t, this.options = e, this.storage = e.storage || localStorage, this.load();
|
|
526
|
+
}
|
|
527
|
+
/** Current value or default if undefined */
|
|
528
|
+
get value() {
|
|
529
|
+
var t;
|
|
530
|
+
return this._value !== void 0 ? this._value : (t = this.options) == null ? void 0 : t.default;
|
|
531
|
+
}
|
|
532
|
+
/** Set value with proxy object wrapper to sync future changes */
|
|
533
|
+
set value(t) {
|
|
534
|
+
t == null || typeof t != "object" ? this._value = t : this._value = new Proxy(t, {
|
|
535
|
+
get: (e, n) => typeof e[n] == "function" ? (...o) => {
|
|
536
|
+
const i = e[n](...o);
|
|
537
|
+
return this.save(), i;
|
|
538
|
+
} : e[n],
|
|
539
|
+
set: (e, n, s) => (e[n] = s, this.save(), true)
|
|
540
|
+
}), this.save();
|
|
541
|
+
}
|
|
542
|
+
/** Notify listeners of change */
|
|
543
|
+
notify(t) {
|
|
544
|
+
Object.values(this.watches).forEach((e) => e(t));
|
|
545
|
+
}
|
|
546
|
+
/** Delete value from storage */
|
|
547
|
+
clear() {
|
|
548
|
+
this.storage.removeItem(this.key);
|
|
549
|
+
}
|
|
550
|
+
/** Save current value to storage */
|
|
551
|
+
save() {
|
|
552
|
+
this._value === void 0 ? this.clear() : this.storage.setItem(this.key, JSON.stringify(this._value)), this.notify(this.value);
|
|
553
|
+
}
|
|
554
|
+
/** Load value from storage */
|
|
555
|
+
load() {
|
|
556
|
+
if (this.storage[this.key] != null) {
|
|
557
|
+
let t = JSON.parse(this.storage.getItem(this.key));
|
|
558
|
+
t != null && typeof t == "object" && this.options.type && (t.__proto__ = this.options.type.prototype), this.value = t;
|
|
559
|
+
} else
|
|
560
|
+
this.value = this.options.default || void 0;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Callback function which is run when there are changes
|
|
564
|
+
*
|
|
565
|
+
* @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
|
|
566
|
+
* @returns {() => void} Function which will unsubscribe the watch/callback when called
|
|
567
|
+
*/
|
|
568
|
+
watch(t) {
|
|
569
|
+
const e = Object.keys(this.watches).length;
|
|
570
|
+
return this.watches[e] = t, () => {
|
|
571
|
+
delete this.watches[e];
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Return value as JSON string
|
|
576
|
+
*
|
|
577
|
+
* @returns {string} Stringified object as JSON
|
|
578
|
+
*/
|
|
579
|
+
toString() {
|
|
580
|
+
return JSON.stringify(this.value);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Return current value
|
|
584
|
+
*
|
|
585
|
+
* @returns {T} Current value
|
|
586
|
+
*/
|
|
587
|
+
valueOf() {
|
|
588
|
+
return this.value;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
S.Persist = st;
|
|
592
|
+
function Bt(r) {
|
|
593
|
+
return (t, e) => {
|
|
594
|
+
const n = (r == null ? void 0 : r.key) || `${t.constructor.name}.${e.toString()}`, s = new st(n, r);
|
|
595
|
+
Object.defineProperty(t, e, {
|
|
596
|
+
get: function() {
|
|
597
|
+
return s.value;
|
|
598
|
+
},
|
|
599
|
+
set: function(o) {
|
|
600
|
+
s.value = o;
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
S.persist = Bt;
|
|
606
|
+
var L = {};
|
|
607
|
+
Object.defineProperty(L, "__esModule", { value: true });
|
|
608
|
+
L.MemoryStorage = void 0;
|
|
609
|
+
class At {
|
|
610
|
+
get length() {
|
|
611
|
+
return Object.keys(this).length;
|
|
612
|
+
}
|
|
613
|
+
clear() {
|
|
614
|
+
Object.keys(this).forEach((t) => this.removeItem(t));
|
|
615
|
+
}
|
|
616
|
+
getItem(t) {
|
|
617
|
+
return this[t];
|
|
618
|
+
}
|
|
619
|
+
key(t) {
|
|
620
|
+
return Object.keys(this)[t];
|
|
621
|
+
}
|
|
622
|
+
removeItem(t) {
|
|
623
|
+
delete this[t];
|
|
624
|
+
}
|
|
625
|
+
setItem(t, e) {
|
|
626
|
+
this[t] = e;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
L.MemoryStorage = At;
|
|
630
|
+
(function(r) {
|
|
631
|
+
var t = $ && $.__createBinding || (Object.create ? function(n, s, o, i) {
|
|
632
|
+
i === void 0 && (i = o);
|
|
633
|
+
var a = Object.getOwnPropertyDescriptor(s, o);
|
|
634
|
+
(!a || ("get" in a ? !s.__esModule : a.writable || a.configurable)) && (a = { enumerable: true, get: function() {
|
|
635
|
+
return s[o];
|
|
636
|
+
} }), Object.defineProperty(n, i, a);
|
|
637
|
+
} : function(n, s, o, i) {
|
|
638
|
+
i === void 0 && (i = o), n[i] = s[o];
|
|
639
|
+
}), e = $ && $.__exportStar || function(n, s) {
|
|
640
|
+
for (var o in n) o !== "default" && !Object.prototype.hasOwnProperty.call(s, o) && t(s, n, o);
|
|
641
|
+
};
|
|
642
|
+
Object.defineProperty(r, "__esModule", { value: true }), e(S, r), e(L, r);
|
|
643
|
+
})(xt);
|
|
644
|
+
class Api extends F {
|
|
409
645
|
constructor(url = location.origin, opts = {}) {
|
|
410
646
|
opts.url = url;
|
|
411
647
|
super(opts);
|
|
412
|
-
__publicField(this, "emitter", new
|
|
648
|
+
__publicField(this, "emitter", new _());
|
|
649
|
+
__publicField(this, "pending", {});
|
|
413
650
|
__publicField(this, "_token", null);
|
|
414
651
|
__publicField(this, "emit", this.emitter.emit.bind(this.emitter));
|
|
415
652
|
__publicField(this, "off", this.emitter.off.bind(this.emitter));
|
|
@@ -434,724 +671,20 @@ class Api extends q {
|
|
|
434
671
|
return children.filter((p2) => !!p2).join("/").replaceAll("//", "/");
|
|
435
672
|
}
|
|
436
673
|
request(options) {
|
|
437
|
-
const
|
|
674
|
+
const key = Lt(options);
|
|
675
|
+
if (this.pending[key] != null) return this.pending[key];
|
|
676
|
+
this.pending[key] = super.request(options).then((resp) => {
|
|
438
677
|
this.emit("response", resp, options);
|
|
439
678
|
return resp.data;
|
|
440
679
|
}).catch((err) => {
|
|
441
680
|
const e = (err == null ? void 0 : err.data) || err;
|
|
442
681
|
this.emit("rejected", e, options);
|
|
443
682
|
throw e;
|
|
444
|
-
});
|
|
445
|
-
this.emit("request",
|
|
446
|
-
return
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
var extendStatics = function(d, b2) {
|
|
450
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
|
|
451
|
-
d2.__proto__ = b3;
|
|
452
|
-
} || function(d2, b3) {
|
|
453
|
-
for (var p2 in b3) if (Object.prototype.hasOwnProperty.call(b3, p2)) d2[p2] = b3[p2];
|
|
454
|
-
};
|
|
455
|
-
return extendStatics(d, b2);
|
|
456
|
-
};
|
|
457
|
-
function __extends(d, b2) {
|
|
458
|
-
if (typeof b2 !== "function" && b2 !== null)
|
|
459
|
-
throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
|
|
460
|
-
extendStatics(d, b2);
|
|
461
|
-
function __() {
|
|
462
|
-
this.constructor = d;
|
|
463
|
-
}
|
|
464
|
-
d.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
|
|
465
|
-
}
|
|
466
|
-
function __values(o) {
|
|
467
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
|
|
468
|
-
if (m2) return m2.call(o);
|
|
469
|
-
if (o && typeof o.length === "number") return {
|
|
470
|
-
next: function() {
|
|
471
|
-
if (o && i2 >= o.length) o = void 0;
|
|
472
|
-
return { value: o && o[i2++], done: !o };
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
476
|
-
}
|
|
477
|
-
function __read(o, n) {
|
|
478
|
-
var m2 = typeof Symbol === "function" && o[Symbol.iterator];
|
|
479
|
-
if (!m2) return o;
|
|
480
|
-
var i2 = m2.call(o), r, ar = [], e;
|
|
481
|
-
try {
|
|
482
|
-
while ((n === void 0 || n-- > 0) && !(r = i2.next()).done) ar.push(r.value);
|
|
483
|
-
} catch (error) {
|
|
484
|
-
e = { error };
|
|
485
|
-
} finally {
|
|
486
|
-
try {
|
|
487
|
-
if (r && !r.done && (m2 = i2["return"])) m2.call(i2);
|
|
488
|
-
} finally {
|
|
489
|
-
if (e) throw e.error;
|
|
490
|
-
}
|
|
683
|
+
}).finally(() => delete this.pending[key]);
|
|
684
|
+
this.emit("request", this.pending[key], options);
|
|
685
|
+
return this.pending[key];
|
|
491
686
|
}
|
|
492
|
-
return ar;
|
|
493
|
-
}
|
|
494
|
-
function __spreadArray(to, from, pack) {
|
|
495
|
-
if (pack || arguments.length === 2) for (var i2 = 0, l = from.length, ar; i2 < l; i2++) {
|
|
496
|
-
if (ar || !(i2 in from)) {
|
|
497
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i2);
|
|
498
|
-
ar[i2] = from[i2];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
502
|
-
}
|
|
503
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
504
|
-
var e = new Error(message);
|
|
505
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
506
|
-
};
|
|
507
|
-
function isFunction(value) {
|
|
508
|
-
return typeof value === "function";
|
|
509
|
-
}
|
|
510
|
-
function createErrorClass(createImpl) {
|
|
511
|
-
var _super = function(instance) {
|
|
512
|
-
Error.call(instance);
|
|
513
|
-
instance.stack = new Error().stack;
|
|
514
|
-
};
|
|
515
|
-
var ctorFunc = createImpl(_super);
|
|
516
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
517
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
518
|
-
return ctorFunc;
|
|
519
|
-
}
|
|
520
|
-
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
521
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
522
|
-
_super(this);
|
|
523
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i2) {
|
|
524
|
-
return i2 + 1 + ") " + err.toString();
|
|
525
|
-
}).join("\n ") : "";
|
|
526
|
-
this.name = "UnsubscriptionError";
|
|
527
|
-
this.errors = errors;
|
|
528
|
-
};
|
|
529
|
-
});
|
|
530
|
-
function arrRemove(arr, item) {
|
|
531
|
-
if (arr) {
|
|
532
|
-
var index = arr.indexOf(item);
|
|
533
|
-
0 <= index && arr.splice(index, 1);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
var Subscription = function() {
|
|
537
|
-
function Subscription2(initialTeardown) {
|
|
538
|
-
this.initialTeardown = initialTeardown;
|
|
539
|
-
this.closed = false;
|
|
540
|
-
this._parentage = null;
|
|
541
|
-
this._finalizers = null;
|
|
542
|
-
}
|
|
543
|
-
Subscription2.prototype.unsubscribe = function() {
|
|
544
|
-
var e_1, _a, e_2, _b;
|
|
545
|
-
var errors;
|
|
546
|
-
if (!this.closed) {
|
|
547
|
-
this.closed = true;
|
|
548
|
-
var _parentage = this._parentage;
|
|
549
|
-
if (_parentage) {
|
|
550
|
-
this._parentage = null;
|
|
551
|
-
if (Array.isArray(_parentage)) {
|
|
552
|
-
try {
|
|
553
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
554
|
-
var parent_1 = _parentage_1_1.value;
|
|
555
|
-
parent_1.remove(this);
|
|
556
|
-
}
|
|
557
|
-
} catch (e_1_1) {
|
|
558
|
-
e_1 = { error: e_1_1 };
|
|
559
|
-
} finally {
|
|
560
|
-
try {
|
|
561
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
562
|
-
} finally {
|
|
563
|
-
if (e_1) throw e_1.error;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
} else {
|
|
567
|
-
_parentage.remove(this);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
var initialFinalizer = this.initialTeardown;
|
|
571
|
-
if (isFunction(initialFinalizer)) {
|
|
572
|
-
try {
|
|
573
|
-
initialFinalizer();
|
|
574
|
-
} catch (e) {
|
|
575
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
var _finalizers = this._finalizers;
|
|
579
|
-
if (_finalizers) {
|
|
580
|
-
this._finalizers = null;
|
|
581
|
-
try {
|
|
582
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
583
|
-
var finalizer = _finalizers_1_1.value;
|
|
584
|
-
try {
|
|
585
|
-
execFinalizer(finalizer);
|
|
586
|
-
} catch (err) {
|
|
587
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
588
|
-
if (err instanceof UnsubscriptionError) {
|
|
589
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
590
|
-
} else {
|
|
591
|
-
errors.push(err);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
} catch (e_2_1) {
|
|
596
|
-
e_2 = { error: e_2_1 };
|
|
597
|
-
} finally {
|
|
598
|
-
try {
|
|
599
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
600
|
-
} finally {
|
|
601
|
-
if (e_2) throw e_2.error;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if (errors) {
|
|
606
|
-
throw new UnsubscriptionError(errors);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
Subscription2.prototype.add = function(teardown) {
|
|
611
|
-
var _a;
|
|
612
|
-
if (teardown && teardown !== this) {
|
|
613
|
-
if (this.closed) {
|
|
614
|
-
execFinalizer(teardown);
|
|
615
|
-
} else {
|
|
616
|
-
if (teardown instanceof Subscription2) {
|
|
617
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
teardown._addParent(this);
|
|
621
|
-
}
|
|
622
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
Subscription2.prototype._hasParent = function(parent) {
|
|
627
|
-
var _parentage = this._parentage;
|
|
628
|
-
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
|
629
|
-
};
|
|
630
|
-
Subscription2.prototype._addParent = function(parent) {
|
|
631
|
-
var _parentage = this._parentage;
|
|
632
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
633
|
-
};
|
|
634
|
-
Subscription2.prototype._removeParent = function(parent) {
|
|
635
|
-
var _parentage = this._parentage;
|
|
636
|
-
if (_parentage === parent) {
|
|
637
|
-
this._parentage = null;
|
|
638
|
-
} else if (Array.isArray(_parentage)) {
|
|
639
|
-
arrRemove(_parentage, parent);
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
Subscription2.prototype.remove = function(teardown) {
|
|
643
|
-
var _finalizers = this._finalizers;
|
|
644
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
645
|
-
if (teardown instanceof Subscription2) {
|
|
646
|
-
teardown._removeParent(this);
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
Subscription2.EMPTY = function() {
|
|
650
|
-
var empty = new Subscription2();
|
|
651
|
-
empty.closed = true;
|
|
652
|
-
return empty;
|
|
653
|
-
}();
|
|
654
|
-
return Subscription2;
|
|
655
|
-
}();
|
|
656
|
-
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
657
|
-
function isSubscription(value) {
|
|
658
|
-
return value instanceof Subscription || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
|
|
659
|
-
}
|
|
660
|
-
function execFinalizer(finalizer) {
|
|
661
|
-
if (isFunction(finalizer)) {
|
|
662
|
-
finalizer();
|
|
663
|
-
} else {
|
|
664
|
-
finalizer.unsubscribe();
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
var config = {
|
|
668
|
-
onUnhandledError: null,
|
|
669
|
-
onStoppedNotification: null,
|
|
670
|
-
Promise: void 0,
|
|
671
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
672
|
-
useDeprecatedNextContext: false
|
|
673
|
-
};
|
|
674
|
-
var timeoutProvider = {
|
|
675
|
-
setTimeout: function(handler, timeout) {
|
|
676
|
-
var args = [];
|
|
677
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
678
|
-
args[_i - 2] = arguments[_i];
|
|
679
|
-
}
|
|
680
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
681
|
-
},
|
|
682
|
-
clearTimeout: function(handle) {
|
|
683
|
-
var delegate = timeoutProvider.delegate;
|
|
684
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
685
|
-
},
|
|
686
|
-
delegate: void 0
|
|
687
|
-
};
|
|
688
|
-
function reportUnhandledError(err) {
|
|
689
|
-
timeoutProvider.setTimeout(function() {
|
|
690
|
-
{
|
|
691
|
-
throw err;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
function noop() {
|
|
696
|
-
}
|
|
697
|
-
function errorContext(cb) {
|
|
698
|
-
{
|
|
699
|
-
cb();
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
var Subscriber = function(_super) {
|
|
703
|
-
__extends(Subscriber2, _super);
|
|
704
|
-
function Subscriber2(destination) {
|
|
705
|
-
var _this = _super.call(this) || this;
|
|
706
|
-
_this.isStopped = false;
|
|
707
|
-
if (destination) {
|
|
708
|
-
_this.destination = destination;
|
|
709
|
-
if (isSubscription(destination)) {
|
|
710
|
-
destination.add(_this);
|
|
711
|
-
}
|
|
712
|
-
} else {
|
|
713
|
-
_this.destination = EMPTY_OBSERVER;
|
|
714
|
-
}
|
|
715
|
-
return _this;
|
|
716
|
-
}
|
|
717
|
-
Subscriber2.create = function(next, error, complete) {
|
|
718
|
-
return new SafeSubscriber(next, error, complete);
|
|
719
|
-
};
|
|
720
|
-
Subscriber2.prototype.next = function(value) {
|
|
721
|
-
if (this.isStopped) ;
|
|
722
|
-
else {
|
|
723
|
-
this._next(value);
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
Subscriber2.prototype.error = function(err) {
|
|
727
|
-
if (this.isStopped) ;
|
|
728
|
-
else {
|
|
729
|
-
this.isStopped = true;
|
|
730
|
-
this._error(err);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
Subscriber2.prototype.complete = function() {
|
|
734
|
-
if (this.isStopped) ;
|
|
735
|
-
else {
|
|
736
|
-
this.isStopped = true;
|
|
737
|
-
this._complete();
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
Subscriber2.prototype.unsubscribe = function() {
|
|
741
|
-
if (!this.closed) {
|
|
742
|
-
this.isStopped = true;
|
|
743
|
-
_super.prototype.unsubscribe.call(this);
|
|
744
|
-
this.destination = null;
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
Subscriber2.prototype._next = function(value) {
|
|
748
|
-
this.destination.next(value);
|
|
749
|
-
};
|
|
750
|
-
Subscriber2.prototype._error = function(err) {
|
|
751
|
-
try {
|
|
752
|
-
this.destination.error(err);
|
|
753
|
-
} finally {
|
|
754
|
-
this.unsubscribe();
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
Subscriber2.prototype._complete = function() {
|
|
758
|
-
try {
|
|
759
|
-
this.destination.complete();
|
|
760
|
-
} finally {
|
|
761
|
-
this.unsubscribe();
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
return Subscriber2;
|
|
765
|
-
}(Subscription);
|
|
766
|
-
var _bind = Function.prototype.bind;
|
|
767
|
-
function bind(fn, thisArg) {
|
|
768
|
-
return _bind.call(fn, thisArg);
|
|
769
|
-
}
|
|
770
|
-
var ConsumerObserver = function() {
|
|
771
|
-
function ConsumerObserver2(partialObserver) {
|
|
772
|
-
this.partialObserver = partialObserver;
|
|
773
|
-
}
|
|
774
|
-
ConsumerObserver2.prototype.next = function(value) {
|
|
775
|
-
var partialObserver = this.partialObserver;
|
|
776
|
-
if (partialObserver.next) {
|
|
777
|
-
try {
|
|
778
|
-
partialObserver.next(value);
|
|
779
|
-
} catch (error) {
|
|
780
|
-
handleUnhandledError(error);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
ConsumerObserver2.prototype.error = function(err) {
|
|
785
|
-
var partialObserver = this.partialObserver;
|
|
786
|
-
if (partialObserver.error) {
|
|
787
|
-
try {
|
|
788
|
-
partialObserver.error(err);
|
|
789
|
-
} catch (error) {
|
|
790
|
-
handleUnhandledError(error);
|
|
791
|
-
}
|
|
792
|
-
} else {
|
|
793
|
-
handleUnhandledError(err);
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
ConsumerObserver2.prototype.complete = function() {
|
|
797
|
-
var partialObserver = this.partialObserver;
|
|
798
|
-
if (partialObserver.complete) {
|
|
799
|
-
try {
|
|
800
|
-
partialObserver.complete();
|
|
801
|
-
} catch (error) {
|
|
802
|
-
handleUnhandledError(error);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
return ConsumerObserver2;
|
|
807
|
-
}();
|
|
808
|
-
var SafeSubscriber = function(_super) {
|
|
809
|
-
__extends(SafeSubscriber2, _super);
|
|
810
|
-
function SafeSubscriber2(observerOrNext, error, complete) {
|
|
811
|
-
var _this = _super.call(this) || this;
|
|
812
|
-
var partialObserver;
|
|
813
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
814
|
-
partialObserver = {
|
|
815
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : void 0,
|
|
816
|
-
error: error !== null && error !== void 0 ? error : void 0,
|
|
817
|
-
complete: complete !== null && complete !== void 0 ? complete : void 0
|
|
818
|
-
};
|
|
819
|
-
} else {
|
|
820
|
-
var context_1;
|
|
821
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
822
|
-
context_1 = Object.create(observerOrNext);
|
|
823
|
-
context_1.unsubscribe = function() {
|
|
824
|
-
return _this.unsubscribe();
|
|
825
|
-
};
|
|
826
|
-
partialObserver = {
|
|
827
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
828
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
829
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1)
|
|
830
|
-
};
|
|
831
|
-
} else {
|
|
832
|
-
partialObserver = observerOrNext;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
836
|
-
return _this;
|
|
837
|
-
}
|
|
838
|
-
return SafeSubscriber2;
|
|
839
|
-
}(Subscriber);
|
|
840
|
-
function handleUnhandledError(error) {
|
|
841
|
-
{
|
|
842
|
-
reportUnhandledError(error);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
function defaultErrorHandler(err) {
|
|
846
|
-
throw err;
|
|
847
|
-
}
|
|
848
|
-
var EMPTY_OBSERVER = {
|
|
849
|
-
closed: true,
|
|
850
|
-
next: noop,
|
|
851
|
-
error: defaultErrorHandler,
|
|
852
|
-
complete: noop
|
|
853
|
-
};
|
|
854
|
-
var observable = function() {
|
|
855
|
-
return typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
856
|
-
}();
|
|
857
|
-
function identity(x) {
|
|
858
|
-
return x;
|
|
859
|
-
}
|
|
860
|
-
function pipeFromArray(fns) {
|
|
861
|
-
if (fns.length === 0) {
|
|
862
|
-
return identity;
|
|
863
|
-
}
|
|
864
|
-
if (fns.length === 1) {
|
|
865
|
-
return fns[0];
|
|
866
|
-
}
|
|
867
|
-
return function piped(input) {
|
|
868
|
-
return fns.reduce(function(prev, fn) {
|
|
869
|
-
return fn(prev);
|
|
870
|
-
}, input);
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
var Observable = function() {
|
|
874
|
-
function Observable2(subscribe) {
|
|
875
|
-
if (subscribe) {
|
|
876
|
-
this._subscribe = subscribe;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
Observable2.prototype.lift = function(operator) {
|
|
880
|
-
var observable2 = new Observable2();
|
|
881
|
-
observable2.source = this;
|
|
882
|
-
observable2.operator = operator;
|
|
883
|
-
return observable2;
|
|
884
|
-
};
|
|
885
|
-
Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
886
|
-
var _this = this;
|
|
887
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
888
|
-
errorContext(function() {
|
|
889
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
890
|
-
subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
|
|
891
|
-
});
|
|
892
|
-
return subscriber;
|
|
893
|
-
};
|
|
894
|
-
Observable2.prototype._trySubscribe = function(sink) {
|
|
895
|
-
try {
|
|
896
|
-
return this._subscribe(sink);
|
|
897
|
-
} catch (err) {
|
|
898
|
-
sink.error(err);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
902
|
-
var _this = this;
|
|
903
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
904
|
-
return new promiseCtor(function(resolve, reject) {
|
|
905
|
-
var subscriber = new SafeSubscriber({
|
|
906
|
-
next: function(value) {
|
|
907
|
-
try {
|
|
908
|
-
next(value);
|
|
909
|
-
} catch (err) {
|
|
910
|
-
reject(err);
|
|
911
|
-
subscriber.unsubscribe();
|
|
912
|
-
}
|
|
913
|
-
},
|
|
914
|
-
error: reject,
|
|
915
|
-
complete: resolve
|
|
916
|
-
});
|
|
917
|
-
_this.subscribe(subscriber);
|
|
918
|
-
});
|
|
919
|
-
};
|
|
920
|
-
Observable2.prototype._subscribe = function(subscriber) {
|
|
921
|
-
var _a;
|
|
922
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
923
|
-
};
|
|
924
|
-
Observable2.prototype[observable] = function() {
|
|
925
|
-
return this;
|
|
926
|
-
};
|
|
927
|
-
Observable2.prototype.pipe = function() {
|
|
928
|
-
var operations = [];
|
|
929
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
930
|
-
operations[_i] = arguments[_i];
|
|
931
|
-
}
|
|
932
|
-
return pipeFromArray(operations)(this);
|
|
933
|
-
};
|
|
934
|
-
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
935
|
-
var _this = this;
|
|
936
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
937
|
-
return new promiseCtor(function(resolve, reject) {
|
|
938
|
-
var value;
|
|
939
|
-
_this.subscribe(function(x) {
|
|
940
|
-
return value = x;
|
|
941
|
-
}, function(err) {
|
|
942
|
-
return reject(err);
|
|
943
|
-
}, function() {
|
|
944
|
-
return resolve(value);
|
|
945
|
-
});
|
|
946
|
-
});
|
|
947
|
-
};
|
|
948
|
-
Observable2.create = function(subscribe) {
|
|
949
|
-
return new Observable2(subscribe);
|
|
950
|
-
};
|
|
951
|
-
return Observable2;
|
|
952
|
-
}();
|
|
953
|
-
function getPromiseCtor(promiseCtor) {
|
|
954
|
-
var _a;
|
|
955
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
956
|
-
}
|
|
957
|
-
function isObserver(value) {
|
|
958
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
959
687
|
}
|
|
960
|
-
function isSubscriber(value) {
|
|
961
|
-
return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
|
|
962
|
-
}
|
|
963
|
-
var ObjectUnsubscribedError = createErrorClass(function(_super) {
|
|
964
|
-
return function ObjectUnsubscribedErrorImpl() {
|
|
965
|
-
_super(this);
|
|
966
|
-
this.name = "ObjectUnsubscribedError";
|
|
967
|
-
this.message = "object unsubscribed";
|
|
968
|
-
};
|
|
969
|
-
});
|
|
970
|
-
var Subject = function(_super) {
|
|
971
|
-
__extends(Subject2, _super);
|
|
972
|
-
function Subject2() {
|
|
973
|
-
var _this = _super.call(this) || this;
|
|
974
|
-
_this.closed = false;
|
|
975
|
-
_this.currentObservers = null;
|
|
976
|
-
_this.observers = [];
|
|
977
|
-
_this.isStopped = false;
|
|
978
|
-
_this.hasError = false;
|
|
979
|
-
_this.thrownError = null;
|
|
980
|
-
return _this;
|
|
981
|
-
}
|
|
982
|
-
Subject2.prototype.lift = function(operator) {
|
|
983
|
-
var subject = new AnonymousSubject(this, this);
|
|
984
|
-
subject.operator = operator;
|
|
985
|
-
return subject;
|
|
986
|
-
};
|
|
987
|
-
Subject2.prototype._throwIfClosed = function() {
|
|
988
|
-
if (this.closed) {
|
|
989
|
-
throw new ObjectUnsubscribedError();
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
Subject2.prototype.next = function(value) {
|
|
993
|
-
var _this = this;
|
|
994
|
-
errorContext(function() {
|
|
995
|
-
var e_1, _a;
|
|
996
|
-
_this._throwIfClosed();
|
|
997
|
-
if (!_this.isStopped) {
|
|
998
|
-
if (!_this.currentObservers) {
|
|
999
|
-
_this.currentObservers = Array.from(_this.observers);
|
|
1000
|
-
}
|
|
1001
|
-
try {
|
|
1002
|
-
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1003
|
-
var observer = _c.value;
|
|
1004
|
-
observer.next(value);
|
|
1005
|
-
}
|
|
1006
|
-
} catch (e_1_1) {
|
|
1007
|
-
e_1 = { error: e_1_1 };
|
|
1008
|
-
} finally {
|
|
1009
|
-
try {
|
|
1010
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1011
|
-
} finally {
|
|
1012
|
-
if (e_1) throw e_1.error;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
};
|
|
1018
|
-
Subject2.prototype.error = function(err) {
|
|
1019
|
-
var _this = this;
|
|
1020
|
-
errorContext(function() {
|
|
1021
|
-
_this._throwIfClosed();
|
|
1022
|
-
if (!_this.isStopped) {
|
|
1023
|
-
_this.hasError = _this.isStopped = true;
|
|
1024
|
-
_this.thrownError = err;
|
|
1025
|
-
var observers = _this.observers;
|
|
1026
|
-
while (observers.length) {
|
|
1027
|
-
observers.shift().error(err);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
};
|
|
1032
|
-
Subject2.prototype.complete = function() {
|
|
1033
|
-
var _this = this;
|
|
1034
|
-
errorContext(function() {
|
|
1035
|
-
_this._throwIfClosed();
|
|
1036
|
-
if (!_this.isStopped) {
|
|
1037
|
-
_this.isStopped = true;
|
|
1038
|
-
var observers = _this.observers;
|
|
1039
|
-
while (observers.length) {
|
|
1040
|
-
observers.shift().complete();
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
};
|
|
1045
|
-
Subject2.prototype.unsubscribe = function() {
|
|
1046
|
-
this.isStopped = this.closed = true;
|
|
1047
|
-
this.observers = this.currentObservers = null;
|
|
1048
|
-
};
|
|
1049
|
-
Object.defineProperty(Subject2.prototype, "observed", {
|
|
1050
|
-
get: function() {
|
|
1051
|
-
var _a;
|
|
1052
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
1053
|
-
},
|
|
1054
|
-
enumerable: false,
|
|
1055
|
-
configurable: true
|
|
1056
|
-
});
|
|
1057
|
-
Subject2.prototype._trySubscribe = function(subscriber) {
|
|
1058
|
-
this._throwIfClosed();
|
|
1059
|
-
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
1060
|
-
};
|
|
1061
|
-
Subject2.prototype._subscribe = function(subscriber) {
|
|
1062
|
-
this._throwIfClosed();
|
|
1063
|
-
this._checkFinalizedStatuses(subscriber);
|
|
1064
|
-
return this._innerSubscribe(subscriber);
|
|
1065
|
-
};
|
|
1066
|
-
Subject2.prototype._innerSubscribe = function(subscriber) {
|
|
1067
|
-
var _this = this;
|
|
1068
|
-
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
1069
|
-
if (hasError || isStopped) {
|
|
1070
|
-
return EMPTY_SUBSCRIPTION;
|
|
1071
|
-
}
|
|
1072
|
-
this.currentObservers = null;
|
|
1073
|
-
observers.push(subscriber);
|
|
1074
|
-
return new Subscription(function() {
|
|
1075
|
-
_this.currentObservers = null;
|
|
1076
|
-
arrRemove(observers, subscriber);
|
|
1077
|
-
});
|
|
1078
|
-
};
|
|
1079
|
-
Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
|
|
1080
|
-
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
1081
|
-
if (hasError) {
|
|
1082
|
-
subscriber.error(thrownError);
|
|
1083
|
-
} else if (isStopped) {
|
|
1084
|
-
subscriber.complete();
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
Subject2.prototype.asObservable = function() {
|
|
1088
|
-
var observable2 = new Observable();
|
|
1089
|
-
observable2.source = this;
|
|
1090
|
-
return observable2;
|
|
1091
|
-
};
|
|
1092
|
-
Subject2.create = function(destination, source) {
|
|
1093
|
-
return new AnonymousSubject(destination, source);
|
|
1094
|
-
};
|
|
1095
|
-
return Subject2;
|
|
1096
|
-
}(Observable);
|
|
1097
|
-
var AnonymousSubject = function(_super) {
|
|
1098
|
-
__extends(AnonymousSubject2, _super);
|
|
1099
|
-
function AnonymousSubject2(destination, source) {
|
|
1100
|
-
var _this = _super.call(this) || this;
|
|
1101
|
-
_this.destination = destination;
|
|
1102
|
-
_this.source = source;
|
|
1103
|
-
return _this;
|
|
1104
|
-
}
|
|
1105
|
-
AnonymousSubject2.prototype.next = function(value) {
|
|
1106
|
-
var _a, _b;
|
|
1107
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
1108
|
-
};
|
|
1109
|
-
AnonymousSubject2.prototype.error = function(err) {
|
|
1110
|
-
var _a, _b;
|
|
1111
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
1112
|
-
};
|
|
1113
|
-
AnonymousSubject2.prototype.complete = function() {
|
|
1114
|
-
var _a, _b;
|
|
1115
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1116
|
-
};
|
|
1117
|
-
AnonymousSubject2.prototype._subscribe = function(subscriber) {
|
|
1118
|
-
var _a, _b;
|
|
1119
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
1120
|
-
};
|
|
1121
|
-
return AnonymousSubject2;
|
|
1122
|
-
}(Subject);
|
|
1123
|
-
var BehaviorSubject = function(_super) {
|
|
1124
|
-
__extends(BehaviorSubject2, _super);
|
|
1125
|
-
function BehaviorSubject2(_value) {
|
|
1126
|
-
var _this = _super.call(this) || this;
|
|
1127
|
-
_this._value = _value;
|
|
1128
|
-
return _this;
|
|
1129
|
-
}
|
|
1130
|
-
Object.defineProperty(BehaviorSubject2.prototype, "value", {
|
|
1131
|
-
get: function() {
|
|
1132
|
-
return this.getValue();
|
|
1133
|
-
},
|
|
1134
|
-
enumerable: false,
|
|
1135
|
-
configurable: true
|
|
1136
|
-
});
|
|
1137
|
-
BehaviorSubject2.prototype._subscribe = function(subscriber) {
|
|
1138
|
-
var subscription = _super.prototype._subscribe.call(this, subscriber);
|
|
1139
|
-
!subscription.closed && subscriber.next(this._value);
|
|
1140
|
-
return subscription;
|
|
1141
|
-
};
|
|
1142
|
-
BehaviorSubject2.prototype.getValue = function() {
|
|
1143
|
-
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value;
|
|
1144
|
-
if (hasError) {
|
|
1145
|
-
throw thrownError;
|
|
1146
|
-
}
|
|
1147
|
-
this._throwIfClosed();
|
|
1148
|
-
return _value;
|
|
1149
|
-
};
|
|
1150
|
-
BehaviorSubject2.prototype.next = function(value) {
|
|
1151
|
-
_super.prototype.next.call(this, this._value = value);
|
|
1152
|
-
};
|
|
1153
|
-
return BehaviorSubject2;
|
|
1154
|
-
}(Subject);
|
|
1155
688
|
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
1156
689
|
ActionType2[ActionType2["CRON"] = 0] = "CRON";
|
|
1157
690
|
ActionType2[ActionType2["EVENT"] = 1] = "EVENT";
|
|
@@ -1162,37 +695,31 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
|
1162
695
|
ActionType2[ActionType2["PUT"] = 6] = "PUT";
|
|
1163
696
|
return ActionType2;
|
|
1164
697
|
})(ActionType || {});
|
|
1165
|
-
class Actions extends
|
|
698
|
+
class Actions extends _ {
|
|
1166
699
|
constructor(api) {
|
|
1167
700
|
super();
|
|
1168
701
|
__publicField(this, "api");
|
|
1169
|
-
__publicField(this, "
|
|
702
|
+
__publicField(this, "cache", new Dt("_id"));
|
|
1170
703
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1171
704
|
}
|
|
1172
|
-
get cache() {
|
|
1173
|
-
return this.$cache.value;
|
|
1174
|
-
}
|
|
1175
|
-
set cache(val) {
|
|
1176
|
-
this.$cache.next(val);
|
|
1177
|
-
}
|
|
1178
705
|
delete(id) {
|
|
1179
706
|
return this.api.request({ url: `/api/actions/${id}`, method: "DELETE" }).then(() => {
|
|
1180
|
-
this.cache
|
|
707
|
+
this.cache.delete(id);
|
|
1181
708
|
this.emit("delete", id);
|
|
1182
709
|
});
|
|
1183
710
|
}
|
|
1184
711
|
all() {
|
|
1185
712
|
return this.api.request({ url: `/api/actions` }).then((resp) => {
|
|
1186
|
-
|
|
713
|
+
this.cache.addAll(resp);
|
|
1187
714
|
this.emit("all", resp || []);
|
|
1188
715
|
return resp;
|
|
1189
716
|
});
|
|
1190
717
|
}
|
|
1191
718
|
read(id, reload = false) {
|
|
1192
|
-
const cached = this.cache.
|
|
719
|
+
const cached = this.cache.get(id);
|
|
1193
720
|
if (!reload && cached) return Promise.resolve(cached);
|
|
1194
721
|
return this.api.request({ url: `/api/actions/${id}` }).then((action) => {
|
|
1195
|
-
if (action) this.cache
|
|
722
|
+
if (action) this.cache.add(action);
|
|
1196
723
|
this.emit("read", action);
|
|
1197
724
|
return action;
|
|
1198
725
|
});
|
|
@@ -1216,13 +743,13 @@ class Actions extends v {
|
|
|
1216
743
|
method: "POST",
|
|
1217
744
|
body: action
|
|
1218
745
|
}).then((action2) => {
|
|
1219
|
-
if (action2) this.cache
|
|
746
|
+
if (action2) this.cache.add(action2);
|
|
1220
747
|
this.emit("update", action2);
|
|
1221
748
|
return action2;
|
|
1222
749
|
});
|
|
1223
750
|
}
|
|
1224
751
|
}
|
|
1225
|
-
class Ai extends
|
|
752
|
+
class Ai extends _ {
|
|
1226
753
|
constructor(api) {
|
|
1227
754
|
super();
|
|
1228
755
|
__publicField(this, "api");
|
|
@@ -1241,7 +768,7 @@ class Ai extends v {
|
|
|
1241
768
|
return this.api.request({ url: "/api/ai", method: "DELETE" });
|
|
1242
769
|
}
|
|
1243
770
|
}
|
|
1244
|
-
class Analytics extends
|
|
771
|
+
class Analytics extends _ {
|
|
1245
772
|
constructor(api) {
|
|
1246
773
|
super();
|
|
1247
774
|
__publicField(this, "api");
|
|
@@ -1266,19 +793,19 @@ class Totp {
|
|
|
1266
793
|
return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
|
|
1267
794
|
}
|
|
1268
795
|
setup(username, method = "app", totp) {
|
|
1269
|
-
return this.api.request({ url: `/api/auth/totp/${username}`, body:
|
|
796
|
+
return this.api.request({ url: `/api/auth/totp/${username}`, body: ut({
|
|
1270
797
|
method,
|
|
1271
798
|
totp
|
|
1272
799
|
}) });
|
|
1273
800
|
}
|
|
1274
801
|
}
|
|
1275
|
-
class Auth extends
|
|
802
|
+
class Auth extends _ {
|
|
1276
803
|
constructor(api, opts = {}) {
|
|
1277
804
|
super();
|
|
1278
805
|
__publicField(this, "api");
|
|
1279
806
|
__publicField(this, "storageKey");
|
|
1280
807
|
__publicField(this, "totp");
|
|
1281
|
-
__publicField(this, "
|
|
808
|
+
__publicField(this, "_user");
|
|
1282
809
|
this.opts = opts;
|
|
1283
810
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1284
811
|
this.totp = new Totp(this.api);
|
|
@@ -1317,13 +844,12 @@ class Auth extends v {
|
|
|
1317
844
|
}
|
|
1318
845
|
}
|
|
1319
846
|
get user() {
|
|
1320
|
-
return this
|
|
847
|
+
return this._user;
|
|
1321
848
|
}
|
|
1322
849
|
set user(user) {
|
|
1323
|
-
if (!
|
|
1324
|
-
|
|
1325
|
-
this
|
|
1326
|
-
this.emit("user", u);
|
|
850
|
+
if (!A(this.user, user)) {
|
|
851
|
+
this._user = user ? user : null;
|
|
852
|
+
this.emit("user", this._user);
|
|
1327
853
|
}
|
|
1328
854
|
}
|
|
1329
855
|
knownHost(host = location.origin) {
|
|
@@ -1412,7 +938,227 @@ class Auth extends v {
|
|
|
1412
938
|
});
|
|
1413
939
|
}
|
|
1414
940
|
}
|
|
1415
|
-
class
|
|
941
|
+
class Client {
|
|
942
|
+
constructor(settings) {
|
|
943
|
+
__publicField(this, "_platform");
|
|
944
|
+
__publicField(this, "_pwa");
|
|
945
|
+
this.settings = settings;
|
|
946
|
+
}
|
|
947
|
+
get platform() {
|
|
948
|
+
if (!this._platform) {
|
|
949
|
+
const userAgent = navigator.userAgent || navigator.vendor;
|
|
950
|
+
if (/windows/i.test(userAgent)) this._platform = "windows";
|
|
951
|
+
else if (/android/i.test(userAgent)) this._platform = "android";
|
|
952
|
+
else if (/iPad|iPhone|iPod/.test(userAgent)) this._platform = "ios";
|
|
953
|
+
else if (/macintosh|mac os x/i.test(userAgent)) this._platform = "mac";
|
|
954
|
+
else if (/linux/i.test(userAgent)) this._platform = "linux";
|
|
955
|
+
else this._platform = "unknown";
|
|
956
|
+
}
|
|
957
|
+
return this._platform;
|
|
958
|
+
}
|
|
959
|
+
get pwa() {
|
|
960
|
+
if (this._pwa == null)
|
|
961
|
+
this._pwa = window.matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
|
|
962
|
+
return this._pwa;
|
|
963
|
+
}
|
|
964
|
+
async inject(reload = false) {
|
|
965
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
966
|
+
const settings = await this.settings.all();
|
|
967
|
+
if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
|
|
968
|
+
const meta = document.createElement("meta");
|
|
969
|
+
meta.name = "mobile-web-app-capable";
|
|
970
|
+
meta.content = "yes";
|
|
971
|
+
document.head.append(meta);
|
|
972
|
+
}
|
|
973
|
+
if (!document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]')) {
|
|
974
|
+
const meta = document.createElement("meta");
|
|
975
|
+
meta.name = "apple-mobile-web-app-status-bar-style";
|
|
976
|
+
meta.content = "default";
|
|
977
|
+
document.head.append(meta);
|
|
978
|
+
}
|
|
979
|
+
if (!document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
|
|
980
|
+
const meta = document.createElement("meta");
|
|
981
|
+
meta.name = "apple-mobile-web-app-title";
|
|
982
|
+
meta.content = settings["title"];
|
|
983
|
+
document.head.append(meta);
|
|
984
|
+
}
|
|
985
|
+
if (!document.querySelector('link[rel="apple-touch-icon"]')) {
|
|
986
|
+
const meta = document.createElement("link");
|
|
987
|
+
meta.rel = "apple-touch-icon";
|
|
988
|
+
meta.href = settings["logo"];
|
|
989
|
+
document.head.append(meta);
|
|
990
|
+
}
|
|
991
|
+
if (!document.querySelector('link[rel="apple-touch-startup-image"]')) {
|
|
992
|
+
const meta = document.createElement("link");
|
|
993
|
+
meta.rel = "apple-touch-startup-image";
|
|
994
|
+
meta.href = settings["logo"];
|
|
995
|
+
document.head.append(meta);
|
|
996
|
+
}
|
|
997
|
+
window.document.body.classList.add(((_a = settings["theme"]) == null ? void 0 : _a.darkMode) ? "theme-dark" : "theme-light");
|
|
998
|
+
window.document.body.classList.remove(((_b = settings["theme"]) == null ? void 0 : _b.darkMode) ? "theme-light" : "theme-dark");
|
|
999
|
+
if (settings["title"])
|
|
1000
|
+
window.document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
|
|
1001
|
+
if (settings["description"])
|
|
1002
|
+
window.document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
|
|
1003
|
+
if (settings.version)
|
|
1004
|
+
window.document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
|
|
1005
|
+
if (settings["logo"]) {
|
|
1006
|
+
window.document.querySelectorAll(".momentum-logo").forEach((el) => {
|
|
1007
|
+
el.src = settings["logo"];
|
|
1008
|
+
el.href = settings["logo"];
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
if (settings["theme"]) {
|
|
1012
|
+
let style = window.document.querySelector("#momentum-theme");
|
|
1013
|
+
if (!style) {
|
|
1014
|
+
style = window.document.createElement("style");
|
|
1015
|
+
style.id = "momentum-theme";
|
|
1016
|
+
window.document.head.append(style);
|
|
1017
|
+
}
|
|
1018
|
+
style.innerHTML = `
|
|
1019
|
+
:root {
|
|
1020
|
+
--theme-bg-primary: ${(_c = settings["theme"]) == null ? void 0 : _c.background};
|
|
1021
|
+
--theme-bg-secondary: ${((_d = settings["theme"]) == null ? void 0 : _d.darkMode) ? "#2e2e2e" : "#ffffff"};
|
|
1022
|
+
--theme-primary: ${(_e = settings["theme"]) == null ? void 0 : _e.primary};
|
|
1023
|
+
--theme-secondary: ${(_f = settings["theme"]) == null ? void 0 : _f.secondary};
|
|
1024
|
+
--theme-text: ${((_g = settings["theme"]) == null ? void 0 : _g.darkMode) ? "#ffffff" : "#000000"};
|
|
1025
|
+
--theme-muted: ${((_h = settings["theme"]) == null ? void 0 : _h.darkMode) ? "#cccccc" : "#6c757d"};
|
|
1026
|
+
}`;
|
|
1027
|
+
}
|
|
1028
|
+
if (settings["pwa"]) {
|
|
1029
|
+
const link = window.document.createElement("link");
|
|
1030
|
+
link.setAttribute("rel", "manifest");
|
|
1031
|
+
link.setAttribute("href", this.settings.api.url + "/manifest.json");
|
|
1032
|
+
window.document.head.append(link);
|
|
1033
|
+
setTimeout(() => {
|
|
1034
|
+
const dismissed = !!localStorage.getItem("momentum:install-prompt");
|
|
1035
|
+
if (!dismissed && !this.pwa && this.platform == "ios") this.pwaPrompt();
|
|
1036
|
+
}, 500);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
pwaPrompt(platform) {
|
|
1040
|
+
const url = this.settings.api.url;
|
|
1041
|
+
const settings = this.settings.cache;
|
|
1042
|
+
const android = (platform || this.platform) == "android";
|
|
1043
|
+
let style = document.querySelector("style.momentum-pwa");
|
|
1044
|
+
if (!style) {
|
|
1045
|
+
style = document.createElement("style");
|
|
1046
|
+
style.innerHTML = `
|
|
1047
|
+
.momentum-pwa-prompt-backdrop {
|
|
1048
|
+
position: fixed;
|
|
1049
|
+
display: relative;
|
|
1050
|
+
left: 0;
|
|
1051
|
+
top: 0;
|
|
1052
|
+
right: 0;
|
|
1053
|
+
bottom: 0;
|
|
1054
|
+
background: rgba(0,0,0,.5);
|
|
1055
|
+
z-index: 9999;
|
|
1056
|
+
animation: fadeIn 0.5s ease-in-out forwards;
|
|
1057
|
+
opacity: 0;
|
|
1058
|
+
}
|
|
1059
|
+
.momentum-pwa-prompt-backdrop.exit {
|
|
1060
|
+
animation: fadeOut 0.5s ease-in-out forwards !important;
|
|
1061
|
+
}
|
|
1062
|
+
.momentum-pwa-prompt {
|
|
1063
|
+
position: fixed;
|
|
1064
|
+
background: #fff;
|
|
1065
|
+
color: black;
|
|
1066
|
+
bottom: 0;
|
|
1067
|
+
left: 50%;
|
|
1068
|
+
width: min(100vw, 450px);
|
|
1069
|
+
transform: translate(-50%, 0);
|
|
1070
|
+
animation: slideUp 0.5s ease-in-out forwards;
|
|
1071
|
+
}
|
|
1072
|
+
.momentum-pwa-prompt.exit {
|
|
1073
|
+
animation: slideDown 0.5s ease-in-out forwards !important;
|
|
1074
|
+
}
|
|
1075
|
+
.momentum-pwa-prompt img {
|
|
1076
|
+
width: 18px;
|
|
1077
|
+
height: 18px;
|
|
1078
|
+
}
|
|
1079
|
+
.momentum-pwa-prompt h1 {
|
|
1080
|
+
font-size: 1.25rem;
|
|
1081
|
+
font-weight: bold;
|
|
1082
|
+
}
|
|
1083
|
+
.momentum-pwa-prompt-close {
|
|
1084
|
+
position: absolute;
|
|
1085
|
+
right: 5px;
|
|
1086
|
+
top: 10px;
|
|
1087
|
+
background: transparent;
|
|
1088
|
+
border: none;
|
|
1089
|
+
cursor: pointer;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
@keyframes fadeIn {
|
|
1093
|
+
from { opacity: 0; }
|
|
1094
|
+
to { opacity: 1; }
|
|
1095
|
+
}
|
|
1096
|
+
@keyframes fadeOut {
|
|
1097
|
+
from { opacity: 1; }
|
|
1098
|
+
to { opacity: 0; }
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
@keyframes slideUp {
|
|
1102
|
+
from { transform: translate(-50%, 100%); }
|
|
1103
|
+
to { transform: translate(-50%, 0); }
|
|
1104
|
+
}
|
|
1105
|
+
@keyframes slideDown {
|
|
1106
|
+
from { transform: translate(-50%, 0); }
|
|
1107
|
+
to { transform: translate(-50%, 100%); }
|
|
1108
|
+
}
|
|
1109
|
+
`;
|
|
1110
|
+
document.head.append(style);
|
|
1111
|
+
}
|
|
1112
|
+
const backdrop = document.createElement("div");
|
|
1113
|
+
backdrop.classList.add("momentum-pwa-prompt-backdrop");
|
|
1114
|
+
const prompt = document.createElement("div");
|
|
1115
|
+
prompt.classList.add("momentum-pwa-prompt");
|
|
1116
|
+
prompt.innerHTML = `
|
|
1117
|
+
<div style="display: flex; padding: 1rem; align-items: center">
|
|
1118
|
+
<img src="${url}${settings.logo}" alt="Logo" style="height: 30px; width: auto; margin-right: .5rem;" />
|
|
1119
|
+
<h1 style="margin: 0">Install ${settings.title}</h1>
|
|
1120
|
+
</div>
|
|
1121
|
+
<div style="display: flex; flex-direction: column; align-items: center">
|
|
1122
|
+
<div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
|
|
1123
|
+
<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>
|
|
1124
|
+
</div>
|
|
1125
|
+
<table style="margin: 1.5rem 0">
|
|
1126
|
+
<tr>
|
|
1127
|
+
<td style="width: 50px; text-align: center">
|
|
1128
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>' : '<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>'}
|
|
1129
|
+
</td>
|
|
1130
|
+
<td>
|
|
1131
|
+
<p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p>
|
|
1132
|
+
</td>
|
|
1133
|
+
</tr>
|
|
1134
|
+
<tr>
|
|
1135
|
+
<td style="width: 50px; text-align: center">
|
|
1136
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(-1.5, 1.5)"><path d="M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h280v80H280v40h280v80H280v480h400v-80h80v200q0 33-23.5 56.5T680-40H280Zm0-120v40h400v-40H280Zm440-240L520-600l56-56 104 104v-288h80v288l104-104 56 56-200 200ZM280-800v-40 40Zm0 640v40-40Z"/></svg>' : '<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>'}
|
|
1137
|
+
</td>
|
|
1138
|
+
<td>
|
|
1139
|
+
<p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
|
|
1140
|
+
</td>
|
|
1141
|
+
</tr>
|
|
1142
|
+
</table>
|
|
1143
|
+
</div>`;
|
|
1144
|
+
const close = document.createElement("button");
|
|
1145
|
+
close.classList.add("momentum-pwa-prompt-close");
|
|
1146
|
+
close.innerText = "X";
|
|
1147
|
+
close.onclick = () => {
|
|
1148
|
+
prompt.classList.add("exit");
|
|
1149
|
+
backdrop.classList.add("exit");
|
|
1150
|
+
localStorage.setItem("momentum:install-prompt", "dismissed");
|
|
1151
|
+
setTimeout(() => {
|
|
1152
|
+
prompt.remove();
|
|
1153
|
+
backdrop.remove();
|
|
1154
|
+
}, 500);
|
|
1155
|
+
};
|
|
1156
|
+
prompt.append(close);
|
|
1157
|
+
backdrop.append(prompt);
|
|
1158
|
+
document.body.append(backdrop);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
class Data extends _ {
|
|
1416
1162
|
constructor(api) {
|
|
1417
1163
|
super();
|
|
1418
1164
|
__publicField(this, "api");
|
|
@@ -1458,7 +1204,7 @@ class Data extends v {
|
|
|
1458
1204
|
});
|
|
1459
1205
|
}
|
|
1460
1206
|
}
|
|
1461
|
-
class Email extends
|
|
1207
|
+
class Email extends _ {
|
|
1462
1208
|
constructor(api) {
|
|
1463
1209
|
super();
|
|
1464
1210
|
__publicField(this, "api");
|
|
@@ -1473,7 +1219,7 @@ class Email extends v {
|
|
|
1473
1219
|
});
|
|
1474
1220
|
}
|
|
1475
1221
|
}
|
|
1476
|
-
class Groups extends
|
|
1222
|
+
class Groups extends _ {
|
|
1477
1223
|
constructor(api) {
|
|
1478
1224
|
super();
|
|
1479
1225
|
__publicField(this, "api");
|
|
@@ -1558,40 +1304,40 @@ ${log}`;
|
|
|
1558
1304
|
return this.api.request({ url: `/api/logs/server`, method: "DELETE" });
|
|
1559
1305
|
}
|
|
1560
1306
|
clientLogs(length, page) {
|
|
1561
|
-
const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((
|
|
1307
|
+
const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((v) => !!v).join("&");
|
|
1562
1308
|
return this.api.request({ url: `/api/logs/client${query ? `?${query}` : ""}` }).then((resp) => resp);
|
|
1563
1309
|
}
|
|
1564
1310
|
serverLogs(length, page) {
|
|
1565
|
-
const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((
|
|
1311
|
+
const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((v) => !!v).join("&");
|
|
1566
1312
|
return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
|
|
1567
1313
|
}
|
|
1568
1314
|
debug(...logs) {
|
|
1569
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1315
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(yt.DEBUG, logs) }).then(() => {
|
|
1570
1316
|
}).catch(() => {
|
|
1571
1317
|
});
|
|
1572
1318
|
}
|
|
1573
1319
|
log(...logs) {
|
|
1574
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1320
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(yt.LOG, logs) }).then(() => {
|
|
1575
1321
|
}).catch(() => {
|
|
1576
1322
|
});
|
|
1577
1323
|
}
|
|
1578
1324
|
info(...logs) {
|
|
1579
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1325
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(yt.INFO, logs) }).then(() => {
|
|
1580
1326
|
}).catch(() => {
|
|
1581
1327
|
});
|
|
1582
1328
|
}
|
|
1583
1329
|
warn(...logs) {
|
|
1584
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1330
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(yt.WARN, logs) }).then(() => {
|
|
1585
1331
|
}).catch(() => {
|
|
1586
1332
|
});
|
|
1587
1333
|
}
|
|
1588
1334
|
error(...logs) {
|
|
1589
|
-
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(
|
|
1335
|
+
return this.api.request({ url: `/api/logs/client`, body: this.buildLog(yt.ERROR, logs) }).then(() => {
|
|
1590
1336
|
}).catch(() => {
|
|
1591
1337
|
});
|
|
1592
1338
|
}
|
|
1593
1339
|
}
|
|
1594
|
-
class Payments extends
|
|
1340
|
+
class Payments extends _ {
|
|
1595
1341
|
constructor(api, secret) {
|
|
1596
1342
|
super();
|
|
1597
1343
|
__publicField(this, "api");
|
|
@@ -1632,7 +1378,7 @@ class Payments extends v {
|
|
|
1632
1378
|
return history;
|
|
1633
1379
|
}
|
|
1634
1380
|
}
|
|
1635
|
-
class Pdf extends
|
|
1381
|
+
class Pdf extends _ {
|
|
1636
1382
|
constructor(api) {
|
|
1637
1383
|
super();
|
|
1638
1384
|
__publicField(this, "api");
|
|
@@ -1642,7 +1388,7 @@ class Pdf extends v {
|
|
|
1642
1388
|
const blob = await resp.blob();
|
|
1643
1389
|
if (fileName) {
|
|
1644
1390
|
const url = URL.createObjectURL(blob);
|
|
1645
|
-
|
|
1391
|
+
dt(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
|
|
1646
1392
|
URL.revokeObjectURL(url);
|
|
1647
1393
|
}
|
|
1648
1394
|
this.emit("create", blob);
|
|
@@ -1705,7 +1451,7 @@ const _Socket = class _Socket {
|
|
|
1705
1451
|
};
|
|
1706
1452
|
__publicField(_Socket, "timeout", 1e4);
|
|
1707
1453
|
let Socket = _Socket;
|
|
1708
|
-
class Storage extends
|
|
1454
|
+
class Storage extends _ {
|
|
1709
1455
|
constructor(api) {
|
|
1710
1456
|
super();
|
|
1711
1457
|
__publicField(this, "api");
|
|
@@ -1730,7 +1476,7 @@ class Storage extends v {
|
|
|
1730
1476
|
const blob = await response.blob();
|
|
1731
1477
|
const name = opts.downloadAs || path.split("/").pop();
|
|
1732
1478
|
this.emit("download", path, blob);
|
|
1733
|
-
|
|
1479
|
+
Gt(blob, name);
|
|
1734
1480
|
return response;
|
|
1735
1481
|
});
|
|
1736
1482
|
}
|
|
@@ -1764,13 +1510,13 @@ class Storage extends v {
|
|
|
1764
1510
|
});
|
|
1765
1511
|
}
|
|
1766
1512
|
upload(files, opts = "") {
|
|
1767
|
-
return new
|
|
1768
|
-
if (!files) files = await
|
|
1513
|
+
return new E(async (res, rej, prog) => {
|
|
1514
|
+
if (!files) files = await Ut(typeof opts == "object" ? opts : void 0);
|
|
1769
1515
|
if (!files || Array.isArray(files) && !files.length) return [];
|
|
1770
1516
|
const path = this.api.path("/api/storage/", typeof opts == "string" ? opts : opts.path || "");
|
|
1771
|
-
return
|
|
1517
|
+
return Ft({
|
|
1772
1518
|
url: `${this.api.url}${path}`,
|
|
1773
|
-
files:
|
|
1519
|
+
files: ft(files),
|
|
1774
1520
|
headers: this.api.headers
|
|
1775
1521
|
}).onProgress((p2) => {
|
|
1776
1522
|
prog(p2);
|
|
@@ -1781,255 +1527,42 @@ class Storage extends v {
|
|
|
1781
1527
|
});
|
|
1782
1528
|
}
|
|
1783
1529
|
}
|
|
1784
|
-
class
|
|
1785
|
-
constructor(settings) {
|
|
1786
|
-
this.settings = settings;
|
|
1787
|
-
}
|
|
1788
|
-
async inject(reload = false) {
|
|
1789
|
-
if (!Object.keys(this.settings.cache).length || reload) await this.settings.all();
|
|
1790
|
-
if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
|
|
1791
|
-
const meta = document.createElement("meta");
|
|
1792
|
-
meta.name = "mobile-web-app-capable";
|
|
1793
|
-
meta.content = "yes";
|
|
1794
|
-
document.head.append(meta);
|
|
1795
|
-
}
|
|
1796
|
-
if (!document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]')) {
|
|
1797
|
-
const meta = document.createElement("meta");
|
|
1798
|
-
meta.name = "apple-mobile-web-app-status-bar-style";
|
|
1799
|
-
meta.content = "default";
|
|
1800
|
-
document.head.append(meta);
|
|
1801
|
-
}
|
|
1802
|
-
if (!document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
|
|
1803
|
-
const meta = document.createElement("meta");
|
|
1804
|
-
meta.name = "apple-mobile-web-app-title";
|
|
1805
|
-
meta.content = this.settings.cache.title;
|
|
1806
|
-
document.head.append(meta);
|
|
1807
|
-
}
|
|
1808
|
-
if (!document.querySelector('link[rel="apple-touch-icon"]')) {
|
|
1809
|
-
const meta = document.createElement("link");
|
|
1810
|
-
meta.rel = "apple-touch-icon";
|
|
1811
|
-
meta.href = this.settings.cache.logo;
|
|
1812
|
-
document.head.append(meta);
|
|
1813
|
-
}
|
|
1814
|
-
if (!document.querySelector('link[rel="apple-touch-startup-image"]')) {
|
|
1815
|
-
const meta = document.createElement("link");
|
|
1816
|
-
meta.rel = "apple-touch-startup-image";
|
|
1817
|
-
meta.href = this.settings.cache.logo;
|
|
1818
|
-
document.head.append(meta);
|
|
1819
|
-
}
|
|
1820
|
-
window.document.body.classList.add(this.settings.cache.theme.darkMode ? "theme-dark" : "theme-light");
|
|
1821
|
-
window.document.body.classList.remove(this.settings.cache.theme.darkMode ? "theme-light" : "theme-dark");
|
|
1822
|
-
if (this.settings.cache.title)
|
|
1823
|
-
window.document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = this.settings.cache.title);
|
|
1824
|
-
if (this.settings.cache.description)
|
|
1825
|
-
window.document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = this.settings.cache.description);
|
|
1826
|
-
if (this.settings.cache.version)
|
|
1827
|
-
window.document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = this.settings.cache.version);
|
|
1828
|
-
if (this.settings.cache.logo) {
|
|
1829
|
-
window.document.querySelectorAll(".momentum-logo").forEach((el) => {
|
|
1830
|
-
el.src = this.settings.cache.logo;
|
|
1831
|
-
el.href = this.settings.cache.logo;
|
|
1832
|
-
});
|
|
1833
|
-
}
|
|
1834
|
-
if (this.settings.cache.theme) {
|
|
1835
|
-
let style = window.document.querySelector("#momentum-theme");
|
|
1836
|
-
if (!style) {
|
|
1837
|
-
style = window.document.createElement("style");
|
|
1838
|
-
style.id = "momentum-theme";
|
|
1839
|
-
window.document.head.append(style);
|
|
1840
|
-
}
|
|
1841
|
-
style.innerHTML = `
|
|
1842
|
-
:root {
|
|
1843
|
-
--theme-bg-primary: ${this.settings.cache.theme.background};
|
|
1844
|
-
--theme-bg-secondary: ${this.settings.cache.theme.darkMode ? "#2e2e2e" : "#ffffff"};
|
|
1845
|
-
--theme-primary: ${this.settings.cache.theme.primary};
|
|
1846
|
-
--theme-secondary: ${this.settings.cache.theme.secondary};
|
|
1847
|
-
--theme-text: ${this.settings.cache.theme.darkMode ? "#ffffff" : "#000000"};
|
|
1848
|
-
--theme-muted: ${this.settings.cache.theme.darkMode ? "#cccccc" : "#6c757d"};
|
|
1849
|
-
}`;
|
|
1850
|
-
}
|
|
1851
|
-
if (this.settings.cache.pwa) {
|
|
1852
|
-
const link = window.document.createElement("link");
|
|
1853
|
-
link.setAttribute("rel", "manifest");
|
|
1854
|
-
link.setAttribute("href", this.settings.api.url + "/manifest.json");
|
|
1855
|
-
window.document.head.append(link);
|
|
1856
|
-
this.iosPrompt();
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
iosPrompt() {
|
|
1860
|
-
const url = this.settings.api.url;
|
|
1861
|
-
const settings = this.settings.cache;
|
|
1862
|
-
let dismissed = !!localStorage.getItem("ios-prompt");
|
|
1863
|
-
const ios = /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
1864
|
-
const pwa = window.matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
|
|
1865
|
-
function open() {
|
|
1866
|
-
let style = document.querySelector("style.ios-prompt");
|
|
1867
|
-
if (!style) {
|
|
1868
|
-
style = document.createElement("style");
|
|
1869
|
-
style.innerHTML = `
|
|
1870
|
-
.ios-prompt-backdrop {
|
|
1871
|
-
position: fixed;
|
|
1872
|
-
display: relative;
|
|
1873
|
-
left: 0;
|
|
1874
|
-
top: 0;
|
|
1875
|
-
right: 0;
|
|
1876
|
-
bottom: 0;
|
|
1877
|
-
background: rgba(0,0,0,.5);
|
|
1878
|
-
z-index: 9999;
|
|
1879
|
-
animation: fadeIn 0.5s ease-in-out forwards;
|
|
1880
|
-
opacity: 0;
|
|
1881
|
-
}
|
|
1882
|
-
.ios-prompt-backdrop.exit {
|
|
1883
|
-
animation: fadeOut 0.5s ease-in-out forwards !important;
|
|
1884
|
-
}
|
|
1885
|
-
.ios-prompt {
|
|
1886
|
-
position: fixed;
|
|
1887
|
-
background: #fff;
|
|
1888
|
-
color: black;
|
|
1889
|
-
bottom: 0;
|
|
1890
|
-
left: 50%;
|
|
1891
|
-
width: min(100vw, 450px);
|
|
1892
|
-
transform: translate(-50%, 0);
|
|
1893
|
-
animation: slideUp 0.5s ease-in-out forwards;
|
|
1894
|
-
}
|
|
1895
|
-
.ios-prompt.exit {
|
|
1896
|
-
animation: slideDown 0.5s ease-in-out forwards !important;
|
|
1897
|
-
}
|
|
1898
|
-
.ios-prompt img {
|
|
1899
|
-
width: 18px;
|
|
1900
|
-
height: 18px;
|
|
1901
|
-
}
|
|
1902
|
-
.ios-prompt h1 {
|
|
1903
|
-
font-size: 1.25rem;
|
|
1904
|
-
font-weight: bold;
|
|
1905
|
-
}
|
|
1906
|
-
.ios-prompt-close {
|
|
1907
|
-
position: absolute;
|
|
1908
|
-
right: 5px;
|
|
1909
|
-
top: 10px;
|
|
1910
|
-
background: transparent;
|
|
1911
|
-
border: none;
|
|
1912
|
-
cursor: pointer;
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
@keyframes fadeIn {
|
|
1916
|
-
from { opacity: 0; }
|
|
1917
|
-
to { opacity: 1; }
|
|
1918
|
-
}
|
|
1919
|
-
@keyframes fadeOut {
|
|
1920
|
-
from { opacity: 1; }
|
|
1921
|
-
to { opacity: 0; }
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
@keyframes slideUp {
|
|
1925
|
-
from { transform: translate(-50%, 100%); }
|
|
1926
|
-
to { transform: translate(-50%, 0); }
|
|
1927
|
-
}
|
|
1928
|
-
@keyframes slideDown {
|
|
1929
|
-
from { transform: translate(-50%, 0); }
|
|
1930
|
-
to { transform: translate(-50%, 100%); }
|
|
1931
|
-
}
|
|
1932
|
-
`;
|
|
1933
|
-
document.head.append(style);
|
|
1934
|
-
}
|
|
1935
|
-
const backdrop = document.createElement("div");
|
|
1936
|
-
backdrop.classList.add("ios-prompt-backdrop");
|
|
1937
|
-
const prompt = document.createElement("div");
|
|
1938
|
-
prompt.classList.add("ios-prompt");
|
|
1939
|
-
prompt.innerHTML = `
|
|
1940
|
-
<div style="display: flex; padding: 1rem; align-items: center">
|
|
1941
|
-
<img src="${url}${settings.logo}" alt="Logo" style="height: 30px; width: auto; margin-right: .5rem;" />
|
|
1942
|
-
<h1 style="margin: 0">Install ${settings.title}</h1>
|
|
1943
|
-
</div>
|
|
1944
|
-
<div style="display: flex; flex-direction: column; align-items: center">
|
|
1945
|
-
<div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
|
|
1946
|
-
<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>
|
|
1947
|
-
</div>
|
|
1948
|
-
<table style="margin: 1.5rem 0">
|
|
1949
|
-
<tr>
|
|
1950
|
-
<td style="width: 50px">
|
|
1951
|
-
<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>
|
|
1952
|
-
</td>
|
|
1953
|
-
<td>
|
|
1954
|
-
<p style="margin: 1rem 0">1) Press the "Share" button</p>
|
|
1955
|
-
</td>
|
|
1956
|
-
</tr>
|
|
1957
|
-
<tr>
|
|
1958
|
-
<td>
|
|
1959
|
-
<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>
|
|
1960
|
-
</td>
|
|
1961
|
-
<td>
|
|
1962
|
-
<p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
|
|
1963
|
-
</td>
|
|
1964
|
-
</tr>
|
|
1965
|
-
</table>
|
|
1966
|
-
</div>`;
|
|
1967
|
-
const close = document.createElement("button");
|
|
1968
|
-
close.classList.add("ios-prompt-close");
|
|
1969
|
-
close.innerText = "X";
|
|
1970
|
-
close.onclick = () => {
|
|
1971
|
-
prompt.classList.add("exit");
|
|
1972
|
-
backdrop.classList.add("exit");
|
|
1973
|
-
localStorage.setItem("ios-prompt", "dismissed");
|
|
1974
|
-
setTimeout(() => {
|
|
1975
|
-
prompt.remove();
|
|
1976
|
-
backdrop.remove();
|
|
1977
|
-
}, 500);
|
|
1978
|
-
};
|
|
1979
|
-
prompt.append(close);
|
|
1980
|
-
backdrop.append(prompt);
|
|
1981
|
-
document.body.append(backdrop);
|
|
1982
|
-
}
|
|
1983
|
-
setTimeout(() => {
|
|
1984
|
-
if (ios && !dismissed && !pwa) open();
|
|
1985
|
-
}, 1e3);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
class Users extends v {
|
|
1530
|
+
class Users extends _ {
|
|
1989
1531
|
constructor(api) {
|
|
1990
1532
|
super();
|
|
1991
1533
|
__publicField(this, "api");
|
|
1992
1534
|
__publicField(this, "listed", false);
|
|
1993
|
-
__publicField(this, "
|
|
1535
|
+
__publicField(this, "cache", new Dt("username"));
|
|
1994
1536
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1995
1537
|
}
|
|
1996
|
-
get cache() {
|
|
1997
|
-
return this.$cache.value;
|
|
1998
|
-
}
|
|
1999
|
-
set cache(val) {
|
|
2000
|
-
this.$cache.next(val);
|
|
2001
|
-
}
|
|
2002
1538
|
delete(username) {
|
|
2003
1539
|
return this.api.request({
|
|
2004
1540
|
url: `/api/users/${username}`,
|
|
2005
1541
|
method: "DELETE"
|
|
2006
1542
|
}).then(() => {
|
|
2007
|
-
this.cache
|
|
1543
|
+
this.cache.delete(username);
|
|
2008
1544
|
this.emit("delete", username);
|
|
2009
1545
|
});
|
|
2010
1546
|
}
|
|
2011
|
-
all(reload = false) {
|
|
2012
|
-
if (!reload && this.
|
|
1547
|
+
async all(reload = false) {
|
|
1548
|
+
if (!reload && this.cache.complete) return this.cache.all();
|
|
2013
1549
|
return this.api.request({ url: `/api/users` }).then((resp) => {
|
|
2014
|
-
resp == null ? void 0 : resp.
|
|
1550
|
+
resp == null ? void 0 : resp.forEach((r) => {
|
|
2015
1551
|
r.image = this.api.url + r.image + `?token=${this.api.token}`;
|
|
2016
1552
|
return r;
|
|
2017
1553
|
});
|
|
2018
|
-
this.cache
|
|
1554
|
+
this.cache.addAll(resp);
|
|
2019
1555
|
this.listed = true;
|
|
2020
1556
|
this.emit("all", resp || []);
|
|
2021
1557
|
return resp;
|
|
2022
1558
|
});
|
|
2023
1559
|
}
|
|
2024
|
-
read(username, reload = false) {
|
|
2025
|
-
if (!reload)
|
|
2026
|
-
const cached = this.cache.find((u) => u.username == username);
|
|
2027
|
-
if (cached) return Promise.resolve(cached);
|
|
2028
|
-
}
|
|
1560
|
+
async read(username, reload = false) {
|
|
1561
|
+
if (!reload && this.cache.get(username)) return this.cache.get(username);
|
|
2029
1562
|
return this.api.request({ url: `/api/users/${username}` }).then((resp) => {
|
|
2030
1563
|
if (resp) {
|
|
2031
1564
|
resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
|
|
2032
|
-
this.cache
|
|
1565
|
+
this.cache.add(resp);
|
|
2033
1566
|
}
|
|
2034
1567
|
this.emit("read", resp);
|
|
2035
1568
|
return resp;
|
|
@@ -2043,14 +1576,14 @@ class Users extends v {
|
|
|
2043
1576
|
}).then((resp) => {
|
|
2044
1577
|
if (resp) {
|
|
2045
1578
|
resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
|
|
2046
|
-
this.cache
|
|
1579
|
+
this.cache.add(resp);
|
|
2047
1580
|
}
|
|
2048
1581
|
this.emit(resp._id ? "update" : "create", resp);
|
|
2049
1582
|
return resp;
|
|
2050
1583
|
});
|
|
2051
1584
|
}
|
|
2052
1585
|
uploadImage(username, file) {
|
|
2053
|
-
return
|
|
1586
|
+
return Ft({
|
|
2054
1587
|
url: this.api.url + `/api/users/${username}/image`,
|
|
2055
1588
|
files: [file],
|
|
2056
1589
|
headers: this.api.headers
|
|
@@ -2060,49 +1593,45 @@ class Users extends v {
|
|
|
2060
1593
|
});
|
|
2061
1594
|
}
|
|
2062
1595
|
}
|
|
2063
|
-
class Settings extends
|
|
1596
|
+
class Settings extends _ {
|
|
2064
1597
|
constructor(api) {
|
|
2065
1598
|
super();
|
|
2066
1599
|
__publicField(this, "api");
|
|
2067
|
-
__publicField(this, "
|
|
1600
|
+
__publicField(this, "cache", new Dt());
|
|
2068
1601
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
2069
1602
|
}
|
|
2070
|
-
|
|
2071
|
-
return this
|
|
2072
|
-
}
|
|
2073
|
-
set cache(val) {
|
|
2074
|
-
this.$cache.next(val);
|
|
2075
|
-
}
|
|
2076
|
-
all(detailed = false) {
|
|
1603
|
+
async all(detailed = false, reload) {
|
|
1604
|
+
if (!detailed && this.cache.complete && !reload) return this.cache;
|
|
2077
1605
|
return this.api.request({ url: `/api/settings` + (detailed ? "?detailed" : "") }).then((resp) => {
|
|
2078
|
-
|
|
2079
|
-
this.
|
|
1606
|
+
Object.entries(resp).forEach(([key, value]) => this.cache.set(key, detailed ? value.value : value));
|
|
1607
|
+
this.cache.complete = true;
|
|
1608
|
+
this.emit("all", resp || []);
|
|
2080
1609
|
return resp;
|
|
2081
1610
|
});
|
|
2082
1611
|
}
|
|
2083
1612
|
delete(key) {
|
|
2084
1613
|
return this.api.request({ url: `/api/settings/${key}`, method: "DELETE" }).then(() => {
|
|
2085
|
-
this.cache
|
|
1614
|
+
this.cache.delete(key);
|
|
2086
1615
|
this.emit("delete", key);
|
|
2087
1616
|
});
|
|
2088
1617
|
}
|
|
2089
1618
|
read(key, reload = false) {
|
|
2090
|
-
if (!reload && this.cache
|
|
1619
|
+
if (!reload && this.cache.get(key)) return this.cache.get(key);
|
|
2091
1620
|
return this.api.request({ url: `/api/settings/${key}` }).then((variable) => {
|
|
2092
|
-
if (variable) this.cache
|
|
1621
|
+
if (variable) this.cache.set(variable.key, variable.value);
|
|
2093
1622
|
this.emit("read", variable);
|
|
2094
1623
|
return variable;
|
|
2095
1624
|
});
|
|
2096
1625
|
}
|
|
2097
1626
|
update(variable) {
|
|
2098
1627
|
return this.api.request({ url: `/api/settings/${variable.key}`, body: variable }).then((variable2) => {
|
|
2099
|
-
if (variable2) this.cache
|
|
1628
|
+
if (variable2) this.cache.set(variable2.key, variable2.value);
|
|
2100
1629
|
this.emit("update", variable2);
|
|
2101
1630
|
return variable2;
|
|
2102
1631
|
});
|
|
2103
1632
|
}
|
|
2104
1633
|
}
|
|
2105
|
-
class Static extends
|
|
1634
|
+
class Static extends _ {
|
|
2106
1635
|
constructor(api) {
|
|
2107
1636
|
super();
|
|
2108
1637
|
__publicField(this, "api");
|
|
@@ -2114,10 +1643,10 @@ class Static extends v {
|
|
|
2114
1643
|
});
|
|
2115
1644
|
}
|
|
2116
1645
|
upload(files, path = "/") {
|
|
2117
|
-
return new
|
|
2118
|
-
return
|
|
1646
|
+
return new E(async (res, rej, prog) => {
|
|
1647
|
+
return Ft({
|
|
2119
1648
|
url: this.api.url + ("/api/static/" + path).replaceAll("//", "/"),
|
|
2120
|
-
files:
|
|
1649
|
+
files: ft(files),
|
|
2121
1650
|
headers: this.api.headers
|
|
2122
1651
|
}).onProgress((p2) => {
|
|
2123
1652
|
prog(p2);
|
|
@@ -2128,7 +1657,7 @@ class Static extends v {
|
|
|
2128
1657
|
});
|
|
2129
1658
|
}
|
|
2130
1659
|
}
|
|
2131
|
-
class Momentum extends
|
|
1660
|
+
class Momentum extends _ {
|
|
2132
1661
|
constructor(url, opts) {
|
|
2133
1662
|
super();
|
|
2134
1663
|
__publicField(this, "api");
|
|
@@ -2136,6 +1665,7 @@ class Momentum extends v {
|
|
|
2136
1665
|
__publicField(this, "ai");
|
|
2137
1666
|
__publicField(this, "analytics");
|
|
2138
1667
|
__publicField(this, "auth");
|
|
1668
|
+
__publicField(this, "client");
|
|
2139
1669
|
__publicField(this, "data");
|
|
2140
1670
|
__publicField(this, "email");
|
|
2141
1671
|
__publicField(this, "groups");
|
|
@@ -2146,7 +1676,6 @@ class Momentum extends v {
|
|
|
2146
1676
|
__publicField(this, "socket");
|
|
2147
1677
|
__publicField(this, "static");
|
|
2148
1678
|
__publicField(this, "storage");
|
|
2149
|
-
__publicField(this, "ui");
|
|
2150
1679
|
__publicField(this, "users");
|
|
2151
1680
|
this.api = new Api(url, opts == null ? void 0 : opts.api);
|
|
2152
1681
|
this.actions = new Actions(this.api);
|
|
@@ -2166,7 +1695,7 @@ class Momentum extends v {
|
|
|
2166
1695
|
if (opts == null ? void 0 : opts.socket) this.socket = new Socket(this.api);
|
|
2167
1696
|
this.static = new Static(this.api);
|
|
2168
1697
|
this.storage = new Storage(this.api);
|
|
2169
|
-
this.
|
|
1698
|
+
this.client = new Client(this.settings);
|
|
2170
1699
|
this.users = new Users(this.api);
|
|
2171
1700
|
this.api.on("*", (event, ...args) => this.emit(`Api:${event}`, ...args));
|
|
2172
1701
|
this.actions.on("*", (event, ...args) => this.emit(`Actions:${event}`, ...args));
|
|
@@ -2181,7 +1710,7 @@ class Momentum extends v {
|
|
|
2181
1710
|
this.storage.on("*", (event, ...args) => this.emit(`Storage:${event}`, ...args));
|
|
2182
1711
|
this.users.on("*", (event, ...args) => this.emit(`Users:${event}`, ...args));
|
|
2183
1712
|
this.users.on("*", (event, ...args) => {
|
|
2184
|
-
const u =
|
|
1713
|
+
const u = ft(args[0]).find((u2) => {
|
|
2185
1714
|
var _a;
|
|
2186
1715
|
return (u2 == null ? void 0 : u2._id) == ((_a = this.auth.user) == null ? void 0 : _a._id);
|
|
2187
1716
|
});
|
|
@@ -2196,6 +1725,7 @@ export {
|
|
|
2196
1725
|
Analytics,
|
|
2197
1726
|
Api,
|
|
2198
1727
|
Auth,
|
|
1728
|
+
Client,
|
|
2199
1729
|
Data,
|
|
2200
1730
|
Email,
|
|
2201
1731
|
Groups,
|
|
@@ -2208,6 +1738,5 @@ export {
|
|
|
2208
1738
|
Static,
|
|
2209
1739
|
Storage,
|
|
2210
1740
|
Totp,
|
|
2211
|
-
UI,
|
|
2212
1741
|
Users
|
|
2213
1742
|
};
|