buzzcasting-storage 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/dist/buzzcasting-storage.cjs +7 -0
- package/dist/buzzcasting-storage.d.ts +54 -0
- package/dist/buzzcasting-storage.iife.js +7 -0
- package/dist/buzzcasting-storage.js +3274 -0
- package/dist/buzzcasting-storage.umd.cjs +7 -0
- package/package.json +54 -0
|
@@ -0,0 +1,3274 @@
|
|
|
1
|
+
var lr = Object.defineProperty;
|
|
2
|
+
var ur = (t, e, n) => e in t ? lr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var k = (t, e, n) => (ur(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
class hr {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
k(this, "options");
|
|
7
|
+
k(this, "url");
|
|
8
|
+
k(this, "csrf", () => {
|
|
9
|
+
var e, n;
|
|
10
|
+
if ((e = this.options) != null && e.csrf)
|
|
11
|
+
return {
|
|
12
|
+
headers: new Headers({
|
|
13
|
+
"X-Csrf-Token": (n = this.options) == null ? void 0 : n.csrf
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
this.options = e, this.url = `https://${e.app}.buzzcasting.net`;
|
|
18
|
+
}
|
|
19
|
+
auth() {
|
|
20
|
+
var n;
|
|
21
|
+
if (!((n = this.options) != null && n.token))
|
|
22
|
+
return;
|
|
23
|
+
let e = "";
|
|
24
|
+
switch (this.options.token) {
|
|
25
|
+
case "meta":
|
|
26
|
+
e = "Bearer " + this.options.bearer;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
headers: new Headers({
|
|
31
|
+
Authorization: e
|
|
32
|
+
//'X-Session-Key': localStorage.getItem('guid') || 'invalid',
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async get(e) {
|
|
37
|
+
let n;
|
|
38
|
+
const r = this.auth(), s = this.csrf();
|
|
39
|
+
n = { ...r, ...s };
|
|
40
|
+
let i = Object.assign({}, e);
|
|
41
|
+
delete i.type;
|
|
42
|
+
const o = Object.keys(i).length > 0 ? "?" + new URLSearchParams(i).toString() : "";
|
|
43
|
+
return await fetch(
|
|
44
|
+
[this.url, "api", this.options.version, e.type].join("/") + o,
|
|
45
|
+
{ ...n, method: "get" }
|
|
46
|
+
).then((a) => {
|
|
47
|
+
if (!a.ok)
|
|
48
|
+
throw Error(a.statusText);
|
|
49
|
+
return a;
|
|
50
|
+
}).then((a) => a.json()).then((a) => (a.query = e, a)).catch((a) => ({ succes: !1, message: a, data: [] }));
|
|
51
|
+
}
|
|
52
|
+
async hideMessage(e) {
|
|
53
|
+
const { app: n, version: r } = this.options, s = this.auth(), i = "?action=visible";
|
|
54
|
+
return console.log(
|
|
55
|
+
[n, "api", r, e.type, e.id].join("/") + i,
|
|
56
|
+
{ ...s, method: "put" }
|
|
57
|
+
), await fetch(
|
|
58
|
+
[n, "api", r, e.type, e.id].join("/") + i,
|
|
59
|
+
{ ...s, method: "put" }
|
|
60
|
+
).then((o) => {
|
|
61
|
+
if (!o.ok)
|
|
62
|
+
throw Error(o.statusText);
|
|
63
|
+
return o;
|
|
64
|
+
}).then((o) => o.json()).catch((o) => ({ succes: !1, message: o, data: [] }));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const Oe = "messages", Kn = "cloud", Dt = "series", dr = "topics", fr = "keyval", pr = "local", mr = "session", yr = "dexie", gr = "window", D = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, R = Object.keys, L = Array.isArray;
|
|
68
|
+
function z(t, e) {
|
|
69
|
+
return typeof e != "object" || R(e).forEach(function(n) {
|
|
70
|
+
t[n] = e[n];
|
|
71
|
+
}), t;
|
|
72
|
+
}
|
|
73
|
+
typeof Promise > "u" || D.Promise || (D.Promise = Promise);
|
|
74
|
+
const $e = Object.getPrototypeOf, br = {}.hasOwnProperty;
|
|
75
|
+
function H(t, e) {
|
|
76
|
+
return br.call(t, e);
|
|
77
|
+
}
|
|
78
|
+
function Ce(t, e) {
|
|
79
|
+
typeof e == "function" && (e = e($e(t))), (typeof Reflect > "u" ? R : Reflect.ownKeys)(e).forEach((n) => {
|
|
80
|
+
te(t, n, e[n]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const An = Object.defineProperty;
|
|
84
|
+
function te(t, e, n, r) {
|
|
85
|
+
An(t, e, z(n && H(n, "get") && typeof n.get == "function" ? { get: n.get, set: n.set, configurable: !0 } : { value: n, configurable: !0, writable: !0 }, r));
|
|
86
|
+
}
|
|
87
|
+
function Se(t) {
|
|
88
|
+
return { from: function(e) {
|
|
89
|
+
return t.prototype = Object.create(e.prototype), te(t.prototype, "constructor", t), { extend: Ce.bind(null, t.prototype) };
|
|
90
|
+
} };
|
|
91
|
+
}
|
|
92
|
+
const vr = Object.getOwnPropertyDescriptor;
|
|
93
|
+
function sn(t, e) {
|
|
94
|
+
let n;
|
|
95
|
+
return vr(t, e) || (n = $e(t)) && sn(n, e);
|
|
96
|
+
}
|
|
97
|
+
const wr = [].slice;
|
|
98
|
+
function ht(t, e, n) {
|
|
99
|
+
return wr.call(t, e, n);
|
|
100
|
+
}
|
|
101
|
+
function Dn(t, e) {
|
|
102
|
+
return e(t);
|
|
103
|
+
}
|
|
104
|
+
function Ie(t) {
|
|
105
|
+
if (!t)
|
|
106
|
+
throw new Error("Assertion Failed");
|
|
107
|
+
}
|
|
108
|
+
function In(t) {
|
|
109
|
+
D.setImmediate ? setImmediate(t) : setTimeout(t, 0);
|
|
110
|
+
}
|
|
111
|
+
function Bn(t, e) {
|
|
112
|
+
return t.reduce((n, r, s) => {
|
|
113
|
+
var i = e(r, s);
|
|
114
|
+
return i && (n[i[0]] = i[1]), n;
|
|
115
|
+
}, {});
|
|
116
|
+
}
|
|
117
|
+
function ne(t, e) {
|
|
118
|
+
if (typeof e == "string" && H(t, e))
|
|
119
|
+
return t[e];
|
|
120
|
+
if (!e)
|
|
121
|
+
return t;
|
|
122
|
+
if (typeof e != "string") {
|
|
123
|
+
for (var n = [], r = 0, s = e.length; r < s; ++r) {
|
|
124
|
+
var i = ne(t, e[r]);
|
|
125
|
+
n.push(i);
|
|
126
|
+
}
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
var o = e.indexOf(".");
|
|
130
|
+
if (o !== -1) {
|
|
131
|
+
var a = t[e.substr(0, o)];
|
|
132
|
+
return a === void 0 ? void 0 : ne(a, e.substr(o + 1));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function Y(t, e, n) {
|
|
136
|
+
if (t && e !== void 0 && (!("isFrozen" in Object) || !Object.isFrozen(t)))
|
|
137
|
+
if (typeof e != "string" && "length" in e) {
|
|
138
|
+
Ie(typeof n != "string" && "length" in n);
|
|
139
|
+
for (var r = 0, s = e.length; r < s; ++r)
|
|
140
|
+
Y(t, e[r], n[r]);
|
|
141
|
+
} else {
|
|
142
|
+
var i = e.indexOf(".");
|
|
143
|
+
if (i !== -1) {
|
|
144
|
+
var o = e.substr(0, i), a = e.substr(i + 1);
|
|
145
|
+
if (a === "")
|
|
146
|
+
n === void 0 ? L(t) && !isNaN(parseInt(o)) ? t.splice(o, 1) : delete t[o] : t[o] = n;
|
|
147
|
+
else {
|
|
148
|
+
var c = t[o];
|
|
149
|
+
c && H(t, o) || (c = t[o] = {}), Y(c, a, n);
|
|
150
|
+
}
|
|
151
|
+
} else
|
|
152
|
+
n === void 0 ? L(t) && !isNaN(parseInt(e)) ? t.splice(e, 1) : delete t[e] : t[e] = n;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function Tn(t) {
|
|
156
|
+
var e = {};
|
|
157
|
+
for (var n in t)
|
|
158
|
+
H(t, n) && (e[n] = t[n]);
|
|
159
|
+
return e;
|
|
160
|
+
}
|
|
161
|
+
const _r = [].concat;
|
|
162
|
+
function Mn(t) {
|
|
163
|
+
return _r.apply([], t);
|
|
164
|
+
}
|
|
165
|
+
const Rn = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Mn([8, 16, 32, 64].map((t) => ["Int", "Uint", "Float"].map((e) => e + t + "Array")))).filter((t) => D[t]), kr = Rn.map((t) => D[t]);
|
|
166
|
+
Bn(Rn, (t) => [t, !0]);
|
|
167
|
+
let ie = null;
|
|
168
|
+
function He(t) {
|
|
169
|
+
ie = typeof WeakMap < "u" && /* @__PURE__ */ new WeakMap();
|
|
170
|
+
const e = It(t);
|
|
171
|
+
return ie = null, e;
|
|
172
|
+
}
|
|
173
|
+
function It(t) {
|
|
174
|
+
if (!t || typeof t != "object")
|
|
175
|
+
return t;
|
|
176
|
+
let e = ie && ie.get(t);
|
|
177
|
+
if (e)
|
|
178
|
+
return e;
|
|
179
|
+
if (L(t)) {
|
|
180
|
+
e = [], ie && ie.set(t, e);
|
|
181
|
+
for (var n = 0, r = t.length; n < r; ++n)
|
|
182
|
+
e.push(It(t[n]));
|
|
183
|
+
} else if (kr.indexOf(t.constructor) >= 0)
|
|
184
|
+
e = t;
|
|
185
|
+
else {
|
|
186
|
+
const i = $e(t);
|
|
187
|
+
for (var s in e = i === Object.prototype ? {} : Object.create(i), ie && ie.set(t, e), t)
|
|
188
|
+
H(t, s) && (e[s] = It(t[s]));
|
|
189
|
+
}
|
|
190
|
+
return e;
|
|
191
|
+
}
|
|
192
|
+
const { toString: xr } = {};
|
|
193
|
+
function Bt(t) {
|
|
194
|
+
return xr.call(t).slice(8, -1);
|
|
195
|
+
}
|
|
196
|
+
const Tt = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", Sr = typeof Tt == "symbol" ? function(t) {
|
|
197
|
+
var e;
|
|
198
|
+
return t != null && (e = t[Tt]) && e.apply(t);
|
|
199
|
+
} : function() {
|
|
200
|
+
return null;
|
|
201
|
+
}, xe = {};
|
|
202
|
+
function q(t) {
|
|
203
|
+
var e, n, r, s;
|
|
204
|
+
if (arguments.length === 1) {
|
|
205
|
+
if (L(t))
|
|
206
|
+
return t.slice();
|
|
207
|
+
if (this === xe && typeof t == "string")
|
|
208
|
+
return [t];
|
|
209
|
+
if (s = Sr(t)) {
|
|
210
|
+
for (n = []; !(r = s.next()).done; )
|
|
211
|
+
n.push(r.value);
|
|
212
|
+
return n;
|
|
213
|
+
}
|
|
214
|
+
if (t == null)
|
|
215
|
+
return [t];
|
|
216
|
+
if (typeof (e = t.length) == "number") {
|
|
217
|
+
for (n = new Array(e); e--; )
|
|
218
|
+
n[e] = t[e];
|
|
219
|
+
return n;
|
|
220
|
+
}
|
|
221
|
+
return [t];
|
|
222
|
+
}
|
|
223
|
+
for (e = arguments.length, n = new Array(e); e--; )
|
|
224
|
+
n[e] = arguments[e];
|
|
225
|
+
return n;
|
|
226
|
+
}
|
|
227
|
+
const on = typeof Symbol < "u" ? (t) => t[Symbol.toStringTag] === "AsyncFunction" : () => !1;
|
|
228
|
+
var J = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
|
|
229
|
+
function Fn(t, e) {
|
|
230
|
+
J = t, Nn = e;
|
|
231
|
+
}
|
|
232
|
+
var Nn = () => !0;
|
|
233
|
+
const Er = !new Error("").stack;
|
|
234
|
+
function be() {
|
|
235
|
+
if (Er)
|
|
236
|
+
try {
|
|
237
|
+
throw be.arguments, new Error();
|
|
238
|
+
} catch (t) {
|
|
239
|
+
return t;
|
|
240
|
+
}
|
|
241
|
+
return new Error();
|
|
242
|
+
}
|
|
243
|
+
function Mt(t, e) {
|
|
244
|
+
var n = t.stack;
|
|
245
|
+
return n ? (e = e || 0, n.indexOf(t.name) === 0 && (e += (t.name + t.message).split(`
|
|
246
|
+
`).length), n.split(`
|
|
247
|
+
`).slice(e).filter(Nn).map((r) => `
|
|
248
|
+
` + r).join("")) : "";
|
|
249
|
+
}
|
|
250
|
+
var $n = ["Unknown", "Constraint", "Data", "TransactionInactive", "ReadOnly", "Version", "NotFound", "InvalidState", "InvalidAccess", "Abort", "Timeout", "QuotaExceeded", "Syntax", "DataClone"], an = ["Modify", "Bulk", "OpenFailed", "VersionChange", "Schema", "Upgrade", "InvalidTable", "MissingAPI", "NoSuchDatabase", "InvalidArgument", "SubTransaction", "Unsupported", "Internal", "DatabaseClosed", "PrematureCommit", "ForeignAwait"].concat($n), Pr = { VersionChanged: "Database version changed by other database connection", DatabaseClosed: "Database has been closed", Abort: "Transaction aborted", TransactionInactive: "Transaction has already completed or failed", MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb" };
|
|
251
|
+
function Ee(t, e) {
|
|
252
|
+
this._e = be(), this.name = t, this.message = e;
|
|
253
|
+
}
|
|
254
|
+
function Ln(t, e) {
|
|
255
|
+
return t + ". Errors: " + Object.keys(e).map((n) => e[n].toString()).filter((n, r, s) => s.indexOf(n) === r).join(`
|
|
256
|
+
`);
|
|
257
|
+
}
|
|
258
|
+
function dt(t, e, n, r) {
|
|
259
|
+
this._e = be(), this.failures = e, this.failedKeys = r, this.successCount = n, this.message = Ln(t, e);
|
|
260
|
+
}
|
|
261
|
+
function Te(t, e) {
|
|
262
|
+
this._e = be(), this.name = "BulkError", this.failures = Object.keys(e).map((n) => e[n]), this.failuresByPos = e, this.message = Ln(t, e);
|
|
263
|
+
}
|
|
264
|
+
Se(Ee).from(Error).extend({ stack: { get: function() {
|
|
265
|
+
return this._stack || (this._stack = this.name + ": " + this.message + Mt(this._e, 2));
|
|
266
|
+
} }, toString: function() {
|
|
267
|
+
return this.name + ": " + this.message;
|
|
268
|
+
} }), Se(dt).from(Ee), Se(Te).from(Ee);
|
|
269
|
+
var cn = an.reduce((t, e) => (t[e] = e + "Error", t), {});
|
|
270
|
+
const Or = Ee;
|
|
271
|
+
var C = an.reduce((t, e) => {
|
|
272
|
+
var n = e + "Error";
|
|
273
|
+
function r(s, i) {
|
|
274
|
+
this._e = be(), this.name = n, s ? typeof s == "string" ? (this.message = `${s}${i ? `
|
|
275
|
+
` + i : ""}`, this.inner = i || null) : typeof s == "object" && (this.message = `${s.name} ${s.message}`, this.inner = s) : (this.message = Pr[e] || n, this.inner = null);
|
|
276
|
+
}
|
|
277
|
+
return Se(r).from(Or), t[e] = r, t;
|
|
278
|
+
}, {});
|
|
279
|
+
C.Syntax = SyntaxError, C.Type = TypeError, C.Range = RangeError;
|
|
280
|
+
var bn = $n.reduce((t, e) => (t[e + "Error"] = C[e], t), {}), st = an.reduce((t, e) => (["Syntax", "Type", "Range"].indexOf(e) === -1 && (t[e + "Error"] = C[e]), t), {});
|
|
281
|
+
function A() {
|
|
282
|
+
}
|
|
283
|
+
function Le(t) {
|
|
284
|
+
return t;
|
|
285
|
+
}
|
|
286
|
+
function Cr(t, e) {
|
|
287
|
+
return t == null || t === Le ? e : function(n) {
|
|
288
|
+
return e(t(n));
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function ye(t, e) {
|
|
292
|
+
return function() {
|
|
293
|
+
t.apply(this, arguments), e.apply(this, arguments);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function jr(t, e) {
|
|
297
|
+
return t === A ? e : function() {
|
|
298
|
+
var n = t.apply(this, arguments);
|
|
299
|
+
n !== void 0 && (arguments[0] = n);
|
|
300
|
+
var r = this.onsuccess, s = this.onerror;
|
|
301
|
+
this.onsuccess = null, this.onerror = null;
|
|
302
|
+
var i = e.apply(this, arguments);
|
|
303
|
+
return r && (this.onsuccess = this.onsuccess ? ye(r, this.onsuccess) : r), s && (this.onerror = this.onerror ? ye(s, this.onerror) : s), i !== void 0 ? i : n;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function Kr(t, e) {
|
|
307
|
+
return t === A ? e : function() {
|
|
308
|
+
t.apply(this, arguments);
|
|
309
|
+
var n = this.onsuccess, r = this.onerror;
|
|
310
|
+
this.onsuccess = this.onerror = null, e.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? ye(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? ye(r, this.onerror) : r);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function Ar(t, e) {
|
|
314
|
+
return t === A ? e : function(n) {
|
|
315
|
+
var r = t.apply(this, arguments);
|
|
316
|
+
z(n, r);
|
|
317
|
+
var s = this.onsuccess, i = this.onerror;
|
|
318
|
+
this.onsuccess = null, this.onerror = null;
|
|
319
|
+
var o = e.apply(this, arguments);
|
|
320
|
+
return s && (this.onsuccess = this.onsuccess ? ye(s, this.onsuccess) : s), i && (this.onerror = this.onerror ? ye(i, this.onerror) : i), r === void 0 ? o === void 0 ? void 0 : o : z(r, o);
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function Dr(t, e) {
|
|
324
|
+
return t === A ? e : function() {
|
|
325
|
+
return e.apply(this, arguments) !== !1 && t.apply(this, arguments);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function ln(t, e) {
|
|
329
|
+
return t === A ? e : function() {
|
|
330
|
+
var n = t.apply(this, arguments);
|
|
331
|
+
if (n && typeof n.then == "function") {
|
|
332
|
+
for (var r = this, s = arguments.length, i = new Array(s); s--; )
|
|
333
|
+
i[s] = arguments[s];
|
|
334
|
+
return n.then(function() {
|
|
335
|
+
return e.apply(r, i);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return e.apply(this, arguments);
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
st.ModifyError = dt, st.DexieError = Ee, st.BulkError = Te;
|
|
342
|
+
var Ue = {};
|
|
343
|
+
const Un = 100, [Rt, ft, Ft] = typeof Promise > "u" ? [] : (() => {
|
|
344
|
+
let t = Promise.resolve();
|
|
345
|
+
if (typeof crypto > "u" || !crypto.subtle)
|
|
346
|
+
return [t, $e(t), t];
|
|
347
|
+
const e = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
|
|
348
|
+
return [e, $e(e), t];
|
|
349
|
+
})(), Wn = ft && ft.then, it = Rt && Rt.constructor, un = !!Ft;
|
|
350
|
+
var Nt = !1, Ir = Ft ? () => {
|
|
351
|
+
Ft.then(Xe);
|
|
352
|
+
} : D.setImmediate ? setImmediate.bind(null, Xe) : D.MutationObserver ? () => {
|
|
353
|
+
var t = document.createElement("div");
|
|
354
|
+
new MutationObserver(() => {
|
|
355
|
+
Xe(), t = null;
|
|
356
|
+
}).observe(t, { attributes: !0 }), t.setAttribute("i", "1");
|
|
357
|
+
} : () => {
|
|
358
|
+
setTimeout(Xe, 0);
|
|
359
|
+
}, Me = function(t, e) {
|
|
360
|
+
Be.push([t, e]), pt && (Ir(), pt = !1);
|
|
361
|
+
}, $t = !0, pt = !0, fe = [], ot = [], Lt = null, Ut = Le, Pe = { id: "global", global: !0, ref: 0, unhandleds: [], onunhandled: _n, pgp: !1, env: {}, finalize: function() {
|
|
362
|
+
this.unhandleds.forEach((t) => {
|
|
363
|
+
try {
|
|
364
|
+
_n(t[0], t[1]);
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
} }, O = Pe, Be = [], pe = 0, at = [];
|
|
369
|
+
function E(t) {
|
|
370
|
+
if (typeof this != "object")
|
|
371
|
+
throw new TypeError("Promises must be constructed via new");
|
|
372
|
+
this._listeners = [], this.onuncatched = A, this._lib = !1;
|
|
373
|
+
var e = this._PSD = O;
|
|
374
|
+
if (J && (this._stackHolder = be(), this._prev = null, this._numPrev = 0), typeof t != "function") {
|
|
375
|
+
if (t !== Ue)
|
|
376
|
+
throw new TypeError("Not a function");
|
|
377
|
+
return this._state = arguments[1], this._value = arguments[2], void (this._state === !1 && zt(this, this._value));
|
|
378
|
+
}
|
|
379
|
+
this._state = null, this._value = null, ++e.ref, Vn(this, t);
|
|
380
|
+
}
|
|
381
|
+
const Wt = { get: function() {
|
|
382
|
+
var t = O, e = mt;
|
|
383
|
+
function n(r, s) {
|
|
384
|
+
var i = !t.global && (t !== O || e !== mt);
|
|
385
|
+
const o = i && !re();
|
|
386
|
+
var a = new E((c, l) => {
|
|
387
|
+
hn(this, new zn(yt(r, t, i, o), yt(s, t, i, o), c, l, t));
|
|
388
|
+
});
|
|
389
|
+
return J && Yn(a, this), a;
|
|
390
|
+
}
|
|
391
|
+
return n.prototype = Ue, n;
|
|
392
|
+
}, set: function(t) {
|
|
393
|
+
te(this, "then", t && t.prototype === Ue ? Wt : { get: function() {
|
|
394
|
+
return t;
|
|
395
|
+
}, set: Wt.set });
|
|
396
|
+
} };
|
|
397
|
+
function zn(t, e, n, r, s) {
|
|
398
|
+
this.onFulfilled = typeof t == "function" ? t : null, this.onRejected = typeof e == "function" ? e : null, this.resolve = n, this.reject = r, this.psd = s;
|
|
399
|
+
}
|
|
400
|
+
function Vn(t, e) {
|
|
401
|
+
try {
|
|
402
|
+
e((n) => {
|
|
403
|
+
if (t._state === null) {
|
|
404
|
+
if (n === t)
|
|
405
|
+
throw new TypeError("A promise cannot be resolved with itself.");
|
|
406
|
+
var r = t._lib && Ye();
|
|
407
|
+
n && typeof n.then == "function" ? Vn(t, (s, i) => {
|
|
408
|
+
n instanceof E ? n._then(s, i) : n.then(s, i);
|
|
409
|
+
}) : (t._state = !0, t._value = n, Gn(t)), r && Qe();
|
|
410
|
+
}
|
|
411
|
+
}, zt.bind(null, t));
|
|
412
|
+
} catch (n) {
|
|
413
|
+
zt(t, n);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function zt(t, e) {
|
|
417
|
+
if (ot.push(e), t._state === null) {
|
|
418
|
+
var n = t._lib && Ye();
|
|
419
|
+
e = Ut(e), t._state = !1, t._value = e, J && e !== null && typeof e == "object" && !e._promise && function(r, s, i) {
|
|
420
|
+
try {
|
|
421
|
+
r.apply(null, i);
|
|
422
|
+
} catch (o) {
|
|
423
|
+
s && s(o);
|
|
424
|
+
}
|
|
425
|
+
}(() => {
|
|
426
|
+
var r = sn(e, "stack");
|
|
427
|
+
e._promise = t, te(e, "stack", { get: () => Nt ? r && (r.get ? r.get.apply(e) : r.value) : t.stack });
|
|
428
|
+
}), function(r) {
|
|
429
|
+
fe.some((s) => s._value === r._value) || fe.push(r);
|
|
430
|
+
}(t), Gn(t), n && Qe();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function Gn(t) {
|
|
434
|
+
var e = t._listeners;
|
|
435
|
+
t._listeners = [];
|
|
436
|
+
for (var n = 0, r = e.length; n < r; ++n)
|
|
437
|
+
hn(t, e[n]);
|
|
438
|
+
var s = t._PSD;
|
|
439
|
+
--s.ref || s.finalize(), pe === 0 && (++pe, Me(() => {
|
|
440
|
+
--pe == 0 && dn();
|
|
441
|
+
}, []));
|
|
442
|
+
}
|
|
443
|
+
function hn(t, e) {
|
|
444
|
+
if (t._state !== null) {
|
|
445
|
+
var n = t._state ? e.onFulfilled : e.onRejected;
|
|
446
|
+
if (n === null)
|
|
447
|
+
return (t._state ? e.resolve : e.reject)(t._value);
|
|
448
|
+
++e.psd.ref, ++pe, Me(Br, [n, t, e]);
|
|
449
|
+
} else
|
|
450
|
+
t._listeners.push(e);
|
|
451
|
+
}
|
|
452
|
+
function Br(t, e, n) {
|
|
453
|
+
try {
|
|
454
|
+
Lt = e;
|
|
455
|
+
var r, s = e._value;
|
|
456
|
+
e._state ? r = t(s) : (ot.length && (ot = []), r = t(s), ot.indexOf(s) === -1 && function(i) {
|
|
457
|
+
for (var o = fe.length; o; )
|
|
458
|
+
if (fe[--o]._value === i._value)
|
|
459
|
+
return void fe.splice(o, 1);
|
|
460
|
+
}(e)), n.resolve(r);
|
|
461
|
+
} catch (i) {
|
|
462
|
+
n.reject(i);
|
|
463
|
+
} finally {
|
|
464
|
+
Lt = null, --pe == 0 && dn(), --n.psd.ref || n.psd.finalize();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function Hn(t, e, n) {
|
|
468
|
+
if (e.length === n)
|
|
469
|
+
return e;
|
|
470
|
+
var r = "";
|
|
471
|
+
if (t._state === !1) {
|
|
472
|
+
var s, i, o = t._value;
|
|
473
|
+
o != null ? (s = o.name || "Error", i = o.message || o, r = Mt(o, 0)) : (s = o, i = ""), e.push(s + (i ? ": " + i : "") + r);
|
|
474
|
+
}
|
|
475
|
+
return J && ((r = Mt(t._stackHolder, 2)) && e.indexOf(r) === -1 && e.push(r), t._prev && Hn(t._prev, e, n)), e;
|
|
476
|
+
}
|
|
477
|
+
function Yn(t, e) {
|
|
478
|
+
var n = e ? e._numPrev + 1 : 0;
|
|
479
|
+
n < 100 && (t._prev = e, t._numPrev = n);
|
|
480
|
+
}
|
|
481
|
+
function Xe() {
|
|
482
|
+
Ye() && Qe();
|
|
483
|
+
}
|
|
484
|
+
function Ye() {
|
|
485
|
+
var t = $t;
|
|
486
|
+
return $t = !1, pt = !1, t;
|
|
487
|
+
}
|
|
488
|
+
function Qe() {
|
|
489
|
+
var t, e, n;
|
|
490
|
+
do
|
|
491
|
+
for (; Be.length > 0; )
|
|
492
|
+
for (t = Be, Be = [], n = t.length, e = 0; e < n; ++e) {
|
|
493
|
+
var r = t[e];
|
|
494
|
+
r[0].apply(null, r[1]);
|
|
495
|
+
}
|
|
496
|
+
while (Be.length > 0);
|
|
497
|
+
$t = !0, pt = !0;
|
|
498
|
+
}
|
|
499
|
+
function dn() {
|
|
500
|
+
var t = fe;
|
|
501
|
+
fe = [], t.forEach((r) => {
|
|
502
|
+
r._PSD.onunhandled.call(null, r._value, r);
|
|
503
|
+
});
|
|
504
|
+
for (var e = at.slice(0), n = e.length; n; )
|
|
505
|
+
e[--n]();
|
|
506
|
+
}
|
|
507
|
+
function Ze(t) {
|
|
508
|
+
return new E(Ue, !1, t);
|
|
509
|
+
}
|
|
510
|
+
function I(t, e) {
|
|
511
|
+
var n = O;
|
|
512
|
+
return function() {
|
|
513
|
+
var r = Ye(), s = O;
|
|
514
|
+
try {
|
|
515
|
+
return ce(n, !0), t.apply(this, arguments);
|
|
516
|
+
} catch (i) {
|
|
517
|
+
e && e(i);
|
|
518
|
+
} finally {
|
|
519
|
+
ce(s, !1), r && Qe();
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
Ce(E.prototype, { then: Wt, _then: function(t, e) {
|
|
524
|
+
hn(this, new zn(null, null, t, e, O));
|
|
525
|
+
}, catch: function(t) {
|
|
526
|
+
if (arguments.length === 1)
|
|
527
|
+
return this.then(null, t);
|
|
528
|
+
var e = arguments[0], n = arguments[1];
|
|
529
|
+
return typeof e == "function" ? this.then(null, (r) => r instanceof e ? n(r) : Ze(r)) : this.then(null, (r) => r && r.name === e ? n(r) : Ze(r));
|
|
530
|
+
}, finally: function(t) {
|
|
531
|
+
return this.then((e) => (t(), e), (e) => (t(), Ze(e)));
|
|
532
|
+
}, stack: { get: function() {
|
|
533
|
+
if (this._stack)
|
|
534
|
+
return this._stack;
|
|
535
|
+
try {
|
|
536
|
+
Nt = !0;
|
|
537
|
+
var t = Hn(this, [], 20).join(`
|
|
538
|
+
From previous: `);
|
|
539
|
+
return this._state !== null && (this._stack = t), t;
|
|
540
|
+
} finally {
|
|
541
|
+
Nt = !1;
|
|
542
|
+
}
|
|
543
|
+
} }, timeout: function(t, e) {
|
|
544
|
+
return t < 1 / 0 ? new E((n, r) => {
|
|
545
|
+
var s = setTimeout(() => r(new C.Timeout(e)), t);
|
|
546
|
+
this.then(n, r).finally(clearTimeout.bind(null, s));
|
|
547
|
+
}) : this;
|
|
548
|
+
} }), typeof Symbol < "u" && Symbol.toStringTag && te(E.prototype, Symbol.toStringTag, "Dexie.Promise"), Pe.env = Qn(), Ce(E, { all: function() {
|
|
549
|
+
var t = q.apply(null, arguments).map(qe);
|
|
550
|
+
return new E(function(e, n) {
|
|
551
|
+
t.length === 0 && e([]);
|
|
552
|
+
var r = t.length;
|
|
553
|
+
t.forEach((s, i) => E.resolve(s).then((o) => {
|
|
554
|
+
t[i] = o, --r || e(t);
|
|
555
|
+
}, n));
|
|
556
|
+
});
|
|
557
|
+
}, resolve: (t) => {
|
|
558
|
+
if (t instanceof E)
|
|
559
|
+
return t;
|
|
560
|
+
if (t && typeof t.then == "function")
|
|
561
|
+
return new E((n, r) => {
|
|
562
|
+
t.then(n, r);
|
|
563
|
+
});
|
|
564
|
+
var e = new E(Ue, !0, t);
|
|
565
|
+
return Yn(e, Lt), e;
|
|
566
|
+
}, reject: Ze, race: function() {
|
|
567
|
+
var t = q.apply(null, arguments).map(qe);
|
|
568
|
+
return new E((e, n) => {
|
|
569
|
+
t.map((r) => E.resolve(r).then(e, n));
|
|
570
|
+
});
|
|
571
|
+
}, PSD: { get: () => O, set: (t) => O = t }, totalEchoes: { get: () => mt }, newPSD: ae, usePSD: Ke, scheduler: { get: () => Me, set: (t) => {
|
|
572
|
+
Me = t;
|
|
573
|
+
} }, rejectionMapper: { get: () => Ut, set: (t) => {
|
|
574
|
+
Ut = t;
|
|
575
|
+
} }, follow: (t, e) => new E((n, r) => ae((s, i) => {
|
|
576
|
+
var o = O;
|
|
577
|
+
o.unhandleds = [], o.onunhandled = i, o.finalize = ye(function() {
|
|
578
|
+
(function(a) {
|
|
579
|
+
function c() {
|
|
580
|
+
a(), at.splice(at.indexOf(c), 1);
|
|
581
|
+
}
|
|
582
|
+
at.push(c), ++pe, Me(() => {
|
|
583
|
+
--pe == 0 && dn();
|
|
584
|
+
}, []);
|
|
585
|
+
})(() => {
|
|
586
|
+
this.unhandleds.length === 0 ? s() : i(this.unhandleds[0]);
|
|
587
|
+
});
|
|
588
|
+
}, o.finalize), t();
|
|
589
|
+
}, e, n, r)) }), it && (it.allSettled && te(E, "allSettled", function() {
|
|
590
|
+
const t = q.apply(null, arguments).map(qe);
|
|
591
|
+
return new E((e) => {
|
|
592
|
+
t.length === 0 && e([]);
|
|
593
|
+
let n = t.length;
|
|
594
|
+
const r = new Array(n);
|
|
595
|
+
t.forEach((s, i) => E.resolve(s).then((o) => r[i] = { status: "fulfilled", value: o }, (o) => r[i] = { status: "rejected", reason: o }).then(() => --n || e(r)));
|
|
596
|
+
});
|
|
597
|
+
}), it.any && typeof AggregateError < "u" && te(E, "any", function() {
|
|
598
|
+
const t = q.apply(null, arguments).map(qe);
|
|
599
|
+
return new E((e, n) => {
|
|
600
|
+
t.length === 0 && n(new AggregateError([]));
|
|
601
|
+
let r = t.length;
|
|
602
|
+
const s = new Array(r);
|
|
603
|
+
t.forEach((i, o) => E.resolve(i).then((a) => e(a), (a) => {
|
|
604
|
+
s[o] = a, --r || n(new AggregateError(s));
|
|
605
|
+
}));
|
|
606
|
+
});
|
|
607
|
+
}));
|
|
608
|
+
const $ = { awaits: 0, echoes: 0, id: 0 };
|
|
609
|
+
var Tr = 0, ct = [], kt = 0, mt = 0, Mr = 0;
|
|
610
|
+
function ae(t, e, n, r) {
|
|
611
|
+
var s = O, i = Object.create(s);
|
|
612
|
+
i.parent = s, i.ref = 0, i.global = !1, i.id = ++Mr;
|
|
613
|
+
var o = Pe.env;
|
|
614
|
+
i.env = un ? { Promise: E, PromiseProp: { value: E, configurable: !0, writable: !0 }, all: E.all, race: E.race, allSettled: E.allSettled, any: E.any, resolve: E.resolve, reject: E.reject, nthen: vn(o.nthen, i), gthen: vn(o.gthen, i) } : {}, e && z(i, e), ++s.ref, i.finalize = function() {
|
|
615
|
+
--this.parent.ref || this.parent.finalize();
|
|
616
|
+
};
|
|
617
|
+
var a = Ke(i, t, n, r);
|
|
618
|
+
return i.ref === 0 && i.finalize(), a;
|
|
619
|
+
}
|
|
620
|
+
function je() {
|
|
621
|
+
return $.id || ($.id = ++Tr), ++$.awaits, $.echoes += Un, $.id;
|
|
622
|
+
}
|
|
623
|
+
function re() {
|
|
624
|
+
return !!$.awaits && (--$.awaits == 0 && ($.id = 0), $.echoes = $.awaits * Un, !0);
|
|
625
|
+
}
|
|
626
|
+
function qe(t) {
|
|
627
|
+
return $.echoes && t && t.constructor === it ? (je(), t.then((e) => (re(), e), (e) => (re(), F(e)))) : t;
|
|
628
|
+
}
|
|
629
|
+
function Rr(t) {
|
|
630
|
+
++mt, $.echoes && --$.echoes != 0 || ($.echoes = $.id = 0), ct.push(O), ce(t, !0);
|
|
631
|
+
}
|
|
632
|
+
function Fr() {
|
|
633
|
+
var t = ct[ct.length - 1];
|
|
634
|
+
ct.pop(), ce(t, !1);
|
|
635
|
+
}
|
|
636
|
+
function ce(t, e) {
|
|
637
|
+
var n = O;
|
|
638
|
+
if ((e ? !$.echoes || kt++ && t === O : !kt || --kt && t === O) || Jn(e ? Rr.bind(null, t) : Fr), t !== O && (O = t, n === Pe && (Pe.env = Qn()), un)) {
|
|
639
|
+
var r = Pe.env.Promise, s = t.env;
|
|
640
|
+
ft.then = s.nthen, r.prototype.then = s.gthen, (n.global || t.global) && (Object.defineProperty(D, "Promise", s.PromiseProp), r.all = s.all, r.race = s.race, r.resolve = s.resolve, r.reject = s.reject, s.allSettled && (r.allSettled = s.allSettled), s.any && (r.any = s.any));
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function Qn() {
|
|
644
|
+
var t = D.Promise;
|
|
645
|
+
return un ? { Promise: t, PromiseProp: Object.getOwnPropertyDescriptor(D, "Promise"), all: t.all, race: t.race, allSettled: t.allSettled, any: t.any, resolve: t.resolve, reject: t.reject, nthen: ft.then, gthen: t.prototype.then } : {};
|
|
646
|
+
}
|
|
647
|
+
function Ke(t, e, n, r, s) {
|
|
648
|
+
var i = O;
|
|
649
|
+
try {
|
|
650
|
+
return ce(t, !0), e(n, r, s);
|
|
651
|
+
} finally {
|
|
652
|
+
ce(i, !1);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function Jn(t) {
|
|
656
|
+
Wn.call(Rt, t);
|
|
657
|
+
}
|
|
658
|
+
function yt(t, e, n, r) {
|
|
659
|
+
return typeof t != "function" ? t : function() {
|
|
660
|
+
var s = O;
|
|
661
|
+
n && je(), ce(e, !0);
|
|
662
|
+
try {
|
|
663
|
+
return t.apply(this, arguments);
|
|
664
|
+
} finally {
|
|
665
|
+
ce(s, !1), r && Jn(re);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function vn(t, e) {
|
|
670
|
+
return function(n, r) {
|
|
671
|
+
return t.call(this, yt(n, e), yt(r, e));
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
("" + Wn).indexOf("[native code]") === -1 && (je = re = A);
|
|
675
|
+
const wn = "unhandledrejection";
|
|
676
|
+
function _n(t, e) {
|
|
677
|
+
var n;
|
|
678
|
+
try {
|
|
679
|
+
n = e.onuncatched(t);
|
|
680
|
+
} catch {
|
|
681
|
+
}
|
|
682
|
+
if (n !== !1)
|
|
683
|
+
try {
|
|
684
|
+
var r, s = { promise: e, reason: t };
|
|
685
|
+
if (D.document && document.createEvent ? ((r = document.createEvent("Event")).initEvent(wn, !0, !0), z(r, s)) : D.CustomEvent && z(r = new CustomEvent(wn, { detail: s }), s), r && D.dispatchEvent && (dispatchEvent(r), !D.PromiseRejectionEvent && D.onunhandledrejection))
|
|
686
|
+
try {
|
|
687
|
+
D.onunhandledrejection(r);
|
|
688
|
+
} catch {
|
|
689
|
+
}
|
|
690
|
+
J && r && !r.defaultPrevented && console.warn(`Unhandled rejection: ${t.stack || t}`);
|
|
691
|
+
} catch {
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
var F = E.reject;
|
|
695
|
+
function Vt(t, e, n, r) {
|
|
696
|
+
if (t.idbdb && (t._state.openComplete || O.letThrough || t._vip)) {
|
|
697
|
+
var s = t._createTransaction(e, n, t._dbSchema);
|
|
698
|
+
try {
|
|
699
|
+
s.create(), t._state.PR1398_maxLoop = 3;
|
|
700
|
+
} catch (i) {
|
|
701
|
+
return i.name === cn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => Vt(t, e, n, r))) : F(i);
|
|
702
|
+
}
|
|
703
|
+
return s._promise(e, (i, o) => ae(() => (O.trans = s, r(i, o, s)))).then((i) => s._completion.then(() => i));
|
|
704
|
+
}
|
|
705
|
+
if (t._state.openComplete)
|
|
706
|
+
return F(new C.DatabaseClosed(t._state.dbOpenError));
|
|
707
|
+
if (!t._state.isBeingOpened) {
|
|
708
|
+
if (!t._options.autoOpen)
|
|
709
|
+
return F(new C.DatabaseClosed());
|
|
710
|
+
t.open().catch(A);
|
|
711
|
+
}
|
|
712
|
+
return t._state.dbReadyPromise.then(() => Vt(t, e, n, r));
|
|
713
|
+
}
|
|
714
|
+
const kn = "3.2.5", de = "", Gt = -1 / 0, X = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", Xn = "String expected.", Re = [], vt = typeof navigator < "u" && /(MSIE|Trident|Edge)/.test(navigator.userAgent), Nr = vt, $r = vt, Zn = (t) => !/(dexie\.js|dexie\.min\.js)/.test(t), wt = "__dbnames", xt = "readonly", St = "readwrite";
|
|
715
|
+
function ge(t, e) {
|
|
716
|
+
return t ? e ? function() {
|
|
717
|
+
return t.apply(this, arguments) && e.apply(this, arguments);
|
|
718
|
+
} : t : e;
|
|
719
|
+
}
|
|
720
|
+
const qn = { type: 3, lower: -1 / 0, lowerOpen: !1, upper: [[]], upperOpen: !1 };
|
|
721
|
+
function et(t) {
|
|
722
|
+
return typeof t != "string" || /\./.test(t) ? (e) => e : (e) => (e[t] === void 0 && t in e && delete (e = He(e))[t], e);
|
|
723
|
+
}
|
|
724
|
+
class Lr {
|
|
725
|
+
_trans(e, n, r) {
|
|
726
|
+
const s = this._tx || O.trans, i = this.name;
|
|
727
|
+
function o(c, l, u) {
|
|
728
|
+
if (!u.schema[i])
|
|
729
|
+
throw new C.NotFound("Table " + i + " not part of transaction");
|
|
730
|
+
return n(u.idbtrans, u);
|
|
731
|
+
}
|
|
732
|
+
const a = Ye();
|
|
733
|
+
try {
|
|
734
|
+
return s && s.db === this.db ? s === O.trans ? s._promise(e, o, r) : ae(() => s._promise(e, o, r), { trans: s, transless: O.transless || O }) : Vt(this.db, e, [this.name], o);
|
|
735
|
+
} finally {
|
|
736
|
+
a && Qe();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
get(e, n) {
|
|
740
|
+
return e && e.constructor === Object ? this.where(e).first(n) : this._trans("readonly", (r) => this.core.get({ trans: r, key: e }).then((s) => this.hook.reading.fire(s))).then(n);
|
|
741
|
+
}
|
|
742
|
+
where(e) {
|
|
743
|
+
if (typeof e == "string")
|
|
744
|
+
return new this.db.WhereClause(this, e);
|
|
745
|
+
if (L(e))
|
|
746
|
+
return new this.db.WhereClause(this, `[${e.join("+")}]`);
|
|
747
|
+
const n = R(e);
|
|
748
|
+
if (n.length === 1)
|
|
749
|
+
return this.where(n[0]).equals(e[n[0]]);
|
|
750
|
+
const r = this.schema.indexes.concat(this.schema.primKey).filter((l) => {
|
|
751
|
+
if (l.compound && n.every((u) => l.keyPath.indexOf(u) >= 0)) {
|
|
752
|
+
for (let u = 0; u < n.length; ++u)
|
|
753
|
+
if (n.indexOf(l.keyPath[u]) === -1)
|
|
754
|
+
return !1;
|
|
755
|
+
return !0;
|
|
756
|
+
}
|
|
757
|
+
return !1;
|
|
758
|
+
}).sort((l, u) => l.keyPath.length - u.keyPath.length)[0];
|
|
759
|
+
if (r && this.db._maxKey !== de) {
|
|
760
|
+
const l = r.keyPath.slice(0, n.length);
|
|
761
|
+
return this.where(l).equals(l.map((u) => e[u]));
|
|
762
|
+
}
|
|
763
|
+
!r && J && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);
|
|
764
|
+
const { idxByName: s } = this.schema, i = this.db._deps.indexedDB;
|
|
765
|
+
function o(l, u) {
|
|
766
|
+
try {
|
|
767
|
+
return i.cmp(l, u) === 0;
|
|
768
|
+
} catch {
|
|
769
|
+
return !1;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
const [a, c] = n.reduce(([l, u], d) => {
|
|
773
|
+
const h = s[d], p = e[d];
|
|
774
|
+
return [l || h, l || !h ? ge(u, h && h.multi ? (g) => {
|
|
775
|
+
const y = ne(g, d);
|
|
776
|
+
return L(y) && y.some((b) => o(p, b));
|
|
777
|
+
} : (g) => o(p, ne(g, d))) : u];
|
|
778
|
+
}, [null, null]);
|
|
779
|
+
return a ? this.where(a.name).equals(e[a.keyPath]).filter(c) : r ? this.filter(c) : this.where(n).equals("");
|
|
780
|
+
}
|
|
781
|
+
filter(e) {
|
|
782
|
+
return this.toCollection().and(e);
|
|
783
|
+
}
|
|
784
|
+
count(e) {
|
|
785
|
+
return this.toCollection().count(e);
|
|
786
|
+
}
|
|
787
|
+
offset(e) {
|
|
788
|
+
return this.toCollection().offset(e);
|
|
789
|
+
}
|
|
790
|
+
limit(e) {
|
|
791
|
+
return this.toCollection().limit(e);
|
|
792
|
+
}
|
|
793
|
+
each(e) {
|
|
794
|
+
return this.toCollection().each(e);
|
|
795
|
+
}
|
|
796
|
+
toArray(e) {
|
|
797
|
+
return this.toCollection().toArray(e);
|
|
798
|
+
}
|
|
799
|
+
toCollection() {
|
|
800
|
+
return new this.db.Collection(new this.db.WhereClause(this));
|
|
801
|
+
}
|
|
802
|
+
orderBy(e) {
|
|
803
|
+
return new this.db.Collection(new this.db.WhereClause(this, L(e) ? `[${e.join("+")}]` : e));
|
|
804
|
+
}
|
|
805
|
+
reverse() {
|
|
806
|
+
return this.toCollection().reverse();
|
|
807
|
+
}
|
|
808
|
+
mapToClass(e) {
|
|
809
|
+
this.schema.mappedClass = e;
|
|
810
|
+
const n = (r) => {
|
|
811
|
+
if (!r)
|
|
812
|
+
return r;
|
|
813
|
+
const s = Object.create(e.prototype);
|
|
814
|
+
for (var i in r)
|
|
815
|
+
if (H(r, i))
|
|
816
|
+
try {
|
|
817
|
+
s[i] = r[i];
|
|
818
|
+
} catch {
|
|
819
|
+
}
|
|
820
|
+
return s;
|
|
821
|
+
};
|
|
822
|
+
return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = n, this.hook("reading", n), e;
|
|
823
|
+
}
|
|
824
|
+
defineClass() {
|
|
825
|
+
return this.mapToClass(function(e) {
|
|
826
|
+
z(this, e);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
add(e, n) {
|
|
830
|
+
const { auto: r, keyPath: s } = this.schema.primKey;
|
|
831
|
+
let i = e;
|
|
832
|
+
return s && r && (i = et(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "add", keys: n != null ? [n] : null, values: [i] })).then((o) => o.numFailures ? E.reject(o.failures[0]) : o.lastResult).then((o) => {
|
|
833
|
+
if (s)
|
|
834
|
+
try {
|
|
835
|
+
Y(e, s, o);
|
|
836
|
+
} catch {
|
|
837
|
+
}
|
|
838
|
+
return o;
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
update(e, n) {
|
|
842
|
+
if (typeof e != "object" || L(e))
|
|
843
|
+
return this.where(":id").equals(e).modify(n);
|
|
844
|
+
{
|
|
845
|
+
const r = ne(e, this.schema.primKey.keyPath);
|
|
846
|
+
if (r === void 0)
|
|
847
|
+
return F(new C.InvalidArgument("Given object does not contain its primary key"));
|
|
848
|
+
try {
|
|
849
|
+
typeof n != "function" ? R(n).forEach((s) => {
|
|
850
|
+
Y(e, s, n[s]);
|
|
851
|
+
}) : n(e, { value: e, primKey: r });
|
|
852
|
+
} catch {
|
|
853
|
+
}
|
|
854
|
+
return this.where(":id").equals(r).modify(n);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
put(e, n) {
|
|
858
|
+
const { auto: r, keyPath: s } = this.schema.primKey;
|
|
859
|
+
let i = e;
|
|
860
|
+
return s && r && (i = et(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "put", values: [i], keys: n != null ? [n] : null })).then((o) => o.numFailures ? E.reject(o.failures[0]) : o.lastResult).then((o) => {
|
|
861
|
+
if (s)
|
|
862
|
+
try {
|
|
863
|
+
Y(e, s, o);
|
|
864
|
+
} catch {
|
|
865
|
+
}
|
|
866
|
+
return o;
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
delete(e) {
|
|
870
|
+
return this._trans("readwrite", (n) => this.core.mutate({ trans: n, type: "delete", keys: [e] })).then((n) => n.numFailures ? E.reject(n.failures[0]) : void 0);
|
|
871
|
+
}
|
|
872
|
+
clear() {
|
|
873
|
+
return this._trans("readwrite", (e) => this.core.mutate({ trans: e, type: "deleteRange", range: qn })).then((e) => e.numFailures ? E.reject(e.failures[0]) : void 0);
|
|
874
|
+
}
|
|
875
|
+
bulkGet(e) {
|
|
876
|
+
return this._trans("readonly", (n) => this.core.getMany({ keys: e, trans: n }).then((r) => r.map((s) => this.hook.reading.fire(s))));
|
|
877
|
+
}
|
|
878
|
+
bulkAdd(e, n, r) {
|
|
879
|
+
const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
|
|
880
|
+
return this._trans("readwrite", (o) => {
|
|
881
|
+
const { auto: a, keyPath: c } = this.schema.primKey;
|
|
882
|
+
if (c && s)
|
|
883
|
+
throw new C.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
|
|
884
|
+
if (s && s.length !== e.length)
|
|
885
|
+
throw new C.InvalidArgument("Arguments objects and keys must have the same length");
|
|
886
|
+
const l = e.length;
|
|
887
|
+
let u = c && a ? e.map(et(c)) : e;
|
|
888
|
+
return this.core.mutate({ trans: o, type: "add", keys: s, values: u, wantResults: i }).then(({ numFailures: d, results: h, lastResult: p, failures: g }) => {
|
|
889
|
+
if (d === 0)
|
|
890
|
+
return i ? h : p;
|
|
891
|
+
throw new Te(`${this.name}.bulkAdd(): ${d} of ${l} operations failed`, g);
|
|
892
|
+
});
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
bulkPut(e, n, r) {
|
|
896
|
+
const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
|
|
897
|
+
return this._trans("readwrite", (o) => {
|
|
898
|
+
const { auto: a, keyPath: c } = this.schema.primKey;
|
|
899
|
+
if (c && s)
|
|
900
|
+
throw new C.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
|
|
901
|
+
if (s && s.length !== e.length)
|
|
902
|
+
throw new C.InvalidArgument("Arguments objects and keys must have the same length");
|
|
903
|
+
const l = e.length;
|
|
904
|
+
let u = c && a ? e.map(et(c)) : e;
|
|
905
|
+
return this.core.mutate({ trans: o, type: "put", keys: s, values: u, wantResults: i }).then(({ numFailures: d, results: h, lastResult: p, failures: g }) => {
|
|
906
|
+
if (d === 0)
|
|
907
|
+
return i ? h : p;
|
|
908
|
+
throw new Te(`${this.name}.bulkPut(): ${d} of ${l} operations failed`, g);
|
|
909
|
+
});
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
bulkDelete(e) {
|
|
913
|
+
const n = e.length;
|
|
914
|
+
return this._trans("readwrite", (r) => this.core.mutate({ trans: r, type: "delete", keys: e })).then(({ numFailures: r, lastResult: s, failures: i }) => {
|
|
915
|
+
if (r === 0)
|
|
916
|
+
return s;
|
|
917
|
+
throw new Te(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
function Fe(t) {
|
|
922
|
+
var e = {}, n = function(o, a) {
|
|
923
|
+
if (a) {
|
|
924
|
+
for (var c = arguments.length, l = new Array(c - 1); --c; )
|
|
925
|
+
l[c - 1] = arguments[c];
|
|
926
|
+
return e[o].subscribe.apply(null, l), t;
|
|
927
|
+
}
|
|
928
|
+
if (typeof o == "string")
|
|
929
|
+
return e[o];
|
|
930
|
+
};
|
|
931
|
+
n.addEventType = i;
|
|
932
|
+
for (var r = 1, s = arguments.length; r < s; ++r)
|
|
933
|
+
i(arguments[r]);
|
|
934
|
+
return n;
|
|
935
|
+
function i(o, a, c) {
|
|
936
|
+
if (typeof o != "object") {
|
|
937
|
+
var l;
|
|
938
|
+
a || (a = Dr), c || (c = A);
|
|
939
|
+
var u = { subscribers: [], fire: c, subscribe: function(d) {
|
|
940
|
+
u.subscribers.indexOf(d) === -1 && (u.subscribers.push(d), u.fire = a(u.fire, d));
|
|
941
|
+
}, unsubscribe: function(d) {
|
|
942
|
+
u.subscribers = u.subscribers.filter(function(h) {
|
|
943
|
+
return h !== d;
|
|
944
|
+
}), u.fire = u.subscribers.reduce(a, c);
|
|
945
|
+
} };
|
|
946
|
+
return e[o] = n[o] = u, u;
|
|
947
|
+
}
|
|
948
|
+
R(l = o).forEach(function(d) {
|
|
949
|
+
var h = l[d];
|
|
950
|
+
if (L(h))
|
|
951
|
+
i(d, l[d][0], l[d][1]);
|
|
952
|
+
else {
|
|
953
|
+
if (h !== "asap")
|
|
954
|
+
throw new C.InvalidArgument("Invalid event config");
|
|
955
|
+
var p = i(d, Le, function() {
|
|
956
|
+
for (var g = arguments.length, y = new Array(g); g--; )
|
|
957
|
+
y[g] = arguments[g];
|
|
958
|
+
p.subscribers.forEach(function(b) {
|
|
959
|
+
In(function() {
|
|
960
|
+
b.apply(null, y);
|
|
961
|
+
});
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function De(t, e) {
|
|
969
|
+
return Se(e).from({ prototype: t }), e;
|
|
970
|
+
}
|
|
971
|
+
function _e(t, e) {
|
|
972
|
+
return !(t.filter || t.algorithm || t.or) && (e ? t.justLimit : !t.replayFilter);
|
|
973
|
+
}
|
|
974
|
+
function Et(t, e) {
|
|
975
|
+
t.filter = ge(t.filter, e);
|
|
976
|
+
}
|
|
977
|
+
function Pt(t, e, n) {
|
|
978
|
+
var r = t.replayFilter;
|
|
979
|
+
t.replayFilter = r ? () => ge(r(), e()) : e, t.justLimit = n && !r;
|
|
980
|
+
}
|
|
981
|
+
function lt(t, e) {
|
|
982
|
+
if (t.isPrimKey)
|
|
983
|
+
return e.primaryKey;
|
|
984
|
+
const n = e.getIndexByKeyPath(t.index);
|
|
985
|
+
if (!n)
|
|
986
|
+
throw new C.Schema("KeyPath " + t.index + " on object store " + e.name + " is not indexed");
|
|
987
|
+
return n;
|
|
988
|
+
}
|
|
989
|
+
function xn(t, e, n) {
|
|
990
|
+
const r = lt(t, e.schema);
|
|
991
|
+
return e.openCursor({ trans: n, values: !t.keysOnly, reverse: t.dir === "prev", unique: !!t.unique, query: { index: r, range: t.range } });
|
|
992
|
+
}
|
|
993
|
+
function tt(t, e, n, r) {
|
|
994
|
+
const s = t.replayFilter ? ge(t.filter, t.replayFilter()) : t.filter;
|
|
995
|
+
if (t.or) {
|
|
996
|
+
const i = {}, o = (a, c, l) => {
|
|
997
|
+
if (!s || s(c, l, (h) => c.stop(h), (h) => c.fail(h))) {
|
|
998
|
+
var u = c.primaryKey, d = "" + u;
|
|
999
|
+
d === "[object ArrayBuffer]" && (d = "" + new Uint8Array(u)), H(i, d) || (i[d] = !0, e(a, c, l));
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
return Promise.all([t.or._iterate(o, n), Sn(xn(t, r, n), t.algorithm, o, !t.keysOnly && t.valueMapper)]);
|
|
1003
|
+
}
|
|
1004
|
+
return Sn(xn(t, r, n), ge(t.algorithm, s), e, !t.keysOnly && t.valueMapper);
|
|
1005
|
+
}
|
|
1006
|
+
function Sn(t, e, n, r) {
|
|
1007
|
+
var s = I(r ? (i, o, a) => n(r(i), o, a) : n);
|
|
1008
|
+
return t.then((i) => {
|
|
1009
|
+
if (i)
|
|
1010
|
+
return i.start(() => {
|
|
1011
|
+
var o = () => i.continue();
|
|
1012
|
+
e && !e(i, (a) => o = a, (a) => {
|
|
1013
|
+
i.stop(a), o = A;
|
|
1014
|
+
}, (a) => {
|
|
1015
|
+
i.fail(a), o = A;
|
|
1016
|
+
}) || s(i.value, i, (a) => o = a), o();
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
function W(t, e) {
|
|
1021
|
+
try {
|
|
1022
|
+
const n = En(t), r = En(e);
|
|
1023
|
+
if (n !== r)
|
|
1024
|
+
return n === "Array" ? 1 : r === "Array" ? -1 : n === "binary" ? 1 : r === "binary" ? -1 : n === "string" ? 1 : r === "string" ? -1 : n === "Date" ? 1 : r !== "Date" ? NaN : -1;
|
|
1025
|
+
switch (n) {
|
|
1026
|
+
case "number":
|
|
1027
|
+
case "Date":
|
|
1028
|
+
case "string":
|
|
1029
|
+
return t > e ? 1 : t < e ? -1 : 0;
|
|
1030
|
+
case "binary":
|
|
1031
|
+
return function(s, i) {
|
|
1032
|
+
const o = s.length, a = i.length, c = o < a ? o : a;
|
|
1033
|
+
for (let l = 0; l < c; ++l)
|
|
1034
|
+
if (s[l] !== i[l])
|
|
1035
|
+
return s[l] < i[l] ? -1 : 1;
|
|
1036
|
+
return o === a ? 0 : o < a ? -1 : 1;
|
|
1037
|
+
}(Pn(t), Pn(e));
|
|
1038
|
+
case "Array":
|
|
1039
|
+
return function(s, i) {
|
|
1040
|
+
const o = s.length, a = i.length, c = o < a ? o : a;
|
|
1041
|
+
for (let l = 0; l < c; ++l) {
|
|
1042
|
+
const u = W(s[l], i[l]);
|
|
1043
|
+
if (u !== 0)
|
|
1044
|
+
return u;
|
|
1045
|
+
}
|
|
1046
|
+
return o === a ? 0 : o < a ? -1 : 1;
|
|
1047
|
+
}(t, e);
|
|
1048
|
+
}
|
|
1049
|
+
} catch {
|
|
1050
|
+
}
|
|
1051
|
+
return NaN;
|
|
1052
|
+
}
|
|
1053
|
+
function En(t) {
|
|
1054
|
+
const e = typeof t;
|
|
1055
|
+
if (e !== "object")
|
|
1056
|
+
return e;
|
|
1057
|
+
if (ArrayBuffer.isView(t))
|
|
1058
|
+
return "binary";
|
|
1059
|
+
const n = Bt(t);
|
|
1060
|
+
return n === "ArrayBuffer" ? "binary" : n;
|
|
1061
|
+
}
|
|
1062
|
+
function Pn(t) {
|
|
1063
|
+
return t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t);
|
|
1064
|
+
}
|
|
1065
|
+
class Ur {
|
|
1066
|
+
_read(e, n) {
|
|
1067
|
+
var r = this._ctx;
|
|
1068
|
+
return r.error ? r.table._trans(null, F.bind(null, r.error)) : r.table._trans("readonly", e).then(n);
|
|
1069
|
+
}
|
|
1070
|
+
_write(e) {
|
|
1071
|
+
var n = this._ctx;
|
|
1072
|
+
return n.error ? n.table._trans(null, F.bind(null, n.error)) : n.table._trans("readwrite", e, "locked");
|
|
1073
|
+
}
|
|
1074
|
+
_addAlgorithm(e) {
|
|
1075
|
+
var n = this._ctx;
|
|
1076
|
+
n.algorithm = ge(n.algorithm, e);
|
|
1077
|
+
}
|
|
1078
|
+
_iterate(e, n) {
|
|
1079
|
+
return tt(this._ctx, e, n, this._ctx.table.core);
|
|
1080
|
+
}
|
|
1081
|
+
clone(e) {
|
|
1082
|
+
var n = Object.create(this.constructor.prototype), r = Object.create(this._ctx);
|
|
1083
|
+
return e && z(r, e), n._ctx = r, n;
|
|
1084
|
+
}
|
|
1085
|
+
raw() {
|
|
1086
|
+
return this._ctx.valueMapper = null, this;
|
|
1087
|
+
}
|
|
1088
|
+
each(e) {
|
|
1089
|
+
var n = this._ctx;
|
|
1090
|
+
return this._read((r) => tt(n, e, r, n.table.core));
|
|
1091
|
+
}
|
|
1092
|
+
count(e) {
|
|
1093
|
+
return this._read((n) => {
|
|
1094
|
+
const r = this._ctx, s = r.table.core;
|
|
1095
|
+
if (_e(r, !0))
|
|
1096
|
+
return s.count({ trans: n, query: { index: lt(r, s.schema), range: r.range } }).then((o) => Math.min(o, r.limit));
|
|
1097
|
+
var i = 0;
|
|
1098
|
+
return tt(r, () => (++i, !1), n, s).then(() => i);
|
|
1099
|
+
}).then(e);
|
|
1100
|
+
}
|
|
1101
|
+
sortBy(e, n) {
|
|
1102
|
+
const r = e.split(".").reverse(), s = r[0], i = r.length - 1;
|
|
1103
|
+
function o(l, u) {
|
|
1104
|
+
return u ? o(l[r[u]], u - 1) : l[s];
|
|
1105
|
+
}
|
|
1106
|
+
var a = this._ctx.dir === "next" ? 1 : -1;
|
|
1107
|
+
function c(l, u) {
|
|
1108
|
+
var d = o(l, i), h = o(u, i);
|
|
1109
|
+
return d < h ? -a : d > h ? a : 0;
|
|
1110
|
+
}
|
|
1111
|
+
return this.toArray(function(l) {
|
|
1112
|
+
return l.sort(c);
|
|
1113
|
+
}).then(n);
|
|
1114
|
+
}
|
|
1115
|
+
toArray(e) {
|
|
1116
|
+
return this._read((n) => {
|
|
1117
|
+
var r = this._ctx;
|
|
1118
|
+
if (r.dir === "next" && _e(r, !0) && r.limit > 0) {
|
|
1119
|
+
const { valueMapper: s } = r, i = lt(r, r.table.core.schema);
|
|
1120
|
+
return r.table.core.query({ trans: n, limit: r.limit, values: !0, query: { index: i, range: r.range } }).then(({ result: o }) => s ? o.map(s) : o);
|
|
1121
|
+
}
|
|
1122
|
+
{
|
|
1123
|
+
const s = [];
|
|
1124
|
+
return tt(r, (i) => s.push(i), n, r.table.core).then(() => s);
|
|
1125
|
+
}
|
|
1126
|
+
}, e);
|
|
1127
|
+
}
|
|
1128
|
+
offset(e) {
|
|
1129
|
+
var n = this._ctx;
|
|
1130
|
+
return e <= 0 || (n.offset += e, _e(n) ? Pt(n, () => {
|
|
1131
|
+
var r = e;
|
|
1132
|
+
return (s, i) => r === 0 || (r === 1 ? (--r, !1) : (i(() => {
|
|
1133
|
+
s.advance(r), r = 0;
|
|
1134
|
+
}), !1));
|
|
1135
|
+
}) : Pt(n, () => {
|
|
1136
|
+
var r = e;
|
|
1137
|
+
return () => --r < 0;
|
|
1138
|
+
})), this;
|
|
1139
|
+
}
|
|
1140
|
+
limit(e) {
|
|
1141
|
+
return this._ctx.limit = Math.min(this._ctx.limit, e), Pt(this._ctx, () => {
|
|
1142
|
+
var n = e;
|
|
1143
|
+
return function(r, s, i) {
|
|
1144
|
+
return --n <= 0 && s(i), n >= 0;
|
|
1145
|
+
};
|
|
1146
|
+
}, !0), this;
|
|
1147
|
+
}
|
|
1148
|
+
until(e, n) {
|
|
1149
|
+
return Et(this._ctx, function(r, s, i) {
|
|
1150
|
+
return !e(r.value) || (s(i), n);
|
|
1151
|
+
}), this;
|
|
1152
|
+
}
|
|
1153
|
+
first(e) {
|
|
1154
|
+
return this.limit(1).toArray(function(n) {
|
|
1155
|
+
return n[0];
|
|
1156
|
+
}).then(e);
|
|
1157
|
+
}
|
|
1158
|
+
last(e) {
|
|
1159
|
+
return this.reverse().first(e);
|
|
1160
|
+
}
|
|
1161
|
+
filter(e) {
|
|
1162
|
+
var n, r;
|
|
1163
|
+
return Et(this._ctx, function(s) {
|
|
1164
|
+
return e(s.value);
|
|
1165
|
+
}), n = this._ctx, r = e, n.isMatch = ge(n.isMatch, r), this;
|
|
1166
|
+
}
|
|
1167
|
+
and(e) {
|
|
1168
|
+
return this.filter(e);
|
|
1169
|
+
}
|
|
1170
|
+
or(e) {
|
|
1171
|
+
return new this.db.WhereClause(this._ctx.table, e, this);
|
|
1172
|
+
}
|
|
1173
|
+
reverse() {
|
|
1174
|
+
return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
|
|
1175
|
+
}
|
|
1176
|
+
desc() {
|
|
1177
|
+
return this.reverse();
|
|
1178
|
+
}
|
|
1179
|
+
eachKey(e) {
|
|
1180
|
+
var n = this._ctx;
|
|
1181
|
+
return n.keysOnly = !n.isMatch, this.each(function(r, s) {
|
|
1182
|
+
e(s.key, s);
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
eachUniqueKey(e) {
|
|
1186
|
+
return this._ctx.unique = "unique", this.eachKey(e);
|
|
1187
|
+
}
|
|
1188
|
+
eachPrimaryKey(e) {
|
|
1189
|
+
var n = this._ctx;
|
|
1190
|
+
return n.keysOnly = !n.isMatch, this.each(function(r, s) {
|
|
1191
|
+
e(s.primaryKey, s);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
keys(e) {
|
|
1195
|
+
var n = this._ctx;
|
|
1196
|
+
n.keysOnly = !n.isMatch;
|
|
1197
|
+
var r = [];
|
|
1198
|
+
return this.each(function(s, i) {
|
|
1199
|
+
r.push(i.key);
|
|
1200
|
+
}).then(function() {
|
|
1201
|
+
return r;
|
|
1202
|
+
}).then(e);
|
|
1203
|
+
}
|
|
1204
|
+
primaryKeys(e) {
|
|
1205
|
+
var n = this._ctx;
|
|
1206
|
+
if (n.dir === "next" && _e(n, !0) && n.limit > 0)
|
|
1207
|
+
return this._read((s) => {
|
|
1208
|
+
var i = lt(n, n.table.core.schema);
|
|
1209
|
+
return n.table.core.query({ trans: s, values: !1, limit: n.limit, query: { index: i, range: n.range } });
|
|
1210
|
+
}).then(({ result: s }) => s).then(e);
|
|
1211
|
+
n.keysOnly = !n.isMatch;
|
|
1212
|
+
var r = [];
|
|
1213
|
+
return this.each(function(s, i) {
|
|
1214
|
+
r.push(i.primaryKey);
|
|
1215
|
+
}).then(function() {
|
|
1216
|
+
return r;
|
|
1217
|
+
}).then(e);
|
|
1218
|
+
}
|
|
1219
|
+
uniqueKeys(e) {
|
|
1220
|
+
return this._ctx.unique = "unique", this.keys(e);
|
|
1221
|
+
}
|
|
1222
|
+
firstKey(e) {
|
|
1223
|
+
return this.limit(1).keys(function(n) {
|
|
1224
|
+
return n[0];
|
|
1225
|
+
}).then(e);
|
|
1226
|
+
}
|
|
1227
|
+
lastKey(e) {
|
|
1228
|
+
return this.reverse().firstKey(e);
|
|
1229
|
+
}
|
|
1230
|
+
distinct() {
|
|
1231
|
+
var e = this._ctx, n = e.index && e.table.schema.idxByName[e.index];
|
|
1232
|
+
if (!n || !n.multi)
|
|
1233
|
+
return this;
|
|
1234
|
+
var r = {};
|
|
1235
|
+
return Et(this._ctx, function(s) {
|
|
1236
|
+
var i = s.primaryKey.toString(), o = H(r, i);
|
|
1237
|
+
return r[i] = !0, !o;
|
|
1238
|
+
}), this;
|
|
1239
|
+
}
|
|
1240
|
+
modify(e) {
|
|
1241
|
+
var n = this._ctx;
|
|
1242
|
+
return this._write((r) => {
|
|
1243
|
+
var s;
|
|
1244
|
+
if (typeof e == "function")
|
|
1245
|
+
s = e;
|
|
1246
|
+
else {
|
|
1247
|
+
var i = R(e), o = i.length;
|
|
1248
|
+
s = function(y) {
|
|
1249
|
+
for (var b = !1, m = 0; m < o; ++m) {
|
|
1250
|
+
var f = i[m], w = e[f];
|
|
1251
|
+
ne(y, f) !== w && (Y(y, f, w), b = !0);
|
|
1252
|
+
}
|
|
1253
|
+
return b;
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
const a = n.table.core, { outbound: c, extractKey: l } = a.schema.primaryKey, u = this.db._options.modifyChunkSize || 200, d = [];
|
|
1257
|
+
let h = 0;
|
|
1258
|
+
const p = [], g = (y, b) => {
|
|
1259
|
+
const { failures: m, numFailures: f } = b;
|
|
1260
|
+
h += y - f;
|
|
1261
|
+
for (let w of R(m))
|
|
1262
|
+
d.push(m[w]);
|
|
1263
|
+
};
|
|
1264
|
+
return this.clone().primaryKeys().then((y) => {
|
|
1265
|
+
const b = (m) => {
|
|
1266
|
+
const f = Math.min(u, y.length - m);
|
|
1267
|
+
return a.getMany({ trans: r, keys: y.slice(m, m + f), cache: "immutable" }).then((w) => {
|
|
1268
|
+
const S = [], P = [], x = c ? [] : null, v = [];
|
|
1269
|
+
for (let _ = 0; _ < f; ++_) {
|
|
1270
|
+
const T = w[_], K = { value: He(T), primKey: y[m + _] };
|
|
1271
|
+
s.call(K, K.value, K) !== !1 && (K.value == null ? v.push(y[m + _]) : c || W(l(T), l(K.value)) === 0 ? (P.push(K.value), c && x.push(y[m + _])) : (v.push(y[m + _]), S.push(K.value)));
|
|
1272
|
+
}
|
|
1273
|
+
const j = _e(n) && n.limit === 1 / 0 && (typeof e != "function" || e === Ot) && { index: n.index, range: n.range };
|
|
1274
|
+
return Promise.resolve(S.length > 0 && a.mutate({ trans: r, type: "add", values: S }).then((_) => {
|
|
1275
|
+
for (let T in _.failures)
|
|
1276
|
+
v.splice(parseInt(T), 1);
|
|
1277
|
+
g(S.length, _);
|
|
1278
|
+
})).then(() => (P.length > 0 || j && typeof e == "object") && a.mutate({ trans: r, type: "put", keys: x, values: P, criteria: j, changeSpec: typeof e != "function" && e }).then((_) => g(P.length, _))).then(() => (v.length > 0 || j && e === Ot) && a.mutate({ trans: r, type: "delete", keys: v, criteria: j }).then((_) => g(v.length, _))).then(() => y.length > m + f && b(m + u));
|
|
1279
|
+
});
|
|
1280
|
+
};
|
|
1281
|
+
return b(0).then(() => {
|
|
1282
|
+
if (d.length > 0)
|
|
1283
|
+
throw new dt("Error modifying one or more objects", d, h, p);
|
|
1284
|
+
return y.length;
|
|
1285
|
+
});
|
|
1286
|
+
});
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
delete() {
|
|
1290
|
+
var e = this._ctx, n = e.range;
|
|
1291
|
+
return _e(e) && (e.isPrimKey && !$r || n.type === 3) ? this._write((r) => {
|
|
1292
|
+
const { primaryKey: s } = e.table.core.schema, i = n;
|
|
1293
|
+
return e.table.core.count({ trans: r, query: { index: s, range: i } }).then((o) => e.table.core.mutate({ trans: r, type: "deleteRange", range: i }).then(({ failures: a, lastResult: c, results: l, numFailures: u }) => {
|
|
1294
|
+
if (u)
|
|
1295
|
+
throw new dt("Could not delete some values", Object.keys(a).map((d) => a[d]), o - u);
|
|
1296
|
+
return o - u;
|
|
1297
|
+
}));
|
|
1298
|
+
}) : this.modify(Ot);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
const Ot = (t, e) => e.value = null;
|
|
1302
|
+
function Wr(t, e) {
|
|
1303
|
+
return t < e ? -1 : t === e ? 0 : 1;
|
|
1304
|
+
}
|
|
1305
|
+
function zr(t, e) {
|
|
1306
|
+
return t > e ? -1 : t === e ? 0 : 1;
|
|
1307
|
+
}
|
|
1308
|
+
function G(t, e, n) {
|
|
1309
|
+
var r = t instanceof tr ? new t.Collection(t) : t;
|
|
1310
|
+
return r._ctx.error = n ? new n(e) : new TypeError(e), r;
|
|
1311
|
+
}
|
|
1312
|
+
function ke(t) {
|
|
1313
|
+
return new t.Collection(t, () => er("")).limit(0);
|
|
1314
|
+
}
|
|
1315
|
+
function Vr(t, e, n, r, s, i) {
|
|
1316
|
+
for (var o = Math.min(t.length, r.length), a = -1, c = 0; c < o; ++c) {
|
|
1317
|
+
var l = e[c];
|
|
1318
|
+
if (l !== r[c])
|
|
1319
|
+
return s(t[c], n[c]) < 0 ? t.substr(0, c) + n[c] + n.substr(c + 1) : s(t[c], r[c]) < 0 ? t.substr(0, c) + r[c] + n.substr(c + 1) : a >= 0 ? t.substr(0, a) + e[a] + n.substr(a + 1) : null;
|
|
1320
|
+
s(t[c], l) < 0 && (a = c);
|
|
1321
|
+
}
|
|
1322
|
+
return o < r.length && i === "next" ? t + n.substr(t.length) : o < t.length && i === "prev" ? t.substr(0, n.length) : a < 0 ? null : t.substr(0, a) + r[a] + n.substr(a + 1);
|
|
1323
|
+
}
|
|
1324
|
+
function nt(t, e, n, r) {
|
|
1325
|
+
var s, i, o, a, c, l, u, d = n.length;
|
|
1326
|
+
if (!n.every((y) => typeof y == "string"))
|
|
1327
|
+
return G(t, Xn);
|
|
1328
|
+
function h(y) {
|
|
1329
|
+
s = /* @__PURE__ */ function(m) {
|
|
1330
|
+
return m === "next" ? (f) => f.toUpperCase() : (f) => f.toLowerCase();
|
|
1331
|
+
}(y), i = /* @__PURE__ */ function(m) {
|
|
1332
|
+
return m === "next" ? (f) => f.toLowerCase() : (f) => f.toUpperCase();
|
|
1333
|
+
}(y), o = y === "next" ? Wr : zr;
|
|
1334
|
+
var b = n.map(function(m) {
|
|
1335
|
+
return { lower: i(m), upper: s(m) };
|
|
1336
|
+
}).sort(function(m, f) {
|
|
1337
|
+
return o(m.lower, f.lower);
|
|
1338
|
+
});
|
|
1339
|
+
a = b.map(function(m) {
|
|
1340
|
+
return m.upper;
|
|
1341
|
+
}), c = b.map(function(m) {
|
|
1342
|
+
return m.lower;
|
|
1343
|
+
}), l = y, u = y === "next" ? "" : r;
|
|
1344
|
+
}
|
|
1345
|
+
h("next");
|
|
1346
|
+
var p = new t.Collection(t, () => se(a[0], c[d - 1] + r));
|
|
1347
|
+
p._ondirectionchange = function(y) {
|
|
1348
|
+
h(y);
|
|
1349
|
+
};
|
|
1350
|
+
var g = 0;
|
|
1351
|
+
return p._addAlgorithm(function(y, b, m) {
|
|
1352
|
+
var f = y.key;
|
|
1353
|
+
if (typeof f != "string")
|
|
1354
|
+
return !1;
|
|
1355
|
+
var w = i(f);
|
|
1356
|
+
if (e(w, c, g))
|
|
1357
|
+
return !0;
|
|
1358
|
+
for (var S = null, P = g; P < d; ++P) {
|
|
1359
|
+
var x = Vr(f, w, a[P], c[P], o, l);
|
|
1360
|
+
x === null && S === null ? g = P + 1 : (S === null || o(S, x) > 0) && (S = x);
|
|
1361
|
+
}
|
|
1362
|
+
return b(S !== null ? function() {
|
|
1363
|
+
y.continue(S + u);
|
|
1364
|
+
} : m), !1;
|
|
1365
|
+
}), p;
|
|
1366
|
+
}
|
|
1367
|
+
function se(t, e, n, r) {
|
|
1368
|
+
return { type: 2, lower: t, upper: e, lowerOpen: n, upperOpen: r };
|
|
1369
|
+
}
|
|
1370
|
+
function er(t) {
|
|
1371
|
+
return { type: 1, lower: t, upper: t };
|
|
1372
|
+
}
|
|
1373
|
+
class tr {
|
|
1374
|
+
get Collection() {
|
|
1375
|
+
return this._ctx.table.db.Collection;
|
|
1376
|
+
}
|
|
1377
|
+
between(e, n, r, s) {
|
|
1378
|
+
r = r !== !1, s = s === !0;
|
|
1379
|
+
try {
|
|
1380
|
+
return this._cmp(e, n) > 0 || this._cmp(e, n) === 0 && (r || s) && (!r || !s) ? ke(this) : new this.Collection(this, () => se(e, n, !r, !s));
|
|
1381
|
+
} catch {
|
|
1382
|
+
return G(this, X);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
equals(e) {
|
|
1386
|
+
return e == null ? G(this, X) : new this.Collection(this, () => er(e));
|
|
1387
|
+
}
|
|
1388
|
+
above(e) {
|
|
1389
|
+
return e == null ? G(this, X) : new this.Collection(this, () => se(e, void 0, !0));
|
|
1390
|
+
}
|
|
1391
|
+
aboveOrEqual(e) {
|
|
1392
|
+
return e == null ? G(this, X) : new this.Collection(this, () => se(e, void 0, !1));
|
|
1393
|
+
}
|
|
1394
|
+
below(e) {
|
|
1395
|
+
return e == null ? G(this, X) : new this.Collection(this, () => se(void 0, e, !1, !0));
|
|
1396
|
+
}
|
|
1397
|
+
belowOrEqual(e) {
|
|
1398
|
+
return e == null ? G(this, X) : new this.Collection(this, () => se(void 0, e));
|
|
1399
|
+
}
|
|
1400
|
+
startsWith(e) {
|
|
1401
|
+
return typeof e != "string" ? G(this, Xn) : this.between(e, e + de, !0, !0);
|
|
1402
|
+
}
|
|
1403
|
+
startsWithIgnoreCase(e) {
|
|
1404
|
+
return e === "" ? this.startsWith(e) : nt(this, (n, r) => n.indexOf(r[0]) === 0, [e], de);
|
|
1405
|
+
}
|
|
1406
|
+
equalsIgnoreCase(e) {
|
|
1407
|
+
return nt(this, (n, r) => n === r[0], [e], "");
|
|
1408
|
+
}
|
|
1409
|
+
anyOfIgnoreCase() {
|
|
1410
|
+
var e = q.apply(xe, arguments);
|
|
1411
|
+
return e.length === 0 ? ke(this) : nt(this, (n, r) => r.indexOf(n) !== -1, e, "");
|
|
1412
|
+
}
|
|
1413
|
+
startsWithAnyOfIgnoreCase() {
|
|
1414
|
+
var e = q.apply(xe, arguments);
|
|
1415
|
+
return e.length === 0 ? ke(this) : nt(this, (n, r) => r.some((s) => n.indexOf(s) === 0), e, de);
|
|
1416
|
+
}
|
|
1417
|
+
anyOf() {
|
|
1418
|
+
const e = q.apply(xe, arguments);
|
|
1419
|
+
let n = this._cmp;
|
|
1420
|
+
try {
|
|
1421
|
+
e.sort(n);
|
|
1422
|
+
} catch {
|
|
1423
|
+
return G(this, X);
|
|
1424
|
+
}
|
|
1425
|
+
if (e.length === 0)
|
|
1426
|
+
return ke(this);
|
|
1427
|
+
const r = new this.Collection(this, () => se(e[0], e[e.length - 1]));
|
|
1428
|
+
r._ondirectionchange = (i) => {
|
|
1429
|
+
n = i === "next" ? this._ascending : this._descending, e.sort(n);
|
|
1430
|
+
};
|
|
1431
|
+
let s = 0;
|
|
1432
|
+
return r._addAlgorithm((i, o, a) => {
|
|
1433
|
+
const c = i.key;
|
|
1434
|
+
for (; n(c, e[s]) > 0; )
|
|
1435
|
+
if (++s, s === e.length)
|
|
1436
|
+
return o(a), !1;
|
|
1437
|
+
return n(c, e[s]) === 0 || (o(() => {
|
|
1438
|
+
i.continue(e[s]);
|
|
1439
|
+
}), !1);
|
|
1440
|
+
}), r;
|
|
1441
|
+
}
|
|
1442
|
+
notEqual(e) {
|
|
1443
|
+
return this.inAnyRange([[Gt, e], [e, this.db._maxKey]], { includeLowers: !1, includeUppers: !1 });
|
|
1444
|
+
}
|
|
1445
|
+
noneOf() {
|
|
1446
|
+
const e = q.apply(xe, arguments);
|
|
1447
|
+
if (e.length === 0)
|
|
1448
|
+
return new this.Collection(this);
|
|
1449
|
+
try {
|
|
1450
|
+
e.sort(this._ascending);
|
|
1451
|
+
} catch {
|
|
1452
|
+
return G(this, X);
|
|
1453
|
+
}
|
|
1454
|
+
const n = e.reduce((r, s) => r ? r.concat([[r[r.length - 1][1], s]]) : [[Gt, s]], null);
|
|
1455
|
+
return n.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(n, { includeLowers: !1, includeUppers: !1 });
|
|
1456
|
+
}
|
|
1457
|
+
inAnyRange(e, n) {
|
|
1458
|
+
const r = this._cmp, s = this._ascending, i = this._descending, o = this._min, a = this._max;
|
|
1459
|
+
if (e.length === 0)
|
|
1460
|
+
return ke(this);
|
|
1461
|
+
if (!e.every((f) => f[0] !== void 0 && f[1] !== void 0 && s(f[0], f[1]) <= 0))
|
|
1462
|
+
return G(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", C.InvalidArgument);
|
|
1463
|
+
const c = !n || n.includeLowers !== !1, l = n && n.includeUppers === !0;
|
|
1464
|
+
let u, d = s;
|
|
1465
|
+
function h(f, w) {
|
|
1466
|
+
return d(f[0], w[0]);
|
|
1467
|
+
}
|
|
1468
|
+
try {
|
|
1469
|
+
u = e.reduce(function(f, w) {
|
|
1470
|
+
let S = 0, P = f.length;
|
|
1471
|
+
for (; S < P; ++S) {
|
|
1472
|
+
const x = f[S];
|
|
1473
|
+
if (r(w[0], x[1]) < 0 && r(w[1], x[0]) > 0) {
|
|
1474
|
+
x[0] = o(x[0], w[0]), x[1] = a(x[1], w[1]);
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
return S === P && f.push(w), f;
|
|
1479
|
+
}, []), u.sort(h);
|
|
1480
|
+
} catch {
|
|
1481
|
+
return G(this, X);
|
|
1482
|
+
}
|
|
1483
|
+
let p = 0;
|
|
1484
|
+
const g = l ? (f) => s(f, u[p][1]) > 0 : (f) => s(f, u[p][1]) >= 0, y = c ? (f) => i(f, u[p][0]) > 0 : (f) => i(f, u[p][0]) >= 0;
|
|
1485
|
+
let b = g;
|
|
1486
|
+
const m = new this.Collection(this, () => se(u[0][0], u[u.length - 1][1], !c, !l));
|
|
1487
|
+
return m._ondirectionchange = (f) => {
|
|
1488
|
+
f === "next" ? (b = g, d = s) : (b = y, d = i), u.sort(h);
|
|
1489
|
+
}, m._addAlgorithm((f, w, S) => {
|
|
1490
|
+
for (var P = f.key; b(P); )
|
|
1491
|
+
if (++p, p === u.length)
|
|
1492
|
+
return w(S), !1;
|
|
1493
|
+
return !!function(x) {
|
|
1494
|
+
return !g(x) && !y(x);
|
|
1495
|
+
}(P) || (this._cmp(P, u[p][1]) === 0 || this._cmp(P, u[p][0]) === 0 || w(() => {
|
|
1496
|
+
d === s ? f.continue(u[p][0]) : f.continue(u[p][1]);
|
|
1497
|
+
}), !1);
|
|
1498
|
+
}), m;
|
|
1499
|
+
}
|
|
1500
|
+
startsWithAnyOf() {
|
|
1501
|
+
const e = q.apply(xe, arguments);
|
|
1502
|
+
return e.every((n) => typeof n == "string") ? e.length === 0 ? ke(this) : this.inAnyRange(e.map((n) => [n, n + de])) : G(this, "startsWithAnyOf() only works with strings");
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function Q(t) {
|
|
1506
|
+
return I(function(e) {
|
|
1507
|
+
return We(e), t(e.target.error), !1;
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
function We(t) {
|
|
1511
|
+
t.stopPropagation && t.stopPropagation(), t.preventDefault && t.preventDefault();
|
|
1512
|
+
}
|
|
1513
|
+
const ze = "storagemutated", oe = "x-storagemutated-1", le = Fe(null, ze);
|
|
1514
|
+
class Gr {
|
|
1515
|
+
_lock() {
|
|
1516
|
+
return Ie(!O.global), ++this._reculock, this._reculock !== 1 || O.global || (O.lockOwnerFor = this), this;
|
|
1517
|
+
}
|
|
1518
|
+
_unlock() {
|
|
1519
|
+
if (Ie(!O.global), --this._reculock == 0)
|
|
1520
|
+
for (O.global || (O.lockOwnerFor = null); this._blockedFuncs.length > 0 && !this._locked(); ) {
|
|
1521
|
+
var e = this._blockedFuncs.shift();
|
|
1522
|
+
try {
|
|
1523
|
+
Ke(e[1], e[0]);
|
|
1524
|
+
} catch {
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
return this;
|
|
1528
|
+
}
|
|
1529
|
+
_locked() {
|
|
1530
|
+
return this._reculock && O.lockOwnerFor !== this;
|
|
1531
|
+
}
|
|
1532
|
+
create(e) {
|
|
1533
|
+
if (!this.mode)
|
|
1534
|
+
return this;
|
|
1535
|
+
const n = this.db.idbdb, r = this.db._state.dbOpenError;
|
|
1536
|
+
if (Ie(!this.idbtrans), !e && !n)
|
|
1537
|
+
switch (r && r.name) {
|
|
1538
|
+
case "DatabaseClosedError":
|
|
1539
|
+
throw new C.DatabaseClosed(r);
|
|
1540
|
+
case "MissingAPIError":
|
|
1541
|
+
throw new C.MissingAPI(r.message, r);
|
|
1542
|
+
default:
|
|
1543
|
+
throw new C.OpenFailed(r);
|
|
1544
|
+
}
|
|
1545
|
+
if (!this.active)
|
|
1546
|
+
throw new C.TransactionInactive();
|
|
1547
|
+
return Ie(this._completion._state === null), (e = this.idbtrans = e || (this.db.core ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }) : n.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }))).onerror = I((s) => {
|
|
1548
|
+
We(s), this._reject(e.error);
|
|
1549
|
+
}), e.onabort = I((s) => {
|
|
1550
|
+
We(s), this.active && this._reject(new C.Abort(e.error)), this.active = !1, this.on("abort").fire(s);
|
|
1551
|
+
}), e.oncomplete = I(() => {
|
|
1552
|
+
this.active = !1, this._resolve(), "mutatedParts" in e && le.storagemutated.fire(e.mutatedParts);
|
|
1553
|
+
}), this;
|
|
1554
|
+
}
|
|
1555
|
+
_promise(e, n, r) {
|
|
1556
|
+
if (e === "readwrite" && this.mode !== "readwrite")
|
|
1557
|
+
return F(new C.ReadOnly("Transaction is readonly"));
|
|
1558
|
+
if (!this.active)
|
|
1559
|
+
return F(new C.TransactionInactive());
|
|
1560
|
+
if (this._locked())
|
|
1561
|
+
return new E((i, o) => {
|
|
1562
|
+
this._blockedFuncs.push([() => {
|
|
1563
|
+
this._promise(e, n, r).then(i, o);
|
|
1564
|
+
}, O]);
|
|
1565
|
+
});
|
|
1566
|
+
if (r)
|
|
1567
|
+
return ae(() => {
|
|
1568
|
+
var i = new E((o, a) => {
|
|
1569
|
+
this._lock();
|
|
1570
|
+
const c = n(o, a, this);
|
|
1571
|
+
c && c.then && c.then(o, a);
|
|
1572
|
+
});
|
|
1573
|
+
return i.finally(() => this._unlock()), i._lib = !0, i;
|
|
1574
|
+
});
|
|
1575
|
+
var s = new E((i, o) => {
|
|
1576
|
+
var a = n(i, o, this);
|
|
1577
|
+
a && a.then && a.then(i, o);
|
|
1578
|
+
});
|
|
1579
|
+
return s._lib = !0, s;
|
|
1580
|
+
}
|
|
1581
|
+
_root() {
|
|
1582
|
+
return this.parent ? this.parent._root() : this;
|
|
1583
|
+
}
|
|
1584
|
+
waitFor(e) {
|
|
1585
|
+
var n = this._root();
|
|
1586
|
+
const r = E.resolve(e);
|
|
1587
|
+
if (n._waitingFor)
|
|
1588
|
+
n._waitingFor = n._waitingFor.then(() => r);
|
|
1589
|
+
else {
|
|
1590
|
+
n._waitingFor = r, n._waitingQueue = [];
|
|
1591
|
+
var s = n.idbtrans.objectStore(n.storeNames[0]);
|
|
1592
|
+
(function o() {
|
|
1593
|
+
for (++n._spinCount; n._waitingQueue.length; )
|
|
1594
|
+
n._waitingQueue.shift()();
|
|
1595
|
+
n._waitingFor && (s.get(-1 / 0).onsuccess = o);
|
|
1596
|
+
})();
|
|
1597
|
+
}
|
|
1598
|
+
var i = n._waitingFor;
|
|
1599
|
+
return new E((o, a) => {
|
|
1600
|
+
r.then((c) => n._waitingQueue.push(I(o.bind(null, c))), (c) => n._waitingQueue.push(I(a.bind(null, c)))).finally(() => {
|
|
1601
|
+
n._waitingFor === i && (n._waitingFor = null);
|
|
1602
|
+
});
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
abort() {
|
|
1606
|
+
this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new C.Abort()));
|
|
1607
|
+
}
|
|
1608
|
+
table(e) {
|
|
1609
|
+
const n = this._memoizedTables || (this._memoizedTables = {});
|
|
1610
|
+
if (H(n, e))
|
|
1611
|
+
return n[e];
|
|
1612
|
+
const r = this.schema[e];
|
|
1613
|
+
if (!r)
|
|
1614
|
+
throw new C.NotFound("Table " + e + " not part of transaction");
|
|
1615
|
+
const s = new this.db.Table(e, r, this);
|
|
1616
|
+
return s.core = this.db.core.table(e), n[e] = s, s;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
function Ht(t, e, n, r, s, i, o) {
|
|
1620
|
+
return { name: t, keyPath: e, unique: n, multi: r, auto: s, compound: i, src: (n && !o ? "&" : "") + (r ? "*" : "") + (s ? "++" : "") + nr(e) };
|
|
1621
|
+
}
|
|
1622
|
+
function nr(t) {
|
|
1623
|
+
return typeof t == "string" ? t : t ? "[" + [].join.call(t, "+") + "]" : "";
|
|
1624
|
+
}
|
|
1625
|
+
function rr(t, e, n) {
|
|
1626
|
+
return { name: t, primKey: e, indexes: n, mappedClass: null, idxByName: Bn(n, (r) => [r.name, r]) };
|
|
1627
|
+
}
|
|
1628
|
+
let Ve = (t) => {
|
|
1629
|
+
try {
|
|
1630
|
+
return t.only([[]]), Ve = () => [[]], [[]];
|
|
1631
|
+
} catch {
|
|
1632
|
+
return Ve = () => de, de;
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
function Yt(t) {
|
|
1636
|
+
return t == null ? () => {
|
|
1637
|
+
} : typeof t == "string" ? function(e) {
|
|
1638
|
+
return e.split(".").length === 1 ? (r) => r[e] : (r) => ne(r, e);
|
|
1639
|
+
}(t) : (e) => ne(e, t);
|
|
1640
|
+
}
|
|
1641
|
+
function On(t) {
|
|
1642
|
+
return [].slice.call(t);
|
|
1643
|
+
}
|
|
1644
|
+
let Hr = 0;
|
|
1645
|
+
function Ne(t) {
|
|
1646
|
+
return t == null ? ":id" : typeof t == "string" ? t : `[${t.join("+")}]`;
|
|
1647
|
+
}
|
|
1648
|
+
function Yr(t, e, n) {
|
|
1649
|
+
function r(c) {
|
|
1650
|
+
if (c.type === 3)
|
|
1651
|
+
return null;
|
|
1652
|
+
if (c.type === 4)
|
|
1653
|
+
throw new Error("Cannot convert never type to IDBKeyRange");
|
|
1654
|
+
const { lower: l, upper: u, lowerOpen: d, upperOpen: h } = c;
|
|
1655
|
+
return l === void 0 ? u === void 0 ? null : e.upperBound(u, !!h) : u === void 0 ? e.lowerBound(l, !!d) : e.bound(l, u, !!d, !!h);
|
|
1656
|
+
}
|
|
1657
|
+
const { schema: s, hasGetAll: i } = function(c, l) {
|
|
1658
|
+
const u = On(c.objectStoreNames);
|
|
1659
|
+
return { schema: { name: c.name, tables: u.map((d) => l.objectStore(d)).map((d) => {
|
|
1660
|
+
const { keyPath: h, autoIncrement: p } = d, g = L(h), y = h == null, b = {}, m = { name: d.name, primaryKey: { name: null, isPrimaryKey: !0, outbound: y, compound: g, keyPath: h, autoIncrement: p, unique: !0, extractKey: Yt(h) }, indexes: On(d.indexNames).map((f) => d.index(f)).map((f) => {
|
|
1661
|
+
const { name: w, unique: S, multiEntry: P, keyPath: x } = f, v = { name: w, compound: L(x), keyPath: x, unique: S, multiEntry: P, extractKey: Yt(x) };
|
|
1662
|
+
return b[Ne(x)] = v, v;
|
|
1663
|
+
}), getIndexByKeyPath: (f) => b[Ne(f)] };
|
|
1664
|
+
return b[":id"] = m.primaryKey, h != null && (b[Ne(h)] = m.primaryKey), m;
|
|
1665
|
+
}) }, hasGetAll: u.length > 0 && "getAll" in l.objectStore(u[0]) && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) };
|
|
1666
|
+
}(t, n), o = s.tables.map((c) => function(l) {
|
|
1667
|
+
const u = l.name;
|
|
1668
|
+
return { name: u, schema: l, mutate: function({ trans: d, type: h, keys: p, values: g, range: y }) {
|
|
1669
|
+
return new Promise((b, m) => {
|
|
1670
|
+
b = I(b);
|
|
1671
|
+
const f = d.objectStore(u), w = f.keyPath == null, S = h === "put" || h === "add";
|
|
1672
|
+
if (!S && h !== "delete" && h !== "deleteRange")
|
|
1673
|
+
throw new Error("Invalid operation type: " + h);
|
|
1674
|
+
const { length: P } = p || g || { length: 1 };
|
|
1675
|
+
if (p && g && p.length !== g.length)
|
|
1676
|
+
throw new Error("Given keys array must have same length as given values array.");
|
|
1677
|
+
if (P === 0)
|
|
1678
|
+
return b({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
|
|
1679
|
+
let x;
|
|
1680
|
+
const v = [], j = [];
|
|
1681
|
+
let _ = 0;
|
|
1682
|
+
const T = (U) => {
|
|
1683
|
+
++_, We(U);
|
|
1684
|
+
};
|
|
1685
|
+
if (h === "deleteRange") {
|
|
1686
|
+
if (y.type === 4)
|
|
1687
|
+
return b({ numFailures: _, failures: j, results: [], lastResult: void 0 });
|
|
1688
|
+
y.type === 3 ? v.push(x = f.clear()) : v.push(x = f.delete(r(y)));
|
|
1689
|
+
} else {
|
|
1690
|
+
const [U, N] = S ? w ? [g, p] : [g, null] : [p, null];
|
|
1691
|
+
if (S)
|
|
1692
|
+
for (let M = 0; M < P; ++M)
|
|
1693
|
+
v.push(x = N && N[M] !== void 0 ? f[h](U[M], N[M]) : f[h](U[M])), x.onerror = T;
|
|
1694
|
+
else
|
|
1695
|
+
for (let M = 0; M < P; ++M)
|
|
1696
|
+
v.push(x = f[h](U[M])), x.onerror = T;
|
|
1697
|
+
}
|
|
1698
|
+
const K = (U) => {
|
|
1699
|
+
const N = U.target.result;
|
|
1700
|
+
v.forEach((M, ve) => M.error != null && (j[ve] = M.error)), b({ numFailures: _, failures: j, results: h === "delete" ? p : v.map((M) => M.result), lastResult: N });
|
|
1701
|
+
};
|
|
1702
|
+
x.onerror = (U) => {
|
|
1703
|
+
T(U), K(U);
|
|
1704
|
+
}, x.onsuccess = K;
|
|
1705
|
+
});
|
|
1706
|
+
}, getMany: ({ trans: d, keys: h }) => new Promise((p, g) => {
|
|
1707
|
+
p = I(p);
|
|
1708
|
+
const y = d.objectStore(u), b = h.length, m = new Array(b);
|
|
1709
|
+
let f, w = 0, S = 0;
|
|
1710
|
+
const P = (v) => {
|
|
1711
|
+
const j = v.target;
|
|
1712
|
+
m[j._pos] = j.result, ++S === w && p(m);
|
|
1713
|
+
}, x = Q(g);
|
|
1714
|
+
for (let v = 0; v < b; ++v)
|
|
1715
|
+
h[v] != null && (f = y.get(h[v]), f._pos = v, f.onsuccess = P, f.onerror = x, ++w);
|
|
1716
|
+
w === 0 && p(m);
|
|
1717
|
+
}), get: ({ trans: d, key: h }) => new Promise((p, g) => {
|
|
1718
|
+
p = I(p);
|
|
1719
|
+
const y = d.objectStore(u).get(h);
|
|
1720
|
+
y.onsuccess = (b) => p(b.target.result), y.onerror = Q(g);
|
|
1721
|
+
}), query: /* @__PURE__ */ function(d) {
|
|
1722
|
+
return (h) => new Promise((p, g) => {
|
|
1723
|
+
p = I(p);
|
|
1724
|
+
const { trans: y, values: b, limit: m, query: f } = h, w = m === 1 / 0 ? void 0 : m, { index: S, range: P } = f, x = y.objectStore(u), v = S.isPrimaryKey ? x : x.index(S.name), j = r(P);
|
|
1725
|
+
if (m === 0)
|
|
1726
|
+
return p({ result: [] });
|
|
1727
|
+
if (d) {
|
|
1728
|
+
const _ = b ? v.getAll(j, w) : v.getAllKeys(j, w);
|
|
1729
|
+
_.onsuccess = (T) => p({ result: T.target.result }), _.onerror = Q(g);
|
|
1730
|
+
} else {
|
|
1731
|
+
let _ = 0;
|
|
1732
|
+
const T = b || !("openKeyCursor" in v) ? v.openCursor(j) : v.openKeyCursor(j), K = [];
|
|
1733
|
+
T.onsuccess = (U) => {
|
|
1734
|
+
const N = T.result;
|
|
1735
|
+
return N ? (K.push(b ? N.value : N.primaryKey), ++_ === m ? p({ result: K }) : void N.continue()) : p({ result: K });
|
|
1736
|
+
}, T.onerror = Q(g);
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
}(i), openCursor: function({ trans: d, values: h, query: p, reverse: g, unique: y }) {
|
|
1740
|
+
return new Promise((b, m) => {
|
|
1741
|
+
b = I(b);
|
|
1742
|
+
const { index: f, range: w } = p, S = d.objectStore(u), P = f.isPrimaryKey ? S : S.index(f.name), x = g ? y ? "prevunique" : "prev" : y ? "nextunique" : "next", v = h || !("openKeyCursor" in P) ? P.openCursor(r(w), x) : P.openKeyCursor(r(w), x);
|
|
1743
|
+
v.onerror = Q(m), v.onsuccess = I((j) => {
|
|
1744
|
+
const _ = v.result;
|
|
1745
|
+
if (!_)
|
|
1746
|
+
return void b(null);
|
|
1747
|
+
_.___id = ++Hr, _.done = !1;
|
|
1748
|
+
const T = _.continue.bind(_);
|
|
1749
|
+
let K = _.continuePrimaryKey;
|
|
1750
|
+
K && (K = K.bind(_));
|
|
1751
|
+
const U = _.advance.bind(_), N = () => {
|
|
1752
|
+
throw new Error("Cursor not stopped");
|
|
1753
|
+
};
|
|
1754
|
+
_.trans = d, _.stop = _.continue = _.continuePrimaryKey = _.advance = () => {
|
|
1755
|
+
throw new Error("Cursor not started");
|
|
1756
|
+
}, _.fail = I(m), _.next = function() {
|
|
1757
|
+
let M = 1;
|
|
1758
|
+
return this.start(() => M-- ? this.continue() : this.stop()).then(() => this);
|
|
1759
|
+
}, _.start = (M) => {
|
|
1760
|
+
const ve = new Promise((V, ue) => {
|
|
1761
|
+
V = I(V), v.onerror = Q(ue), _.fail = ue, _.stop = (Ae) => {
|
|
1762
|
+
_.stop = _.continue = _.continuePrimaryKey = _.advance = N, V(Ae);
|
|
1763
|
+
};
|
|
1764
|
+
}), we = () => {
|
|
1765
|
+
if (v.result)
|
|
1766
|
+
try {
|
|
1767
|
+
M();
|
|
1768
|
+
} catch (V) {
|
|
1769
|
+
_.fail(V);
|
|
1770
|
+
}
|
|
1771
|
+
else
|
|
1772
|
+
_.done = !0, _.start = () => {
|
|
1773
|
+
throw new Error("Cursor behind last entry");
|
|
1774
|
+
}, _.stop();
|
|
1775
|
+
};
|
|
1776
|
+
return v.onsuccess = I((V) => {
|
|
1777
|
+
v.onsuccess = we, we();
|
|
1778
|
+
}), _.continue = T, _.continuePrimaryKey = K, _.advance = U, we(), ve;
|
|
1779
|
+
}, b(_);
|
|
1780
|
+
}, m);
|
|
1781
|
+
});
|
|
1782
|
+
}, count({ query: d, trans: h }) {
|
|
1783
|
+
const { index: p, range: g } = d;
|
|
1784
|
+
return new Promise((y, b) => {
|
|
1785
|
+
const m = h.objectStore(u), f = p.isPrimaryKey ? m : m.index(p.name), w = r(g), S = w ? f.count(w) : f.count();
|
|
1786
|
+
S.onsuccess = I((P) => y(P.target.result)), S.onerror = Q(b);
|
|
1787
|
+
});
|
|
1788
|
+
} };
|
|
1789
|
+
}(c)), a = {};
|
|
1790
|
+
return o.forEach((c) => a[c.name] = c), { stack: "dbcore", transaction: t.transaction.bind(t), table(c) {
|
|
1791
|
+
if (!a[c])
|
|
1792
|
+
throw new Error(`Table '${c}' not found`);
|
|
1793
|
+
return a[c];
|
|
1794
|
+
}, MIN_KEY: -1 / 0, MAX_KEY: Ve(e), schema: s };
|
|
1795
|
+
}
|
|
1796
|
+
function Qt({ _novip: t }, e) {
|
|
1797
|
+
const n = e.db, r = function(s, i, { IDBKeyRange: o, indexedDB: a }, c) {
|
|
1798
|
+
return { dbcore: function(u, d) {
|
|
1799
|
+
return d.reduce((h, { create: p }) => ({ ...h, ...p(h) }), u);
|
|
1800
|
+
}(Yr(i, o, c), s.dbcore) };
|
|
1801
|
+
}(t._middlewares, n, t._deps, e);
|
|
1802
|
+
t.core = r.dbcore, t.tables.forEach((s) => {
|
|
1803
|
+
const i = s.name;
|
|
1804
|
+
t.core.schema.tables.some((o) => o.name === i) && (s.core = t.core.table(i), t[i] instanceof t.Table && (t[i].core = s.core));
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
function gt({ _novip: t }, e, n, r) {
|
|
1808
|
+
n.forEach((s) => {
|
|
1809
|
+
const i = r[s];
|
|
1810
|
+
e.forEach((o) => {
|
|
1811
|
+
const a = sn(o, s);
|
|
1812
|
+
(!a || "value" in a && a.value === void 0) && (o === t.Transaction.prototype || o instanceof t.Transaction ? te(o, s, { get() {
|
|
1813
|
+
return this.table(s);
|
|
1814
|
+
}, set(c) {
|
|
1815
|
+
An(this, s, { value: c, writable: !0, configurable: !0, enumerable: !0 });
|
|
1816
|
+
} }) : o[s] = new t.Table(s, i));
|
|
1817
|
+
});
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
function Jt({ _novip: t }, e) {
|
|
1821
|
+
e.forEach((n) => {
|
|
1822
|
+
for (let r in n)
|
|
1823
|
+
n[r] instanceof t.Table && delete n[r];
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
function Qr(t, e) {
|
|
1827
|
+
return t._cfg.version - e._cfg.version;
|
|
1828
|
+
}
|
|
1829
|
+
function Jr(t, e, n, r) {
|
|
1830
|
+
const s = t._dbSchema, i = t._createTransaction("readwrite", t._storeNames, s);
|
|
1831
|
+
i.create(n), i._completion.catch(r);
|
|
1832
|
+
const o = i._reject.bind(i), a = O.transless || O;
|
|
1833
|
+
ae(() => {
|
|
1834
|
+
O.trans = i, O.transless = a, e === 0 ? (R(s).forEach((c) => {
|
|
1835
|
+
Ct(n, c, s[c].primKey, s[c].indexes);
|
|
1836
|
+
}), Qt(t, n), E.follow(() => t.on.populate.fire(i)).catch(o)) : function({ _novip: c }, l, u, d) {
|
|
1837
|
+
const h = [], p = c._versions;
|
|
1838
|
+
let g = c._dbSchema = Zt(c, c.idbdb, d), y = !1;
|
|
1839
|
+
const b = p.filter((f) => f._cfg.version >= l);
|
|
1840
|
+
function m() {
|
|
1841
|
+
return h.length ? E.resolve(h.shift()(u.idbtrans)).then(m) : E.resolve();
|
|
1842
|
+
}
|
|
1843
|
+
return b.forEach((f) => {
|
|
1844
|
+
h.push(() => {
|
|
1845
|
+
const w = g, S = f._cfg.dbschema;
|
|
1846
|
+
qt(c, w, d), qt(c, S, d), g = c._dbSchema = S;
|
|
1847
|
+
const P = sr(w, S);
|
|
1848
|
+
P.add.forEach((v) => {
|
|
1849
|
+
Ct(d, v[0], v[1].primKey, v[1].indexes);
|
|
1850
|
+
}), P.change.forEach((v) => {
|
|
1851
|
+
if (v.recreate)
|
|
1852
|
+
throw new C.Upgrade("Not yet support for changing primary key");
|
|
1853
|
+
{
|
|
1854
|
+
const j = d.objectStore(v.name);
|
|
1855
|
+
v.add.forEach((_) => Xt(j, _)), v.change.forEach((_) => {
|
|
1856
|
+
j.deleteIndex(_.name), Xt(j, _);
|
|
1857
|
+
}), v.del.forEach((_) => j.deleteIndex(_));
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1860
|
+
const x = f._cfg.contentUpgrade;
|
|
1861
|
+
if (x && f._cfg.version > l) {
|
|
1862
|
+
Qt(c, d), u._memoizedTables = {}, y = !0;
|
|
1863
|
+
let v = Tn(S);
|
|
1864
|
+
P.del.forEach((K) => {
|
|
1865
|
+
v[K] = w[K];
|
|
1866
|
+
}), Jt(c, [c.Transaction.prototype]), gt(c, [c.Transaction.prototype], R(v), v), u.schema = v;
|
|
1867
|
+
const j = on(x);
|
|
1868
|
+
let _;
|
|
1869
|
+
j && je();
|
|
1870
|
+
const T = E.follow(() => {
|
|
1871
|
+
if (_ = x(u), _ && j) {
|
|
1872
|
+
var K = re.bind(null, null);
|
|
1873
|
+
_.then(K, K);
|
|
1874
|
+
}
|
|
1875
|
+
});
|
|
1876
|
+
return _ && typeof _.then == "function" ? E.resolve(_) : T.then(() => _);
|
|
1877
|
+
}
|
|
1878
|
+
}), h.push((w) => {
|
|
1879
|
+
(!y || !Nr) && function(S, P) {
|
|
1880
|
+
[].slice.call(P.db.objectStoreNames).forEach((x) => S[x] == null && P.db.deleteObjectStore(x));
|
|
1881
|
+
}(f._cfg.dbschema, w), Jt(c, [c.Transaction.prototype]), gt(c, [c.Transaction.prototype], c._storeNames, c._dbSchema), u.schema = c._dbSchema;
|
|
1882
|
+
});
|
|
1883
|
+
}), m().then(() => {
|
|
1884
|
+
var f, w;
|
|
1885
|
+
w = d, R(f = g).forEach((S) => {
|
|
1886
|
+
w.db.objectStoreNames.contains(S) || Ct(w, S, f[S].primKey, f[S].indexes);
|
|
1887
|
+
});
|
|
1888
|
+
});
|
|
1889
|
+
}(t, e, i, n).catch(o);
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
function sr(t, e) {
|
|
1893
|
+
const n = { del: [], add: [], change: [] };
|
|
1894
|
+
let r;
|
|
1895
|
+
for (r in t)
|
|
1896
|
+
e[r] || n.del.push(r);
|
|
1897
|
+
for (r in e) {
|
|
1898
|
+
const s = t[r], i = e[r];
|
|
1899
|
+
if (s) {
|
|
1900
|
+
const o = { name: r, def: i, recreate: !1, del: [], add: [], change: [] };
|
|
1901
|
+
if ("" + (s.primKey.keyPath || "") != "" + (i.primKey.keyPath || "") || s.primKey.auto !== i.primKey.auto && !vt)
|
|
1902
|
+
o.recreate = !0, n.change.push(o);
|
|
1903
|
+
else {
|
|
1904
|
+
const a = s.idxByName, c = i.idxByName;
|
|
1905
|
+
let l;
|
|
1906
|
+
for (l in a)
|
|
1907
|
+
c[l] || o.del.push(l);
|
|
1908
|
+
for (l in c) {
|
|
1909
|
+
const u = a[l], d = c[l];
|
|
1910
|
+
u ? u.src !== d.src && o.change.push(d) : o.add.push(d);
|
|
1911
|
+
}
|
|
1912
|
+
(o.del.length > 0 || o.add.length > 0 || o.change.length > 0) && n.change.push(o);
|
|
1913
|
+
}
|
|
1914
|
+
} else
|
|
1915
|
+
n.add.push([r, i]);
|
|
1916
|
+
}
|
|
1917
|
+
return n;
|
|
1918
|
+
}
|
|
1919
|
+
function Ct(t, e, n, r) {
|
|
1920
|
+
const s = t.db.createObjectStore(e, n.keyPath ? { keyPath: n.keyPath, autoIncrement: n.auto } : { autoIncrement: n.auto });
|
|
1921
|
+
return r.forEach((i) => Xt(s, i)), s;
|
|
1922
|
+
}
|
|
1923
|
+
function Xt(t, e) {
|
|
1924
|
+
t.createIndex(e.name, e.keyPath, { unique: e.unique, multiEntry: e.multi });
|
|
1925
|
+
}
|
|
1926
|
+
function Zt(t, e, n) {
|
|
1927
|
+
const r = {};
|
|
1928
|
+
return ht(e.objectStoreNames, 0).forEach((s) => {
|
|
1929
|
+
const i = n.objectStore(s);
|
|
1930
|
+
let o = i.keyPath;
|
|
1931
|
+
const a = Ht(nr(o), o || "", !1, !1, !!i.autoIncrement, o && typeof o != "string", !0), c = [];
|
|
1932
|
+
for (let u = 0; u < i.indexNames.length; ++u) {
|
|
1933
|
+
const d = i.index(i.indexNames[u]);
|
|
1934
|
+
o = d.keyPath;
|
|
1935
|
+
var l = Ht(d.name, o, !!d.unique, !!d.multiEntry, !1, o && typeof o != "string", !1);
|
|
1936
|
+
c.push(l);
|
|
1937
|
+
}
|
|
1938
|
+
r[s] = rr(s, a, c);
|
|
1939
|
+
}), r;
|
|
1940
|
+
}
|
|
1941
|
+
function qt({ _novip: t }, e, n) {
|
|
1942
|
+
const r = n.db.objectStoreNames;
|
|
1943
|
+
for (let s = 0; s < r.length; ++s) {
|
|
1944
|
+
const i = r[s], o = n.objectStore(i);
|
|
1945
|
+
t._hasGetAll = "getAll" in o;
|
|
1946
|
+
for (let a = 0; a < o.indexNames.length; ++a) {
|
|
1947
|
+
const c = o.indexNames[a], l = o.index(c).keyPath, u = typeof l == "string" ? l : "[" + ht(l).join("+") + "]";
|
|
1948
|
+
if (e[i]) {
|
|
1949
|
+
const d = e[i].idxByName[u];
|
|
1950
|
+
d && (d.name = c, delete e[i].idxByName[u], e[i].idxByName[c] = d);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && D.WorkerGlobalScope && D instanceof D.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (t._hasGetAll = !1);
|
|
1955
|
+
}
|
|
1956
|
+
class Xr {
|
|
1957
|
+
_parseStoresSpec(e, n) {
|
|
1958
|
+
R(e).forEach((r) => {
|
|
1959
|
+
if (e[r] !== null) {
|
|
1960
|
+
var s = e[r].split(",").map((o, a) => {
|
|
1961
|
+
const c = (o = o.trim()).replace(/([&*]|\+\+)/g, ""), l = /^\[/.test(c) ? c.match(/^\[(.*)\]$/)[1].split("+") : c;
|
|
1962
|
+
return Ht(c, l || null, /\&/.test(o), /\*/.test(o), /\+\+/.test(o), L(l), a === 0);
|
|
1963
|
+
}), i = s.shift();
|
|
1964
|
+
if (i.multi)
|
|
1965
|
+
throw new C.Schema("Primary key cannot be multi-valued");
|
|
1966
|
+
s.forEach((o) => {
|
|
1967
|
+
if (o.auto)
|
|
1968
|
+
throw new C.Schema("Only primary key can be marked as autoIncrement (++)");
|
|
1969
|
+
if (!o.keyPath)
|
|
1970
|
+
throw new C.Schema("Index must have a name and cannot be an empty string");
|
|
1971
|
+
}), n[r] = rr(r, i, s);
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
stores(e) {
|
|
1976
|
+
const n = this.db;
|
|
1977
|
+
this._cfg.storesSource = this._cfg.storesSource ? z(this._cfg.storesSource, e) : e;
|
|
1978
|
+
const r = n._versions, s = {};
|
|
1979
|
+
let i = {};
|
|
1980
|
+
return r.forEach((o) => {
|
|
1981
|
+
z(s, o._cfg.storesSource), i = o._cfg.dbschema = {}, o._parseStoresSpec(s, i);
|
|
1982
|
+
}), n._dbSchema = i, Jt(n, [n._allTables, n, n.Transaction.prototype]), gt(n, [n._allTables, n, n.Transaction.prototype, this._cfg.tables], R(i), i), n._storeNames = R(i), this;
|
|
1983
|
+
}
|
|
1984
|
+
upgrade(e) {
|
|
1985
|
+
return this._cfg.contentUpgrade = ln(this._cfg.contentUpgrade || A, e), this;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
function fn(t, e) {
|
|
1989
|
+
let n = t._dbNamesDB;
|
|
1990
|
+
return n || (n = t._dbNamesDB = new me(wt, { addons: [], indexedDB: t, IDBKeyRange: e }), n.version(1).stores({ dbnames: "name" })), n.table("dbnames");
|
|
1991
|
+
}
|
|
1992
|
+
function pn(t) {
|
|
1993
|
+
return t && typeof t.databases == "function";
|
|
1994
|
+
}
|
|
1995
|
+
function en(t) {
|
|
1996
|
+
return ae(function() {
|
|
1997
|
+
return O.letThrough = !0, t();
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
function Zr() {
|
|
2001
|
+
var t;
|
|
2002
|
+
return !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
|
|
2003
|
+
var n = function() {
|
|
2004
|
+
return indexedDB.databases().finally(e);
|
|
2005
|
+
};
|
|
2006
|
+
t = setInterval(n, 100), n();
|
|
2007
|
+
}).finally(function() {
|
|
2008
|
+
return clearInterval(t);
|
|
2009
|
+
}) : Promise.resolve();
|
|
2010
|
+
}
|
|
2011
|
+
function qr(t) {
|
|
2012
|
+
const e = t._state, { indexedDB: n } = t._deps;
|
|
2013
|
+
if (e.isBeingOpened || t.idbdb)
|
|
2014
|
+
return e.dbReadyPromise.then(() => e.dbOpenError ? F(e.dbOpenError) : t);
|
|
2015
|
+
J && (e.openCanceller._stackHolder = be()), e.isBeingOpened = !0, e.dbOpenError = null, e.openComplete = !1;
|
|
2016
|
+
const r = e.openCanceller;
|
|
2017
|
+
function s() {
|
|
2018
|
+
if (e.openCanceller !== r)
|
|
2019
|
+
throw new C.DatabaseClosed("db.open() was cancelled");
|
|
2020
|
+
}
|
|
2021
|
+
let i = e.dbReadyResolve, o = null, a = !1;
|
|
2022
|
+
const c = () => new E((l, u) => {
|
|
2023
|
+
if (s(), !n)
|
|
2024
|
+
throw new C.MissingAPI();
|
|
2025
|
+
const d = t.name, h = e.autoSchema ? n.open(d) : n.open(d, Math.round(10 * t.verno));
|
|
2026
|
+
if (!h)
|
|
2027
|
+
throw new C.MissingAPI();
|
|
2028
|
+
h.onerror = Q(u), h.onblocked = I(t._fireOnBlocked), h.onupgradeneeded = I((p) => {
|
|
2029
|
+
if (o = h.transaction, e.autoSchema && !t._options.allowEmptyDB) {
|
|
2030
|
+
h.onerror = We, o.abort(), h.result.close();
|
|
2031
|
+
const y = n.deleteDatabase(d);
|
|
2032
|
+
y.onsuccess = y.onerror = I(() => {
|
|
2033
|
+
u(new C.NoSuchDatabase(`Database ${d} doesnt exist`));
|
|
2034
|
+
});
|
|
2035
|
+
} else {
|
|
2036
|
+
o.onerror = Q(u);
|
|
2037
|
+
var g = p.oldVersion > Math.pow(2, 62) ? 0 : p.oldVersion;
|
|
2038
|
+
a = g < 1, t._novip.idbdb = h.result, Jr(t, g / 10, o, u);
|
|
2039
|
+
}
|
|
2040
|
+
}, u), h.onsuccess = I(() => {
|
|
2041
|
+
o = null;
|
|
2042
|
+
const p = t._novip.idbdb = h.result, g = ht(p.objectStoreNames);
|
|
2043
|
+
if (g.length > 0)
|
|
2044
|
+
try {
|
|
2045
|
+
const b = p.transaction((y = g).length === 1 ? y[0] : y, "readonly");
|
|
2046
|
+
e.autoSchema ? function({ _novip: m }, f, w) {
|
|
2047
|
+
m.verno = f.version / 10;
|
|
2048
|
+
const S = m._dbSchema = Zt(0, f, w);
|
|
2049
|
+
m._storeNames = ht(f.objectStoreNames, 0), gt(m, [m._allTables], R(S), S);
|
|
2050
|
+
}(t, p, b) : (qt(t, t._dbSchema, b), function(m, f) {
|
|
2051
|
+
const w = sr(Zt(0, m.idbdb, f), m._dbSchema);
|
|
2052
|
+
return !(w.add.length || w.change.some((S) => S.add.length || S.change.length));
|
|
2053
|
+
}(t, b) || console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")), Qt(t, b);
|
|
2054
|
+
} catch {
|
|
2055
|
+
}
|
|
2056
|
+
var y;
|
|
2057
|
+
Re.push(t), p.onversionchange = I((b) => {
|
|
2058
|
+
e.vcFired = !0, t.on("versionchange").fire(b);
|
|
2059
|
+
}), p.onclose = I((b) => {
|
|
2060
|
+
t.on("close").fire(b);
|
|
2061
|
+
}), a && function({ indexedDB: b, IDBKeyRange: m }, f) {
|
|
2062
|
+
!pn(b) && f !== wt && fn(b, m).put({ name: f }).catch(A);
|
|
2063
|
+
}(t._deps, d), l();
|
|
2064
|
+
}, u);
|
|
2065
|
+
}).catch((l) => l && l.name === "UnknownError" && e.PR1398_maxLoop > 0 ? (e.PR1398_maxLoop--, console.warn("Dexie: Workaround for Chrome UnknownError on open()"), c()) : E.reject(l));
|
|
2066
|
+
return E.race([r, (typeof navigator > "u" ? E.resolve() : Zr()).then(c)]).then(() => (s(), e.onReadyBeingFired = [], E.resolve(en(() => t.on.ready.fire(t.vip))).then(function l() {
|
|
2067
|
+
if (e.onReadyBeingFired.length > 0) {
|
|
2068
|
+
let u = e.onReadyBeingFired.reduce(ln, A);
|
|
2069
|
+
return e.onReadyBeingFired = [], E.resolve(en(() => u(t.vip))).then(l);
|
|
2070
|
+
}
|
|
2071
|
+
}))).finally(() => {
|
|
2072
|
+
e.onReadyBeingFired = null, e.isBeingOpened = !1;
|
|
2073
|
+
}).then(() => t).catch((l) => {
|
|
2074
|
+
e.dbOpenError = l;
|
|
2075
|
+
try {
|
|
2076
|
+
o && o.abort();
|
|
2077
|
+
} catch {
|
|
2078
|
+
}
|
|
2079
|
+
return r === e.openCanceller && t._close(), F(l);
|
|
2080
|
+
}).finally(() => {
|
|
2081
|
+
e.openComplete = !0, i();
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
function tn(t) {
|
|
2085
|
+
var e = (i) => t.next(i), n = s(e), r = s((i) => t.throw(i));
|
|
2086
|
+
function s(i) {
|
|
2087
|
+
return (o) => {
|
|
2088
|
+
var a = i(o), c = a.value;
|
|
2089
|
+
return a.done ? c : c && typeof c.then == "function" ? c.then(n, r) : L(c) ? Promise.all(c).then(n, r) : n(c);
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
return s(e)();
|
|
2093
|
+
}
|
|
2094
|
+
function es(t, e, n) {
|
|
2095
|
+
var r = arguments.length;
|
|
2096
|
+
if (r < 2)
|
|
2097
|
+
throw new C.InvalidArgument("Too few arguments");
|
|
2098
|
+
for (var s = new Array(r - 1); --r; )
|
|
2099
|
+
s[r - 1] = arguments[r];
|
|
2100
|
+
return n = s.pop(), [t, Mn(s), n];
|
|
2101
|
+
}
|
|
2102
|
+
function ir(t, e, n, r, s) {
|
|
2103
|
+
return E.resolve().then(() => {
|
|
2104
|
+
const i = O.transless || O, o = t._createTransaction(e, n, t._dbSchema, r), a = { trans: o, transless: i };
|
|
2105
|
+
if (r)
|
|
2106
|
+
o.idbtrans = r.idbtrans;
|
|
2107
|
+
else
|
|
2108
|
+
try {
|
|
2109
|
+
o.create(), t._state.PR1398_maxLoop = 3;
|
|
2110
|
+
} catch (d) {
|
|
2111
|
+
return d.name === cn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => ir(t, e, n, null, s))) : F(d);
|
|
2112
|
+
}
|
|
2113
|
+
const c = on(s);
|
|
2114
|
+
let l;
|
|
2115
|
+
c && je();
|
|
2116
|
+
const u = E.follow(() => {
|
|
2117
|
+
if (l = s.call(o, o), l)
|
|
2118
|
+
if (c) {
|
|
2119
|
+
var d = re.bind(null, null);
|
|
2120
|
+
l.then(d, d);
|
|
2121
|
+
} else
|
|
2122
|
+
typeof l.next == "function" && typeof l.throw == "function" && (l = tn(l));
|
|
2123
|
+
}, a);
|
|
2124
|
+
return (l && typeof l.then == "function" ? E.resolve(l).then((d) => o.active ? d : F(new C.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))) : u.then(() => l)).then((d) => (r && o._resolve(), o._completion.then(() => d))).catch((d) => (o._reject(d), F(d)));
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
function rt(t, e, n) {
|
|
2128
|
+
const r = L(t) ? t.slice() : [t];
|
|
2129
|
+
for (let s = 0; s < n; ++s)
|
|
2130
|
+
r.push(e);
|
|
2131
|
+
return r;
|
|
2132
|
+
}
|
|
2133
|
+
const ts = { stack: "dbcore", name: "VirtualIndexMiddleware", level: 1, create: function(t) {
|
|
2134
|
+
return { ...t, table(e) {
|
|
2135
|
+
const n = t.table(e), { schema: r } = n, s = {}, i = [];
|
|
2136
|
+
function o(u, d, h) {
|
|
2137
|
+
const p = Ne(u), g = s[p] = s[p] || [], y = u == null ? 0 : typeof u == "string" ? 1 : u.length, b = d > 0, m = { ...h, isVirtual: b, keyTail: d, keyLength: y, extractKey: Yt(u), unique: !b && h.unique };
|
|
2138
|
+
return g.push(m), m.isPrimaryKey || i.push(m), y > 1 && o(y === 2 ? u[0] : u.slice(0, y - 1), d + 1, h), g.sort((f, w) => f.keyTail - w.keyTail), m;
|
|
2139
|
+
}
|
|
2140
|
+
const a = o(r.primaryKey.keyPath, 0, r.primaryKey);
|
|
2141
|
+
s[":id"] = [a];
|
|
2142
|
+
for (const u of r.indexes)
|
|
2143
|
+
o(u.keyPath, 0, u);
|
|
2144
|
+
function c(u) {
|
|
2145
|
+
const d = u.query.index;
|
|
2146
|
+
return d.isVirtual ? { ...u, query: { index: d, range: (h = u.query.range, p = d.keyTail, { type: h.type === 1 ? 2 : h.type, lower: rt(h.lower, h.lowerOpen ? t.MAX_KEY : t.MIN_KEY, p), lowerOpen: !0, upper: rt(h.upper, h.upperOpen ? t.MIN_KEY : t.MAX_KEY, p), upperOpen: !0 }) } } : u;
|
|
2147
|
+
var h, p;
|
|
2148
|
+
}
|
|
2149
|
+
return { ...n, schema: { ...r, primaryKey: a, indexes: i, getIndexByKeyPath: function(u) {
|
|
2150
|
+
const d = s[Ne(u)];
|
|
2151
|
+
return d && d[0];
|
|
2152
|
+
} }, count: (u) => n.count(c(u)), query: (u) => n.query(c(u)), openCursor(u) {
|
|
2153
|
+
const { keyTail: d, isVirtual: h, keyLength: p } = u.query.index;
|
|
2154
|
+
return h ? n.openCursor(c(u)).then((g) => g && function(y) {
|
|
2155
|
+
return Object.create(y, { continue: { value: function(m) {
|
|
2156
|
+
m != null ? y.continue(rt(m, u.reverse ? t.MAX_KEY : t.MIN_KEY, d)) : u.unique ? y.continue(y.key.slice(0, p).concat(u.reverse ? t.MIN_KEY : t.MAX_KEY, d)) : y.continue();
|
|
2157
|
+
} }, continuePrimaryKey: { value(m, f) {
|
|
2158
|
+
y.continuePrimaryKey(rt(m, t.MAX_KEY, d), f);
|
|
2159
|
+
} }, primaryKey: { get: () => y.primaryKey }, key: { get() {
|
|
2160
|
+
const m = y.key;
|
|
2161
|
+
return p === 1 ? m[0] : m.slice(0, p);
|
|
2162
|
+
} }, value: { get: () => y.value } });
|
|
2163
|
+
}(g)) : n.openCursor(u);
|
|
2164
|
+
} };
|
|
2165
|
+
} };
|
|
2166
|
+
} };
|
|
2167
|
+
function mn(t, e, n, r) {
|
|
2168
|
+
return n = n || {}, r = r || "", R(t).forEach((s) => {
|
|
2169
|
+
if (H(e, s)) {
|
|
2170
|
+
var i = t[s], o = e[s];
|
|
2171
|
+
if (typeof i == "object" && typeof o == "object" && i && o) {
|
|
2172
|
+
const a = Bt(i);
|
|
2173
|
+
a !== Bt(o) ? n[r + s] = e[s] : a === "Object" ? mn(i, o, n, r + s + ".") : i !== o && (n[r + s] = e[s]);
|
|
2174
|
+
} else
|
|
2175
|
+
i !== o && (n[r + s] = e[s]);
|
|
2176
|
+
} else
|
|
2177
|
+
n[r + s] = void 0;
|
|
2178
|
+
}), R(e).forEach((s) => {
|
|
2179
|
+
H(t, s) || (n[r + s] = e[s]);
|
|
2180
|
+
}), n;
|
|
2181
|
+
}
|
|
2182
|
+
const ns = { stack: "dbcore", name: "HooksMiddleware", level: 2, create: (t) => ({ ...t, table(e) {
|
|
2183
|
+
const n = t.table(e), { primaryKey: r } = n.schema;
|
|
2184
|
+
return { ...n, mutate(i) {
|
|
2185
|
+
const o = O.trans, { deleting: a, creating: c, updating: l } = o.table(e).hook;
|
|
2186
|
+
switch (i.type) {
|
|
2187
|
+
case "add":
|
|
2188
|
+
if (c.fire === A)
|
|
2189
|
+
break;
|
|
2190
|
+
return o._promise("readwrite", () => u(i), !0);
|
|
2191
|
+
case "put":
|
|
2192
|
+
if (c.fire === A && l.fire === A)
|
|
2193
|
+
break;
|
|
2194
|
+
return o._promise("readwrite", () => u(i), !0);
|
|
2195
|
+
case "delete":
|
|
2196
|
+
if (a.fire === A)
|
|
2197
|
+
break;
|
|
2198
|
+
return o._promise("readwrite", () => u(i), !0);
|
|
2199
|
+
case "deleteRange":
|
|
2200
|
+
if (a.fire === A)
|
|
2201
|
+
break;
|
|
2202
|
+
return o._promise("readwrite", () => function(h) {
|
|
2203
|
+
return d(h.trans, h.range, 1e4);
|
|
2204
|
+
}(i), !0);
|
|
2205
|
+
}
|
|
2206
|
+
return n.mutate(i);
|
|
2207
|
+
function u(h) {
|
|
2208
|
+
const p = O.trans, g = h.keys || function(y, b) {
|
|
2209
|
+
return b.type === "delete" ? b.keys : b.keys || b.values.map(y.extractKey);
|
|
2210
|
+
}(r, h);
|
|
2211
|
+
if (!g)
|
|
2212
|
+
throw new Error("Keys missing");
|
|
2213
|
+
return (h = h.type === "add" || h.type === "put" ? { ...h, keys: g } : { ...h }).type !== "delete" && (h.values = [...h.values]), h.keys && (h.keys = [...h.keys]), function(y, b, m) {
|
|
2214
|
+
return b.type === "add" ? Promise.resolve([]) : y.getMany({ trans: b.trans, keys: m, cache: "immutable" });
|
|
2215
|
+
}(n, h, g).then((y) => {
|
|
2216
|
+
const b = g.map((m, f) => {
|
|
2217
|
+
const w = y[f], S = { onerror: null, onsuccess: null };
|
|
2218
|
+
if (h.type === "delete")
|
|
2219
|
+
a.fire.call(S, m, w, p);
|
|
2220
|
+
else if (h.type === "add" || w === void 0) {
|
|
2221
|
+
const P = c.fire.call(S, m, h.values[f], p);
|
|
2222
|
+
m == null && P != null && (m = P, h.keys[f] = m, r.outbound || Y(h.values[f], r.keyPath, m));
|
|
2223
|
+
} else {
|
|
2224
|
+
const P = mn(w, h.values[f]), x = l.fire.call(S, P, m, w, p);
|
|
2225
|
+
if (x) {
|
|
2226
|
+
const v = h.values[f];
|
|
2227
|
+
Object.keys(x).forEach((j) => {
|
|
2228
|
+
H(v, j) ? v[j] = x[j] : Y(v, j, x[j]);
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
return S;
|
|
2233
|
+
});
|
|
2234
|
+
return n.mutate(h).then(({ failures: m, results: f, numFailures: w, lastResult: S }) => {
|
|
2235
|
+
for (let P = 0; P < g.length; ++P) {
|
|
2236
|
+
const x = f ? f[P] : g[P], v = b[P];
|
|
2237
|
+
x == null ? v.onerror && v.onerror(m[P]) : v.onsuccess && v.onsuccess(h.type === "put" && y[P] ? h.values[P] : x);
|
|
2238
|
+
}
|
|
2239
|
+
return { failures: m, results: f, numFailures: w, lastResult: S };
|
|
2240
|
+
}).catch((m) => (b.forEach((f) => f.onerror && f.onerror(m)), Promise.reject(m)));
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
function d(h, p, g) {
|
|
2244
|
+
return n.query({ trans: h, values: !1, query: { index: r, range: p }, limit: g }).then(({ result: y }) => u({ type: "delete", keys: y, trans: h }).then((b) => b.numFailures > 0 ? Promise.reject(b.failures[0]) : y.length < g ? { failures: [], numFailures: 0, lastResult: void 0 } : d(h, { ...p, lower: y[y.length - 1], lowerOpen: !0 }, g)));
|
|
2245
|
+
}
|
|
2246
|
+
} };
|
|
2247
|
+
} }) };
|
|
2248
|
+
function or(t, e, n) {
|
|
2249
|
+
try {
|
|
2250
|
+
if (!e || e.keys.length < t.length)
|
|
2251
|
+
return null;
|
|
2252
|
+
const r = [];
|
|
2253
|
+
for (let s = 0, i = 0; s < e.keys.length && i < t.length; ++s)
|
|
2254
|
+
W(e.keys[s], t[i]) === 0 && (r.push(n ? He(e.values[s]) : e.values[s]), ++i);
|
|
2255
|
+
return r.length === t.length ? r : null;
|
|
2256
|
+
} catch {
|
|
2257
|
+
return null;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
const rs = { stack: "dbcore", level: -1, create: (t) => ({ table: (e) => {
|
|
2261
|
+
const n = t.table(e);
|
|
2262
|
+
return { ...n, getMany: (r) => {
|
|
2263
|
+
if (!r.cache)
|
|
2264
|
+
return n.getMany(r);
|
|
2265
|
+
const s = or(r.keys, r.trans._cache, r.cache === "clone");
|
|
2266
|
+
return s ? E.resolve(s) : n.getMany(r).then((i) => (r.trans._cache = { keys: r.keys, values: r.cache === "clone" ? He(i) : i }, i));
|
|
2267
|
+
}, mutate: (r) => (r.type !== "add" && (r.trans._cache = null), n.mutate(r)) };
|
|
2268
|
+
} }) };
|
|
2269
|
+
function yn(t) {
|
|
2270
|
+
return !("from" in t);
|
|
2271
|
+
}
|
|
2272
|
+
const Z = function(t, e) {
|
|
2273
|
+
if (!this) {
|
|
2274
|
+
const n = new Z();
|
|
2275
|
+
return t && "d" in t && z(n, t), n;
|
|
2276
|
+
}
|
|
2277
|
+
z(this, arguments.length ? { d: 1, from: t, to: arguments.length > 1 ? e : t } : { d: 0 });
|
|
2278
|
+
};
|
|
2279
|
+
function Ge(t, e, n) {
|
|
2280
|
+
const r = W(e, n);
|
|
2281
|
+
if (isNaN(r))
|
|
2282
|
+
return;
|
|
2283
|
+
if (r > 0)
|
|
2284
|
+
throw RangeError();
|
|
2285
|
+
if (yn(t))
|
|
2286
|
+
return z(t, { from: e, to: n, d: 1 });
|
|
2287
|
+
const s = t.l, i = t.r;
|
|
2288
|
+
if (W(n, t.from) < 0)
|
|
2289
|
+
return s ? Ge(s, e, n) : t.l = { from: e, to: n, d: 1, l: null, r: null }, Cn(t);
|
|
2290
|
+
if (W(e, t.to) > 0)
|
|
2291
|
+
return i ? Ge(i, e, n) : t.r = { from: e, to: n, d: 1, l: null, r: null }, Cn(t);
|
|
2292
|
+
W(e, t.from) < 0 && (t.from = e, t.l = null, t.d = i ? i.d + 1 : 1), W(n, t.to) > 0 && (t.to = n, t.r = null, t.d = t.l ? t.l.d + 1 : 1);
|
|
2293
|
+
const o = !t.r;
|
|
2294
|
+
s && !t.l && bt(t, s), i && o && bt(t, i);
|
|
2295
|
+
}
|
|
2296
|
+
function bt(t, e) {
|
|
2297
|
+
yn(e) || function n(r, { from: s, to: i, l: o, r: a }) {
|
|
2298
|
+
Ge(r, s, i), o && n(r, o), a && n(r, a);
|
|
2299
|
+
}(t, e);
|
|
2300
|
+
}
|
|
2301
|
+
function ss(t, e) {
|
|
2302
|
+
const n = nn(e);
|
|
2303
|
+
let r = n.next();
|
|
2304
|
+
if (r.done)
|
|
2305
|
+
return !1;
|
|
2306
|
+
let s = r.value;
|
|
2307
|
+
const i = nn(t);
|
|
2308
|
+
let o = i.next(s.from), a = o.value;
|
|
2309
|
+
for (; !r.done && !o.done; ) {
|
|
2310
|
+
if (W(a.from, s.to) <= 0 && W(a.to, s.from) >= 0)
|
|
2311
|
+
return !0;
|
|
2312
|
+
W(s.from, a.from) < 0 ? s = (r = n.next(a.from)).value : a = (o = i.next(s.from)).value;
|
|
2313
|
+
}
|
|
2314
|
+
return !1;
|
|
2315
|
+
}
|
|
2316
|
+
function nn(t) {
|
|
2317
|
+
let e = yn(t) ? null : { s: 0, n: t };
|
|
2318
|
+
return { next(n) {
|
|
2319
|
+
const r = arguments.length > 0;
|
|
2320
|
+
for (; e; )
|
|
2321
|
+
switch (e.s) {
|
|
2322
|
+
case 0:
|
|
2323
|
+
if (e.s = 1, r)
|
|
2324
|
+
for (; e.n.l && W(n, e.n.from) < 0; )
|
|
2325
|
+
e = { up: e, n: e.n.l, s: 1 };
|
|
2326
|
+
else
|
|
2327
|
+
for (; e.n.l; )
|
|
2328
|
+
e = { up: e, n: e.n.l, s: 1 };
|
|
2329
|
+
case 1:
|
|
2330
|
+
if (e.s = 2, !r || W(n, e.n.to) <= 0)
|
|
2331
|
+
return { value: e.n, done: !1 };
|
|
2332
|
+
case 2:
|
|
2333
|
+
if (e.n.r) {
|
|
2334
|
+
e.s = 3, e = { up: e, n: e.n.r, s: 0 };
|
|
2335
|
+
continue;
|
|
2336
|
+
}
|
|
2337
|
+
case 3:
|
|
2338
|
+
e = e.up;
|
|
2339
|
+
}
|
|
2340
|
+
return { done: !0 };
|
|
2341
|
+
} };
|
|
2342
|
+
}
|
|
2343
|
+
function Cn(t) {
|
|
2344
|
+
var e, n;
|
|
2345
|
+
const r = (((e = t.r) === null || e === void 0 ? void 0 : e.d) || 0) - (((n = t.l) === null || n === void 0 ? void 0 : n.d) || 0), s = r > 1 ? "r" : r < -1 ? "l" : "";
|
|
2346
|
+
if (s) {
|
|
2347
|
+
const i = s === "r" ? "l" : "r", o = { ...t }, a = t[s];
|
|
2348
|
+
t.from = a.from, t.to = a.to, t[s] = a[s], o[s] = a[i], t[i] = o, o.d = jn(o);
|
|
2349
|
+
}
|
|
2350
|
+
t.d = jn(t);
|
|
2351
|
+
}
|
|
2352
|
+
function jn({ r: t, l: e }) {
|
|
2353
|
+
return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
|
|
2354
|
+
}
|
|
2355
|
+
Ce(Z.prototype, { add(t) {
|
|
2356
|
+
return bt(this, t), this;
|
|
2357
|
+
}, addKey(t) {
|
|
2358
|
+
return Ge(this, t, t), this;
|
|
2359
|
+
}, addKeys(t) {
|
|
2360
|
+
return t.forEach((e) => Ge(this, e, e)), this;
|
|
2361
|
+
}, [Tt]() {
|
|
2362
|
+
return nn(this);
|
|
2363
|
+
} });
|
|
2364
|
+
const is = { stack: "dbcore", level: 0, create: (t) => {
|
|
2365
|
+
const e = t.schema.name, n = new Z(t.MIN_KEY, t.MAX_KEY);
|
|
2366
|
+
return { ...t, table: (r) => {
|
|
2367
|
+
const s = t.table(r), { schema: i } = s, { primaryKey: o } = i, { extractKey: a, outbound: c } = o, l = { ...s, mutate: (h) => {
|
|
2368
|
+
const p = h.trans, g = p.mutatedParts || (p.mutatedParts = {}), y = (x) => {
|
|
2369
|
+
const v = `idb://${e}/${r}/${x}`;
|
|
2370
|
+
return g[v] || (g[v] = new Z());
|
|
2371
|
+
}, b = y(""), m = y(":dels"), { type: f } = h;
|
|
2372
|
+
let [w, S] = h.type === "deleteRange" ? [h.range] : h.type === "delete" ? [h.keys] : h.values.length < 50 ? [[], h.values] : [];
|
|
2373
|
+
const P = h.trans._cache;
|
|
2374
|
+
return s.mutate(h).then((x) => {
|
|
2375
|
+
if (L(w)) {
|
|
2376
|
+
f !== "delete" && (w = x.results), b.addKeys(w);
|
|
2377
|
+
const v = or(w, P);
|
|
2378
|
+
v || f === "add" || m.addKeys(w), (v || S) && function(j, _, T, K) {
|
|
2379
|
+
function U(N) {
|
|
2380
|
+
const M = j(N.name || "");
|
|
2381
|
+
function ve(V) {
|
|
2382
|
+
return V != null ? N.extractKey(V) : null;
|
|
2383
|
+
}
|
|
2384
|
+
const we = (V) => N.multiEntry && L(V) ? V.forEach((ue) => M.addKey(ue)) : M.addKey(V);
|
|
2385
|
+
(T || K).forEach((V, ue) => {
|
|
2386
|
+
const Ae = T && ve(T[ue]), _t = K && ve(K[ue]);
|
|
2387
|
+
W(Ae, _t) !== 0 && (Ae != null && we(Ae), _t != null && we(_t));
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
_.indexes.forEach(U);
|
|
2391
|
+
}(y, i, v, S);
|
|
2392
|
+
} else if (w) {
|
|
2393
|
+
const v = { from: w.lower, to: w.upper };
|
|
2394
|
+
m.add(v), b.add(v);
|
|
2395
|
+
} else
|
|
2396
|
+
b.add(n), m.add(n), i.indexes.forEach((v) => y(v.name).add(n));
|
|
2397
|
+
return x;
|
|
2398
|
+
});
|
|
2399
|
+
} }, u = ({ query: { index: h, range: p } }) => {
|
|
2400
|
+
var g, y;
|
|
2401
|
+
return [h, new Z((g = p.lower) !== null && g !== void 0 ? g : t.MIN_KEY, (y = p.upper) !== null && y !== void 0 ? y : t.MAX_KEY)];
|
|
2402
|
+
}, d = { get: (h) => [o, new Z(h.key)], getMany: (h) => [o, new Z().addKeys(h.keys)], count: u, query: u, openCursor: u };
|
|
2403
|
+
return R(d).forEach((h) => {
|
|
2404
|
+
l[h] = function(p) {
|
|
2405
|
+
const { subscr: g } = O;
|
|
2406
|
+
if (g) {
|
|
2407
|
+
const y = (S) => {
|
|
2408
|
+
const P = `idb://${e}/${r}/${S}`;
|
|
2409
|
+
return g[P] || (g[P] = new Z());
|
|
2410
|
+
}, b = y(""), m = y(":dels"), [f, w] = d[h](p);
|
|
2411
|
+
if (y(f.name || "").add(w), !f.isPrimaryKey) {
|
|
2412
|
+
if (h !== "count") {
|
|
2413
|
+
const S = h === "query" && c && p.values && s.query({ ...p, values: !1 });
|
|
2414
|
+
return s[h].apply(this, arguments).then((P) => {
|
|
2415
|
+
if (h === "query") {
|
|
2416
|
+
if (c && p.values)
|
|
2417
|
+
return S.then(({ result: v }) => (b.addKeys(v), P));
|
|
2418
|
+
const x = p.values ? P.result.map(a) : P.result;
|
|
2419
|
+
p.values ? b.addKeys(x) : m.addKeys(x);
|
|
2420
|
+
} else if (h === "openCursor") {
|
|
2421
|
+
const x = P, v = p.values;
|
|
2422
|
+
return x && Object.create(x, { key: { get: () => (m.addKey(x.primaryKey), x.key) }, primaryKey: { get() {
|
|
2423
|
+
const j = x.primaryKey;
|
|
2424
|
+
return m.addKey(j), j;
|
|
2425
|
+
} }, value: { get: () => (v && b.addKey(x.primaryKey), x.value) } });
|
|
2426
|
+
}
|
|
2427
|
+
return P;
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
m.add(n);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
return s[h].apply(this, arguments);
|
|
2434
|
+
};
|
|
2435
|
+
}), l;
|
|
2436
|
+
} };
|
|
2437
|
+
} };
|
|
2438
|
+
class me {
|
|
2439
|
+
constructor(e, n) {
|
|
2440
|
+
this._middlewares = {}, this.verno = 0;
|
|
2441
|
+
const r = me.dependencies;
|
|
2442
|
+
this._options = n = { addons: me.addons, autoOpen: !0, indexedDB: r.indexedDB, IDBKeyRange: r.IDBKeyRange, ...n }, this._deps = { indexedDB: n.indexedDB, IDBKeyRange: n.IDBKeyRange };
|
|
2443
|
+
const { addons: s } = n;
|
|
2444
|
+
this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this;
|
|
2445
|
+
const i = { dbOpenError: null, isBeingOpened: !1, onReadyBeingFired: null, openComplete: !1, dbReadyResolve: A, dbReadyPromise: null, cancelOpen: A, openCanceller: null, autoSchema: !0, PR1398_maxLoop: 3 };
|
|
2446
|
+
var o;
|
|
2447
|
+
i.dbReadyPromise = new E((a) => {
|
|
2448
|
+
i.dbReadyResolve = a;
|
|
2449
|
+
}), i.openCanceller = new E((a, c) => {
|
|
2450
|
+
i.cancelOpen = c;
|
|
2451
|
+
}), this._state = i, this.name = e, this.on = Fe(this, "populate", "blocked", "versionchange", "close", { ready: [ln, A] }), this.on.ready.subscribe = Dn(this.on.ready.subscribe, (a) => (c, l) => {
|
|
2452
|
+
me.vip(() => {
|
|
2453
|
+
const u = this._state;
|
|
2454
|
+
if (u.openComplete)
|
|
2455
|
+
u.dbOpenError || E.resolve().then(c), l && a(c);
|
|
2456
|
+
else if (u.onReadyBeingFired)
|
|
2457
|
+
u.onReadyBeingFired.push(c), l && a(c);
|
|
2458
|
+
else {
|
|
2459
|
+
a(c);
|
|
2460
|
+
const d = this;
|
|
2461
|
+
l || a(function h() {
|
|
2462
|
+
d.on.ready.unsubscribe(c), d.on.ready.unsubscribe(h);
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
});
|
|
2466
|
+
}), this.Collection = (o = this, De(Ur.prototype, function(a, c) {
|
|
2467
|
+
this.db = o;
|
|
2468
|
+
let l = qn, u = null;
|
|
2469
|
+
if (c)
|
|
2470
|
+
try {
|
|
2471
|
+
l = c();
|
|
2472
|
+
} catch (g) {
|
|
2473
|
+
u = g;
|
|
2474
|
+
}
|
|
2475
|
+
const d = a._ctx, h = d.table, p = h.hook.reading.fire;
|
|
2476
|
+
this._ctx = { table: h, index: d.index, isPrimKey: !d.index || h.schema.primKey.keyPath && d.index === h.schema.primKey.name, range: l, keysOnly: !1, dir: "next", unique: "", algorithm: null, filter: null, replayFilter: null, justLimit: !0, isMatch: null, offset: 0, limit: 1 / 0, error: u, or: d.or, valueMapper: p !== Le ? p : null };
|
|
2477
|
+
})), this.Table = function(a) {
|
|
2478
|
+
return De(Lr.prototype, function(c, l, u) {
|
|
2479
|
+
this.db = a, this._tx = u, this.name = c, this.schema = l, this.hook = a._allTables[c] ? a._allTables[c].hook : Fe(null, { creating: [jr, A], reading: [Cr, Le], updating: [Ar, A], deleting: [Kr, A] });
|
|
2480
|
+
});
|
|
2481
|
+
}(this), this.Transaction = function(a) {
|
|
2482
|
+
return De(Gr.prototype, function(c, l, u, d, h) {
|
|
2483
|
+
this.db = a, this.mode = c, this.storeNames = l, this.schema = u, this.chromeTransactionDurability = d, this.idbtrans = null, this.on = Fe(this, "complete", "error", "abort"), this.parent = h || null, this.active = !0, this._reculock = 0, this._blockedFuncs = [], this._resolve = null, this._reject = null, this._waitingFor = null, this._waitingQueue = null, this._spinCount = 0, this._completion = new E((p, g) => {
|
|
2484
|
+
this._resolve = p, this._reject = g;
|
|
2485
|
+
}), this._completion.then(() => {
|
|
2486
|
+
this.active = !1, this.on.complete.fire();
|
|
2487
|
+
}, (p) => {
|
|
2488
|
+
var g = this.active;
|
|
2489
|
+
return this.active = !1, this.on.error.fire(p), this.parent ? this.parent._reject(p) : g && this.idbtrans && this.idbtrans.abort(), F(p);
|
|
2490
|
+
});
|
|
2491
|
+
});
|
|
2492
|
+
}(this), this.Version = function(a) {
|
|
2493
|
+
return De(Xr.prototype, function(c) {
|
|
2494
|
+
this.db = a, this._cfg = { version: c, storesSource: null, dbschema: {}, tables: {}, contentUpgrade: null };
|
|
2495
|
+
});
|
|
2496
|
+
}(this), this.WhereClause = function(a) {
|
|
2497
|
+
return De(tr.prototype, function(c, l, u) {
|
|
2498
|
+
this.db = a, this._ctx = { table: c, index: l === ":id" ? null : l, or: u };
|
|
2499
|
+
const d = a._deps.indexedDB;
|
|
2500
|
+
if (!d)
|
|
2501
|
+
throw new C.MissingAPI();
|
|
2502
|
+
this._cmp = this._ascending = d.cmp.bind(d), this._descending = (h, p) => d.cmp(p, h), this._max = (h, p) => d.cmp(h, p) > 0 ? h : p, this._min = (h, p) => d.cmp(h, p) < 0 ? h : p, this._IDBKeyRange = a._deps.IDBKeyRange;
|
|
2503
|
+
});
|
|
2504
|
+
}(this), this.on("versionchange", (a) => {
|
|
2505
|
+
a.newVersion > 0 ? console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`), this.close();
|
|
2506
|
+
}), this.on("blocked", (a) => {
|
|
2507
|
+
!a.newVersion || a.newVersion < a.oldVersion ? console.warn(`Dexie.delete('${this.name}') was blocked`) : console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${a.oldVersion / 10}`);
|
|
2508
|
+
}), this._maxKey = Ve(n.IDBKeyRange), this._createTransaction = (a, c, l, u) => new this.Transaction(a, c, l, this._options.chromeTransactionDurability, u), this._fireOnBlocked = (a) => {
|
|
2509
|
+
this.on("blocked").fire(a), Re.filter((c) => c.name === this.name && c !== this && !c._state.vcFired).map((c) => c.on("versionchange").fire(a));
|
|
2510
|
+
}, this.use(ts), this.use(ns), this.use(is), this.use(rs), this.vip = Object.create(this, { _vip: { value: !0 } }), s.forEach((a) => a(this));
|
|
2511
|
+
}
|
|
2512
|
+
version(e) {
|
|
2513
|
+
if (isNaN(e) || e < 0.1)
|
|
2514
|
+
throw new C.Type("Given version is not a positive number");
|
|
2515
|
+
if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened)
|
|
2516
|
+
throw new C.Schema("Cannot add version when database is open");
|
|
2517
|
+
this.verno = Math.max(this.verno, e);
|
|
2518
|
+
const n = this._versions;
|
|
2519
|
+
var r = n.filter((s) => s._cfg.version === e)[0];
|
|
2520
|
+
return r || (r = new this.Version(e), n.push(r), n.sort(Qr), r.stores({}), this._state.autoSchema = !1, r);
|
|
2521
|
+
}
|
|
2522
|
+
_whenReady(e) {
|
|
2523
|
+
return this.idbdb && (this._state.openComplete || O.letThrough || this._vip) ? e() : new E((n, r) => {
|
|
2524
|
+
if (this._state.openComplete)
|
|
2525
|
+
return r(new C.DatabaseClosed(this._state.dbOpenError));
|
|
2526
|
+
if (!this._state.isBeingOpened) {
|
|
2527
|
+
if (!this._options.autoOpen)
|
|
2528
|
+
return void r(new C.DatabaseClosed());
|
|
2529
|
+
this.open().catch(A);
|
|
2530
|
+
}
|
|
2531
|
+
this._state.dbReadyPromise.then(n, r);
|
|
2532
|
+
}).then(e);
|
|
2533
|
+
}
|
|
2534
|
+
use({ stack: e, create: n, level: r, name: s }) {
|
|
2535
|
+
s && this.unuse({ stack: e, name: s });
|
|
2536
|
+
const i = this._middlewares[e] || (this._middlewares[e] = []);
|
|
2537
|
+
return i.push({ stack: e, create: n, level: r ?? 10, name: s }), i.sort((o, a) => o.level - a.level), this;
|
|
2538
|
+
}
|
|
2539
|
+
unuse({ stack: e, name: n, create: r }) {
|
|
2540
|
+
return e && this._middlewares[e] && (this._middlewares[e] = this._middlewares[e].filter((s) => r ? s.create !== r : !!n && s.name !== n)), this;
|
|
2541
|
+
}
|
|
2542
|
+
open() {
|
|
2543
|
+
return qr(this);
|
|
2544
|
+
}
|
|
2545
|
+
_close() {
|
|
2546
|
+
const e = this._state, n = Re.indexOf(this);
|
|
2547
|
+
if (n >= 0 && Re.splice(n, 1), this.idbdb) {
|
|
2548
|
+
try {
|
|
2549
|
+
this.idbdb.close();
|
|
2550
|
+
} catch {
|
|
2551
|
+
}
|
|
2552
|
+
this._novip.idbdb = null;
|
|
2553
|
+
}
|
|
2554
|
+
e.dbReadyPromise = new E((r) => {
|
|
2555
|
+
e.dbReadyResolve = r;
|
|
2556
|
+
}), e.openCanceller = new E((r, s) => {
|
|
2557
|
+
e.cancelOpen = s;
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
close() {
|
|
2561
|
+
this._close();
|
|
2562
|
+
const e = this._state;
|
|
2563
|
+
this._options.autoOpen = !1, e.dbOpenError = new C.DatabaseClosed(), e.isBeingOpened && e.cancelOpen(e.dbOpenError);
|
|
2564
|
+
}
|
|
2565
|
+
delete() {
|
|
2566
|
+
const e = arguments.length > 0, n = this._state;
|
|
2567
|
+
return new E((r, s) => {
|
|
2568
|
+
const i = () => {
|
|
2569
|
+
this.close();
|
|
2570
|
+
var o = this._deps.indexedDB.deleteDatabase(this.name);
|
|
2571
|
+
o.onsuccess = I(() => {
|
|
2572
|
+
(function({ indexedDB: a, IDBKeyRange: c }, l) {
|
|
2573
|
+
!pn(a) && l !== wt && fn(a, c).delete(l).catch(A);
|
|
2574
|
+
})(this._deps, this.name), r();
|
|
2575
|
+
}), o.onerror = Q(s), o.onblocked = this._fireOnBlocked;
|
|
2576
|
+
};
|
|
2577
|
+
if (e)
|
|
2578
|
+
throw new C.InvalidArgument("Arguments not allowed in db.delete()");
|
|
2579
|
+
n.isBeingOpened ? n.dbReadyPromise.then(i) : i();
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2582
|
+
backendDB() {
|
|
2583
|
+
return this.idbdb;
|
|
2584
|
+
}
|
|
2585
|
+
isOpen() {
|
|
2586
|
+
return this.idbdb !== null;
|
|
2587
|
+
}
|
|
2588
|
+
hasBeenClosed() {
|
|
2589
|
+
const e = this._state.dbOpenError;
|
|
2590
|
+
return e && e.name === "DatabaseClosed";
|
|
2591
|
+
}
|
|
2592
|
+
hasFailed() {
|
|
2593
|
+
return this._state.dbOpenError !== null;
|
|
2594
|
+
}
|
|
2595
|
+
dynamicallyOpened() {
|
|
2596
|
+
return this._state.autoSchema;
|
|
2597
|
+
}
|
|
2598
|
+
get tables() {
|
|
2599
|
+
return R(this._allTables).map((e) => this._allTables[e]);
|
|
2600
|
+
}
|
|
2601
|
+
transaction() {
|
|
2602
|
+
const e = es.apply(this, arguments);
|
|
2603
|
+
return this._transaction.apply(this, e);
|
|
2604
|
+
}
|
|
2605
|
+
_transaction(e, n, r) {
|
|
2606
|
+
let s = O.trans;
|
|
2607
|
+
s && s.db === this && e.indexOf("!") === -1 || (s = null);
|
|
2608
|
+
const i = e.indexOf("?") !== -1;
|
|
2609
|
+
let o, a;
|
|
2610
|
+
e = e.replace("!", "").replace("?", "");
|
|
2611
|
+
try {
|
|
2612
|
+
if (a = n.map((l) => {
|
|
2613
|
+
var u = l instanceof this.Table ? l.name : l;
|
|
2614
|
+
if (typeof u != "string")
|
|
2615
|
+
throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
|
|
2616
|
+
return u;
|
|
2617
|
+
}), e == "r" || e === xt)
|
|
2618
|
+
o = xt;
|
|
2619
|
+
else {
|
|
2620
|
+
if (e != "rw" && e != St)
|
|
2621
|
+
throw new C.InvalidArgument("Invalid transaction mode: " + e);
|
|
2622
|
+
o = St;
|
|
2623
|
+
}
|
|
2624
|
+
if (s) {
|
|
2625
|
+
if (s.mode === xt && o === St) {
|
|
2626
|
+
if (!i)
|
|
2627
|
+
throw new C.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
|
|
2628
|
+
s = null;
|
|
2629
|
+
}
|
|
2630
|
+
s && a.forEach((l) => {
|
|
2631
|
+
if (s && s.storeNames.indexOf(l) === -1) {
|
|
2632
|
+
if (!i)
|
|
2633
|
+
throw new C.SubTransaction("Table " + l + " not included in parent transaction.");
|
|
2634
|
+
s = null;
|
|
2635
|
+
}
|
|
2636
|
+
}), i && s && !s.active && (s = null);
|
|
2637
|
+
}
|
|
2638
|
+
} catch (l) {
|
|
2639
|
+
return s ? s._promise(null, (u, d) => {
|
|
2640
|
+
d(l);
|
|
2641
|
+
}) : F(l);
|
|
2642
|
+
}
|
|
2643
|
+
const c = ir.bind(null, this, o, a, s, r);
|
|
2644
|
+
return s ? s._promise(o, c, "lock") : O.trans ? Ke(O.transless, () => this._whenReady(c)) : this._whenReady(c);
|
|
2645
|
+
}
|
|
2646
|
+
table(e) {
|
|
2647
|
+
if (!H(this._allTables, e))
|
|
2648
|
+
throw new C.InvalidTable(`Table ${e} does not exist`);
|
|
2649
|
+
return this._allTables[e];
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
const os = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable";
|
|
2653
|
+
class as {
|
|
2654
|
+
constructor(e) {
|
|
2655
|
+
this._subscribe = e;
|
|
2656
|
+
}
|
|
2657
|
+
subscribe(e, n, r) {
|
|
2658
|
+
return this._subscribe(e && typeof e != "function" ? e : { next: e, error: n, complete: r });
|
|
2659
|
+
}
|
|
2660
|
+
[os]() {
|
|
2661
|
+
return this;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
function ar(t, e) {
|
|
2665
|
+
return R(e).forEach((n) => {
|
|
2666
|
+
bt(t[n] || (t[n] = new Z()), e[n]);
|
|
2667
|
+
}), t;
|
|
2668
|
+
}
|
|
2669
|
+
function cs(t) {
|
|
2670
|
+
let e, n = !1;
|
|
2671
|
+
const r = new as((s) => {
|
|
2672
|
+
const i = on(t);
|
|
2673
|
+
let o = !1, a = {}, c = {};
|
|
2674
|
+
const l = { get closed() {
|
|
2675
|
+
return o;
|
|
2676
|
+
}, unsubscribe: () => {
|
|
2677
|
+
o = !0, le.storagemutated.unsubscribe(p);
|
|
2678
|
+
} };
|
|
2679
|
+
s.start && s.start(l);
|
|
2680
|
+
let u = !1, d = !1;
|
|
2681
|
+
function h() {
|
|
2682
|
+
return R(c).some((y) => a[y] && ss(a[y], c[y]));
|
|
2683
|
+
}
|
|
2684
|
+
const p = (y) => {
|
|
2685
|
+
ar(a, y), h() && g();
|
|
2686
|
+
}, g = () => {
|
|
2687
|
+
if (u || o)
|
|
2688
|
+
return;
|
|
2689
|
+
a = {};
|
|
2690
|
+
const y = {}, b = function(m) {
|
|
2691
|
+
i && je();
|
|
2692
|
+
const f = () => ae(t, { subscr: m, trans: null }), w = O.trans ? Ke(O.transless, f) : f();
|
|
2693
|
+
return i && w.then(re, re), w;
|
|
2694
|
+
}(y);
|
|
2695
|
+
d || (le(ze, p), d = !0), u = !0, Promise.resolve(b).then((m) => {
|
|
2696
|
+
n = !0, e = m, u = !1, o || (h() ? g() : (a = {}, c = y, s.next && s.next(m)));
|
|
2697
|
+
}, (m) => {
|
|
2698
|
+
u = !1, n = !1, s.error && s.error(m), l.unsubscribe();
|
|
2699
|
+
});
|
|
2700
|
+
};
|
|
2701
|
+
return g(), l;
|
|
2702
|
+
});
|
|
2703
|
+
return r.hasValue = () => n, r.getValue = () => e, r;
|
|
2704
|
+
}
|
|
2705
|
+
let rn;
|
|
2706
|
+
try {
|
|
2707
|
+
rn = { indexedDB: D.indexedDB || D.mozIndexedDB || D.webkitIndexedDB || D.msIndexedDB, IDBKeyRange: D.IDBKeyRange || D.webkitIDBKeyRange };
|
|
2708
|
+
} catch {
|
|
2709
|
+
rn = { indexedDB: null, IDBKeyRange: null };
|
|
2710
|
+
}
|
|
2711
|
+
const he = me;
|
|
2712
|
+
function ut(t) {
|
|
2713
|
+
let e = ee;
|
|
2714
|
+
try {
|
|
2715
|
+
ee = !0, le.storagemutated.fire(t);
|
|
2716
|
+
} finally {
|
|
2717
|
+
ee = e;
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
Ce(he, { ...st, delete: (t) => new he(t, { addons: [] }).delete(), exists: (t) => new he(t, { addons: [] }).open().then((e) => (e.close(), !0)).catch("NoSuchDatabaseError", () => !1), getDatabaseNames(t) {
|
|
2721
|
+
try {
|
|
2722
|
+
return function({ indexedDB: e, IDBKeyRange: n }) {
|
|
2723
|
+
return pn(e) ? Promise.resolve(e.databases()).then((r) => r.map((s) => s.name).filter((s) => s !== wt)) : fn(e, n).toCollection().primaryKeys();
|
|
2724
|
+
}(he.dependencies).then(t);
|
|
2725
|
+
} catch {
|
|
2726
|
+
return F(new C.MissingAPI());
|
|
2727
|
+
}
|
|
2728
|
+
}, defineClass: () => function(t) {
|
|
2729
|
+
z(this, t);
|
|
2730
|
+
}, ignoreTransaction: (t) => O.trans ? Ke(O.transless, t) : t(), vip: en, async: function(t) {
|
|
2731
|
+
return function() {
|
|
2732
|
+
try {
|
|
2733
|
+
var e = tn(t.apply(this, arguments));
|
|
2734
|
+
return e && typeof e.then == "function" ? e : E.resolve(e);
|
|
2735
|
+
} catch (n) {
|
|
2736
|
+
return F(n);
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
}, spawn: function(t, e, n) {
|
|
2740
|
+
try {
|
|
2741
|
+
var r = tn(t.apply(n, e || []));
|
|
2742
|
+
return r && typeof r.then == "function" ? r : E.resolve(r);
|
|
2743
|
+
} catch (s) {
|
|
2744
|
+
return F(s);
|
|
2745
|
+
}
|
|
2746
|
+
}, currentTransaction: { get: () => O.trans || null }, waitFor: function(t, e) {
|
|
2747
|
+
const n = E.resolve(typeof t == "function" ? he.ignoreTransaction(t) : t).timeout(e || 6e4);
|
|
2748
|
+
return O.trans ? O.trans.waitFor(n) : n;
|
|
2749
|
+
}, Promise: E, debug: { get: () => J, set: (t) => {
|
|
2750
|
+
Fn(t, t === "dexie" ? () => !0 : Zn);
|
|
2751
|
+
} }, derive: Se, extend: z, props: Ce, override: Dn, Events: Fe, on: le, liveQuery: cs, extendObservabilitySet: ar, getByKeyPath: ne, setByKeyPath: Y, delByKeyPath: function(t, e) {
|
|
2752
|
+
typeof e == "string" ? Y(t, e, void 0) : "length" in e && [].map.call(e, function(n) {
|
|
2753
|
+
Y(t, n, void 0);
|
|
2754
|
+
});
|
|
2755
|
+
}, shallowClone: Tn, deepClone: He, getObjectDiff: mn, cmp: W, asap: In, minKey: Gt, addons: [], connections: Re, errnames: cn, dependencies: rn, semVer: kn, version: kn.split(".").map((t) => parseInt(t)).reduce((t, e, n) => t + e / Math.pow(10, 2 * n)) }), he.maxKey = Ve(he.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (le(ze, (t) => {
|
|
2756
|
+
if (!ee) {
|
|
2757
|
+
let e;
|
|
2758
|
+
vt ? (e = document.createEvent("CustomEvent"), e.initCustomEvent(oe, !0, !0, t)) : e = new CustomEvent(oe, { detail: t }), ee = !0, dispatchEvent(e), ee = !1;
|
|
2759
|
+
}
|
|
2760
|
+
}), addEventListener(oe, ({ detail: t }) => {
|
|
2761
|
+
ee || ut(t);
|
|
2762
|
+
}));
|
|
2763
|
+
let ee = !1;
|
|
2764
|
+
if (typeof BroadcastChannel < "u") {
|
|
2765
|
+
const t = new BroadcastChannel(oe);
|
|
2766
|
+
typeof t.unref == "function" && t.unref(), le(ze, (e) => {
|
|
2767
|
+
ee || t.postMessage(e);
|
|
2768
|
+
}), t.onmessage = (e) => {
|
|
2769
|
+
e.data && ut(e.data);
|
|
2770
|
+
};
|
|
2771
|
+
} else if (typeof self < "u" && typeof navigator < "u") {
|
|
2772
|
+
le(ze, (e) => {
|
|
2773
|
+
try {
|
|
2774
|
+
ee || (typeof localStorage < "u" && localStorage.setItem(oe, JSON.stringify({ trig: Math.random(), changedParts: e })), typeof self.clients == "object" && [...self.clients.matchAll({ includeUncontrolled: !0 })].forEach((n) => n.postMessage({ type: oe, changedParts: e })));
|
|
2775
|
+
} catch {
|
|
2776
|
+
}
|
|
2777
|
+
}), typeof addEventListener < "u" && addEventListener("storage", (e) => {
|
|
2778
|
+
if (e.key === oe) {
|
|
2779
|
+
const n = JSON.parse(e.newValue);
|
|
2780
|
+
n && ut(n.changedParts);
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
const t = self.document && navigator.serviceWorker;
|
|
2784
|
+
t && t.addEventListener("message", function({ data: e }) {
|
|
2785
|
+
e && e.type === oe && ut(e.changedParts);
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
E.rejectionMapper = function(t, e) {
|
|
2789
|
+
if (!t || t instanceof Ee || t instanceof TypeError || t instanceof SyntaxError || !t.name || !bn[t.name])
|
|
2790
|
+
return t;
|
|
2791
|
+
var n = new bn[t.name](e || t.message, t);
|
|
2792
|
+
return "stack" in t && te(n, "stack", { get: function() {
|
|
2793
|
+
return this.inner.stack;
|
|
2794
|
+
} }), n;
|
|
2795
|
+
}, Fn(J, Zn);
|
|
2796
|
+
const B = (t) => {
|
|
2797
|
+
let e = `${t.type}.${t.topics}`;
|
|
2798
|
+
return t.hasOwnProperty("order") && (e += `.${t.order}`), t.hasOwnProperty("period") && (e += `.${t.period}`), e;
|
|
2799
|
+
};
|
|
2800
|
+
function Je(t, e) {
|
|
2801
|
+
var n;
|
|
2802
|
+
switch (t.moderation) {
|
|
2803
|
+
case "before":
|
|
2804
|
+
const r = /* @__PURE__ */ new Date(), s = (n = t.beforeTime) == null ? void 0 : n.split(":"), i = parseInt(s ? s[0] : "00"), o = parseInt(s ? s[1] : "00"), a = parseInt(s ? s[2] : "00");
|
|
2805
|
+
e.before = r.setHours(i, o, a, 0) / 1e3, e.hasOwnProperty("period") || (e.period = r.getDay() === 1 ? 72 : 24);
|
|
2806
|
+
break;
|
|
2807
|
+
case "delayed":
|
|
2808
|
+
t.delay && t.delay > 0 && (e.delay = `${t.delay}`);
|
|
2809
|
+
break;
|
|
2810
|
+
case "approved":
|
|
2811
|
+
e.approved = "1";
|
|
2812
|
+
break;
|
|
2813
|
+
default:
|
|
2814
|
+
t.period !== 0 && (e.period = t.period);
|
|
2815
|
+
}
|
|
2816
|
+
return e;
|
|
2817
|
+
}
|
|
2818
|
+
class ls {
|
|
2819
|
+
constructor(e) {
|
|
2820
|
+
k(this, "db");
|
|
2821
|
+
k(this, "subscribers", []);
|
|
2822
|
+
k(this, "options");
|
|
2823
|
+
k(this, "setCloud", async (e, n) => {
|
|
2824
|
+
n !== "" && await this.db.table("cloud").put({
|
|
2825
|
+
id: e.widget,
|
|
2826
|
+
dashboard_id: e.dashboard,
|
|
2827
|
+
data: n
|
|
2828
|
+
});
|
|
2829
|
+
});
|
|
2830
|
+
k(this, "getCloud", async (e) => {
|
|
2831
|
+
const n = await this.db.table(Kn).where({ id: e.widget }).last();
|
|
2832
|
+
return n.presentation = (e == null ? void 0 : e.presentation) || "not set", n.slide = (e == null ? void 0 : e.slide) || "not set", n ?? { data: null };
|
|
2833
|
+
});
|
|
2834
|
+
k(this, "setSeries", async (e, n) => {
|
|
2835
|
+
n !== "" && await this.db.table(Dt).put({
|
|
2836
|
+
id: e.widget,
|
|
2837
|
+
dashboard_id: e.dashboard,
|
|
2838
|
+
data: n.data
|
|
2839
|
+
});
|
|
2840
|
+
});
|
|
2841
|
+
k(this, "getSeries", async (e) => {
|
|
2842
|
+
const n = await this.db.table(Dt).where({ id: e.widget }).last();
|
|
2843
|
+
return n.presentation = (e == null ? void 0 : e.presentation) || "not set", n.slide = (e == null ? void 0 : e.slide) || "not set", n ?? { data: null };
|
|
2844
|
+
});
|
|
2845
|
+
k(this, "setMessages", async (e, n) => {
|
|
2846
|
+
const r = n.title;
|
|
2847
|
+
n.messages.forEach((s) => {
|
|
2848
|
+
var i, o, a;
|
|
2849
|
+
this.db.table(Oe).put({ id: s.id, utc: s.utc, data: s }), this.db.table(dr).put({
|
|
2850
|
+
widget_id: e.widget,
|
|
2851
|
+
message_id: s.id,
|
|
2852
|
+
dashboard_id: e.dashboard,
|
|
2853
|
+
title: r,
|
|
2854
|
+
engagement: (i = s.dynamics) == null ? void 0 : i.engagement,
|
|
2855
|
+
impressions: (o = s.dynamics) == null ? void 0 : o.semrush_visits,
|
|
2856
|
+
reach: (a = s.dynamics) == null ? void 0 : a.potential_reach,
|
|
2857
|
+
sentiment: s.topics[0].sentiment,
|
|
2858
|
+
utc: s.utc
|
|
2859
|
+
});
|
|
2860
|
+
});
|
|
2861
|
+
});
|
|
2862
|
+
k(this, "getMessages", async (e) => {
|
|
2863
|
+
const n = (l) => l.widget_id === e.widget, r = (l) => l.utc > ((e == null ? void 0 : e.since) || 0), s = (l) => !l.hasOwnProperty("visible") || (l == null ? void 0 : l.visible) !== 0, i = await this.db.table("topics").orderBy("utc").reverse().filter(n).filter(r).filter(s).limit((e == null ? void 0 : e.limit) ?? 25).toArray(), o = i[0].title || "No results", a = i.map((l) => l.message_id), c = await this.db.table("messages").where("id").anyOf(a).toArray().then((l) => l.sort(function(u, d) {
|
|
2864
|
+
return d.utc - u.utc;
|
|
2865
|
+
}));
|
|
2866
|
+
return {
|
|
2867
|
+
data: {
|
|
2868
|
+
presentation: (e == null ? void 0 : e.presentation) || "not set",
|
|
2869
|
+
slide: (e == null ? void 0 : e.slide) || "not set",
|
|
2870
|
+
messages: c.map((l) => l.data),
|
|
2871
|
+
title: o,
|
|
2872
|
+
topics: [e.dashboard, e.widget].join("-"),
|
|
2873
|
+
query: e
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
});
|
|
2877
|
+
k(this, "cleanMessages", async (e) => {
|
|
2878
|
+
const n = Date.now() / 1e3, r = (s) => s.utc < e - n;
|
|
2879
|
+
await this.db.table("topics").orderBy("utc").filter(r).modify((s, i) => {
|
|
2880
|
+
delete i.value;
|
|
2881
|
+
});
|
|
2882
|
+
});
|
|
2883
|
+
k(this, "subscribe", (e) => {
|
|
2884
|
+
var r;
|
|
2885
|
+
if (e.widget === void 0) {
|
|
2886
|
+
const s = (r = e.topics) == null ? void 0 : r.split("-");
|
|
2887
|
+
e.dashboard = s ? s[0] : "", e.widget = s ? s[1] : "";
|
|
2888
|
+
}
|
|
2889
|
+
this.subscribers.filter((s) => s.widget == e.widget).length > 0 || (e.type === Oe && (e = Je(this.options, e)), console.log("[storage] subscribe", e), this.subscribers.push(e));
|
|
2890
|
+
});
|
|
2891
|
+
this.options = e, this.db = new me(e.app), this.db.version(2).stores({
|
|
2892
|
+
player: "id,title,name,location",
|
|
2893
|
+
monitor: "id,player_id,cols,rows,order,width,height,physicalwidth,physicalheight,devicePixelRatio,screenLeft,screenTop,orientation,monitor",
|
|
2894
|
+
display: "id,monitor_id,presentation_id,colstart,colend,rowstart,rowend",
|
|
2895
|
+
channel: "id,slide_index",
|
|
2896
|
+
presentation: "id,name,data",
|
|
2897
|
+
cloud: "id,dashboard_id,data",
|
|
2898
|
+
messages: "id,utc,visible,data",
|
|
2899
|
+
series: "id,dashboard_id,data",
|
|
2900
|
+
topics: "[widget_id+message_id],widget_id,dashboard_id,title,engagement,impressions,reach,sentiment,visible,utc",
|
|
2901
|
+
widgets: "id,dashboard_id,type"
|
|
2902
|
+
}), this.db.open();
|
|
2903
|
+
}
|
|
2904
|
+
getSubscribers() {
|
|
2905
|
+
return this.subscribers;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
function gn(t) {
|
|
2909
|
+
return new Promise((e, n) => {
|
|
2910
|
+
t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () => n(t.error);
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
function us(t, e) {
|
|
2914
|
+
const n = indexedDB.open(t);
|
|
2915
|
+
n.onupgradeneeded = () => n.result.createObjectStore(e);
|
|
2916
|
+
const r = gn(n);
|
|
2917
|
+
return (s, i) => r.then((o) => i(o.transaction(e, s).objectStore(e)));
|
|
2918
|
+
}
|
|
2919
|
+
let jt;
|
|
2920
|
+
function cr() {
|
|
2921
|
+
return jt || (jt = us("keyval-store", "keyval")), jt;
|
|
2922
|
+
}
|
|
2923
|
+
function Kt(t, e = cr()) {
|
|
2924
|
+
return e("readonly", (n) => gn(n.get(t)));
|
|
2925
|
+
}
|
|
2926
|
+
function At(t, e, n = cr()) {
|
|
2927
|
+
return n("readwrite", (r) => (r.put(e, t), gn(r.transaction)));
|
|
2928
|
+
}
|
|
2929
|
+
class hs {
|
|
2930
|
+
constructor(e) {
|
|
2931
|
+
k(this, "subscribers", []);
|
|
2932
|
+
k(this, "options");
|
|
2933
|
+
k(this, "setCloud", async (e, n) => {
|
|
2934
|
+
const r = B(e);
|
|
2935
|
+
await At(r, n);
|
|
2936
|
+
});
|
|
2937
|
+
k(this, "getCloud", async (e) => {
|
|
2938
|
+
const n = B(e);
|
|
2939
|
+
return await Kt(n);
|
|
2940
|
+
});
|
|
2941
|
+
k(this, "setSeries", async (e, n) => {
|
|
2942
|
+
const r = B(e);
|
|
2943
|
+
await At(r, n);
|
|
2944
|
+
});
|
|
2945
|
+
k(this, "getSeries", async (e) => {
|
|
2946
|
+
const n = B(e);
|
|
2947
|
+
return await Kt(n);
|
|
2948
|
+
});
|
|
2949
|
+
k(this, "setMessages", async (e, n) => {
|
|
2950
|
+
const r = B(e);
|
|
2951
|
+
await At(r, n);
|
|
2952
|
+
});
|
|
2953
|
+
k(this, "getMessages", async (e) => {
|
|
2954
|
+
const n = B(e);
|
|
2955
|
+
return await Kt(n);
|
|
2956
|
+
});
|
|
2957
|
+
k(this, "cleanMessages", async (e) => {
|
|
2958
|
+
console.log("cleanMessages not implemented for ", this.options.storage);
|
|
2959
|
+
});
|
|
2960
|
+
k(this, "subscribe", (e) => {
|
|
2961
|
+
var r;
|
|
2962
|
+
if (e.widget === void 0) {
|
|
2963
|
+
const s = (r = e.topics) == null ? void 0 : r.split("-");
|
|
2964
|
+
e.dashboard = s ? s[0] : "", e.widget = s ? s[1] : "";
|
|
2965
|
+
}
|
|
2966
|
+
e.type === "messages" && (e = Je(this.options, e)), !this.subscribers.filter((s) => s.widget == e.widget).length && this.subscribers.push(e);
|
|
2967
|
+
});
|
|
2968
|
+
this.options = e;
|
|
2969
|
+
}
|
|
2970
|
+
getSubscribers() {
|
|
2971
|
+
return this.subscribers;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
class ds {
|
|
2975
|
+
constructor(e) {
|
|
2976
|
+
k(this, "subscribers", []);
|
|
2977
|
+
k(this, "options");
|
|
2978
|
+
k(this, "setCloud", async (e, n) => {
|
|
2979
|
+
const r = B(e);
|
|
2980
|
+
return new Promise(async (s) => {
|
|
2981
|
+
s(window.localStorage.setObject(r, n));
|
|
2982
|
+
});
|
|
2983
|
+
});
|
|
2984
|
+
k(this, "getCloud", async (e) => {
|
|
2985
|
+
const n = B(e);
|
|
2986
|
+
return new Promise(async (r) => {
|
|
2987
|
+
r(window.localStorage.getObject(n));
|
|
2988
|
+
});
|
|
2989
|
+
});
|
|
2990
|
+
k(this, "setSeries", async (e, n) => {
|
|
2991
|
+
const r = B(e);
|
|
2992
|
+
return new Promise(async (s) => {
|
|
2993
|
+
s(window.localStorage.setObject(r, n));
|
|
2994
|
+
});
|
|
2995
|
+
});
|
|
2996
|
+
k(this, "getSeries", async (e) => {
|
|
2997
|
+
const n = B(e);
|
|
2998
|
+
return new Promise(async (r) => {
|
|
2999
|
+
r(window.localStorage.getObject(n));
|
|
3000
|
+
});
|
|
3001
|
+
});
|
|
3002
|
+
k(this, "setMessages", async (e, n) => {
|
|
3003
|
+
const r = B(e);
|
|
3004
|
+
return new Promise(async (s) => {
|
|
3005
|
+
s(window.localStorage.setObject(r, n));
|
|
3006
|
+
});
|
|
3007
|
+
});
|
|
3008
|
+
k(this, "getMessages", async (e) => {
|
|
3009
|
+
const n = B(e);
|
|
3010
|
+
return new Promise(async (r) => {
|
|
3011
|
+
r(window.localStorage.getObject(n));
|
|
3012
|
+
});
|
|
3013
|
+
});
|
|
3014
|
+
k(this, "cleanMessages", async (e) => {
|
|
3015
|
+
console.log("cleanMessages not implemented for ", this.options.storage);
|
|
3016
|
+
});
|
|
3017
|
+
k(this, "setWidget", async (e) => {
|
|
3018
|
+
let n = `widget.${e.widget}`;
|
|
3019
|
+
return new Promise(async (r) => {
|
|
3020
|
+
r(window.localStorage.setObject(n, e));
|
|
3021
|
+
});
|
|
3022
|
+
});
|
|
3023
|
+
k(this, "subscribe", (e) => {
|
|
3024
|
+
var r;
|
|
3025
|
+
if (e.widget === void 0) {
|
|
3026
|
+
const s = (r = e.topics) == null ? void 0 : r.split("-");
|
|
3027
|
+
e.dashboard = s ? s[0] : "", e.widget = s ? s[1] : "";
|
|
3028
|
+
}
|
|
3029
|
+
e.type === Oe && (e = Je(this.options, e)), !this.subscribers.filter((s) => s.widget == e.widget).length && this.subscribers.push(e);
|
|
3030
|
+
});
|
|
3031
|
+
this.options = e, Storage.prototype.setObject = function(n, r) {
|
|
3032
|
+
this.setItem(n, JSON.stringify(r));
|
|
3033
|
+
}, Storage.prototype.getObject = function(n) {
|
|
3034
|
+
const r = this.getItem(n);
|
|
3035
|
+
return r && JSON.parse(r);
|
|
3036
|
+
};
|
|
3037
|
+
}
|
|
3038
|
+
getSubscribers() {
|
|
3039
|
+
return this.subscribers;
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
class fs {
|
|
3043
|
+
constructor(e) {
|
|
3044
|
+
k(this, "subscribers", []);
|
|
3045
|
+
k(this, "options");
|
|
3046
|
+
k(this, "setCloud", async (e, n) => {
|
|
3047
|
+
const r = B(e);
|
|
3048
|
+
return new Promise(async (s) => {
|
|
3049
|
+
s(window.sessionStorage.setObject(r, n));
|
|
3050
|
+
});
|
|
3051
|
+
});
|
|
3052
|
+
k(this, "getCloud", async (e) => {
|
|
3053
|
+
const n = B(e);
|
|
3054
|
+
return new Promise(async (r) => {
|
|
3055
|
+
r(window.sessionStorage.getObject(n));
|
|
3056
|
+
});
|
|
3057
|
+
});
|
|
3058
|
+
k(this, "setSeries", async (e, n) => {
|
|
3059
|
+
const r = B(e);
|
|
3060
|
+
return new Promise(async (s) => {
|
|
3061
|
+
s(window.sessionStorage.setObject(r, n));
|
|
3062
|
+
});
|
|
3063
|
+
});
|
|
3064
|
+
k(this, "getSeries", async (e) => {
|
|
3065
|
+
const n = B(e);
|
|
3066
|
+
return new Promise(async (r) => {
|
|
3067
|
+
r(window.sessionStorage.getObject(n));
|
|
3068
|
+
});
|
|
3069
|
+
});
|
|
3070
|
+
k(this, "setMessages", async (e, n) => {
|
|
3071
|
+
const r = B(e);
|
|
3072
|
+
return new Promise(async (s) => {
|
|
3073
|
+
s(window.sessionStorage.setObject(r, n));
|
|
3074
|
+
});
|
|
3075
|
+
});
|
|
3076
|
+
k(this, "getMessages", async (e) => {
|
|
3077
|
+
const n = B(e);
|
|
3078
|
+
return new Promise(async (r) => {
|
|
3079
|
+
r(window.sessionStorage.getObject(n));
|
|
3080
|
+
});
|
|
3081
|
+
});
|
|
3082
|
+
k(this, "cleanMessages", async (e) => {
|
|
3083
|
+
console.log("cleanMessages not implemented for ", this.options.storage);
|
|
3084
|
+
});
|
|
3085
|
+
k(this, "setWidget", async (e) => {
|
|
3086
|
+
let n = `widget.${e.widget}`;
|
|
3087
|
+
return new Promise(async (r) => {
|
|
3088
|
+
r(window.sessionStorage.setObject(n, e));
|
|
3089
|
+
});
|
|
3090
|
+
});
|
|
3091
|
+
k(this, "subscribe", (e) => {
|
|
3092
|
+
var r;
|
|
3093
|
+
if (e.widget === void 0) {
|
|
3094
|
+
const s = (r = e.topics) == null ? void 0 : r.split("-");
|
|
3095
|
+
e.dashboard = s ? s[0] : "", e.widget = s ? s[1] : "";
|
|
3096
|
+
}
|
|
3097
|
+
e.type === Oe && (e = Je(this.options, e)), !this.subscribers.filter(
|
|
3098
|
+
(s) => s.widget == e.widget
|
|
3099
|
+
).length && this.subscribers.push(e);
|
|
3100
|
+
});
|
|
3101
|
+
this.options = e, Storage.prototype.setObject = function(n, r) {
|
|
3102
|
+
this.setItem(n, JSON.stringify(r));
|
|
3103
|
+
}, Storage.prototype.getObject = function(n) {
|
|
3104
|
+
const r = this.getItem(n);
|
|
3105
|
+
return r && JSON.parse(r);
|
|
3106
|
+
};
|
|
3107
|
+
}
|
|
3108
|
+
getSubscribers() {
|
|
3109
|
+
return this.subscribers;
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
class ps {
|
|
3113
|
+
constructor(e) {
|
|
3114
|
+
k(this, "subscribers", []);
|
|
3115
|
+
k(this, "options");
|
|
3116
|
+
k(this, "setCloud", async (e, n) => {
|
|
3117
|
+
const r = B(e);
|
|
3118
|
+
return new Promise(async (s) => {
|
|
3119
|
+
s(window.BuzzCasting.WidgetData[r] = n);
|
|
3120
|
+
});
|
|
3121
|
+
});
|
|
3122
|
+
k(this, "getCloud", async (e) => {
|
|
3123
|
+
const n = B(e);
|
|
3124
|
+
return new Promise(async (r) => {
|
|
3125
|
+
r(window.localStorage.getObject(n));
|
|
3126
|
+
});
|
|
3127
|
+
});
|
|
3128
|
+
k(this, "setSeries", async (e, n) => {
|
|
3129
|
+
const r = B(e);
|
|
3130
|
+
return new Promise(async (s) => {
|
|
3131
|
+
s(window.localStorage.setObject(r, n));
|
|
3132
|
+
});
|
|
3133
|
+
});
|
|
3134
|
+
k(this, "getSeries", async (e) => {
|
|
3135
|
+
const n = B(e);
|
|
3136
|
+
return new Promise(async (r) => {
|
|
3137
|
+
r(window.localStorage.getObject(n));
|
|
3138
|
+
});
|
|
3139
|
+
});
|
|
3140
|
+
k(this, "setMessages", async (e, n) => {
|
|
3141
|
+
const r = B(e);
|
|
3142
|
+
return new Promise(async (s) => {
|
|
3143
|
+
s(window.localStorage.setObject(r, n));
|
|
3144
|
+
});
|
|
3145
|
+
});
|
|
3146
|
+
k(this, "getMessages", async (e) => {
|
|
3147
|
+
const n = B(e);
|
|
3148
|
+
return new Promise(async (r) => {
|
|
3149
|
+
r(window.localStorage.getObject(n));
|
|
3150
|
+
});
|
|
3151
|
+
});
|
|
3152
|
+
k(this, "cleanMessages", async (e) => {
|
|
3153
|
+
console.log("cleanMessages not implemented for ", this.options.storage);
|
|
3154
|
+
});
|
|
3155
|
+
k(this, "setWidget", async (e) => {
|
|
3156
|
+
let n = `widget.${e.widget}`;
|
|
3157
|
+
return new Promise(async (r) => {
|
|
3158
|
+
r(window.localStorage.setObject(n, e));
|
|
3159
|
+
});
|
|
3160
|
+
});
|
|
3161
|
+
k(this, "subscribe", (e) => {
|
|
3162
|
+
var r;
|
|
3163
|
+
if (e.widget === void 0) {
|
|
3164
|
+
const s = (r = e.topics) == null ? void 0 : r.split("-");
|
|
3165
|
+
e.dashboard = s ? s[0] : "", e.widget = s ? s[1] : "";
|
|
3166
|
+
}
|
|
3167
|
+
e.type === Oe && (e = Je(this.options, e)), !this.subscribers.filter((s) => s.widget == e.widget).length && this.subscribers.push(e);
|
|
3168
|
+
});
|
|
3169
|
+
this.options = e, window.BuzzCasting.WidgetData = /* @__PURE__ */ new Set();
|
|
3170
|
+
}
|
|
3171
|
+
getSubscribers() {
|
|
3172
|
+
return this.subscribers;
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
class ys {
|
|
3176
|
+
//private options: IStorageManager
|
|
3177
|
+
constructor(e) {
|
|
3178
|
+
k(this, "sm");
|
|
3179
|
+
k(this, "api");
|
|
3180
|
+
k(this, "bc");
|
|
3181
|
+
k(this, "options");
|
|
3182
|
+
k(this, "update", async () => {
|
|
3183
|
+
var r;
|
|
3184
|
+
const e = (r = this.sm) == null ? void 0 : r.getSubscribers();
|
|
3185
|
+
if ((e == null ? void 0 : e.length) === 0)
|
|
3186
|
+
return;
|
|
3187
|
+
const n = [];
|
|
3188
|
+
e == null || e.forEach((s) => {
|
|
3189
|
+
n.push(this.api.get(s));
|
|
3190
|
+
}), await Promise.allSettled(n).then(
|
|
3191
|
+
(s) => s.forEach((i) => {
|
|
3192
|
+
var o, a, c;
|
|
3193
|
+
if (i.status === "fulfilled") {
|
|
3194
|
+
const l = i.value;
|
|
3195
|
+
switch (l.query.type) {
|
|
3196
|
+
case Oe:
|
|
3197
|
+
(o = this.sm) == null || o.setMessages(l.query, l.data);
|
|
3198
|
+
break;
|
|
3199
|
+
case Kn:
|
|
3200
|
+
(a = this.sm) == null || a.setCloud(l.query, l.data);
|
|
3201
|
+
break;
|
|
3202
|
+
case Dt:
|
|
3203
|
+
(c = this.sm) == null || c.setSeries(l.query, l.data);
|
|
3204
|
+
break;
|
|
3205
|
+
default:
|
|
3206
|
+
console.warn(`data type ${l.query.type} unknown`);
|
|
3207
|
+
}
|
|
3208
|
+
console.debug("[store]", l.data.title ?? l.query.widget), this.bc.postMessage({ event: "widget-update", data: l.query });
|
|
3209
|
+
} else
|
|
3210
|
+
console.warn("[store error]");
|
|
3211
|
+
})
|
|
3212
|
+
);
|
|
3213
|
+
});
|
|
3214
|
+
k(this, "hide", (e) => {
|
|
3215
|
+
this.api.hideMessage(e);
|
|
3216
|
+
});
|
|
3217
|
+
k(this, "actions", async (e) => {
|
|
3218
|
+
var n;
|
|
3219
|
+
switch (e.data.event) {
|
|
3220
|
+
case "subscribe":
|
|
3221
|
+
(n = this.sm) == null || n.subscribe(e.data.data);
|
|
3222
|
+
break;
|
|
3223
|
+
case "update":
|
|
3224
|
+
console.debug("[sm] update", e.data), await this.update();
|
|
3225
|
+
break;
|
|
3226
|
+
}
|
|
3227
|
+
});
|
|
3228
|
+
k(this, "getCloud", async (e) => {
|
|
3229
|
+
var n;
|
|
3230
|
+
return await ((n = this.sm) == null ? void 0 : n.getCloud(e));
|
|
3231
|
+
});
|
|
3232
|
+
k(this, "getSeries", async (e) => {
|
|
3233
|
+
var n;
|
|
3234
|
+
return await ((n = this.sm) == null ? void 0 : n.getSeries(e));
|
|
3235
|
+
});
|
|
3236
|
+
k(this, "getMessages", async (e) => {
|
|
3237
|
+
var n;
|
|
3238
|
+
return await ((n = this.sm) == null ? void 0 : n.getMessages(e));
|
|
3239
|
+
});
|
|
3240
|
+
k(this, "cleanMessages", async () => {
|
|
3241
|
+
var n, r;
|
|
3242
|
+
const e = ((n = this.options) == null ? void 0 : n.retention) || 345600;
|
|
3243
|
+
return await ((r = this.sm) == null ? void 0 : r.cleanMessages(e));
|
|
3244
|
+
});
|
|
3245
|
+
k(this, "getSubscribers", async () => {
|
|
3246
|
+
var e;
|
|
3247
|
+
return await ((e = this.sm) == null ? void 0 : e.getSubscribers());
|
|
3248
|
+
});
|
|
3249
|
+
switch (this.options = e, this.bc = new BroadcastChannel(e.app), console.debug("[sm] broadcast channel", e.app), this.bc.onmessage = (n) => {
|
|
3250
|
+
this.actions(n);
|
|
3251
|
+
}, this.bc.postMessage({ event: "sm-init", data: {} }), this.api = new hr(e), e.storage) {
|
|
3252
|
+
case yr:
|
|
3253
|
+
this.sm = new ls(e);
|
|
3254
|
+
break;
|
|
3255
|
+
case pr:
|
|
3256
|
+
this.sm = new fs(e);
|
|
3257
|
+
break;
|
|
3258
|
+
case mr:
|
|
3259
|
+
this.sm = new ds(e);
|
|
3260
|
+
break;
|
|
3261
|
+
case fr:
|
|
3262
|
+
this.sm = new hs(e);
|
|
3263
|
+
break;
|
|
3264
|
+
case gr:
|
|
3265
|
+
this.sm = new ps(e);
|
|
3266
|
+
break;
|
|
3267
|
+
default:
|
|
3268
|
+
this.sm = null;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
export {
|
|
3273
|
+
ys as default
|
|
3274
|
+
};
|