@inpageedit/core 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionButton-BgbTKTg7.js +24 -0
- package/dist/ActionButton-BgbTKTg7.js.map +1 -0
- package/dist/{RadioBox-BZFhTEo5.js → RadioBox-CaA8VgLu.js} +16 -16
- package/dist/{RadioBox-BZFhTEo5.js.map → RadioBox-CaA8VgLu.js.map} +1 -1
- package/dist/components/TwinSwapInput/index.d.ts +1 -0
- package/dist/components/index.js +21 -22
- package/dist/components/index.js.map +1 -1
- package/dist/index-BIgWRk98.js +4826 -0
- package/dist/index-BIgWRk98.js.map +1 -0
- package/dist/index-BMmKF_kG.js +165 -0
- package/dist/index-BMmKF_kG.js.map +1 -0
- package/dist/{index-BPsDFq9U.js → index-Bh70Udzi.js} +14 -13
- package/dist/index-Bh70Udzi.js.map +1 -0
- package/dist/index-CBphMyYJ.js +5170 -0
- package/dist/index-CBphMyYJ.js.map +1 -0
- package/dist/{index-X1X416tZ.js → index-CJLKdEqr.js} +41 -25
- package/dist/index-CJLKdEqr.js.map +1 -0
- package/dist/{index-BsYzf3Yw.js → index-CX5H4xCe.js} +12 -12
- package/dist/index-CX5H4xCe.js.map +1 -0
- package/dist/{index-BByzm2Fz.js → index-DNm9SNqM.js} +128 -120
- package/dist/{index-BByzm2Fz.js.map → index-DNm9SNqM.js.map} +1 -1
- package/dist/{index-Ch5DJDZZ.js → index-Djd6Ddcm.js} +125 -121
- package/dist/index-Djd6Ddcm.js.map +1 -0
- package/dist/index-Dk3xR25y.js +96 -0
- package/dist/index-Dk3xR25y.js.map +1 -0
- package/dist/{index-D-zQLFuZ.js → index-QF8lvEam.js} +14 -21
- package/dist/index-QF8lvEam.js.map +1 -0
- package/dist/index.js +9 -4639
- package/dist/index.js.map +1 -1
- package/dist/models/WikiPage/index.d.ts +5 -4
- package/dist/plugins/BasePlugin.d.ts +12 -4
- package/dist/plugins/_debug/index.d.ts +1 -1
- package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +2 -1
- package/dist/plugins/quick-edit/index.d.ts +2 -1
- package/dist/plugins/quick-move/index.d.ts +1 -1
- package/dist/plugins/quick-preview/index.d.ts +4 -3
- package/dist/plugins/quick-redirect/index.d.ts +1 -1
- package/dist/plugins/toolbox/index.d.ts +2 -2
- package/dist/services/ModalService/IPEModal.d.ts +235 -0
- package/dist/services/ModalService/index.d.ts +35 -0
- package/dist/style.css +1 -1
- package/dist/utils/interpolate.d.ts +20 -0
- package/dist/utils/interpolate.spec.d.ts +1 -0
- package/lib/index.umd.js +32 -32
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +24 -25
- package/dist/ActionButton-ByMKIthQ.js +0 -24
- package/dist/ActionButton-ByMKIthQ.js.map +0 -1
- package/dist/index-BPsDFq9U.js.map +0 -1
- package/dist/index-BTngTj1f.js +0 -4682
- package/dist/index-BTngTj1f.js.map +0 -1
- package/dist/index-BsYzf3Yw.js.map +0 -1
- package/dist/index-Ch5DJDZZ.js.map +0 -1
- package/dist/index-Cq9xxVsu.js +0 -149
- package/dist/index-Cq9xxVsu.js.map +0 -1
- package/dist/index-D-zQLFuZ.js.map +0 -1
- package/dist/index-HyxA2rYz.js +0 -87
- package/dist/index-HyxA2rYz.js.map +0 -1
- package/dist/index-X1X416tZ.js.map +0 -1
- package/dist/services/SsiModalService.d.ts +0 -36
package/dist/index.js
CHANGED
|
@@ -1,4642 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const Qt = () => {
|
|
3
|
-
let r, e;
|
|
4
|
-
return { promise: new Promise((n, i) => {
|
|
5
|
-
r = n, e = i;
|
|
6
|
-
}), resolve: r, reject: e };
|
|
7
|
-
};
|
|
8
|
-
Promise.withResolvers || (Promise.withResolvers = Qt);
|
|
9
|
-
var vn = Object.defineProperty, j = (r, e) => vn(r, "name", { value: e, configurable: !0 });
|
|
10
|
-
function bn() {
|
|
11
|
-
}
|
|
12
|
-
j(bn, "noop");
|
|
13
|
-
function z(r) {
|
|
14
|
-
return r == null;
|
|
15
|
-
}
|
|
16
|
-
j(z, "isNullable");
|
|
17
|
-
function wn(r) {
|
|
18
|
-
return !z(r);
|
|
19
|
-
}
|
|
20
|
-
j(wn, "isNonNullable");
|
|
21
|
-
function Be(r) {
|
|
22
|
-
return r && typeof r == "object" && !Array.isArray(r);
|
|
23
|
-
}
|
|
24
|
-
j(Be, "isPlainObject");
|
|
25
|
-
function Xt(r, e) {
|
|
26
|
-
return Object.fromEntries(Object.entries(r).filter(([t, n]) => e(t, n)));
|
|
27
|
-
}
|
|
28
|
-
j(Xt, "filterKeys");
|
|
29
|
-
function se(r, e) {
|
|
30
|
-
return Object.fromEntries(Object.entries(r).map(([t, n]) => [t, e(n, t)]));
|
|
31
|
-
}
|
|
32
|
-
j(se, "mapValues");
|
|
33
|
-
function Zt(r, e, t) {
|
|
34
|
-
if (!e) return { ...r };
|
|
35
|
-
const n = {};
|
|
36
|
-
for (const i of e)
|
|
37
|
-
(t || r[i] !== void 0) && (n[i] = r[i]);
|
|
38
|
-
return n;
|
|
39
|
-
}
|
|
40
|
-
j(Zt, "pick");
|
|
41
|
-
function _n(r, e) {
|
|
42
|
-
if (!e) return { ...r };
|
|
43
|
-
const t = { ...r };
|
|
44
|
-
for (const n of e)
|
|
45
|
-
Reflect.deleteProperty(t, n);
|
|
46
|
-
return t;
|
|
47
|
-
}
|
|
48
|
-
j(_n, "omit");
|
|
49
|
-
function G(r, e, t) {
|
|
50
|
-
return Object.defineProperty(r, e, { writable: !0, value: t, enumerable: !1 });
|
|
51
|
-
}
|
|
52
|
-
j(G, "defineProperty");
|
|
53
|
-
function Sn(r, e) {
|
|
54
|
-
return e.every((t) => r.includes(t));
|
|
55
|
-
}
|
|
56
|
-
j(Sn, "contain");
|
|
57
|
-
function xn(r, e) {
|
|
58
|
-
return r.filter((t) => e.includes(t));
|
|
59
|
-
}
|
|
60
|
-
j(xn, "intersection");
|
|
61
|
-
function En(r, e) {
|
|
62
|
-
return r.filter((t) => !e.includes(t));
|
|
63
|
-
}
|
|
64
|
-
j(En, "difference");
|
|
65
|
-
function On(r, e) {
|
|
66
|
-
return Array.from(/* @__PURE__ */ new Set([...r, ...e]));
|
|
67
|
-
}
|
|
68
|
-
j(On, "union");
|
|
69
|
-
function Rn(r) {
|
|
70
|
-
return [...new Set(r)];
|
|
71
|
-
}
|
|
72
|
-
j(Rn, "deduplicate");
|
|
73
|
-
function fe(r, e) {
|
|
74
|
-
const t = r?.indexOf(e);
|
|
75
|
-
return t >= 0 ? (r.splice(t, 1), !0) : !1;
|
|
76
|
-
}
|
|
77
|
-
j(fe, "remove");
|
|
78
|
-
function In(r) {
|
|
79
|
-
return Array.isArray(r) ? r : z(r) ? [] : [r];
|
|
80
|
-
}
|
|
81
|
-
j(In, "makeArray");
|
|
82
|
-
function le(r, e) {
|
|
83
|
-
return arguments.length === 1 ? (t) => le(r, t) : r in globalThis && e instanceof globalThis[r] || Object.prototype.toString.call(e).slice(8, -1) === r;
|
|
84
|
-
}
|
|
85
|
-
j(le, "is");
|
|
86
|
-
function ke(r) {
|
|
87
|
-
return le("ArrayBuffer", r) || le("SharedArrayBuffer", r);
|
|
88
|
-
}
|
|
89
|
-
j(ke, "isArrayBufferLike");
|
|
90
|
-
function er(r) {
|
|
91
|
-
return ke(r) || ArrayBuffer.isView(r);
|
|
92
|
-
}
|
|
93
|
-
j(er, "isArrayBufferSource");
|
|
94
|
-
var re;
|
|
95
|
-
((r) => {
|
|
96
|
-
r.is = ke, r.isSource = er;
|
|
97
|
-
function e(c) {
|
|
98
|
-
return ArrayBuffer.isView(c) ? c.buffer.slice(c.byteOffset, c.byteOffset + c.byteLength) : c;
|
|
99
|
-
}
|
|
100
|
-
r.fromSource = e, j(e, "fromSource");
|
|
101
|
-
function t(c) {
|
|
102
|
-
if (typeof Buffer < "u")
|
|
103
|
-
return Buffer.from(c).toString("base64");
|
|
104
|
-
let u = "";
|
|
105
|
-
const v = new Uint8Array(c);
|
|
106
|
-
for (let _ = 0; _ < v.byteLength; _++)
|
|
107
|
-
u += String.fromCharCode(v[_]);
|
|
108
|
-
return btoa(u);
|
|
109
|
-
}
|
|
110
|
-
r.toBase64 = t, j(t, "toBase64");
|
|
111
|
-
function n(c) {
|
|
112
|
-
return typeof Buffer < "u" ? e(Buffer.from(c, "base64")) : Uint8Array.from(atob(c), (u) => u.charCodeAt(0));
|
|
113
|
-
}
|
|
114
|
-
r.fromBase64 = n, j(n, "fromBase64");
|
|
115
|
-
function i(c) {
|
|
116
|
-
return typeof Buffer < "u" ? Buffer.from(c).toString("hex") : Array.from(new Uint8Array(c), (u) => u.toString(16).padStart(2, "0")).join("");
|
|
117
|
-
}
|
|
118
|
-
r.toHex = i, j(i, "toHex");
|
|
119
|
-
function s(c) {
|
|
120
|
-
if (typeof Buffer < "u") return e(Buffer.from(c, "hex"));
|
|
121
|
-
const u = c.length % 2 === 0 ? c : c.slice(0, c.length - 1), v = [];
|
|
122
|
-
for (let _ = 0; _ < u.length; _ += 2)
|
|
123
|
-
v.push(parseInt(`${u[_]}${u[_ + 1]}`, 16));
|
|
124
|
-
return Uint8Array.from(v).buffer;
|
|
125
|
-
}
|
|
126
|
-
r.fromHex = s, j(s, "fromHex");
|
|
127
|
-
})(re || (re = {}));
|
|
128
|
-
re.fromBase64;
|
|
129
|
-
re.toBase64;
|
|
130
|
-
re.fromHex;
|
|
131
|
-
re.toHex;
|
|
132
|
-
function Ue(r, e = /* @__PURE__ */ new Map()) {
|
|
133
|
-
if (!r || typeof r != "object") return r;
|
|
134
|
-
if (le("Date", r)) return new Date(r.valueOf());
|
|
135
|
-
if (le("RegExp", r)) return new RegExp(r.source, r.flags);
|
|
136
|
-
if (ke(r)) return r.slice(0);
|
|
137
|
-
if (ArrayBuffer.isView(r)) return r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength);
|
|
138
|
-
const t = e.get(r);
|
|
139
|
-
if (t) return t;
|
|
140
|
-
if (Array.isArray(r)) {
|
|
141
|
-
const i = [];
|
|
142
|
-
return e.set(r, i), r.forEach((s, c) => {
|
|
143
|
-
i[c] = Reflect.apply(Ue, null, [s, e]);
|
|
144
|
-
}), i;
|
|
145
|
-
}
|
|
146
|
-
const n = Object.create(Object.getPrototypeOf(r));
|
|
147
|
-
e.set(r, n);
|
|
148
|
-
for (const i of Reflect.ownKeys(r)) {
|
|
149
|
-
const s = { ...Reflect.getOwnPropertyDescriptor(r, i) };
|
|
150
|
-
"value" in s && (s.value = Reflect.apply(Ue, null, [s.value, e])), Reflect.defineProperty(n, i, s);
|
|
151
|
-
}
|
|
152
|
-
return n;
|
|
153
|
-
}
|
|
154
|
-
j(Ue, "clone");
|
|
155
|
-
function he(r, e, t) {
|
|
156
|
-
if (r === e || !t && z(r) && z(e)) return !0;
|
|
157
|
-
if (typeof r != typeof e || typeof r != "object" || !r || !e) return !1;
|
|
158
|
-
function n(i, s) {
|
|
159
|
-
return i(r) ? i(e) ? s(r, e) : !1 : i(e) ? !1 : void 0;
|
|
160
|
-
}
|
|
161
|
-
return j(n, "check"), n(Array.isArray, (i, s) => i.length === s.length && i.every((c, u) => he(c, s[u]))) ?? n(le("Date"), (i, s) => i.valueOf() === s.valueOf()) ?? n(le("RegExp"), (i, s) => i.source === s.source && i.flags === s.flags) ?? n(ke, (i, s) => {
|
|
162
|
-
if (i.byteLength !== s.byteLength) return !1;
|
|
163
|
-
const c = new Uint8Array(i), u = new Uint8Array(s);
|
|
164
|
-
for (let v = 0; v < c.length; v++)
|
|
165
|
-
if (c[v] !== u[v]) return !1;
|
|
166
|
-
return !0;
|
|
167
|
-
}) ?? Object.keys({ ...r, ...e }).every((i) => he(r[i], e[i], t));
|
|
168
|
-
}
|
|
169
|
-
j(he, "deepEqual");
|
|
170
|
-
function An(r) {
|
|
171
|
-
return r.charAt(0).toUpperCase() + r.slice(1);
|
|
172
|
-
}
|
|
173
|
-
j(An, "capitalize");
|
|
174
|
-
function kn(r) {
|
|
175
|
-
return r.charAt(0).toLowerCase() + r.slice(1);
|
|
176
|
-
}
|
|
177
|
-
j(kn, "uncapitalize");
|
|
178
|
-
function Pn(r) {
|
|
179
|
-
return r.replace(/[_-][a-z]/g, (e) => e.slice(1).toUpperCase());
|
|
180
|
-
}
|
|
181
|
-
j(Pn, "camelCase");
|
|
182
|
-
function lt(r, e, t) {
|
|
183
|
-
const n = [];
|
|
184
|
-
let i = 0;
|
|
185
|
-
for (let s = 0; s < r.length; s++) {
|
|
186
|
-
const c = r.charCodeAt(s);
|
|
187
|
-
if (c >= 65 && c <= 90) {
|
|
188
|
-
if (i === 1) {
|
|
189
|
-
const u = r.charCodeAt(s + 1);
|
|
190
|
-
u >= 97 && u <= 122 && n.push(t), n.push(c + 32);
|
|
191
|
-
} else
|
|
192
|
-
i !== 0 && n.push(t), n.push(c + 32);
|
|
193
|
-
i = 1;
|
|
194
|
-
} else c >= 97 && c <= 122 ? (n.push(c), i = 2) : e.includes(c) ? (i !== 0 && n.push(t), i = 0) : n.push(c);
|
|
195
|
-
}
|
|
196
|
-
return String.fromCharCode(...n);
|
|
197
|
-
}
|
|
198
|
-
j(lt, "tokenize");
|
|
199
|
-
function Dn(r) {
|
|
200
|
-
return lt(r, [45, 95], 45);
|
|
201
|
-
}
|
|
202
|
-
j(Dn, "paramCase");
|
|
203
|
-
function Tn(r) {
|
|
204
|
-
return lt(r, [45, 95], 95);
|
|
205
|
-
}
|
|
206
|
-
j(Tn, "snakeCase");
|
|
207
|
-
function Ln(r) {
|
|
208
|
-
return typeof r != "string" ? `[${r.toString()}]` : /^[a-z_$][\w$]*$/i.test(r) ? `.${r}` : `[${JSON.stringify(r)}]`;
|
|
209
|
-
}
|
|
210
|
-
j(Ln, "formatProperty");
|
|
211
|
-
function tr(r) {
|
|
212
|
-
return r.replace(/\/$/, "");
|
|
213
|
-
}
|
|
214
|
-
j(tr, "trimSlash");
|
|
215
|
-
function Nn(r) {
|
|
216
|
-
return r.startsWith("/") || (r = "/" + r), tr(r);
|
|
217
|
-
}
|
|
218
|
-
j(Nn, "sanitize");
|
|
219
|
-
var Mt;
|
|
220
|
-
((r) => {
|
|
221
|
-
r.millisecond = 1, r.second = 1e3, r.minute = r.second * 60, r.hour = r.minute * 60, r.day = r.hour * 24, r.week = r.day * 7;
|
|
222
|
-
let e = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
223
|
-
function t(P) {
|
|
224
|
-
e = P;
|
|
225
|
-
}
|
|
226
|
-
r.setTimezoneOffset = t, j(t, "setTimezoneOffset");
|
|
227
|
-
function n() {
|
|
228
|
-
return e;
|
|
229
|
-
}
|
|
230
|
-
r.getTimezoneOffset = n, j(n, "getTimezoneOffset");
|
|
231
|
-
function i(P = /* @__PURE__ */ new Date(), L) {
|
|
232
|
-
return typeof P == "number" && (P = new Date(P)), L === void 0 && (L = e), Math.floor((P.valueOf() / r.minute - L) / 1440);
|
|
233
|
-
}
|
|
234
|
-
r.getDateNumber = i, j(i, "getDateNumber");
|
|
235
|
-
function s(P, L) {
|
|
236
|
-
const Y = new Date(P * r.day);
|
|
237
|
-
return L === void 0 && (L = e), new Date(+Y + L * r.minute);
|
|
238
|
-
}
|
|
239
|
-
r.fromDateNumber = s, j(s, "fromDateNumber");
|
|
240
|
-
const c = /\d+(?:\.\d+)?/.source, u = new RegExp(`^${[
|
|
241
|
-
"w(?:eek(?:s)?)?",
|
|
242
|
-
"d(?:ay(?:s)?)?",
|
|
243
|
-
"h(?:our(?:s)?)?",
|
|
244
|
-
"m(?:in(?:ute)?(?:s)?)?",
|
|
245
|
-
"s(?:ec(?:ond)?(?:s)?)?"
|
|
246
|
-
].map((P) => `(${c}${P})?`).join("")}$`);
|
|
247
|
-
function v(P) {
|
|
248
|
-
const L = u.exec(P);
|
|
249
|
-
return L ? (parseFloat(L[1]) * r.week || 0) + (parseFloat(L[2]) * r.day || 0) + (parseFloat(L[3]) * r.hour || 0) + (parseFloat(L[4]) * r.minute || 0) + (parseFloat(L[5]) * r.second || 0) : 0;
|
|
250
|
-
}
|
|
251
|
-
r.parseTime = v, j(v, "parseTime");
|
|
252
|
-
function _(P) {
|
|
253
|
-
const L = v(P);
|
|
254
|
-
return L ? P = Date.now() + L : /^\d{1,2}(:\d{1,2}){1,2}$/.test(P) ? P = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${P}` : /^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(P) && (P = `${(/* @__PURE__ */ new Date()).getFullYear()}-${P}`), P ? new Date(P) : /* @__PURE__ */ new Date();
|
|
255
|
-
}
|
|
256
|
-
r.parseDate = _, j(_, "parseDate");
|
|
257
|
-
function E(P) {
|
|
258
|
-
const L = Math.abs(P);
|
|
259
|
-
return L >= r.day - r.hour / 2 ? Math.round(P / r.day) + "d" : L >= r.hour - r.minute / 2 ? Math.round(P / r.hour) + "h" : L >= r.minute - r.second / 2 ? Math.round(P / r.minute) + "m" : L >= r.second ? Math.round(P / r.second) + "s" : P + "ms";
|
|
260
|
-
}
|
|
261
|
-
r.format = E, j(E, "format");
|
|
262
|
-
function b(P, L = 2) {
|
|
263
|
-
return P.toString().padStart(L, "0");
|
|
264
|
-
}
|
|
265
|
-
r.toDigits = b, j(b, "toDigits");
|
|
266
|
-
function T(P, L = /* @__PURE__ */ new Date()) {
|
|
267
|
-
return P.replace("yyyy", L.getFullYear().toString()).replace("yy", L.getFullYear().toString().slice(2)).replace("MM", b(L.getMonth() + 1)).replace("dd", b(L.getDate())).replace("hh", b(L.getHours())).replace("mm", b(L.getMinutes())).replace("ss", b(L.getSeconds())).replace("SSS", b(L.getMilliseconds(), 3));
|
|
268
|
-
}
|
|
269
|
-
r.template = T, j(T, "template");
|
|
270
|
-
})(Mt || (Mt = {}));
|
|
271
|
-
var Cn = Object.defineProperty, C = (r, e) => Cn(r, "name", { value: e, configurable: !0 }), D = {
|
|
272
|
-
// internal symbols
|
|
273
|
-
shadow: Symbol.for("cordis.shadow"),
|
|
274
|
-
receiver: Symbol.for("cordis.receiver"),
|
|
275
|
-
original: Symbol.for("cordis.original"),
|
|
276
|
-
// context symbols
|
|
277
|
-
store: Symbol.for("cordis.store"),
|
|
278
|
-
events: Symbol.for("cordis.events"),
|
|
279
|
-
static: Symbol.for("cordis.static"),
|
|
280
|
-
filter: Symbol.for("cordis.filter"),
|
|
281
|
-
expose: Symbol.for("cordis.expose"),
|
|
282
|
-
isolate: Symbol.for("cordis.isolate"),
|
|
283
|
-
internal: Symbol.for("cordis.internal"),
|
|
284
|
-
intercept: Symbol.for("cordis.intercept"),
|
|
285
|
-
// service symbols
|
|
286
|
-
setup: Symbol.for("cordis.setup"),
|
|
287
|
-
invoke: Symbol.for("cordis.invoke"),
|
|
288
|
-
extend: Symbol.for("cordis.extend"),
|
|
289
|
-
tracker: Symbol.for("cordis.tracker"),
|
|
290
|
-
provide: Symbol.for("cordis.provide"),
|
|
291
|
-
immediate: Symbol.for("cordis.immediate")
|
|
292
|
-
}, $n = function* () {
|
|
293
|
-
}.constructor, qt = async function* () {
|
|
294
|
-
}.constructor;
|
|
295
|
-
function ht(r) {
|
|
296
|
-
return !(!r.prototype || r instanceof $n || qt !== Function && r instanceof qt);
|
|
297
|
-
}
|
|
298
|
-
C(ht, "isConstructor");
|
|
299
|
-
function Pe(r, e) {
|
|
300
|
-
const t = r.Config || r.schema;
|
|
301
|
-
return t && r.schema !== !1 && (e = t(e)), e ?? {};
|
|
302
|
-
}
|
|
303
|
-
C(Pe, "resolveConfig");
|
|
304
|
-
function rr(r) {
|
|
305
|
-
return [Map, Set, Date, Promise].some((e) => r instanceof e);
|
|
306
|
-
}
|
|
307
|
-
C(rr, "isUnproxyable");
|
|
308
|
-
function dt(r, e) {
|
|
309
|
-
if (r === Object.prototype) return e;
|
|
310
|
-
const t = Object.create(dt(Object.getPrototypeOf(r), e));
|
|
311
|
-
for (const n of Reflect.ownKeys(r))
|
|
312
|
-
Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
|
|
313
|
-
return t;
|
|
314
|
-
}
|
|
315
|
-
C(dt, "joinPrototype");
|
|
316
|
-
function pt(r) {
|
|
317
|
-
return r && (typeof r == "object" || typeof r == "function");
|
|
318
|
-
}
|
|
319
|
-
C(pt, "isObject");
|
|
320
|
-
function ne(r, e, t) {
|
|
321
|
-
if (!pt(e)) return e;
|
|
322
|
-
if (Object.hasOwn(e, D.shadow))
|
|
323
|
-
return Object.getPrototypeOf(e);
|
|
324
|
-
const n = e[D.tracker];
|
|
325
|
-
return n ? qe(r, e, n, t) : e;
|
|
326
|
-
}
|
|
327
|
-
C(ne, "getTraceable");
|
|
328
|
-
function Oe(r, e) {
|
|
329
|
-
return e ? new Proxy(r, {
|
|
330
|
-
get: /* @__PURE__ */ C((t, n, i) => n in e && n !== "constructor" ? Reflect.get(e, n, i) : Reflect.get(t, n, i), "get"),
|
|
331
|
-
set: /* @__PURE__ */ C((t, n, i, s) => n in e && n !== "constructor" ? Reflect.set(e, n, i, s) : Reflect.set(t, n, i, s), "set")
|
|
332
|
-
}) : r;
|
|
333
|
-
}
|
|
334
|
-
C(Oe, "withProps");
|
|
335
|
-
function Fe(r, e, t) {
|
|
336
|
-
return Oe(r, Object.defineProperty(/* @__PURE__ */ Object.create(null), e, {
|
|
337
|
-
value: t,
|
|
338
|
-
writable: !1
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
C(Fe, "withProp");
|
|
342
|
-
function it(r, e, t, n) {
|
|
343
|
-
if (!t) return n;
|
|
344
|
-
const i = Reflect.getOwnPropertyDescriptor(e, t)?.value;
|
|
345
|
-
return i ? Fe(n, t, r.extend({ [D.shadow]: i })) : n;
|
|
346
|
-
}
|
|
347
|
-
C(it, "createShadow");
|
|
348
|
-
function nr(r, e, t, n) {
|
|
349
|
-
return new Proxy(e, {
|
|
350
|
-
apply: /* @__PURE__ */ C((i, s, c) => (s === t && (s = n), c = c.map((u) => typeof u != "function" || u[D.original] ? u : new Proxy(u, {
|
|
351
|
-
get: /* @__PURE__ */ C((v, _, E) => {
|
|
352
|
-
if (_ === D.original) return v;
|
|
353
|
-
const b = Reflect.get(v, _, E);
|
|
354
|
-
return _ === "toString" && b === Function.prototype.toString ? function(...T) {
|
|
355
|
-
return Reflect.apply(b, this === E ? v : this, T);
|
|
356
|
-
} : b;
|
|
357
|
-
}, "get"),
|
|
358
|
-
apply: /* @__PURE__ */ C((v, _, E) => Reflect.apply(v, ne(r, _), E.map((b) => ne(r, b))), "apply"),
|
|
359
|
-
construct: /* @__PURE__ */ C((v, _, E) => Reflect.construct(v, _.map((b) => ne(r, b)), E), "construct")
|
|
360
|
-
})), ne(r, Reflect.apply(i, s, c))), "apply")
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
C(nr, "createShadowMethod");
|
|
364
|
-
function qe(r, e, t, n) {
|
|
365
|
-
r[D.shadow] && (r = Object.getPrototypeOf(r));
|
|
366
|
-
const i = new Proxy(e, {
|
|
367
|
-
get: /* @__PURE__ */ C((s, c, u) => {
|
|
368
|
-
if (c === D.original) return s;
|
|
369
|
-
if (c === t.property) return r;
|
|
370
|
-
if (typeof c == "symbol")
|
|
371
|
-
return Reflect.get(s, c, u);
|
|
372
|
-
if (t.associate && r[D.internal][`${t.associate}.${c}`])
|
|
373
|
-
return Reflect.get(r, `${t.associate}.${c}`, Fe(r, D.receiver, u));
|
|
374
|
-
const v = it(r, s, t.property, u), _ = Reflect.get(s, c, v), E = _?.[D.tracker];
|
|
375
|
-
return E ? qe(r, _, E) : !n && typeof _ == "function" ? nr(r, _, u, v) : _;
|
|
376
|
-
}, "get"),
|
|
377
|
-
set: /* @__PURE__ */ C((s, c, u, v) => {
|
|
378
|
-
if (c === D.original || c === t.property) return !1;
|
|
379
|
-
if (typeof c == "symbol")
|
|
380
|
-
return Reflect.set(s, c, u, v);
|
|
381
|
-
if (t.associate && r[D.internal][`${t.associate}.${c}`])
|
|
382
|
-
return Reflect.set(r, `${t.associate}.${c}`, u, Fe(r, D.receiver, v));
|
|
383
|
-
const _ = it(r, s, t.property, v);
|
|
384
|
-
return Reflect.set(s, c, u, _);
|
|
385
|
-
}, "set"),
|
|
386
|
-
apply: /* @__PURE__ */ C((s, c, u) => yt(i, s, c, u), "apply")
|
|
387
|
-
});
|
|
388
|
-
return i;
|
|
389
|
-
}
|
|
390
|
-
C(qe, "createTraceable");
|
|
391
|
-
function yt(r, e, t, n) {
|
|
392
|
-
return e[D.invoke] ? e[D.invoke].apply(r, n) : Reflect.apply(e, t, n);
|
|
393
|
-
}
|
|
394
|
-
C(yt, "applyTraceable");
|
|
395
|
-
function ot(r, e, t) {
|
|
396
|
-
const n = /* @__PURE__ */ C(function(...i) {
|
|
397
|
-
const s = qe(n.ctx, n, t);
|
|
398
|
-
return yt(s, n, this, i);
|
|
399
|
-
}, "self");
|
|
400
|
-
return G(n, "name", r), Object.setPrototypeOf(n, e);
|
|
401
|
-
}
|
|
402
|
-
C(ot, "createCallable");
|
|
403
|
-
var jn = class me {
|
|
404
|
-
constructor(e) {
|
|
405
|
-
this.ctx = e, G(this, D.tracker, {
|
|
406
|
-
associate: "reflect",
|
|
407
|
-
property: "ctx"
|
|
408
|
-
}), this._mixin("reflect", ["get", "set", "provide", "accessor", "mixin", "alias"]), this._mixin("scope", ["config", "runtime", "effect", "collect", "accept", "decline"]), this._mixin("registry", ["using", "inject", "plugin"]), this._mixin("lifecycle", ["on", "once", "parallel", "emit", "serial", "bail", "start", "stop"]);
|
|
409
|
-
}
|
|
410
|
-
static {
|
|
411
|
-
C(this, "ReflectService");
|
|
412
|
-
}
|
|
413
|
-
static resolveInject(e, t) {
|
|
414
|
-
let n = e[D.internal][t];
|
|
415
|
-
for (; n?.type === "alias"; )
|
|
416
|
-
t = n.name, n = e[D.internal][t];
|
|
417
|
-
return [t, n];
|
|
418
|
-
}
|
|
419
|
-
static checkInject(e, t, n) {
|
|
420
|
-
if (e = e[D.shadow] ?? e, ["prototype", "then", "registry", "lifecycle"].includes(t) || t[0] === "$" || t[0] === "_" || !e.runtime.plugin || e.bail(e, "internal/inject", t)) return;
|
|
421
|
-
const i = n.stack.split(`
|
|
422
|
-
`);
|
|
423
|
-
i.splice(1, 1), n.stack = i.join(`
|
|
424
|
-
`), e.emit(e, "internal/warning", n);
|
|
425
|
-
}
|
|
426
|
-
static handler = {
|
|
427
|
-
get: /* @__PURE__ */ C((e, t, n) => {
|
|
428
|
-
if (typeof t != "string") return Reflect.get(e, t, n);
|
|
429
|
-
if (Reflect.has(e, t))
|
|
430
|
-
return ne(n, Reflect.get(e, t, n), !0);
|
|
431
|
-
const [i, s] = me.resolveInject(e, t), c = new Error(`property ${i} is not registered, declare it as \`inject\` to suppress this warning`);
|
|
432
|
-
return s ? s.type === "accessor" ? s.get.call(n, n[D.receiver]) : (s.builtin || me.checkInject(n, i, c), n.reflect.get(i)) : (me.checkInject(n, i, c), Reflect.get(e, i, n));
|
|
433
|
-
}, "get"),
|
|
434
|
-
set: /* @__PURE__ */ C((e, t, n, i) => {
|
|
435
|
-
if (typeof t != "string") return Reflect.set(e, t, n, i);
|
|
436
|
-
const [s, c] = me.resolveInject(e, t);
|
|
437
|
-
return c ? c.type === "accessor" ? c.set ? c.set.call(i, n, i[D.receiver]) : !1 : (i.reflect.set(s, n), !0) : Reflect.set(e, s, n, i);
|
|
438
|
-
}, "set"),
|
|
439
|
-
has: /* @__PURE__ */ C((e, t) => {
|
|
440
|
-
if (typeof t != "string") return Reflect.has(e, t);
|
|
441
|
-
if (Reflect.has(e, t)) return !0;
|
|
442
|
-
const [, n] = me.resolveInject(e, t);
|
|
443
|
-
return !!n;
|
|
444
|
-
}, "has")
|
|
445
|
-
};
|
|
446
|
-
get(e) {
|
|
447
|
-
if (this.ctx[D.internal][e]?.type !== "service") return;
|
|
448
|
-
const n = this.ctx[D.isolate][e], i = this.ctx[D.store][n]?.value;
|
|
449
|
-
return ne(this.ctx, i);
|
|
450
|
-
}
|
|
451
|
-
set(e, t) {
|
|
452
|
-
this.provide(e);
|
|
453
|
-
const n = this.ctx[D.isolate][e], i = this.ctx[D.store][n]?.value;
|
|
454
|
-
t ??= void 0;
|
|
455
|
-
let s = /* @__PURE__ */ C(() => {
|
|
456
|
-
}, "dispose");
|
|
457
|
-
if (i === t) return s;
|
|
458
|
-
if (!z(t) && !z(i))
|
|
459
|
-
throw new Error(`service ${e} has been registered`);
|
|
460
|
-
const c = this.ctx;
|
|
461
|
-
z(t) || (s = c.effect(() => () => {
|
|
462
|
-
c.set(e, void 0);
|
|
463
|
-
})), rr(t) && c.emit(c, "internal/warning", new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));
|
|
464
|
-
const u = Object.create(c);
|
|
465
|
-
return u[D.filter] = (v) => c[D.isolate][e] === v[D.isolate][e], c.emit(u, "internal/before-service", e, t), c[D.store][n] = { value: t, source: c }, c.emit(u, "internal/service", e, i), s;
|
|
466
|
-
}
|
|
467
|
-
provide(e, t, n) {
|
|
468
|
-
const i = this.ctx.root[D.internal];
|
|
469
|
-
if (e in i) return;
|
|
470
|
-
const s = Symbol(e);
|
|
471
|
-
i[e] = { type: "service", builtin: n }, this.ctx.root[D.isolate][e] = s, pt(t) && (this.ctx[D.store][s] = { value: t, source: null }, G(t, D.tracker, {
|
|
472
|
-
associate: e,
|
|
473
|
-
property: "ctx"
|
|
474
|
-
}));
|
|
475
|
-
}
|
|
476
|
-
_accessor(e, t) {
|
|
477
|
-
const n = this.ctx.root[D.internal];
|
|
478
|
-
return e in n ? () => {
|
|
479
|
-
} : (n[e] = { type: "accessor", ...t }, () => delete this.ctx.root[D.isolate][e]);
|
|
480
|
-
}
|
|
481
|
-
accessor(e, t) {
|
|
482
|
-
this.ctx.scope.effect(() => this._accessor(e, t));
|
|
483
|
-
}
|
|
484
|
-
alias(e, t) {
|
|
485
|
-
const n = this.ctx.root[D.internal];
|
|
486
|
-
if (!(e in n))
|
|
487
|
-
for (const i of t)
|
|
488
|
-
n[i] ||= { type: "alias", name: e };
|
|
489
|
-
}
|
|
490
|
-
_mixin(e, t) {
|
|
491
|
-
const n = Array.isArray(t) ? t.map((c) => [c, c]) : Object.entries(t), i = typeof e == "string" ? (c) => c[e] : () => e, s = n.map(([c, u]) => this._accessor(u, {
|
|
492
|
-
get(v) {
|
|
493
|
-
const _ = i(this);
|
|
494
|
-
if (z(_)) return _;
|
|
495
|
-
const E = v ? Oe(v, _) : _, b = Reflect.get(_, c, E);
|
|
496
|
-
return typeof b != "function" ? b : b.bind(E ?? _);
|
|
497
|
-
},
|
|
498
|
-
set(v, _) {
|
|
499
|
-
const E = i(this), b = _ ? Oe(_, E) : E;
|
|
500
|
-
return Reflect.set(E, c, v, b);
|
|
501
|
-
}
|
|
502
|
-
}));
|
|
503
|
-
return () => s.forEach((c) => c());
|
|
504
|
-
}
|
|
505
|
-
mixin(e, t) {
|
|
506
|
-
this.ctx.scope.effect(() => this._mixin(e, t));
|
|
507
|
-
}
|
|
508
|
-
trace(e) {
|
|
509
|
-
return ne(this.ctx, e);
|
|
510
|
-
}
|
|
511
|
-
bind(e) {
|
|
512
|
-
return new Proxy(e, {
|
|
513
|
-
apply: /* @__PURE__ */ C((t, n, i) => t.apply(this.trace(n), i.map((s) => this.trace(s))), "apply")
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
}, st = jn;
|
|
517
|
-
function at(r) {
|
|
518
|
-
return r !== null && r !== !1 && r !== void 0;
|
|
519
|
-
}
|
|
520
|
-
C(at, "isBailed");
|
|
521
|
-
var Bn = class {
|
|
522
|
-
constructor(r) {
|
|
523
|
-
this.ctx = r, G(this, D.tracker, {
|
|
524
|
-
associate: "lifecycle",
|
|
525
|
-
property: "ctx"
|
|
526
|
-
}), G(this.on("internal/listener", function(t, n, i) {
|
|
527
|
-
const s = i.prepend ? "unshift" : "push";
|
|
528
|
-
if (t === "ready")
|
|
529
|
-
return this.lifecycle.isActive ? (this.scope.ensure(async () => n()), () => !1) : void 0;
|
|
530
|
-
if (t === "dispose")
|
|
531
|
-
return this.scope.disposables[s](n), G(n, "name", "event <dispose>"), () => fe(this.scope.disposables, n);
|
|
532
|
-
if (t === "fork")
|
|
533
|
-
return this.scope.runtime.forkables[s](n), this.scope.collect("event <fork>", () => fe(this.scope.runtime.forkables, n));
|
|
534
|
-
}), Q.static, r.scope);
|
|
535
|
-
for (const t of ["info", "error", "warning"])
|
|
536
|
-
G(this.on(`internal/${t}`, (n, ...i) => {
|
|
537
|
-
this._hooks[`internal/${t}`].length > 1 || console.info(n, ...i);
|
|
538
|
-
}), Q.static, r.scope);
|
|
539
|
-
G(this.on("internal/before-service", function(t) {
|
|
540
|
-
for (const n of this.registry.values()) {
|
|
541
|
-
if (!n.inject[t]?.required) continue;
|
|
542
|
-
const i = n.isReusable ? n.children : [n];
|
|
543
|
-
for (const s of i)
|
|
544
|
-
this[D.filter](s.ctx) && (s.updateStatus(), s.reset());
|
|
545
|
-
}
|
|
546
|
-
}, { global: !0 }), Q.static, r.scope), G(this.on("internal/service", function(t) {
|
|
547
|
-
for (const n of this.registry.values()) {
|
|
548
|
-
if (!n.inject[t]?.required) continue;
|
|
549
|
-
const i = n.isReusable ? n.children : [n];
|
|
550
|
-
for (const s of i)
|
|
551
|
-
this[D.filter](s.ctx) && s.start();
|
|
552
|
-
}
|
|
553
|
-
}, { global: !0 }), Q.static, r.scope);
|
|
554
|
-
const e = /* @__PURE__ */ C((t, n) => {
|
|
555
|
-
if (!t.runtime.plugin) return !1;
|
|
556
|
-
for (const i in t.runtime.inject)
|
|
557
|
-
if (n === st.resolveInject(t.ctx, i)[0]) return !0;
|
|
558
|
-
return e(t.parent.scope, n);
|
|
559
|
-
}, "checkInject");
|
|
560
|
-
G(this.on("internal/inject", function(t) {
|
|
561
|
-
return e(this.scope, t);
|
|
562
|
-
}, { global: !0 }), Q.static, r.scope);
|
|
563
|
-
}
|
|
564
|
-
static {
|
|
565
|
-
C(this, "Lifecycle");
|
|
566
|
-
}
|
|
567
|
-
isActive = !1;
|
|
568
|
-
_tasks = /* @__PURE__ */ new Set();
|
|
569
|
-
_hooks = {};
|
|
570
|
-
async flush() {
|
|
571
|
-
for (; this._tasks.size; )
|
|
572
|
-
await Promise.all(Array.from(this._tasks));
|
|
573
|
-
}
|
|
574
|
-
filterHooks(r, e) {
|
|
575
|
-
return e = ne(this.ctx, e), r.slice().filter((t) => {
|
|
576
|
-
const n = e?.[Q.filter];
|
|
577
|
-
return t.global || !n || n.call(e, t.ctx);
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
*dispatch(r, e) {
|
|
581
|
-
const t = typeof e[0] == "object" || typeof e[0] == "function" ? e.shift() : null, n = e.shift();
|
|
582
|
-
n !== "internal/event" && this.emit("internal/event", r, n, e, t);
|
|
583
|
-
for (const i of this.filterHooks(this._hooks[n] || [], t))
|
|
584
|
-
yield i.callback.apply(t, e);
|
|
585
|
-
}
|
|
586
|
-
async parallel(...r) {
|
|
587
|
-
await Promise.all(this.dispatch("emit", r));
|
|
588
|
-
}
|
|
589
|
-
emit(...r) {
|
|
590
|
-
Array.from(this.dispatch("emit", r));
|
|
591
|
-
}
|
|
592
|
-
async serial(...r) {
|
|
593
|
-
for await (const e of this.dispatch("serial", r))
|
|
594
|
-
if (at(e)) return e;
|
|
595
|
-
}
|
|
596
|
-
bail(...r) {
|
|
597
|
-
for (const e of this.dispatch("bail", r))
|
|
598
|
-
if (at(e)) return e;
|
|
599
|
-
}
|
|
600
|
-
register(r, e, t, n) {
|
|
601
|
-
const i = n.prepend ? "unshift" : "push";
|
|
602
|
-
return e[i]({ ctx: this.ctx, callback: t, ...n }), this.ctx.state.collect(r, () => this.unregister(e, t));
|
|
603
|
-
}
|
|
604
|
-
unregister(r, e) {
|
|
605
|
-
const t = r.findIndex((n) => n.callback === e);
|
|
606
|
-
if (t >= 0)
|
|
607
|
-
return r.splice(t, 1), !0;
|
|
608
|
-
}
|
|
609
|
-
on(r, e, t) {
|
|
610
|
-
typeof t != "object" && (t = { prepend: t }), this.ctx.scope.assertActive(), e = this.ctx.reflect.bind(e);
|
|
611
|
-
const n = this.bail(this.ctx, "internal/listener", r, e, t);
|
|
612
|
-
if (n) return n;
|
|
613
|
-
const i = this._hooks[r] ||= [], s = typeof r == "string" ? `event <${r}>` : "event (Symbol)";
|
|
614
|
-
return this.register(s, i, e, t);
|
|
615
|
-
}
|
|
616
|
-
once(r, e, t) {
|
|
617
|
-
const n = this.on(r, function(...i) {
|
|
618
|
-
return n(), e.apply(this, i);
|
|
619
|
-
}, t);
|
|
620
|
-
return n;
|
|
621
|
-
}
|
|
622
|
-
async start() {
|
|
623
|
-
this.isActive = !0;
|
|
624
|
-
const r = this._hooks.ready || [];
|
|
625
|
-
for (; r.length; ) {
|
|
626
|
-
const { ctx: e, callback: t } = r.shift();
|
|
627
|
-
e.scope.ensure(async () => t());
|
|
628
|
-
}
|
|
629
|
-
await this.flush();
|
|
630
|
-
}
|
|
631
|
-
async stop() {
|
|
632
|
-
this.isActive = !1, this.ctx.scope.reset();
|
|
633
|
-
}
|
|
634
|
-
}, Un = Bn, ct = class ir extends Error {
|
|
635
|
-
constructor(e, t) {
|
|
636
|
-
super(t ?? ir.Code[e]), this.code = e;
|
|
637
|
-
}
|
|
638
|
-
static {
|
|
639
|
-
C(this, "CordisError");
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
((r) => {
|
|
643
|
-
r.Code = {
|
|
644
|
-
INACTIVE_EFFECT: "cannot create effect on inactive context"
|
|
645
|
-
};
|
|
646
|
-
})(ct || (ct = {}));
|
|
647
|
-
var or = class {
|
|
648
|
-
constructor(r, e) {
|
|
649
|
-
this.parent = r, this.config = e, this.uid = r.registry ? r.registry.counter : 0, this.ctx = this.context = r.extend({ scope: this }), this.proxy = new Proxy({}, {
|
|
650
|
-
get: /* @__PURE__ */ C((t, n) => Reflect.get(this.config, n), "get")
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
static {
|
|
654
|
-
C(this, "EffectScope");
|
|
655
|
-
}
|
|
656
|
-
uid;
|
|
657
|
-
ctx;
|
|
658
|
-
disposables = [];
|
|
659
|
-
error;
|
|
660
|
-
status = 0;
|
|
661
|
-
isActive = !1;
|
|
662
|
-
// Same as `this.ctx`, but with a more specific type.
|
|
663
|
-
context;
|
|
664
|
-
proxy;
|
|
665
|
-
acceptors = [];
|
|
666
|
-
tasks = /* @__PURE__ */ new Set();
|
|
667
|
-
hasError = !1;
|
|
668
|
-
get _config() {
|
|
669
|
-
return this.runtime.isReactive ? this.proxy : this.config;
|
|
670
|
-
}
|
|
671
|
-
assertActive() {
|
|
672
|
-
if (!(this.uid !== null || this.isActive))
|
|
673
|
-
throw new ct("INACTIVE_EFFECT");
|
|
674
|
-
}
|
|
675
|
-
effect(r, e) {
|
|
676
|
-
this.assertActive();
|
|
677
|
-
const t = ht(r) ? new r(this.ctx, e) : r(this.ctx, e);
|
|
678
|
-
let n = !1;
|
|
679
|
-
const i = typeof t == "function" ? t : t.dispose.bind(t), s = /* @__PURE__ */ C((...c) => {
|
|
680
|
-
if (!n)
|
|
681
|
-
return n = !0, fe(this.disposables, s), i(...c);
|
|
682
|
-
}, "wrapped");
|
|
683
|
-
return this.disposables.push(s), typeof t == "function" ? s : (t.dispose = s, t);
|
|
684
|
-
}
|
|
685
|
-
collect(r, e) {
|
|
686
|
-
const t = G(() => (fe(this.disposables, t), e()), "name", r);
|
|
687
|
-
return this.disposables.push(t), t;
|
|
688
|
-
}
|
|
689
|
-
restart() {
|
|
690
|
-
this.reset(), this.error = null, this.hasError = !1, this.status = 0, this.start();
|
|
691
|
-
}
|
|
692
|
-
_getStatus() {
|
|
693
|
-
return this.uid === null ? 4 : this.hasError ? 3 : this.tasks.size ? 1 : this.ready ? 2 : 0;
|
|
694
|
-
}
|
|
695
|
-
updateStatus(r) {
|
|
696
|
-
const e = this.status;
|
|
697
|
-
r?.(), this.status = this._getStatus(), e !== this.status && this.context.emit("internal/status", this, e);
|
|
698
|
-
}
|
|
699
|
-
ensure(r) {
|
|
700
|
-
const e = r().catch((t) => {
|
|
701
|
-
this.context.emit(this.ctx, "internal/error", t), this.cancel(t);
|
|
702
|
-
}).finally(() => {
|
|
703
|
-
this.updateStatus(() => this.tasks.delete(e)), this.context.events._tasks.delete(e);
|
|
704
|
-
});
|
|
705
|
-
this.updateStatus(() => this.tasks.add(e)), this.context.events._tasks.add(e);
|
|
706
|
-
}
|
|
707
|
-
cancel(r) {
|
|
708
|
-
this.error = r, this.updateStatus(() => this.hasError = !0), this.reset();
|
|
709
|
-
}
|
|
710
|
-
get ready() {
|
|
711
|
-
return Object.entries(this.runtime.inject).every(([r, e]) => !e.required || !z(this.ctx.get(r)));
|
|
712
|
-
}
|
|
713
|
-
reset() {
|
|
714
|
-
this.isActive = !1, this.disposables = this.disposables.splice(0).filter((r) => {
|
|
715
|
-
if (this.uid !== null && r[Q.static] === this) return !0;
|
|
716
|
-
(async () => r())().catch((e) => {
|
|
717
|
-
this.context.emit(this.ctx, "internal/error", e);
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
init(r) {
|
|
722
|
-
this.config ? this.start() : this.cancel(r);
|
|
723
|
-
}
|
|
724
|
-
start() {
|
|
725
|
-
if (!this.ready || this.isActive || this.uid === null) return !0;
|
|
726
|
-
this.isActive = !0, this.updateStatus(() => this.hasError = !1);
|
|
727
|
-
}
|
|
728
|
-
accept(...r) {
|
|
729
|
-
const t = { keys: Array.isArray(r[0]) ? r.shift() : null, callback: r[0], ...r[1] };
|
|
730
|
-
return this.effect(() => (this.acceptors.push(t), t.immediate && t.callback?.(this.config), () => fe(this.acceptors, t)));
|
|
731
|
-
}
|
|
732
|
-
decline(r) {
|
|
733
|
-
return this.accept(r, () => !0);
|
|
734
|
-
}
|
|
735
|
-
checkUpdate(r, e) {
|
|
736
|
-
if (e || !this.config) return [!0, !0];
|
|
737
|
-
if (e === !1) return [!1, !1];
|
|
738
|
-
const t = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ C((v) => {
|
|
739
|
-
const _ = t[v] ??= !he(this.config[v], r[v]);
|
|
740
|
-
return s ||= _, _;
|
|
741
|
-
}, "checkPropertyUpdate"), i = /* @__PURE__ */ new Set();
|
|
742
|
-
let s = !1, c = !1, u = this.runtime.isReactive || null;
|
|
743
|
-
for (const { keys: v, callback: _, passive: E } of this.acceptors) {
|
|
744
|
-
if (!v)
|
|
745
|
-
u ||= !E;
|
|
746
|
-
else if (E)
|
|
747
|
-
v?.forEach((T) => i.add(T));
|
|
748
|
-
else {
|
|
749
|
-
let T = !1;
|
|
750
|
-
for (const P of v)
|
|
751
|
-
T ||= n(P);
|
|
752
|
-
if (!T) continue;
|
|
753
|
-
}
|
|
754
|
-
_?.(r) && (c = !0);
|
|
755
|
-
}
|
|
756
|
-
for (const v in { ...this.config, ...r })
|
|
757
|
-
if (u !== !1 && !(v in t) && !i.has(v)) {
|
|
758
|
-
const _ = n(v);
|
|
759
|
-
u === null && (c ||= _);
|
|
760
|
-
}
|
|
761
|
-
return [s, c];
|
|
762
|
-
}
|
|
763
|
-
}, Fn = class extends or {
|
|
764
|
-
constructor(r, e, t, n) {
|
|
765
|
-
super(r, t), this.runtime = e, this.dispose = G(r.scope.collect(`fork <${r.runtime.name}>`, () => {
|
|
766
|
-
this.uid = null, this.reset(), this.context.emit("internal/fork", this);
|
|
767
|
-
const i = fe(e.disposables, this.dispose);
|
|
768
|
-
return fe(e.children, this) && !e.children.length && r.registry.delete(e.plugin), i;
|
|
769
|
-
}), Q.static, e), e.children.push(this), e.disposables.push(this.dispose), this.context.emit("internal/fork", this), this.init(n);
|
|
770
|
-
}
|
|
771
|
-
static {
|
|
772
|
-
C(this, "ForkScope");
|
|
773
|
-
}
|
|
774
|
-
dispose;
|
|
775
|
-
start() {
|
|
776
|
-
if (super.start()) return !0;
|
|
777
|
-
for (const r of this.runtime.forkables)
|
|
778
|
-
this.ensure(async () => r(this.context, this._config));
|
|
779
|
-
}
|
|
780
|
-
update(r, e) {
|
|
781
|
-
const t = this.config, n = this.runtime.isForkable ? this : this.runtime;
|
|
782
|
-
if (n.config !== t) return;
|
|
783
|
-
let i;
|
|
784
|
-
try {
|
|
785
|
-
i = Pe(this.runtime.plugin, r);
|
|
786
|
-
} catch (u) {
|
|
787
|
-
return this.context.emit("internal/error", u), this.cancel(u);
|
|
788
|
-
}
|
|
789
|
-
const [s, c] = n.checkUpdate(i, e);
|
|
790
|
-
this.context.emit("internal/before-update", this, r), this.config = i, n.config = i, s && this.context.emit("internal/update", this, t), c && n.restart();
|
|
791
|
-
}
|
|
792
|
-
}, Wt = class extends or {
|
|
793
|
-
constructor(r, e, t, n) {
|
|
794
|
-
super(r, t), this.plugin = e, e ? (this.setup(), this.init(n)) : (this.name = "root", this.isActive = !0);
|
|
795
|
-
}
|
|
796
|
-
static {
|
|
797
|
-
C(this, "MainScope");
|
|
798
|
-
}
|
|
799
|
-
value;
|
|
800
|
-
runtime = this;
|
|
801
|
-
schema;
|
|
802
|
-
name;
|
|
803
|
-
inject = /* @__PURE__ */ Object.create(null);
|
|
804
|
-
forkables = [];
|
|
805
|
-
children = [];
|
|
806
|
-
isReusable = !1;
|
|
807
|
-
isReactive = !1;
|
|
808
|
-
get isForkable() {
|
|
809
|
-
return this.forkables.length > 0;
|
|
810
|
-
}
|
|
811
|
-
fork(r, e, t) {
|
|
812
|
-
return new Fn(r, this, e, t);
|
|
813
|
-
}
|
|
814
|
-
dispose() {
|
|
815
|
-
return this.uid = null, this.reset(), this.context.emit("internal/runtime", this), !0;
|
|
816
|
-
}
|
|
817
|
-
setup() {
|
|
818
|
-
const { name: r } = this.plugin;
|
|
819
|
-
r && r !== "apply" && (this.name = r), this.schema = this.plugin.Config || this.plugin.schema, this.inject = Re.resolve(this.plugin.using || this.plugin.inject), this.isReusable = this.plugin.reusable, this.isReactive = this.plugin.reactive, this.context.emit("internal/runtime", this), this.isReusable && this.forkables.push(this.apply);
|
|
820
|
-
}
|
|
821
|
-
apply = /* @__PURE__ */ C((r, e) => {
|
|
822
|
-
if (typeof this.plugin != "function")
|
|
823
|
-
return this.plugin.apply(r, e);
|
|
824
|
-
if (ht(this.plugin)) {
|
|
825
|
-
const t = new this.plugin(r, e), n = t[Q.expose];
|
|
826
|
-
return n && r.set(n, t), t.fork && this.forkables.push(t.fork.bind(t)), t;
|
|
827
|
-
} else
|
|
828
|
-
return this.plugin(r, e);
|
|
829
|
-
}, "apply");
|
|
830
|
-
reset() {
|
|
831
|
-
super.reset();
|
|
832
|
-
for (const r of this.children)
|
|
833
|
-
r.reset();
|
|
834
|
-
}
|
|
835
|
-
start() {
|
|
836
|
-
if (super.start()) return !0;
|
|
837
|
-
!this.isReusable && this.plugin && this.ensure(async () => this.value = this.apply(this.ctx, this._config));
|
|
838
|
-
for (const r of this.children)
|
|
839
|
-
r.start();
|
|
840
|
-
}
|
|
841
|
-
update(r, e) {
|
|
842
|
-
if (this.isForkable) {
|
|
843
|
-
const u = new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);
|
|
844
|
-
this.context.emit(this.ctx, "internal/warning", u);
|
|
845
|
-
}
|
|
846
|
-
const t = this.config;
|
|
847
|
-
let n;
|
|
848
|
-
try {
|
|
849
|
-
n = Pe(this.runtime.plugin || this.context.constructor, r);
|
|
850
|
-
} catch (u) {
|
|
851
|
-
return this.context.emit("internal/error", u), this.cancel(u);
|
|
852
|
-
}
|
|
853
|
-
const [i, s] = this.checkUpdate(n, e), c = this.children.find((u) => u.config === t);
|
|
854
|
-
this.config = n, c && (this.context.emit("internal/before-update", c, r), c.config = n, i && this.context.emit("internal/update", c, t)), s && this.restart();
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
function sr(r) {
|
|
858
|
-
return r && typeof r == "object" && typeof r.apply == "function";
|
|
859
|
-
}
|
|
860
|
-
C(sr, "isApplicable");
|
|
861
|
-
function Re(r) {
|
|
862
|
-
return function(e, t) {
|
|
863
|
-
if (t.kind === "class")
|
|
864
|
-
e.inject = r;
|
|
865
|
-
else if (t.kind === "method")
|
|
866
|
-
t.addInitializer(function() {
|
|
867
|
-
const n = this[D.tracker]?.property;
|
|
868
|
-
if (!n) throw new Error("missing context tracker");
|
|
869
|
-
this[n].inject(r, (i) => {
|
|
870
|
-
e.call(Oe(this, { [n]: i }));
|
|
871
|
-
});
|
|
872
|
-
});
|
|
873
|
-
else
|
|
874
|
-
throw new Error("@Inject can only be used on class or class methods");
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
C(Re, "Inject");
|
|
878
|
-
((r) => {
|
|
879
|
-
function e(t) {
|
|
880
|
-
if (!t) return {};
|
|
881
|
-
if (Array.isArray(t))
|
|
882
|
-
return Object.fromEntries(t.map((c) => [c, { required: !0 }]));
|
|
883
|
-
const { required: n, optional: i, ...s } = t;
|
|
884
|
-
return Array.isArray(n) && Object.assign(s, Object.fromEntries(n.map((c) => [c, { required: !0 }]))), Array.isArray(i) && Object.assign(s, Object.fromEntries(i.map((c) => [c, { required: !1 }]))), s;
|
|
885
|
-
}
|
|
886
|
-
r.resolve = e, C(e, "resolve");
|
|
887
|
-
})(Re || (Re = {}));
|
|
888
|
-
var Mn = class {
|
|
889
|
-
constructor(r, e) {
|
|
890
|
-
this.ctx = r, G(this, D.tracker, {
|
|
891
|
-
associate: "registry",
|
|
892
|
-
property: "ctx"
|
|
893
|
-
}), this.context = r;
|
|
894
|
-
const t = new Wt(r, null, e);
|
|
895
|
-
r.scope = t, t.ctx = r, this.set(null, t);
|
|
896
|
-
}
|
|
897
|
-
static {
|
|
898
|
-
C(this, "Registry");
|
|
899
|
-
}
|
|
900
|
-
_counter = 0;
|
|
901
|
-
_internal = /* @__PURE__ */ new Map();
|
|
902
|
-
context;
|
|
903
|
-
get counter() {
|
|
904
|
-
return ++this._counter;
|
|
905
|
-
}
|
|
906
|
-
get size() {
|
|
907
|
-
return this._internal.size;
|
|
908
|
-
}
|
|
909
|
-
resolve(r, e = !1) {
|
|
910
|
-
if (r === null || typeof r == "function") return r;
|
|
911
|
-
if (sr(r)) return r.apply;
|
|
912
|
-
if (e) throw new Error('invalid plugin, expect function or object with an "apply" method, received ' + typeof r);
|
|
913
|
-
}
|
|
914
|
-
get(r) {
|
|
915
|
-
const e = this.resolve(r);
|
|
916
|
-
return e && this._internal.get(e);
|
|
917
|
-
}
|
|
918
|
-
has(r) {
|
|
919
|
-
const e = this.resolve(r);
|
|
920
|
-
return !!e && this._internal.has(e);
|
|
921
|
-
}
|
|
922
|
-
set(r, e) {
|
|
923
|
-
const t = this.resolve(r);
|
|
924
|
-
this._internal.set(t, e);
|
|
925
|
-
}
|
|
926
|
-
delete(r) {
|
|
927
|
-
const e = this.resolve(r), t = e && this._internal.get(e);
|
|
928
|
-
if (t)
|
|
929
|
-
return this._internal.delete(e), t.dispose(), t;
|
|
930
|
-
}
|
|
931
|
-
keys() {
|
|
932
|
-
return this._internal.keys();
|
|
933
|
-
}
|
|
934
|
-
values() {
|
|
935
|
-
return this._internal.values();
|
|
936
|
-
}
|
|
937
|
-
entries() {
|
|
938
|
-
return this._internal.entries();
|
|
939
|
-
}
|
|
940
|
-
forEach(r) {
|
|
941
|
-
return this._internal.forEach(r);
|
|
942
|
-
}
|
|
943
|
-
using(r, e) {
|
|
944
|
-
return this.inject(r, e);
|
|
945
|
-
}
|
|
946
|
-
inject(r, e) {
|
|
947
|
-
return this.plugin({ inject: r, apply: e, name: e.name });
|
|
948
|
-
}
|
|
949
|
-
plugin(r, e, t) {
|
|
950
|
-
if (this.resolve(r, !0), this.ctx.scope.assertActive(), !t)
|
|
951
|
-
try {
|
|
952
|
-
e = Pe(r, e);
|
|
953
|
-
} catch (i) {
|
|
954
|
-
this.context.emit(this.ctx, "internal/error", i), t = i, e = null;
|
|
955
|
-
}
|
|
956
|
-
let n = this.get(r);
|
|
957
|
-
return n ? (n.isForkable || this.context.emit(this.ctx, "internal/warning", new Error(`duplicate plugin detected: ${r.name}`)), n.fork(this.ctx, e, t)) : (n = new Wt(this.ctx, r, e, t), this.set(r, n), n.fork(this.ctx, e, t));
|
|
958
|
-
}
|
|
959
|
-
}, qn = Mn, Q = class Se {
|
|
960
|
-
static {
|
|
961
|
-
C(this, "Context");
|
|
962
|
-
}
|
|
963
|
-
static store = D.store;
|
|
964
|
-
static events = D.events;
|
|
965
|
-
static static = D.static;
|
|
966
|
-
static filter = D.filter;
|
|
967
|
-
static expose = D.expose;
|
|
968
|
-
static isolate = D.isolate;
|
|
969
|
-
static internal = D.internal;
|
|
970
|
-
static intercept = D.intercept;
|
|
971
|
-
static origin = "ctx";
|
|
972
|
-
static current = "ctx";
|
|
973
|
-
static is(e) {
|
|
974
|
-
return !!e?.[Se.is];
|
|
975
|
-
}
|
|
976
|
-
static {
|
|
977
|
-
Se.is[Symbol.toPrimitive] = () => Symbol.for("cordis.is"), Se.prototype[Se.is] = !0;
|
|
978
|
-
}
|
|
979
|
-
/** @deprecated use `Service.traceable` instead */
|
|
980
|
-
static associate(e, t) {
|
|
981
|
-
return e;
|
|
982
|
-
}
|
|
983
|
-
constructor(e) {
|
|
984
|
-
e = Pe(this.constructor, e), this[D.store] = /* @__PURE__ */ Object.create(null), this[D.isolate] = /* @__PURE__ */ Object.create(null), this[D.internal] = /* @__PURE__ */ Object.create(null), this[D.intercept] = /* @__PURE__ */ Object.create(null);
|
|
985
|
-
const t = new Proxy(this, st.handler);
|
|
986
|
-
t.root = t, t.reflect = new st(t), t.registry = new qn(t, e), t.lifecycle = new Un(t);
|
|
987
|
-
const n = /* @__PURE__ */ C((i) => {
|
|
988
|
-
if (i) {
|
|
989
|
-
n(Object.getPrototypeOf(i));
|
|
990
|
-
for (const s of Object.getOwnPropertyNames(i)) {
|
|
991
|
-
const c = i[s].prototype?.constructor;
|
|
992
|
-
c && (t[i[s].key] = new c(t, e), G(t[i[s].key], "ctx", t));
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}, "attach");
|
|
996
|
-
return n(this[D.internal]), t;
|
|
997
|
-
}
|
|
998
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
999
|
-
return `Context <${this.name}>`;
|
|
1000
|
-
}
|
|
1001
|
-
get name() {
|
|
1002
|
-
let e = this.runtime;
|
|
1003
|
-
for (; e && !e.name; )
|
|
1004
|
-
e = e.parent.runtime;
|
|
1005
|
-
return e?.name;
|
|
1006
|
-
}
|
|
1007
|
-
get events() {
|
|
1008
|
-
return this.lifecycle;
|
|
1009
|
-
}
|
|
1010
|
-
/** @deprecated */
|
|
1011
|
-
get state() {
|
|
1012
|
-
return this.scope;
|
|
1013
|
-
}
|
|
1014
|
-
extend(e = {}) {
|
|
1015
|
-
const t = Reflect.getOwnPropertyDescriptor(this, D.shadow)?.value, n = Object.assign(Object.create(ne(this, this)), e);
|
|
1016
|
-
return t ? Object.assign(Object.create(n), { [D.shadow]: t }) : n;
|
|
1017
|
-
}
|
|
1018
|
-
isolate(e, t) {
|
|
1019
|
-
const n = Object.create(this[D.isolate]);
|
|
1020
|
-
return n[e] = t ?? Symbol(e), this.extend({ [D.isolate]: n });
|
|
1021
|
-
}
|
|
1022
|
-
intercept(e, t) {
|
|
1023
|
-
const n = Object.create(this[D.intercept]);
|
|
1024
|
-
return n[e] = t, this.extend({ [D.intercept]: n });
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
Q.prototype[Q.internal] = /* @__PURE__ */ Object.create(null);
|
|
1028
|
-
var We = class ar {
|
|
1029
|
-
static {
|
|
1030
|
-
C(this, "Service");
|
|
1031
|
-
}
|
|
1032
|
-
static setup = D.setup;
|
|
1033
|
-
static invoke = D.invoke;
|
|
1034
|
-
static extend = D.extend;
|
|
1035
|
-
static tracker = D.tracker;
|
|
1036
|
-
static provide = D.provide;
|
|
1037
|
-
static immediate = D.immediate;
|
|
1038
|
-
start() {
|
|
1039
|
-
}
|
|
1040
|
-
stop() {
|
|
1041
|
-
}
|
|
1042
|
-
ctx;
|
|
1043
|
-
name;
|
|
1044
|
-
config;
|
|
1045
|
-
constructor(...e) {
|
|
1046
|
-
let t, n, i, s;
|
|
1047
|
-
Q.is(e[0]) ? (t = e[0], typeof e[1] == "string" ? (n = e[1], i = e[2]) : s = e[1]) : s = e[0], n ??= this.constructor[D.provide], i ??= this.constructor[D.immediate];
|
|
1048
|
-
let c = this;
|
|
1049
|
-
const u = {
|
|
1050
|
-
associate: n,
|
|
1051
|
-
property: "ctx"
|
|
1052
|
-
};
|
|
1053
|
-
return c[D.invoke] && (c = ot(n, dt(Object.getPrototypeOf(this), Function.prototype), u)), t ? c.ctx = t : c[D.setup](), c.name = n, c.config = s, G(c, D.tracker, u), c.ctx.provide(n), c.ctx.runtime.name = n, i && (t ? c[D.expose] = n : c.ctx.set(n, c)), c.ctx.on("ready", async () => {
|
|
1054
|
-
await Promise.resolve(), await c.start(), i || c.ctx.set(n, c);
|
|
1055
|
-
}), c.ctx.on("dispose", () => c.stop()), c;
|
|
1056
|
-
}
|
|
1057
|
-
[D.filter](e) {
|
|
1058
|
-
return e[D.isolate][this.name] === this.ctx[D.isolate][this.name];
|
|
1059
|
-
}
|
|
1060
|
-
[D.setup]() {
|
|
1061
|
-
this.ctx = new Q();
|
|
1062
|
-
}
|
|
1063
|
-
[D.extend](e) {
|
|
1064
|
-
let t;
|
|
1065
|
-
return this[ar.invoke] ? t = ot(this.name, this, this[D.tracker]) : t = Object.create(this), Object.assign(t, e);
|
|
1066
|
-
}
|
|
1067
|
-
static [Symbol.hasInstance](e) {
|
|
1068
|
-
let t = e.constructor;
|
|
1069
|
-
for (; t; ) {
|
|
1070
|
-
if (t = t.prototype?.constructor, t === this) return !0;
|
|
1071
|
-
t = Object.getPrototypeOf(t);
|
|
1072
|
-
}
|
|
1073
|
-
return !1;
|
|
1074
|
-
}
|
|
1075
|
-
}, Wn = Object.defineProperty, Hn = Object.getOwnPropertyNames, F = (r, e) => Wn(r, "name", { value: e, configurable: !0 }), zn = (r, e) => function() {
|
|
1076
|
-
return e || (0, r[Hn(r)[0]])((e = { exports: {} }).exports, e), e.exports;
|
|
1077
|
-
}, Yn = zn({
|
|
1078
|
-
"src/index.ts"(r, e) {
|
|
1079
|
-
var t = Symbol.for("schemastery"), n = Symbol.for("ValidationError");
|
|
1080
|
-
globalThis.__schemastery_index__ ??= 0;
|
|
1081
|
-
var i = class extends TypeError {
|
|
1082
|
-
constructor(f, d) {
|
|
1083
|
-
let m = "$";
|
|
1084
|
-
for (const h of d.path || [])
|
|
1085
|
-
typeof h == "string" ? m += "." + h : typeof h == "number" ? m += "[" + h + "]" : typeof h == "symbol" && (m += `[Symbol(${h.toString()})]`);
|
|
1086
|
-
m.startsWith(".") && (m = m.slice(1)), super((m === "$" ? "" : `${m} `) + f), this.options = d;
|
|
1087
|
-
}
|
|
1088
|
-
static {
|
|
1089
|
-
F(this, "ValidationError");
|
|
1090
|
-
}
|
|
1091
|
-
name = "ValidationError";
|
|
1092
|
-
static is(f) {
|
|
1093
|
-
return !!f?.[n];
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
Object.defineProperty(i.prototype, n, {
|
|
1097
|
-
value: !0
|
|
1098
|
-
});
|
|
1099
|
-
var s = /* @__PURE__ */ F(function(f) {
|
|
1100
|
-
const d = /* @__PURE__ */ F(function(m, h = {}) {
|
|
1101
|
-
return s.resolve(m, d, h)[0];
|
|
1102
|
-
}, "schema");
|
|
1103
|
-
if (f.refs) {
|
|
1104
|
-
const m = se(f.refs, (w) => new s(w)), h = /* @__PURE__ */ F((w) => m[w], "getRef");
|
|
1105
|
-
for (const w in m) {
|
|
1106
|
-
const x = m[w];
|
|
1107
|
-
x.sKey = h(x.sKey), x.inner = h(x.inner), x.list = x.list && x.list.map(h), x.dict = x.dict && se(x.dict, h);
|
|
1108
|
-
}
|
|
1109
|
-
return m[f.uid];
|
|
1110
|
-
}
|
|
1111
|
-
if (Object.assign(d, f), typeof d.callback == "string")
|
|
1112
|
-
try {
|
|
1113
|
-
d.callback = new Function("return " + d.callback)();
|
|
1114
|
-
} catch {
|
|
1115
|
-
}
|
|
1116
|
-
return Object.defineProperty(d, "uid", { value: globalThis.__schemastery_index__++ }), Object.setPrototypeOf(d, s.prototype), d.meta ||= {}, d.toString = d.toString.bind(d), d;
|
|
1117
|
-
}, "Schema");
|
|
1118
|
-
s.prototype = Object.create(Function.prototype), s.prototype[t] = !0, s.ValidationError = i;
|
|
1119
|
-
var c;
|
|
1120
|
-
s.prototype.toJSON = /* @__PURE__ */ F(function() {
|
|
1121
|
-
if (c)
|
|
1122
|
-
return c[this.uid] ??= JSON.parse(JSON.stringify({ ...this })), this.uid;
|
|
1123
|
-
c = { [this.uid]: { ...this } }, c[this.uid] = JSON.parse(JSON.stringify({ ...this }));
|
|
1124
|
-
const d = { uid: this.uid, refs: c };
|
|
1125
|
-
return c = void 0, d;
|
|
1126
|
-
}, "toJSON"), s.prototype.set = /* @__PURE__ */ F(function(d, m) {
|
|
1127
|
-
return this.dict[d] = m, this;
|
|
1128
|
-
}, "set"), s.prototype.push = /* @__PURE__ */ F(function(d) {
|
|
1129
|
-
return this.list.push(d), this;
|
|
1130
|
-
}, "push");
|
|
1131
|
-
function u(f, d) {
|
|
1132
|
-
const m = typeof f == "string" ? { "": f } : { ...f };
|
|
1133
|
-
for (const h in d) {
|
|
1134
|
-
const w = d[h];
|
|
1135
|
-
w?.$description || w?.$desc ? m[h] = w.$description || w.$desc : typeof w == "string" && (m[h] = w);
|
|
1136
|
-
}
|
|
1137
|
-
return m;
|
|
1138
|
-
}
|
|
1139
|
-
F(u, "mergeDesc");
|
|
1140
|
-
function v(f) {
|
|
1141
|
-
return f?.$value ?? f?.$inner;
|
|
1142
|
-
}
|
|
1143
|
-
F(v, "getInner");
|
|
1144
|
-
function _(f) {
|
|
1145
|
-
return Xt(f ?? {}, (d) => !d.startsWith("$"));
|
|
1146
|
-
}
|
|
1147
|
-
F(_, "extractKeys"), s.prototype.i18n = /* @__PURE__ */ F(function(d) {
|
|
1148
|
-
const m = s(this), h = u(m.meta.description, d);
|
|
1149
|
-
return Object.keys(h).length && (m.meta.description = h), m.dict && (m.dict = se(m.dict, (w, x) => w.i18n(se(d, (A) => v(A)?.[x] ?? A?.[x])))), m.list && (m.list = m.list.map((w, x) => w.i18n(se(d, (A = {}) => Array.isArray(v(A)) ? v(A)[x] : Array.isArray(A) ? A[x] : _(A))))), m.inner && (m.inner = m.inner.i18n(se(d, (w) => v(w) ? v(w) : _(w)))), m.sKey && (m.sKey = m.sKey.i18n(se(d, (w) => w?.$key))), m;
|
|
1150
|
-
}, "i18n"), s.prototype.extra = /* @__PURE__ */ F(function(d, m) {
|
|
1151
|
-
const h = s(this);
|
|
1152
|
-
return h.meta = { ...h.meta, [d]: m }, h;
|
|
1153
|
-
}, "extra");
|
|
1154
|
-
for (const f of ["required", "disabled", "collapse", "hidden", "loose"])
|
|
1155
|
-
Object.assign(s.prototype, {
|
|
1156
|
-
[f](d = !0) {
|
|
1157
|
-
const m = s(this);
|
|
1158
|
-
return m.meta = { ...m.meta, [f]: d }, m;
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
s.prototype.deprecated = /* @__PURE__ */ F(function() {
|
|
1162
|
-
const d = s(this);
|
|
1163
|
-
return d.meta.badges ||= [], d.meta.badges.push({ text: "deprecated", type: "danger" }), d;
|
|
1164
|
-
}, "deprecated"), s.prototype.experimental = /* @__PURE__ */ F(function() {
|
|
1165
|
-
const d = s(this);
|
|
1166
|
-
return d.meta.badges ||= [], d.meta.badges.push({ text: "experimental", type: "warning" }), d;
|
|
1167
|
-
}, "experimental"), s.prototype.pattern = /* @__PURE__ */ F(function(d) {
|
|
1168
|
-
const m = s(this), h = Zt(d, ["source", "flags"]);
|
|
1169
|
-
return m.meta = { ...m.meta, pattern: h }, m;
|
|
1170
|
-
}, "pattern"), s.prototype.simplify = /* @__PURE__ */ F(function(d) {
|
|
1171
|
-
if (he(d, this.meta.default, this.type === "dict")) return null;
|
|
1172
|
-
if (z(d)) return d;
|
|
1173
|
-
if (this.type === "object" || this.type === "dict") {
|
|
1174
|
-
const m = {};
|
|
1175
|
-
for (const h in d) {
|
|
1176
|
-
const x = (this.type === "object" ? this.dict[h] : this.inner)?.simplify(d[h]);
|
|
1177
|
-
(this.type === "dict" || !z(x)) && (m[h] = x);
|
|
1178
|
-
}
|
|
1179
|
-
return he(m, this.meta.default, this.type === "dict") ? null : m;
|
|
1180
|
-
} else if (this.type === "array" || this.type === "tuple") {
|
|
1181
|
-
const m = [];
|
|
1182
|
-
return d.forEach((h, w) => {
|
|
1183
|
-
const x = this.type === "array" ? this.inner : this.list[w], A = x ? x.simplify(h) : h;
|
|
1184
|
-
m.push(A);
|
|
1185
|
-
}), m;
|
|
1186
|
-
} else if (this.type === "intersect") {
|
|
1187
|
-
const m = {};
|
|
1188
|
-
for (const h of this.list)
|
|
1189
|
-
Object.assign(m, h.simplify(d));
|
|
1190
|
-
return m;
|
|
1191
|
-
} else if (this.type === "union")
|
|
1192
|
-
for (const m of this.list)
|
|
1193
|
-
try {
|
|
1194
|
-
return s.resolve(d, m, {}), m.simplify(d);
|
|
1195
|
-
} catch {
|
|
1196
|
-
}
|
|
1197
|
-
return d;
|
|
1198
|
-
}, "simplify"), s.prototype.toString = /* @__PURE__ */ F(function(d) {
|
|
1199
|
-
return W[this.type]?.(this, d) ?? `Schema<${this.type}>`;
|
|
1200
|
-
}, "toString"), s.prototype.role = /* @__PURE__ */ F(function(f, d) {
|
|
1201
|
-
const m = s(this);
|
|
1202
|
-
return m.meta = { ...m.meta, role: f, extra: d }, m;
|
|
1203
|
-
}, "role");
|
|
1204
|
-
for (const f of ["default", "link", "comment", "description", "max", "min", "step"])
|
|
1205
|
-
Object.assign(s.prototype, {
|
|
1206
|
-
[f](d) {
|
|
1207
|
-
const m = s(this);
|
|
1208
|
-
return m.meta = { ...m.meta, [f]: d }, m;
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
var E = {};
|
|
1212
|
-
s.extend = /* @__PURE__ */ F(function(d, m) {
|
|
1213
|
-
E[d] = m;
|
|
1214
|
-
}, "extend"), s.resolve = /* @__PURE__ */ F(function(d, m, h = {}, w = !1) {
|
|
1215
|
-
if (!m) return [d];
|
|
1216
|
-
if (h.ignore?.(d, m)) return [d];
|
|
1217
|
-
if (z(d) && m.type !== "lazy") {
|
|
1218
|
-
if (m.meta.required) throw new i("missing required value", h);
|
|
1219
|
-
let A = m, $ = m.meta.default;
|
|
1220
|
-
for (; A?.type === "intersect" && z($); )
|
|
1221
|
-
A = A.list[0], $ = A?.meta.default;
|
|
1222
|
-
if (z($)) return [d];
|
|
1223
|
-
d = Ue($);
|
|
1224
|
-
}
|
|
1225
|
-
const x = E[m.type];
|
|
1226
|
-
if (!x) throw new i(`unsupported type "${m.type}"`, h);
|
|
1227
|
-
try {
|
|
1228
|
-
return x(d, m, h, w);
|
|
1229
|
-
} catch (A) {
|
|
1230
|
-
if (!m.meta.loose) throw A;
|
|
1231
|
-
return [m.meta.default];
|
|
1232
|
-
}
|
|
1233
|
-
}, "resolve"), s.from = /* @__PURE__ */ F(function(d) {
|
|
1234
|
-
if (z(d))
|
|
1235
|
-
return s.any();
|
|
1236
|
-
if (["string", "number", "boolean"].includes(typeof d))
|
|
1237
|
-
return s.const(d).required();
|
|
1238
|
-
if (d[t])
|
|
1239
|
-
return d;
|
|
1240
|
-
if (typeof d == "function")
|
|
1241
|
-
switch (d) {
|
|
1242
|
-
case String:
|
|
1243
|
-
return s.string().required();
|
|
1244
|
-
case Number:
|
|
1245
|
-
return s.number().required();
|
|
1246
|
-
case Boolean:
|
|
1247
|
-
return s.boolean().required();
|
|
1248
|
-
case Function:
|
|
1249
|
-
return s.function().required();
|
|
1250
|
-
default:
|
|
1251
|
-
return s.is(d).required();
|
|
1252
|
-
}
|
|
1253
|
-
else
|
|
1254
|
-
throw new TypeError(`cannot infer schema from ${d}`);
|
|
1255
|
-
}, "from"), s.lazy = /* @__PURE__ */ F(function(d) {
|
|
1256
|
-
const m = /* @__PURE__ */ F(() => (h.inner[t] || (h.inner = h.builder(), h.inner.meta = { ...h.meta, ...h.inner.meta }), h.inner.toJSON()), "toJSON"), h = new s({ type: "lazy", builder: d, inner: { toJSON: m } });
|
|
1257
|
-
return h;
|
|
1258
|
-
}, "lazy"), s.natural = /* @__PURE__ */ F(function() {
|
|
1259
|
-
return s.number().step(1).min(0);
|
|
1260
|
-
}, "natural"), s.percent = /* @__PURE__ */ F(function() {
|
|
1261
|
-
return s.number().step(0.01).min(0).max(1).role("slider");
|
|
1262
|
-
}, "percent"), s.date = /* @__PURE__ */ F(function() {
|
|
1263
|
-
return s.union([
|
|
1264
|
-
s.is(Date),
|
|
1265
|
-
s.transform(s.string().role("datetime"), (d, m) => {
|
|
1266
|
-
const h = new Date(d);
|
|
1267
|
-
if (isNaN(+h)) throw new i(`invalid date "${d}"`, m);
|
|
1268
|
-
return h;
|
|
1269
|
-
}, !0)
|
|
1270
|
-
]);
|
|
1271
|
-
}, "date"), s.regExp = /* @__PURE__ */ F(function(d = "") {
|
|
1272
|
-
return s.union([
|
|
1273
|
-
s.is(RegExp),
|
|
1274
|
-
s.transform(s.string().role("regexp", { flag: d }), (m, h) => {
|
|
1275
|
-
try {
|
|
1276
|
-
return new RegExp(m, d);
|
|
1277
|
-
} catch (w) {
|
|
1278
|
-
throw new i(w.message, h);
|
|
1279
|
-
}
|
|
1280
|
-
}, !0)
|
|
1281
|
-
]);
|
|
1282
|
-
}, "regExp"), s.arrayBuffer = /* @__PURE__ */ F(function(d) {
|
|
1283
|
-
return s.union([
|
|
1284
|
-
s.is(ArrayBuffer),
|
|
1285
|
-
s.is(SharedArrayBuffer),
|
|
1286
|
-
s.transform(s.any(), (m, h) => {
|
|
1287
|
-
if (re.isSource(m)) return re.fromSource(m);
|
|
1288
|
-
throw new i(`expected ArrayBufferSource but got ${m}`, h);
|
|
1289
|
-
}, !0),
|
|
1290
|
-
...d ? [s.transform(s.string(), (m, h) => {
|
|
1291
|
-
try {
|
|
1292
|
-
return d === "base64" ? re.fromBase64(m) : re.fromHex(m);
|
|
1293
|
-
} catch (w) {
|
|
1294
|
-
throw new i(w.message, h);
|
|
1295
|
-
}
|
|
1296
|
-
}, !0)] : []
|
|
1297
|
-
]);
|
|
1298
|
-
}, "arrayBuffer"), s.extend("lazy", (f, d, m, h) => (d.inner[t] || (d.inner = d.builder(), d.inner.meta = { ...d.meta, ...d.inner.meta }), s.resolve(f, d.inner, m, h))), s.extend("any", (f) => [f]), s.extend("never", (f, d, m) => {
|
|
1299
|
-
throw new i(`expected nullable but got ${f}`, m);
|
|
1300
|
-
}), s.extend("const", (f, { value: d }, m) => {
|
|
1301
|
-
if (he(f, d)) return [d];
|
|
1302
|
-
throw new i(`expected ${d} but got ${f}`, m);
|
|
1303
|
-
});
|
|
1304
|
-
function b(f, d, m, h, w = !1) {
|
|
1305
|
-
const { max: x = 1 / 0, min: A = -1 / 0 } = d;
|
|
1306
|
-
if (f > x) throw new i(`expected ${m} <= ${x} but got ${f}`, h);
|
|
1307
|
-
if (f < A && !w) throw new i(`expected ${m} >= ${A} but got ${f}`, h);
|
|
1308
|
-
}
|
|
1309
|
-
F(b, "checkWithinRange"), s.extend("string", (f, { meta: d }, m) => {
|
|
1310
|
-
if (typeof f != "string") throw new i(`expected string but got ${f}`, m);
|
|
1311
|
-
if (d.pattern) {
|
|
1312
|
-
const h = new RegExp(d.pattern.source, d.pattern.flags);
|
|
1313
|
-
if (!h.test(f)) throw new i(`expect string to match regexp ${h}`, m);
|
|
1314
|
-
}
|
|
1315
|
-
return b(f.length, d, "string length", m), [f];
|
|
1316
|
-
});
|
|
1317
|
-
function T(f, d) {
|
|
1318
|
-
const m = f.toString();
|
|
1319
|
-
if (m.includes("e")) return f * Math.pow(10, d);
|
|
1320
|
-
const h = m.indexOf(".");
|
|
1321
|
-
if (h === -1) return f * Math.pow(10, d);
|
|
1322
|
-
const w = m.slice(h + 1), x = m.slice(0, h);
|
|
1323
|
-
return w.length <= d ? +(x + w.padEnd(d, "0")) : +(x + w.slice(0, d) + "." + w.slice(d));
|
|
1324
|
-
}
|
|
1325
|
-
F(T, "decimalShift");
|
|
1326
|
-
function P(f, d, m) {
|
|
1327
|
-
if (m = Math.abs(m), !/^\d+\.\d+$/.test(m.toString()))
|
|
1328
|
-
return (f - d) % m === 0;
|
|
1329
|
-
const h = m.toString().indexOf("."), w = m.toString().slice(h + 1).length;
|
|
1330
|
-
return Math.abs(T(f, w) - T(d, w)) % T(m, w) === 0;
|
|
1331
|
-
}
|
|
1332
|
-
F(P, "isMultipleOf"), s.extend("number", (f, { meta: d }, m) => {
|
|
1333
|
-
if (typeof f != "number") throw new i(`expected number but got ${f}`, m);
|
|
1334
|
-
b(f, d, "number", m);
|
|
1335
|
-
const { step: h } = d;
|
|
1336
|
-
if (h && !P(f, d.min ?? 0, h))
|
|
1337
|
-
throw new i(`expected number multiple of ${h} but got ${f}`, m);
|
|
1338
|
-
return [f];
|
|
1339
|
-
}), s.extend("boolean", (f, d, m) => {
|
|
1340
|
-
if (typeof f == "boolean") return [f];
|
|
1341
|
-
throw new i(`expected boolean but got ${f}`, m);
|
|
1342
|
-
}), s.extend("bitset", (f, { bits: d, meta: m }, h) => {
|
|
1343
|
-
let w = 0, x = [];
|
|
1344
|
-
if (typeof f == "number") {
|
|
1345
|
-
w = f;
|
|
1346
|
-
for (const A in d)
|
|
1347
|
-
f & d[A] && x.push(A);
|
|
1348
|
-
} else if (Array.isArray(f)) {
|
|
1349
|
-
x = f;
|
|
1350
|
-
for (const A of x) {
|
|
1351
|
-
if (typeof A != "string") throw new i(`expected string but got ${A}`, h);
|
|
1352
|
-
A in d && (w |= d[A]);
|
|
1353
|
-
}
|
|
1354
|
-
} else
|
|
1355
|
-
throw new i(`expected number or array but got ${f}`, h);
|
|
1356
|
-
return w === m.default ? [w] : [w, x];
|
|
1357
|
-
}), s.extend("function", (f, d, m) => {
|
|
1358
|
-
if (typeof f == "function") return [f];
|
|
1359
|
-
throw new i(`expected function but got ${f}`, m);
|
|
1360
|
-
}), s.extend("is", (f, { constructor: d }, m) => {
|
|
1361
|
-
if (typeof d == "function") {
|
|
1362
|
-
if (f instanceof d) return [f];
|
|
1363
|
-
throw new i(`expected ${d.name} but got ${f}`, m);
|
|
1364
|
-
} else {
|
|
1365
|
-
if (z(f))
|
|
1366
|
-
throw new i(`expected ${d} but got ${f}`, m);
|
|
1367
|
-
let h = Object.getPrototypeOf(f);
|
|
1368
|
-
for (; h; ) {
|
|
1369
|
-
if (h.constructor?.name === d) return [f];
|
|
1370
|
-
h = Object.getPrototypeOf(h);
|
|
1371
|
-
}
|
|
1372
|
-
throw new i(`expected ${d} but got ${f}`, m);
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
function L(f, d, m, h) {
|
|
1376
|
-
try {
|
|
1377
|
-
const [w, x] = s.resolve(f[d], m, {
|
|
1378
|
-
...h,
|
|
1379
|
-
path: [...h.path || [], d]
|
|
1380
|
-
});
|
|
1381
|
-
return x !== void 0 && (f[d] = x), w;
|
|
1382
|
-
} catch (w) {
|
|
1383
|
-
if (!h?.autofix) throw w;
|
|
1384
|
-
return delete f[d], m.meta.default;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
F(L, "property"), s.extend("array", (f, { inner: d, meta: m }, h) => {
|
|
1388
|
-
if (!Array.isArray(f)) throw new i(`expected array but got ${f}`, h);
|
|
1389
|
-
return b(f.length, m, "array length", h, !z(d.meta.default)), [f.map((w, x) => L(f, x, d, h))];
|
|
1390
|
-
}), s.extend("dict", (f, { inner: d, sKey: m }, h, w) => {
|
|
1391
|
-
if (!Be(f)) throw new i(`expected object but got ${f}`, h);
|
|
1392
|
-
const x = {};
|
|
1393
|
-
for (const A in f) {
|
|
1394
|
-
let $;
|
|
1395
|
-
try {
|
|
1396
|
-
$ = s.resolve(A, m, h)[0];
|
|
1397
|
-
} catch (V) {
|
|
1398
|
-
if (w) continue;
|
|
1399
|
-
throw V;
|
|
1400
|
-
}
|
|
1401
|
-
x[$] = L(f, A, d, h), f[$] = f[A], A !== $ && delete f[A];
|
|
1402
|
-
}
|
|
1403
|
-
return [x];
|
|
1404
|
-
}), s.extend("tuple", (f, { list: d }, m, h) => {
|
|
1405
|
-
if (!Array.isArray(f)) throw new i(`expected array but got ${f}`, m);
|
|
1406
|
-
const w = d.map((x, A) => L(f, A, x, m));
|
|
1407
|
-
return h ? [w] : (w.push(...f.slice(d.length)), [w]);
|
|
1408
|
-
});
|
|
1409
|
-
function Y(f, d) {
|
|
1410
|
-
for (const m in d)
|
|
1411
|
-
m in f || (f[m] = d[m]);
|
|
1412
|
-
}
|
|
1413
|
-
F(Y, "merge"), s.extend("object", (f, { dict: d }, m, h) => {
|
|
1414
|
-
if (!Be(f)) throw new i(`expected object but got ${f}`, m);
|
|
1415
|
-
const w = {};
|
|
1416
|
-
for (const x in d) {
|
|
1417
|
-
const A = L(f, x, d[x], m);
|
|
1418
|
-
(!z(A) || x in f) && (w[x] = A);
|
|
1419
|
-
}
|
|
1420
|
-
return h || Y(w, f), [w];
|
|
1421
|
-
}), s.extend("union", (f, { list: d, toString: m }, h, w) => {
|
|
1422
|
-
for (const x of d)
|
|
1423
|
-
try {
|
|
1424
|
-
return s.resolve(f, x, h, w);
|
|
1425
|
-
} catch {
|
|
1426
|
-
}
|
|
1427
|
-
throw new i(`expected ${m()} but got ${JSON.stringify(f)}`, h);
|
|
1428
|
-
}), s.extend("intersect", (f, { list: d, toString: m }, h, w) => {
|
|
1429
|
-
let x;
|
|
1430
|
-
for (const A of d) {
|
|
1431
|
-
const $ = s.resolve(f, A, h, !0)[0];
|
|
1432
|
-
if (!z($))
|
|
1433
|
-
if (z(x))
|
|
1434
|
-
x = $;
|
|
1435
|
-
else {
|
|
1436
|
-
if (typeof x != typeof $)
|
|
1437
|
-
throw new i(`expected ${m()} but got ${JSON.stringify(f)}`, h);
|
|
1438
|
-
if (typeof $ == "object")
|
|
1439
|
-
Y(x ??= {}, $);
|
|
1440
|
-
else if (x !== $)
|
|
1441
|
-
throw new i(`expected ${m()} but got ${JSON.stringify(f)}`, h);
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
return !w && Be(f) && Y(x, f), [x];
|
|
1445
|
-
}), s.extend("transform", (f, { inner: d, callback: m, preserve: h }, w) => {
|
|
1446
|
-
const [x, A = f] = s.resolve(f, d, w, !0);
|
|
1447
|
-
return h ? [m(x)] : [m(x), m(A)];
|
|
1448
|
-
});
|
|
1449
|
-
var W = {};
|
|
1450
|
-
function U(f, d, m) {
|
|
1451
|
-
W[f] = m, Object.assign(s, {
|
|
1452
|
-
[f](...h) {
|
|
1453
|
-
const w = new s({ type: f });
|
|
1454
|
-
return d.forEach((x, A) => {
|
|
1455
|
-
switch (x) {
|
|
1456
|
-
case "sKey":
|
|
1457
|
-
w.sKey = h[A] ?? s.string();
|
|
1458
|
-
break;
|
|
1459
|
-
case "inner":
|
|
1460
|
-
w.inner = s.from(h[A]);
|
|
1461
|
-
break;
|
|
1462
|
-
case "list":
|
|
1463
|
-
w.list = h[A].map(s.from);
|
|
1464
|
-
break;
|
|
1465
|
-
case "dict":
|
|
1466
|
-
w.dict = se(h[A], s.from);
|
|
1467
|
-
break;
|
|
1468
|
-
case "bits": {
|
|
1469
|
-
w.bits = {};
|
|
1470
|
-
for (const $ in h[A])
|
|
1471
|
-
typeof h[A][$] == "number" && (w.bits[$] = h[A][$]);
|
|
1472
|
-
break;
|
|
1473
|
-
}
|
|
1474
|
-
case "callback": {
|
|
1475
|
-
const $ = w.callback = h[A];
|
|
1476
|
-
$.toJSON ||= () => $.toString();
|
|
1477
|
-
break;
|
|
1478
|
-
}
|
|
1479
|
-
case "constructor": {
|
|
1480
|
-
const $ = w.constructor = h[A];
|
|
1481
|
-
typeof $ == "function" && ($.toJSON ||= () => $.name);
|
|
1482
|
-
break;
|
|
1483
|
-
}
|
|
1484
|
-
default:
|
|
1485
|
-
w[x] = h[A];
|
|
1486
|
-
}
|
|
1487
|
-
}), f === "object" || f === "dict" ? w.meta.default = {} : f === "array" || f === "tuple" ? w.meta.default = [] : f === "bitset" && (w.meta.default = 0), w;
|
|
1488
|
-
}
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
F(U, "defineMethod"), U("is", ["constructor"], ({ constructor: f }) => typeof f == "function" ? f.name : f), U("any", [], () => "any"), U("never", [], () => "never"), U("const", ["value"], ({ value: f }) => typeof f == "string" ? JSON.stringify(f) : f), U("string", [], () => "string"), U("number", [], () => "number"), U("boolean", [], () => "boolean"), U("bitset", ["bits"], () => "bitset"), U("function", [], () => "function"), U("array", ["inner"], ({ inner: f }) => `${f.toString(!0)}[]`), U("dict", ["inner", "sKey"], ({ inner: f, sKey: d }) => `{ [key: ${d.toString()}]: ${f.toString()} }`), U("tuple", ["list"], ({ list: f }) => `[${f.map((d) => d.toString()).join(", ")}]`), U("object", ["dict"], ({ dict: f }) => Object.keys(f).length === 0 ? "{}" : `{ ${Object.entries(f).map(([d, m]) => `${d}${m.meta.required ? "" : "?"}: ${m.toString()}`).join(", ")} }`), U("union", ["list"], ({ list: f }, d) => {
|
|
1492
|
-
const m = f.map(({ toString: h }) => h()).join(" | ");
|
|
1493
|
-
return d ? `(${m})` : m;
|
|
1494
|
-
}), U("intersect", ["list"], ({ list: f }) => `${f.map((d) => d.toString(!0)).join(" & ")}`), U("transform", ["inner", "callback", "preserve"], ({ inner: f }, d) => f.toString(d)), e.exports = s;
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
const Kn = Yn();
|
|
1498
|
-
/**
|
|
1499
|
-
* @inpageedit/logger
|
|
1500
|
-
*
|
|
1501
|
-
* Flexible, Extensible Console Logger with Colored Labels and Hierarchical Loggers
|
|
1502
|
-
*
|
|
1503
|
-
* @author dragon-fish <dragon-fish@qq.com>
|
|
1504
|
-
* @license MIT
|
|
1505
|
-
*/
|
|
1506
|
-
var cr = /* @__PURE__ */ ((r) => (r[r.debug = -1] = "debug", r[r.log = 0] = "log", r[r.info = 1] = "info", r[r.warn = 2] = "warn", r[r.error = 3] = "error", r[r.silent = 4] = "silent", r))(cr || {});
|
|
1507
|
-
const ut = globalThis || window, ft = Symbol.for("__IPE_LOGGER_COLOR_MAP__");
|
|
1508
|
-
ut[ft] || (ut[ft] = /* @__PURE__ */ new Map());
|
|
1509
|
-
const et = ut[ft];
|
|
1510
|
-
function Ne(r) {
|
|
1511
|
-
let e = 2166136261;
|
|
1512
|
-
for (let t = 0; t < r.length; t++)
|
|
1513
|
-
e ^= r.charCodeAt(t), e = (e >>> 0) * 16777619;
|
|
1514
|
-
return e >>> 0;
|
|
1515
|
-
}
|
|
1516
|
-
const Ht = [
|
|
1517
|
-
[350, 360],
|
|
1518
|
-
[0, 15],
|
|
1519
|
-
[15, 30],
|
|
1520
|
-
[200, 230],
|
|
1521
|
-
[230, 250],
|
|
1522
|
-
[250, 280],
|
|
1523
|
-
[280, 310],
|
|
1524
|
-
[310, 330],
|
|
1525
|
-
[140, 160],
|
|
1526
|
-
[160, 180]
|
|
1527
|
-
];
|
|
1528
|
-
function Gn(r, e) {
|
|
1529
|
-
const t = Ht.length, n = Ne(r) % t, [i, s] = Ht[n], c = s - i, u = Ne(r + ":" + e), v = i + u % (c || 1), _ = Ne(r + ":s"), E = Ne(r + ":l");
|
|
1530
|
-
let b, T;
|
|
1531
|
-
if (e === "name")
|
|
1532
|
-
b = 62 + _ % 18, T = 30 + E % 12;
|
|
1533
|
-
else {
|
|
1534
|
-
const P = v >= 0 && v < 50 || v > 330 && v < 360, L = v >= 200 && v <= 300;
|
|
1535
|
-
b = 55 + _ % 20, L ? T = 55 + E % 8 : P ? T = 48 + E % 6 : T = 50 + E % 8, b < 60 && (b += 5);
|
|
1536
|
-
}
|
|
1537
|
-
return `hsl(${v}, ${b}%, ${T}%)`;
|
|
1538
|
-
}
|
|
1539
|
-
function Ce(r, e) {
|
|
1540
|
-
if (e)
|
|
1541
|
-
return et.set(r, e), e;
|
|
1542
|
-
const t = et.get(r);
|
|
1543
|
-
if (t) return t;
|
|
1544
|
-
const n = r.startsWith("name:") ? "name" : "group", i = Gn(r, n);
|
|
1545
|
-
return et.set(r, i), i;
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* @inpageedit/logger
|
|
1549
|
-
* Flexible, Extensible Console Logger with Colored Labels and Hierarchical Loggers
|
|
1550
|
-
*
|
|
1551
|
-
* @author dragon-fish <dragon-fish@qq.com>
|
|
1552
|
-
* @license MIT
|
|
1553
|
-
*
|
|
1554
|
-
* @example
|
|
1555
|
-
* ```ts
|
|
1556
|
-
* const logger = new Logger({ name: 'MyApp', level: LoggerLevel.debug })
|
|
1557
|
-
* // normal usage
|
|
1558
|
-
* logger.info('Application started')
|
|
1559
|
-
* // create sub-logger group
|
|
1560
|
-
* const apiLogger = logger.group('API', { color: '#f59e0b' })
|
|
1561
|
-
* apiLogger.warn('Deprecated API endpoint used')
|
|
1562
|
-
* // define custom level
|
|
1563
|
-
* logger.defineLevel('success', { level: LoggerLevel.info, label: '✅', method: 'info' })
|
|
1564
|
-
* logger.success('User created successfully')
|
|
1565
|
-
* ```
|
|
1566
|
-
*/
|
|
1567
|
-
class mt {
|
|
1568
|
-
/**
|
|
1569
|
-
* Note: constructor returns a callable Proxy so that you can do `logger('group')`.
|
|
1570
|
-
*/
|
|
1571
|
-
constructor(e = {}) {
|
|
1572
|
-
this._custom = (t) => {
|
|
1573
|
-
if (!this._enabled(t.level)) return zt;
|
|
1574
|
-
const [n, i] = this._prefix(t.label);
|
|
1575
|
-
return this._consoleMethod(t.method).bind(console, n, ...i);
|
|
1576
|
-
}, this._name = e.name, this._nameColor = e.color, this._groupPath = e._groupPath ? [...e._groupPath] : [], this._dynamicLevels = { ...e._dynamicLevels }, this._levelRef = e._levelRef ?? {
|
|
1577
|
-
value: e.level ?? 1
|
|
1578
|
-
/* info */
|
|
1579
|
-
}, this._name && Ce(`name:${this._name}`, this._nameColor), this._installBuiltinLevels();
|
|
1580
|
-
for (const t of Object.keys(this._dynamicLevels))
|
|
1581
|
-
this._installLevelGetter(t, this._dynamicLevels[t]);
|
|
1582
|
-
return Jn(this);
|
|
1583
|
-
}
|
|
1584
|
-
// ---------- public API ----------
|
|
1585
|
-
get level() {
|
|
1586
|
-
return this._levelRef.value;
|
|
1587
|
-
}
|
|
1588
|
-
set level(e) {
|
|
1589
|
-
this._levelRef.value = e;
|
|
1590
|
-
}
|
|
1591
|
-
/** Create a sub-logger with a group label */
|
|
1592
|
-
group(e, t) {
|
|
1593
|
-
return e && Ce(`group:${e}`, t?.color), new mt({
|
|
1594
|
-
name: this._name,
|
|
1595
|
-
color: this._nameColor,
|
|
1596
|
-
_groupPath: [...this._groupPath, e],
|
|
1597
|
-
_dynamicLevels: this._dynamicLevels,
|
|
1598
|
-
_levelRef: this._levelRef
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
/** Define a custom level, e.g. logger.defineLevel('success', { level: info, label: '✅', method: 'info' }) */
|
|
1602
|
-
defineLevel(e, t) {
|
|
1603
|
-
this._dynamicLevels[e] = { ...t }, this._installLevelGetter(e, t);
|
|
1604
|
-
}
|
|
1605
|
-
// Built-in level getters
|
|
1606
|
-
get debug() {
|
|
1607
|
-
return this._method("debug");
|
|
1608
|
-
}
|
|
1609
|
-
get log() {
|
|
1610
|
-
return this._method("log");
|
|
1611
|
-
}
|
|
1612
|
-
get info() {
|
|
1613
|
-
return this._method("info");
|
|
1614
|
-
}
|
|
1615
|
-
get warn() {
|
|
1616
|
-
return this._method("warn");
|
|
1617
|
-
}
|
|
1618
|
-
get error() {
|
|
1619
|
-
return this._method("error");
|
|
1620
|
-
}
|
|
1621
|
-
// ---------- internals ----------
|
|
1622
|
-
_installBuiltinLevels() {
|
|
1623
|
-
}
|
|
1624
|
-
_installLevelGetter(e, t) {
|
|
1625
|
-
Object.defineProperty(this, e, {
|
|
1626
|
-
configurable: !0,
|
|
1627
|
-
enumerable: !1,
|
|
1628
|
-
get: () => this._custom(t)
|
|
1629
|
-
});
|
|
1630
|
-
}
|
|
1631
|
-
_method(e) {
|
|
1632
|
-
const t = Vn[e];
|
|
1633
|
-
if (!this._enabled(t.level)) return zt;
|
|
1634
|
-
const [n, i] = this._prefix(t.label);
|
|
1635
|
-
return this._consoleMethod(e).bind(console, n, ...i);
|
|
1636
|
-
}
|
|
1637
|
-
_consoleMethod(e) {
|
|
1638
|
-
return (console[e] || console.log).bind(console);
|
|
1639
|
-
}
|
|
1640
|
-
_enabled(e) {
|
|
1641
|
-
return e >= this._levelRef.value && this._levelRef.value !== 4;
|
|
1642
|
-
}
|
|
1643
|
-
_prefix(e) {
|
|
1644
|
-
const t = [];
|
|
1645
|
-
let n = "";
|
|
1646
|
-
if (this._name) {
|
|
1647
|
-
const i = Ce(`name:${this._name}`, this._nameColor);
|
|
1648
|
-
n += `%c${this._name}%c`, t.push(
|
|
1649
|
-
`background:${i}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,
|
|
1650
|
-
Yt
|
|
1651
|
-
);
|
|
1652
|
-
}
|
|
1653
|
-
if (e && (n += ` ${e}`), this._groupPath.length) {
|
|
1654
|
-
const i = this._groupPath.join("/"), s = Ce(`group:${i}`);
|
|
1655
|
-
n += ` %c${i}%c`, t.push(`color:${s}; text-decoration: underline;`, Yt);
|
|
1656
|
-
}
|
|
1657
|
-
return [n, t];
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
const zt = () => {
|
|
1661
|
-
}, Yt = "color:inherit; background:transparent; text-decoration:none;", Vn = {
|
|
1662
|
-
debug: { level: -1, label: "", method: "debug" },
|
|
1663
|
-
log: { level: 0, label: "", method: "log" },
|
|
1664
|
-
info: { level: 1, label: "[I]", method: "info" },
|
|
1665
|
-
warn: { level: 2, label: "[W]", method: "warn" },
|
|
1666
|
-
error: { level: 3, label: "[E]", method: "error" }
|
|
1667
|
-
};
|
|
1668
|
-
function Jn(r) {
|
|
1669
|
-
const e = function(t, n) {
|
|
1670
|
-
return r.group(t, n);
|
|
1671
|
-
};
|
|
1672
|
-
return new Proxy(e, {
|
|
1673
|
-
get(t, n, i) {
|
|
1674
|
-
return r[n];
|
|
1675
|
-
},
|
|
1676
|
-
set(t, n, i) {
|
|
1677
|
-
return r[n] = i, !0;
|
|
1678
|
-
},
|
|
1679
|
-
apply(t, n, i) {
|
|
1680
|
-
return r.group(i[0], i[1]);
|
|
1681
|
-
},
|
|
1682
|
-
has(t, n) {
|
|
1683
|
-
return n in r;
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
function Qn(r) {
|
|
1688
|
-
return new mt(r);
|
|
1689
|
-
}
|
|
1690
|
-
var X = /* @__PURE__ */ ((r) => (r.BODY_USED = "BODY_USED", r.NO_BODY_READER = "NO_BODY_READER", r.TIMEOUT = "TIMEOUT", r.NETWORK_ERROR = "NETWORK_ERROR", r.BODY_NOT_ALLOWED = "BODY_NOT_ALLOWED", r.HOOK_CONTEXT_CHANGED = "HOOK_CONTEXT_CHANGED", r.ABORTED_BY_HOOK = "ABORTED_BY_HOOK", r.INVALID_HOOK_CALLBACK = "INVALID_HOOK_CALLBACK", r.UNEXPECTED_HOOK_RETURN = "UNEXPECTED_HOOK_RETURN", r))(X || {});
|
|
1691
|
-
class J extends Error {
|
|
1692
|
-
constructor(e, t, n, i) {
|
|
1693
|
-
super(t, i), this.code = e, this.context = n, this.name = "FexiosError";
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
class Xn extends J {
|
|
1697
|
-
constructor(e, t, n) {
|
|
1698
|
-
super(t.statusText, e, void 0, n), this.response = t, this.name = "FexiosResponseError";
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
function Zn(r, e = 2048) {
|
|
1702
|
-
if (!(r instanceof Uint8Array))
|
|
1703
|
-
throw new TypeError("Input must be a Uint8Array");
|
|
1704
|
-
if (r.length === 0)
|
|
1705
|
-
return !0;
|
|
1706
|
-
const t = Math.min(
|
|
1707
|
-
Math.max(r.length, 256),
|
|
1708
|
-
e
|
|
1709
|
-
), n = r.slice(0, t);
|
|
1710
|
-
if (ei(n))
|
|
1711
|
-
return !1;
|
|
1712
|
-
const i = ti(n);
|
|
1713
|
-
if (i.nullByteRatio > 0.05 || i.highByteRatio > 0.95)
|
|
1714
|
-
return !1;
|
|
1715
|
-
const s = ["utf-8", "utf-16le", "utf-16be", "iso-8859-1"];
|
|
1716
|
-
let c = -1, u = !1;
|
|
1717
|
-
for (const v of s)
|
|
1718
|
-
try {
|
|
1719
|
-
const _ = new TextDecoder(v, { fatal: !0 }).decode(n), E = ri(_);
|
|
1720
|
-
E > c && (c = E, u = E > 0.7);
|
|
1721
|
-
} catch {
|
|
1722
|
-
continue;
|
|
1723
|
-
}
|
|
1724
|
-
return u;
|
|
1725
|
-
}
|
|
1726
|
-
function ei(r) {
|
|
1727
|
-
if (r.length < 4) return !1;
|
|
1728
|
-
const e = [
|
|
1729
|
-
[137, 80, 78, 71],
|
|
1730
|
-
// PNG
|
|
1731
|
-
[255, 216, 255],
|
|
1732
|
-
// JPEG
|
|
1733
|
-
[71, 73, 70],
|
|
1734
|
-
// GIF
|
|
1735
|
-
[37, 80, 68, 70],
|
|
1736
|
-
// PDF
|
|
1737
|
-
[80, 75, 3, 4],
|
|
1738
|
-
// ZIP/Office documents
|
|
1739
|
-
[80, 75, 5, 6],
|
|
1740
|
-
// ZIP empty archive
|
|
1741
|
-
[80, 75, 7, 8],
|
|
1742
|
-
// ZIP spanned archive
|
|
1743
|
-
[127, 69, 76, 70],
|
|
1744
|
-
// ELF executable
|
|
1745
|
-
[77, 90],
|
|
1746
|
-
// Windows executable
|
|
1747
|
-
[202, 254, 186, 190],
|
|
1748
|
-
// Java class file
|
|
1749
|
-
[0, 0, 1, 0],
|
|
1750
|
-
// ICO
|
|
1751
|
-
[82, 73, 70, 70]
|
|
1752
|
-
// RIFF (AVI, WAV, etc.)
|
|
1753
|
-
];
|
|
1754
|
-
for (const t of e)
|
|
1755
|
-
if (r.length >= t.length) {
|
|
1756
|
-
let n = !0;
|
|
1757
|
-
for (let i = 0; i < t.length; i++)
|
|
1758
|
-
if (r[i] !== t[i]) {
|
|
1759
|
-
n = !1;
|
|
1760
|
-
break;
|
|
1761
|
-
}
|
|
1762
|
-
if (n) return !0;
|
|
1763
|
-
}
|
|
1764
|
-
return !1;
|
|
1765
|
-
}
|
|
1766
|
-
function ti(r) {
|
|
1767
|
-
let e = 0, t = 0, n = 0;
|
|
1768
|
-
for (const i of r)
|
|
1769
|
-
i === 0 && e++, i > 127 && t++, (i < 32 && i !== 9 && i !== 10 && i !== 13 || i === 127) && n++;
|
|
1770
|
-
return {
|
|
1771
|
-
nullByteRatio: e / r.length,
|
|
1772
|
-
highByteRatio: t / r.length,
|
|
1773
|
-
controlCharRatio: n / r.length
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
function ri(r) {
|
|
1777
|
-
if (r.length === 0) return 1;
|
|
1778
|
-
let e = 1, t = 0;
|
|
1779
|
-
for (let i = 0; i < r.length; i++) {
|
|
1780
|
-
const s = r[i].charCodeAt(0);
|
|
1781
|
-
s >= 32 && s <= 126 || s === 9 || s === 10 || s === 13 || s === 32 ? t++ : s > 127 && s < 65534 ? !ni(s) && !ii(s) && t++ : e -= 0.1;
|
|
1782
|
-
}
|
|
1783
|
-
const n = t / r.length;
|
|
1784
|
-
return e *= n, oi(r) && (e *= 1.1), Math.max(0, Math.min(1, e));
|
|
1785
|
-
}
|
|
1786
|
-
function ni(r) {
|
|
1787
|
-
return r >= 0 && r <= 31 || r >= 127 && r <= 159;
|
|
1788
|
-
}
|
|
1789
|
-
function ii(r) {
|
|
1790
|
-
return r >= 57344 && r <= 63743 || r >= 983040 && r <= 1048573 || r >= 1048576 && r <= 1114109;
|
|
1791
|
-
}
|
|
1792
|
-
function oi(r) {
|
|
1793
|
-
return [
|
|
1794
|
-
/\b\w+\b/,
|
|
1795
|
-
// Words
|
|
1796
|
-
/[.!?]+\s/,
|
|
1797
|
-
// Sentence endings
|
|
1798
|
-
/\s+/,
|
|
1799
|
-
// Whitespace
|
|
1800
|
-
/[a-zA-Z]{3,}/,
|
|
1801
|
-
// English words
|
|
1802
|
-
/[\u4e00-\u9fa5]+/,
|
|
1803
|
-
// Chinese characters
|
|
1804
|
-
/\d+/
|
|
1805
|
-
// Numbers
|
|
1806
|
-
].some((e) => e.test(r));
|
|
1807
|
-
}
|
|
1808
|
-
function tt(r) {
|
|
1809
|
-
if (typeof r != "object" || r === null || Object.prototype.toString.call(r) !== "[object Object]")
|
|
1810
|
-
return !1;
|
|
1811
|
-
const e = Object.getPrototypeOf(r);
|
|
1812
|
-
return e === Object.prototype || e === null;
|
|
1813
|
-
}
|
|
1814
|
-
function Kt(r, e = {}) {
|
|
1815
|
-
const t = {};
|
|
1816
|
-
return Object.entries(r).forEach(([n, i]) => {
|
|
1817
|
-
i != null && (e.dropEmptyString && i === "" || (t[n] = i));
|
|
1818
|
-
}), t;
|
|
1819
|
-
}
|
|
1820
|
-
class xe {
|
|
1821
|
-
constructor(e, t, n) {
|
|
1822
|
-
this.rawResponse = e, this.data = t, this.ok = e.ok, this.status = e.status, this.statusText = e.statusText, this.headers = e.headers, Object.entries(n || {}).forEach(([i, s]) => {
|
|
1823
|
-
this[i] = s;
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
async function si(r, e, t) {
|
|
1828
|
-
var n;
|
|
1829
|
-
if (r.bodyUsed)
|
|
1830
|
-
throw new J(
|
|
1831
|
-
X.BODY_USED,
|
|
1832
|
-
"Response body has already been used or locked"
|
|
1833
|
-
);
|
|
1834
|
-
const i = r.headers.get("content-type") || "", s = Number(r.headers.get("content-length")) || 0, c = (v, _) => _ === "json" || v.startsWith("application/json"), u = (v, _, E) => E === "blob" || v.startsWith("image/") && !v.startsWith("image/svg") || v.startsWith("video/") || v.startsWith("audio/") || !Zn(_);
|
|
1835
|
-
if ((r.status === 101 || r.status === 426 || r.headers.get("upgrade")) && typeof globalThis.WebSocket < "u") {
|
|
1836
|
-
const v = new WebSocket(r.url);
|
|
1837
|
-
return await new Promise((_, E) => {
|
|
1838
|
-
v.onopen = _, v.onerror = E;
|
|
1839
|
-
}), new xe(r, v, {
|
|
1840
|
-
ok: !0,
|
|
1841
|
-
status: 101,
|
|
1842
|
-
statusText: "Switching Protocols"
|
|
1843
|
-
});
|
|
1844
|
-
} else if (i.startsWith("text/event-stream") && !["text", "json"].includes(e || "") && typeof globalThis.EventSource < "u") {
|
|
1845
|
-
const v = new EventSource(r.url);
|
|
1846
|
-
return await new Promise((_, E) => {
|
|
1847
|
-
v.onopen = _, v.onerror = E;
|
|
1848
|
-
}), new xe(r, v);
|
|
1849
|
-
} else {
|
|
1850
|
-
if (e === "stream")
|
|
1851
|
-
return new xe(
|
|
1852
|
-
r,
|
|
1853
|
-
r.body
|
|
1854
|
-
);
|
|
1855
|
-
{
|
|
1856
|
-
const v = (n = r.clone().body) == null ? void 0 : n.getReader();
|
|
1857
|
-
if (!v)
|
|
1858
|
-
throw new J(
|
|
1859
|
-
X.NO_BODY_READER,
|
|
1860
|
-
"Failed to get ReadableStream from response body"
|
|
1861
|
-
);
|
|
1862
|
-
let _ = new Uint8Array();
|
|
1863
|
-
for (; ; ) {
|
|
1864
|
-
const { done: b, value: T } = await v.read();
|
|
1865
|
-
if (b) break;
|
|
1866
|
-
if (T && (_ = new Uint8Array([..._, ...T]), t && s > 0)) {
|
|
1867
|
-
const P = Math.min(_.length / s, 1);
|
|
1868
|
-
t(P, _);
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
const E = new xe(r, void 0);
|
|
1872
|
-
if (e === "arrayBuffer")
|
|
1873
|
-
return E.data = _.buffer, E;
|
|
1874
|
-
if (c(i, e))
|
|
1875
|
-
try {
|
|
1876
|
-
const b = new TextDecoder().decode(_);
|
|
1877
|
-
E.data = JSON.parse(b);
|
|
1878
|
-
} catch {
|
|
1879
|
-
}
|
|
1880
|
-
if (typeof E.data != "string" && u(i, _, e) ? E.data = new Blob([_], {
|
|
1881
|
-
type: r.headers.get("content-type") || void 0
|
|
1882
|
-
}) : E.data = new TextDecoder().decode(_), typeof E.data == "string" && e !== "text") {
|
|
1883
|
-
const b = E.data.trim(), T = b[0], P = b[b.length - 1];
|
|
1884
|
-
if (T === "{" && P === "}" || T === "[" && P === "]")
|
|
1885
|
-
try {
|
|
1886
|
-
E.data = JSON.parse(E.data);
|
|
1887
|
-
} catch {
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
if (typeof E.data > "u" && (E.data = _.length > 0 ? _ : void 0), E.ok)
|
|
1891
|
-
return E;
|
|
1892
|
-
throw new Xn(
|
|
1893
|
-
`Request failed with status code ${r.status}`,
|
|
1894
|
-
E
|
|
1895
|
-
);
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
class ai {
|
|
1900
|
-
/**
|
|
1901
|
-
* Build URLSearchParams from a record object with proper array handling
|
|
1902
|
-
* @param query - The query object containing key-value pairs
|
|
1903
|
-
* @returns URLSearchParams instance
|
|
1904
|
-
*/
|
|
1905
|
-
static makeSearchParams(e) {
|
|
1906
|
-
const t = new URLSearchParams();
|
|
1907
|
-
return Object.entries(e).forEach(([n, i]) => {
|
|
1908
|
-
Array.isArray(i) ? i.forEach((s) => t.append(n, String(s))) : t.set(n, String(i));
|
|
1909
|
-
}), t;
|
|
1910
|
-
}
|
|
1911
|
-
/**
|
|
1912
|
-
* Build query string from a record object with proper array handling
|
|
1913
|
-
* @param query - The query object containing key-value pairs
|
|
1914
|
-
* @returns URL-encoded query string
|
|
1915
|
-
*/
|
|
1916
|
-
static makeQueryString(e) {
|
|
1917
|
-
return this.makeSearchParams(e).toString();
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
function ci(r) {
|
|
1921
|
-
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
1922
|
-
}
|
|
1923
|
-
var rt, Gt;
|
|
1924
|
-
function ui() {
|
|
1925
|
-
if (Gt) return rt;
|
|
1926
|
-
Gt = 1;
|
|
1927
|
-
function r(e) {
|
|
1928
|
-
var t = this.constructor.prototype[e], n = function() {
|
|
1929
|
-
return t.apply(n, arguments);
|
|
1930
|
-
};
|
|
1931
|
-
return Object.setPrototypeOf(n, this.constructor.prototype), Object.getOwnPropertyNames(t).forEach(function(i) {
|
|
1932
|
-
Object.defineProperty(n, i, Object.getOwnPropertyDescriptor(t, i));
|
|
1933
|
-
}), n;
|
|
1934
|
-
}
|
|
1935
|
-
return r.prototype = Object.create(Function.prototype), rt = r, rt;
|
|
1936
|
-
}
|
|
1937
|
-
var fi = ui();
|
|
1938
|
-
const li = /* @__PURE__ */ ci(fi);
|
|
1939
|
-
class ge extends li {
|
|
1940
|
-
constructor(e = {}) {
|
|
1941
|
-
super("request"), this.baseConfigs = e, this.hooks = [], this.DEFAULT_CONFIGS = {
|
|
1942
|
-
baseURL: "",
|
|
1943
|
-
timeout: 60 * 1e3,
|
|
1944
|
-
credentials: "same-origin",
|
|
1945
|
-
headers: {},
|
|
1946
|
-
query: {},
|
|
1947
|
-
responseType: void 0
|
|
1948
|
-
}, this.ALL_METHODS = [
|
|
1949
|
-
"get",
|
|
1950
|
-
"post",
|
|
1951
|
-
"put",
|
|
1952
|
-
"patch",
|
|
1953
|
-
"delete",
|
|
1954
|
-
"head",
|
|
1955
|
-
"options",
|
|
1956
|
-
"trace"
|
|
1957
|
-
], this.METHODS_WITHOUT_BODY = [
|
|
1958
|
-
"get",
|
|
1959
|
-
"head",
|
|
1960
|
-
"options",
|
|
1961
|
-
"trace"
|
|
1962
|
-
], this.interceptors = {
|
|
1963
|
-
request: this.createInterceptor("beforeRequest"),
|
|
1964
|
-
response: this.createInterceptor("afterResponse")
|
|
1965
|
-
}, this.create = ge.create, this.dropUndefinedAndNull = Kt, this.checkIsPlainObject = tt, this.ALL_METHODS.forEach(this.createMethodShortcut.bind(this));
|
|
1966
|
-
}
|
|
1967
|
-
async request(e, t) {
|
|
1968
|
-
var n, i, s, c;
|
|
1969
|
-
let u = t = t || {};
|
|
1970
|
-
typeof e == "string" || e instanceof URL ? u.url = e.toString() : typeof e == "object" && (u = { ...e, ...u }), u = await this.emit("beforeInit", u);
|
|
1971
|
-
const v = t.baseURL || this.baseConfigs.baseURL || ((n = globalThis.location) == null ? void 0 : n.href), _ = v ? new URL(v, (i = globalThis.location) == null ? void 0 : i.href) : void 0, E = new URL(u.url.toString(), _);
|
|
1972
|
-
u.url = E.href, u.baseURL = _ ? _.href : E.origin, u.headers = this.mergeHeaders(
|
|
1973
|
-
this.baseConfigs.headers,
|
|
1974
|
-
t.headers
|
|
1975
|
-
);
|
|
1976
|
-
const b = _?.searchParams, T = new URLSearchParams(E.searchParams);
|
|
1977
|
-
if (E.search = "", u.url = E.href, u.query = this.mergeQuery(
|
|
1978
|
-
b,
|
|
1979
|
-
// baseURL query (lowest priority)
|
|
1980
|
-
this.baseConfigs.query,
|
|
1981
|
-
// defaultOptions (baseOptions)
|
|
1982
|
-
T,
|
|
1983
|
-
// requestURL query (urlParams)
|
|
1984
|
-
t.query
|
|
1985
|
-
// requestOptions (highest priority)
|
|
1986
|
-
), E.search = ai.makeQueryString(u.query), u.url = E.toString(), this.METHODS_WITHOUT_BODY.includes(
|
|
1987
|
-
(s = u.method) == null ? void 0 : s.toLocaleLowerCase()
|
|
1988
|
-
) && u.body)
|
|
1989
|
-
throw new J(
|
|
1990
|
-
X.BODY_NOT_ALLOWED,
|
|
1991
|
-
`Request method "${u.method}" does not allow body`
|
|
1992
|
-
);
|
|
1993
|
-
u = await this.emit("beforeRequest", u);
|
|
1994
|
-
let P;
|
|
1995
|
-
typeof u.body < "u" && u.body !== null && (u.body instanceof Blob || u.body instanceof FormData || u.body instanceof URLSearchParams ? P = u.body : typeof u.body == "object" && u.body !== null ? (P = JSON.stringify(u.body), u.headers["content-type"] = "application/json") : P = u.body), !((c = t.headers) != null && c["content-type"]) && P && (P instanceof FormData || P instanceof URLSearchParams ? delete u.headers["content-type"] : typeof P == "string" && typeof u.body == "object" ? u.headers["content-type"] = "application/json" : P instanceof Blob && (u.headers["content-type"] = P.type)), u.body = P, u = await this.emit("afterBodyTransformed", u);
|
|
1996
|
-
const L = u.abortController || globalThis.AbortController ? new AbortController() : void 0, Y = new Request(u.url, {
|
|
1997
|
-
method: u.method || "GET",
|
|
1998
|
-
credentials: u.credentials,
|
|
1999
|
-
cache: u.cache,
|
|
2000
|
-
mode: u.mode,
|
|
2001
|
-
headers: u.headers,
|
|
2002
|
-
body: u.body,
|
|
2003
|
-
signal: L?.signal
|
|
2004
|
-
});
|
|
2005
|
-
u.rawRequest = Y, u = await this.emit("beforeActualFetch", u);
|
|
2006
|
-
const W = u.timeout || this.baseConfigs.timeout || 60 * 1e3;
|
|
2007
|
-
if (u.url.startsWith("ws"))
|
|
2008
|
-
try {
|
|
2009
|
-
const f = new WebSocket(u.url);
|
|
2010
|
-
return await new Promise((d, m) => {
|
|
2011
|
-
const h = setTimeout(() => {
|
|
2012
|
-
m(
|
|
2013
|
-
new J(
|
|
2014
|
-
X.TIMEOUT,
|
|
2015
|
-
`WebSocket connection timed out after ${W}ms`,
|
|
2016
|
-
u
|
|
2017
|
-
)
|
|
2018
|
-
);
|
|
2019
|
-
}, W);
|
|
2020
|
-
f.onopen = () => {
|
|
2021
|
-
clearTimeout(h), d();
|
|
2022
|
-
}, f.onerror = (w) => {
|
|
2023
|
-
clearTimeout(h), m(
|
|
2024
|
-
new J(
|
|
2025
|
-
X.NETWORK_ERROR,
|
|
2026
|
-
"WebSocket connection failed",
|
|
2027
|
-
u
|
|
2028
|
-
)
|
|
2029
|
-
);
|
|
2030
|
-
}, f.onclose = (w) => {
|
|
2031
|
-
w.code !== 1e3 && (clearTimeout(h), m(
|
|
2032
|
-
new J(
|
|
2033
|
-
X.NETWORK_ERROR,
|
|
2034
|
-
`WebSocket closed with code ${w.code}`,
|
|
2035
|
-
u
|
|
2036
|
-
)
|
|
2037
|
-
));
|
|
2038
|
-
};
|
|
2039
|
-
}), u.rawResponse = new Response(), u.response = new xe(u.rawResponse, f, {
|
|
2040
|
-
ok: !0,
|
|
2041
|
-
status: 101,
|
|
2042
|
-
statusText: "Switching Protocols"
|
|
2043
|
-
}), u.data = f, u.headers = new Headers(), this.emit("afterResponse", u);
|
|
2044
|
-
} catch (f) {
|
|
2045
|
-
throw f instanceof J ? f : new J(
|
|
2046
|
-
X.NETWORK_ERROR,
|
|
2047
|
-
`WebSocket creation failed: ${f}`,
|
|
2048
|
-
u
|
|
2049
|
-
);
|
|
2050
|
-
}
|
|
2051
|
-
let U;
|
|
2052
|
-
try {
|
|
2053
|
-
L && (U = setTimeout(() => {
|
|
2054
|
-
L.abort();
|
|
2055
|
-
}, W));
|
|
2056
|
-
const f = await fetch(u.rawRequest).catch((d) => {
|
|
2057
|
-
throw U && clearTimeout(U), L != null && L.signal.aborted ? new J(
|
|
2058
|
-
X.TIMEOUT,
|
|
2059
|
-
`Request timed out after ${W}ms`,
|
|
2060
|
-
u
|
|
2061
|
-
) : new J(X.NETWORK_ERROR, d.message, u);
|
|
2062
|
-
});
|
|
2063
|
-
return U && clearTimeout(U), u.rawResponse = f, u.response = await si(
|
|
2064
|
-
f,
|
|
2065
|
-
u.responseType,
|
|
2066
|
-
(d, m) => {
|
|
2067
|
-
var h;
|
|
2068
|
-
(h = t?.onProgress) == null || h.call(t, d, m);
|
|
2069
|
-
}
|
|
2070
|
-
), u.data = u.response.data, u.headers = u.response.headers, this.emit("afterResponse", u);
|
|
2071
|
-
} catch (f) {
|
|
2072
|
-
throw U && clearTimeout(U), f;
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
mergeQuery(e, ...t) {
|
|
2076
|
-
const n = {}, i = (s) => {
|
|
2077
|
-
s && (tt(s) ? Object.entries(s).forEach(([c, u]) => {
|
|
2078
|
-
u == null ? delete n[c] : Array.isArray(u) ? (c.endsWith("[]"), n[c] = u.map(String)) : n[c] = String(u);
|
|
2079
|
-
}) : new URLSearchParams(s).forEach((c, u) => {
|
|
2080
|
-
n[u] = c;
|
|
2081
|
-
}));
|
|
2082
|
-
};
|
|
2083
|
-
return i(e), t.forEach(i), n;
|
|
2084
|
-
}
|
|
2085
|
-
mergeHeaders(e, ...t) {
|
|
2086
|
-
const n = {}, i = new Headers(e);
|
|
2087
|
-
for (const s of t)
|
|
2088
|
-
if (s != null)
|
|
2089
|
-
if (tt(s)) {
|
|
2090
|
-
const c = Kt(s);
|
|
2091
|
-
if (Object.keys(c).length === 0) continue;
|
|
2092
|
-
new Headers(c).forEach((u, v) => {
|
|
2093
|
-
i.set(v, u);
|
|
2094
|
-
});
|
|
2095
|
-
} else
|
|
2096
|
-
new Headers(s).forEach((c, u) => {
|
|
2097
|
-
i.set(u, c);
|
|
2098
|
-
});
|
|
2099
|
-
return i.forEach((s, c) => {
|
|
2100
|
-
n[c] = s;
|
|
2101
|
-
}), n;
|
|
2102
|
-
}
|
|
2103
|
-
async emit(e, t) {
|
|
2104
|
-
const n = this.hooks.filter((i) => i.event === e);
|
|
2105
|
-
try {
|
|
2106
|
-
let i = 0;
|
|
2107
|
-
for (const s of n) {
|
|
2108
|
-
const c = `${e}#${s.action.name || `anonymous#${i}`}`, u = Symbol("FexiosHookContext");
|
|
2109
|
-
t[u] = u;
|
|
2110
|
-
const v = await s.action.call(this, t);
|
|
2111
|
-
if (v === !1)
|
|
2112
|
-
throw new J(
|
|
2113
|
-
X.ABORTED_BY_HOOK,
|
|
2114
|
-
`Request aborted by hook "${c}"`,
|
|
2115
|
-
t
|
|
2116
|
-
);
|
|
2117
|
-
if (typeof v == "object" && v[u] === u)
|
|
2118
|
-
t = v;
|
|
2119
|
-
else {
|
|
2120
|
-
const _ = globalThis["".concat("console")];
|
|
2121
|
-
try {
|
|
2122
|
-
throw new J(
|
|
2123
|
-
X.HOOK_CONTEXT_CHANGED,
|
|
2124
|
-
`Hook "${c}" should return the original FexiosContext or return false to abort the request, but got "${v}".`
|
|
2125
|
-
);
|
|
2126
|
-
} catch (E) {
|
|
2127
|
-
_.warn(E.stack || E);
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
delete t[u], i++;
|
|
2131
|
-
}
|
|
2132
|
-
} catch (i) {
|
|
2133
|
-
return Promise.reject(i);
|
|
2134
|
-
}
|
|
2135
|
-
return t;
|
|
2136
|
-
}
|
|
2137
|
-
on(e, t, n = !1) {
|
|
2138
|
-
if (typeof t != "function")
|
|
2139
|
-
throw new J(
|
|
2140
|
-
X.INVALID_HOOK_CALLBACK,
|
|
2141
|
-
`Hook should be a function, but got "${typeof t}"`
|
|
2142
|
-
);
|
|
2143
|
-
return this.hooks[n ? "unshift" : "push"]({
|
|
2144
|
-
event: e,
|
|
2145
|
-
action: t
|
|
2146
|
-
}), this;
|
|
2147
|
-
}
|
|
2148
|
-
off(e, t) {
|
|
2149
|
-
return e === "*" || !e ? this.hooks = this.hooks.filter((n) => n.action !== t) : this.hooks = this.hooks.filter(
|
|
2150
|
-
(n) => n.event !== e || n.action !== t
|
|
2151
|
-
), this;
|
|
2152
|
-
}
|
|
2153
|
-
createInterceptor(e) {
|
|
2154
|
-
return {
|
|
2155
|
-
handlers: () => this.hooks.filter((t) => t.event === e).map((t) => t.action),
|
|
2156
|
-
use: (t, n = !1) => this.on(e, t, n),
|
|
2157
|
-
clear: () => {
|
|
2158
|
-
this.hooks = this.hooks.filter((t) => t.event !== e);
|
|
2159
|
-
}
|
|
2160
|
-
};
|
|
2161
|
-
}
|
|
2162
|
-
createMethodShortcut(e) {
|
|
2163
|
-
return Object.defineProperty(this, e, {
|
|
2164
|
-
value: (t, n, i) => (this.METHODS_WITHOUT_BODY.includes(
|
|
2165
|
-
e.toLocaleLowerCase()
|
|
2166
|
-
) ? i = n : (i = i || {}, i.body = n), this.request(t, {
|
|
2167
|
-
...i,
|
|
2168
|
-
method: e
|
|
2169
|
-
}))
|
|
2170
|
-
}), this;
|
|
2171
|
-
}
|
|
2172
|
-
extends(e) {
|
|
2173
|
-
const t = new ge({ ...this.baseConfigs, ...e });
|
|
2174
|
-
return t.hooks = [...this.hooks], t;
|
|
2175
|
-
}
|
|
2176
|
-
static create(e) {
|
|
2177
|
-
return new ge(e);
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
|
-
* Fexios
|
|
2182
|
-
* @desc Fetch based HTTP client with similar API to axios for browser and Node.js
|
|
2183
|
-
*
|
|
2184
|
-
* @license MIT
|
|
2185
|
-
* @author dragon-fish <dragon-fish@qq.com>
|
|
2186
|
-
*/
|
|
2187
|
-
const hi = ge.create, Vt = hi();
|
|
2188
|
-
typeof globalThis < "u" ? globalThis.fexios = Vt : typeof window < "u" && (window.fexios = Vt);
|
|
2189
|
-
/**
|
|
2190
|
-
* MediaWiki Api
|
|
2191
|
-
* Provides the API call methods similar to `mw.Api` at non-mw environments
|
|
2192
|
-
*
|
|
2193
|
-
* @author Dragon-Fish <dragon-fish@qq.com>
|
|
2194
|
-
* @license MIT
|
|
2195
|
-
*/
|
|
2196
|
-
const ur = class ue {
|
|
2197
|
-
constructor(e, t, n) {
|
|
2198
|
-
if (this.baseURL = e, this.version = "5.0.0", !e && typeof window == "object" && window.mediaWiki) {
|
|
2199
|
-
const { wgServer: i, wgScriptPath: s } = window.mediaWiki?.config?.get(["wgServer", "wgScriptPath"]) || {};
|
|
2200
|
-
typeof i == "string" && typeof s == "string" && (e = `${i}${s}/api.php`);
|
|
2201
|
-
}
|
|
2202
|
-
if (typeof e != "string")
|
|
2203
|
-
throw new Error("baseURL is undefined");
|
|
2204
|
-
this.baseURL = e, this.tokens = {}, this.defaultParams = {
|
|
2205
|
-
...ue.INIT_DEFAULT_PARAMS,
|
|
2206
|
-
...n
|
|
2207
|
-
}, this.defaultOptions = {
|
|
2208
|
-
responseType: "json",
|
|
2209
|
-
...t
|
|
2210
|
-
}, this.request = ue.createRequestHandler(this.baseURL);
|
|
2211
|
-
}
|
|
2212
|
-
setBaseURL(e) {
|
|
2213
|
-
return this.request.baseConfigs.baseURL = e, this;
|
|
2214
|
-
}
|
|
2215
|
-
static normalizeParamValue(e) {
|
|
2216
|
-
return Array.isArray(e) ? e.join("|") : typeof e == "boolean" ? e ? "1" : void 0 : typeof e == "number" ? "" + e : e;
|
|
2217
|
-
}
|
|
2218
|
-
static createRequestHandler(e) {
|
|
2219
|
-
const t = new ge({
|
|
2220
|
-
baseURL: e,
|
|
2221
|
-
responseType: "json"
|
|
2222
|
-
});
|
|
2223
|
-
return t.on("beforeInit", (n) => {
|
|
2224
|
-
if (n.method?.toLowerCase() !== "post")
|
|
2225
|
-
return n;
|
|
2226
|
-
if (typeof n.body == "object" && n.body !== null && !(n.body instanceof URLSearchParams) && !(n.body instanceof FormData)) {
|
|
2227
|
-
const i = n.body;
|
|
2228
|
-
Object.keys(i).forEach((s) => {
|
|
2229
|
-
const c = ue.normalizeParamValue(i[s]);
|
|
2230
|
-
typeof c > "u" || c === null ? delete i[s] : c !== i[s] && (i[s] = c);
|
|
2231
|
-
}), n.body = new URLSearchParams(n.body);
|
|
2232
|
-
}
|
|
2233
|
-
if (globalThis.FormData && n.body instanceof FormData || n.body instanceof URLSearchParams) {
|
|
2234
|
-
const i = n.body;
|
|
2235
|
-
i.forEach((c, u) => {
|
|
2236
|
-
const v = ue.normalizeParamValue(c);
|
|
2237
|
-
typeof v > "u" || v === null ? i.delete(u) : v !== c && i.set(u, v);
|
|
2238
|
-
});
|
|
2239
|
-
const s = new URLSearchParams(n.query);
|
|
2240
|
-
!s.has("format") && s.set("format", "" + (i.get("format") || "json")), !s.has("formatversion") && s.set(
|
|
2241
|
-
"formatversion",
|
|
2242
|
-
"" + (i.get("formatversion") || "2")
|
|
2243
|
-
), i.has("origin") && s.set("origin", "" + i.get("origin")), n.query = Object.fromEntries(s.entries()), i.has("action") && (n.query.action = "" + i.get("action"));
|
|
2244
|
-
}
|
|
2245
|
-
return n;
|
|
2246
|
-
}), t.on("beforeInit", (n) => {
|
|
2247
|
-
n.query = n.query;
|
|
2248
|
-
for (const i in n.query) {
|
|
2249
|
-
const s = ue.normalizeParamValue(n.query[i]);
|
|
2250
|
-
typeof s > "u" || s === null ? delete n.query[i] : s !== n.query[i] && (n.query[i] = "" + s);
|
|
2251
|
-
}
|
|
2252
|
-
return n;
|
|
2253
|
-
}), t.on("beforeRequest", (n) => {
|
|
2254
|
-
const i = new URL(n.url), s = i.searchParams;
|
|
2255
|
-
if (globalThis.location && (!s.has("origin") && location.origin !== new URL(e).origin ? (s.set("origin", location.origin), t.baseConfigs.credentials = "include", t.baseConfigs.mode = "cors") : location.origin === new URL(e).origin && (s.delete("origin"), t.baseConfigs.credentials = void 0, t.baseConfigs.mode = void 0)), i.searchParams.has("origin")) {
|
|
2256
|
-
const c = encodeURIComponent(
|
|
2257
|
-
i.searchParams.get("origin") || ""
|
|
2258
|
-
).replace(/\./g, "%2E");
|
|
2259
|
-
n.query = {}, i.searchParams.delete("origin"), n.url = `${i}${i.search ? "&" : "?"}origin=${c}`;
|
|
2260
|
-
}
|
|
2261
|
-
return n;
|
|
2262
|
-
}), t;
|
|
2263
|
-
}
|
|
2264
|
-
/** Base methods encapsulation */
|
|
2265
|
-
get(e, t) {
|
|
2266
|
-
return this.request.get("", {
|
|
2267
|
-
...this.defaultOptions,
|
|
2268
|
-
query: {
|
|
2269
|
-
...this.defaultParams,
|
|
2270
|
-
...this.defaultOptions.query,
|
|
2271
|
-
...e
|
|
2272
|
-
},
|
|
2273
|
-
...t
|
|
2274
|
-
});
|
|
2275
|
-
}
|
|
2276
|
-
post(e, t) {
|
|
2277
|
-
return this.request.post("", e, {
|
|
2278
|
-
...this.defaultOptions,
|
|
2279
|
-
query: { ...this.defaultParams, ...this.defaultOptions.query },
|
|
2280
|
-
...t
|
|
2281
|
-
});
|
|
2282
|
-
}
|
|
2283
|
-
async login(e, t, n, i) {
|
|
2284
|
-
if (this.defaultOptions.credentials = "include", i = i || {}, i.retry ??= 3, i.retry < 1)
|
|
2285
|
-
throw new ye(
|
|
2286
|
-
"LOGIN_RETRY_LIMIT_EXCEEDED",
|
|
2287
|
-
"The limit of the number of times to automatically re-login has been exceeded"
|
|
2288
|
-
);
|
|
2289
|
-
let s;
|
|
2290
|
-
try {
|
|
2291
|
-
const c = await this.postWithToken(
|
|
2292
|
-
"login",
|
|
2293
|
-
{
|
|
2294
|
-
action: "login",
|
|
2295
|
-
lgname: e,
|
|
2296
|
-
lgpassword: t,
|
|
2297
|
-
...n
|
|
2298
|
-
},
|
|
2299
|
-
{ tokenName: "lgtoken", ...i }
|
|
2300
|
-
);
|
|
2301
|
-
if (c?.data?.login)
|
|
2302
|
-
s = c.data;
|
|
2303
|
-
else
|
|
2304
|
-
throw c;
|
|
2305
|
-
} catch (c) {
|
|
2306
|
-
if (c instanceof ye)
|
|
2307
|
-
throw c;
|
|
2308
|
-
if (c?.ok === !1)
|
|
2309
|
-
return this.login(e, t, n, {
|
|
2310
|
-
...i,
|
|
2311
|
-
noCache: !0,
|
|
2312
|
-
retry: i.retry - 1
|
|
2313
|
-
});
|
|
2314
|
-
throw new ye(
|
|
2315
|
-
"HTTP_ERROR",
|
|
2316
|
-
"The server returns an error, but it doesn't seem to be caused by MediaWiki",
|
|
2317
|
-
c
|
|
2318
|
-
);
|
|
2319
|
-
}
|
|
2320
|
-
if (s?.login?.result !== "Success")
|
|
2321
|
-
throw new ye(
|
|
2322
|
-
"LOGIN_FAILED",
|
|
2323
|
-
s?.login?.reason?.text || s?.login?.result || "Login failed with unknown reason",
|
|
2324
|
-
s
|
|
2325
|
-
);
|
|
2326
|
-
return s.login;
|
|
2327
|
-
}
|
|
2328
|
-
async getUserInfo() {
|
|
2329
|
-
const { data: e } = await this.get({
|
|
2330
|
-
action: "query",
|
|
2331
|
-
meta: "userinfo",
|
|
2332
|
-
uiprop: ["groups", "rights", "blockinfo"]
|
|
2333
|
-
});
|
|
2334
|
-
return e?.query?.userinfo;
|
|
2335
|
-
}
|
|
2336
|
-
/** Token Handler */
|
|
2337
|
-
async getTokens(e = ["csrf"]) {
|
|
2338
|
-
this.defaultOptions.credentials = "include";
|
|
2339
|
-
const { data: t } = await this.get({
|
|
2340
|
-
action: "query",
|
|
2341
|
-
meta: "tokens",
|
|
2342
|
-
type: e
|
|
2343
|
-
});
|
|
2344
|
-
return this.tokens = { ...this.tokens, ...t.query.tokens }, this.tokens;
|
|
2345
|
-
}
|
|
2346
|
-
async token(e = "csrf", t = !1) {
|
|
2347
|
-
return (!this.tokens[`${e}token`] || t) && (delete this.tokens[`${e}token`], await this.getTokens([e])), this.tokens[`${e}token`];
|
|
2348
|
-
}
|
|
2349
|
-
async postWithToken(e, t, n) {
|
|
2350
|
-
const { tokenName: i = "token", retry: s = 3, noCache: c = !1 } = n || {};
|
|
2351
|
-
if (s < 1)
|
|
2352
|
-
throw new ye(
|
|
2353
|
-
"TOKEN_RETRY_LIMIT_EXCEEDED",
|
|
2354
|
-
"The limit of the number of times to automatically re-acquire the token has been exceeded"
|
|
2355
|
-
);
|
|
2356
|
-
const u = await this.token(e, c), v = () => this.postWithToken(e, t, {
|
|
2357
|
-
tokenName: i,
|
|
2358
|
-
retry: s - 1,
|
|
2359
|
-
noCache: !0
|
|
2360
|
-
});
|
|
2361
|
-
return this.post({
|
|
2362
|
-
[i]: u,
|
|
2363
|
-
...t
|
|
2364
|
-
}).then((_) => {
|
|
2365
|
-
const E = _.data;
|
|
2366
|
-
return ue.isBadTokenError(E) ? v() : _;
|
|
2367
|
-
}).catch((_) => {
|
|
2368
|
-
const E = _.data;
|
|
2369
|
-
if (ue.isBadTokenError(E) || _?.ok === !1)
|
|
2370
|
-
return v();
|
|
2371
|
-
if (typeof E == "object" && E !== null)
|
|
2372
|
-
return Promise.reject(E);
|
|
2373
|
-
throw new ye(
|
|
2374
|
-
"HTTP_ERROR",
|
|
2375
|
-
"The server returns an error, but it doesn’t seem to be caused by MediaWiki",
|
|
2376
|
-
_
|
|
2377
|
-
);
|
|
2378
|
-
});
|
|
2379
|
-
}
|
|
2380
|
-
postWithEditToken(e) {
|
|
2381
|
-
return this.postWithToken("csrf", e);
|
|
2382
|
-
}
|
|
2383
|
-
static isBadTokenError(e) {
|
|
2384
|
-
return e?.error?.code === "badtoken" || e?.errors?.some((t) => t.code === "badtoken") || ["NeedToken", "WrongToken"].includes(e?.login?.result);
|
|
2385
|
-
}
|
|
2386
|
-
async getMessages(e, t = "zh", n) {
|
|
2387
|
-
const { data: i } = await this.get({
|
|
2388
|
-
action: "query",
|
|
2389
|
-
meta: "allmessages",
|
|
2390
|
-
ammessages: e,
|
|
2391
|
-
amlang: t,
|
|
2392
|
-
...n
|
|
2393
|
-
}), s = {};
|
|
2394
|
-
return i.query.allmessages.forEach(function(c) {
|
|
2395
|
-
c.missing || (s[c.name] = c.content);
|
|
2396
|
-
}), s;
|
|
2397
|
-
}
|
|
2398
|
-
async parseWikitext(e, t, n, i) {
|
|
2399
|
-
const { data: s } = await this.post(
|
|
2400
|
-
{
|
|
2401
|
-
action: "parse",
|
|
2402
|
-
title: t,
|
|
2403
|
-
text: e,
|
|
2404
|
-
...n
|
|
2405
|
-
},
|
|
2406
|
-
i
|
|
2407
|
-
);
|
|
2408
|
-
return s.parse.text;
|
|
2409
|
-
}
|
|
2410
|
-
};
|
|
2411
|
-
ur.INIT_DEFAULT_PARAMS = {
|
|
2412
|
-
action: "query",
|
|
2413
|
-
errorformat: "plaintext",
|
|
2414
|
-
format: "json",
|
|
2415
|
-
formatversion: 2
|
|
2416
|
-
};
|
|
2417
|
-
let di = ur;
|
|
2418
|
-
class ye extends Error {
|
|
2419
|
-
constructor(e, t = "", n) {
|
|
2420
|
-
super(), this.code = e, this.message = t, this.cause = n, this.name = "WikiSaikouError";
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
/**
|
|
2424
|
-
* MediaWiki Api
|
|
2425
|
-
* Provides the API call methods similar to `mw.Api` at non-mw environments
|
|
2426
|
-
*
|
|
2427
|
-
* @author Dragon-Fish <dragon-fish@qq.com>
|
|
2428
|
-
* @license MIT
|
|
2429
|
-
*/
|
|
2430
|
-
class fr extends di {
|
|
2431
|
-
}
|
|
2432
|
-
class pi {
|
|
2433
|
-
constructor(e, t) {
|
|
2434
|
-
this.ctx = e;
|
|
2435
|
-
let n = typeof t?.baseURL == "string" ? t.baseURL : t?.baseURL?.toString();
|
|
2436
|
-
n?.startsWith("/") && (n = new URL(n, location.origin).href);
|
|
2437
|
-
const i = new fr(n, {
|
|
2438
|
-
headers: {
|
|
2439
|
-
"x-api-user-agent": `InPageEdit-NEXT ${e.version}`
|
|
2440
|
-
}
|
|
2441
|
-
});
|
|
2442
|
-
e.set("api", i);
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
class yi extends We {
|
|
2446
|
-
constructor(e) {
|
|
2447
|
-
super(e, "resourceLoader", !0), this.ctx = e;
|
|
2448
|
-
}
|
|
2449
|
-
stop() {
|
|
2450
|
-
}
|
|
2451
|
-
loadScript(e, t) {
|
|
2452
|
-
if (!e)
|
|
2453
|
-
return Promise.resolve(null);
|
|
2454
|
-
const n = `script:${e}`, i = document.querySelector(`[data-ipe="${n}"]`);
|
|
2455
|
-
return i ? Promise.resolve(i) : new Promise((c, u) => {
|
|
2456
|
-
const v = document.createElement("script");
|
|
2457
|
-
v.src = e, v.dataset.ipe = n, t && Object.entries(t).forEach(([_, E]) => {
|
|
2458
|
-
typeof E > "u" || E === !1 || E === null ? v.removeAttribute(_) : v.setAttribute(_, E);
|
|
2459
|
-
}), document.body.appendChild(v), v.onload = () => c(v), v.onerror = (_) => u(_);
|
|
2460
|
-
});
|
|
2461
|
-
}
|
|
2462
|
-
loadStyle(e, t) {
|
|
2463
|
-
if (!e)
|
|
2464
|
-
return Promise.resolve(null);
|
|
2465
|
-
const n = `style:${e}`, i = document.querySelector(`[data-ipe="${n}"]`);
|
|
2466
|
-
return i ? Promise.resolve(i) : new Promise((c, u) => {
|
|
2467
|
-
const v = document.createElement("link");
|
|
2468
|
-
v.rel = "stylesheet", v.href = e, v.dataset.ipe = n, t && Object.entries(t).forEach(([E, b]) => {
|
|
2469
|
-
typeof b > "u" || b === !1 || b === null ? v.removeAttribute(E) : v.setAttribute(E, b);
|
|
2470
|
-
}), (document.querySelector('meta[name="ipe-styles"]') || (() => {
|
|
2471
|
-
const E = document.createElement("meta");
|
|
2472
|
-
return E.id = "ipe-styles", E.name = "ipe-styles", document.head.insertAdjacentElement("afterbegin", E), E;
|
|
2473
|
-
})()).before(v), v.onload = () => c(v), v.onerror = (E) => u(E);
|
|
2474
|
-
});
|
|
2475
|
-
}
|
|
2476
|
-
resolveImportPath(e) {
|
|
2477
|
-
return e.startsWith("http") || e.startsWith("//") ? e : import.meta.resolve(e);
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
var ve = /* @__PURE__ */ ((r) => (r.ANALYTICS_API_BASE = "https://analytics.ipe.wiki/api", r.ANALYTICS_DASH_URL = "https://analytics.ipe.wiki", r.GITHUB_URL = "https://github.com/inpageedit/inpageedit-v2", r.HOME_URL = "https://www.ipe.wiki/", r.PLUGIN_CDN_BASE = "https://ipe-plugins.js.org", r.PLUGIN_HOME_URL = "https://github.com/inpageedit/Plugins", r.SPECIAL_NOTICE_JSON = "https://ipe-plugins.js.org/specialNotice.json", r.UPDATE_LOGS_URL = "https://www.ipe.wiki/update/", r))(ve || {});
|
|
2481
|
-
class mi {
|
|
2482
|
-
constructor(e) {
|
|
2483
|
-
this.ctx = e, this.start(), this.ctx.on("dispose", () => {
|
|
2484
|
-
this.stop();
|
|
2485
|
-
});
|
|
2486
|
-
}
|
|
2487
|
-
static {
|
|
2488
|
-
this.inject = ["resourceLoader"];
|
|
2489
|
-
}
|
|
2490
|
-
start() {
|
|
2491
|
-
const { promise: e, resolve: t } = Promise.withResolvers();
|
|
2492
|
-
return window.ssi_modal && typeof window.ssi_modal.show == "function" ? t(window.ssi_modal) : (this.ctx.resourceLoader.loadStyle(`${ve.PLUGIN_CDN_BASE}/lib/ssi-modal/ssi-modal.css`), this.ctx.resourceLoader.loadScript(`${ve.PLUGIN_CDN_BASE}/lib/ssi-modal/ssi-modal.js`, {
|
|
2493
|
-
async: ""
|
|
2494
|
-
}).then(() => {
|
|
2495
|
-
t(window.ssi_modal);
|
|
2496
|
-
})), e.then((n) => {
|
|
2497
|
-
this.hackSsiModal(n), this.ctx.set("modal", n), this.modal = n;
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
get logger() {
|
|
2501
|
-
return this.ctx.logger("SSI_MODAL");
|
|
2502
|
-
}
|
|
2503
|
-
stop() {
|
|
2504
|
-
this.modal?.closeAll();
|
|
2505
|
-
}
|
|
2506
|
-
hackSsiModal(e) {
|
|
2507
|
-
const t = this, n = e.proto.init;
|
|
2508
|
-
e.proto.init = function() {
|
|
2509
|
-
return t.logger.log("init", this), this.options.className ||= "", this.options.className += " in-page-edit theme-ipe", n.call(this);
|
|
2510
|
-
};
|
|
2511
|
-
const i = e.proto.show;
|
|
2512
|
-
e.proto.show = function() {
|
|
2513
|
-
return t.ctx.emit("modal/show", { modal: this }), i.call(this);
|
|
2514
|
-
};
|
|
2515
|
-
const s = e.proto.close;
|
|
2516
|
-
return e.proto.close = function() {
|
|
2517
|
-
return t.ctx.emit("modal/close", { modal: this }), s.call(this);
|
|
2518
|
-
}, e.proto.setLoadingState = function(c) {
|
|
2519
|
-
if (this.get$window().toggleClass("loading", c), c) {
|
|
2520
|
-
const u = this.get$window().find(
|
|
2521
|
-
"input:not([disabled]),button:not([disabled])"
|
|
2522
|
-
);
|
|
2523
|
-
this.get$modal().data("inputsAndButtons", u), u.prop("disabled", !0), this.get$window().append(
|
|
2524
|
-
/* @__PURE__ */ Ft(
|
|
2525
|
-
"div",
|
|
2526
|
-
{
|
|
2527
|
-
id: "ssi-modalLoadingWrapper",
|
|
2528
|
-
style: {
|
|
2529
|
-
position: "absolute",
|
|
2530
|
-
top: 0,
|
|
2531
|
-
left: 0,
|
|
2532
|
-
right: 0,
|
|
2533
|
-
bottom: 0,
|
|
2534
|
-
display: "flex",
|
|
2535
|
-
justifyContent: "center",
|
|
2536
|
-
alignItems: "center",
|
|
2537
|
-
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
2538
|
-
zIndex: 2e3
|
|
2539
|
-
},
|
|
2540
|
-
children: /* @__PURE__ */ Ft(gn, { style: { width: "80%", maxWidth: "800px" } })
|
|
2541
|
-
}
|
|
2542
|
-
)
|
|
2543
|
-
);
|
|
2544
|
-
} else {
|
|
2545
|
-
this.get$window().find("#ssi-modalLoadingWrapper").remove();
|
|
2546
|
-
const u = this.get$modal().data("inputsAndButtons");
|
|
2547
|
-
u && u.prop("disabled", !1);
|
|
2548
|
-
}
|
|
2549
|
-
}, e;
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
var $e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2553
|
-
function gi(r) {
|
|
2554
|
-
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
2555
|
-
}
|
|
2556
|
-
function je(r) {
|
|
2557
|
-
throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
2558
|
-
}
|
|
2559
|
-
var nt = { exports: {} };
|
|
2560
|
-
/*!
|
|
2561
|
-
localForage -- Offline Storage, Improved
|
|
2562
|
-
Version 1.10.0
|
|
2563
|
-
https://localforage.github.io/localForage
|
|
2564
|
-
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
2565
|
-
*/
|
|
2566
|
-
var Jt;
|
|
2567
|
-
function vi() {
|
|
2568
|
-
return Jt || (Jt = 1, function(r, e) {
|
|
2569
|
-
(function(t) {
|
|
2570
|
-
r.exports = t();
|
|
2571
|
-
})(function() {
|
|
2572
|
-
return function t(n, i, s) {
|
|
2573
|
-
function c(_, E) {
|
|
2574
|
-
if (!i[_]) {
|
|
2575
|
-
if (!n[_]) {
|
|
2576
|
-
var b = typeof je == "function" && je;
|
|
2577
|
-
if (!E && b) return b(_, !0);
|
|
2578
|
-
if (u) return u(_, !0);
|
|
2579
|
-
var T = new Error("Cannot find module '" + _ + "'");
|
|
2580
|
-
throw T.code = "MODULE_NOT_FOUND", T;
|
|
2581
|
-
}
|
|
2582
|
-
var P = i[_] = { exports: {} };
|
|
2583
|
-
n[_][0].call(P.exports, function(L) {
|
|
2584
|
-
var Y = n[_][1][L];
|
|
2585
|
-
return c(Y || L);
|
|
2586
|
-
}, P, P.exports, t, n, i, s);
|
|
2587
|
-
}
|
|
2588
|
-
return i[_].exports;
|
|
2589
|
-
}
|
|
2590
|
-
for (var u = typeof je == "function" && je, v = 0; v < s.length; v++) c(s[v]);
|
|
2591
|
-
return c;
|
|
2592
|
-
}({ 1: [function(t, n, i) {
|
|
2593
|
-
(function(s) {
|
|
2594
|
-
var c = s.MutationObserver || s.WebKitMutationObserver, u;
|
|
2595
|
-
if (c) {
|
|
2596
|
-
var v = 0, _ = new c(L), E = s.document.createTextNode("");
|
|
2597
|
-
_.observe(E, {
|
|
2598
|
-
characterData: !0
|
|
2599
|
-
}), u = function() {
|
|
2600
|
-
E.data = v = ++v % 2;
|
|
2601
|
-
};
|
|
2602
|
-
} else if (!s.setImmediate && typeof s.MessageChannel < "u") {
|
|
2603
|
-
var b = new s.MessageChannel();
|
|
2604
|
-
b.port1.onmessage = L, u = function() {
|
|
2605
|
-
b.port2.postMessage(0);
|
|
2606
|
-
};
|
|
2607
|
-
} else "document" in s && "onreadystatechange" in s.document.createElement("script") ? u = function() {
|
|
2608
|
-
var W = s.document.createElement("script");
|
|
2609
|
-
W.onreadystatechange = function() {
|
|
2610
|
-
L(), W.onreadystatechange = null, W.parentNode.removeChild(W), W = null;
|
|
2611
|
-
}, s.document.documentElement.appendChild(W);
|
|
2612
|
-
} : u = function() {
|
|
2613
|
-
setTimeout(L, 0);
|
|
2614
|
-
};
|
|
2615
|
-
var T, P = [];
|
|
2616
|
-
function L() {
|
|
2617
|
-
T = !0;
|
|
2618
|
-
for (var W, U, f = P.length; f; ) {
|
|
2619
|
-
for (U = P, P = [], W = -1; ++W < f; )
|
|
2620
|
-
U[W]();
|
|
2621
|
-
f = P.length;
|
|
2622
|
-
}
|
|
2623
|
-
T = !1;
|
|
2624
|
-
}
|
|
2625
|
-
n.exports = Y;
|
|
2626
|
-
function Y(W) {
|
|
2627
|
-
P.push(W) === 1 && !T && u();
|
|
2628
|
-
}
|
|
2629
|
-
}).call(this, typeof $e < "u" ? $e : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
2630
|
-
}, {}], 2: [function(t, n, i) {
|
|
2631
|
-
var s = t(1);
|
|
2632
|
-
function c() {
|
|
2633
|
-
}
|
|
2634
|
-
var u = {}, v = ["REJECTED"], _ = ["FULFILLED"], E = ["PENDING"];
|
|
2635
|
-
n.exports = b;
|
|
2636
|
-
function b(h) {
|
|
2637
|
-
if (typeof h != "function")
|
|
2638
|
-
throw new TypeError("resolver must be a function");
|
|
2639
|
-
this.state = E, this.queue = [], this.outcome = void 0, h !== c && Y(this, h);
|
|
2640
|
-
}
|
|
2641
|
-
b.prototype.catch = function(h) {
|
|
2642
|
-
return this.then(null, h);
|
|
2643
|
-
}, b.prototype.then = function(h, w) {
|
|
2644
|
-
if (typeof h != "function" && this.state === _ || typeof w != "function" && this.state === v)
|
|
2645
|
-
return this;
|
|
2646
|
-
var x = new this.constructor(c);
|
|
2647
|
-
if (this.state !== E) {
|
|
2648
|
-
var A = this.state === _ ? h : w;
|
|
2649
|
-
P(x, A, this.outcome);
|
|
2650
|
-
} else
|
|
2651
|
-
this.queue.push(new T(x, h, w));
|
|
2652
|
-
return x;
|
|
2653
|
-
};
|
|
2654
|
-
function T(h, w, x) {
|
|
2655
|
-
this.promise = h, typeof w == "function" && (this.onFulfilled = w, this.callFulfilled = this.otherCallFulfilled), typeof x == "function" && (this.onRejected = x, this.callRejected = this.otherCallRejected);
|
|
2656
|
-
}
|
|
2657
|
-
T.prototype.callFulfilled = function(h) {
|
|
2658
|
-
u.resolve(this.promise, h);
|
|
2659
|
-
}, T.prototype.otherCallFulfilled = function(h) {
|
|
2660
|
-
P(this.promise, this.onFulfilled, h);
|
|
2661
|
-
}, T.prototype.callRejected = function(h) {
|
|
2662
|
-
u.reject(this.promise, h);
|
|
2663
|
-
}, T.prototype.otherCallRejected = function(h) {
|
|
2664
|
-
P(this.promise, this.onRejected, h);
|
|
2665
|
-
};
|
|
2666
|
-
function P(h, w, x) {
|
|
2667
|
-
s(function() {
|
|
2668
|
-
var A;
|
|
2669
|
-
try {
|
|
2670
|
-
A = w(x);
|
|
2671
|
-
} catch ($) {
|
|
2672
|
-
return u.reject(h, $);
|
|
2673
|
-
}
|
|
2674
|
-
A === h ? u.reject(h, new TypeError("Cannot resolve promise with itself")) : u.resolve(h, A);
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
u.resolve = function(h, w) {
|
|
2678
|
-
var x = W(L, w);
|
|
2679
|
-
if (x.status === "error")
|
|
2680
|
-
return u.reject(h, x.value);
|
|
2681
|
-
var A = x.value;
|
|
2682
|
-
if (A)
|
|
2683
|
-
Y(h, A);
|
|
2684
|
-
else {
|
|
2685
|
-
h.state = _, h.outcome = w;
|
|
2686
|
-
for (var $ = -1, V = h.queue.length; ++$ < V; )
|
|
2687
|
-
h.queue[$].callFulfilled(w);
|
|
2688
|
-
}
|
|
2689
|
-
return h;
|
|
2690
|
-
}, u.reject = function(h, w) {
|
|
2691
|
-
h.state = v, h.outcome = w;
|
|
2692
|
-
for (var x = -1, A = h.queue.length; ++x < A; )
|
|
2693
|
-
h.queue[x].callRejected(w);
|
|
2694
|
-
return h;
|
|
2695
|
-
};
|
|
2696
|
-
function L(h) {
|
|
2697
|
-
var w = h && h.then;
|
|
2698
|
-
if (h && (typeof h == "object" || typeof h == "function") && typeof w == "function")
|
|
2699
|
-
return function() {
|
|
2700
|
-
w.apply(h, arguments);
|
|
2701
|
-
};
|
|
2702
|
-
}
|
|
2703
|
-
function Y(h, w) {
|
|
2704
|
-
var x = !1;
|
|
2705
|
-
function A(ee) {
|
|
2706
|
-
x || (x = !0, u.reject(h, ee));
|
|
2707
|
-
}
|
|
2708
|
-
function $(ee) {
|
|
2709
|
-
x || (x = !0, u.resolve(h, ee));
|
|
2710
|
-
}
|
|
2711
|
-
function V() {
|
|
2712
|
-
w($, A);
|
|
2713
|
-
}
|
|
2714
|
-
var Z = W(V);
|
|
2715
|
-
Z.status === "error" && A(Z.value);
|
|
2716
|
-
}
|
|
2717
|
-
function W(h, w) {
|
|
2718
|
-
var x = {};
|
|
2719
|
-
try {
|
|
2720
|
-
x.value = h(w), x.status = "success";
|
|
2721
|
-
} catch (A) {
|
|
2722
|
-
x.status = "error", x.value = A;
|
|
2723
|
-
}
|
|
2724
|
-
return x;
|
|
2725
|
-
}
|
|
2726
|
-
b.resolve = U;
|
|
2727
|
-
function U(h) {
|
|
2728
|
-
return h instanceof this ? h : u.resolve(new this(c), h);
|
|
2729
|
-
}
|
|
2730
|
-
b.reject = f;
|
|
2731
|
-
function f(h) {
|
|
2732
|
-
var w = new this(c);
|
|
2733
|
-
return u.reject(w, h);
|
|
2734
|
-
}
|
|
2735
|
-
b.all = d;
|
|
2736
|
-
function d(h) {
|
|
2737
|
-
var w = this;
|
|
2738
|
-
if (Object.prototype.toString.call(h) !== "[object Array]")
|
|
2739
|
-
return this.reject(new TypeError("must be an array"));
|
|
2740
|
-
var x = h.length, A = !1;
|
|
2741
|
-
if (!x)
|
|
2742
|
-
return this.resolve([]);
|
|
2743
|
-
for (var $ = new Array(x), V = 0, Z = -1, ee = new this(c); ++Z < x; )
|
|
2744
|
-
ie(h[Z], Z);
|
|
2745
|
-
return ee;
|
|
2746
|
-
function ie(be, De) {
|
|
2747
|
-
w.resolve(be).then(He, function(de) {
|
|
2748
|
-
A || (A = !0, u.reject(ee, de));
|
|
2749
|
-
});
|
|
2750
|
-
function He(de) {
|
|
2751
|
-
$[De] = de, ++V === x && !A && (A = !0, u.resolve(ee, $));
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
b.race = m;
|
|
2756
|
-
function m(h) {
|
|
2757
|
-
var w = this;
|
|
2758
|
-
if (Object.prototype.toString.call(h) !== "[object Array]")
|
|
2759
|
-
return this.reject(new TypeError("must be an array"));
|
|
2760
|
-
var x = h.length, A = !1;
|
|
2761
|
-
if (!x)
|
|
2762
|
-
return this.resolve([]);
|
|
2763
|
-
for (var $ = -1, V = new this(c); ++$ < x; )
|
|
2764
|
-
Z(h[$]);
|
|
2765
|
-
return V;
|
|
2766
|
-
function Z(ee) {
|
|
2767
|
-
w.resolve(ee).then(function(ie) {
|
|
2768
|
-
A || (A = !0, u.resolve(V, ie));
|
|
2769
|
-
}, function(ie) {
|
|
2770
|
-
A || (A = !0, u.reject(V, ie));
|
|
2771
|
-
});
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
2774
|
-
}, { 1: 1 }], 3: [function(t, n, i) {
|
|
2775
|
-
(function(s) {
|
|
2776
|
-
typeof s.Promise != "function" && (s.Promise = t(2));
|
|
2777
|
-
}).call(this, typeof $e < "u" ? $e : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
2778
|
-
}, { 2: 2 }], 4: [function(t, n, i) {
|
|
2779
|
-
var s = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
|
|
2780
|
-
return typeof o;
|
|
2781
|
-
} : function(o) {
|
|
2782
|
-
return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
2783
|
-
};
|
|
2784
|
-
function c(o, l) {
|
|
2785
|
-
if (!(o instanceof l))
|
|
2786
|
-
throw new TypeError("Cannot call a class as a function");
|
|
2787
|
-
}
|
|
2788
|
-
function u() {
|
|
2789
|
-
try {
|
|
2790
|
-
if (typeof indexedDB < "u")
|
|
2791
|
-
return indexedDB;
|
|
2792
|
-
if (typeof webkitIndexedDB < "u")
|
|
2793
|
-
return webkitIndexedDB;
|
|
2794
|
-
if (typeof mozIndexedDB < "u")
|
|
2795
|
-
return mozIndexedDB;
|
|
2796
|
-
if (typeof OIndexedDB < "u")
|
|
2797
|
-
return OIndexedDB;
|
|
2798
|
-
if (typeof msIndexedDB < "u")
|
|
2799
|
-
return msIndexedDB;
|
|
2800
|
-
} catch {
|
|
2801
|
-
return;
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
var v = u();
|
|
2805
|
-
function _() {
|
|
2806
|
-
try {
|
|
2807
|
-
if (!v || !v.open)
|
|
2808
|
-
return !1;
|
|
2809
|
-
var o = typeof openDatabase < "u" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform), l = typeof fetch == "function" && fetch.toString().indexOf("[native code") !== -1;
|
|
2810
|
-
return (!o || l) && typeof indexedDB < "u" && // some outdated implementations of IDB that appear on Samsung
|
|
2811
|
-
// and HTC Android devices <4.4 are missing IDBKeyRange
|
|
2812
|
-
// See: https://github.com/mozilla/localForage/issues/128
|
|
2813
|
-
// See: https://github.com/mozilla/localForage/issues/272
|
|
2814
|
-
typeof IDBKeyRange < "u";
|
|
2815
|
-
} catch {
|
|
2816
|
-
return !1;
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
function E(o, l) {
|
|
2820
|
-
o = o || [], l = l || {};
|
|
2821
|
-
try {
|
|
2822
|
-
return new Blob(o, l);
|
|
2823
|
-
} catch (p) {
|
|
2824
|
-
if (p.name !== "TypeError")
|
|
2825
|
-
throw p;
|
|
2826
|
-
for (var a = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, y = new a(), g = 0; g < o.length; g += 1)
|
|
2827
|
-
y.append(o[g]);
|
|
2828
|
-
return y.getBlob(l.type);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
typeof Promise > "u" && t(3);
|
|
2832
|
-
var b = Promise;
|
|
2833
|
-
function T(o, l) {
|
|
2834
|
-
l && o.then(function(a) {
|
|
2835
|
-
l(null, a);
|
|
2836
|
-
}, function(a) {
|
|
2837
|
-
l(a);
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
function P(o, l, a) {
|
|
2841
|
-
typeof l == "function" && o.then(l), typeof a == "function" && o.catch(a);
|
|
2842
|
-
}
|
|
2843
|
-
function L(o) {
|
|
2844
|
-
return typeof o != "string" && (console.warn(o + " used as a key, but it is not a string."), o = String(o)), o;
|
|
2845
|
-
}
|
|
2846
|
-
function Y() {
|
|
2847
|
-
if (arguments.length && typeof arguments[arguments.length - 1] == "function")
|
|
2848
|
-
return arguments[arguments.length - 1];
|
|
2849
|
-
}
|
|
2850
|
-
var W = "local-forage-detect-blob-support", U = void 0, f = {}, d = Object.prototype.toString, m = "readonly", h = "readwrite";
|
|
2851
|
-
function w(o) {
|
|
2852
|
-
for (var l = o.length, a = new ArrayBuffer(l), y = new Uint8Array(a), g = 0; g < l; g++)
|
|
2853
|
-
y[g] = o.charCodeAt(g);
|
|
2854
|
-
return a;
|
|
2855
|
-
}
|
|
2856
|
-
function x(o) {
|
|
2857
|
-
return new b(function(l) {
|
|
2858
|
-
var a = o.transaction(W, h), y = E([""]);
|
|
2859
|
-
a.objectStore(W).put(y, "key"), a.onabort = function(g) {
|
|
2860
|
-
g.preventDefault(), g.stopPropagation(), l(!1);
|
|
2861
|
-
}, a.oncomplete = function() {
|
|
2862
|
-
var g = navigator.userAgent.match(/Chrome\/(\d+)/), p = navigator.userAgent.match(/Edge\//);
|
|
2863
|
-
l(p || !g || parseInt(g[1], 10) >= 43);
|
|
2864
|
-
};
|
|
2865
|
-
}).catch(function() {
|
|
2866
|
-
return !1;
|
|
2867
|
-
});
|
|
2868
|
-
}
|
|
2869
|
-
function A(o) {
|
|
2870
|
-
return typeof U == "boolean" ? b.resolve(U) : x(o).then(function(l) {
|
|
2871
|
-
return U = l, U;
|
|
2872
|
-
});
|
|
2873
|
-
}
|
|
2874
|
-
function $(o) {
|
|
2875
|
-
var l = f[o.name], a = {};
|
|
2876
|
-
a.promise = new b(function(y, g) {
|
|
2877
|
-
a.resolve = y, a.reject = g;
|
|
2878
|
-
}), l.deferredOperations.push(a), l.dbReady ? l.dbReady = l.dbReady.then(function() {
|
|
2879
|
-
return a.promise;
|
|
2880
|
-
}) : l.dbReady = a.promise;
|
|
2881
|
-
}
|
|
2882
|
-
function V(o) {
|
|
2883
|
-
var l = f[o.name], a = l.deferredOperations.pop();
|
|
2884
|
-
if (a)
|
|
2885
|
-
return a.resolve(), a.promise;
|
|
2886
|
-
}
|
|
2887
|
-
function Z(o, l) {
|
|
2888
|
-
var a = f[o.name], y = a.deferredOperations.pop();
|
|
2889
|
-
if (y)
|
|
2890
|
-
return y.reject(l), y.promise;
|
|
2891
|
-
}
|
|
2892
|
-
function ee(o, l) {
|
|
2893
|
-
return new b(function(a, y) {
|
|
2894
|
-
if (f[o.name] = f[o.name] || wt(), o.db)
|
|
2895
|
-
if (l)
|
|
2896
|
-
$(o), o.db.close();
|
|
2897
|
-
else
|
|
2898
|
-
return a(o.db);
|
|
2899
|
-
var g = [o.name];
|
|
2900
|
-
l && g.push(o.version);
|
|
2901
|
-
var p = v.open.apply(v, g);
|
|
2902
|
-
l && (p.onupgradeneeded = function(S) {
|
|
2903
|
-
var O = p.result;
|
|
2904
|
-
try {
|
|
2905
|
-
O.createObjectStore(o.storeName), S.oldVersion <= 1 && O.createObjectStore(W);
|
|
2906
|
-
} catch (R) {
|
|
2907
|
-
if (R.name === "ConstraintError")
|
|
2908
|
-
console.warn('The database "' + o.name + '" has been upgraded from version ' + S.oldVersion + " to version " + S.newVersion + ', but the storage "' + o.storeName + '" already exists.');
|
|
2909
|
-
else
|
|
2910
|
-
throw R;
|
|
2911
|
-
}
|
|
2912
|
-
}), p.onerror = function(S) {
|
|
2913
|
-
S.preventDefault(), y(p.error);
|
|
2914
|
-
}, p.onsuccess = function() {
|
|
2915
|
-
var S = p.result;
|
|
2916
|
-
S.onversionchange = function(O) {
|
|
2917
|
-
O.target.close();
|
|
2918
|
-
}, a(S), V(o);
|
|
2919
|
-
};
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
function ie(o) {
|
|
2923
|
-
return ee(o, !1);
|
|
2924
|
-
}
|
|
2925
|
-
function be(o) {
|
|
2926
|
-
return ee(o, !0);
|
|
2927
|
-
}
|
|
2928
|
-
function De(o, l) {
|
|
2929
|
-
if (!o.db)
|
|
2930
|
-
return !0;
|
|
2931
|
-
var a = !o.db.objectStoreNames.contains(o.storeName), y = o.version < o.db.version, g = o.version > o.db.version;
|
|
2932
|
-
if (y && (o.version !== l && console.warn('The database "' + o.name + `" can't be downgraded from version ` + o.db.version + " to version " + o.version + "."), o.version = o.db.version), g || a) {
|
|
2933
|
-
if (a) {
|
|
2934
|
-
var p = o.db.version + 1;
|
|
2935
|
-
p > o.version && (o.version = p);
|
|
2936
|
-
}
|
|
2937
|
-
return !0;
|
|
2938
|
-
}
|
|
2939
|
-
return !1;
|
|
2940
|
-
}
|
|
2941
|
-
function He(o) {
|
|
2942
|
-
return new b(function(l, a) {
|
|
2943
|
-
var y = new FileReader();
|
|
2944
|
-
y.onerror = a, y.onloadend = function(g) {
|
|
2945
|
-
var p = btoa(g.target.result || "");
|
|
2946
|
-
l({
|
|
2947
|
-
__local_forage_encoded_blob: !0,
|
|
2948
|
-
data: p,
|
|
2949
|
-
type: o.type
|
|
2950
|
-
});
|
|
2951
|
-
}, y.readAsBinaryString(o);
|
|
2952
|
-
});
|
|
2953
|
-
}
|
|
2954
|
-
function de(o) {
|
|
2955
|
-
var l = w(atob(o.data));
|
|
2956
|
-
return E([l], { type: o.type });
|
|
2957
|
-
}
|
|
2958
|
-
function bt(o) {
|
|
2959
|
-
return o && o.__local_forage_encoded_blob;
|
|
2960
|
-
}
|
|
2961
|
-
function gr(o) {
|
|
2962
|
-
var l = this, a = l._initReady().then(function() {
|
|
2963
|
-
var y = f[l._dbInfo.name];
|
|
2964
|
-
if (y && y.dbReady)
|
|
2965
|
-
return y.dbReady;
|
|
2966
|
-
});
|
|
2967
|
-
return P(a, o, o), a;
|
|
2968
|
-
}
|
|
2969
|
-
function vr(o) {
|
|
2970
|
-
$(o);
|
|
2971
|
-
for (var l = f[o.name], a = l.forages, y = 0; y < a.length; y++) {
|
|
2972
|
-
var g = a[y];
|
|
2973
|
-
g._dbInfo.db && (g._dbInfo.db.close(), g._dbInfo.db = null);
|
|
2974
|
-
}
|
|
2975
|
-
return o.db = null, ie(o).then(function(p) {
|
|
2976
|
-
return o.db = p, De(o) ? be(o) : p;
|
|
2977
|
-
}).then(function(p) {
|
|
2978
|
-
o.db = l.db = p;
|
|
2979
|
-
for (var S = 0; S < a.length; S++)
|
|
2980
|
-
a[S]._dbInfo.db = p;
|
|
2981
|
-
}).catch(function(p) {
|
|
2982
|
-
throw Z(o, p), p;
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
function oe(o, l, a, y) {
|
|
2986
|
-
y === void 0 && (y = 1);
|
|
2987
|
-
try {
|
|
2988
|
-
var g = o.db.transaction(o.storeName, l);
|
|
2989
|
-
a(null, g);
|
|
2990
|
-
} catch (p) {
|
|
2991
|
-
if (y > 0 && (!o.db || p.name === "InvalidStateError" || p.name === "NotFoundError"))
|
|
2992
|
-
return b.resolve().then(function() {
|
|
2993
|
-
if (!o.db || p.name === "NotFoundError" && !o.db.objectStoreNames.contains(o.storeName) && o.version <= o.db.version)
|
|
2994
|
-
return o.db && (o.version = o.db.version + 1), be(o);
|
|
2995
|
-
}).then(function() {
|
|
2996
|
-
return vr(o).then(function() {
|
|
2997
|
-
oe(o, l, a, y - 1);
|
|
2998
|
-
});
|
|
2999
|
-
}).catch(a);
|
|
3000
|
-
a(p);
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
function wt() {
|
|
3004
|
-
return {
|
|
3005
|
-
// Running localForages sharing a database.
|
|
3006
|
-
forages: [],
|
|
3007
|
-
// Shared database.
|
|
3008
|
-
db: null,
|
|
3009
|
-
// Database readiness (promise).
|
|
3010
|
-
dbReady: null,
|
|
3011
|
-
// Deferred operations on the database.
|
|
3012
|
-
deferredOperations: []
|
|
3013
|
-
};
|
|
3014
|
-
}
|
|
3015
|
-
function br(o) {
|
|
3016
|
-
var l = this, a = {
|
|
3017
|
-
db: null
|
|
3018
|
-
};
|
|
3019
|
-
if (o)
|
|
3020
|
-
for (var y in o)
|
|
3021
|
-
a[y] = o[y];
|
|
3022
|
-
var g = f[a.name];
|
|
3023
|
-
g || (g = wt(), f[a.name] = g), g.forages.push(l), l._initReady || (l._initReady = l.ready, l.ready = gr);
|
|
3024
|
-
var p = [];
|
|
3025
|
-
function S() {
|
|
3026
|
-
return b.resolve();
|
|
3027
|
-
}
|
|
3028
|
-
for (var O = 0; O < g.forages.length; O++) {
|
|
3029
|
-
var R = g.forages[O];
|
|
3030
|
-
R !== l && p.push(R._initReady().catch(S));
|
|
3031
|
-
}
|
|
3032
|
-
var I = g.forages.slice(0);
|
|
3033
|
-
return b.all(p).then(function() {
|
|
3034
|
-
return a.db = g.db, ie(a);
|
|
3035
|
-
}).then(function(k) {
|
|
3036
|
-
return a.db = k, De(a, l._defaultConfig.version) ? be(a) : k;
|
|
3037
|
-
}).then(function(k) {
|
|
3038
|
-
a.db = g.db = k, l._dbInfo = a;
|
|
3039
|
-
for (var N = 0; N < I.length; N++) {
|
|
3040
|
-
var B = I[N];
|
|
3041
|
-
B !== l && (B._dbInfo.db = a.db, B._dbInfo.version = a.version);
|
|
3042
|
-
}
|
|
3043
|
-
});
|
|
3044
|
-
}
|
|
3045
|
-
function wr(o, l) {
|
|
3046
|
-
var a = this;
|
|
3047
|
-
o = L(o);
|
|
3048
|
-
var y = new b(function(g, p) {
|
|
3049
|
-
a.ready().then(function() {
|
|
3050
|
-
oe(a._dbInfo, m, function(S, O) {
|
|
3051
|
-
if (S)
|
|
3052
|
-
return p(S);
|
|
3053
|
-
try {
|
|
3054
|
-
var R = O.objectStore(a._dbInfo.storeName), I = R.get(o);
|
|
3055
|
-
I.onsuccess = function() {
|
|
3056
|
-
var k = I.result;
|
|
3057
|
-
k === void 0 && (k = null), bt(k) && (k = de(k)), g(k);
|
|
3058
|
-
}, I.onerror = function() {
|
|
3059
|
-
p(I.error);
|
|
3060
|
-
};
|
|
3061
|
-
} catch (k) {
|
|
3062
|
-
p(k);
|
|
3063
|
-
}
|
|
3064
|
-
});
|
|
3065
|
-
}).catch(p);
|
|
3066
|
-
});
|
|
3067
|
-
return T(y, l), y;
|
|
3068
|
-
}
|
|
3069
|
-
function _r(o, l) {
|
|
3070
|
-
var a = this, y = new b(function(g, p) {
|
|
3071
|
-
a.ready().then(function() {
|
|
3072
|
-
oe(a._dbInfo, m, function(S, O) {
|
|
3073
|
-
if (S)
|
|
3074
|
-
return p(S);
|
|
3075
|
-
try {
|
|
3076
|
-
var R = O.objectStore(a._dbInfo.storeName), I = R.openCursor(), k = 1;
|
|
3077
|
-
I.onsuccess = function() {
|
|
3078
|
-
var N = I.result;
|
|
3079
|
-
if (N) {
|
|
3080
|
-
var B = N.value;
|
|
3081
|
-
bt(B) && (B = de(B));
|
|
3082
|
-
var M = o(B, N.key, k++);
|
|
3083
|
-
M !== void 0 ? g(M) : N.continue();
|
|
3084
|
-
} else
|
|
3085
|
-
g();
|
|
3086
|
-
}, I.onerror = function() {
|
|
3087
|
-
p(I.error);
|
|
3088
|
-
};
|
|
3089
|
-
} catch (N) {
|
|
3090
|
-
p(N);
|
|
3091
|
-
}
|
|
3092
|
-
});
|
|
3093
|
-
}).catch(p);
|
|
3094
|
-
});
|
|
3095
|
-
return T(y, l), y;
|
|
3096
|
-
}
|
|
3097
|
-
function Sr(o, l, a) {
|
|
3098
|
-
var y = this;
|
|
3099
|
-
o = L(o);
|
|
3100
|
-
var g = new b(function(p, S) {
|
|
3101
|
-
var O;
|
|
3102
|
-
y.ready().then(function() {
|
|
3103
|
-
return O = y._dbInfo, d.call(l) === "[object Blob]" ? A(O.db).then(function(R) {
|
|
3104
|
-
return R ? l : He(l);
|
|
3105
|
-
}) : l;
|
|
3106
|
-
}).then(function(R) {
|
|
3107
|
-
oe(y._dbInfo, h, function(I, k) {
|
|
3108
|
-
if (I)
|
|
3109
|
-
return S(I);
|
|
3110
|
-
try {
|
|
3111
|
-
var N = k.objectStore(y._dbInfo.storeName);
|
|
3112
|
-
R === null && (R = void 0);
|
|
3113
|
-
var B = N.put(R, o);
|
|
3114
|
-
k.oncomplete = function() {
|
|
3115
|
-
R === void 0 && (R = null), p(R);
|
|
3116
|
-
}, k.onabort = k.onerror = function() {
|
|
3117
|
-
var M = B.error ? B.error : B.transaction.error;
|
|
3118
|
-
S(M);
|
|
3119
|
-
};
|
|
3120
|
-
} catch (M) {
|
|
3121
|
-
S(M);
|
|
3122
|
-
}
|
|
3123
|
-
});
|
|
3124
|
-
}).catch(S);
|
|
3125
|
-
});
|
|
3126
|
-
return T(g, a), g;
|
|
3127
|
-
}
|
|
3128
|
-
function xr(o, l) {
|
|
3129
|
-
var a = this;
|
|
3130
|
-
o = L(o);
|
|
3131
|
-
var y = new b(function(g, p) {
|
|
3132
|
-
a.ready().then(function() {
|
|
3133
|
-
oe(a._dbInfo, h, function(S, O) {
|
|
3134
|
-
if (S)
|
|
3135
|
-
return p(S);
|
|
3136
|
-
try {
|
|
3137
|
-
var R = O.objectStore(a._dbInfo.storeName), I = R.delete(o);
|
|
3138
|
-
O.oncomplete = function() {
|
|
3139
|
-
g();
|
|
3140
|
-
}, O.onerror = function() {
|
|
3141
|
-
p(I.error);
|
|
3142
|
-
}, O.onabort = function() {
|
|
3143
|
-
var k = I.error ? I.error : I.transaction.error;
|
|
3144
|
-
p(k);
|
|
3145
|
-
};
|
|
3146
|
-
} catch (k) {
|
|
3147
|
-
p(k);
|
|
3148
|
-
}
|
|
3149
|
-
});
|
|
3150
|
-
}).catch(p);
|
|
3151
|
-
});
|
|
3152
|
-
return T(y, l), y;
|
|
3153
|
-
}
|
|
3154
|
-
function Er(o) {
|
|
3155
|
-
var l = this, a = new b(function(y, g) {
|
|
3156
|
-
l.ready().then(function() {
|
|
3157
|
-
oe(l._dbInfo, h, function(p, S) {
|
|
3158
|
-
if (p)
|
|
3159
|
-
return g(p);
|
|
3160
|
-
try {
|
|
3161
|
-
var O = S.objectStore(l._dbInfo.storeName), R = O.clear();
|
|
3162
|
-
S.oncomplete = function() {
|
|
3163
|
-
y();
|
|
3164
|
-
}, S.onabort = S.onerror = function() {
|
|
3165
|
-
var I = R.error ? R.error : R.transaction.error;
|
|
3166
|
-
g(I);
|
|
3167
|
-
};
|
|
3168
|
-
} catch (I) {
|
|
3169
|
-
g(I);
|
|
3170
|
-
}
|
|
3171
|
-
});
|
|
3172
|
-
}).catch(g);
|
|
3173
|
-
});
|
|
3174
|
-
return T(a, o), a;
|
|
3175
|
-
}
|
|
3176
|
-
function Or(o) {
|
|
3177
|
-
var l = this, a = new b(function(y, g) {
|
|
3178
|
-
l.ready().then(function() {
|
|
3179
|
-
oe(l._dbInfo, m, function(p, S) {
|
|
3180
|
-
if (p)
|
|
3181
|
-
return g(p);
|
|
3182
|
-
try {
|
|
3183
|
-
var O = S.objectStore(l._dbInfo.storeName), R = O.count();
|
|
3184
|
-
R.onsuccess = function() {
|
|
3185
|
-
y(R.result);
|
|
3186
|
-
}, R.onerror = function() {
|
|
3187
|
-
g(R.error);
|
|
3188
|
-
};
|
|
3189
|
-
} catch (I) {
|
|
3190
|
-
g(I);
|
|
3191
|
-
}
|
|
3192
|
-
});
|
|
3193
|
-
}).catch(g);
|
|
3194
|
-
});
|
|
3195
|
-
return T(a, o), a;
|
|
3196
|
-
}
|
|
3197
|
-
function Rr(o, l) {
|
|
3198
|
-
var a = this, y = new b(function(g, p) {
|
|
3199
|
-
if (o < 0) {
|
|
3200
|
-
g(null);
|
|
3201
|
-
return;
|
|
3202
|
-
}
|
|
3203
|
-
a.ready().then(function() {
|
|
3204
|
-
oe(a._dbInfo, m, function(S, O) {
|
|
3205
|
-
if (S)
|
|
3206
|
-
return p(S);
|
|
3207
|
-
try {
|
|
3208
|
-
var R = O.objectStore(a._dbInfo.storeName), I = !1, k = R.openKeyCursor();
|
|
3209
|
-
k.onsuccess = function() {
|
|
3210
|
-
var N = k.result;
|
|
3211
|
-
if (!N) {
|
|
3212
|
-
g(null);
|
|
3213
|
-
return;
|
|
3214
|
-
}
|
|
3215
|
-
o === 0 || I ? g(N.key) : (I = !0, N.advance(o));
|
|
3216
|
-
}, k.onerror = function() {
|
|
3217
|
-
p(k.error);
|
|
3218
|
-
};
|
|
3219
|
-
} catch (N) {
|
|
3220
|
-
p(N);
|
|
3221
|
-
}
|
|
3222
|
-
});
|
|
3223
|
-
}).catch(p);
|
|
3224
|
-
});
|
|
3225
|
-
return T(y, l), y;
|
|
3226
|
-
}
|
|
3227
|
-
function Ir(o) {
|
|
3228
|
-
var l = this, a = new b(function(y, g) {
|
|
3229
|
-
l.ready().then(function() {
|
|
3230
|
-
oe(l._dbInfo, m, function(p, S) {
|
|
3231
|
-
if (p)
|
|
3232
|
-
return g(p);
|
|
3233
|
-
try {
|
|
3234
|
-
var O = S.objectStore(l._dbInfo.storeName), R = O.openKeyCursor(), I = [];
|
|
3235
|
-
R.onsuccess = function() {
|
|
3236
|
-
var k = R.result;
|
|
3237
|
-
if (!k) {
|
|
3238
|
-
y(I);
|
|
3239
|
-
return;
|
|
3240
|
-
}
|
|
3241
|
-
I.push(k.key), k.continue();
|
|
3242
|
-
}, R.onerror = function() {
|
|
3243
|
-
g(R.error);
|
|
3244
|
-
};
|
|
3245
|
-
} catch (k) {
|
|
3246
|
-
g(k);
|
|
3247
|
-
}
|
|
3248
|
-
});
|
|
3249
|
-
}).catch(g);
|
|
3250
|
-
});
|
|
3251
|
-
return T(a, o), a;
|
|
3252
|
-
}
|
|
3253
|
-
function Ar(o, l) {
|
|
3254
|
-
l = Y.apply(this, arguments);
|
|
3255
|
-
var a = this.config();
|
|
3256
|
-
o = typeof o != "function" && o || {}, o.name || (o.name = o.name || a.name, o.storeName = o.storeName || a.storeName);
|
|
3257
|
-
var y = this, g;
|
|
3258
|
-
if (!o.name)
|
|
3259
|
-
g = b.reject("Invalid arguments");
|
|
3260
|
-
else {
|
|
3261
|
-
var p = o.name === a.name && y._dbInfo.db, S = p ? b.resolve(y._dbInfo.db) : ie(o).then(function(O) {
|
|
3262
|
-
var R = f[o.name], I = R.forages;
|
|
3263
|
-
R.db = O;
|
|
3264
|
-
for (var k = 0; k < I.length; k++)
|
|
3265
|
-
I[k]._dbInfo.db = O;
|
|
3266
|
-
return O;
|
|
3267
|
-
});
|
|
3268
|
-
o.storeName ? g = S.then(function(O) {
|
|
3269
|
-
if (O.objectStoreNames.contains(o.storeName)) {
|
|
3270
|
-
var R = O.version + 1;
|
|
3271
|
-
$(o);
|
|
3272
|
-
var I = f[o.name], k = I.forages;
|
|
3273
|
-
O.close();
|
|
3274
|
-
for (var N = 0; N < k.length; N++) {
|
|
3275
|
-
var B = k[N];
|
|
3276
|
-
B._dbInfo.db = null, B._dbInfo.version = R;
|
|
3277
|
-
}
|
|
3278
|
-
var M = new b(function(q, K) {
|
|
3279
|
-
var H = v.open(o.name, R);
|
|
3280
|
-
H.onerror = function(te) {
|
|
3281
|
-
var _e = H.result;
|
|
3282
|
-
_e.close(), K(te);
|
|
3283
|
-
}, H.onupgradeneeded = function() {
|
|
3284
|
-
var te = H.result;
|
|
3285
|
-
te.deleteObjectStore(o.storeName);
|
|
3286
|
-
}, H.onsuccess = function() {
|
|
3287
|
-
var te = H.result;
|
|
3288
|
-
te.close(), q(te);
|
|
3289
|
-
};
|
|
3290
|
-
});
|
|
3291
|
-
return M.then(function(q) {
|
|
3292
|
-
I.db = q;
|
|
3293
|
-
for (var K = 0; K < k.length; K++) {
|
|
3294
|
-
var H = k[K];
|
|
3295
|
-
H._dbInfo.db = q, V(H._dbInfo);
|
|
3296
|
-
}
|
|
3297
|
-
}).catch(function(q) {
|
|
3298
|
-
throw (Z(o, q) || b.resolve()).catch(function() {
|
|
3299
|
-
}), q;
|
|
3300
|
-
});
|
|
3301
|
-
}
|
|
3302
|
-
}) : g = S.then(function(O) {
|
|
3303
|
-
$(o);
|
|
3304
|
-
var R = f[o.name], I = R.forages;
|
|
3305
|
-
O.close();
|
|
3306
|
-
for (var k = 0; k < I.length; k++) {
|
|
3307
|
-
var N = I[k];
|
|
3308
|
-
N._dbInfo.db = null;
|
|
3309
|
-
}
|
|
3310
|
-
var B = new b(function(M, q) {
|
|
3311
|
-
var K = v.deleteDatabase(o.name);
|
|
3312
|
-
K.onerror = function() {
|
|
3313
|
-
var H = K.result;
|
|
3314
|
-
H && H.close(), q(K.error);
|
|
3315
|
-
}, K.onblocked = function() {
|
|
3316
|
-
console.warn('dropInstance blocked for database "' + o.name + '" until all open connections are closed');
|
|
3317
|
-
}, K.onsuccess = function() {
|
|
3318
|
-
var H = K.result;
|
|
3319
|
-
H && H.close(), M(H);
|
|
3320
|
-
};
|
|
3321
|
-
});
|
|
3322
|
-
return B.then(function(M) {
|
|
3323
|
-
R.db = M;
|
|
3324
|
-
for (var q = 0; q < I.length; q++) {
|
|
3325
|
-
var K = I[q];
|
|
3326
|
-
V(K._dbInfo);
|
|
3327
|
-
}
|
|
3328
|
-
}).catch(function(M) {
|
|
3329
|
-
throw (Z(o, M) || b.resolve()).catch(function() {
|
|
3330
|
-
}), M;
|
|
3331
|
-
});
|
|
3332
|
-
});
|
|
3333
|
-
}
|
|
3334
|
-
return T(g, l), g;
|
|
3335
|
-
}
|
|
3336
|
-
var kr = {
|
|
3337
|
-
_driver: "asyncStorage",
|
|
3338
|
-
_initStorage: br,
|
|
3339
|
-
_support: _(),
|
|
3340
|
-
iterate: _r,
|
|
3341
|
-
getItem: wr,
|
|
3342
|
-
setItem: Sr,
|
|
3343
|
-
removeItem: xr,
|
|
3344
|
-
clear: Er,
|
|
3345
|
-
length: Or,
|
|
3346
|
-
key: Rr,
|
|
3347
|
-
keys: Ir,
|
|
3348
|
-
dropInstance: Ar
|
|
3349
|
-
};
|
|
3350
|
-
function Pr() {
|
|
3351
|
-
return typeof openDatabase == "function";
|
|
3352
|
-
}
|
|
3353
|
-
var ae = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Dr = "~~local_forage_type~", _t = /^~~local_forage_type~([^~]+)~/, Te = "__lfsc__:", ze = Te.length, Ye = "arbf", Ke = "blob", St = "si08", xt = "ui08", Et = "uic8", Ot = "si16", Rt = "si32", It = "ur16", At = "ui32", kt = "fl32", Pt = "fl64", Dt = ze + Ye.length, Tt = Object.prototype.toString;
|
|
3354
|
-
function Lt(o) {
|
|
3355
|
-
var l = o.length * 0.75, a = o.length, y, g = 0, p, S, O, R;
|
|
3356
|
-
o[o.length - 1] === "=" && (l--, o[o.length - 2] === "=" && l--);
|
|
3357
|
-
var I = new ArrayBuffer(l), k = new Uint8Array(I);
|
|
3358
|
-
for (y = 0; y < a; y += 4)
|
|
3359
|
-
p = ae.indexOf(o[y]), S = ae.indexOf(o[y + 1]), O = ae.indexOf(o[y + 2]), R = ae.indexOf(o[y + 3]), k[g++] = p << 2 | S >> 4, k[g++] = (S & 15) << 4 | O >> 2, k[g++] = (O & 3) << 6 | R & 63;
|
|
3360
|
-
return I;
|
|
3361
|
-
}
|
|
3362
|
-
function Ge(o) {
|
|
3363
|
-
var l = new Uint8Array(o), a = "", y;
|
|
3364
|
-
for (y = 0; y < l.length; y += 3)
|
|
3365
|
-
a += ae[l[y] >> 2], a += ae[(l[y] & 3) << 4 | l[y + 1] >> 4], a += ae[(l[y + 1] & 15) << 2 | l[y + 2] >> 6], a += ae[l[y + 2] & 63];
|
|
3366
|
-
return l.length % 3 === 2 ? a = a.substring(0, a.length - 1) + "=" : l.length % 3 === 1 && (a = a.substring(0, a.length - 2) + "=="), a;
|
|
3367
|
-
}
|
|
3368
|
-
function Tr(o, l) {
|
|
3369
|
-
var a = "";
|
|
3370
|
-
if (o && (a = Tt.call(o)), o && (a === "[object ArrayBuffer]" || o.buffer && Tt.call(o.buffer) === "[object ArrayBuffer]")) {
|
|
3371
|
-
var y, g = Te;
|
|
3372
|
-
o instanceof ArrayBuffer ? (y = o, g += Ye) : (y = o.buffer, a === "[object Int8Array]" ? g += St : a === "[object Uint8Array]" ? g += xt : a === "[object Uint8ClampedArray]" ? g += Et : a === "[object Int16Array]" ? g += Ot : a === "[object Uint16Array]" ? g += It : a === "[object Int32Array]" ? g += Rt : a === "[object Uint32Array]" ? g += At : a === "[object Float32Array]" ? g += kt : a === "[object Float64Array]" ? g += Pt : l(new Error("Failed to get type for BinaryArray"))), l(g + Ge(y));
|
|
3373
|
-
} else if (a === "[object Blob]") {
|
|
3374
|
-
var p = new FileReader();
|
|
3375
|
-
p.onload = function() {
|
|
3376
|
-
var S = Dr + o.type + "~" + Ge(this.result);
|
|
3377
|
-
l(Te + Ke + S);
|
|
3378
|
-
}, p.readAsArrayBuffer(o);
|
|
3379
|
-
} else
|
|
3380
|
-
try {
|
|
3381
|
-
l(JSON.stringify(o));
|
|
3382
|
-
} catch (S) {
|
|
3383
|
-
console.error("Couldn't convert value into a JSON string: ", o), l(null, S);
|
|
3384
|
-
}
|
|
3385
|
-
}
|
|
3386
|
-
function Lr(o) {
|
|
3387
|
-
if (o.substring(0, ze) !== Te)
|
|
3388
|
-
return JSON.parse(o);
|
|
3389
|
-
var l = o.substring(Dt), a = o.substring(ze, Dt), y;
|
|
3390
|
-
if (a === Ke && _t.test(l)) {
|
|
3391
|
-
var g = l.match(_t);
|
|
3392
|
-
y = g[1], l = l.substring(g[0].length);
|
|
3393
|
-
}
|
|
3394
|
-
var p = Lt(l);
|
|
3395
|
-
switch (a) {
|
|
3396
|
-
case Ye:
|
|
3397
|
-
return p;
|
|
3398
|
-
case Ke:
|
|
3399
|
-
return E([p], { type: y });
|
|
3400
|
-
case St:
|
|
3401
|
-
return new Int8Array(p);
|
|
3402
|
-
case xt:
|
|
3403
|
-
return new Uint8Array(p);
|
|
3404
|
-
case Et:
|
|
3405
|
-
return new Uint8ClampedArray(p);
|
|
3406
|
-
case Ot:
|
|
3407
|
-
return new Int16Array(p);
|
|
3408
|
-
case It:
|
|
3409
|
-
return new Uint16Array(p);
|
|
3410
|
-
case Rt:
|
|
3411
|
-
return new Int32Array(p);
|
|
3412
|
-
case At:
|
|
3413
|
-
return new Uint32Array(p);
|
|
3414
|
-
case kt:
|
|
3415
|
-
return new Float32Array(p);
|
|
3416
|
-
case Pt:
|
|
3417
|
-
return new Float64Array(p);
|
|
3418
|
-
default:
|
|
3419
|
-
throw new Error("Unkown type: " + a);
|
|
3420
|
-
}
|
|
3421
|
-
}
|
|
3422
|
-
var Ve = {
|
|
3423
|
-
serialize: Tr,
|
|
3424
|
-
deserialize: Lr,
|
|
3425
|
-
stringToBuffer: Lt,
|
|
3426
|
-
bufferToString: Ge
|
|
3427
|
-
};
|
|
3428
|
-
function Nt(o, l, a, y) {
|
|
3429
|
-
o.executeSql("CREATE TABLE IF NOT EXISTS " + l.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], a, y);
|
|
3430
|
-
}
|
|
3431
|
-
function Nr(o) {
|
|
3432
|
-
var l = this, a = {
|
|
3433
|
-
db: null
|
|
3434
|
-
};
|
|
3435
|
-
if (o)
|
|
3436
|
-
for (var y in o)
|
|
3437
|
-
a[y] = typeof o[y] != "string" ? o[y].toString() : o[y];
|
|
3438
|
-
var g = new b(function(p, S) {
|
|
3439
|
-
try {
|
|
3440
|
-
a.db = openDatabase(a.name, String(a.version), a.description, a.size);
|
|
3441
|
-
} catch (O) {
|
|
3442
|
-
return S(O);
|
|
3443
|
-
}
|
|
3444
|
-
a.db.transaction(function(O) {
|
|
3445
|
-
Nt(O, a, function() {
|
|
3446
|
-
l._dbInfo = a, p();
|
|
3447
|
-
}, function(R, I) {
|
|
3448
|
-
S(I);
|
|
3449
|
-
});
|
|
3450
|
-
}, S);
|
|
3451
|
-
});
|
|
3452
|
-
return a.serializer = Ve, g;
|
|
3453
|
-
}
|
|
3454
|
-
function ce(o, l, a, y, g, p) {
|
|
3455
|
-
o.executeSql(a, y, g, function(S, O) {
|
|
3456
|
-
O.code === O.SYNTAX_ERR ? S.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [l.storeName], function(R, I) {
|
|
3457
|
-
I.rows.length ? p(R, O) : Nt(R, l, function() {
|
|
3458
|
-
R.executeSql(a, y, g, p);
|
|
3459
|
-
}, p);
|
|
3460
|
-
}, p) : p(S, O);
|
|
3461
|
-
}, p);
|
|
3462
|
-
}
|
|
3463
|
-
function Cr(o, l) {
|
|
3464
|
-
var a = this;
|
|
3465
|
-
o = L(o);
|
|
3466
|
-
var y = new b(function(g, p) {
|
|
3467
|
-
a.ready().then(function() {
|
|
3468
|
-
var S = a._dbInfo;
|
|
3469
|
-
S.db.transaction(function(O) {
|
|
3470
|
-
ce(O, S, "SELECT * FROM " + S.storeName + " WHERE key = ? LIMIT 1", [o], function(R, I) {
|
|
3471
|
-
var k = I.rows.length ? I.rows.item(0).value : null;
|
|
3472
|
-
k && (k = S.serializer.deserialize(k)), g(k);
|
|
3473
|
-
}, function(R, I) {
|
|
3474
|
-
p(I);
|
|
3475
|
-
});
|
|
3476
|
-
});
|
|
3477
|
-
}).catch(p);
|
|
3478
|
-
});
|
|
3479
|
-
return T(y, l), y;
|
|
3480
|
-
}
|
|
3481
|
-
function $r(o, l) {
|
|
3482
|
-
var a = this, y = new b(function(g, p) {
|
|
3483
|
-
a.ready().then(function() {
|
|
3484
|
-
var S = a._dbInfo;
|
|
3485
|
-
S.db.transaction(function(O) {
|
|
3486
|
-
ce(O, S, "SELECT * FROM " + S.storeName, [], function(R, I) {
|
|
3487
|
-
for (var k = I.rows, N = k.length, B = 0; B < N; B++) {
|
|
3488
|
-
var M = k.item(B), q = M.value;
|
|
3489
|
-
if (q && (q = S.serializer.deserialize(q)), q = o(q, M.key, B + 1), q !== void 0) {
|
|
3490
|
-
g(q);
|
|
3491
|
-
return;
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
g();
|
|
3495
|
-
}, function(R, I) {
|
|
3496
|
-
p(I);
|
|
3497
|
-
});
|
|
3498
|
-
});
|
|
3499
|
-
}).catch(p);
|
|
3500
|
-
});
|
|
3501
|
-
return T(y, l), y;
|
|
3502
|
-
}
|
|
3503
|
-
function Ct(o, l, a, y) {
|
|
3504
|
-
var g = this;
|
|
3505
|
-
o = L(o);
|
|
3506
|
-
var p = new b(function(S, O) {
|
|
3507
|
-
g.ready().then(function() {
|
|
3508
|
-
l === void 0 && (l = null);
|
|
3509
|
-
var R = l, I = g._dbInfo;
|
|
3510
|
-
I.serializer.serialize(l, function(k, N) {
|
|
3511
|
-
N ? O(N) : I.db.transaction(function(B) {
|
|
3512
|
-
ce(B, I, "INSERT OR REPLACE INTO " + I.storeName + " (key, value) VALUES (?, ?)", [o, k], function() {
|
|
3513
|
-
S(R);
|
|
3514
|
-
}, function(M, q) {
|
|
3515
|
-
O(q);
|
|
3516
|
-
});
|
|
3517
|
-
}, function(B) {
|
|
3518
|
-
if (B.code === B.QUOTA_ERR) {
|
|
3519
|
-
if (y > 0) {
|
|
3520
|
-
S(Ct.apply(g, [o, R, a, y - 1]));
|
|
3521
|
-
return;
|
|
3522
|
-
}
|
|
3523
|
-
O(B);
|
|
3524
|
-
}
|
|
3525
|
-
});
|
|
3526
|
-
});
|
|
3527
|
-
}).catch(O);
|
|
3528
|
-
});
|
|
3529
|
-
return T(p, a), p;
|
|
3530
|
-
}
|
|
3531
|
-
function jr(o, l, a) {
|
|
3532
|
-
return Ct.apply(this, [o, l, a, 1]);
|
|
3533
|
-
}
|
|
3534
|
-
function Br(o, l) {
|
|
3535
|
-
var a = this;
|
|
3536
|
-
o = L(o);
|
|
3537
|
-
var y = new b(function(g, p) {
|
|
3538
|
-
a.ready().then(function() {
|
|
3539
|
-
var S = a._dbInfo;
|
|
3540
|
-
S.db.transaction(function(O) {
|
|
3541
|
-
ce(O, S, "DELETE FROM " + S.storeName + " WHERE key = ?", [o], function() {
|
|
3542
|
-
g();
|
|
3543
|
-
}, function(R, I) {
|
|
3544
|
-
p(I);
|
|
3545
|
-
});
|
|
3546
|
-
});
|
|
3547
|
-
}).catch(p);
|
|
3548
|
-
});
|
|
3549
|
-
return T(y, l), y;
|
|
3550
|
-
}
|
|
3551
|
-
function Ur(o) {
|
|
3552
|
-
var l = this, a = new b(function(y, g) {
|
|
3553
|
-
l.ready().then(function() {
|
|
3554
|
-
var p = l._dbInfo;
|
|
3555
|
-
p.db.transaction(function(S) {
|
|
3556
|
-
ce(S, p, "DELETE FROM " + p.storeName, [], function() {
|
|
3557
|
-
y();
|
|
3558
|
-
}, function(O, R) {
|
|
3559
|
-
g(R);
|
|
3560
|
-
});
|
|
3561
|
-
});
|
|
3562
|
-
}).catch(g);
|
|
3563
|
-
});
|
|
3564
|
-
return T(a, o), a;
|
|
3565
|
-
}
|
|
3566
|
-
function Fr(o) {
|
|
3567
|
-
var l = this, a = new b(function(y, g) {
|
|
3568
|
-
l.ready().then(function() {
|
|
3569
|
-
var p = l._dbInfo;
|
|
3570
|
-
p.db.transaction(function(S) {
|
|
3571
|
-
ce(S, p, "SELECT COUNT(key) as c FROM " + p.storeName, [], function(O, R) {
|
|
3572
|
-
var I = R.rows.item(0).c;
|
|
3573
|
-
y(I);
|
|
3574
|
-
}, function(O, R) {
|
|
3575
|
-
g(R);
|
|
3576
|
-
});
|
|
3577
|
-
});
|
|
3578
|
-
}).catch(g);
|
|
3579
|
-
});
|
|
3580
|
-
return T(a, o), a;
|
|
3581
|
-
}
|
|
3582
|
-
function Mr(o, l) {
|
|
3583
|
-
var a = this, y = new b(function(g, p) {
|
|
3584
|
-
a.ready().then(function() {
|
|
3585
|
-
var S = a._dbInfo;
|
|
3586
|
-
S.db.transaction(function(O) {
|
|
3587
|
-
ce(O, S, "SELECT key FROM " + S.storeName + " WHERE id = ? LIMIT 1", [o + 1], function(R, I) {
|
|
3588
|
-
var k = I.rows.length ? I.rows.item(0).key : null;
|
|
3589
|
-
g(k);
|
|
3590
|
-
}, function(R, I) {
|
|
3591
|
-
p(I);
|
|
3592
|
-
});
|
|
3593
|
-
});
|
|
3594
|
-
}).catch(p);
|
|
3595
|
-
});
|
|
3596
|
-
return T(y, l), y;
|
|
3597
|
-
}
|
|
3598
|
-
function qr(o) {
|
|
3599
|
-
var l = this, a = new b(function(y, g) {
|
|
3600
|
-
l.ready().then(function() {
|
|
3601
|
-
var p = l._dbInfo;
|
|
3602
|
-
p.db.transaction(function(S) {
|
|
3603
|
-
ce(S, p, "SELECT key FROM " + p.storeName, [], function(O, R) {
|
|
3604
|
-
for (var I = [], k = 0; k < R.rows.length; k++)
|
|
3605
|
-
I.push(R.rows.item(k).key);
|
|
3606
|
-
y(I);
|
|
3607
|
-
}, function(O, R) {
|
|
3608
|
-
g(R);
|
|
3609
|
-
});
|
|
3610
|
-
});
|
|
3611
|
-
}).catch(g);
|
|
3612
|
-
});
|
|
3613
|
-
return T(a, o), a;
|
|
3614
|
-
}
|
|
3615
|
-
function Wr(o) {
|
|
3616
|
-
return new b(function(l, a) {
|
|
3617
|
-
o.transaction(function(y) {
|
|
3618
|
-
y.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(g, p) {
|
|
3619
|
-
for (var S = [], O = 0; O < p.rows.length; O++)
|
|
3620
|
-
S.push(p.rows.item(O).name);
|
|
3621
|
-
l({
|
|
3622
|
-
db: o,
|
|
3623
|
-
storeNames: S
|
|
3624
|
-
});
|
|
3625
|
-
}, function(g, p) {
|
|
3626
|
-
a(p);
|
|
3627
|
-
});
|
|
3628
|
-
}, function(y) {
|
|
3629
|
-
a(y);
|
|
3630
|
-
});
|
|
3631
|
-
});
|
|
3632
|
-
}
|
|
3633
|
-
function Hr(o, l) {
|
|
3634
|
-
l = Y.apply(this, arguments);
|
|
3635
|
-
var a = this.config();
|
|
3636
|
-
o = typeof o != "function" && o || {}, o.name || (o.name = o.name || a.name, o.storeName = o.storeName || a.storeName);
|
|
3637
|
-
var y = this, g;
|
|
3638
|
-
return o.name ? g = new b(function(p) {
|
|
3639
|
-
var S;
|
|
3640
|
-
o.name === a.name ? S = y._dbInfo.db : S = openDatabase(o.name, "", "", 0), o.storeName ? p({
|
|
3641
|
-
db: S,
|
|
3642
|
-
storeNames: [o.storeName]
|
|
3643
|
-
}) : p(Wr(S));
|
|
3644
|
-
}).then(function(p) {
|
|
3645
|
-
return new b(function(S, O) {
|
|
3646
|
-
p.db.transaction(function(R) {
|
|
3647
|
-
function I(M) {
|
|
3648
|
-
return new b(function(q, K) {
|
|
3649
|
-
R.executeSql("DROP TABLE IF EXISTS " + M, [], function() {
|
|
3650
|
-
q();
|
|
3651
|
-
}, function(H, te) {
|
|
3652
|
-
K(te);
|
|
3653
|
-
});
|
|
3654
|
-
});
|
|
3655
|
-
}
|
|
3656
|
-
for (var k = [], N = 0, B = p.storeNames.length; N < B; N++)
|
|
3657
|
-
k.push(I(p.storeNames[N]));
|
|
3658
|
-
b.all(k).then(function() {
|
|
3659
|
-
S();
|
|
3660
|
-
}).catch(function(M) {
|
|
3661
|
-
O(M);
|
|
3662
|
-
});
|
|
3663
|
-
}, function(R) {
|
|
3664
|
-
O(R);
|
|
3665
|
-
});
|
|
3666
|
-
});
|
|
3667
|
-
}) : g = b.reject("Invalid arguments"), T(g, l), g;
|
|
3668
|
-
}
|
|
3669
|
-
var zr = {
|
|
3670
|
-
_driver: "webSQLStorage",
|
|
3671
|
-
_initStorage: Nr,
|
|
3672
|
-
_support: Pr(),
|
|
3673
|
-
iterate: $r,
|
|
3674
|
-
getItem: Cr,
|
|
3675
|
-
setItem: jr,
|
|
3676
|
-
removeItem: Br,
|
|
3677
|
-
clear: Ur,
|
|
3678
|
-
length: Fr,
|
|
3679
|
-
key: Mr,
|
|
3680
|
-
keys: qr,
|
|
3681
|
-
dropInstance: Hr
|
|
3682
|
-
};
|
|
3683
|
-
function Yr() {
|
|
3684
|
-
try {
|
|
3685
|
-
return typeof localStorage < "u" && "setItem" in localStorage && // in IE8 typeof localStorage.setItem === 'object'
|
|
3686
|
-
!!localStorage.setItem;
|
|
3687
|
-
} catch {
|
|
3688
|
-
return !1;
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
function $t(o, l) {
|
|
3692
|
-
var a = o.name + "/";
|
|
3693
|
-
return o.storeName !== l.storeName && (a += o.storeName + "/"), a;
|
|
3694
|
-
}
|
|
3695
|
-
function Kr() {
|
|
3696
|
-
var o = "_localforage_support_test";
|
|
3697
|
-
try {
|
|
3698
|
-
return localStorage.setItem(o, !0), localStorage.removeItem(o), !1;
|
|
3699
|
-
} catch {
|
|
3700
|
-
return !0;
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
function Gr() {
|
|
3704
|
-
return !Kr() || localStorage.length > 0;
|
|
3705
|
-
}
|
|
3706
|
-
function Vr(o) {
|
|
3707
|
-
var l = this, a = {};
|
|
3708
|
-
if (o)
|
|
3709
|
-
for (var y in o)
|
|
3710
|
-
a[y] = o[y];
|
|
3711
|
-
return a.keyPrefix = $t(o, l._defaultConfig), Gr() ? (l._dbInfo = a, a.serializer = Ve, b.resolve()) : b.reject();
|
|
3712
|
-
}
|
|
3713
|
-
function Jr(o) {
|
|
3714
|
-
var l = this, a = l.ready().then(function() {
|
|
3715
|
-
for (var y = l._dbInfo.keyPrefix, g = localStorage.length - 1; g >= 0; g--) {
|
|
3716
|
-
var p = localStorage.key(g);
|
|
3717
|
-
p.indexOf(y) === 0 && localStorage.removeItem(p);
|
|
3718
|
-
}
|
|
3719
|
-
});
|
|
3720
|
-
return T(a, o), a;
|
|
3721
|
-
}
|
|
3722
|
-
function Qr(o, l) {
|
|
3723
|
-
var a = this;
|
|
3724
|
-
o = L(o);
|
|
3725
|
-
var y = a.ready().then(function() {
|
|
3726
|
-
var g = a._dbInfo, p = localStorage.getItem(g.keyPrefix + o);
|
|
3727
|
-
return p && (p = g.serializer.deserialize(p)), p;
|
|
3728
|
-
});
|
|
3729
|
-
return T(y, l), y;
|
|
3730
|
-
}
|
|
3731
|
-
function Xr(o, l) {
|
|
3732
|
-
var a = this, y = a.ready().then(function() {
|
|
3733
|
-
for (var g = a._dbInfo, p = g.keyPrefix, S = p.length, O = localStorage.length, R = 1, I = 0; I < O; I++) {
|
|
3734
|
-
var k = localStorage.key(I);
|
|
3735
|
-
if (k.indexOf(p) === 0) {
|
|
3736
|
-
var N = localStorage.getItem(k);
|
|
3737
|
-
if (N && (N = g.serializer.deserialize(N)), N = o(N, k.substring(S), R++), N !== void 0)
|
|
3738
|
-
return N;
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
});
|
|
3742
|
-
return T(y, l), y;
|
|
3743
|
-
}
|
|
3744
|
-
function Zr(o, l) {
|
|
3745
|
-
var a = this, y = a.ready().then(function() {
|
|
3746
|
-
var g = a._dbInfo, p;
|
|
3747
|
-
try {
|
|
3748
|
-
p = localStorage.key(o);
|
|
3749
|
-
} catch {
|
|
3750
|
-
p = null;
|
|
3751
|
-
}
|
|
3752
|
-
return p && (p = p.substring(g.keyPrefix.length)), p;
|
|
3753
|
-
});
|
|
3754
|
-
return T(y, l), y;
|
|
3755
|
-
}
|
|
3756
|
-
function en(o) {
|
|
3757
|
-
var l = this, a = l.ready().then(function() {
|
|
3758
|
-
for (var y = l._dbInfo, g = localStorage.length, p = [], S = 0; S < g; S++) {
|
|
3759
|
-
var O = localStorage.key(S);
|
|
3760
|
-
O.indexOf(y.keyPrefix) === 0 && p.push(O.substring(y.keyPrefix.length));
|
|
3761
|
-
}
|
|
3762
|
-
return p;
|
|
3763
|
-
});
|
|
3764
|
-
return T(a, o), a;
|
|
3765
|
-
}
|
|
3766
|
-
function tn(o) {
|
|
3767
|
-
var l = this, a = l.keys().then(function(y) {
|
|
3768
|
-
return y.length;
|
|
3769
|
-
});
|
|
3770
|
-
return T(a, o), a;
|
|
3771
|
-
}
|
|
3772
|
-
function rn(o, l) {
|
|
3773
|
-
var a = this;
|
|
3774
|
-
o = L(o);
|
|
3775
|
-
var y = a.ready().then(function() {
|
|
3776
|
-
var g = a._dbInfo;
|
|
3777
|
-
localStorage.removeItem(g.keyPrefix + o);
|
|
3778
|
-
});
|
|
3779
|
-
return T(y, l), y;
|
|
3780
|
-
}
|
|
3781
|
-
function nn(o, l, a) {
|
|
3782
|
-
var y = this;
|
|
3783
|
-
o = L(o);
|
|
3784
|
-
var g = y.ready().then(function() {
|
|
3785
|
-
l === void 0 && (l = null);
|
|
3786
|
-
var p = l;
|
|
3787
|
-
return new b(function(S, O) {
|
|
3788
|
-
var R = y._dbInfo;
|
|
3789
|
-
R.serializer.serialize(l, function(I, k) {
|
|
3790
|
-
if (k)
|
|
3791
|
-
O(k);
|
|
3792
|
-
else
|
|
3793
|
-
try {
|
|
3794
|
-
localStorage.setItem(R.keyPrefix + o, I), S(p);
|
|
3795
|
-
} catch (N) {
|
|
3796
|
-
(N.name === "QuotaExceededError" || N.name === "NS_ERROR_DOM_QUOTA_REACHED") && O(N), O(N);
|
|
3797
|
-
}
|
|
3798
|
-
});
|
|
3799
|
-
});
|
|
3800
|
-
});
|
|
3801
|
-
return T(g, a), g;
|
|
3802
|
-
}
|
|
3803
|
-
function on(o, l) {
|
|
3804
|
-
if (l = Y.apply(this, arguments), o = typeof o != "function" && o || {}, !o.name) {
|
|
3805
|
-
var a = this.config();
|
|
3806
|
-
o.name = o.name || a.name, o.storeName = o.storeName || a.storeName;
|
|
3807
|
-
}
|
|
3808
|
-
var y = this, g;
|
|
3809
|
-
return o.name ? g = new b(function(p) {
|
|
3810
|
-
o.storeName ? p($t(o, y._defaultConfig)) : p(o.name + "/");
|
|
3811
|
-
}).then(function(p) {
|
|
3812
|
-
for (var S = localStorage.length - 1; S >= 0; S--) {
|
|
3813
|
-
var O = localStorage.key(S);
|
|
3814
|
-
O.indexOf(p) === 0 && localStorage.removeItem(O);
|
|
3815
|
-
}
|
|
3816
|
-
}) : g = b.reject("Invalid arguments"), T(g, l), g;
|
|
3817
|
-
}
|
|
3818
|
-
var sn = {
|
|
3819
|
-
_driver: "localStorageWrapper",
|
|
3820
|
-
_initStorage: Vr,
|
|
3821
|
-
_support: Yr(),
|
|
3822
|
-
iterate: Xr,
|
|
3823
|
-
getItem: Qr,
|
|
3824
|
-
setItem: nn,
|
|
3825
|
-
removeItem: rn,
|
|
3826
|
-
clear: Jr,
|
|
3827
|
-
length: tn,
|
|
3828
|
-
key: Zr,
|
|
3829
|
-
keys: en,
|
|
3830
|
-
dropInstance: on
|
|
3831
|
-
}, an = function(l, a) {
|
|
3832
|
-
return l === a || typeof l == "number" && typeof a == "number" && isNaN(l) && isNaN(a);
|
|
3833
|
-
}, cn = function(l, a) {
|
|
3834
|
-
for (var y = l.length, g = 0; g < y; ) {
|
|
3835
|
-
if (an(l[g], a))
|
|
3836
|
-
return !0;
|
|
3837
|
-
g++;
|
|
3838
|
-
}
|
|
3839
|
-
return !1;
|
|
3840
|
-
}, jt = Array.isArray || function(o) {
|
|
3841
|
-
return Object.prototype.toString.call(o) === "[object Array]";
|
|
3842
|
-
}, we = {}, Bt = {}, pe = {
|
|
3843
|
-
INDEXEDDB: kr,
|
|
3844
|
-
WEBSQL: zr,
|
|
3845
|
-
LOCALSTORAGE: sn
|
|
3846
|
-
}, un = [pe.INDEXEDDB._driver, pe.WEBSQL._driver, pe.LOCALSTORAGE._driver], Le = ["dropInstance"], Je = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(Le), fn = {
|
|
3847
|
-
description: "",
|
|
3848
|
-
driver: un.slice(),
|
|
3849
|
-
name: "localforage",
|
|
3850
|
-
// Default DB size is _JUST UNDER_ 5MB, as it's the highest size
|
|
3851
|
-
// we can use without a prompt.
|
|
3852
|
-
size: 4980736,
|
|
3853
|
-
storeName: "keyvaluepairs",
|
|
3854
|
-
version: 1
|
|
3855
|
-
};
|
|
3856
|
-
function ln(o, l) {
|
|
3857
|
-
o[l] = function() {
|
|
3858
|
-
var a = arguments;
|
|
3859
|
-
return o.ready().then(function() {
|
|
3860
|
-
return o[l].apply(o, a);
|
|
3861
|
-
});
|
|
3862
|
-
};
|
|
3863
|
-
}
|
|
3864
|
-
function Qe() {
|
|
3865
|
-
for (var o = 1; o < arguments.length; o++) {
|
|
3866
|
-
var l = arguments[o];
|
|
3867
|
-
if (l)
|
|
3868
|
-
for (var a in l)
|
|
3869
|
-
l.hasOwnProperty(a) && (jt(l[a]) ? arguments[0][a] = l[a].slice() : arguments[0][a] = l[a]);
|
|
3870
|
-
}
|
|
3871
|
-
return arguments[0];
|
|
3872
|
-
}
|
|
3873
|
-
var hn = function() {
|
|
3874
|
-
function o(l) {
|
|
3875
|
-
c(this, o);
|
|
3876
|
-
for (var a in pe)
|
|
3877
|
-
if (pe.hasOwnProperty(a)) {
|
|
3878
|
-
var y = pe[a], g = y._driver;
|
|
3879
|
-
this[a] = g, we[g] || this.defineDriver(y);
|
|
3880
|
-
}
|
|
3881
|
-
this._defaultConfig = Qe({}, fn), this._config = Qe({}, this._defaultConfig, l), this._driverSet = null, this._initDriver = null, this._ready = !1, this._dbInfo = null, this._wrapLibraryMethodsWithReady(), this.setDriver(this._config.driver).catch(function() {
|
|
3882
|
-
});
|
|
3883
|
-
}
|
|
3884
|
-
return o.prototype.config = function(a) {
|
|
3885
|
-
if ((typeof a > "u" ? "undefined" : s(a)) === "object") {
|
|
3886
|
-
if (this._ready)
|
|
3887
|
-
return new Error("Can't call config() after localforage has been used.");
|
|
3888
|
-
for (var y in a) {
|
|
3889
|
-
if (y === "storeName" && (a[y] = a[y].replace(/\W/g, "_")), y === "version" && typeof a[y] != "number")
|
|
3890
|
-
return new Error("Database version must be a number.");
|
|
3891
|
-
this._config[y] = a[y];
|
|
3892
|
-
}
|
|
3893
|
-
return "driver" in a && a.driver ? this.setDriver(this._config.driver) : !0;
|
|
3894
|
-
} else return typeof a == "string" ? this._config[a] : this._config;
|
|
3895
|
-
}, o.prototype.defineDriver = function(a, y, g) {
|
|
3896
|
-
var p = new b(function(S, O) {
|
|
3897
|
-
try {
|
|
3898
|
-
var R = a._driver, I = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
|
|
3899
|
-
if (!a._driver) {
|
|
3900
|
-
O(I);
|
|
3901
|
-
return;
|
|
3902
|
-
}
|
|
3903
|
-
for (var k = Je.concat("_initStorage"), N = 0, B = k.length; N < B; N++) {
|
|
3904
|
-
var M = k[N], q = !cn(Le, M);
|
|
3905
|
-
if ((q || a[M]) && typeof a[M] != "function") {
|
|
3906
|
-
O(I);
|
|
3907
|
-
return;
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
var K = function() {
|
|
3911
|
-
for (var _e = function(yn) {
|
|
3912
|
-
return function() {
|
|
3913
|
-
var mn = new Error("Method " + yn + " is not implemented by the current driver"), Ut = b.reject(mn);
|
|
3914
|
-
return T(Ut, arguments[arguments.length - 1]), Ut;
|
|
3915
|
-
};
|
|
3916
|
-
}, Xe = 0, pn = Le.length; Xe < pn; Xe++) {
|
|
3917
|
-
var Ze = Le[Xe];
|
|
3918
|
-
a[Ze] || (a[Ze] = _e(Ze));
|
|
3919
|
-
}
|
|
3920
|
-
};
|
|
3921
|
-
K();
|
|
3922
|
-
var H = function(_e) {
|
|
3923
|
-
we[R] && console.info("Redefining LocalForage driver: " + R), we[R] = a, Bt[R] = _e, S();
|
|
3924
|
-
};
|
|
3925
|
-
"_support" in a ? a._support && typeof a._support == "function" ? a._support().then(H, O) : H(!!a._support) : H(!0);
|
|
3926
|
-
} catch (te) {
|
|
3927
|
-
O(te);
|
|
3928
|
-
}
|
|
3929
|
-
});
|
|
3930
|
-
return P(p, y, g), p;
|
|
3931
|
-
}, o.prototype.driver = function() {
|
|
3932
|
-
return this._driver || null;
|
|
3933
|
-
}, o.prototype.getDriver = function(a, y, g) {
|
|
3934
|
-
var p = we[a] ? b.resolve(we[a]) : b.reject(new Error("Driver not found."));
|
|
3935
|
-
return P(p, y, g), p;
|
|
3936
|
-
}, o.prototype.getSerializer = function(a) {
|
|
3937
|
-
var y = b.resolve(Ve);
|
|
3938
|
-
return P(y, a), y;
|
|
3939
|
-
}, o.prototype.ready = function(a) {
|
|
3940
|
-
var y = this, g = y._driverSet.then(function() {
|
|
3941
|
-
return y._ready === null && (y._ready = y._initDriver()), y._ready;
|
|
3942
|
-
});
|
|
3943
|
-
return P(g, a, a), g;
|
|
3944
|
-
}, o.prototype.setDriver = function(a, y, g) {
|
|
3945
|
-
var p = this;
|
|
3946
|
-
jt(a) || (a = [a]);
|
|
3947
|
-
var S = this._getSupportedDrivers(a);
|
|
3948
|
-
function O() {
|
|
3949
|
-
p._config.driver = p.driver();
|
|
3950
|
-
}
|
|
3951
|
-
function R(N) {
|
|
3952
|
-
return p._extend(N), O(), p._ready = p._initStorage(p._config), p._ready;
|
|
3953
|
-
}
|
|
3954
|
-
function I(N) {
|
|
3955
|
-
return function() {
|
|
3956
|
-
var B = 0;
|
|
3957
|
-
function M() {
|
|
3958
|
-
for (; B < N.length; ) {
|
|
3959
|
-
var q = N[B];
|
|
3960
|
-
return B++, p._dbInfo = null, p._ready = null, p.getDriver(q).then(R).catch(M);
|
|
3961
|
-
}
|
|
3962
|
-
O();
|
|
3963
|
-
var K = new Error("No available storage method found.");
|
|
3964
|
-
return p._driverSet = b.reject(K), p._driverSet;
|
|
3965
|
-
}
|
|
3966
|
-
return M();
|
|
3967
|
-
};
|
|
3968
|
-
}
|
|
3969
|
-
var k = this._driverSet !== null ? this._driverSet.catch(function() {
|
|
3970
|
-
return b.resolve();
|
|
3971
|
-
}) : b.resolve();
|
|
3972
|
-
return this._driverSet = k.then(function() {
|
|
3973
|
-
var N = S[0];
|
|
3974
|
-
return p._dbInfo = null, p._ready = null, p.getDriver(N).then(function(B) {
|
|
3975
|
-
p._driver = B._driver, O(), p._wrapLibraryMethodsWithReady(), p._initDriver = I(S);
|
|
3976
|
-
});
|
|
3977
|
-
}).catch(function() {
|
|
3978
|
-
O();
|
|
3979
|
-
var N = new Error("No available storage method found.");
|
|
3980
|
-
return p._driverSet = b.reject(N), p._driverSet;
|
|
3981
|
-
}), P(this._driverSet, y, g), this._driverSet;
|
|
3982
|
-
}, o.prototype.supports = function(a) {
|
|
3983
|
-
return !!Bt[a];
|
|
3984
|
-
}, o.prototype._extend = function(a) {
|
|
3985
|
-
Qe(this, a);
|
|
3986
|
-
}, o.prototype._getSupportedDrivers = function(a) {
|
|
3987
|
-
for (var y = [], g = 0, p = a.length; g < p; g++) {
|
|
3988
|
-
var S = a[g];
|
|
3989
|
-
this.supports(S) && y.push(S);
|
|
3990
|
-
}
|
|
3991
|
-
return y;
|
|
3992
|
-
}, o.prototype._wrapLibraryMethodsWithReady = function() {
|
|
3993
|
-
for (var a = 0, y = Je.length; a < y; a++)
|
|
3994
|
-
ln(this, Je[a]);
|
|
3995
|
-
}, o.prototype.createInstance = function(a) {
|
|
3996
|
-
return new o(a);
|
|
3997
|
-
}, o;
|
|
3998
|
-
}(), dn = new hn();
|
|
3999
|
-
n.exports = dn;
|
|
4000
|
-
}, { 3: 3 }] }, {}, [4])(4);
|
|
4001
|
-
});
|
|
4002
|
-
}(nt)), nt.exports;
|
|
4003
|
-
}
|
|
4004
|
-
var bi = vi();
|
|
4005
|
-
const lr = /* @__PURE__ */ gi(bi);
|
|
4006
|
-
class wi extends We {
|
|
4007
|
-
constructor(e) {
|
|
4008
|
-
super(e, "storage", !1), e.set("localforage", lr);
|
|
4009
|
-
}
|
|
4010
|
-
get StorageManager() {
|
|
4011
|
-
return Ie;
|
|
4012
|
-
}
|
|
4013
|
-
createDatabse(e, t, n) {
|
|
4014
|
-
return new Ie("InPageEdit", e, t, n);
|
|
4015
|
-
}
|
|
4016
|
-
}
|
|
4017
|
-
class Ie {
|
|
4018
|
-
/**
|
|
4019
|
-
*
|
|
4020
|
-
* @param dbName
|
|
4021
|
-
* @param storeName
|
|
4022
|
-
* @param ttl
|
|
4023
|
-
*/
|
|
4024
|
-
constructor(e, t, n = Ie.DEFAULT_TTL, i) {
|
|
4025
|
-
this.dbName = e, this.storeName = t, this.ttl = n, this.version = i, this.db = Ie.createDatabase(e, t), this.keys = this.db.keys.bind(this.db);
|
|
4026
|
-
}
|
|
4027
|
-
static {
|
|
4028
|
-
this.DEFAULT_TTL = 1 / 0;
|
|
4029
|
-
}
|
|
4030
|
-
static {
|
|
4031
|
-
this._cached_db_instances = /* @__PURE__ */ new Map();
|
|
4032
|
-
}
|
|
4033
|
-
static createDatabase(e, t) {
|
|
4034
|
-
const n = `${e}:${t}`;
|
|
4035
|
-
if (this._cached_db_instances.has(n))
|
|
4036
|
-
return this._cached_db_instances.get(n);
|
|
4037
|
-
const i = lr.createInstance({
|
|
4038
|
-
name: e,
|
|
4039
|
-
storeName: t
|
|
4040
|
-
});
|
|
4041
|
-
return this._cached_db_instances.set(n, i), i;
|
|
4042
|
-
}
|
|
4043
|
-
async get(e, t = this.ttl, n) {
|
|
4044
|
-
const i = await this.loadFromDB(e), s = this.checkIfExpired(i, t);
|
|
4045
|
-
if (!i || s) {
|
|
4046
|
-
if (typeof n == "function") {
|
|
4047
|
-
const c = await n();
|
|
4048
|
-
return this.set(e, c).then(() => c);
|
|
4049
|
-
}
|
|
4050
|
-
return null;
|
|
4051
|
-
}
|
|
4052
|
-
return i.value;
|
|
4053
|
-
}
|
|
4054
|
-
async set(e, t) {
|
|
4055
|
-
return t === null || typeof t > "u" ? this.delete(e) : this.db.setItem(e, {
|
|
4056
|
-
time: Date.now(),
|
|
4057
|
-
value: t,
|
|
4058
|
-
version: this.version
|
|
4059
|
-
});
|
|
4060
|
-
}
|
|
4061
|
-
async has(e, t = this.ttl) {
|
|
4062
|
-
const n = await this.loadFromDB(e), i = this.checkIfExpired(n, t);
|
|
4063
|
-
return n !== null && !i;
|
|
4064
|
-
}
|
|
4065
|
-
async delete(e) {
|
|
4066
|
-
return this.db.removeItem(e);
|
|
4067
|
-
}
|
|
4068
|
-
async iterate(e) {
|
|
4069
|
-
return await this.db.iterate((t, n) => {
|
|
4070
|
-
e(t.value, n);
|
|
4071
|
-
});
|
|
4072
|
-
}
|
|
4073
|
-
async loadFromDB(e) {
|
|
4074
|
-
const t = await this.db.getItem(e);
|
|
4075
|
-
if (!t)
|
|
4076
|
-
return null;
|
|
4077
|
-
if (typeof t.time != "number" || typeof t.value > "u") {
|
|
4078
|
-
try {
|
|
4079
|
-
this.delete(e);
|
|
4080
|
-
} catch {
|
|
4081
|
-
}
|
|
4082
|
-
return null;
|
|
4083
|
-
}
|
|
4084
|
-
if (typeof this.version == "number" && t.version !== this.version) {
|
|
4085
|
-
try {
|
|
4086
|
-
this.delete(e);
|
|
4087
|
-
} catch {
|
|
4088
|
-
}
|
|
4089
|
-
return null;
|
|
4090
|
-
}
|
|
4091
|
-
return t;
|
|
4092
|
-
}
|
|
4093
|
-
checkIfExpired(e, t = this.ttl) {
|
|
4094
|
-
return e ? Date.now() - e.time > t : !1;
|
|
4095
|
-
}
|
|
4096
|
-
/**
|
|
4097
|
-
* [DANGER] Use with caution!
|
|
4098
|
-
* Delete all data from the database.
|
|
4099
|
-
*/
|
|
4100
|
-
async clear() {
|
|
4101
|
-
return await this.db.clear(), this;
|
|
4102
|
-
}
|
|
4103
|
-
}
|
|
4104
|
-
var _i = Object.create, gt = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, hr = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), dr = (r) => {
|
|
4105
|
-
throw TypeError(r);
|
|
4106
|
-
}, xi = (r, e, t) => e in r ? gt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Ei = (r, e) => gt(r, "name", { value: e, configurable: !0 }), Oi = (r) => [, , , _i(r?.[hr("metadata")] ?? null)], Ri = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], pr = (r) => r !== void 0 && typeof r != "function" ? dr("Function expected") : r, Ii = (r, e, t, n, i) => ({ kind: Ri[r], name: e, metadata: n, addInitializer: (s) => t._ ? dr("Already initialized") : i.push(pr(s || null)) }), Ai = (r, e) => xi(e, hr("metadata"), r[3]), ki = (r, e, t, n) => {
|
|
4107
|
-
for (var i = 0, s = r[e >> 1], c = s && s.length; i < c; i++) s[i].call(t);
|
|
4108
|
-
return n;
|
|
4109
|
-
}, Pi = (r, e, t, n, i, s) => {
|
|
4110
|
-
var c, u, v, _ = e & 7, E = !1, b = 0, T = r[b] || (r[b] = []), P = _ && (i = i.prototype, _ < 5 && (_ > 3 || !E) && Si(i, t));
|
|
4111
|
-
Ei(i, t);
|
|
4112
|
-
for (var L = n.length - 1; L >= 0; L--)
|
|
4113
|
-
v = Ii(_, t, u = {}, r[3], T), c = (0, n[L])(i, v), u._ = 1, pr(c) && (i = c);
|
|
4114
|
-
return Ai(r, i), P && gt(i, t, P), E ? _ ^ 4 ? s : P : i;
|
|
4115
|
-
}, yr, vt, mr;
|
|
4116
|
-
yr = [Re(["api", "storage"])];
|
|
4117
|
-
class Me extends (mr = We) {
|
|
4118
|
-
constructor(e) {
|
|
4119
|
-
super(e, "sitemeta", !1), this.ctx = e, this._data = void 0, this.siteIdentity = void 0, this.CACHE_TTL = 1e3 * 60 * 60 * 24, this.VERSION = 2, this.db = void 0, this.queryData = {
|
|
4120
|
-
meta: "siteinfo|userinfo",
|
|
4121
|
-
siprop: "general|specialpagealiases|namespacealiases|namespaces|magicwords",
|
|
4122
|
-
uiprop: "groups|rights|blockinfo|options"
|
|
4123
|
-
}, this.db = e.storage.createDatabse("sitemeta", this.CACHE_TTL, this.VERSION);
|
|
4124
|
-
}
|
|
4125
|
-
get api() {
|
|
4126
|
-
return this.ctx.api;
|
|
4127
|
-
}
|
|
4128
|
-
get mwConfig() {
|
|
4129
|
-
return mw.config.values;
|
|
4130
|
-
}
|
|
4131
|
-
async start() {
|
|
4132
|
-
const e = await this.fetchFromCache();
|
|
4133
|
-
if (e) {
|
|
4134
|
-
this.ctx.logger("SiteMetadataService").info("Using cached metadata"), this._data = e;
|
|
4135
|
-
return;
|
|
4136
|
-
}
|
|
4137
|
-
const t = await this.fetchFromApi();
|
|
4138
|
-
this.saveToCache(t), this._data = t;
|
|
4139
|
-
}
|
|
4140
|
-
async computeSiteIdentity() {
|
|
4141
|
-
if (this.siteIdentity) return this.siteIdentity;
|
|
4142
|
-
let e;
|
|
4143
|
-
if (!window.mw?.config)
|
|
4144
|
-
e = new URL(location.href).origin;
|
|
4145
|
-
else {
|
|
4146
|
-
const { wgServer: t, wgArticlePath: n } = window.mw.config.get();
|
|
4147
|
-
e = `${t}${n}`;
|
|
4148
|
-
}
|
|
4149
|
-
return this.siteIdentity = e, this.siteIdentity;
|
|
4150
|
-
}
|
|
4151
|
-
async fetchFromApi() {
|
|
4152
|
-
return this.api.get({
|
|
4153
|
-
action: "query",
|
|
4154
|
-
...this.queryData
|
|
4155
|
-
}).then(({ data: e }) => {
|
|
4156
|
-
if (typeof e?.query?.general > "u")
|
|
4157
|
-
throw new Error("Invalid siteinfo");
|
|
4158
|
-
return e.query;
|
|
4159
|
-
}).catch((e) => (this.ctx.logger.error("[InPageEdit]", "fetchMetadata error", e), Promise.reject(e)));
|
|
4160
|
-
}
|
|
4161
|
-
async fetchFromCache() {
|
|
4162
|
-
const e = await this.computeSiteIdentity();
|
|
4163
|
-
return this.db.get(e);
|
|
4164
|
-
}
|
|
4165
|
-
async saveToCache(e) {
|
|
4166
|
-
const t = await this.computeSiteIdentity();
|
|
4167
|
-
return this.db.set(t, e);
|
|
4168
|
-
}
|
|
4169
|
-
// shortcuts
|
|
4170
|
-
get _raw() {
|
|
4171
|
-
return this._data;
|
|
4172
|
-
}
|
|
4173
|
-
get siteInfo() {
|
|
4174
|
-
return this._data.general;
|
|
4175
|
-
}
|
|
4176
|
-
get specialPageAliases() {
|
|
4177
|
-
return this._data.specialpagealiases;
|
|
4178
|
-
}
|
|
4179
|
-
get namespaceAliases() {
|
|
4180
|
-
return this._data.namespacealiases;
|
|
4181
|
-
}
|
|
4182
|
-
get namespaces() {
|
|
4183
|
-
return this._data.namespaces;
|
|
4184
|
-
}
|
|
4185
|
-
get namespaceMap() {
|
|
4186
|
-
const e = Object.values(this.namespaces).map((t) => ({
|
|
4187
|
-
id: t.id,
|
|
4188
|
-
canonical: t.canonical,
|
|
4189
|
-
aliases: this.namespaceAliases.filter((n) => n.id === t.id).map((n) => n.alias)
|
|
4190
|
-
})).sort((t, n) => t.id - n.id);
|
|
4191
|
-
return Reflect.defineProperty(this, "namespaceMap", {
|
|
4192
|
-
value: e,
|
|
4193
|
-
writable: !1,
|
|
4194
|
-
configurable: !1,
|
|
4195
|
-
enumerable: !0
|
|
4196
|
-
}), e;
|
|
4197
|
-
}
|
|
4198
|
-
get magicWords() {
|
|
4199
|
-
return this._data.magicwords;
|
|
4200
|
-
}
|
|
4201
|
-
get userInfo() {
|
|
4202
|
-
return this._data.userinfo;
|
|
4203
|
-
}
|
|
4204
|
-
get userOptions() {
|
|
4205
|
-
return this.userInfo.options;
|
|
4206
|
-
}
|
|
4207
|
-
get isUserBlocked() {
|
|
4208
|
-
return this.userInfo.blockedbyid && this.userInfo.blockexpiry && new Date(this.userInfo.blockexpiry).getTime() > Date.now();
|
|
4209
|
-
}
|
|
4210
|
-
get userGroups() {
|
|
4211
|
-
return this.userInfo.groups;
|
|
4212
|
-
}
|
|
4213
|
-
get userRights() {
|
|
4214
|
-
return this.userInfo.rights;
|
|
4215
|
-
}
|
|
4216
|
-
// utils
|
|
4217
|
-
hasRight(e) {
|
|
4218
|
-
return this.userRights.includes(e);
|
|
4219
|
-
}
|
|
4220
|
-
hasAnyRight(...e) {
|
|
4221
|
-
return e.some((t) => this.hasRight(t));
|
|
4222
|
-
}
|
|
4223
|
-
hasEveryRights(...e) {
|
|
4224
|
-
return e.every((t) => this.hasRight(t));
|
|
4225
|
-
}
|
|
4226
|
-
inGroup(e) {
|
|
4227
|
-
return this.userGroups.includes(e);
|
|
4228
|
-
}
|
|
4229
|
-
inAnyGroup(...e) {
|
|
4230
|
-
return this.userGroups.some((t) => e.includes(t));
|
|
4231
|
-
}
|
|
4232
|
-
getBlockInfo() {
|
|
4233
|
-
return this.isUserBlocked ? {
|
|
4234
|
-
blockid: this.userInfo.blockid,
|
|
4235
|
-
blockedby: this.userInfo.blockedbyid,
|
|
4236
|
-
blockedbyid: this.userInfo.blockedbyid,
|
|
4237
|
-
blockreason: this.userInfo.blockreason,
|
|
4238
|
-
blockedtimestamp: this.userInfo.blockedtimestamp,
|
|
4239
|
-
blockexpiry: this.userInfo.blockexpiry
|
|
4240
|
-
} : null;
|
|
4241
|
-
}
|
|
4242
|
-
}
|
|
4243
|
-
vt = Oi(mr);
|
|
4244
|
-
Me = Pi(vt, 0, "SiteMetadataService", yr, Me);
|
|
4245
|
-
ki(vt, 1, Me);
|
|
4246
|
-
class Ee {
|
|
4247
|
-
static {
|
|
4248
|
-
this.DEFAULT_PAGE_INFO = {
|
|
4249
|
-
pageid: 0,
|
|
4250
|
-
ns: 0,
|
|
4251
|
-
title: "",
|
|
4252
|
-
contentmodel: "wikitext",
|
|
4253
|
-
pagelanguage: "",
|
|
4254
|
-
pagelanguagehtmlcode: "",
|
|
4255
|
-
pagelanguagedir: "ltr",
|
|
4256
|
-
touched: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4257
|
-
lastrevid: 0,
|
|
4258
|
-
length: 0,
|
|
4259
|
-
protection: [],
|
|
4260
|
-
restrictiontypes: [],
|
|
4261
|
-
fullurl: "",
|
|
4262
|
-
canonicalurl: "",
|
|
4263
|
-
editurl: "",
|
|
4264
|
-
varianttitles: {},
|
|
4265
|
-
actions: {
|
|
4266
|
-
edit: !0,
|
|
4267
|
-
move: !1,
|
|
4268
|
-
delete: !1
|
|
4269
|
-
},
|
|
4270
|
-
revisions: [],
|
|
4271
|
-
templates: [],
|
|
4272
|
-
images: []
|
|
4273
|
-
};
|
|
4274
|
-
}
|
|
4275
|
-
constructor(e, t) {
|
|
4276
|
-
this.pageInfo = {
|
|
4277
|
-
...Ee.DEFAULT_PAGE_INFO,
|
|
4278
|
-
...e
|
|
4279
|
-
}, this.api = t || new fr();
|
|
4280
|
-
}
|
|
4281
|
-
// Utils
|
|
4282
|
-
async getPageInfo(e) {
|
|
4283
|
-
const {
|
|
4284
|
-
data: {
|
|
4285
|
-
query: {
|
|
4286
|
-
pages: [t]
|
|
4287
|
-
}
|
|
4288
|
-
}
|
|
4289
|
-
} = await this.api.get({
|
|
4290
|
-
action: "query",
|
|
4291
|
-
prop: "info|templates|transcludedin|images|pageimages|revisions",
|
|
4292
|
-
inprop: "protection|url|varianttitles",
|
|
4293
|
-
intestactions: "edit|move|delete",
|
|
4294
|
-
tllimit: "max",
|
|
4295
|
-
tilimit: "max",
|
|
4296
|
-
imlimit: "max",
|
|
4297
|
-
piprop: "thumbnail|name|original",
|
|
4298
|
-
pithumbsize: "200",
|
|
4299
|
-
pilimit: "max",
|
|
4300
|
-
rvprop: "ids|timestamp|flags|comment|user|content",
|
|
4301
|
-
...e
|
|
4302
|
-
});
|
|
4303
|
-
return t.revisions?.forEach((n) => {
|
|
4304
|
-
if (typeof n.slots == "object") {
|
|
4305
|
-
const i = n.slots.main;
|
|
4306
|
-
i && (n.content = i.content, n.contentmodel = i.contentmodel, n.contentformat = i.contentformat);
|
|
4307
|
-
}
|
|
4308
|
-
}), t;
|
|
4309
|
-
}
|
|
4310
|
-
// Page actions
|
|
4311
|
-
async parse(e) {
|
|
4312
|
-
return this.api.post({
|
|
4313
|
-
action: "parse",
|
|
4314
|
-
page: this.pageInfo.title,
|
|
4315
|
-
prop: "text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",
|
|
4316
|
-
...e
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
async preview(e, t) {
|
|
4320
|
-
return this.parse({
|
|
4321
|
-
action: "parse",
|
|
4322
|
-
page: void 0,
|
|
4323
|
-
title: this.title,
|
|
4324
|
-
text: e,
|
|
4325
|
-
pst: 1,
|
|
4326
|
-
preview: 1,
|
|
4327
|
-
disableeditsection: 1,
|
|
4328
|
-
disablelimitreport: 1,
|
|
4329
|
-
...t
|
|
4330
|
-
});
|
|
4331
|
-
}
|
|
4332
|
-
async edit(e, t) {
|
|
4333
|
-
const { text: n, prependtext: i, appendtext: s, summary: c = "", watchlist: u = "preferences" } = e;
|
|
4334
|
-
return this.api.postWithEditToken({
|
|
4335
|
-
action: "edit",
|
|
4336
|
-
title: this.title,
|
|
4337
|
-
starttimestamp: this.pageInfo.touched,
|
|
4338
|
-
basetimestamp: this.revisions[0]?.timestamp,
|
|
4339
|
-
text: n,
|
|
4340
|
-
prependtext: i,
|
|
4341
|
-
appendtext: s,
|
|
4342
|
-
summary: c,
|
|
4343
|
-
watchlist: u,
|
|
4344
|
-
...t
|
|
4345
|
-
});
|
|
4346
|
-
}
|
|
4347
|
-
async createOnly(e, t) {
|
|
4348
|
-
return this.edit(e, { createonly: 1, ...t });
|
|
4349
|
-
}
|
|
4350
|
-
async delete(e, t) {
|
|
4351
|
-
return this.api.postWithEditToken({
|
|
4352
|
-
action: "delete",
|
|
4353
|
-
pageid: this.pageInfo.pageid,
|
|
4354
|
-
reason: e,
|
|
4355
|
-
...t
|
|
4356
|
-
});
|
|
4357
|
-
}
|
|
4358
|
-
async moveTo(e, t, n) {
|
|
4359
|
-
return this.api.postWithEditToken({
|
|
4360
|
-
action: "move",
|
|
4361
|
-
from: this.pageInfo.title,
|
|
4362
|
-
to: e,
|
|
4363
|
-
reason: t,
|
|
4364
|
-
movetalk: 1,
|
|
4365
|
-
movesubpages: 1,
|
|
4366
|
-
...n
|
|
4367
|
-
});
|
|
4368
|
-
}
|
|
4369
|
-
// === utilities ===
|
|
4370
|
-
userCan(e) {
|
|
4371
|
-
return this.pageInfo?.actions?.[e];
|
|
4372
|
-
}
|
|
4373
|
-
userCanEdit() {
|
|
4374
|
-
return this.userCan("edit");
|
|
4375
|
-
}
|
|
4376
|
-
async refetch() {
|
|
4377
|
-
const e = await this.getPageInfo({
|
|
4378
|
-
pageids: this.pageInfo.pageid,
|
|
4379
|
-
titles: this.pageInfo.title
|
|
4380
|
-
}), t = (this.pageInfo.revisions || []).concat(e.revisions || []).sort((n, i) => n.revid - i.revid).reduce(
|
|
4381
|
-
(n, i) => (n.find((s) => s.revid === i.revid) || n.push(i), n),
|
|
4382
|
-
[]
|
|
4383
|
-
);
|
|
4384
|
-
return this.pageInfo = e, this.pageInfo.revisions = t, this;
|
|
4385
|
-
}
|
|
4386
|
-
// === sugar getters ===
|
|
4387
|
-
get pageid() {
|
|
4388
|
-
return this.pageInfo.pageid;
|
|
4389
|
-
}
|
|
4390
|
-
get title() {
|
|
4391
|
-
return this.pageInfo.title;
|
|
4392
|
-
}
|
|
4393
|
-
get ns() {
|
|
4394
|
-
return this.pageInfo.ns;
|
|
4395
|
-
}
|
|
4396
|
-
get contentmodel() {
|
|
4397
|
-
return this.pageInfo.contentmodel;
|
|
4398
|
-
}
|
|
4399
|
-
get fullurl() {
|
|
4400
|
-
return this.pageInfo.fullurl;
|
|
4401
|
-
}
|
|
4402
|
-
get canonicalurl() {
|
|
4403
|
-
return this.pageInfo.canonicalurl;
|
|
4404
|
-
}
|
|
4405
|
-
get editurl() {
|
|
4406
|
-
return this.pageInfo.editurl;
|
|
4407
|
-
}
|
|
4408
|
-
get revisions() {
|
|
4409
|
-
return this.pageInfo.revisions || [];
|
|
4410
|
-
}
|
|
4411
|
-
get templates() {
|
|
4412
|
-
return this.pageInfo.templates || [];
|
|
4413
|
-
}
|
|
4414
|
-
get images() {
|
|
4415
|
-
return this.pageInfo.images || [];
|
|
4416
|
-
}
|
|
4417
|
-
}
|
|
4418
|
-
class Di extends We {
|
|
4419
|
-
constructor(e) {
|
|
4420
|
-
super(e, "wikiPage", !0), this.ctx = e;
|
|
4421
|
-
}
|
|
4422
|
-
static {
|
|
4423
|
-
this.inject = ["api"];
|
|
4424
|
-
}
|
|
4425
|
-
get WikiPage() {
|
|
4426
|
-
return Ee;
|
|
4427
|
-
}
|
|
4428
|
-
async createInstance(e) {
|
|
4429
|
-
const {
|
|
4430
|
-
data: {
|
|
4431
|
-
query: {
|
|
4432
|
-
pages: [t]
|
|
4433
|
-
}
|
|
4434
|
-
}
|
|
4435
|
-
} = await this.ctx.api.get({
|
|
4436
|
-
action: "query",
|
|
4437
|
-
prop: "info|templates|transcludedin|images|pageimages|revisions",
|
|
4438
|
-
inprop: "protection|url|varianttitles",
|
|
4439
|
-
intestactions: "edit|move|delete",
|
|
4440
|
-
tllimit: "max",
|
|
4441
|
-
tilimit: "max",
|
|
4442
|
-
imlimit: "max",
|
|
4443
|
-
piprop: "thumbnail|name|original",
|
|
4444
|
-
pithumbsize: "200",
|
|
4445
|
-
pilimit: "max",
|
|
4446
|
-
rvprop: "ids|timestamp|user|userid|content",
|
|
4447
|
-
...e
|
|
4448
|
-
});
|
|
4449
|
-
return new Ee(t, this.ctx.api);
|
|
4450
|
-
}
|
|
4451
|
-
async newFromTitle(e, t = !1, n) {
|
|
4452
|
-
return this.createInstance({ titles: e, converttitles: t, rvsection: n });
|
|
4453
|
-
}
|
|
4454
|
-
async newFromPageId(e, t) {
|
|
4455
|
-
return this.createInstance({ pageids: e, rvsection: t });
|
|
4456
|
-
}
|
|
4457
|
-
async newFromRevision(e, t) {
|
|
4458
|
-
return this.createInstance({ revids: e, rvsection: t });
|
|
4459
|
-
}
|
|
4460
|
-
newBlankPage(e = {}) {
|
|
4461
|
-
return new Ee(e, this.ctx.api);
|
|
4462
|
-
}
|
|
4463
|
-
}
|
|
4464
|
-
/**
|
|
4465
|
-
* ✏️ InPageEdit NEXT
|
|
4466
|
-
*
|
|
4467
|
-
* 🚀 Modular, Extensible Supercharged Plugin for MediaWiki
|
|
4468
|
-
*
|
|
4469
|
-
* @author dragon-fish <dragon-fish@qq.com>
|
|
4470
|
-
* @license MIT
|
|
4471
|
-
* @see https://github.com/inpageedit/inpageedit-next
|
|
4472
|
-
* @see https://www.ipe.wiki/
|
|
4473
|
-
*/
|
|
4474
|
-
class Ae extends Q {
|
|
4475
|
-
constructor(e) {
|
|
4476
|
-
super(), this.version = "0.4.1", this.Endpoints = ve, this.schema = Kn, this.config = {
|
|
4477
|
-
...Ae.DEFAULT_CONFIG,
|
|
4478
|
-
...e
|
|
4479
|
-
}, this.logger = Qn({
|
|
4480
|
-
name: "IPE",
|
|
4481
|
-
color: "#33aaff",
|
|
4482
|
-
level: this.config.logLevel
|
|
4483
|
-
}), this.#e(), this.#r(), this.#n();
|
|
4484
|
-
}
|
|
4485
|
-
static {
|
|
4486
|
-
this.DEFAULT_CONFIG = {
|
|
4487
|
-
baseURL: "",
|
|
4488
|
-
legacyPreferences: {},
|
|
4489
|
-
logLevel: cr.info
|
|
4490
|
-
};
|
|
4491
|
-
}
|
|
4492
|
-
async #e() {
|
|
4493
|
-
this.plugin(pi, { baseURL: this.config.baseURL }), this.plugin(yi), this.plugin(mi), this.plugin(wi), this.plugin(Me), this.plugin(Di), this.#t([
|
|
4494
|
-
"api",
|
|
4495
|
-
"resourceLoader",
|
|
4496
|
-
"modal",
|
|
4497
|
-
"storage",
|
|
4498
|
-
// 'sitemeta', // 故意未标记此服务,因为数据是异步加载的
|
|
4499
|
-
"wikiPage"
|
|
4500
|
-
]);
|
|
4501
|
-
}
|
|
4502
|
-
#t(e) {
|
|
4503
|
-
if (typeof e == "string" && (e = [e]), !Array.isArray(e) || e.length === 0) return this;
|
|
4504
|
-
for (const t of e) {
|
|
4505
|
-
const n = this[Ae.internal][t];
|
|
4506
|
-
n?.type === "service" && (n.builtin = !0);
|
|
4507
|
-
}
|
|
4508
|
-
return this;
|
|
4509
|
-
}
|
|
4510
|
-
// TODO: 这里不应该硬编码,暂时先这样
|
|
4511
|
-
async #r() {
|
|
4512
|
-
[
|
|
4513
|
-
import("./index-D-zQLFuZ.js").then(({ PluginPreferences: t }) => t),
|
|
4514
|
-
import("./index-Ch5DJDZZ.js").then(({ PluginQuickEdit: t }) => t),
|
|
4515
|
-
import("./index-Cq9xxVsu.js").then(({ PluginQuickMove: t }) => t),
|
|
4516
|
-
import("./index-HyxA2rYz.js").then(
|
|
4517
|
-
({ PluginQuickPreview: t }) => t
|
|
4518
|
-
),
|
|
4519
|
-
import("./index-BByzm2Fz.js").then(({ PluginQuickDiff: t }) => t),
|
|
4520
|
-
import("./index-X1X416tZ.js").then(
|
|
4521
|
-
({ PluginQuickRedirect: t }) => t
|
|
4522
|
-
),
|
|
4523
|
-
import("./index-BsYzf3Yw.js").then(({ PluginToolbox: t }) => t)
|
|
4524
|
-
].forEach(async (t) => {
|
|
4525
|
-
this.plugin(await t);
|
|
4526
|
-
});
|
|
4527
|
-
}
|
|
4528
|
-
// TODO: 应该抽象到 PluginTheme 中去,暂时先硬编码
|
|
4529
|
-
async #n() {
|
|
4530
|
-
this.inject(["resourceLoader"], (e) => {
|
|
4531
|
-
e.resourceLoader.loadStyle(import.meta.resolve("./style.css")), e.resourceLoader.loadStyle(`${ve.PLUGIN_CDN_BASE}/skins/ipe-default.css`);
|
|
4532
|
-
});
|
|
4533
|
-
}
|
|
4534
|
-
async useScope(e) {
|
|
4535
|
-
const { promise: t, resolve: n } = Qt();
|
|
4536
|
-
return this.inject(e, (i) => {
|
|
4537
|
-
n(i);
|
|
4538
|
-
}), t;
|
|
4539
|
-
}
|
|
4540
|
-
}
|
|
4541
|
-
function Ti(r) {
|
|
4542
|
-
return r.charAt(0).toLowerCase() + r.slice(1);
|
|
4543
|
-
}
|
|
4544
|
-
function Li(r) {
|
|
4545
|
-
return Ti(r).replace(/-/g, "_").replace(/.[A-Z]+/g, (e) => e[0] + "_" + e.slice(1).toLowerCase());
|
|
4546
|
-
}
|
|
4547
|
-
class Bi {
|
|
4548
|
-
constructor(e, t = void 0, n) {
|
|
4549
|
-
this.ctx = e, this.disposeHandlers = [], this.name = n || this.constructor.name, this.config = t || {};
|
|
4550
|
-
const { promise: i, resolve: s, reject: c } = Promise.withResolvers();
|
|
4551
|
-
queueMicrotask(() => {
|
|
4552
|
-
try {
|
|
4553
|
-
const u = this.start();
|
|
4554
|
-
u && typeof u.then == "function" ? u.then(() => s()).catch((v) => {
|
|
4555
|
-
this.logger.error("Plugin start failed", v), c(v);
|
|
4556
|
-
}) : s();
|
|
4557
|
-
} catch (u) {
|
|
4558
|
-
this.logger.error("Plugin start threw synchronously", u), c(u);
|
|
4559
|
-
}
|
|
4560
|
-
i.then(() => {
|
|
4561
|
-
this.logger.info("Plugin started");
|
|
4562
|
-
}), i.catch((u) => {
|
|
4563
|
-
this.logger.error("Plugin start failed", u), this.ctx.scope.dispose();
|
|
4564
|
-
});
|
|
4565
|
-
}), this.ctx.once("dispose", () => {
|
|
4566
|
-
this.disposeHandlers.forEach((u) => u(this.ctx)), this.stop(), this.logger.info("Plugin disposed");
|
|
4567
|
-
});
|
|
4568
|
-
}
|
|
4569
|
-
#e;
|
|
4570
|
-
start() {
|
|
4571
|
-
}
|
|
4572
|
-
stop() {
|
|
4573
|
-
}
|
|
4574
|
-
addDisposeHandler(e) {
|
|
4575
|
-
this.disposeHandlers.push(e);
|
|
4576
|
-
}
|
|
4577
|
-
removeDisposeHandler(e) {
|
|
4578
|
-
this.disposeHandlers = this.disposeHandlers.filter((t) => t !== e);
|
|
4579
|
-
}
|
|
4580
|
-
set name(e) {
|
|
4581
|
-
this.#e = Li(e).toUpperCase();
|
|
4582
|
-
}
|
|
4583
|
-
get name() {
|
|
4584
|
-
return this.#e;
|
|
4585
|
-
}
|
|
4586
|
-
get logger() {
|
|
4587
|
-
return this.ctx.logger(this.name);
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
window.RLQ ||= [];
|
|
4591
|
-
window.__IPE_MODULES__ ||= [];
|
|
4592
|
-
Ci("InPageEdit#autoload", () => {
|
|
4593
|
-
window.RLQ.push(Ni);
|
|
4594
|
-
});
|
|
4595
|
-
async function Ni() {
|
|
4596
|
-
typeof window?.ipe?.stop == "function" && (console.warn("[InPageEdit] Plugin already loaded, disposing..."), await window.ipe.stop());
|
|
4597
|
-
const r = window.InPageEdit || {}, e = new Ae({
|
|
4598
|
-
baseURL: window.mw?.util.wikiScript("api"),
|
|
4599
|
-
legacyPreferences: r?.myPreferences || {}
|
|
4600
|
-
});
|
|
4601
|
-
if (window.InPageEdit = Ae, window.ipe = e, window.mw.hook("InPageEdit.ready").fire(e), await e.start(), Array.isArray(window.__IPE_MODULES__)) {
|
|
4602
|
-
const t = [];
|
|
4603
|
-
for (; window.__IPE_MODULES__.length; )
|
|
4604
|
-
try {
|
|
4605
|
-
const n = window.__IPE_MODULES__.shift();
|
|
4606
|
-
typeof n == "function" && n?.(e), t.push(n);
|
|
4607
|
-
} catch (n) {
|
|
4608
|
-
console.error("[InPageEdit] Failed to initialize module:", n);
|
|
4609
|
-
}
|
|
4610
|
-
window.__IPE_MODULES__ = {
|
|
4611
|
-
push: (n) => {
|
|
4612
|
-
typeof n == "function" && n(e), t.push(n);
|
|
4613
|
-
}
|
|
4614
|
-
}, e.on("dispose", () => {
|
|
4615
|
-
window.__IPE_MODULES__ = t;
|
|
4616
|
-
});
|
|
4617
|
-
}
|
|
4618
|
-
e.logger("AUTOLOAD").info(
|
|
4619
|
-
`${ve.HOME_URL}
|
|
4620
|
-
____ ____ ______ ___ __
|
|
4621
|
-
/ _/___ / __ \\____ _____ ____ / ____/___/ (_) /_
|
|
4622
|
-
/ // __ \\/ /_/ / __ \`/ __ \`/ _ \\/ __/ / __ / / __/
|
|
4623
|
-
_/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_
|
|
4624
|
-
/___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/
|
|
4625
|
-
/____/ v` + e.version
|
|
4626
|
-
);
|
|
4627
|
-
}
|
|
4628
|
-
function Ci(r, e) {
|
|
4629
|
-
const t = Symbol.for(r);
|
|
4630
|
-
return window[t] ? !1 : (window[t] = !0, e(), !0);
|
|
4631
|
-
}
|
|
1
|
+
import { B as s, I as g, a as r, m as c, $ as o, S as t, b as L, c as i } from "./index-CBphMyYJ.js";
|
|
4632
2
|
export {
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
3
|
+
s as BasePlugin,
|
|
4
|
+
g as InPageEdit,
|
|
5
|
+
r as Inject,
|
|
6
|
+
c as Logger,
|
|
7
|
+
o as LoggerLevel,
|
|
8
|
+
t as Schema,
|
|
9
|
+
L as Service,
|
|
10
|
+
i as createLogger
|
|
4641
11
|
};
|
|
4642
12
|
//# sourceMappingURL=index.js.map
|