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