@inpageedit/core 0.14.5 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ActionButton-CRjo_l3y.js → ActionButton-B6OUgtHx.js} +2 -2
- package/dist/{ActionButton-CRjo_l3y.js.map → ActionButton-B6OUgtHx.js.map} +1 -1
- package/dist/CheckBox-Dx3r3LQz.js +13 -0
- package/dist/CheckBox-Dx3r3LQz.js.map +1 -0
- package/dist/IconQuickDiff-BkbxyY-d.js +29 -0
- package/dist/IconQuickDiff-BkbxyY-d.js.map +1 -0
- package/dist/IconQuickEdit-BiRYADU_.js +68 -0
- package/dist/IconQuickEdit-BiRYADU_.js.map +1 -0
- package/dist/IconUpload-Bz4BW_nc.js +27 -0
- package/dist/IconUpload-Bz4BW_nc.js.map +1 -0
- package/dist/InPageEdit.js +20 -0
- package/dist/InPageEdit.js.map +1 -0
- package/dist/InputBox-D2ZRTMFP.js +42 -0
- package/dist/InputBox-D2ZRTMFP.js.map +1 -0
- package/dist/PluginImagesUsed-BVyvFA1_.js +90 -0
- package/dist/PluginImagesUsed-BVyvFA1_.js.map +1 -0
- package/dist/{PluginPrefSync-CbFuuC19.js → PluginPrefSync-CUKkx4Qk.js} +11 -11
- package/dist/{PluginPrefSync-CbFuuC19.js.map → PluginPrefSync-CUKkx4Qk.js.map} +1 -1
- package/dist/{PluginStoreApp-MbC3G9tu.js → PluginStoreApp-CoOAw1fr.js} +4 -4
- package/dist/{PluginStoreApp-MbC3G9tu.js.map → PluginStoreApp-CoOAw1fr.js.map} +1 -1
- package/dist/PluginTemplatesUsed-CdjT1wR4.js +76 -0
- package/dist/PluginTemplatesUsed-CdjT1wR4.js.map +1 -0
- package/dist/{index-CM_6yF2v.js → Promise.withResolvers-C4chhLB1.js} +17 -11
- package/dist/Promise.withResolvers-C4chhLB1.js.map +1 -0
- package/dist/{RadioBox-0UuxlcWZ.js → RadioBox-B0z9YHQg.js} +2 -2
- package/dist/{RadioBox-0UuxlcWZ.js.map → RadioBox-B0z9YHQg.js.map} +1 -1
- package/dist/components/index.js +75 -46
- package/dist/components/index.js.map +1 -1
- package/dist/{BasePlugin-DD7l-5Xw.js → core.js} +28 -10
- package/dist/core.js.map +1 -0
- package/dist/{index-De25v1_Q.js → index-1tsXE6ax.js} +11 -10
- package/dist/index-1tsXE6ax.js.map +1 -0
- package/dist/{index-WfXtYVMt.js → index-B32tFyLB.js} +132 -100
- package/dist/index-B32tFyLB.js.map +1 -0
- package/dist/index-BPTMltVf.js +170 -0
- package/dist/index-BPTMltVf.js.map +1 -0
- package/dist/{index-DKCZDN-Q.js → index-BYlcHc-O.js} +23 -25
- package/dist/index-BYlcHc-O.js.map +1 -0
- package/dist/{index-CnR6CqkM.js → index-C4qm_X_A.js} +11 -11
- package/dist/{index-CnR6CqkM.js.map → index-C4qm_X_A.js.map} +1 -1
- package/dist/index-CAtPo7xJ.js +793 -0
- package/dist/index-CAtPo7xJ.js.map +1 -0
- package/dist/{index-DensW9qt.js → index-CVCy0wPP.js} +9 -8
- package/dist/index-CVCy0wPP.js.map +1 -0
- package/dist/index-CYfkwXRf.js +1631 -0
- package/dist/index-CYfkwXRf.js.map +1 -0
- package/dist/index-DZa9mxN4.js +168 -0
- package/dist/index-DZa9mxN4.js.map +1 -0
- package/dist/{index-BpQ6VGMz.js → index-Dm2vgYkZ.js} +89 -67
- package/dist/index-Dm2vgYkZ.js.map +1 -0
- package/dist/{index-BanevHQ2.js → index-NWWeW3tX.js} +87 -84
- package/dist/index-NWWeW3tX.js.map +1 -0
- package/dist/index-QnWieXQc.js +4932 -0
- package/dist/index-QnWieXQc.js.map +1 -0
- package/dist/{index-B3jld2sl.js → index-bQ0CVu3l.js} +13 -17
- package/dist/{index-B3jld2sl.js.map → index-bQ0CVu3l.js.map} +1 -1
- package/dist/index-ygc4AMy4.js +44 -0
- package/dist/index-ygc4AMy4.js.map +1 -0
- package/dist/{index-DD5CVCfD.js → index-z_qDGCMT.js} +2 -2
- package/dist/{index-DD5CVCfD.js.map → index-z_qDGCMT.js.map} +1 -1
- package/dist/index.d.ts +411 -163
- package/dist/index.js +24 -26
- package/dist/index.js.map +1 -1
- package/dist/{makeCallable-LDU0xZMJ.js → makeCallable-Cg4zUG4c.js} +2 -2
- package/dist/{makeCallable-LDU0xZMJ.js.map → makeCallable-Cg4zUG4c.js.map} +1 -1
- package/dist/models/index.js +7 -7
- package/dist/models/index.js.map +1 -1
- package/dist/plugins/index.js +18 -14
- package/dist/plugins/index.js.map +1 -1
- package/dist/services/index.js +11 -9
- package/dist/style.css +1 -1
- package/dist/{vueHooks-l04s8cIl.js → vueHooks-Bs93iP61.js} +1519 -1492
- package/dist/vueHooks-Bs93iP61.js.map +1 -0
- package/lib/index.umd.js +19 -13
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +38 -27
- package/dist/BasePlugin-DD7l-5Xw.js.map +0 -1
- package/dist/IconQuickEdit-CMCQncyj.js +0 -27
- package/dist/IconQuickEdit-CMCQncyj.js.map +0 -1
- package/dist/InputBox-nQKtiWtZ.js +0 -30
- package/dist/InputBox-nQKtiWtZ.js.map +0 -1
- package/dist/Preferences-C10tZMl1.js +0 -2701
- package/dist/Preferences-C10tZMl1.js.map +0 -1
- package/dist/WatchlistAction-BbNAyryN.js +0 -5
- package/dist/WatchlistAction-BbNAyryN.js.map +0 -1
- package/dist/index-7R2LfhNn.js +0 -220
- package/dist/index-7R2LfhNn.js.map +0 -1
- package/dist/index-BXNyXvre.js +0 -116
- package/dist/index-BXNyXvre.js.map +0 -1
- package/dist/index-BanevHQ2.js.map +0 -1
- package/dist/index-BjDTD66_.js +0 -491
- package/dist/index-BjDTD66_.js.map +0 -1
- package/dist/index-BpQ6VGMz.js.map +0 -1
- package/dist/index-CG38LlAh.js +0 -46
- package/dist/index-CG38LlAh.js.map +0 -1
- package/dist/index-CM_6yF2v.js.map +0 -1
- package/dist/index-DKCZDN-Q.js.map +0 -1
- package/dist/index-De25v1_Q.js.map +0 -1
- package/dist/index-DensW9qt.js.map +0 -1
- package/dist/index-DxaqNWv4.js +0 -3090
- package/dist/index-DxaqNWv4.js.map +0 -1
- package/dist/index-WfXtYVMt.js.map +0 -1
- package/dist/vueHooks-l04s8cIl.js.map +0 -1
|
@@ -0,0 +1,4932 @@
|
|
|
1
|
+
import { W as wi, d as bi, e as vi, r as _i, u as xi, c as ki, a as Si, f as $i } from "./index-CYfkwXRf.js";
|
|
2
|
+
import { j as M, P as Ei, p as wt } from "./Promise.withResolvers-C4chhLB1.js";
|
|
3
|
+
var Ci = Object.defineProperty, S = (i, e) => Ci(i, "name", { value: e, configurable: !0 });
|
|
4
|
+
function Ai() {
|
|
5
|
+
}
|
|
6
|
+
S(Ai, "noop");
|
|
7
|
+
function I(i) {
|
|
8
|
+
return i == null;
|
|
9
|
+
}
|
|
10
|
+
S(I, "isNullable");
|
|
11
|
+
function Oi(i) {
|
|
12
|
+
return !I(i);
|
|
13
|
+
}
|
|
14
|
+
S(Oi, "isNonNullable");
|
|
15
|
+
function le(i) {
|
|
16
|
+
return i && typeof i == "object" && !Array.isArray(i);
|
|
17
|
+
}
|
|
18
|
+
S(le, "isPlainObject");
|
|
19
|
+
function bt(i, e) {
|
|
20
|
+
return Object.fromEntries(Object.entries(i).filter(([t, r]) => e(t, r)));
|
|
21
|
+
}
|
|
22
|
+
S(bt, "filterKeys");
|
|
23
|
+
function q(i, e) {
|
|
24
|
+
return Object.fromEntries(Object.entries(i).map(([t, r]) => [t, e(r, t)]));
|
|
25
|
+
}
|
|
26
|
+
S(q, "mapValues");
|
|
27
|
+
function vt(i, e, t) {
|
|
28
|
+
if (!e) return { ...i };
|
|
29
|
+
const r = {};
|
|
30
|
+
for (const n of e)
|
|
31
|
+
(t || i[n] !== void 0) && (r[n] = i[n]);
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
S(vt, "pick");
|
|
35
|
+
function Pi(i, e) {
|
|
36
|
+
if (!e) return { ...i };
|
|
37
|
+
const t = { ...i };
|
|
38
|
+
for (const r of e)
|
|
39
|
+
Reflect.deleteProperty(t, r);
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
42
|
+
S(Pi, "omit");
|
|
43
|
+
function j(i, e, t) {
|
|
44
|
+
return Object.defineProperty(i, e, { writable: !0, value: t, enumerable: !1 });
|
|
45
|
+
}
|
|
46
|
+
S(j, "defineProperty");
|
|
47
|
+
function Ii(i, e) {
|
|
48
|
+
return e.every((t) => i.includes(t));
|
|
49
|
+
}
|
|
50
|
+
S(Ii, "contain");
|
|
51
|
+
function Li(i, e) {
|
|
52
|
+
return i.filter((t) => e.includes(t));
|
|
53
|
+
}
|
|
54
|
+
S(Li, "intersection");
|
|
55
|
+
function Ri(i, e) {
|
|
56
|
+
return i.filter((t) => !e.includes(t));
|
|
57
|
+
}
|
|
58
|
+
S(Ri, "difference");
|
|
59
|
+
function ji(i, e) {
|
|
60
|
+
return Array.from(/* @__PURE__ */ new Set([...i, ...e]));
|
|
61
|
+
}
|
|
62
|
+
S(ji, "union");
|
|
63
|
+
function Di(i) {
|
|
64
|
+
return [...new Set(i)];
|
|
65
|
+
}
|
|
66
|
+
S(Di, "deduplicate");
|
|
67
|
+
function W(i, e) {
|
|
68
|
+
const t = i?.indexOf(e);
|
|
69
|
+
return t >= 0 ? (i.splice(t, 1), !0) : !1;
|
|
70
|
+
}
|
|
71
|
+
S(W, "remove");
|
|
72
|
+
function Ti(i) {
|
|
73
|
+
return Array.isArray(i) ? i : I(i) ? [] : [i];
|
|
74
|
+
}
|
|
75
|
+
S(Ti, "makeArray");
|
|
76
|
+
function G(i, e) {
|
|
77
|
+
return arguments.length === 1 ? (t) => G(i, t) : i in globalThis && e instanceof globalThis[i] || Object.prototype.toString.call(e).slice(8, -1) === i;
|
|
78
|
+
}
|
|
79
|
+
S(G, "is");
|
|
80
|
+
function ne(i) {
|
|
81
|
+
return G("ArrayBuffer", i) || G("SharedArrayBuffer", i);
|
|
82
|
+
}
|
|
83
|
+
S(ne, "isArrayBufferLike");
|
|
84
|
+
function _t(i) {
|
|
85
|
+
return ne(i) || ArrayBuffer.isView(i);
|
|
86
|
+
}
|
|
87
|
+
S(_t, "isArrayBufferSource");
|
|
88
|
+
var B;
|
|
89
|
+
((i) => {
|
|
90
|
+
i.is = ne, i.isSource = _t;
|
|
91
|
+
function e(o) {
|
|
92
|
+
return ArrayBuffer.isView(o) ? o.buffer.slice(o.byteOffset, o.byteOffset + o.byteLength) : o;
|
|
93
|
+
}
|
|
94
|
+
i.fromSource = e, S(e, "fromSource");
|
|
95
|
+
function t(o) {
|
|
96
|
+
if (typeof Buffer < "u")
|
|
97
|
+
return Buffer.from(o).toString("base64");
|
|
98
|
+
let a = "";
|
|
99
|
+
const f = new Uint8Array(o);
|
|
100
|
+
for (let u = 0; u < f.byteLength; u++)
|
|
101
|
+
a += String.fromCharCode(f[u]);
|
|
102
|
+
return btoa(a);
|
|
103
|
+
}
|
|
104
|
+
i.toBase64 = t, S(t, "toBase64");
|
|
105
|
+
function r(o) {
|
|
106
|
+
return typeof Buffer < "u" ? e(Buffer.from(o, "base64")) : Uint8Array.from(atob(o), (a) => a.charCodeAt(0));
|
|
107
|
+
}
|
|
108
|
+
i.fromBase64 = r, S(r, "fromBase64");
|
|
109
|
+
function n(o) {
|
|
110
|
+
return typeof Buffer < "u" ? Buffer.from(o).toString("hex") : Array.from(new Uint8Array(o), (a) => a.toString(16).padStart(2, "0")).join("");
|
|
111
|
+
}
|
|
112
|
+
i.toHex = n, S(n, "toHex");
|
|
113
|
+
function s(o) {
|
|
114
|
+
if (typeof Buffer < "u") return e(Buffer.from(o, "hex"));
|
|
115
|
+
const a = o.length % 2 === 0 ? o : o.slice(0, o.length - 1), f = [];
|
|
116
|
+
for (let u = 0; u < a.length; u += 2)
|
|
117
|
+
f.push(parseInt(`${a[u]}${a[u + 1]}`, 16));
|
|
118
|
+
return Uint8Array.from(f).buffer;
|
|
119
|
+
}
|
|
120
|
+
i.fromHex = s, S(s, "fromHex");
|
|
121
|
+
})(B || (B = {}));
|
|
122
|
+
B.fromBase64;
|
|
123
|
+
B.toBase64;
|
|
124
|
+
B.fromHex;
|
|
125
|
+
B.toHex;
|
|
126
|
+
function he(i, e = /* @__PURE__ */ new Map()) {
|
|
127
|
+
if (!i || typeof i != "object") return i;
|
|
128
|
+
if (G("Date", i)) return new Date(i.valueOf());
|
|
129
|
+
if (G("RegExp", i)) return new RegExp(i.source, i.flags);
|
|
130
|
+
if (ne(i)) return i.slice(0);
|
|
131
|
+
if (ArrayBuffer.isView(i)) return i.buffer.slice(i.byteOffset, i.byteOffset + i.byteLength);
|
|
132
|
+
const t = e.get(i);
|
|
133
|
+
if (t) return t;
|
|
134
|
+
if (Array.isArray(i)) {
|
|
135
|
+
const n = [];
|
|
136
|
+
return e.set(i, n), i.forEach((s, o) => {
|
|
137
|
+
n[o] = Reflect.apply(he, null, [s, e]);
|
|
138
|
+
}), n;
|
|
139
|
+
}
|
|
140
|
+
const r = Object.create(Object.getPrototypeOf(i));
|
|
141
|
+
e.set(i, r);
|
|
142
|
+
for (const n of Reflect.ownKeys(i)) {
|
|
143
|
+
const s = { ...Reflect.getOwnPropertyDescriptor(i, n) };
|
|
144
|
+
"value" in s && (s.value = Reflect.apply(he, null, [s.value, e])), Reflect.defineProperty(r, n, s);
|
|
145
|
+
}
|
|
146
|
+
return r;
|
|
147
|
+
}
|
|
148
|
+
S(he, "clone");
|
|
149
|
+
function J(i, e, t) {
|
|
150
|
+
if (i === e || !t && I(i) && I(e)) return !0;
|
|
151
|
+
if (typeof i != typeof e || typeof i != "object" || !i || !e) return !1;
|
|
152
|
+
function r(n, s) {
|
|
153
|
+
return n(i) ? n(e) ? s(i, e) : !1 : n(e) ? !1 : void 0;
|
|
154
|
+
}
|
|
155
|
+
return S(r, "check"), r(Array.isArray, (n, s) => n.length === s.length && n.every((o, a) => J(o, s[a]))) ?? r(G("Date"), (n, s) => n.valueOf() === s.valueOf()) ?? r(G("RegExp"), (n, s) => n.source === s.source && n.flags === s.flags) ?? r(ne, (n, s) => {
|
|
156
|
+
if (n.byteLength !== s.byteLength) return !1;
|
|
157
|
+
const o = new Uint8Array(n), a = new Uint8Array(s);
|
|
158
|
+
for (let f = 0; f < o.length; f++)
|
|
159
|
+
if (o[f] !== a[f]) return !1;
|
|
160
|
+
return !0;
|
|
161
|
+
}) ?? Object.keys({ ...i, ...e }).every((n) => J(i[n], e[n], t));
|
|
162
|
+
}
|
|
163
|
+
S(J, "deepEqual");
|
|
164
|
+
function Mi(i) {
|
|
165
|
+
return i.charAt(0).toUpperCase() + i.slice(1);
|
|
166
|
+
}
|
|
167
|
+
S(Mi, "capitalize");
|
|
168
|
+
function Ni(i) {
|
|
169
|
+
return i.charAt(0).toLowerCase() + i.slice(1);
|
|
170
|
+
}
|
|
171
|
+
S(Ni, "uncapitalize");
|
|
172
|
+
function Bi(i) {
|
|
173
|
+
return i.replace(/[_-][a-z]/g, (e) => e.slice(1).toUpperCase());
|
|
174
|
+
}
|
|
175
|
+
S(Bi, "camelCase");
|
|
176
|
+
function Me(i, e, t) {
|
|
177
|
+
const r = [];
|
|
178
|
+
let n = 0;
|
|
179
|
+
for (let s = 0; s < i.length; s++) {
|
|
180
|
+
const o = i.charCodeAt(s);
|
|
181
|
+
if (o >= 65 && o <= 90) {
|
|
182
|
+
if (n === 1) {
|
|
183
|
+
const a = i.charCodeAt(s + 1);
|
|
184
|
+
a >= 97 && a <= 122 && r.push(t), r.push(o + 32);
|
|
185
|
+
} else
|
|
186
|
+
n !== 0 && r.push(t), r.push(o + 32);
|
|
187
|
+
n = 1;
|
|
188
|
+
} else o >= 97 && o <= 122 ? (r.push(o), n = 2) : e.includes(o) ? (n !== 0 && r.push(t), n = 0) : r.push(o);
|
|
189
|
+
}
|
|
190
|
+
return String.fromCharCode(...r);
|
|
191
|
+
}
|
|
192
|
+
S(Me, "tokenize");
|
|
193
|
+
function Ui(i) {
|
|
194
|
+
return Me(i, [45, 95], 45);
|
|
195
|
+
}
|
|
196
|
+
S(Ui, "paramCase");
|
|
197
|
+
function Fi(i) {
|
|
198
|
+
return Me(i, [45, 95], 95);
|
|
199
|
+
}
|
|
200
|
+
S(Fi, "snakeCase");
|
|
201
|
+
function zi(i) {
|
|
202
|
+
return typeof i != "string" ? `[${i.toString()}]` : /^[a-z_$][\w$]*$/i.test(i) ? `.${i}` : `[${JSON.stringify(i)}]`;
|
|
203
|
+
}
|
|
204
|
+
S(zi, "formatProperty");
|
|
205
|
+
function xt(i) {
|
|
206
|
+
return i.replace(/\/$/, "");
|
|
207
|
+
}
|
|
208
|
+
S(xt, "trimSlash");
|
|
209
|
+
function Ki(i) {
|
|
210
|
+
return i.startsWith("/") || (i = "/" + i), xt(i);
|
|
211
|
+
}
|
|
212
|
+
S(Ki, "sanitize");
|
|
213
|
+
var ot;
|
|
214
|
+
((i) => {
|
|
215
|
+
i.millisecond = 1, i.second = 1e3, i.minute = i.second * 60, i.hour = i.minute * 60, i.day = i.hour * 24, i.week = i.day * 7;
|
|
216
|
+
let e = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
217
|
+
function t(g) {
|
|
218
|
+
e = g;
|
|
219
|
+
}
|
|
220
|
+
i.setTimezoneOffset = t, S(t, "setTimezoneOffset");
|
|
221
|
+
function r() {
|
|
222
|
+
return e;
|
|
223
|
+
}
|
|
224
|
+
i.getTimezoneOffset = r, S(r, "getTimezoneOffset");
|
|
225
|
+
function n(g = /* @__PURE__ */ new Date(), w) {
|
|
226
|
+
return typeof g == "number" && (g = new Date(g)), w === void 0 && (w = e), Math.floor((g.valueOf() / i.minute - w) / 1440);
|
|
227
|
+
}
|
|
228
|
+
i.getDateNumber = n, S(n, "getDateNumber");
|
|
229
|
+
function s(g, w) {
|
|
230
|
+
const O = new Date(g * i.day);
|
|
231
|
+
return w === void 0 && (w = e), new Date(+O + w * i.minute);
|
|
232
|
+
}
|
|
233
|
+
i.fromDateNumber = s, S(s, "fromDateNumber");
|
|
234
|
+
const o = /\d+(?:\.\d+)?/.source, a = new RegExp(`^${[
|
|
235
|
+
"w(?:eek(?:s)?)?",
|
|
236
|
+
"d(?:ay(?:s)?)?",
|
|
237
|
+
"h(?:our(?:s)?)?",
|
|
238
|
+
"m(?:in(?:ute)?(?:s)?)?",
|
|
239
|
+
"s(?:ec(?:ond)?(?:s)?)?"
|
|
240
|
+
].map((g) => `(${o}${g})?`).join("")}$`);
|
|
241
|
+
function f(g) {
|
|
242
|
+
const w = a.exec(g);
|
|
243
|
+
return w ? (parseFloat(w[1]) * i.week || 0) + (parseFloat(w[2]) * i.day || 0) + (parseFloat(w[3]) * i.hour || 0) + (parseFloat(w[4]) * i.minute || 0) + (parseFloat(w[5]) * i.second || 0) : 0;
|
|
244
|
+
}
|
|
245
|
+
i.parseTime = f, S(f, "parseTime");
|
|
246
|
+
function u(g) {
|
|
247
|
+
const w = f(g);
|
|
248
|
+
return w ? g = Date.now() + w : /^\d{1,2}(:\d{1,2}){1,2}$/.test(g) ? g = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${g}` : /^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(g) && (g = `${(/* @__PURE__ */ new Date()).getFullYear()}-${g}`), g ? new Date(g) : /* @__PURE__ */ new Date();
|
|
249
|
+
}
|
|
250
|
+
i.parseDate = u, S(u, "parseDate");
|
|
251
|
+
function p(g) {
|
|
252
|
+
const w = Math.abs(g);
|
|
253
|
+
return w >= i.day - i.hour / 2 ? Math.round(g / i.day) + "d" : w >= i.hour - i.minute / 2 ? Math.round(g / i.hour) + "h" : w >= i.minute - i.second / 2 ? Math.round(g / i.minute) + "m" : w >= i.second ? Math.round(g / i.second) + "s" : g + "ms";
|
|
254
|
+
}
|
|
255
|
+
i.format = p, S(p, "format");
|
|
256
|
+
function y(g, w = 2) {
|
|
257
|
+
return g.toString().padStart(w, "0");
|
|
258
|
+
}
|
|
259
|
+
i.toDigits = y, S(y, "toDigits");
|
|
260
|
+
function _(g, w = /* @__PURE__ */ new Date()) {
|
|
261
|
+
return g.replace("yyyy", w.getFullYear().toString()).replace("yy", w.getFullYear().toString().slice(2)).replace("MM", y(w.getMonth() + 1)).replace("dd", y(w.getDate())).replace("hh", y(w.getHours())).replace("mm", y(w.getMinutes())).replace("ss", y(w.getSeconds())).replace("SSS", y(w.getMilliseconds(), 3));
|
|
262
|
+
}
|
|
263
|
+
i.template = _, S(_, "template");
|
|
264
|
+
})(ot || (ot = {}));
|
|
265
|
+
var qi = Object.defineProperty, k = (i, e) => qi(i, "name", { value: e, configurable: !0 }), b = {
|
|
266
|
+
// internal symbols
|
|
267
|
+
shadow: /* @__PURE__ */ Symbol.for("cordis.shadow"),
|
|
268
|
+
receiver: /* @__PURE__ */ Symbol.for("cordis.receiver"),
|
|
269
|
+
original: /* @__PURE__ */ Symbol.for("cordis.original"),
|
|
270
|
+
// context symbols
|
|
271
|
+
store: /* @__PURE__ */ Symbol.for("cordis.store"),
|
|
272
|
+
events: /* @__PURE__ */ Symbol.for("cordis.events"),
|
|
273
|
+
static: /* @__PURE__ */ Symbol.for("cordis.static"),
|
|
274
|
+
filter: /* @__PURE__ */ Symbol.for("cordis.filter"),
|
|
275
|
+
expose: /* @__PURE__ */ Symbol.for("cordis.expose"),
|
|
276
|
+
isolate: /* @__PURE__ */ Symbol.for("cordis.isolate"),
|
|
277
|
+
internal: /* @__PURE__ */ Symbol.for("cordis.internal"),
|
|
278
|
+
intercept: /* @__PURE__ */ Symbol.for("cordis.intercept"),
|
|
279
|
+
// service symbols
|
|
280
|
+
setup: /* @__PURE__ */ Symbol.for("cordis.setup"),
|
|
281
|
+
invoke: /* @__PURE__ */ Symbol.for("cordis.invoke"),
|
|
282
|
+
extend: /* @__PURE__ */ Symbol.for("cordis.extend"),
|
|
283
|
+
tracker: /* @__PURE__ */ Symbol.for("cordis.tracker"),
|
|
284
|
+
provide: /* @__PURE__ */ Symbol.for("cordis.provide"),
|
|
285
|
+
immediate: /* @__PURE__ */ Symbol.for("cordis.immediate")
|
|
286
|
+
}, Hi = function* () {
|
|
287
|
+
}.constructor, at = async function* () {
|
|
288
|
+
}.constructor;
|
|
289
|
+
function Ne(i) {
|
|
290
|
+
return !(!i.prototype || i instanceof Hi || at !== Function && i instanceof at);
|
|
291
|
+
}
|
|
292
|
+
k(Ne, "isConstructor");
|
|
293
|
+
function se(i, e) {
|
|
294
|
+
const t = i.Config || i.schema;
|
|
295
|
+
return t && i.schema !== !1 && (e = t(e)), e ?? {};
|
|
296
|
+
}
|
|
297
|
+
k(se, "resolveConfig");
|
|
298
|
+
function kt(i) {
|
|
299
|
+
return [Map, Set, Date, Promise].some((e) => i instanceof e);
|
|
300
|
+
}
|
|
301
|
+
k(kt, "isUnproxyable");
|
|
302
|
+
function Be(i, e) {
|
|
303
|
+
if (i === Object.prototype) return e;
|
|
304
|
+
const t = Object.create(Be(Object.getPrototypeOf(i), e));
|
|
305
|
+
for (const r of Reflect.ownKeys(i))
|
|
306
|
+
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(i, r));
|
|
307
|
+
return t;
|
|
308
|
+
}
|
|
309
|
+
k(Be, "joinPrototype");
|
|
310
|
+
function Ue(i) {
|
|
311
|
+
return i && (typeof i == "object" || typeof i == "function");
|
|
312
|
+
}
|
|
313
|
+
k(Ue, "isObject");
|
|
314
|
+
function U(i, e, t) {
|
|
315
|
+
if (!Ue(e)) return e;
|
|
316
|
+
if (Object.hasOwn(e, b.shadow))
|
|
317
|
+
return Object.getPrototypeOf(e);
|
|
318
|
+
const r = e[b.tracker];
|
|
319
|
+
return r ? ve(i, e, r, t) : e;
|
|
320
|
+
}
|
|
321
|
+
k(U, "getTraceable");
|
|
322
|
+
function ie(i, e) {
|
|
323
|
+
return e ? new Proxy(i, {
|
|
324
|
+
get: /* @__PURE__ */ k((t, r, n) => r in e && r !== "constructor" ? Reflect.get(e, r, n) : Reflect.get(t, r, n), "get"),
|
|
325
|
+
set: /* @__PURE__ */ k((t, r, n, s) => r in e && r !== "constructor" ? Reflect.set(e, r, n, s) : Reflect.set(t, r, n, s), "set")
|
|
326
|
+
}) : i;
|
|
327
|
+
}
|
|
328
|
+
k(ie, "withProps");
|
|
329
|
+
function ue(i, e, t) {
|
|
330
|
+
return ie(i, Object.defineProperty(/* @__PURE__ */ Object.create(null), e, {
|
|
331
|
+
value: t,
|
|
332
|
+
writable: !1
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
k(ue, "withProp");
|
|
336
|
+
function Ee(i, e, t, r) {
|
|
337
|
+
if (!t) return r;
|
|
338
|
+
const n = Reflect.getOwnPropertyDescriptor(e, t)?.value;
|
|
339
|
+
return n ? ue(r, t, i.extend({ [b.shadow]: n })) : r;
|
|
340
|
+
}
|
|
341
|
+
k(Ee, "createShadow");
|
|
342
|
+
function St(i, e, t, r) {
|
|
343
|
+
return new Proxy(e, {
|
|
344
|
+
apply: /* @__PURE__ */ k((n, s, o) => (s === t && (s = r), o = o.map((a) => typeof a != "function" || a[b.original] ? a : new Proxy(a, {
|
|
345
|
+
get: /* @__PURE__ */ k((f, u, p) => {
|
|
346
|
+
if (u === b.original) return f;
|
|
347
|
+
const y = Reflect.get(f, u, p);
|
|
348
|
+
return u === "toString" && y === Function.prototype.toString ? function(..._) {
|
|
349
|
+
return Reflect.apply(y, this === p ? f : this, _);
|
|
350
|
+
} : y;
|
|
351
|
+
}, "get"),
|
|
352
|
+
apply: /* @__PURE__ */ k((f, u, p) => Reflect.apply(f, U(i, u), p.map((y) => U(i, y))), "apply"),
|
|
353
|
+
construct: /* @__PURE__ */ k((f, u, p) => Reflect.construct(f, u.map((y) => U(i, y)), p), "construct")
|
|
354
|
+
})), U(i, Reflect.apply(n, s, o))), "apply")
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
k(St, "createShadowMethod");
|
|
358
|
+
function ve(i, e, t, r) {
|
|
359
|
+
i[b.shadow] && (i = Object.getPrototypeOf(i));
|
|
360
|
+
const n = new Proxy(e, {
|
|
361
|
+
get: /* @__PURE__ */ k((s, o, a) => {
|
|
362
|
+
if (o === b.original) return s;
|
|
363
|
+
if (o === t.property) return i;
|
|
364
|
+
if (typeof o == "symbol")
|
|
365
|
+
return Reflect.get(s, o, a);
|
|
366
|
+
if (t.associate && i[b.internal][`${t.associate}.${o}`])
|
|
367
|
+
return Reflect.get(i, `${t.associate}.${o}`, ue(i, b.receiver, a));
|
|
368
|
+
const f = Ee(i, s, t.property, a), u = Reflect.get(s, o, f), p = u?.[b.tracker];
|
|
369
|
+
return p ? ve(i, u, p) : !r && typeof u == "function" ? St(i, u, a, f) : u;
|
|
370
|
+
}, "get"),
|
|
371
|
+
set: /* @__PURE__ */ k((s, o, a, f) => {
|
|
372
|
+
if (o === b.original || o === t.property) return !1;
|
|
373
|
+
if (typeof o == "symbol")
|
|
374
|
+
return Reflect.set(s, o, a, f);
|
|
375
|
+
if (t.associate && i[b.internal][`${t.associate}.${o}`])
|
|
376
|
+
return Reflect.set(i, `${t.associate}.${o}`, a, ue(i, b.receiver, f));
|
|
377
|
+
const u = Ee(i, s, t.property, f);
|
|
378
|
+
return Reflect.set(s, o, a, u);
|
|
379
|
+
}, "set"),
|
|
380
|
+
apply: /* @__PURE__ */ k((s, o, a) => Fe(n, s, o, a), "apply")
|
|
381
|
+
});
|
|
382
|
+
return n;
|
|
383
|
+
}
|
|
384
|
+
k(ve, "createTraceable");
|
|
385
|
+
function Fe(i, e, t, r) {
|
|
386
|
+
return e[b.invoke] ? e[b.invoke].apply(i, r) : Reflect.apply(e, t, r);
|
|
387
|
+
}
|
|
388
|
+
k(Fe, "applyTraceable");
|
|
389
|
+
function Ce(i, e, t) {
|
|
390
|
+
const r = /* @__PURE__ */ k(function(...n) {
|
|
391
|
+
const s = ve(r.ctx, r, t);
|
|
392
|
+
return Fe(s, r, this, n);
|
|
393
|
+
}, "self");
|
|
394
|
+
return j(r, "name", i), Object.setPrototypeOf(r, e);
|
|
395
|
+
}
|
|
396
|
+
k(Ce, "createCallable");
|
|
397
|
+
var Wi = class Q {
|
|
398
|
+
constructor(e) {
|
|
399
|
+
this.ctx = e, j(this, b.tracker, {
|
|
400
|
+
associate: "reflect",
|
|
401
|
+
property: "ctx"
|
|
402
|
+
}), 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"]);
|
|
403
|
+
}
|
|
404
|
+
static {
|
|
405
|
+
k(this, "ReflectService");
|
|
406
|
+
}
|
|
407
|
+
static resolveInject(e, t) {
|
|
408
|
+
let r = e[b.internal][t];
|
|
409
|
+
for (; r?.type === "alias"; )
|
|
410
|
+
t = r.name, r = e[b.internal][t];
|
|
411
|
+
return [t, r];
|
|
412
|
+
}
|
|
413
|
+
static checkInject(e, t, r) {
|
|
414
|
+
if (e = e[b.shadow] ?? e, ["prototype", "then", "registry", "lifecycle"].includes(t) || t[0] === "$" || t[0] === "_" || !e.runtime.plugin || e.bail(e, "internal/inject", t)) return;
|
|
415
|
+
const n = r.stack.split(`
|
|
416
|
+
`);
|
|
417
|
+
n.splice(1, 1), r.stack = n.join(`
|
|
418
|
+
`), e.emit(e, "internal/warning", r);
|
|
419
|
+
}
|
|
420
|
+
static handler = {
|
|
421
|
+
get: /* @__PURE__ */ k((e, t, r) => {
|
|
422
|
+
if (typeof t != "string") return Reflect.get(e, t, r);
|
|
423
|
+
if (Reflect.has(e, t))
|
|
424
|
+
return U(r, Reflect.get(e, t, r), !0);
|
|
425
|
+
const [n, s] = Q.resolveInject(e, t), o = new Error(`property ${n} is not registered, declare it as \`inject\` to suppress this warning`);
|
|
426
|
+
return s ? s.type === "accessor" ? s.get.call(r, r[b.receiver]) : (s.builtin || Q.checkInject(r, n, o), r.reflect.get(n)) : (Q.checkInject(r, n, o), Reflect.get(e, n, r));
|
|
427
|
+
}, "get"),
|
|
428
|
+
set: /* @__PURE__ */ k((e, t, r, n) => {
|
|
429
|
+
if (typeof t != "string") return Reflect.set(e, t, r, n);
|
|
430
|
+
const [s, o] = Q.resolveInject(e, t);
|
|
431
|
+
return o ? o.type === "accessor" ? o.set ? o.set.call(n, r, n[b.receiver]) : !1 : (n.reflect.set(s, r), !0) : Reflect.set(e, s, r, n);
|
|
432
|
+
}, "set"),
|
|
433
|
+
has: /* @__PURE__ */ k((e, t) => {
|
|
434
|
+
if (typeof t != "string") return Reflect.has(e, t);
|
|
435
|
+
if (Reflect.has(e, t)) return !0;
|
|
436
|
+
const [, r] = Q.resolveInject(e, t);
|
|
437
|
+
return !!r;
|
|
438
|
+
}, "has")
|
|
439
|
+
};
|
|
440
|
+
get(e) {
|
|
441
|
+
if (this.ctx[b.internal][e]?.type !== "service") return;
|
|
442
|
+
const r = this.ctx[b.isolate][e], n = this.ctx[b.store][r]?.value;
|
|
443
|
+
return U(this.ctx, n);
|
|
444
|
+
}
|
|
445
|
+
set(e, t) {
|
|
446
|
+
this.provide(e);
|
|
447
|
+
const r = this.ctx[b.isolate][e], n = this.ctx[b.store][r]?.value;
|
|
448
|
+
t ??= void 0;
|
|
449
|
+
let s = /* @__PURE__ */ k(() => {
|
|
450
|
+
}, "dispose");
|
|
451
|
+
if (n === t) return s;
|
|
452
|
+
if (!I(t) && !I(n))
|
|
453
|
+
throw new Error(`service ${e} has been registered`);
|
|
454
|
+
const o = this.ctx;
|
|
455
|
+
I(t) || (s = o.effect(() => () => {
|
|
456
|
+
o.set(e, void 0);
|
|
457
|
+
})), kt(t) && o.emit(o, "internal/warning", new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));
|
|
458
|
+
const a = Object.create(o);
|
|
459
|
+
return a[b.filter] = (f) => o[b.isolate][e] === f[b.isolate][e], o.emit(a, "internal/before-service", e, t), o[b.store][r] = { value: t, source: o }, o.emit(a, "internal/service", e, n), s;
|
|
460
|
+
}
|
|
461
|
+
provide(e, t, r) {
|
|
462
|
+
const n = this.ctx.root[b.internal];
|
|
463
|
+
if (e in n) return;
|
|
464
|
+
const s = Symbol(e);
|
|
465
|
+
n[e] = { type: "service", builtin: r }, this.ctx.root[b.isolate][e] = s, Ue(t) && (this.ctx[b.store][s] = { value: t, source: null }, j(t, b.tracker, {
|
|
466
|
+
associate: e,
|
|
467
|
+
property: "ctx"
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
_accessor(e, t) {
|
|
471
|
+
const r = this.ctx.root[b.internal];
|
|
472
|
+
return e in r ? () => {
|
|
473
|
+
} : (r[e] = { type: "accessor", ...t }, () => delete this.ctx.root[b.isolate][e]);
|
|
474
|
+
}
|
|
475
|
+
accessor(e, t) {
|
|
476
|
+
this.ctx.scope.effect(() => this._accessor(e, t));
|
|
477
|
+
}
|
|
478
|
+
alias(e, t) {
|
|
479
|
+
const r = this.ctx.root[b.internal];
|
|
480
|
+
if (!(e in r))
|
|
481
|
+
for (const n of t)
|
|
482
|
+
r[n] ||= { type: "alias", name: e };
|
|
483
|
+
}
|
|
484
|
+
_mixin(e, t) {
|
|
485
|
+
const r = Array.isArray(t) ? t.map((o) => [o, o]) : Object.entries(t), n = typeof e == "string" ? (o) => o[e] : () => e, s = r.map(([o, a]) => this._accessor(a, {
|
|
486
|
+
get(f) {
|
|
487
|
+
const u = n(this);
|
|
488
|
+
if (I(u)) return u;
|
|
489
|
+
const p = f ? ie(f, u) : u, y = Reflect.get(u, o, p);
|
|
490
|
+
return typeof y != "function" ? y : y.bind(p ?? u);
|
|
491
|
+
},
|
|
492
|
+
set(f, u) {
|
|
493
|
+
const p = n(this), y = u ? ie(u, p) : p;
|
|
494
|
+
return Reflect.set(p, o, f, y);
|
|
495
|
+
}
|
|
496
|
+
}));
|
|
497
|
+
return () => s.forEach((o) => o());
|
|
498
|
+
}
|
|
499
|
+
mixin(e, t) {
|
|
500
|
+
this.ctx.scope.effect(() => this._mixin(e, t));
|
|
501
|
+
}
|
|
502
|
+
trace(e) {
|
|
503
|
+
return U(this.ctx, e);
|
|
504
|
+
}
|
|
505
|
+
bind(e) {
|
|
506
|
+
return new Proxy(e, {
|
|
507
|
+
apply: /* @__PURE__ */ k((t, r, n) => t.apply(this.trace(r), n.map((s) => this.trace(s))), "apply")
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}, Ae = Wi;
|
|
511
|
+
function Oe(i) {
|
|
512
|
+
return i !== null && i !== !1 && i !== void 0;
|
|
513
|
+
}
|
|
514
|
+
k(Oe, "isBailed");
|
|
515
|
+
var Gi = class {
|
|
516
|
+
constructor(i) {
|
|
517
|
+
this.ctx = i, j(this, b.tracker, {
|
|
518
|
+
associate: "lifecycle",
|
|
519
|
+
property: "ctx"
|
|
520
|
+
}), j(this.on("internal/listener", function(t, r, n) {
|
|
521
|
+
const s = n.prepend ? "unshift" : "push";
|
|
522
|
+
if (t === "ready")
|
|
523
|
+
return this.lifecycle.isActive ? (this.scope.ensure(async () => r()), () => !1) : void 0;
|
|
524
|
+
if (t === "dispose")
|
|
525
|
+
return this.scope.disposables[s](r), j(r, "name", "event <dispose>"), () => W(this.scope.disposables, r);
|
|
526
|
+
if (t === "fork")
|
|
527
|
+
return this.scope.runtime.forkables[s](r), this.scope.collect("event <fork>", () => W(this.scope.runtime.forkables, r));
|
|
528
|
+
}), N.static, i.scope);
|
|
529
|
+
for (const t of ["info", "error", "warning"])
|
|
530
|
+
j(this.on(`internal/${t}`, (r, ...n) => {
|
|
531
|
+
this._hooks[`internal/${t}`].length > 1;
|
|
532
|
+
}), N.static, i.scope);
|
|
533
|
+
j(this.on("internal/before-service", function(t) {
|
|
534
|
+
for (const r of this.registry.values()) {
|
|
535
|
+
if (!r.inject[t]?.required) continue;
|
|
536
|
+
const n = r.isReusable ? r.children : [r];
|
|
537
|
+
for (const s of n)
|
|
538
|
+
this[b.filter](s.ctx) && (s.updateStatus(), s.reset());
|
|
539
|
+
}
|
|
540
|
+
}, { global: !0 }), N.static, i.scope), j(this.on("internal/service", function(t) {
|
|
541
|
+
for (const r of this.registry.values()) {
|
|
542
|
+
if (!r.inject[t]?.required) continue;
|
|
543
|
+
const n = r.isReusable ? r.children : [r];
|
|
544
|
+
for (const s of n)
|
|
545
|
+
this[b.filter](s.ctx) && s.start();
|
|
546
|
+
}
|
|
547
|
+
}, { global: !0 }), N.static, i.scope);
|
|
548
|
+
const e = /* @__PURE__ */ k((t, r) => {
|
|
549
|
+
if (!t.runtime.plugin) return !1;
|
|
550
|
+
for (const n in t.runtime.inject)
|
|
551
|
+
if (r === Ae.resolveInject(t.ctx, n)[0]) return !0;
|
|
552
|
+
return e(t.parent.scope, r);
|
|
553
|
+
}, "checkInject");
|
|
554
|
+
j(this.on("internal/inject", function(t) {
|
|
555
|
+
return e(this.scope, t);
|
|
556
|
+
}, { global: !0 }), N.static, i.scope);
|
|
557
|
+
}
|
|
558
|
+
static {
|
|
559
|
+
k(this, "Lifecycle");
|
|
560
|
+
}
|
|
561
|
+
isActive = !1;
|
|
562
|
+
_tasks = /* @__PURE__ */ new Set();
|
|
563
|
+
_hooks = {};
|
|
564
|
+
async flush() {
|
|
565
|
+
for (; this._tasks.size; )
|
|
566
|
+
await Promise.all(Array.from(this._tasks));
|
|
567
|
+
}
|
|
568
|
+
filterHooks(i, e) {
|
|
569
|
+
return e = U(this.ctx, e), i.slice().filter((t) => {
|
|
570
|
+
const r = e?.[N.filter];
|
|
571
|
+
return t.global || !r || r.call(e, t.ctx);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
*dispatch(i, e) {
|
|
575
|
+
const t = typeof e[0] == "object" || typeof e[0] == "function" ? e.shift() : null, r = e.shift();
|
|
576
|
+
r !== "internal/event" && this.emit("internal/event", i, r, e, t);
|
|
577
|
+
for (const n of this.filterHooks(this._hooks[r] || [], t))
|
|
578
|
+
yield n.callback.apply(t, e);
|
|
579
|
+
}
|
|
580
|
+
async parallel(...i) {
|
|
581
|
+
await Promise.all(this.dispatch("emit", i));
|
|
582
|
+
}
|
|
583
|
+
emit(...i) {
|
|
584
|
+
Array.from(this.dispatch("emit", i));
|
|
585
|
+
}
|
|
586
|
+
async serial(...i) {
|
|
587
|
+
for await (const e of this.dispatch("serial", i))
|
|
588
|
+
if (Oe(e)) return e;
|
|
589
|
+
}
|
|
590
|
+
bail(...i) {
|
|
591
|
+
for (const e of this.dispatch("bail", i))
|
|
592
|
+
if (Oe(e)) return e;
|
|
593
|
+
}
|
|
594
|
+
register(i, e, t, r) {
|
|
595
|
+
const n = r.prepend ? "unshift" : "push";
|
|
596
|
+
return e[n]({ ctx: this.ctx, callback: t, ...r }), this.ctx.state.collect(i, () => this.unregister(e, t));
|
|
597
|
+
}
|
|
598
|
+
unregister(i, e) {
|
|
599
|
+
const t = i.findIndex((r) => r.callback === e);
|
|
600
|
+
if (t >= 0)
|
|
601
|
+
return i.splice(t, 1), !0;
|
|
602
|
+
}
|
|
603
|
+
on(i, e, t) {
|
|
604
|
+
typeof t != "object" && (t = { prepend: t }), this.ctx.scope.assertActive(), e = this.ctx.reflect.bind(e);
|
|
605
|
+
const r = this.bail(this.ctx, "internal/listener", i, e, t);
|
|
606
|
+
if (r) return r;
|
|
607
|
+
const n = this._hooks[i] ||= [], s = typeof i == "string" ? `event <${i}>` : "event (Symbol)";
|
|
608
|
+
return this.register(s, n, e, t);
|
|
609
|
+
}
|
|
610
|
+
once(i, e, t) {
|
|
611
|
+
const r = this.on(i, function(...n) {
|
|
612
|
+
return r(), e.apply(this, n);
|
|
613
|
+
}, t);
|
|
614
|
+
return r;
|
|
615
|
+
}
|
|
616
|
+
async start() {
|
|
617
|
+
this.isActive = !0;
|
|
618
|
+
const i = this._hooks.ready || [];
|
|
619
|
+
for (; i.length; ) {
|
|
620
|
+
const { ctx: e, callback: t } = i.shift();
|
|
621
|
+
e.scope.ensure(async () => t());
|
|
622
|
+
}
|
|
623
|
+
await this.flush();
|
|
624
|
+
}
|
|
625
|
+
async stop() {
|
|
626
|
+
this.isActive = !1, this.ctx.scope.reset();
|
|
627
|
+
}
|
|
628
|
+
}, Vi = Gi, Ji = /* @__PURE__ */ ((i) => (i[i.PENDING = 0] = "PENDING", i[i.LOADING = 1] = "LOADING", i[i.ACTIVE = 2] = "ACTIVE", i[i.FAILED = 3] = "FAILED", i[i.DISPOSED = 4] = "DISPOSED", i))(Ji || {}), Pe = class $t extends Error {
|
|
629
|
+
constructor(e, t) {
|
|
630
|
+
super(t ?? $t.Code[e]), this.code = e;
|
|
631
|
+
}
|
|
632
|
+
static {
|
|
633
|
+
k(this, "CordisError");
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
((i) => {
|
|
637
|
+
i.Code = {
|
|
638
|
+
INACTIVE_EFFECT: "cannot create effect on inactive context"
|
|
639
|
+
};
|
|
640
|
+
})(Pe || (Pe = {}));
|
|
641
|
+
var Et = class {
|
|
642
|
+
constructor(i, e) {
|
|
643
|
+
this.parent = i, this.config = e, this.uid = i.registry ? i.registry.counter : 0, this.ctx = this.context = i.extend({ scope: this }), this.proxy = new Proxy({}, {
|
|
644
|
+
get: /* @__PURE__ */ k((t, r) => Reflect.get(this.config, r), "get")
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
static {
|
|
648
|
+
k(this, "EffectScope");
|
|
649
|
+
}
|
|
650
|
+
uid;
|
|
651
|
+
ctx;
|
|
652
|
+
disposables = [];
|
|
653
|
+
error;
|
|
654
|
+
status = 0;
|
|
655
|
+
isActive = !1;
|
|
656
|
+
// Same as `this.ctx`, but with a more specific type.
|
|
657
|
+
context;
|
|
658
|
+
proxy;
|
|
659
|
+
acceptors = [];
|
|
660
|
+
tasks = /* @__PURE__ */ new Set();
|
|
661
|
+
hasError = !1;
|
|
662
|
+
get _config() {
|
|
663
|
+
return this.runtime.isReactive ? this.proxy : this.config;
|
|
664
|
+
}
|
|
665
|
+
assertActive() {
|
|
666
|
+
if (!(this.uid !== null || this.isActive))
|
|
667
|
+
throw new Pe("INACTIVE_EFFECT");
|
|
668
|
+
}
|
|
669
|
+
effect(i, e) {
|
|
670
|
+
this.assertActive();
|
|
671
|
+
const t = Ne(i) ? new i(this.ctx, e) : i(this.ctx, e);
|
|
672
|
+
let r = !1;
|
|
673
|
+
const n = typeof t == "function" ? t : t.dispose.bind(t), s = /* @__PURE__ */ k((...o) => {
|
|
674
|
+
if (!r)
|
|
675
|
+
return r = !0, W(this.disposables, s), n(...o);
|
|
676
|
+
}, "wrapped");
|
|
677
|
+
return this.disposables.push(s), typeof t == "function" ? s : (t.dispose = s, t);
|
|
678
|
+
}
|
|
679
|
+
collect(i, e) {
|
|
680
|
+
const t = j(() => (W(this.disposables, t), e()), "name", i);
|
|
681
|
+
return this.disposables.push(t), t;
|
|
682
|
+
}
|
|
683
|
+
restart() {
|
|
684
|
+
this.reset(), this.error = null, this.hasError = !1, this.status = 0, this.start();
|
|
685
|
+
}
|
|
686
|
+
_getStatus() {
|
|
687
|
+
return this.uid === null ? 4 : this.hasError ? 3 : this.tasks.size ? 1 : this.ready ? 2 : 0;
|
|
688
|
+
}
|
|
689
|
+
updateStatus(i) {
|
|
690
|
+
const e = this.status;
|
|
691
|
+
i?.(), this.status = this._getStatus(), e !== this.status && this.context.emit("internal/status", this, e);
|
|
692
|
+
}
|
|
693
|
+
ensure(i) {
|
|
694
|
+
const e = i().catch((t) => {
|
|
695
|
+
this.context.emit(this.ctx, "internal/error", t), this.cancel(t);
|
|
696
|
+
}).finally(() => {
|
|
697
|
+
this.updateStatus(() => this.tasks.delete(e)), this.context.events._tasks.delete(e);
|
|
698
|
+
});
|
|
699
|
+
this.updateStatus(() => this.tasks.add(e)), this.context.events._tasks.add(e);
|
|
700
|
+
}
|
|
701
|
+
cancel(i) {
|
|
702
|
+
this.error = i, this.updateStatus(() => this.hasError = !0), this.reset();
|
|
703
|
+
}
|
|
704
|
+
get ready() {
|
|
705
|
+
return Object.entries(this.runtime.inject).every(([i, e]) => !e.required || !I(this.ctx.get(i)));
|
|
706
|
+
}
|
|
707
|
+
reset() {
|
|
708
|
+
this.isActive = !1, this.disposables = this.disposables.splice(0).filter((i) => {
|
|
709
|
+
if (this.uid !== null && i[N.static] === this) return !0;
|
|
710
|
+
(async () => i())().catch((e) => {
|
|
711
|
+
this.context.emit(this.ctx, "internal/error", e);
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
init(i) {
|
|
716
|
+
this.config ? this.start() : this.cancel(i);
|
|
717
|
+
}
|
|
718
|
+
start() {
|
|
719
|
+
if (!this.ready || this.isActive || this.uid === null) return !0;
|
|
720
|
+
this.isActive = !0, this.updateStatus(() => this.hasError = !1);
|
|
721
|
+
}
|
|
722
|
+
accept(...i) {
|
|
723
|
+
const t = { keys: Array.isArray(i[0]) ? i.shift() : null, callback: i[0], ...i[1] };
|
|
724
|
+
return this.effect(() => (this.acceptors.push(t), t.immediate && t.callback?.(this.config), () => W(this.acceptors, t)));
|
|
725
|
+
}
|
|
726
|
+
decline(i) {
|
|
727
|
+
return this.accept(i, () => !0);
|
|
728
|
+
}
|
|
729
|
+
checkUpdate(i, e) {
|
|
730
|
+
if (e || !this.config) return [!0, !0];
|
|
731
|
+
if (e === !1) return [!1, !1];
|
|
732
|
+
const t = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ k((f) => {
|
|
733
|
+
const u = t[f] ??= !J(this.config[f], i[f]);
|
|
734
|
+
return s ||= u, u;
|
|
735
|
+
}, "checkPropertyUpdate"), n = /* @__PURE__ */ new Set();
|
|
736
|
+
let s = !1, o = !1, a = this.runtime.isReactive || null;
|
|
737
|
+
for (const { keys: f, callback: u, passive: p } of this.acceptors) {
|
|
738
|
+
if (!f)
|
|
739
|
+
a ||= !p;
|
|
740
|
+
else if (p)
|
|
741
|
+
f?.forEach((_) => n.add(_));
|
|
742
|
+
else {
|
|
743
|
+
let _ = !1;
|
|
744
|
+
for (const g of f)
|
|
745
|
+
_ ||= r(g);
|
|
746
|
+
if (!_) continue;
|
|
747
|
+
}
|
|
748
|
+
u?.(i) && (o = !0);
|
|
749
|
+
}
|
|
750
|
+
for (const f in { ...this.config, ...i })
|
|
751
|
+
if (a !== !1 && !(f in t) && !n.has(f)) {
|
|
752
|
+
const u = r(f);
|
|
753
|
+
a === null && (o ||= u);
|
|
754
|
+
}
|
|
755
|
+
return [s, o];
|
|
756
|
+
}
|
|
757
|
+
}, Yi = class extends Et {
|
|
758
|
+
constructor(i, e, t, r) {
|
|
759
|
+
super(i, t), this.runtime = e, this.dispose = j(i.scope.collect(`fork <${i.runtime.name}>`, () => {
|
|
760
|
+
this.uid = null, this.reset(), this.context.emit("internal/fork", this);
|
|
761
|
+
const n = W(e.disposables, this.dispose);
|
|
762
|
+
return W(e.children, this) && !e.children.length && i.registry.delete(e.plugin), n;
|
|
763
|
+
}), N.static, e), e.children.push(this), e.disposables.push(this.dispose), this.context.emit("internal/fork", this), this.init(r);
|
|
764
|
+
}
|
|
765
|
+
static {
|
|
766
|
+
k(this, "ForkScope");
|
|
767
|
+
}
|
|
768
|
+
dispose;
|
|
769
|
+
start() {
|
|
770
|
+
if (super.start()) return !0;
|
|
771
|
+
for (const i of this.runtime.forkables)
|
|
772
|
+
this.ensure(async () => i(this.context, this._config));
|
|
773
|
+
}
|
|
774
|
+
update(i, e) {
|
|
775
|
+
const t = this.config, r = this.runtime.isForkable ? this : this.runtime;
|
|
776
|
+
if (r.config !== t) return;
|
|
777
|
+
let n;
|
|
778
|
+
try {
|
|
779
|
+
n = se(this.runtime.plugin, i);
|
|
780
|
+
} catch (a) {
|
|
781
|
+
return this.context.emit("internal/error", a), this.cancel(a);
|
|
782
|
+
}
|
|
783
|
+
const [s, o] = r.checkUpdate(n, e);
|
|
784
|
+
this.context.emit("internal/before-update", this, i), this.config = n, r.config = n, s && this.context.emit("internal/update", this, t), o && r.restart();
|
|
785
|
+
}
|
|
786
|
+
}, ct = class extends Et {
|
|
787
|
+
constructor(i, e, t, r) {
|
|
788
|
+
super(i, t), this.plugin = e, e ? (this.setup(), this.init(r)) : (this.name = "root", this.isActive = !0);
|
|
789
|
+
}
|
|
790
|
+
static {
|
|
791
|
+
k(this, "MainScope");
|
|
792
|
+
}
|
|
793
|
+
value;
|
|
794
|
+
runtime = this;
|
|
795
|
+
schema;
|
|
796
|
+
name;
|
|
797
|
+
inject = /* @__PURE__ */ Object.create(null);
|
|
798
|
+
forkables = [];
|
|
799
|
+
children = [];
|
|
800
|
+
isReusable = !1;
|
|
801
|
+
isReactive = !1;
|
|
802
|
+
get isForkable() {
|
|
803
|
+
return this.forkables.length > 0;
|
|
804
|
+
}
|
|
805
|
+
fork(i, e, t) {
|
|
806
|
+
return new Yi(i, this, e, t);
|
|
807
|
+
}
|
|
808
|
+
dispose() {
|
|
809
|
+
return this.uid = null, this.reset(), this.context.emit("internal/runtime", this), !0;
|
|
810
|
+
}
|
|
811
|
+
setup() {
|
|
812
|
+
const { name: i } = this.plugin;
|
|
813
|
+
i && i !== "apply" && (this.name = i), this.schema = this.plugin.Config || this.plugin.schema, this.inject = F.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);
|
|
814
|
+
}
|
|
815
|
+
apply = /* @__PURE__ */ k((i, e) => {
|
|
816
|
+
if (typeof this.plugin != "function")
|
|
817
|
+
return this.plugin.apply(i, e);
|
|
818
|
+
if (Ne(this.plugin)) {
|
|
819
|
+
const t = new this.plugin(i, e), r = t[N.expose];
|
|
820
|
+
return r && i.set(r, t), t.fork && this.forkables.push(t.fork.bind(t)), t;
|
|
821
|
+
} else
|
|
822
|
+
return this.plugin(i, e);
|
|
823
|
+
}, "apply");
|
|
824
|
+
reset() {
|
|
825
|
+
super.reset();
|
|
826
|
+
for (const i of this.children)
|
|
827
|
+
i.reset();
|
|
828
|
+
}
|
|
829
|
+
start() {
|
|
830
|
+
if (super.start()) return !0;
|
|
831
|
+
!this.isReusable && this.plugin && this.ensure(async () => this.value = this.apply(this.ctx, this._config));
|
|
832
|
+
for (const i of this.children)
|
|
833
|
+
i.start();
|
|
834
|
+
}
|
|
835
|
+
update(i, e) {
|
|
836
|
+
if (this.isForkable) {
|
|
837
|
+
const a = new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);
|
|
838
|
+
this.context.emit(this.ctx, "internal/warning", a);
|
|
839
|
+
}
|
|
840
|
+
const t = this.config;
|
|
841
|
+
let r;
|
|
842
|
+
try {
|
|
843
|
+
r = se(this.runtime.plugin || this.context.constructor, i);
|
|
844
|
+
} catch (a) {
|
|
845
|
+
return this.context.emit("internal/error", a), this.cancel(a);
|
|
846
|
+
}
|
|
847
|
+
const [n, s] = this.checkUpdate(r, e), o = this.children.find((a) => a.config === t);
|
|
848
|
+
this.config = r, o && (this.context.emit("internal/before-update", o, i), o.config = r, n && this.context.emit("internal/update", o, t)), s && this.restart();
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
function Ct(i) {
|
|
852
|
+
return i && typeof i == "object" && typeof i.apply == "function";
|
|
853
|
+
}
|
|
854
|
+
k(Ct, "isApplicable");
|
|
855
|
+
function F(i) {
|
|
856
|
+
return function(e, t) {
|
|
857
|
+
if (t.kind === "class")
|
|
858
|
+
e.inject = i;
|
|
859
|
+
else if (t.kind === "method")
|
|
860
|
+
t.addInitializer(function() {
|
|
861
|
+
const r = this[b.tracker]?.property;
|
|
862
|
+
if (!r) throw new Error("missing context tracker");
|
|
863
|
+
this[r].inject(i, (n) => {
|
|
864
|
+
e.call(ie(this, { [r]: n }));
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
else
|
|
868
|
+
throw new Error("@Inject can only be used on class or class methods");
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
k(F, "Inject");
|
|
872
|
+
((i) => {
|
|
873
|
+
function e(t) {
|
|
874
|
+
if (!t) return {};
|
|
875
|
+
if (Array.isArray(t))
|
|
876
|
+
return Object.fromEntries(t.map((o) => [o, { required: !0 }]));
|
|
877
|
+
const { required: r, optional: n, ...s } = t;
|
|
878
|
+
return Array.isArray(r) && Object.assign(s, Object.fromEntries(r.map((o) => [o, { required: !0 }]))), Array.isArray(n) && Object.assign(s, Object.fromEntries(n.map((o) => [o, { required: !1 }]))), s;
|
|
879
|
+
}
|
|
880
|
+
i.resolve = e, k(e, "resolve");
|
|
881
|
+
})(F || (F = {}));
|
|
882
|
+
var Xi = class {
|
|
883
|
+
constructor(i, e) {
|
|
884
|
+
this.ctx = i, j(this, b.tracker, {
|
|
885
|
+
associate: "registry",
|
|
886
|
+
property: "ctx"
|
|
887
|
+
}), this.context = i;
|
|
888
|
+
const t = new ct(i, null, e);
|
|
889
|
+
i.scope = t, t.ctx = i, this.set(null, t);
|
|
890
|
+
}
|
|
891
|
+
static {
|
|
892
|
+
k(this, "Registry");
|
|
893
|
+
}
|
|
894
|
+
_counter = 0;
|
|
895
|
+
_internal = /* @__PURE__ */ new Map();
|
|
896
|
+
context;
|
|
897
|
+
get counter() {
|
|
898
|
+
return ++this._counter;
|
|
899
|
+
}
|
|
900
|
+
get size() {
|
|
901
|
+
return this._internal.size;
|
|
902
|
+
}
|
|
903
|
+
resolve(i, e = !1) {
|
|
904
|
+
if (i === null || typeof i == "function") return i;
|
|
905
|
+
if (Ct(i)) return i.apply;
|
|
906
|
+
if (e) throw new Error('invalid plugin, expect function or object with an "apply" method, received ' + typeof i);
|
|
907
|
+
}
|
|
908
|
+
get(i) {
|
|
909
|
+
const e = this.resolve(i);
|
|
910
|
+
return e && this._internal.get(e);
|
|
911
|
+
}
|
|
912
|
+
has(i) {
|
|
913
|
+
const e = this.resolve(i);
|
|
914
|
+
return !!e && this._internal.has(e);
|
|
915
|
+
}
|
|
916
|
+
set(i, e) {
|
|
917
|
+
const t = this.resolve(i);
|
|
918
|
+
this._internal.set(t, e);
|
|
919
|
+
}
|
|
920
|
+
delete(i) {
|
|
921
|
+
const e = this.resolve(i), t = e && this._internal.get(e);
|
|
922
|
+
if (t)
|
|
923
|
+
return this._internal.delete(e), t.dispose(), t;
|
|
924
|
+
}
|
|
925
|
+
keys() {
|
|
926
|
+
return this._internal.keys();
|
|
927
|
+
}
|
|
928
|
+
values() {
|
|
929
|
+
return this._internal.values();
|
|
930
|
+
}
|
|
931
|
+
entries() {
|
|
932
|
+
return this._internal.entries();
|
|
933
|
+
}
|
|
934
|
+
forEach(i) {
|
|
935
|
+
return this._internal.forEach(i);
|
|
936
|
+
}
|
|
937
|
+
using(i, e) {
|
|
938
|
+
return this.inject(i, e);
|
|
939
|
+
}
|
|
940
|
+
inject(i, e) {
|
|
941
|
+
return this.plugin({ inject: i, apply: e, name: e.name });
|
|
942
|
+
}
|
|
943
|
+
plugin(i, e, t) {
|
|
944
|
+
if (this.resolve(i, !0), this.ctx.scope.assertActive(), !t)
|
|
945
|
+
try {
|
|
946
|
+
e = se(i, e);
|
|
947
|
+
} catch (n) {
|
|
948
|
+
this.context.emit(this.ctx, "internal/error", n), t = n, e = null;
|
|
949
|
+
}
|
|
950
|
+
let r = this.get(i);
|
|
951
|
+
return r ? (r.isForkable || this.context.emit(this.ctx, "internal/warning", new Error(`duplicate plugin detected: ${i.name}`)), r.fork(this.ctx, e, t)) : (r = new ct(this.ctx, i, e, t), this.set(i, r), r.fork(this.ctx, e, t));
|
|
952
|
+
}
|
|
953
|
+
}, Qi = Xi, N = class ee {
|
|
954
|
+
static {
|
|
955
|
+
k(this, "Context");
|
|
956
|
+
}
|
|
957
|
+
static store = b.store;
|
|
958
|
+
static events = b.events;
|
|
959
|
+
static static = b.static;
|
|
960
|
+
static filter = b.filter;
|
|
961
|
+
static expose = b.expose;
|
|
962
|
+
static isolate = b.isolate;
|
|
963
|
+
static internal = b.internal;
|
|
964
|
+
static intercept = b.intercept;
|
|
965
|
+
static origin = "ctx";
|
|
966
|
+
static current = "ctx";
|
|
967
|
+
static is(e) {
|
|
968
|
+
return !!e?.[ee.is];
|
|
969
|
+
}
|
|
970
|
+
static {
|
|
971
|
+
ee.is[Symbol.toPrimitive] = () => /* @__PURE__ */ Symbol.for("cordis.is"), ee.prototype[ee.is] = !0;
|
|
972
|
+
}
|
|
973
|
+
/** @deprecated use `Service.traceable` instead */
|
|
974
|
+
static associate(e, t) {
|
|
975
|
+
return e;
|
|
976
|
+
}
|
|
977
|
+
constructor(e) {
|
|
978
|
+
e = se(this.constructor, e), this[b.store] = /* @__PURE__ */ Object.create(null), this[b.isolate] = /* @__PURE__ */ Object.create(null), this[b.internal] = /* @__PURE__ */ Object.create(null), this[b.intercept] = /* @__PURE__ */ Object.create(null);
|
|
979
|
+
const t = new Proxy(this, Ae.handler);
|
|
980
|
+
t.root = t, t.reflect = new Ae(t), t.registry = new Qi(t, e), t.lifecycle = new Vi(t);
|
|
981
|
+
const r = /* @__PURE__ */ k((n) => {
|
|
982
|
+
if (n) {
|
|
983
|
+
r(Object.getPrototypeOf(n));
|
|
984
|
+
for (const s of Object.getOwnPropertyNames(n)) {
|
|
985
|
+
const o = n[s].prototype?.constructor;
|
|
986
|
+
o && (t[n[s].key] = new o(t, e), j(t[n[s].key], "ctx", t));
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}, "attach");
|
|
990
|
+
return r(this[b.internal]), t;
|
|
991
|
+
}
|
|
992
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
993
|
+
return `Context <${this.name}>`;
|
|
994
|
+
}
|
|
995
|
+
get name() {
|
|
996
|
+
let e = this.runtime;
|
|
997
|
+
for (; e && !e.name; )
|
|
998
|
+
e = e.parent.runtime;
|
|
999
|
+
return e?.name;
|
|
1000
|
+
}
|
|
1001
|
+
get events() {
|
|
1002
|
+
return this.lifecycle;
|
|
1003
|
+
}
|
|
1004
|
+
/** @deprecated */
|
|
1005
|
+
get state() {
|
|
1006
|
+
return this.scope;
|
|
1007
|
+
}
|
|
1008
|
+
extend(e = {}) {
|
|
1009
|
+
const t = Reflect.getOwnPropertyDescriptor(this, b.shadow)?.value, r = Object.assign(Object.create(U(this, this)), e);
|
|
1010
|
+
return t ? Object.assign(Object.create(r), { [b.shadow]: t }) : r;
|
|
1011
|
+
}
|
|
1012
|
+
isolate(e, t) {
|
|
1013
|
+
const r = Object.create(this[b.isolate]);
|
|
1014
|
+
return r[e] = t ?? Symbol(e), this.extend({ [b.isolate]: r });
|
|
1015
|
+
}
|
|
1016
|
+
intercept(e, t) {
|
|
1017
|
+
const r = Object.create(this[b.intercept]);
|
|
1018
|
+
return r[e] = t, this.extend({ [b.intercept]: r });
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
N.prototype[N.internal] = /* @__PURE__ */ Object.create(null);
|
|
1022
|
+
var z = class At {
|
|
1023
|
+
static {
|
|
1024
|
+
k(this, "Service");
|
|
1025
|
+
}
|
|
1026
|
+
static setup = b.setup;
|
|
1027
|
+
static invoke = b.invoke;
|
|
1028
|
+
static extend = b.extend;
|
|
1029
|
+
static tracker = b.tracker;
|
|
1030
|
+
static provide = b.provide;
|
|
1031
|
+
static immediate = b.immediate;
|
|
1032
|
+
start() {
|
|
1033
|
+
}
|
|
1034
|
+
stop() {
|
|
1035
|
+
}
|
|
1036
|
+
ctx;
|
|
1037
|
+
name;
|
|
1038
|
+
config;
|
|
1039
|
+
constructor(...e) {
|
|
1040
|
+
let t, r, n, s;
|
|
1041
|
+
N.is(e[0]) ? (t = e[0], typeof e[1] == "string" ? (r = e[1], n = e[2]) : s = e[1]) : s = e[0], r ??= this.constructor[b.provide], n ??= this.constructor[b.immediate];
|
|
1042
|
+
let o = this;
|
|
1043
|
+
const a = {
|
|
1044
|
+
associate: r,
|
|
1045
|
+
property: "ctx"
|
|
1046
|
+
};
|
|
1047
|
+
return o[b.invoke] && (o = Ce(r, Be(Object.getPrototypeOf(this), Function.prototype), a)), t ? o.ctx = t : o[b.setup](), o.name = r, o.config = s, j(o, b.tracker, a), o.ctx.provide(r), o.ctx.runtime.name = r, n && (t ? o[b.expose] = r : o.ctx.set(r, o)), o.ctx.on("ready", async () => {
|
|
1048
|
+
await Promise.resolve(), await o.start(), n || o.ctx.set(r, o);
|
|
1049
|
+
}), o.ctx.on("dispose", () => o.stop()), o;
|
|
1050
|
+
}
|
|
1051
|
+
[b.filter](e) {
|
|
1052
|
+
return e[b.isolate][this.name] === this.ctx[b.isolate][this.name];
|
|
1053
|
+
}
|
|
1054
|
+
[b.setup]() {
|
|
1055
|
+
this.ctx = new N();
|
|
1056
|
+
}
|
|
1057
|
+
[b.extend](e) {
|
|
1058
|
+
let t;
|
|
1059
|
+
return this[At.invoke] ? t = Ce(this.name, this, this[b.tracker]) : t = Object.create(this), Object.assign(t, e);
|
|
1060
|
+
}
|
|
1061
|
+
static [Symbol.hasInstance](e) {
|
|
1062
|
+
let t = e.constructor;
|
|
1063
|
+
for (; t; ) {
|
|
1064
|
+
if (t = t.prototype?.constructor, t === this) return !0;
|
|
1065
|
+
t = Object.getPrototypeOf(t);
|
|
1066
|
+
}
|
|
1067
|
+
return !1;
|
|
1068
|
+
}
|
|
1069
|
+
}, Zi = Object.defineProperty, er = Object.getOwnPropertyNames, E = (i, e) => Zi(i, "name", { value: e, configurable: !0 }), tr = (i, e) => function() {
|
|
1070
|
+
return e || (0, i[er(i)[0]])((e = { exports: {} }).exports, e), e.exports;
|
|
1071
|
+
}, ir = tr({
|
|
1072
|
+
"src/index.ts"(i, e) {
|
|
1073
|
+
var t = /* @__PURE__ */ Symbol.for("schemastery"), r = /* @__PURE__ */ Symbol.for("ValidationError");
|
|
1074
|
+
globalThis.__schemastery_index__ ??= 0, globalThis.__schemastery_refs__ = void 0;
|
|
1075
|
+
var n = class extends TypeError {
|
|
1076
|
+
constructor(l, c) {
|
|
1077
|
+
let h = "$";
|
|
1078
|
+
for (const d of c.path || [])
|
|
1079
|
+
typeof d == "string" ? h += "." + d : typeof d == "number" ? h += "[" + d + "]" : typeof d == "symbol" && (h += `[Symbol(${d.toString()})]`);
|
|
1080
|
+
h.startsWith(".") && (h = h.slice(1)), super((h === "$" ? "" : `${h} `) + l), this.options = c;
|
|
1081
|
+
}
|
|
1082
|
+
static {
|
|
1083
|
+
E(this, "ValidationError");
|
|
1084
|
+
}
|
|
1085
|
+
name = "ValidationError";
|
|
1086
|
+
static is(l) {
|
|
1087
|
+
return !!l?.[r];
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
Object.defineProperty(n.prototype, r, {
|
|
1091
|
+
value: !0
|
|
1092
|
+
});
|
|
1093
|
+
var s = /* @__PURE__ */ E(function(l) {
|
|
1094
|
+
const c = /* @__PURE__ */ E(function(h, d = {}) {
|
|
1095
|
+
return s.resolve(h, c, d)[0];
|
|
1096
|
+
}, "schema");
|
|
1097
|
+
if (l.refs) {
|
|
1098
|
+
const h = q(l.refs, (m) => new s(m)), d = /* @__PURE__ */ E((m) => h[m], "getRef");
|
|
1099
|
+
for (const m in h) {
|
|
1100
|
+
const v = h[m];
|
|
1101
|
+
v.sKey = d(v.sKey), v.inner = d(v.inner), v.list = v.list && v.list.map(d), v.dict = v.dict && q(v.dict, d);
|
|
1102
|
+
}
|
|
1103
|
+
return h[l.uid];
|
|
1104
|
+
}
|
|
1105
|
+
if (Object.assign(c, l), typeof c.callback == "string")
|
|
1106
|
+
try {
|
|
1107
|
+
c.callback = new Function("return " + c.callback)();
|
|
1108
|
+
} catch {
|
|
1109
|
+
}
|
|
1110
|
+
return Object.defineProperty(c, "uid", { value: globalThis.__schemastery_index__++ }), Object.setPrototypeOf(c, s.prototype), c.meta ||= {}, c.toString = c.toString.bind(c), c;
|
|
1111
|
+
}, "Schema");
|
|
1112
|
+
s.prototype = Object.create(Function.prototype), s.prototype[t] = !0, s.ValidationError = n, s.prototype.toJSON = /* @__PURE__ */ E(function() {
|
|
1113
|
+
if (globalThis.__schemastery_refs__)
|
|
1114
|
+
return globalThis.__schemastery_refs__[this.uid] ??= JSON.parse(JSON.stringify({ ...this })), this.uid;
|
|
1115
|
+
globalThis.__schemastery_refs__ = { [this.uid]: { ...this } }, globalThis.__schemastery_refs__[this.uid] = JSON.parse(JSON.stringify({ ...this }));
|
|
1116
|
+
const c = { uid: this.uid, refs: globalThis.__schemastery_refs__ };
|
|
1117
|
+
return globalThis.__schemastery_refs__ = void 0, c;
|
|
1118
|
+
}, "toJSON"), s.prototype.set = /* @__PURE__ */ E(function(c, h) {
|
|
1119
|
+
return this.dict[c] = h, this;
|
|
1120
|
+
}, "set"), s.prototype.push = /* @__PURE__ */ E(function(c) {
|
|
1121
|
+
return this.list.push(c), this;
|
|
1122
|
+
}, "push");
|
|
1123
|
+
function o(l, c) {
|
|
1124
|
+
const h = typeof l == "string" ? { "": l } : { ...l };
|
|
1125
|
+
for (const d in c) {
|
|
1126
|
+
const m = c[d];
|
|
1127
|
+
m?.$description || m?.$desc ? h[d] = m.$description || m.$desc : typeof m == "string" && (h[d] = m);
|
|
1128
|
+
}
|
|
1129
|
+
return h;
|
|
1130
|
+
}
|
|
1131
|
+
E(o, "mergeDesc");
|
|
1132
|
+
function a(l) {
|
|
1133
|
+
return l?.$value ?? l?.$inner;
|
|
1134
|
+
}
|
|
1135
|
+
E(a, "getInner");
|
|
1136
|
+
function f(l) {
|
|
1137
|
+
return bt(l ?? {}, (c) => !c.startsWith("$"));
|
|
1138
|
+
}
|
|
1139
|
+
E(f, "extractKeys"), s.prototype.i18n = /* @__PURE__ */ E(function(c) {
|
|
1140
|
+
const h = s(this), d = o(h.meta.description, c);
|
|
1141
|
+
return Object.keys(d).length && (h.meta.description = d), h.dict && (h.dict = q(h.dict, (m, v) => m.i18n(q(c, (x) => a(x)?.[v] ?? x?.[v])))), h.list && (h.list = h.list.map((m, v) => m.i18n(q(c, (x = {}) => Array.isArray(a(x)) ? a(x)[v] : Array.isArray(x) ? x[v] : f(x))))), h.inner && (h.inner = h.inner.i18n(q(c, (m) => a(m) ? a(m) : f(m)))), h.sKey && (h.sKey = h.sKey.i18n(q(c, (m) => m?.$key))), h;
|
|
1142
|
+
}, "i18n"), s.prototype.extra = /* @__PURE__ */ E(function(c, h) {
|
|
1143
|
+
const d = s(this);
|
|
1144
|
+
return d.meta = { ...d.meta, [c]: h }, d;
|
|
1145
|
+
}, "extra");
|
|
1146
|
+
for (const l of ["required", "disabled", "collapse", "hidden", "loose"])
|
|
1147
|
+
Object.assign(s.prototype, {
|
|
1148
|
+
[l](c = !0) {
|
|
1149
|
+
const h = s(this);
|
|
1150
|
+
return h.meta = { ...h.meta, [l]: c }, h;
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
s.prototype.deprecated = /* @__PURE__ */ E(function() {
|
|
1154
|
+
const c = s(this);
|
|
1155
|
+
return c.meta.badges ||= [], c.meta.badges.push({ text: "deprecated", type: "danger" }), c;
|
|
1156
|
+
}, "deprecated"), s.prototype.experimental = /* @__PURE__ */ E(function() {
|
|
1157
|
+
const c = s(this);
|
|
1158
|
+
return c.meta.badges ||= [], c.meta.badges.push({ text: "experimental", type: "warning" }), c;
|
|
1159
|
+
}, "experimental"), s.prototype.pattern = /* @__PURE__ */ E(function(c) {
|
|
1160
|
+
const h = s(this), d = vt(c, ["source", "flags"]);
|
|
1161
|
+
return h.meta = { ...h.meta, pattern: d }, h;
|
|
1162
|
+
}, "pattern"), s.prototype.simplify = /* @__PURE__ */ E(function(c) {
|
|
1163
|
+
if (J(c, this.meta.default, this.type === "dict")) return null;
|
|
1164
|
+
if (I(c)) return c;
|
|
1165
|
+
if (this.type === "object" || this.type === "dict") {
|
|
1166
|
+
const h = {};
|
|
1167
|
+
for (const d in c) {
|
|
1168
|
+
const v = (this.type === "object" ? this.dict[d] : this.inner)?.simplify(c[d]);
|
|
1169
|
+
(this.type === "dict" || !I(v)) && (h[d] = v);
|
|
1170
|
+
}
|
|
1171
|
+
return J(h, this.meta.default, this.type === "dict") ? null : h;
|
|
1172
|
+
} else if (this.type === "array" || this.type === "tuple") {
|
|
1173
|
+
const h = [];
|
|
1174
|
+
return c.forEach((d, m) => {
|
|
1175
|
+
const v = this.type === "array" ? this.inner : this.list[m], x = v ? v.simplify(d) : d;
|
|
1176
|
+
h.push(x);
|
|
1177
|
+
}), h;
|
|
1178
|
+
} else if (this.type === "intersect") {
|
|
1179
|
+
const h = {};
|
|
1180
|
+
for (const d of this.list)
|
|
1181
|
+
Object.assign(h, d.simplify(c));
|
|
1182
|
+
return h;
|
|
1183
|
+
} else if (this.type === "union")
|
|
1184
|
+
for (const h of this.list)
|
|
1185
|
+
try {
|
|
1186
|
+
return s.resolve(c, h, {}), h.simplify(c);
|
|
1187
|
+
} catch {
|
|
1188
|
+
}
|
|
1189
|
+
return c;
|
|
1190
|
+
}, "simplify"), s.prototype.toString = /* @__PURE__ */ E(function(c) {
|
|
1191
|
+
return O[this.type]?.(this, c) ?? `Schema<${this.type}>`;
|
|
1192
|
+
}, "toString"), s.prototype.role = /* @__PURE__ */ E(function(l, c) {
|
|
1193
|
+
const h = s(this);
|
|
1194
|
+
return h.meta = { ...h.meta, role: l, extra: c }, h;
|
|
1195
|
+
}, "role");
|
|
1196
|
+
for (const l of ["default", "link", "comment", "description", "max", "min", "step"])
|
|
1197
|
+
Object.assign(s.prototype, {
|
|
1198
|
+
[l](c) {
|
|
1199
|
+
const h = s(this);
|
|
1200
|
+
return h.meta = { ...h.meta, [l]: c }, h;
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
var u = {};
|
|
1204
|
+
s.extend = /* @__PURE__ */ E(function(c, h) {
|
|
1205
|
+
u[c] = h;
|
|
1206
|
+
}, "extend"), s.resolve = /* @__PURE__ */ E(function(c, h, d = {}, m = !1) {
|
|
1207
|
+
if (!h) return [c];
|
|
1208
|
+
if (d.ignore?.(c, h)) return [c];
|
|
1209
|
+
if (I(c) && h.type !== "lazy") {
|
|
1210
|
+
if (h.meta.required) throw new n("missing required value", d);
|
|
1211
|
+
let x = h, A = h.meta.default;
|
|
1212
|
+
for (; x?.type === "intersect" && I(A); )
|
|
1213
|
+
x = x.list[0], A = x?.meta.default;
|
|
1214
|
+
if (I(A)) return [c];
|
|
1215
|
+
c = he(A);
|
|
1216
|
+
}
|
|
1217
|
+
const v = u[h.type];
|
|
1218
|
+
if (!v) throw new n(`unsupported type "${h.type}"`, d);
|
|
1219
|
+
try {
|
|
1220
|
+
return v(c, h, d, m);
|
|
1221
|
+
} catch (x) {
|
|
1222
|
+
if (!h.meta.loose) throw x;
|
|
1223
|
+
return [h.meta.default];
|
|
1224
|
+
}
|
|
1225
|
+
}, "resolve"), s.from = /* @__PURE__ */ E(function(c) {
|
|
1226
|
+
if (I(c))
|
|
1227
|
+
return s.any();
|
|
1228
|
+
if (["string", "number", "boolean"].includes(typeof c))
|
|
1229
|
+
return s.const(c).required();
|
|
1230
|
+
if (c[t])
|
|
1231
|
+
return c;
|
|
1232
|
+
if (typeof c == "function")
|
|
1233
|
+
switch (c) {
|
|
1234
|
+
case String:
|
|
1235
|
+
return s.string().required();
|
|
1236
|
+
case Number:
|
|
1237
|
+
return s.number().required();
|
|
1238
|
+
case Boolean:
|
|
1239
|
+
return s.boolean().required();
|
|
1240
|
+
case Function:
|
|
1241
|
+
return s.function().required();
|
|
1242
|
+
default:
|
|
1243
|
+
return s.is(c).required();
|
|
1244
|
+
}
|
|
1245
|
+
else
|
|
1246
|
+
throw new TypeError(`cannot infer schema from ${c}`);
|
|
1247
|
+
}, "from"), s.lazy = /* @__PURE__ */ E(function(c) {
|
|
1248
|
+
const h = /* @__PURE__ */ E(() => (d.inner[t] || (d.inner = d.builder(), d.inner.meta = { ...d.meta, ...d.inner.meta }), d.inner.toJSON()), "toJSON"), d = new s({ type: "lazy", builder: c, inner: { toJSON: h } });
|
|
1249
|
+
return d;
|
|
1250
|
+
}, "lazy"), s.natural = /* @__PURE__ */ E(function() {
|
|
1251
|
+
return s.number().step(1).min(0);
|
|
1252
|
+
}, "natural"), s.percent = /* @__PURE__ */ E(function() {
|
|
1253
|
+
return s.number().step(0.01).min(0).max(1).role("slider");
|
|
1254
|
+
}, "percent"), s.date = /* @__PURE__ */ E(function() {
|
|
1255
|
+
return s.union([
|
|
1256
|
+
s.is(Date),
|
|
1257
|
+
s.transform(s.string().role("datetime"), (c, h) => {
|
|
1258
|
+
const d = new Date(c);
|
|
1259
|
+
if (isNaN(+d)) throw new n(`invalid date "${c}"`, h);
|
|
1260
|
+
return d;
|
|
1261
|
+
}, !0)
|
|
1262
|
+
]);
|
|
1263
|
+
}, "date"), s.regExp = /* @__PURE__ */ E(function(c = "") {
|
|
1264
|
+
return s.union([
|
|
1265
|
+
s.is(RegExp),
|
|
1266
|
+
s.transform(s.string().role("regexp", { flag: c }), (h, d) => {
|
|
1267
|
+
try {
|
|
1268
|
+
return new RegExp(h, c);
|
|
1269
|
+
} catch (m) {
|
|
1270
|
+
throw new n(m.message, d);
|
|
1271
|
+
}
|
|
1272
|
+
}, !0)
|
|
1273
|
+
]);
|
|
1274
|
+
}, "regExp"), s.arrayBuffer = /* @__PURE__ */ E(function(c) {
|
|
1275
|
+
return s.union([
|
|
1276
|
+
s.is(ArrayBuffer),
|
|
1277
|
+
s.is(SharedArrayBuffer),
|
|
1278
|
+
s.transform(s.any(), (h, d) => {
|
|
1279
|
+
if (B.isSource(h)) return B.fromSource(h);
|
|
1280
|
+
throw new n(`expected ArrayBufferSource but got ${h}`, d);
|
|
1281
|
+
}, !0),
|
|
1282
|
+
...c ? [s.transform(s.string(), (h, d) => {
|
|
1283
|
+
try {
|
|
1284
|
+
return c === "base64" ? B.fromBase64(h) : B.fromHex(h);
|
|
1285
|
+
} catch (m) {
|
|
1286
|
+
throw new n(m.message, d);
|
|
1287
|
+
}
|
|
1288
|
+
}, !0)] : []
|
|
1289
|
+
]);
|
|
1290
|
+
}, "arrayBuffer"), s.extend("lazy", (l, c, h, d) => (c.inner[t] || (c.inner = c.builder(), c.inner.meta = { ...c.meta, ...c.inner.meta }), s.resolve(l, c.inner, h, d))), s.extend("any", (l) => [l]), s.extend("never", (l, c, h) => {
|
|
1291
|
+
throw new n(`expected nullable but got ${l}`, h);
|
|
1292
|
+
}), s.extend("const", (l, { value: c }, h) => {
|
|
1293
|
+
if (J(l, c)) return [c];
|
|
1294
|
+
throw new n(`expected ${c} but got ${l}`, h);
|
|
1295
|
+
});
|
|
1296
|
+
function p(l, c, h, d, m = !1) {
|
|
1297
|
+
const { max: v = 1 / 0, min: x = -1 / 0 } = c;
|
|
1298
|
+
if (l > v) throw new n(`expected ${h} <= ${v} but got ${l}`, d);
|
|
1299
|
+
if (l < x && !m) throw new n(`expected ${h} >= ${x} but got ${l}`, d);
|
|
1300
|
+
}
|
|
1301
|
+
E(p, "checkWithinRange"), s.extend("string", (l, { meta: c }, h) => {
|
|
1302
|
+
if (typeof l != "string") throw new n(`expected string but got ${l}`, h);
|
|
1303
|
+
if (c.pattern) {
|
|
1304
|
+
const d = new RegExp(c.pattern.source, c.pattern.flags);
|
|
1305
|
+
if (!d.test(l)) throw new n(`expect string to match regexp ${d}`, h);
|
|
1306
|
+
}
|
|
1307
|
+
return p(l.length, c, "string length", h), [l];
|
|
1308
|
+
});
|
|
1309
|
+
function y(l, c) {
|
|
1310
|
+
const h = l.toString();
|
|
1311
|
+
if (h.includes("e")) return l * Math.pow(10, c);
|
|
1312
|
+
const d = h.indexOf(".");
|
|
1313
|
+
if (d === -1) return l * Math.pow(10, c);
|
|
1314
|
+
const m = h.slice(d + 1), v = h.slice(0, d);
|
|
1315
|
+
return m.length <= c ? +(v + m.padEnd(c, "0")) : +(v + m.slice(0, c) + "." + m.slice(c));
|
|
1316
|
+
}
|
|
1317
|
+
E(y, "decimalShift");
|
|
1318
|
+
function _(l, c, h) {
|
|
1319
|
+
if (h = Math.abs(h), !/^\d+\.\d+$/.test(h.toString()))
|
|
1320
|
+
return (l - c) % h === 0;
|
|
1321
|
+
const d = h.toString().indexOf("."), m = h.toString().slice(d + 1).length;
|
|
1322
|
+
return Math.abs(y(l, m) - y(c, m)) % y(h, m) === 0;
|
|
1323
|
+
}
|
|
1324
|
+
E(_, "isMultipleOf"), s.extend("number", (l, { meta: c }, h) => {
|
|
1325
|
+
if (typeof l != "number") throw new n(`expected number but got ${l}`, h);
|
|
1326
|
+
p(l, c, "number", h);
|
|
1327
|
+
const { step: d } = c;
|
|
1328
|
+
if (d && !_(l, c.min ?? 0, d))
|
|
1329
|
+
throw new n(`expected number multiple of ${d} but got ${l}`, h);
|
|
1330
|
+
return [l];
|
|
1331
|
+
}), s.extend("boolean", (l, c, h) => {
|
|
1332
|
+
if (typeof l == "boolean") return [l];
|
|
1333
|
+
throw new n(`expected boolean but got ${l}`, h);
|
|
1334
|
+
}), s.extend("bitset", (l, { bits: c, meta: h }, d) => {
|
|
1335
|
+
let m = 0, v = [];
|
|
1336
|
+
if (typeof l == "number") {
|
|
1337
|
+
m = l;
|
|
1338
|
+
for (const x in c)
|
|
1339
|
+
l & c[x] && v.push(x);
|
|
1340
|
+
} else if (Array.isArray(l)) {
|
|
1341
|
+
v = l;
|
|
1342
|
+
for (const x of v) {
|
|
1343
|
+
if (typeof x != "string") throw new n(`expected string but got ${x}`, d);
|
|
1344
|
+
x in c && (m |= c[x]);
|
|
1345
|
+
}
|
|
1346
|
+
} else
|
|
1347
|
+
throw new n(`expected number or array but got ${l}`, d);
|
|
1348
|
+
return m === h.default ? [m] : [m, v];
|
|
1349
|
+
}), s.extend("function", (l, c, h) => {
|
|
1350
|
+
if (typeof l == "function") return [l];
|
|
1351
|
+
throw new n(`expected function but got ${l}`, h);
|
|
1352
|
+
}), s.extend("is", (l, { constructor: c }, h) => {
|
|
1353
|
+
if (typeof c == "function") {
|
|
1354
|
+
if (l instanceof c) return [l];
|
|
1355
|
+
throw new n(`expected ${c.name} but got ${l}`, h);
|
|
1356
|
+
} else {
|
|
1357
|
+
if (I(l))
|
|
1358
|
+
throw new n(`expected ${c} but got ${l}`, h);
|
|
1359
|
+
let d = Object.getPrototypeOf(l);
|
|
1360
|
+
for (; d; ) {
|
|
1361
|
+
if (d.constructor?.name === c) return [l];
|
|
1362
|
+
d = Object.getPrototypeOf(d);
|
|
1363
|
+
}
|
|
1364
|
+
throw new n(`expected ${c} but got ${l}`, h);
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
function g(l, c, h, d) {
|
|
1368
|
+
try {
|
|
1369
|
+
const [m, v] = s.resolve(l[c], h, {
|
|
1370
|
+
...d,
|
|
1371
|
+
path: [...d.path || [], c]
|
|
1372
|
+
});
|
|
1373
|
+
return v !== void 0 && (l[c] = v), m;
|
|
1374
|
+
} catch (m) {
|
|
1375
|
+
if (!d?.autofix) throw m;
|
|
1376
|
+
return delete l[c], h.meta.default;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
E(g, "property"), s.extend("array", (l, { inner: c, meta: h }, d) => {
|
|
1380
|
+
if (!Array.isArray(l)) throw new n(`expected array but got ${l}`, d);
|
|
1381
|
+
return p(l.length, h, "array length", d, !I(c.meta.default)), [l.map((m, v) => g(l, v, c, d))];
|
|
1382
|
+
}), s.extend("dict", (l, { inner: c, sKey: h }, d, m) => {
|
|
1383
|
+
if (!le(l)) throw new n(`expected object but got ${l}`, d);
|
|
1384
|
+
const v = {};
|
|
1385
|
+
for (const x in l) {
|
|
1386
|
+
let A;
|
|
1387
|
+
try {
|
|
1388
|
+
A = s.resolve(x, h, d)[0];
|
|
1389
|
+
} catch (ke) {
|
|
1390
|
+
if (m) continue;
|
|
1391
|
+
throw ke;
|
|
1392
|
+
}
|
|
1393
|
+
v[A] = g(l, x, c, d), l[A] = l[x], x !== A && delete l[x];
|
|
1394
|
+
}
|
|
1395
|
+
return [v];
|
|
1396
|
+
}), s.extend("tuple", (l, { list: c }, h, d) => {
|
|
1397
|
+
if (!Array.isArray(l)) throw new n(`expected array but got ${l}`, h);
|
|
1398
|
+
const m = c.map((v, x) => g(l, x, v, h));
|
|
1399
|
+
return d ? [m] : (m.push(...l.slice(c.length)), [m]);
|
|
1400
|
+
});
|
|
1401
|
+
function w(l, c) {
|
|
1402
|
+
for (const h in c)
|
|
1403
|
+
h in l || (l[h] = c[h]);
|
|
1404
|
+
}
|
|
1405
|
+
E(w, "merge"), s.extend("object", (l, { dict: c }, h, d) => {
|
|
1406
|
+
if (!le(l)) throw new n(`expected object but got ${l}`, h);
|
|
1407
|
+
const m = {};
|
|
1408
|
+
for (const v in c) {
|
|
1409
|
+
const x = g(l, v, c[v], h);
|
|
1410
|
+
(!I(x) || v in l) && (m[v] = x);
|
|
1411
|
+
}
|
|
1412
|
+
return d || w(m, l), [m];
|
|
1413
|
+
}), s.extend("union", (l, { list: c, toString: h }, d, m) => {
|
|
1414
|
+
for (const v of c)
|
|
1415
|
+
try {
|
|
1416
|
+
return s.resolve(l, v, d, m);
|
|
1417
|
+
} catch {
|
|
1418
|
+
}
|
|
1419
|
+
throw new n(`expected ${h()} but got ${JSON.stringify(l)}`, d);
|
|
1420
|
+
}), s.extend("intersect", (l, { list: c, toString: h }, d, m) => {
|
|
1421
|
+
if (!c.length) return [l];
|
|
1422
|
+
let v;
|
|
1423
|
+
for (const x of c) {
|
|
1424
|
+
const A = s.resolve(l, x, d, !0)[0];
|
|
1425
|
+
if (!I(A))
|
|
1426
|
+
if (I(v))
|
|
1427
|
+
v = A;
|
|
1428
|
+
else {
|
|
1429
|
+
if (typeof v != typeof A)
|
|
1430
|
+
throw new n(`expected ${h()} but got ${JSON.stringify(l)}`, d);
|
|
1431
|
+
if (typeof A == "object")
|
|
1432
|
+
w(v ??= {}, A);
|
|
1433
|
+
else if (v !== A)
|
|
1434
|
+
throw new n(`expected ${h()} but got ${JSON.stringify(l)}`, d);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return !m && le(l) && w(v, l), [v];
|
|
1438
|
+
}), s.extend("transform", (l, { inner: c, callback: h, preserve: d }, m) => {
|
|
1439
|
+
const [v, x = l] = s.resolve(l, c, m, !0);
|
|
1440
|
+
return d ? [h(v)] : [h(v), h(x)];
|
|
1441
|
+
});
|
|
1442
|
+
var O = {};
|
|
1443
|
+
function C(l, c, h) {
|
|
1444
|
+
O[l] = h, Object.assign(s, {
|
|
1445
|
+
[l](...d) {
|
|
1446
|
+
const m = new s({ type: l });
|
|
1447
|
+
return c.forEach((v, x) => {
|
|
1448
|
+
switch (v) {
|
|
1449
|
+
case "sKey":
|
|
1450
|
+
m.sKey = d[x] ?? s.string();
|
|
1451
|
+
break;
|
|
1452
|
+
case "inner":
|
|
1453
|
+
m.inner = s.from(d[x]);
|
|
1454
|
+
break;
|
|
1455
|
+
case "list":
|
|
1456
|
+
m.list = d[x].map(s.from);
|
|
1457
|
+
break;
|
|
1458
|
+
case "dict":
|
|
1459
|
+
m.dict = q(d[x], s.from);
|
|
1460
|
+
break;
|
|
1461
|
+
case "bits": {
|
|
1462
|
+
m.bits = {};
|
|
1463
|
+
for (const A in d[x])
|
|
1464
|
+
typeof d[x][A] == "number" && (m.bits[A] = d[x][A]);
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
case "callback": {
|
|
1468
|
+
const A = m.callback = d[x];
|
|
1469
|
+
A.toJSON ||= () => A.toString();
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
case "constructor": {
|
|
1473
|
+
const A = m.constructor = d[x];
|
|
1474
|
+
typeof A == "function" && (A.toJSON ||= () => A.name);
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
default:
|
|
1478
|
+
m[v] = d[x];
|
|
1479
|
+
}
|
|
1480
|
+
}), l === "object" || l === "dict" ? m.meta.default = {} : l === "array" || l === "tuple" ? m.meta.default = [] : l === "bitset" && (m.meta.default = 0), m;
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
E(C, "defineMethod"), C("is", ["constructor"], ({ constructor: l }) => typeof l == "function" ? l.name : l), C("any", [], () => "any"), C("never", [], () => "never"), C("const", ["value"], ({ value: l }) => typeof l == "string" ? JSON.stringify(l) : l), C("string", [], () => "string"), C("number", [], () => "number"), C("boolean", [], () => "boolean"), C("bitset", ["bits"], () => "bitset"), C("function", [], () => "function"), C("array", ["inner"], ({ inner: l }) => `${l.toString(!0)}[]`), C("dict", ["inner", "sKey"], ({ inner: l, sKey: c }) => `{ [key: ${c.toString()}]: ${l.toString()} }`), C("tuple", ["list"], ({ list: l }) => `[${l.map((c) => c.toString()).join(", ")}]`), C("object", ["dict"], ({ dict: l }) => Object.keys(l).length === 0 ? "{}" : `{ ${Object.entries(l).map(([c, h]) => `${c}${h.meta.required ? "" : "?"}: ${h.toString()}`).join(", ")} }`), C("union", ["list"], ({ list: l }, c) => {
|
|
1485
|
+
const h = l.map(({ toString: d }) => d()).join(" | ");
|
|
1486
|
+
return c ? `(${h})` : h;
|
|
1487
|
+
}), C("intersect", ["list"], ({ list: l }) => `${l.map((c) => c.toString(!0)).join(" & ")}`), C("transform", ["inner", "callback", "preserve"], ({ inner: l }, c) => l.toString(c)), e.exports = s;
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
const $ = ir();
|
|
1491
|
+
var Ot = /* @__PURE__ */ ((i) => (i[i.debug = -1] = "debug", i[i.log = 0] = "log", i[i.info = 1] = "info", i[i.warn = 2] = "warn", i[i.error = 3] = "error", i[i.silent = 4] = "silent", i))(Ot || {});
|
|
1492
|
+
const Ie = globalThis || window, Le = /* @__PURE__ */ Symbol.for("__IPE_LOGGER_COLOR_MAP__");
|
|
1493
|
+
Ie[Le] || (Ie[Le] = /* @__PURE__ */ new Map());
|
|
1494
|
+
const Se = Ie[Le];
|
|
1495
|
+
function oe(i) {
|
|
1496
|
+
let e = 2166136261;
|
|
1497
|
+
for (let t = 0; t < i.length; t++)
|
|
1498
|
+
e ^= i.charCodeAt(t), e = (e >>> 0) * 16777619;
|
|
1499
|
+
return e >>> 0;
|
|
1500
|
+
}
|
|
1501
|
+
const lt = [
|
|
1502
|
+
[350, 360],
|
|
1503
|
+
[0, 15],
|
|
1504
|
+
[15, 30],
|
|
1505
|
+
[200, 230],
|
|
1506
|
+
[230, 250],
|
|
1507
|
+
[250, 280],
|
|
1508
|
+
[280, 310],
|
|
1509
|
+
[310, 330],
|
|
1510
|
+
[140, 160],
|
|
1511
|
+
[160, 180]
|
|
1512
|
+
];
|
|
1513
|
+
function rr(i, e) {
|
|
1514
|
+
const t = lt.length, r = oe(i) % t, [n, s] = lt[r], o = s - n, a = oe(i + ":" + e), f = n + a % (o || 1), u = oe(i + ":s"), p = oe(i + ":l");
|
|
1515
|
+
let y, _;
|
|
1516
|
+
if (e === "name")
|
|
1517
|
+
y = 62 + u % 18, _ = 30 + p % 12;
|
|
1518
|
+
else {
|
|
1519
|
+
const g = f >= 0 && f < 50 || f > 330 && f < 360, w = f >= 200 && f <= 300;
|
|
1520
|
+
y = 55 + u % 20, w ? _ = 55 + p % 8 : g ? _ = 48 + p % 6 : _ = 50 + p % 8, y < 60 && (y += 5);
|
|
1521
|
+
}
|
|
1522
|
+
return `hsl(${f}, ${y}%, ${_}%)`;
|
|
1523
|
+
}
|
|
1524
|
+
function ae(i, e) {
|
|
1525
|
+
if (e)
|
|
1526
|
+
return Se.set(i, e), e;
|
|
1527
|
+
const t = Se.get(i);
|
|
1528
|
+
if (t) return t;
|
|
1529
|
+
const r = i.startsWith("name:") ? "name" : "group", n = rr(i, r);
|
|
1530
|
+
return Se.set(i, n), n;
|
|
1531
|
+
}
|
|
1532
|
+
class ze {
|
|
1533
|
+
/**
|
|
1534
|
+
* Note: constructor returns a callable Proxy so that you can do `logger('group')`.
|
|
1535
|
+
*/
|
|
1536
|
+
constructor(e = {}) {
|
|
1537
|
+
this._custom = (t) => {
|
|
1538
|
+
if (!this._enabled(t.level)) return ht;
|
|
1539
|
+
const [r, n] = this._prefix(t.label);
|
|
1540
|
+
return this._consoleMethod(t.method).bind(console, r, ...n);
|
|
1541
|
+
}, this._name = e.name, this._nameColor = e.color, this._groupPath = e._groupPath ? [...e._groupPath] : [], this._dynamicLevels = { ...e._dynamicLevels }, this._levelRef = e._levelRef ?? {
|
|
1542
|
+
value: e.level ?? 1
|
|
1543
|
+
/* info */
|
|
1544
|
+
}, this._name && ae(`name:${this._name}`, this._nameColor), this._installBuiltinLevels();
|
|
1545
|
+
for (const t of Object.keys(this._dynamicLevels))
|
|
1546
|
+
this._installLevelGetter(t, this._dynamicLevels[t]);
|
|
1547
|
+
return sr(this);
|
|
1548
|
+
}
|
|
1549
|
+
// ---------- public API ----------
|
|
1550
|
+
get level() {
|
|
1551
|
+
return this._levelRef.value;
|
|
1552
|
+
}
|
|
1553
|
+
set level(e) {
|
|
1554
|
+
this._levelRef.value = e;
|
|
1555
|
+
}
|
|
1556
|
+
/** Create a sub-logger with a group label */
|
|
1557
|
+
group(e, t) {
|
|
1558
|
+
return e && ae(`group:${e}`, t?.color), new ze({
|
|
1559
|
+
name: this._name,
|
|
1560
|
+
color: this._nameColor,
|
|
1561
|
+
_groupPath: [...this._groupPath, e],
|
|
1562
|
+
_dynamicLevels: this._dynamicLevels,
|
|
1563
|
+
_levelRef: this._levelRef
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
/** Define a custom level, e.g. logger.defineLevel('success', { level: info, label: '✅', method: 'info' }) */
|
|
1567
|
+
defineLevel(e, t) {
|
|
1568
|
+
this._dynamicLevels[e] = { ...t }, this._installLevelGetter(e, t);
|
|
1569
|
+
}
|
|
1570
|
+
// Built-in level getters
|
|
1571
|
+
get debug() {
|
|
1572
|
+
return this._method("debug");
|
|
1573
|
+
}
|
|
1574
|
+
get log() {
|
|
1575
|
+
return this._method("log");
|
|
1576
|
+
}
|
|
1577
|
+
get info() {
|
|
1578
|
+
return this._method("info");
|
|
1579
|
+
}
|
|
1580
|
+
get warn() {
|
|
1581
|
+
return this._method("warn");
|
|
1582
|
+
}
|
|
1583
|
+
get error() {
|
|
1584
|
+
return this._method("error");
|
|
1585
|
+
}
|
|
1586
|
+
// ---------- internals ----------
|
|
1587
|
+
_installBuiltinLevels() {
|
|
1588
|
+
}
|
|
1589
|
+
_installLevelGetter(e, t) {
|
|
1590
|
+
Object.defineProperty(this, e, {
|
|
1591
|
+
configurable: !0,
|
|
1592
|
+
enumerable: !1,
|
|
1593
|
+
get: () => this._custom(t)
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
_method(e) {
|
|
1597
|
+
const t = nr[e];
|
|
1598
|
+
if (!this._enabled(t.level)) return ht;
|
|
1599
|
+
const [r, n] = this._prefix(t.label);
|
|
1600
|
+
return this._consoleMethod(e).bind(console, r, ...n);
|
|
1601
|
+
}
|
|
1602
|
+
_consoleMethod(e) {
|
|
1603
|
+
return (console[e] || console.log).bind(console);
|
|
1604
|
+
}
|
|
1605
|
+
_enabled(e) {
|
|
1606
|
+
return e >= this._levelRef.value && this._levelRef.value !== 4;
|
|
1607
|
+
}
|
|
1608
|
+
_prefix(e) {
|
|
1609
|
+
const t = [];
|
|
1610
|
+
let r = "";
|
|
1611
|
+
if (this._name) {
|
|
1612
|
+
const n = ae(`name:${this._name}`, this._nameColor);
|
|
1613
|
+
r += `%c${this._name}%c`, t.push(
|
|
1614
|
+
`background:${n}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,
|
|
1615
|
+
ut
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
if (e && (r += ` ${e}`), this._groupPath.length) {
|
|
1619
|
+
const n = this._groupPath.join("/"), s = ae(`group:${n}`);
|
|
1620
|
+
r += ` %c${n}%c`, t.push(`color:${s}; text-decoration: underline;`, ut);
|
|
1621
|
+
}
|
|
1622
|
+
return [r, t];
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
const ht = () => {
|
|
1626
|
+
}, ut = "color:inherit; background:transparent; text-decoration:none;", nr = {
|
|
1627
|
+
debug: { level: -1, label: "", method: "debug" },
|
|
1628
|
+
log: { level: 0, label: "", method: "log" },
|
|
1629
|
+
info: { level: 1, label: "[I]", method: "info" },
|
|
1630
|
+
warn: { level: 2, label: "[W]", method: "warn" },
|
|
1631
|
+
error: { level: 3, label: "[E]", method: "error" }
|
|
1632
|
+
};
|
|
1633
|
+
function sr(i) {
|
|
1634
|
+
const e = function(t, r) {
|
|
1635
|
+
return i.group(t, r);
|
|
1636
|
+
};
|
|
1637
|
+
return new Proxy(e, {
|
|
1638
|
+
get(t, r, n) {
|
|
1639
|
+
return i[r];
|
|
1640
|
+
},
|
|
1641
|
+
set(t, r, n) {
|
|
1642
|
+
return i[r] = n, !0;
|
|
1643
|
+
},
|
|
1644
|
+
apply(t, r, n) {
|
|
1645
|
+
return i.group(n[0], n[1]);
|
|
1646
|
+
},
|
|
1647
|
+
has(t, r) {
|
|
1648
|
+
return r in i;
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
function or(i) {
|
|
1653
|
+
return new ze(i);
|
|
1654
|
+
}
|
|
1655
|
+
class Re extends wi {
|
|
1656
|
+
async clientLogin(e, t, r) {
|
|
1657
|
+
r ||= {}, !r.logincontinue && !r.loginreturnurl && (r.loginreturnurl = location?.origin);
|
|
1658
|
+
const n = await this.postWithToken(
|
|
1659
|
+
"login",
|
|
1660
|
+
{
|
|
1661
|
+
action: "clientlogin",
|
|
1662
|
+
username: e,
|
|
1663
|
+
password: t,
|
|
1664
|
+
...r
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
tokenName: "logintoken"
|
|
1668
|
+
}
|
|
1669
|
+
);
|
|
1670
|
+
if (n?.data?.clientlogin?.status === "PASS")
|
|
1671
|
+
return n.data.clientlogin;
|
|
1672
|
+
throw new bi(
|
|
1673
|
+
vi.LOGIN_FAILED,
|
|
1674
|
+
n.data.clientlogin.message,
|
|
1675
|
+
n
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
class ar extends Re {
|
|
1680
|
+
constructor(e, t, r) {
|
|
1681
|
+
const n = _i(
|
|
1682
|
+
e,
|
|
1683
|
+
{
|
|
1684
|
+
credentials: "include",
|
|
1685
|
+
mode: "cors",
|
|
1686
|
+
...t
|
|
1687
|
+
},
|
|
1688
|
+
{
|
|
1689
|
+
origin: location.origin,
|
|
1690
|
+
...r
|
|
1691
|
+
}
|
|
1692
|
+
);
|
|
1693
|
+
super(n);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
class cr {
|
|
1697
|
+
constructor(e, t = {}) {
|
|
1698
|
+
this.ctx = e, this.options = t, this._apiClients = /* @__PURE__ */ new Map(), location?.href && t?.baseURL?.toString()?.startsWith("/") && (t.baseURL = new URL(t.baseURL, location.origin));
|
|
1699
|
+
const r = this.api = new Re({
|
|
1700
|
+
baseURL: t.baseURL.toString(),
|
|
1701
|
+
fexiosConfigs: {
|
|
1702
|
+
headers: {
|
|
1703
|
+
"x-api-user-agent": `InPageEdit-NEXT ${e.version}`,
|
|
1704
|
+
...t.headers
|
|
1705
|
+
},
|
|
1706
|
+
...t
|
|
1707
|
+
},
|
|
1708
|
+
throwOnApiError: !0
|
|
1709
|
+
});
|
|
1710
|
+
e.set("api", r), e.set("apiService", this);
|
|
1711
|
+
}
|
|
1712
|
+
getClientByFileRepo(e) {
|
|
1713
|
+
const t = new URL(`${e.scriptDirUrl}/api.php`, location.origin), r = t.toString();
|
|
1714
|
+
if (r === this.ctx.root.config.apiConfigs.baseURL?.toString())
|
|
1715
|
+
return this.ctx.api;
|
|
1716
|
+
if (!this._apiClients.has(r)) {
|
|
1717
|
+
const n = t.origin === location.origin, s = {
|
|
1718
|
+
baseURL: t.toString(),
|
|
1719
|
+
throwOnApiError: !0
|
|
1720
|
+
}, o = n ? new Re(s) : new ar(s);
|
|
1721
|
+
o.request.on("beforeRequest", (a) => {
|
|
1722
|
+
a.headers = o.request.mergeHeaders(a.headers, {
|
|
1723
|
+
"x-api-user-agent": null,
|
|
1724
|
+
"x-mw-token-name": null
|
|
1725
|
+
});
|
|
1726
|
+
}), this._apiClients.set(r, o);
|
|
1727
|
+
}
|
|
1728
|
+
return this._apiClients.get(r);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
const ft = (i, e = document) => e.querySelector(i), ps = (i, e = document) => e.querySelectorAll(i);
|
|
1732
|
+
var lr = Object.create, Ke = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Pt = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), It = (i) => {
|
|
1733
|
+
throw TypeError(i);
|
|
1734
|
+
}, ur = (i, e, t) => e in i ? Ke(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, fr = (i, e) => Ke(i, "name", { value: e, configurable: !0 }), dr = (i) => [, , , lr(i?.[Pt("metadata")] ?? null)], pr = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Lt = (i) => i !== void 0 && typeof i != "function" ? It("Function expected") : i, gr = (i, e, t, r, n) => ({ kind: pr[i], name: e, metadata: r, addInitializer: (s) => t._ ? It("Already initialized") : n.push(Lt(s || null)) }), mr = (i, e) => ur(e, Pt("metadata"), i[3]), yr = (i, e, t, r) => {
|
|
1735
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
1736
|
+
return r;
|
|
1737
|
+
}, wr = (i, e, t, r, n, s) => {
|
|
1738
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && hr(n, t));
|
|
1739
|
+
fr(n, t);
|
|
1740
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
1741
|
+
f = gr(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, Lt(o) && (n = o);
|
|
1742
|
+
return mr(i, n), g && Ke(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
1743
|
+
}, Rt, qe, jt;
|
|
1744
|
+
Rt = [F(["wiki", "wikiTitle"])];
|
|
1745
|
+
class fe extends (jt = z) {
|
|
1746
|
+
constructor(e) {
|
|
1747
|
+
super(e, "currentPage", !1), this.ctx = e, this.url = new URL(window.location.href), this.isMainPage = void 0, this.wikiTitle = void 0;
|
|
1748
|
+
}
|
|
1749
|
+
get logger() {
|
|
1750
|
+
return this.ctx.logger("CURRENT_PAGE");
|
|
1751
|
+
}
|
|
1752
|
+
async start() {
|
|
1753
|
+
await this.#e(), this.#i(), window.addEventListener("popstate", this.#t.bind(this)), this.logger.info("initialized", this.wikiTitle);
|
|
1754
|
+
}
|
|
1755
|
+
stop() {
|
|
1756
|
+
window.removeEventListener("popstate", this.#t.bind(this));
|
|
1757
|
+
}
|
|
1758
|
+
async #e() {
|
|
1759
|
+
await this.#n(), await this.#r();
|
|
1760
|
+
}
|
|
1761
|
+
#i() {
|
|
1762
|
+
const e = /* @__PURE__ */ Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");
|
|
1763
|
+
if (window[e])
|
|
1764
|
+
return;
|
|
1765
|
+
const t = history.pushState, r = history.replaceState;
|
|
1766
|
+
history.pushState = function(n, s, o) {
|
|
1767
|
+
t.apply(this, [n, s, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: n }));
|
|
1768
|
+
}, history.replaceState = function(n, s, o) {
|
|
1769
|
+
r.apply(this, [n, s, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: n }));
|
|
1770
|
+
}, window[e] = !0;
|
|
1771
|
+
}
|
|
1772
|
+
async #t(e) {
|
|
1773
|
+
const t = this.url, r = new URL(window.location.href);
|
|
1774
|
+
this.url = r, (t.pathname !== r.pathname || t.searchParams.get("title") !== r.searchParams.get("title") || t.searchParams.get("curid") !== r.searchParams.get("curid")) && (await this.#e(), this.logger.info("location changed", r, this.wikiTitle));
|
|
1775
|
+
}
|
|
1776
|
+
get params() {
|
|
1777
|
+
return this.url.searchParams;
|
|
1778
|
+
}
|
|
1779
|
+
get canonicalUrl() {
|
|
1780
|
+
const e = (ft('link[rel="alternate"][hreflang="x-default"]') || ft('link[rel="canonical"]'))?.href;
|
|
1781
|
+
let t = null;
|
|
1782
|
+
return e && (t = new URL(e, location.origin)), Reflect.defineProperty(this, "canonicalUrl", {
|
|
1783
|
+
get: () => t
|
|
1784
|
+
}), t;
|
|
1785
|
+
}
|
|
1786
|
+
async #r() {
|
|
1787
|
+
const t = this.wikiTitle?.getMainDBKey() === this.ctx.wiki.mainPageName;
|
|
1788
|
+
return Reflect.defineProperty(this, "isMainPage", {
|
|
1789
|
+
get: () => t
|
|
1790
|
+
}), t;
|
|
1791
|
+
}
|
|
1792
|
+
async #n() {
|
|
1793
|
+
let e = null;
|
|
1794
|
+
return this.canonicalUrl ? e = await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl) : e = await this.ctx.wikiTitle.newTitleFromUrl(this.url), Object.freeze(e), Reflect.defineProperty(this, "wikiTitle", {
|
|
1795
|
+
get: () => e
|
|
1796
|
+
}), e;
|
|
1797
|
+
}
|
|
1798
|
+
get wikiAction() {
|
|
1799
|
+
return this.params.get("action") || "view";
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
qe = dr(jt);
|
|
1803
|
+
fe = wr(qe, 0, "CurrentPageService", Rt, fe);
|
|
1804
|
+
yr(qe, 1, fe);
|
|
1805
|
+
class br extends z {
|
|
1806
|
+
constructor(e) {
|
|
1807
|
+
super(e, "resourceLoader", !0), this.ctx = e;
|
|
1808
|
+
}
|
|
1809
|
+
stop() {
|
|
1810
|
+
this.removeAll();
|
|
1811
|
+
}
|
|
1812
|
+
loadScript(e, t) {
|
|
1813
|
+
if (!e)
|
|
1814
|
+
return Promise.resolve(null);
|
|
1815
|
+
const r = `script:${e}`, n = document.querySelector(`[data-ipe="${r}"]`);
|
|
1816
|
+
return n ? Promise.resolve(n) : new Promise((o, a) => {
|
|
1817
|
+
const f = document.createElement("script");
|
|
1818
|
+
f.src = e, f.dataset.ipe = r, t && Object.entries(t).forEach(([u, p]) => {
|
|
1819
|
+
typeof p > "u" || p === !1 || p === null ? f.removeAttribute(u) : f.setAttribute(u, p);
|
|
1820
|
+
}), document.body.appendChild(f), f.onload = () => o(f), f.onerror = (u) => a(u);
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
loadStyle(e, t) {
|
|
1824
|
+
if (!e)
|
|
1825
|
+
return Promise.resolve(null);
|
|
1826
|
+
const r = `style:${e}`, n = document.querySelector(`[data-ipe="${r}"]`);
|
|
1827
|
+
return n ? Promise.resolve(n) : new Promise((o, a) => {
|
|
1828
|
+
const f = document.createElement("link");
|
|
1829
|
+
f.rel = "stylesheet", f.href = e, f.dataset.ipe = r, t && Object.entries(t).forEach(([p, y]) => {
|
|
1830
|
+
typeof y > "u" || y === !1 || y === null ? f.removeAttribute(p) : f.setAttribute(p, y);
|
|
1831
|
+
}), (document.querySelector('meta[name="ipe-styles"]') || (() => {
|
|
1832
|
+
const p = document.createElement("meta");
|
|
1833
|
+
return p.id = "ipe-styles", p.name = "ipe-styles", document.head.insertAdjacentElement("afterbegin", p), p;
|
|
1834
|
+
})()).before(f), f.onload = () => o(f), f.onerror = (p) => a(p);
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
removeStyle(e) {
|
|
1838
|
+
const t = `style:${e}`, r = document.querySelector(`[data-ipe="${t}"]`);
|
|
1839
|
+
r && r.remove();
|
|
1840
|
+
}
|
|
1841
|
+
removeScript(e) {
|
|
1842
|
+
const t = `script:${e}`, r = document.querySelector(`[data-ipe="${t}"]`);
|
|
1843
|
+
r && r.remove();
|
|
1844
|
+
}
|
|
1845
|
+
removeAll() {
|
|
1846
|
+
document.querySelectorAll("[data-ipe]").forEach((e) => {
|
|
1847
|
+
e.remove();
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
resolveImportPath(e) {
|
|
1851
|
+
return e.startsWith("http") || e.startsWith("//") ? e : import.meta.resolve(e);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
const _e = Object.keys;
|
|
1855
|
+
function vr(i) {
|
|
1856
|
+
return typeof i == "boolean";
|
|
1857
|
+
}
|
|
1858
|
+
function _r(i) {
|
|
1859
|
+
return i && typeof i.nodeType == "number";
|
|
1860
|
+
}
|
|
1861
|
+
function He(i) {
|
|
1862
|
+
return typeof i == "string";
|
|
1863
|
+
}
|
|
1864
|
+
function Dt(i) {
|
|
1865
|
+
return typeof i == "number";
|
|
1866
|
+
}
|
|
1867
|
+
function Y(i) {
|
|
1868
|
+
return typeof i == "object" ? i !== null : re(i);
|
|
1869
|
+
}
|
|
1870
|
+
function re(i) {
|
|
1871
|
+
return typeof i == "function";
|
|
1872
|
+
}
|
|
1873
|
+
function xr(i) {
|
|
1874
|
+
return !!(i && i.isComponent);
|
|
1875
|
+
}
|
|
1876
|
+
function kr(i) {
|
|
1877
|
+
return Y(i) && typeof i.length == "number" && typeof i.nodeType != "number";
|
|
1878
|
+
}
|
|
1879
|
+
function je(i, e) {
|
|
1880
|
+
if (i)
|
|
1881
|
+
for (const t of _e(i))
|
|
1882
|
+
e(i[t], t);
|
|
1883
|
+
}
|
|
1884
|
+
function Sr(i) {
|
|
1885
|
+
return Y(i) && "current" in i;
|
|
1886
|
+
}
|
|
1887
|
+
const De = {
|
|
1888
|
+
animationIterationCount: 0,
|
|
1889
|
+
borderImageOutset: 0,
|
|
1890
|
+
borderImageSlice: 0,
|
|
1891
|
+
borderImageWidth: 0,
|
|
1892
|
+
boxFlex: 0,
|
|
1893
|
+
boxFlexGroup: 0,
|
|
1894
|
+
boxOrdinalGroup: 0,
|
|
1895
|
+
columnCount: 0,
|
|
1896
|
+
columns: 0,
|
|
1897
|
+
flex: 0,
|
|
1898
|
+
flexGrow: 0,
|
|
1899
|
+
flexPositive: 0,
|
|
1900
|
+
flexShrink: 0,
|
|
1901
|
+
flexNegative: 0,
|
|
1902
|
+
flexOrder: 0,
|
|
1903
|
+
gridArea: 0,
|
|
1904
|
+
gridRow: 0,
|
|
1905
|
+
gridRowEnd: 0,
|
|
1906
|
+
gridRowSpan: 0,
|
|
1907
|
+
gridRowStart: 0,
|
|
1908
|
+
gridColumn: 0,
|
|
1909
|
+
gridColumnEnd: 0,
|
|
1910
|
+
gridColumnSpan: 0,
|
|
1911
|
+
gridColumnStart: 0,
|
|
1912
|
+
fontWeight: 0,
|
|
1913
|
+
lineClamp: 0,
|
|
1914
|
+
lineHeight: 0,
|
|
1915
|
+
opacity: 0,
|
|
1916
|
+
order: 0,
|
|
1917
|
+
orphans: 0,
|
|
1918
|
+
tabSize: 0,
|
|
1919
|
+
widows: 0,
|
|
1920
|
+
zIndex: 0,
|
|
1921
|
+
zoom: 0,
|
|
1922
|
+
// SVG-related properties
|
|
1923
|
+
fillOpacity: 0,
|
|
1924
|
+
floodOpacity: 0,
|
|
1925
|
+
stopOpacity: 0,
|
|
1926
|
+
strokeDasharray: 0,
|
|
1927
|
+
strokeDashoffset: 0,
|
|
1928
|
+
strokeMiterlimit: 0,
|
|
1929
|
+
strokeOpacity: 0,
|
|
1930
|
+
strokeWidth: 0
|
|
1931
|
+
};
|
|
1932
|
+
function $r(i, e) {
|
|
1933
|
+
return i + e.charAt(0).toUpperCase() + e.substring(1);
|
|
1934
|
+
}
|
|
1935
|
+
const Er = ["Webkit", "ms", "Moz", "O"];
|
|
1936
|
+
_e(De).forEach((i) => {
|
|
1937
|
+
Er.forEach((e) => {
|
|
1938
|
+
De[$r(e, i)] = 0;
|
|
1939
|
+
});
|
|
1940
|
+
});
|
|
1941
|
+
const Cr = /* @__PURE__ */ Symbol.for("jsx-dom:type");
|
|
1942
|
+
var Tt = /* @__PURE__ */ (function(i) {
|
|
1943
|
+
return i.ShadowRoot = "ShadowRoot", i;
|
|
1944
|
+
})(Tt || {});
|
|
1945
|
+
function Ar(i) {
|
|
1946
|
+
return i != null && i[Cr] === Tt.ShadowRoot;
|
|
1947
|
+
}
|
|
1948
|
+
const Or = "http://www.w3.org/2000/svg", Pr = "http://www.w3.org/1999/xlink", Ir = "http://www.w3.org/XML/1998/namespace";
|
|
1949
|
+
function Mt(i) {
|
|
1950
|
+
return !vr(i) && i != null;
|
|
1951
|
+
}
|
|
1952
|
+
function Te(i) {
|
|
1953
|
+
return Array.isArray(i) ? i.map(Te).filter(Boolean).join(" ") : Y(i) ? Symbol.iterator in i ? Te(Array.from(i)) : _e(i).filter((e) => i[e]).join(" ") : Mt(i) ? "" + i : "";
|
|
1954
|
+
}
|
|
1955
|
+
const Lr = {
|
|
1956
|
+
animate: 0,
|
|
1957
|
+
circle: 0,
|
|
1958
|
+
clipPath: 0,
|
|
1959
|
+
defs: 0,
|
|
1960
|
+
desc: 0,
|
|
1961
|
+
ellipse: 0,
|
|
1962
|
+
feBlend: 0,
|
|
1963
|
+
feColorMatrix: 0,
|
|
1964
|
+
feComponentTransfer: 0,
|
|
1965
|
+
feComposite: 0,
|
|
1966
|
+
feConvolveMatrix: 0,
|
|
1967
|
+
feDiffuseLighting: 0,
|
|
1968
|
+
feDisplacementMap: 0,
|
|
1969
|
+
feDistantLight: 0,
|
|
1970
|
+
feFlood: 0,
|
|
1971
|
+
feFuncA: 0,
|
|
1972
|
+
feFuncB: 0,
|
|
1973
|
+
feFuncG: 0,
|
|
1974
|
+
feFuncR: 0,
|
|
1975
|
+
feGaussianBlur: 0,
|
|
1976
|
+
feImage: 0,
|
|
1977
|
+
feMerge: 0,
|
|
1978
|
+
feMergeNode: 0,
|
|
1979
|
+
feMorphology: 0,
|
|
1980
|
+
feOffset: 0,
|
|
1981
|
+
fePointLight: 0,
|
|
1982
|
+
feSpecularLighting: 0,
|
|
1983
|
+
feSpotLight: 0,
|
|
1984
|
+
feTile: 0,
|
|
1985
|
+
feTurbulence: 0,
|
|
1986
|
+
filter: 0,
|
|
1987
|
+
foreignObject: 0,
|
|
1988
|
+
g: 0,
|
|
1989
|
+
image: 0,
|
|
1990
|
+
line: 0,
|
|
1991
|
+
linearGradient: 0,
|
|
1992
|
+
marker: 0,
|
|
1993
|
+
mask: 0,
|
|
1994
|
+
metadata: 0,
|
|
1995
|
+
path: 0,
|
|
1996
|
+
pattern: 0,
|
|
1997
|
+
polygon: 0,
|
|
1998
|
+
polyline: 0,
|
|
1999
|
+
radialGradient: 0,
|
|
2000
|
+
rect: 0,
|
|
2001
|
+
stop: 0,
|
|
2002
|
+
svg: 0,
|
|
2003
|
+
switch: 0,
|
|
2004
|
+
symbol: 0,
|
|
2005
|
+
text: 0,
|
|
2006
|
+
textPath: 0,
|
|
2007
|
+
tspan: 0,
|
|
2008
|
+
use: 0,
|
|
2009
|
+
view: 0
|
|
2010
|
+
}, Rr = /^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;
|
|
2011
|
+
function jr(i) {
|
|
2012
|
+
const e = document.createDocumentFragment();
|
|
2013
|
+
return xe(i.children, e), e;
|
|
2014
|
+
}
|
|
2015
|
+
function Dr(i, e, t) {
|
|
2016
|
+
e = {
|
|
2017
|
+
...e,
|
|
2018
|
+
children: t
|
|
2019
|
+
};
|
|
2020
|
+
const r = new i(e), n = r.render();
|
|
2021
|
+
return "ref" in e && We(e.ref, r), n;
|
|
2022
|
+
}
|
|
2023
|
+
function P(i, e) {
|
|
2024
|
+
let { children: t, ...r } = e;
|
|
2025
|
+
!r.namespaceURI && Lr[i] === 0 && (r = {
|
|
2026
|
+
...r,
|
|
2027
|
+
namespaceURI: Or
|
|
2028
|
+
});
|
|
2029
|
+
let n;
|
|
2030
|
+
if (He(i)) {
|
|
2031
|
+
if (n = r.namespaceURI ? document.createElementNS(r.namespaceURI, i) : document.createElement(i), Nr(r, n), xe(t, n), n instanceof window.HTMLSelectElement && r.value != null)
|
|
2032
|
+
if (r.multiple === !0 && Array.isArray(r.value)) {
|
|
2033
|
+
const s = r.value.map((o) => String(o));
|
|
2034
|
+
n.querySelectorAll("option").forEach(
|
|
2035
|
+
(o) => o.selected = s.includes(o.value)
|
|
2036
|
+
);
|
|
2037
|
+
} else
|
|
2038
|
+
n.value = r.value;
|
|
2039
|
+
We(r.ref, n);
|
|
2040
|
+
} else if (re(i))
|
|
2041
|
+
Y(i.defaultProps) && (r = {
|
|
2042
|
+
...i.defaultProps,
|
|
2043
|
+
...r
|
|
2044
|
+
}), n = xr(i) ? Dr(i, r, t) : i({
|
|
2045
|
+
...r,
|
|
2046
|
+
children: t
|
|
2047
|
+
});
|
|
2048
|
+
else
|
|
2049
|
+
throw new TypeError(`Invalid JSX element type: ${i}`);
|
|
2050
|
+
return n;
|
|
2051
|
+
}
|
|
2052
|
+
function We(i, e) {
|
|
2053
|
+
Sr(i) ? i.current = e : re(i) && i(e);
|
|
2054
|
+
}
|
|
2055
|
+
function xe(i, e) {
|
|
2056
|
+
if (kr(i))
|
|
2057
|
+
Tr(i, e);
|
|
2058
|
+
else if (He(i) || Dt(i))
|
|
2059
|
+
$e(document.createTextNode(i), e);
|
|
2060
|
+
else if (i === null)
|
|
2061
|
+
$e(document.createComment(""), e);
|
|
2062
|
+
else if (_r(i))
|
|
2063
|
+
$e(i, e);
|
|
2064
|
+
else if (Ar(i)) {
|
|
2065
|
+
const t = e.attachShadow(i.attr);
|
|
2066
|
+
xe(i.children, t), We(i.ref, t);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function Tr(i, e) {
|
|
2070
|
+
for (const t of [...i])
|
|
2071
|
+
xe(t, e);
|
|
2072
|
+
return e;
|
|
2073
|
+
}
|
|
2074
|
+
function $e(i, e) {
|
|
2075
|
+
e instanceof window.HTMLTemplateElement ? e.content.appendChild(i) : e.appendChild(i);
|
|
2076
|
+
}
|
|
2077
|
+
function ce(i, e) {
|
|
2078
|
+
return i.replace(/[A-Z]/g, (t) => e + t.toLowerCase());
|
|
2079
|
+
}
|
|
2080
|
+
function Nt(i, e) {
|
|
2081
|
+
e == null || e === !1 || (Array.isArray(e) ? e.forEach((t) => Nt(i, t)) : He(e) ? i.setAttribute("style", e) : Y(e) && je(e, (t, r) => {
|
|
2082
|
+
r.indexOf("-") === 0 ? i.style.setProperty(r, t) : Dt(t) && De[r] !== 0 ? i.style[r] = t + "px" : i.style[r] = t;
|
|
2083
|
+
}));
|
|
2084
|
+
}
|
|
2085
|
+
function Mr(i, e, t) {
|
|
2086
|
+
switch (i) {
|
|
2087
|
+
case "xlinkActuate":
|
|
2088
|
+
case "xlinkArcrole":
|
|
2089
|
+
case "xlinkHref":
|
|
2090
|
+
case "xlinkRole":
|
|
2091
|
+
case "xlinkShow":
|
|
2092
|
+
case "xlinkTitle":
|
|
2093
|
+
case "xlinkType":
|
|
2094
|
+
dt(t, Pr, ce(i, ":"), e);
|
|
2095
|
+
return;
|
|
2096
|
+
case "xmlnsXlink":
|
|
2097
|
+
X(t, ce(i, ":"), e);
|
|
2098
|
+
return;
|
|
2099
|
+
case "xmlBase":
|
|
2100
|
+
case "xmlLang":
|
|
2101
|
+
case "xmlSpace":
|
|
2102
|
+
dt(t, Ir, ce(i, ":"), e);
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
switch (i) {
|
|
2106
|
+
case "htmlFor":
|
|
2107
|
+
X(t, "for", e);
|
|
2108
|
+
return;
|
|
2109
|
+
case "dataset":
|
|
2110
|
+
je(e, (r, n) => {
|
|
2111
|
+
r != null && (t.dataset[n] = r);
|
|
2112
|
+
});
|
|
2113
|
+
return;
|
|
2114
|
+
case "innerHTML":
|
|
2115
|
+
case "innerText":
|
|
2116
|
+
case "textContent":
|
|
2117
|
+
Mt(e) && (t[i] = e);
|
|
2118
|
+
return;
|
|
2119
|
+
case "dangerouslySetInnerHTML":
|
|
2120
|
+
Y(e) && (t.innerHTML = e.__html);
|
|
2121
|
+
return;
|
|
2122
|
+
case "value":
|
|
2123
|
+
if (e == null || t instanceof window.HTMLSelectElement)
|
|
2124
|
+
return;
|
|
2125
|
+
if (t instanceof window.HTMLTextAreaElement) {
|
|
2126
|
+
t.value = e;
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
break;
|
|
2130
|
+
case "spellCheck":
|
|
2131
|
+
t.spellcheck = e;
|
|
2132
|
+
return;
|
|
2133
|
+
case "class":
|
|
2134
|
+
case "className":
|
|
2135
|
+
re(e) ? e(t) : X(t, "class", Te(e));
|
|
2136
|
+
return;
|
|
2137
|
+
case "ref":
|
|
2138
|
+
case "namespaceURI":
|
|
2139
|
+
return;
|
|
2140
|
+
case "style":
|
|
2141
|
+
Nt(t, e);
|
|
2142
|
+
return;
|
|
2143
|
+
case "on":
|
|
2144
|
+
case "onCapture":
|
|
2145
|
+
je(e, (r, n) => {
|
|
2146
|
+
t.addEventListener(n, r, i === "onCapture");
|
|
2147
|
+
});
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
if (re(e)) {
|
|
2151
|
+
if (i[0] === "o" && i[1] === "n") {
|
|
2152
|
+
let r = i.toLowerCase();
|
|
2153
|
+
const n = r.endsWith("capture");
|
|
2154
|
+
if (r === "ondoubleclick" ? r = "ondblclick" : n && r === "ondoubleclickcapture" && (r = "ondblclickcapture"), !n && t[r] === null)
|
|
2155
|
+
t[r] = e;
|
|
2156
|
+
else if (n)
|
|
2157
|
+
t.addEventListener(
|
|
2158
|
+
r.substring(2, r.length - 7),
|
|
2159
|
+
e,
|
|
2160
|
+
!0
|
|
2161
|
+
);
|
|
2162
|
+
else {
|
|
2163
|
+
let s;
|
|
2164
|
+
r in window ? s = r.substring(2) : s = r[2] + i.slice(3), t.addEventListener(s, e);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
} else Y(e) ? t[i] = e : e === !0 ? X(t, i, "") : e !== !1 && e != null && (t instanceof SVGElement && !Rr.test(i) ? X(t, ce(i, "-"), e) : X(t, i, e));
|
|
2168
|
+
}
|
|
2169
|
+
function X(i, e, t) {
|
|
2170
|
+
i.setAttribute(e, t);
|
|
2171
|
+
}
|
|
2172
|
+
function dt(i, e, t, r) {
|
|
2173
|
+
i.setAttributeNS(e, t, r);
|
|
2174
|
+
}
|
|
2175
|
+
function Nr(i, e) {
|
|
2176
|
+
for (const t of _e(i))
|
|
2177
|
+
Mr(t, i[t], e);
|
|
2178
|
+
return e;
|
|
2179
|
+
}
|
|
2180
|
+
var Ge = /* @__PURE__ */ ((i) => (i.Init = "modal.init", i.BeforeShow = "modal.beforeShow", i.Show = "modal.show", i.BeforeClose = "modal.beforeClose", i.Close = "modal.close", i.Destroy = "modal.destroy", i.ToastShow = "toast.show", i.ToastClose = "toast.close", i))(Ge || {});
|
|
2181
|
+
let Br = 0;
|
|
2182
|
+
const pt = (i) => `${i}-${++Br}`;
|
|
2183
|
+
function Z(i) {
|
|
2184
|
+
return i instanceof Node ? i : document.createTextNode(String(i));
|
|
2185
|
+
}
|
|
2186
|
+
function K(i, e) {
|
|
2187
|
+
if (!i) throw new Error(`${e ?? "Element"} not found`);
|
|
2188
|
+
return i;
|
|
2189
|
+
}
|
|
2190
|
+
function gt(i) {
|
|
2191
|
+
const e = [
|
|
2192
|
+
"a[href]",
|
|
2193
|
+
"button:not([disabled])",
|
|
2194
|
+
"input:not([disabled])",
|
|
2195
|
+
"select:not([disabled])",
|
|
2196
|
+
"textarea:not([disabled])",
|
|
2197
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
2198
|
+
].join(",");
|
|
2199
|
+
return Array.from(i.querySelectorAll(e)).filter(
|
|
2200
|
+
(t) => !!(t.offsetWidth || t.offsetHeight || t.getClientRects().length)
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
function D(i, e = {}) {
|
|
2204
|
+
const t = document.createElement(i);
|
|
2205
|
+
if (e.className && (t.className = e.className), e.html != null && (t.innerHTML = e.html), e.text != null && (t.textContent = e.text), e.attrs)
|
|
2206
|
+
for (const [r, n] of Object.entries(e.attrs)) t.setAttribute(r, n);
|
|
2207
|
+
return t;
|
|
2208
|
+
}
|
|
2209
|
+
const Ur = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform), Bt = ["ctrl", "alt", "shift", "meta"];
|
|
2210
|
+
function Fr(i) {
|
|
2211
|
+
if (!i) return null;
|
|
2212
|
+
const e = String(i).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean), t = [];
|
|
2213
|
+
let r = null;
|
|
2214
|
+
const n = (o) => {
|
|
2215
|
+
t.includes(o) || t.push(o);
|
|
2216
|
+
};
|
|
2217
|
+
for (const o of e) {
|
|
2218
|
+
let a = o;
|
|
2219
|
+
if (a === "control" || a === "ctrl") {
|
|
2220
|
+
n("ctrl");
|
|
2221
|
+
continue;
|
|
2222
|
+
}
|
|
2223
|
+
if (a === "alt" || a === "option") {
|
|
2224
|
+
n("alt");
|
|
2225
|
+
continue;
|
|
2226
|
+
}
|
|
2227
|
+
if (a === "shift") {
|
|
2228
|
+
n("shift");
|
|
2229
|
+
continue;
|
|
2230
|
+
}
|
|
2231
|
+
if (a === "meta" || a === "cmd" || a === "command" || a === "super") {
|
|
2232
|
+
n("meta");
|
|
2233
|
+
continue;
|
|
2234
|
+
}
|
|
2235
|
+
if (a === "mod") {
|
|
2236
|
+
n(Ur ? "meta" : "ctrl");
|
|
2237
|
+
continue;
|
|
2238
|
+
}
|
|
2239
|
+
a === "esc" && (a = "escape"), a === "return" && (a = "enter"), (a === "space" || a === "spacebar") && (a = "space"), r = a;
|
|
2240
|
+
}
|
|
2241
|
+
const s = Bt.filter((o) => t.includes(o));
|
|
2242
|
+
return !r || r === "" ? s.length ? s.join("+") : null : s.length ? `${s.join("+")}+${r}` : r;
|
|
2243
|
+
}
|
|
2244
|
+
function zr(i) {
|
|
2245
|
+
const e = [];
|
|
2246
|
+
i.ctrlKey && e.push("ctrl"), i.altKey && e.push("alt"), i.shiftKey && e.push("shift"), i.metaKey && e.push("meta");
|
|
2247
|
+
let t = i.key;
|
|
2248
|
+
t === " " && (t = "space");
|
|
2249
|
+
const r = (t.length, t.toLowerCase()), n = Bt.filter((s) => e.includes(s));
|
|
2250
|
+
return n.length ? `${n.join("+")}+${r}` : r;
|
|
2251
|
+
}
|
|
2252
|
+
class Kr {
|
|
2253
|
+
constructor() {
|
|
2254
|
+
this.zBase = 1e3, this.stack = [];
|
|
2255
|
+
}
|
|
2256
|
+
push(e) {
|
|
2257
|
+
this.stack.push(e), this.syncZ();
|
|
2258
|
+
}
|
|
2259
|
+
remove(e) {
|
|
2260
|
+
this.stack = this.stack.filter((t) => t !== e), this.syncZ();
|
|
2261
|
+
}
|
|
2262
|
+
top() {
|
|
2263
|
+
return this.stack[this.stack.length - 1];
|
|
2264
|
+
}
|
|
2265
|
+
closeAll(e, t) {
|
|
2266
|
+
const r = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), n = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
2267
|
+
[...this.stack].reverse().forEach((s) => {
|
|
2268
|
+
const o = s.modalId, a = n.size ? n.has(s.pluginName) : !0, f = r.has(o);
|
|
2269
|
+
a && !f && s.close();
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
removeAll() {
|
|
2273
|
+
[...this.stack].forEach((e) => e.destroy()), this.stack = [];
|
|
2274
|
+
}
|
|
2275
|
+
syncZ() {
|
|
2276
|
+
this.stack.forEach((e, t) => e.setZIndex(this.zBase + t * 2));
|
|
2277
|
+
}
|
|
2278
|
+
lockBodyScroll() {
|
|
2279
|
+
document.body.classList.add("ipe-modal-no-scroll");
|
|
2280
|
+
}
|
|
2281
|
+
unlockBodyScroll() {
|
|
2282
|
+
document.body.classList.remove("ipe-modal-no-scroll");
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
const T = new Kr();
|
|
2286
|
+
class de {
|
|
2287
|
+
constructor(e = {}) {
|
|
2288
|
+
this.backdropId = pt("ipe-modal-backdrop"), this.modalId = pt("ipe-modal"), this.numberId = this.modalId.split("-")[1], this._isDestroyed = !1, this.pluginName = "normalModal", this.buttonElsLeft = [], this.buttonElsRight = [], this.keyMap = /* @__PURE__ */ new Map(), this.isOpen = !1, this.isToast = !1, this.isDragging = !1, this.dragStartX = 0, this.dragStartY = 0, this.modalStartX = 0, this.modalStartY = 0, this.Event = Ge, this._hooks = [], this.startCloseTimer = (t) => {
|
|
2289
|
+
this.stopCloseTimer(), this.closeTimer = window.setTimeout(() => this.close(), t);
|
|
2290
|
+
}, this.stopCloseTimer = () => {
|
|
2291
|
+
this.closeTimer && window.clearTimeout(this.closeTimer), this.closeTimer = void 0;
|
|
2292
|
+
}, this.onDragMove = (t) => {
|
|
2293
|
+
if (!this.isDragging) return;
|
|
2294
|
+
t.preventDefault();
|
|
2295
|
+
const r = t.clientX - this.dragStartX, n = t.clientY - this.dragStartY, s = this.get$modal(), o = this.modalStartX + r, a = this.modalStartY + n;
|
|
2296
|
+
s.style.left = `${o}px`, s.style.top = `${a}px`;
|
|
2297
|
+
}, this.onDragEnd = () => {
|
|
2298
|
+
if (!this.isDragging) return;
|
|
2299
|
+
this.isDragging = !1, document.removeEventListener("pointermove", this.onDragMove), document.removeEventListener("pointerup", this.onDragEnd);
|
|
2300
|
+
const t = this.get$modal(), r = this.get$window();
|
|
2301
|
+
t.classList.remove("is-dragging"), r.style.animation = "none", requestAnimationFrame(() => {
|
|
2302
|
+
this.applyAnimation(!0);
|
|
2303
|
+
});
|
|
2304
|
+
}, this.options = { ...de.DEFAULT_OPTIONS, ...e }, this.options.backdrop === !1 && e.bodyScroll === void 0 && (this.options.bodyScroll = !0);
|
|
2305
|
+
}
|
|
2306
|
+
get isDestroyed() {
|
|
2307
|
+
return this._isDestroyed;
|
|
2308
|
+
}
|
|
2309
|
+
static {
|
|
2310
|
+
this.DEFAULT_OPTIONS = {
|
|
2311
|
+
className: "",
|
|
2312
|
+
sizeClass: "auto",
|
|
2313
|
+
center: !0,
|
|
2314
|
+
fitScreen: !1,
|
|
2315
|
+
closeIcon: !0,
|
|
2316
|
+
bodyScroll: !1,
|
|
2317
|
+
outSideClose: !0,
|
|
2318
|
+
backdrop: !0,
|
|
2319
|
+
animation: {
|
|
2320
|
+
show: "ipe-modal-fade-in",
|
|
2321
|
+
hide: "ipe-modal-fade-out"
|
|
2322
|
+
},
|
|
2323
|
+
animationSpeed: 200
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
static extends(e = {}) {
|
|
2327
|
+
return class extends this {
|
|
2328
|
+
constructor(t = {}) {
|
|
2329
|
+
super({ ...e, ...t });
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
// ------------------------------ lifecycle ------------------------------ //
|
|
2334
|
+
init() {
|
|
2335
|
+
if (this.$modal) return this;
|
|
2336
|
+
const e = this.options.backdrop !== !1;
|
|
2337
|
+
let t;
|
|
2338
|
+
e && (t = D("div", {
|
|
2339
|
+
className: "ipe-modal-backdrop",
|
|
2340
|
+
attrs: { id: this.backdropId, "data-modal-id": this.modalId }
|
|
2341
|
+
}));
|
|
2342
|
+
const r = D("div", {
|
|
2343
|
+
className: "ipe-modal-modal",
|
|
2344
|
+
attrs: { id: this.modalId, role: "dialog", "aria-modal": "true", tabindex: "-1" }
|
|
2345
|
+
});
|
|
2346
|
+
if (r.modal = this, !e) {
|
|
2347
|
+
r.classList.add("no-backdrop");
|
|
2348
|
+
const g = window.pageYOffset || document.documentElement.scrollTop, w = window.pageXOffset || document.documentElement.scrollLeft, O = window.innerWidth;
|
|
2349
|
+
r.style.top = `${g + 60}px`, this.once("modal.show", () => {
|
|
2350
|
+
r.style.left = `${w + O / 2 - r.offsetWidth / 2}px`;
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
const n = D("div", {
|
|
2354
|
+
className: `ipe-modal-modal__window size--${this.options.sizeClass || "auto"} plugin--${this.pluginName}`
|
|
2355
|
+
});
|
|
2356
|
+
n.modal = this;
|
|
2357
|
+
const s = D("div", { className: "ipe-modal-modal__header" }), o = `${this.modalId}-title`, a = D("h2", {
|
|
2358
|
+
className: "ipe-modal-modal__title",
|
|
2359
|
+
attrs: { id: o, role: "heading", "aria-level": "2" }
|
|
2360
|
+
});
|
|
2361
|
+
r.setAttribute("aria-labelledby", o);
|
|
2362
|
+
const f = D("div", { className: "ipe-modal-modal__icons" });
|
|
2363
|
+
if (this.options.closeIcon) {
|
|
2364
|
+
const g = D("button", {
|
|
2365
|
+
className: "ipe-modal-modal__close",
|
|
2366
|
+
attrs: { type: "button", "aria-label": "Close" },
|
|
2367
|
+
html: "×"
|
|
2368
|
+
});
|
|
2369
|
+
g.addEventListener("click", () => {
|
|
2370
|
+
let w = !0;
|
|
2371
|
+
typeof this.options.onClickClose == "function" ? this.options.onClickClose(this) === !1 && (w = !1) : this.options.onClickClose === !1 && (w = !1), w && this.close();
|
|
2372
|
+
}), f.appendChild(g);
|
|
2373
|
+
}
|
|
2374
|
+
s.append(a, f), this.options.draggable && e && (this.options.draggable = !1), this.options.draggable && (s.style.cursor = "move", s.style.userSelect = "none", s.addEventListener("pointerdown", this.onDragStart.bind(this)), r.classList.add("is-draggable"));
|
|
2375
|
+
const u = D("div", { className: "ipe-modal-modal__content" }), p = D("div", { className: "ipe-modal-modal__footer" }), y = D("div", {
|
|
2376
|
+
className: "ipe-modal-modal__buttons ipe-modal-modal__buttons--left"
|
|
2377
|
+
}), _ = D("div", {
|
|
2378
|
+
className: "ipe-modal-modal__buttons ipe-modal-modal__buttons--right"
|
|
2379
|
+
});
|
|
2380
|
+
return p.append(y, _), n.append(s, u, p), r.appendChild(n), this.$backdrop = t, this.$modal = r, this.$window = n, this.$header = s, this.$title = a, this.$icons = f, this.$content = u, this.$footer = p, this.$buttonsLeft = y, this.$buttonsRight = _, this.options.title && this.setTitle(this.options.title), this.options.content && this.setContent(this.options.content), this.options.buttons?.length ? this.setButtons(this.options.buttons) : p.style.display = "none", this.options.center && this.$modal.classList.add("is-centered"), this.options.fitScreen && this.$modal.classList.add("is-fullscreen"), this.options.iconButtons && this.$header.classList.add("has-icon-buttons"), this.options.className && this.$window.classList.add(...this.options.className.split(/[\s\.#+]+/g).filter(Boolean)), typeof this.options.fixedHeight == "number" ? this.$window.style.height = `${Math.max(0, this.options.fixedHeight)}px` : this.options.fixedHeight === !0 && this.$window.classList.add("is-fixed-height"), t && t.addEventListener("pointerdown", (g) => {
|
|
2381
|
+
this.options.outSideClose && g.target === t && this.close();
|
|
2382
|
+
}), this.options.draggable && n.addEventListener("pointerdown", (g) => {
|
|
2383
|
+
g.target && n.contains(g.target) && this.bringToFront();
|
|
2384
|
+
}), this.onKeyDown = this.onKeyDown.bind(this), this.emit(
|
|
2385
|
+
"modal.init"
|
|
2386
|
+
/* Init */
|
|
2387
|
+
), this;
|
|
2388
|
+
}
|
|
2389
|
+
show() {
|
|
2390
|
+
if (this.$modal || this.init(), !this.$modal) throw new Error("Failed to initialize modal");
|
|
2391
|
+
if (this.isOpen) return this;
|
|
2392
|
+
{
|
|
2393
|
+
const r = this.emit("modal.beforeShow", !0), n = this.options.beforeShow ? this.options.beforeShow(this) !== !1 : !0;
|
|
2394
|
+
if (!r || !n) return this;
|
|
2395
|
+
}
|
|
2396
|
+
this.lastFocused = document.activeElement ?? null, this.$backdrop && document.body.appendChild(this.$backdrop), document.body.appendChild(this.$modal), this.shouldLockBodyOnOpen() && T.lockBodyScroll(), requestAnimationFrame(() => {
|
|
2397
|
+
this.$backdrop?.classList.add("is-open"), this.$modal.classList.add("is-open"), this.applyAnimation(!0), this.focusFirst();
|
|
2398
|
+
}), document.addEventListener("keydown", this.onKeyDown), T.push(this), this.isOpen = !0, this.options.onShow?.(this), this.emit(
|
|
2399
|
+
"modal.show"
|
|
2400
|
+
/* Show */
|
|
2401
|
+
);
|
|
2402
|
+
const e = typeof this.options.closeAfter == "number" ? this.options.closeAfter : this.options.closeAfter?.time, t = typeof this.options.closeAfter == "number" ? !0 : this.options.closeAfter?.resetOnHover;
|
|
2403
|
+
return e && (this.startCloseTimer(e), t && (this.$window?.addEventListener("mouseenter", this.stopCloseTimer), this.$window?.addEventListener("mouseleave", () => this.startCloseTimer(e)))), this;
|
|
2404
|
+
}
|
|
2405
|
+
close() {
|
|
2406
|
+
if (!this.isOpen) return this;
|
|
2407
|
+
{
|
|
2408
|
+
const s = this.emit("modal.beforeClose", !0), o = this.options.beforeClose ? this.options.beforeClose(this) !== !1 : !0;
|
|
2409
|
+
if (!s || !o) return this;
|
|
2410
|
+
}
|
|
2411
|
+
if (this.isToast) {
|
|
2412
|
+
this.applyAnimation(!1), this.emit(
|
|
2413
|
+
"modal.close"
|
|
2414
|
+
/* Close */
|
|
2415
|
+
), this.emit(
|
|
2416
|
+
"toast.close"
|
|
2417
|
+
/* ToastClose */
|
|
2418
|
+
);
|
|
2419
|
+
const s = this.isAnimationDisabled() ? 0 : this.options.animationSpeed ?? 200;
|
|
2420
|
+
let o = !1;
|
|
2421
|
+
const a = () => {
|
|
2422
|
+
o || (o = !0, this.destroy(), this.options.onClose?.(this));
|
|
2423
|
+
}, f = (u, p) => {
|
|
2424
|
+
const y = () => {
|
|
2425
|
+
u.removeEventListener(p, y), a();
|
|
2426
|
+
};
|
|
2427
|
+
u.addEventListener(p, y, { once: !0 });
|
|
2428
|
+
};
|
|
2429
|
+
return s > 0 && this.$window ? (f(this.$window, "transitionend"), f(this.$window, "animationend"), window.setTimeout(a, s + 20)) : window.setTimeout(a, s), this;
|
|
2430
|
+
}
|
|
2431
|
+
this.applyAnimation(!1), this.$backdrop?.classList.remove("is-open"), this.$modal?.classList.remove("is-open"), this.emit(
|
|
2432
|
+
"modal.close"
|
|
2433
|
+
/* Close */
|
|
2434
|
+
);
|
|
2435
|
+
const e = this.isAnimationDisabled() ? 0 : this.options.animationSpeed ?? 200;
|
|
2436
|
+
let t = !1;
|
|
2437
|
+
const r = () => {
|
|
2438
|
+
t || (t = !0, this.destroy(), this.options.onClose?.(this));
|
|
2439
|
+
}, n = (s, o) => {
|
|
2440
|
+
const a = () => {
|
|
2441
|
+
s.removeEventListener(o, a), r();
|
|
2442
|
+
};
|
|
2443
|
+
s.addEventListener(o, a, { once: !0 });
|
|
2444
|
+
};
|
|
2445
|
+
return e > 0 && this.$window ? (n(this.$window, "transitionend"), n(this.$window, "animationend"), window.setTimeout(r, e + 20)) : window.setTimeout(r, e), this;
|
|
2446
|
+
}
|
|
2447
|
+
/** Immediately removes DOM and listeners */
|
|
2448
|
+
destroy() {
|
|
2449
|
+
if (this._isDestroyed) return this;
|
|
2450
|
+
if (this.stopCloseTimer(), document.removeEventListener("keydown", this.onKeyDown), this.isDragging && this.onDragEnd(), this.$window?.removeEventListener("mouseenter", this.stopCloseTimer), this.isToast) {
|
|
2451
|
+
this.$window?.parentElement && this.$window.parentElement.removeChild(this.$window);
|
|
2452
|
+
const e = V.indexOf(this);
|
|
2453
|
+
e !== -1 && V.splice(e, 1);
|
|
2454
|
+
} else
|
|
2455
|
+
this.$backdrop?.parentElement && this.$backdrop.parentElement.removeChild(this.$backdrop), this.$modal?.parentElement && this.$modal.parentElement.removeChild(this.$modal), T.remove(this), this.shouldUnlockBodyOnClose() && T.unlockBodyScroll();
|
|
2456
|
+
return this.isOpen = !1, this.lastFocused?.focus?.(), this.emit(
|
|
2457
|
+
"modal.destroy"
|
|
2458
|
+
/* Destroy */
|
|
2459
|
+
), this._isDestroyed = !0, this;
|
|
2460
|
+
}
|
|
2461
|
+
// ------------------------------ getters ------------------------------- //
|
|
2462
|
+
get$backdrop() {
|
|
2463
|
+
return this.$backdrop;
|
|
2464
|
+
}
|
|
2465
|
+
get$modal() {
|
|
2466
|
+
return K(this.$modal, "modal");
|
|
2467
|
+
}
|
|
2468
|
+
get$window() {
|
|
2469
|
+
return K(this.$window, "window");
|
|
2470
|
+
}
|
|
2471
|
+
get$header() {
|
|
2472
|
+
return K(this.$header, "header");
|
|
2473
|
+
}
|
|
2474
|
+
get$title() {
|
|
2475
|
+
return K(this.$title, "title");
|
|
2476
|
+
}
|
|
2477
|
+
get$content() {
|
|
2478
|
+
return K(this.$content, "content");
|
|
2479
|
+
}
|
|
2480
|
+
get$icons() {
|
|
2481
|
+
return K(this.$icons, "icons");
|
|
2482
|
+
}
|
|
2483
|
+
get$buttons(e) {
|
|
2484
|
+
return e === "leftButtons" ? K(this.$buttonsLeft, "leftButtons") : e === "rightButtons" ? K(this.$buttonsRight, "rightButtons") : K(this.$footer, "buttons");
|
|
2485
|
+
}
|
|
2486
|
+
// ------------------------------ content ------------------------------- //
|
|
2487
|
+
setTitle(e) {
|
|
2488
|
+
const t = this.get$title();
|
|
2489
|
+
return t.innerHTML = "", t.append(Z(e)), this;
|
|
2490
|
+
}
|
|
2491
|
+
setContent(e, t = "replace") {
|
|
2492
|
+
const r = this.get$content();
|
|
2493
|
+
return t === "replace" ? (r.innerHTML = "", r.append(Z(e))) : t === "append" ? r.append(Z(e)) : r.prepend(Z(e)), this;
|
|
2494
|
+
}
|
|
2495
|
+
setIcons(e) {
|
|
2496
|
+
const t = this.get$icons();
|
|
2497
|
+
t.innerHTML = "";
|
|
2498
|
+
for (const r of e) {
|
|
2499
|
+
const n = D("button", {
|
|
2500
|
+
className: `ipe-modal-modal__icon ${r.className}`,
|
|
2501
|
+
attrs: { type: "button" }
|
|
2502
|
+
});
|
|
2503
|
+
n.addEventListener("click", r.method), t.appendChild(n);
|
|
2504
|
+
}
|
|
2505
|
+
return this;
|
|
2506
|
+
}
|
|
2507
|
+
setButtons(e, t) {
|
|
2508
|
+
const r = this.$buttonsLeft, n = this.$buttonsRight;
|
|
2509
|
+
[r, n].forEach((o) => o.innerHTML = ""), this.buttonElsLeft = [], this.buttonElsRight = [], this.keyMap.clear();
|
|
2510
|
+
const s = t ?? this.$footer;
|
|
2511
|
+
if (s === this.$footer)
|
|
2512
|
+
e.forEach((o) => this.addButton(o)), e.length === 0 && (this.$footer.style.display = "none");
|
|
2513
|
+
else {
|
|
2514
|
+
s.innerHTML = "";
|
|
2515
|
+
for (const o of e) {
|
|
2516
|
+
const a = this.generateButton(o);
|
|
2517
|
+
s.appendChild(a);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
return this;
|
|
2521
|
+
}
|
|
2522
|
+
generateButton(e) {
|
|
2523
|
+
const t = e.type ?? "button", r = t === "link" ? D("a") : D("button", { attrs: { type: "button" } });
|
|
2524
|
+
e.id && (r.id = e.id), r.className = `ipe-modal-btn ${e.className ?? ""}`.trim();
|
|
2525
|
+
const n = Z(e.label ?? "OK");
|
|
2526
|
+
if (r.append(n), t === "link" && e.href && (r.href = e.href), e.method && r.addEventListener("click", (s) => {
|
|
2527
|
+
if (r._ipe_tmpDisabled) {
|
|
2528
|
+
s.preventDefault(), s.stopPropagation();
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
e.method.call(r, s, this);
|
|
2532
|
+
}), typeof e.closeAfter == "number" && e.closeAfter >= 0 && r.addEventListener("click", () => {
|
|
2533
|
+
window.setTimeout(() => this.close(), e.closeAfter);
|
|
2534
|
+
}), typeof e.enableAfter == "number" && e.enableAfter > 0) {
|
|
2535
|
+
t === "button" && r.setAttribute("disabled", "true"), r._ipe_tmpDisabled = !0, r.setAttribute("aria-disabled", "true");
|
|
2536
|
+
const s = () => {
|
|
2537
|
+
t === "button" && r.removeAttribute("disabled"), delete r._ipe_tmpDisabled, r.removeAttribute("aria-disabled");
|
|
2538
|
+
};
|
|
2539
|
+
window.setTimeout(s, e.enableAfter);
|
|
2540
|
+
}
|
|
2541
|
+
if (e.keyPress) {
|
|
2542
|
+
const s = String(e.keyPress).split(/[\,\|]+/g).map((o) => o.trim()).filter(Boolean);
|
|
2543
|
+
for (const o of s) {
|
|
2544
|
+
const a = Fr(o);
|
|
2545
|
+
a && this.keyMap.set(a, r);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
return r;
|
|
2549
|
+
}
|
|
2550
|
+
/** Dynamically add button(s) into footer. Supports insertion index per side. */
|
|
2551
|
+
addButton(e, t) {
|
|
2552
|
+
this.$footer && (this.$footer.style.display = "");
|
|
2553
|
+
const r = e.side ?? "right", n = r === "left" ? this.$buttonsLeft : this.$buttonsRight, s = r === "left" ? this.buttonElsLeft : this.buttonElsRight, o = this.generateButton(e), a = Math.max(0, Math.min(t ?? s.length, s.length));
|
|
2554
|
+
return a >= n.children.length ? n.appendChild(o) : n.insertBefore(o, n.children[a]), s.splice(a, 0, o), this;
|
|
2555
|
+
}
|
|
2556
|
+
/** Remove button by element / id / global index (left first, then right). */
|
|
2557
|
+
removeButton(e) {
|
|
2558
|
+
const t = this.buttonElsLeft, r = this.buttonElsRight, n = [...t, ...r];
|
|
2559
|
+
let s = null;
|
|
2560
|
+
if (e === "*")
|
|
2561
|
+
return n.forEach((a) => {
|
|
2562
|
+
this.keyMap.delete(a.id), a.parentElement?.removeChild(a);
|
|
2563
|
+
}), this.$footer && (this.$footer.style.display = "none"), this;
|
|
2564
|
+
if (typeof e == "number" ? s = n[e] ?? null : typeof e == "string" ? s = n.find((a) => a.id === e) ?? null : e instanceof HTMLElement && (s = n.find((a) => a === e) ?? null), !s) return this;
|
|
2565
|
+
for (const [a, f] of this.keyMap.entries()) f === s && this.keyMap.delete(a);
|
|
2566
|
+
let o = t.indexOf(s);
|
|
2567
|
+
return o !== -1 ? (t.splice(o, 1), s.parentElement?.removeChild(s)) : (o = r.indexOf(s), o !== -1 && (r.splice(o, 1), s.parentElement?.removeChild(s))), t.length === 0 && r.length === 0 && this.$footer && (this.$footer.style.display = "none"), this;
|
|
2568
|
+
}
|
|
2569
|
+
changePreviewState() {
|
|
2570
|
+
return this.get$modal().classList.toggle("is-fullscreen"), this;
|
|
2571
|
+
}
|
|
2572
|
+
setModalHeight(e, t = "height") {
|
|
2573
|
+
const r = this.get$window(), n = Math.max(0, window.innerHeight - e);
|
|
2574
|
+
return r.style[t] = `${n}px`, n;
|
|
2575
|
+
}
|
|
2576
|
+
setOptions(e, t) {
|
|
2577
|
+
return typeof e == "string" ? this.options[e] = t : Object.assign(this.options, e), this;
|
|
2578
|
+
}
|
|
2579
|
+
setPluginName(e) {
|
|
2580
|
+
return this.$window && (this.$window.className = this.$window.className.replace(
|
|
2581
|
+
`plugin--${this.pluginName}`,
|
|
2582
|
+
`plugin--${e}`
|
|
2583
|
+
)), this.pluginName = e, this;
|
|
2584
|
+
}
|
|
2585
|
+
// ------------------------------ helpers ------------------------------- //
|
|
2586
|
+
applyAnimation(e) {
|
|
2587
|
+
const t = this.get$modal(), r = this.get$window(), n = this.$backdrop, s = this.options.modalAnimation ?? this.options.animation, o = typeof s == "string" ? s : s && (e ? s.show : s.hide), a = this.options.backdropAnimation ?? this.options.animation, f = typeof a == "string" ? a : a && (e ? a.show : a.hide);
|
|
2588
|
+
!o || o === !1 ? (t.style.transition = "none", r.style.animation = "none", r.style.removeProperty("--ipe-modal-anim")) : (t.style.removeProperty("transition"), r.style.setProperty("--ipe-modal-anim", o)), n && (!f || f === !1 ? n.style.transition = "none" : n.style.removeProperty("transition"));
|
|
2589
|
+
}
|
|
2590
|
+
on(e, t) {
|
|
2591
|
+
return this._hooks.push({ type: e, listener: t }), () => this.off(e, t);
|
|
2592
|
+
}
|
|
2593
|
+
off(e, t) {
|
|
2594
|
+
return this._hooks = this._hooks.filter(
|
|
2595
|
+
(r) => r.type !== e && (t ? r.listener !== t : !0)
|
|
2596
|
+
), this;
|
|
2597
|
+
}
|
|
2598
|
+
once(e, t) {
|
|
2599
|
+
const r = this.on(e, (n) => (r(), t(n)));
|
|
2600
|
+
return r;
|
|
2601
|
+
}
|
|
2602
|
+
emit(e, t) {
|
|
2603
|
+
const r = this._hooks.filter((a) => a.type === e);
|
|
2604
|
+
let n = !0;
|
|
2605
|
+
for (const a of r) {
|
|
2606
|
+
const f = new CustomEvent(e, { detail: this, cancelable: t }), u = a.listener(f);
|
|
2607
|
+
if (f.defaultPrevented && (n = !1), u === !1 && (n = !1), !n) break;
|
|
2608
|
+
}
|
|
2609
|
+
const s = this.$modal ?? document.body, o = new CustomEvent(e, { detail: this, cancelable: t });
|
|
2610
|
+
return (!s.dispatchEvent(o) || o.defaultPrevented) && (n = !1), n;
|
|
2611
|
+
}
|
|
2612
|
+
focusFirst() {
|
|
2613
|
+
const e = this.get$modal(), t = gt(e);
|
|
2614
|
+
t.length ? t[0].focus() : e.focus({ preventScroll: !0 });
|
|
2615
|
+
}
|
|
2616
|
+
onKeyDown(e) {
|
|
2617
|
+
if (T.top() !== this) return;
|
|
2618
|
+
if (e.key === "Escape") {
|
|
2619
|
+
e.preventDefault(), this.close();
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
const t = this.get$modal();
|
|
2623
|
+
if (!t.contains(document.activeElement)) return;
|
|
2624
|
+
if (e.key === "Tab") {
|
|
2625
|
+
const a = gt(t);
|
|
2626
|
+
if (!a.length) return;
|
|
2627
|
+
const f = a[0], u = a[a.length - 1], p = document.activeElement;
|
|
2628
|
+
e.shiftKey && p === f ? (e.preventDefault(), u.focus()) : !e.shiftKey && p === u && (e.preventDefault(), f.focus());
|
|
2629
|
+
}
|
|
2630
|
+
const r = e.ctrlKey || e.altKey || e.metaKey, n = e.target;
|
|
2631
|
+
if (!r && (n && ["INPUT", "TEXTAREA"].includes(n.tagName) || n.contentEditable === "true"))
|
|
2632
|
+
return;
|
|
2633
|
+
const s = zr(e), o = this.keyMap.get(s);
|
|
2634
|
+
if (o) {
|
|
2635
|
+
e.preventDefault(), o.click();
|
|
2636
|
+
return;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
setZIndex(e) {
|
|
2640
|
+
this.$backdrop && (this.$backdrop.style.zIndex = String(e)), this.$modal && (this.$modal.style.zIndex = String(e + 1));
|
|
2641
|
+
}
|
|
2642
|
+
/** Bring this modal to the top of the stack. */
|
|
2643
|
+
bringToFront() {
|
|
2644
|
+
return T.remove(this), T.push(this), this;
|
|
2645
|
+
}
|
|
2646
|
+
isAnimationDisabled() {
|
|
2647
|
+
const e = this.options.modalAnimation ?? this.options.animation;
|
|
2648
|
+
return e === !1 || e == null;
|
|
2649
|
+
}
|
|
2650
|
+
shouldLockBodyOnOpen() {
|
|
2651
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !T.stack.some(
|
|
2652
|
+
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2655
|
+
shouldUnlockBodyOnClose() {
|
|
2656
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !T.stack.some(
|
|
2657
|
+
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
2658
|
+
);
|
|
2659
|
+
}
|
|
2660
|
+
// ------------------------------ drag handlers ------------------------------- //
|
|
2661
|
+
onDragStart(e) {
|
|
2662
|
+
if (this.options.backdrop !== !1 || !this.options.draggable) return;
|
|
2663
|
+
e.preventDefault(), this.isDragging = !0, this.bringToFront(), this.dragStartX = e.clientX, this.dragStartY = e.clientY;
|
|
2664
|
+
const t = this.get$modal(), r = t.getBoundingClientRect();
|
|
2665
|
+
this.modalStartX = r.left + window.pageXOffset, this.modalStartY = r.top + window.pageYOffset, t.style.transform = "none", t.style.left = `${this.modalStartX}px`, t.style.top = `${this.modalStartY}px`, document.addEventListener("pointermove", this.onDragMove), document.addEventListener("pointerup", this.onDragEnd), t.classList.add("is-dragging");
|
|
2666
|
+
}
|
|
2667
|
+
// ------------------------------ toast ------------------------------- //
|
|
2668
|
+
/** Show as toast (no backdrop, container stack). */
|
|
2669
|
+
showToast(e) {
|
|
2670
|
+
this.$window || this.init();
|
|
2671
|
+
const t = qr(e.position ?? "top right"), r = this.get$window();
|
|
2672
|
+
this.isToast = !0, r.style.pointerEvents = "auto", this.applyAnimation(!0), t.appendChild(r);
|
|
2673
|
+
const n = (typeof this.options.closeAfter == "number" ? this.options.closeAfter : this.options.closeAfter?.time) ?? 3e3, s = (typeof this.options.closeAfter == "number" ? !0 : this.options.closeAfter?.resetOnHover) ?? !0;
|
|
2674
|
+
return n > 0 && (this.startCloseTimer(n), s && (r.addEventListener("mouseenter", this.stopCloseTimer), r.addEventListener("mouseleave", () => this.startCloseTimer(n)))), this.isOpen = !0, this.options.onShow?.(this), V.push(this), this.emit(
|
|
2675
|
+
"toast.show"
|
|
2676
|
+
/* ToastShow */
|
|
2677
|
+
), this.emit(
|
|
2678
|
+
"modal.show"
|
|
2679
|
+
/* Show */
|
|
2680
|
+
), this;
|
|
2681
|
+
}
|
|
2682
|
+
// ------------------------------ static helpers --------------------------- //
|
|
2683
|
+
static show(e, t) {
|
|
2684
|
+
return new this(e).init().show();
|
|
2685
|
+
}
|
|
2686
|
+
static createObject(e, t) {
|
|
2687
|
+
return new this(e);
|
|
2688
|
+
}
|
|
2689
|
+
static close(e) {
|
|
2690
|
+
if (!e) {
|
|
2691
|
+
const s = T.top();
|
|
2692
|
+
return s?.close(), s;
|
|
2693
|
+
}
|
|
2694
|
+
const t = typeof e == "string" ? e : e.id, r = T.stack.find((s) => s.modalId === t);
|
|
2695
|
+
if (r)
|
|
2696
|
+
return r.close(), r;
|
|
2697
|
+
const n = V.find((s) => s.modalId === t);
|
|
2698
|
+
return n?.close(), n;
|
|
2699
|
+
}
|
|
2700
|
+
static closeAll(e, t) {
|
|
2701
|
+
const r = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), n = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
2702
|
+
return T.closeAll(e, t), [...V].forEach((s) => {
|
|
2703
|
+
const o = s.modalId, a = n.size ? n.has(s.pluginName) : !0, f = r.has(o);
|
|
2704
|
+
a && !f && s.close();
|
|
2705
|
+
}), T.top() ?? new de();
|
|
2706
|
+
}
|
|
2707
|
+
static removeAll() {
|
|
2708
|
+
T.removeAll(), [...V].forEach((e) => e.destroy());
|
|
2709
|
+
}
|
|
2710
|
+
static dialog(e, t) {
|
|
2711
|
+
const r = new this({
|
|
2712
|
+
sizeClass: "dialog",
|
|
2713
|
+
buttons: [
|
|
2714
|
+
{
|
|
2715
|
+
label: "OK",
|
|
2716
|
+
className: "is-primary is-ghost",
|
|
2717
|
+
method: (n, s) => {
|
|
2718
|
+
t?.(n, s), n.defaultPrevented || r.close();
|
|
2719
|
+
},
|
|
2720
|
+
keyPress: "Enter"
|
|
2721
|
+
}
|
|
2722
|
+
],
|
|
2723
|
+
...e
|
|
2724
|
+
});
|
|
2725
|
+
return r.init().show();
|
|
2726
|
+
}
|
|
2727
|
+
static confirm(e, t) {
|
|
2728
|
+
e.title ??= "Confirm", e.content ??= "Are you sure you want to perform this action?";
|
|
2729
|
+
const r = e.okBtn ?? { label: "OK", className: "is-primary is-ghost" }, n = e.cancelBtn ?? { label: "Cancel", className: "is-danger is-ghost" };
|
|
2730
|
+
return new this({
|
|
2731
|
+
sizeClass: "dialog",
|
|
2732
|
+
...e,
|
|
2733
|
+
buttons: [
|
|
2734
|
+
{
|
|
2735
|
+
label: n.label,
|
|
2736
|
+
className: n.className,
|
|
2737
|
+
keyPress: "n",
|
|
2738
|
+
method: (s, o) => {
|
|
2739
|
+
t?.(!1, o, s), o.close();
|
|
2740
|
+
}
|
|
2741
|
+
},
|
|
2742
|
+
{
|
|
2743
|
+
label: r.label,
|
|
2744
|
+
className: r.className,
|
|
2745
|
+
keyPress: "y",
|
|
2746
|
+
method: (s, o) => {
|
|
2747
|
+
t?.(!0, o, s), s.defaultPrevented || o.close();
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
]
|
|
2751
|
+
}).init().show();
|
|
2752
|
+
}
|
|
2753
|
+
static getDefaultNotifyIcon(e) {
|
|
2754
|
+
switch (e) {
|
|
2755
|
+
case "success":
|
|
2756
|
+
return /* @__PURE__ */ P(
|
|
2757
|
+
"svg",
|
|
2758
|
+
{
|
|
2759
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2760
|
+
width: "24",
|
|
2761
|
+
height: "24",
|
|
2762
|
+
viewBox: "0 0 24 24",
|
|
2763
|
+
fill: "currentColor",
|
|
2764
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-circle-check",
|
|
2765
|
+
children: [
|
|
2766
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2767
|
+
/* @__PURE__ */ P("path", { d: "M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" })
|
|
2768
|
+
]
|
|
2769
|
+
}
|
|
2770
|
+
);
|
|
2771
|
+
case "error":
|
|
2772
|
+
return /* @__PURE__ */ P(
|
|
2773
|
+
"svg",
|
|
2774
|
+
{
|
|
2775
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2776
|
+
width: "24",
|
|
2777
|
+
height: "24",
|
|
2778
|
+
viewBox: "0 0 24 24",
|
|
2779
|
+
fill: "currentColor",
|
|
2780
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",
|
|
2781
|
+
children: [
|
|
2782
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2783
|
+
/* @__PURE__ */ P("path", { d: "M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z" })
|
|
2784
|
+
]
|
|
2785
|
+
}
|
|
2786
|
+
);
|
|
2787
|
+
case "warning":
|
|
2788
|
+
return /* @__PURE__ */ P(
|
|
2789
|
+
"svg",
|
|
2790
|
+
{
|
|
2791
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2792
|
+
width: "24",
|
|
2793
|
+
height: "24",
|
|
2794
|
+
viewBox: "0 0 24 24",
|
|
2795
|
+
fill: "currentColor",
|
|
2796
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",
|
|
2797
|
+
children: [
|
|
2798
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2799
|
+
/* @__PURE__ */ P("path", { d: "M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z" })
|
|
2800
|
+
]
|
|
2801
|
+
}
|
|
2802
|
+
);
|
|
2803
|
+
case "info":
|
|
2804
|
+
return /* @__PURE__ */ P(
|
|
2805
|
+
"svg",
|
|
2806
|
+
{
|
|
2807
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2808
|
+
width: "24",
|
|
2809
|
+
height: "24",
|
|
2810
|
+
viewBox: "0 0 24 24",
|
|
2811
|
+
fill: "currentColor",
|
|
2812
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-info-circle",
|
|
2813
|
+
children: [
|
|
2814
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2815
|
+
/* @__PURE__ */ P("path", { d: "M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 9h-1l-.117 .007a1 1 0 0 0 0 1.986l.117 .007v3l.007 .117a1 1 0 0 0 .876 .876l.117 .007h1l.117 -.007a1 1 0 0 0 .876 -.876l.007 -.117l-.007 -.117a1 1 0 0 0 -.764 -.857l-.112 -.02l-.117 -.006v-3l-.007 -.117a1 1 0 0 0 -.876 -.876l-.117 -.007zm.01 -3l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z" })
|
|
2816
|
+
]
|
|
2817
|
+
}
|
|
2818
|
+
);
|
|
2819
|
+
case "dialog":
|
|
2820
|
+
return /* @__PURE__ */ P(
|
|
2821
|
+
"svg",
|
|
2822
|
+
{
|
|
2823
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2824
|
+
width: "24",
|
|
2825
|
+
height: "24",
|
|
2826
|
+
viewBox: "0 0 24 24",
|
|
2827
|
+
fill: "none",
|
|
2828
|
+
stroke: "currentColor",
|
|
2829
|
+
"stroke-width": "2",
|
|
2830
|
+
"stroke-linecap": "round",
|
|
2831
|
+
"stroke-linejoin": "round",
|
|
2832
|
+
class: "icon icon-tabler icons-tabler-outline icon-tabler-message-dots",
|
|
2833
|
+
children: [
|
|
2834
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2835
|
+
/* @__PURE__ */ P("path", { d: "M12 11v.01" }),
|
|
2836
|
+
/* @__PURE__ */ P("path", { d: "M8 11v.01" }),
|
|
2837
|
+
/* @__PURE__ */ P("path", { d: "M16 11v.01" }),
|
|
2838
|
+
/* @__PURE__ */ P("path", { d: "M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z" })
|
|
2839
|
+
]
|
|
2840
|
+
}
|
|
2841
|
+
);
|
|
2842
|
+
case "confirm":
|
|
2843
|
+
return /* @__PURE__ */ P(
|
|
2844
|
+
"svg",
|
|
2845
|
+
{
|
|
2846
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2847
|
+
width: "24",
|
|
2848
|
+
height: "24",
|
|
2849
|
+
viewBox: "0 0 24 24",
|
|
2850
|
+
fill: "currentColor",
|
|
2851
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-copy-check",
|
|
2852
|
+
children: [
|
|
2853
|
+
/* @__PURE__ */ P("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2854
|
+
/* @__PURE__ */ P("path", { d: "M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414" })
|
|
2855
|
+
]
|
|
2856
|
+
}
|
|
2857
|
+
);
|
|
2858
|
+
default:
|
|
2859
|
+
return null;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
static notify(e, t, r) {
|
|
2863
|
+
if (t?.overrideOther && [...V].forEach((a) => a.close()), typeof t.title > "u") {
|
|
2864
|
+
const a = e || "Notification";
|
|
2865
|
+
t.title = a[0].toUpperCase() + a.slice(1).toLowerCase();
|
|
2866
|
+
}
|
|
2867
|
+
const n = t.icon ?? this.getDefaultNotifyIcon(e);
|
|
2868
|
+
n && (n instanceof Element && n.classList.add("ipe-modal-notify-icon"), t.title = /* @__PURE__ */ P(jr, { children: [
|
|
2869
|
+
n,
|
|
2870
|
+
t.title
|
|
2871
|
+
] })), e === "confirm" && (typeof t.closeAfter > "u" && (t.closeAfter = 0), t.okBtn || (t.okBtn = { label: "OK" })), t.okBtn && (typeof t.okBtn != "object" && (t.okBtn = { label: "OK" }), t.okBtn.label ??= "OK", t.okBtn.className ??= "is-primary is-text ok-btn", t.okBtn.method = (a, f) => {
|
|
2872
|
+
r?.(!0, f, a), f.close();
|
|
2873
|
+
}), t.cancelBtn && (typeof t.cancelBtn != "object" && (t.cancelBtn = { label: "Cancel" }), t.cancelBtn.label ??= "Cancel", t.cancelBtn.className ??= "is-danger is-text cancel-btn", t.cancelBtn.method = (a, f) => {
|
|
2874
|
+
r?.(!1, f, a), f.close();
|
|
2875
|
+
}), t.buttons = [t.cancelBtn, t.okBtn, ...t.buttons ?? []].filter(
|
|
2876
|
+
Boolean
|
|
2877
|
+
);
|
|
2878
|
+
const s = `is-notify type-${e || "default"} ${t.className ?? ""}`, o = new this({
|
|
2879
|
+
...t,
|
|
2880
|
+
className: s,
|
|
2881
|
+
sizeClass: "auto",
|
|
2882
|
+
center: !1,
|
|
2883
|
+
fitScreen: !1,
|
|
2884
|
+
closeIcon: !0,
|
|
2885
|
+
outSideClose: !1,
|
|
2886
|
+
bodyScroll: !0,
|
|
2887
|
+
buttons: t.buttons ?? []
|
|
2888
|
+
});
|
|
2889
|
+
return o.setPluginName("toast"), o.showToast({
|
|
2890
|
+
position: t.position ?? "top right"
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
const V = [];
|
|
2895
|
+
function qr(i = "top right") {
|
|
2896
|
+
const e = "ipe-modal-toast-container", t = `${e}-${i.replace(/[\s-\.|\/]+/g, "-")}`;
|
|
2897
|
+
let r = document.getElementById(t);
|
|
2898
|
+
return r || (r = D("div", {
|
|
2899
|
+
className: `${e} ${i}`,
|
|
2900
|
+
attrs: { id: t, "data-position": i }
|
|
2901
|
+
}), document.body.appendChild(r)), r;
|
|
2902
|
+
}
|
|
2903
|
+
class R extends de {
|
|
2904
|
+
constructor(e = {}) {
|
|
2905
|
+
e.className ||= "", e.className += " theme-ipe", e.modalAnimation ||= {
|
|
2906
|
+
show: "ipe-modal-fade-in",
|
|
2907
|
+
hide: "ipe-modal-fade-out"
|
|
2908
|
+
}, super(e);
|
|
2909
|
+
}
|
|
2910
|
+
setLoadingState(e) {
|
|
2911
|
+
if (this.get$window().classList.toggle("loading", e), e) {
|
|
2912
|
+
const t = this.get$window().querySelectorAll(
|
|
2913
|
+
"input:not([disabled]),button:not([disabled])"
|
|
2914
|
+
);
|
|
2915
|
+
this._tmpDisabledActiveInputs = t, t.forEach((r) => {
|
|
2916
|
+
r.disabled = !0;
|
|
2917
|
+
}), this.get$content().append(
|
|
2918
|
+
/* @__PURE__ */ M(
|
|
2919
|
+
"div",
|
|
2920
|
+
{
|
|
2921
|
+
id: "ipe-modalLoadingWrapper",
|
|
2922
|
+
style: {
|
|
2923
|
+
position: "absolute",
|
|
2924
|
+
top: 0,
|
|
2925
|
+
left: 0,
|
|
2926
|
+
right: 0,
|
|
2927
|
+
bottom: 0,
|
|
2928
|
+
display: "flex",
|
|
2929
|
+
justifyContent: "center",
|
|
2930
|
+
alignItems: "center",
|
|
2931
|
+
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
2932
|
+
zIndex: 2e3
|
|
2933
|
+
},
|
|
2934
|
+
children: /* @__PURE__ */ M(Ei, { style: { width: "80%", maxWidth: "800px" } })
|
|
2935
|
+
}
|
|
2936
|
+
)
|
|
2937
|
+
);
|
|
2938
|
+
} else {
|
|
2939
|
+
this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();
|
|
2940
|
+
const t = this._tmpDisabledActiveInputs;
|
|
2941
|
+
t && t.forEach((r) => {
|
|
2942
|
+
r.disabled = !1;
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
class Hr {
|
|
2948
|
+
constructor(e) {
|
|
2949
|
+
this.ctx = e, this.IPEModal = R, this.IPEModalEvent = Ge, this.show = R.show.bind(R), this.createObject = R.createObject.bind(R), this.close = R.close.bind(R), this.closeAll = R.closeAll.bind(R), this.removeAll = R.removeAll.bind(R), this.dialog = R.dialog.bind(R), this.confirm = R.confirm.bind(R), this.notify = R.notify.bind(R), e.set("modal", this), e.on("dispose", () => {
|
|
2950
|
+
R.closeAll();
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
const Ut = (i) => {
|
|
2955
|
+
if (!i)
|
|
2956
|
+
return new URLSearchParams();
|
|
2957
|
+
if (i instanceof URLSearchParams)
|
|
2958
|
+
return i;
|
|
2959
|
+
if (typeof i != "object" || i?.constructor !== Object)
|
|
2960
|
+
throw new TypeError("only plain object is supported");
|
|
2961
|
+
const e = new URLSearchParams();
|
|
2962
|
+
for (const [t, r] of Object.entries(i))
|
|
2963
|
+
if (r != null) {
|
|
2964
|
+
if (Array.isArray(r)) {
|
|
2965
|
+
for (const n of r)
|
|
2966
|
+
e.append(t, n?.toString());
|
|
2967
|
+
continue;
|
|
2968
|
+
}
|
|
2969
|
+
if (typeof r == "object" && r !== null && r.constructor === Object) {
|
|
2970
|
+
for (const [n, s] of Object.entries(r))
|
|
2971
|
+
s != null && e.set(`${t}[${n}]`, s?.toString());
|
|
2972
|
+
continue;
|
|
2973
|
+
}
|
|
2974
|
+
e.set(t, r?.toString());
|
|
2975
|
+
}
|
|
2976
|
+
return e;
|
|
2977
|
+
}, Ft = (i, e, t) => {
|
|
2978
|
+
const r = typeof i == "string" ? new URL(i, window?.location?.origin) : new URL(i), n = new URLSearchParams(r.search), s = Ut(e);
|
|
2979
|
+
for (const [o, a] of s.entries())
|
|
2980
|
+
n.set(o, a);
|
|
2981
|
+
return r.search = n.toString(), r.hash = "", r;
|
|
2982
|
+
};
|
|
2983
|
+
var Wr = Object.create, Ve = Object.defineProperty, Gr = Object.getOwnPropertyDescriptor, zt = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), Kt = (i) => {
|
|
2984
|
+
throw TypeError(i);
|
|
2985
|
+
}, Vr = (i, e, t) => e in i ? Ve(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Jr = (i, e) => Ve(i, "name", { value: e, configurable: !0 }), Yr = (i) => [, , , Wr(i?.[zt("metadata")] ?? null)], Xr = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], qt = (i) => i !== void 0 && typeof i != "function" ? Kt("Function expected") : i, Qr = (i, e, t, r, n) => ({ kind: Xr[i], name: e, metadata: r, addInitializer: (s) => t._ ? Kt("Already initialized") : n.push(qt(s || null)) }), Zr = (i, e) => Vr(e, zt("metadata"), i[3]), en = (i, e, t, r) => {
|
|
2986
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
2987
|
+
return r;
|
|
2988
|
+
}, tn = (i, e, t, r, n, s) => {
|
|
2989
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && Gr(n, t));
|
|
2990
|
+
Jr(n, t);
|
|
2991
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
2992
|
+
f = Qr(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, qt(o) && (n = o);
|
|
2993
|
+
return Zr(i, n), g && Ve(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
2994
|
+
}, Ht, Je, Wt;
|
|
2995
|
+
Ht = [F(["api", "storage"])];
|
|
2996
|
+
class pe extends (Wt = z) {
|
|
2997
|
+
constructor(e) {
|
|
2998
|
+
super(e, "wiki", !1), this.ctx = e, this._data = {}, this.CACHE_VERSION = 4, this.CACHE_TTL = {
|
|
2999
|
+
siteinfo: 1e3 * 60 * 60 * 24 * 3,
|
|
3000
|
+
// 3 days
|
|
3001
|
+
userinfo: 1e3 * 60 * 30
|
|
3002
|
+
// 30 minutes
|
|
3003
|
+
}, this.QUERY_DATA = {
|
|
3004
|
+
siteinfo: {
|
|
3005
|
+
meta: "siteinfo|filerepoinfo",
|
|
3006
|
+
siprop: "general|specialpagealiases|namespacealiases|namespaces|magicwords",
|
|
3007
|
+
friprop: "canUpload|displayname|initialCapital|local|name|rootUrl|scriptDirUrl|thumbUrl|url"
|
|
3008
|
+
},
|
|
3009
|
+
userinfo: { meta: "userinfo", uiprop: "groups|rights|blockinfo|options" }
|
|
3010
|
+
}, this.CACHE_DB = void 0, this.mwConfig = {
|
|
3011
|
+
get: ((t, r) => window?.mw?.config?.get?.(t, r) ?? r),
|
|
3012
|
+
has: ((t) => window?.mw?.config?.exists?.(t) ?? !1),
|
|
3013
|
+
get values() {
|
|
3014
|
+
return window?.mw?.config?.values || {};
|
|
3015
|
+
}
|
|
3016
|
+
}, this.CACHE_DB = e.storage.createDatabase(
|
|
3017
|
+
"wiki-metadata",
|
|
3018
|
+
1 / 0,
|
|
3019
|
+
this.CACHE_VERSION
|
|
3020
|
+
);
|
|
3021
|
+
}
|
|
3022
|
+
get logger() {
|
|
3023
|
+
return this.ctx.logger("WIKI_METADATA");
|
|
3024
|
+
}
|
|
3025
|
+
get api() {
|
|
3026
|
+
return this.ctx.api;
|
|
3027
|
+
}
|
|
3028
|
+
async start() {
|
|
3029
|
+
await Promise.all(
|
|
3030
|
+
Object.keys(this.QUERY_DATA).map((e) => this.initData(e))
|
|
3031
|
+
), this.ctx.on("clear-cache", this.onClearCache.bind(this)), this.ctx.set("getUrl", this.getUrl.bind(this)), this.ctx.set("getSciprtUrl", this.getSciprtUrl.bind(this)), this.ctx.set("getMainpageUrl", this.getMainpageUrl.bind(this)), this.ctx.inject(["preferences", "$"], (e) => {
|
|
3032
|
+
const t = e.$;
|
|
3033
|
+
e.preferences.registerCustomConfig(
|
|
3034
|
+
"WikiMetadataService",
|
|
3035
|
+
$.object({
|
|
3036
|
+
WikiMetadataService: $.const(
|
|
3037
|
+
/* @__PURE__ */ M("div", { children: [
|
|
3038
|
+
/* @__PURE__ */ M("h3", { children: t`Wiki Informations` }),
|
|
3039
|
+
/* @__PURE__ */ M("ul", { children: [
|
|
3040
|
+
/* @__PURE__ */ M("li", { children: [
|
|
3041
|
+
/* @__PURE__ */ M("strong", { children: [
|
|
3042
|
+
t`Site`,
|
|
3043
|
+
":"
|
|
3044
|
+
] }),
|
|
3045
|
+
" ",
|
|
3046
|
+
this.general.sitename,
|
|
3047
|
+
" (",
|
|
3048
|
+
this.landingPageUrl,
|
|
3049
|
+
")"
|
|
3050
|
+
] }),
|
|
3051
|
+
/* @__PURE__ */ M("li", { children: [
|
|
3052
|
+
/* @__PURE__ */ M("strong", { children: t`User` }),
|
|
3053
|
+
": ",
|
|
3054
|
+
this.userInfo.name,
|
|
3055
|
+
" (ID: ",
|
|
3056
|
+
this.userInfo.id,
|
|
3057
|
+
")"
|
|
3058
|
+
] }),
|
|
3059
|
+
/* @__PURE__ */ M("li", { children: [
|
|
3060
|
+
/* @__PURE__ */ M("strong", { children: t`Groups` }),
|
|
3061
|
+
": ",
|
|
3062
|
+
this.userGroups.join(", ") || "None"
|
|
3063
|
+
] })
|
|
3064
|
+
] }),
|
|
3065
|
+
/* @__PURE__ */ M("div", { children: [
|
|
3066
|
+
/* @__PURE__ */ M("p", { style: { fontStyle: "italic" }, children: t`If the information shown above is incorrect (for example, the user is not you), click the button below.` }),
|
|
3067
|
+
/* @__PURE__ */ M(
|
|
3068
|
+
"button",
|
|
3069
|
+
{
|
|
3070
|
+
className: "btn danger",
|
|
3071
|
+
onClick: async (r) => {
|
|
3072
|
+
r.preventDefault(), await e.serial("clear-cache") || window.location.reload();
|
|
3073
|
+
},
|
|
3074
|
+
children: [
|
|
3075
|
+
"🧹 ",
|
|
3076
|
+
t`Clear caches & Reload`
|
|
3077
|
+
]
|
|
3078
|
+
}
|
|
3079
|
+
)
|
|
3080
|
+
] })
|
|
3081
|
+
] })
|
|
3082
|
+
).role("raw-html")
|
|
3083
|
+
}).description("WikiMetadataService"),
|
|
3084
|
+
"about"
|
|
3085
|
+
);
|
|
3086
|
+
}), this.logger.info("All initialized", this._data);
|
|
3087
|
+
}
|
|
3088
|
+
async initData(e, t = !1) {
|
|
3089
|
+
const r = t ? null : await this.fetchFromCache(e);
|
|
3090
|
+
if (r)
|
|
3091
|
+
return this._data[e] = r, this.logger.debug("Using cached", e, r), r;
|
|
3092
|
+
{
|
|
3093
|
+
const n = await this.fetchFromApi(e);
|
|
3094
|
+
return this.saveToCache(e, n), this._data[e] = n, this.logger.debug("Fetched from API", e, n), n;
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
getCacheKey(e) {
|
|
3098
|
+
return `${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//, "")}`;
|
|
3099
|
+
}
|
|
3100
|
+
async fetchFromApi(e) {
|
|
3101
|
+
return this.api.get({
|
|
3102
|
+
action: "query",
|
|
3103
|
+
...this.QUERY_DATA[e]
|
|
3104
|
+
}).then(({ data: t }) => {
|
|
3105
|
+
if (typeof t?.query != "object" || t.query === null)
|
|
3106
|
+
throw new Error("Invalid query data", { cause: t });
|
|
3107
|
+
return e === "siteinfo" ? t.query : t.query?.[e] || t.query;
|
|
3108
|
+
}).catch((t) => (this.logger.error("Failed to fetch", t), Promise.reject(t)));
|
|
3109
|
+
}
|
|
3110
|
+
async fetchFromCache(e) {
|
|
3111
|
+
const t = this.getCacheKey(e);
|
|
3112
|
+
return await this.CACHE_DB.get(t, this.CACHE_TTL[e]);
|
|
3113
|
+
}
|
|
3114
|
+
async saveToCache(e, t) {
|
|
3115
|
+
const r = this.getCacheKey(e);
|
|
3116
|
+
return this.CACHE_DB.set(r, t);
|
|
3117
|
+
}
|
|
3118
|
+
async invalidateCache(e) {
|
|
3119
|
+
const t = this.getCacheKey(e);
|
|
3120
|
+
return this.CACHE_DB.delete(t);
|
|
3121
|
+
}
|
|
3122
|
+
async onClearCache() {
|
|
3123
|
+
await this.CACHE_DB.clear();
|
|
3124
|
+
}
|
|
3125
|
+
// ====== shortcuts ======
|
|
3126
|
+
get _raw() {
|
|
3127
|
+
return this._data;
|
|
3128
|
+
}
|
|
3129
|
+
// siteInfo
|
|
3130
|
+
get siteInfo() {
|
|
3131
|
+
return this._data.siteinfo;
|
|
3132
|
+
}
|
|
3133
|
+
get general() {
|
|
3134
|
+
return this.siteInfo.general;
|
|
3135
|
+
}
|
|
3136
|
+
get specialPageAliases() {
|
|
3137
|
+
return this.siteInfo.specialpagealiases;
|
|
3138
|
+
}
|
|
3139
|
+
get namespaceAliases() {
|
|
3140
|
+
return this.siteInfo.namespacealiases;
|
|
3141
|
+
}
|
|
3142
|
+
get namespaces() {
|
|
3143
|
+
return this.siteInfo.namespaces;
|
|
3144
|
+
}
|
|
3145
|
+
get namespaceMap() {
|
|
3146
|
+
const e = Object.values(this.namespaces).map((t) => ({
|
|
3147
|
+
id: t.id,
|
|
3148
|
+
canonical: t.canonical,
|
|
3149
|
+
aliases: this.namespaceAliases.filter((r) => r.id === t.id).map((r) => r.alias)
|
|
3150
|
+
})).sort((t, r) => t.id - r.id);
|
|
3151
|
+
return Reflect.defineProperty(this, "namespaceMap", {
|
|
3152
|
+
get: () => e
|
|
3153
|
+
}), e;
|
|
3154
|
+
}
|
|
3155
|
+
get magicWords() {
|
|
3156
|
+
return this.siteInfo.magicwords;
|
|
3157
|
+
}
|
|
3158
|
+
// userInfo
|
|
3159
|
+
get userInfo() {
|
|
3160
|
+
return this._data.userinfo;
|
|
3161
|
+
}
|
|
3162
|
+
get userOptions() {
|
|
3163
|
+
return this.userInfo.options;
|
|
3164
|
+
}
|
|
3165
|
+
get isUserBlocked() {
|
|
3166
|
+
return this.userInfo.blockedbyid && this.userInfo.blockexpiry && new Date(this.userInfo.blockexpiry).getTime() > Date.now();
|
|
3167
|
+
}
|
|
3168
|
+
get userGroups() {
|
|
3169
|
+
return this.userInfo.groups;
|
|
3170
|
+
}
|
|
3171
|
+
get userRights() {
|
|
3172
|
+
return this.userInfo.rights;
|
|
3173
|
+
}
|
|
3174
|
+
// fileRepoInfo
|
|
3175
|
+
get fileRepos() {
|
|
3176
|
+
return this.siteInfo.repos || [];
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Base URL, without trailing slash
|
|
3180
|
+
* @example "https://mediawiki.org"
|
|
3181
|
+
*/
|
|
3182
|
+
get baseUrl() {
|
|
3183
|
+
const e = this.general.server;
|
|
3184
|
+
return e.startsWith("//") ? `${window?.location?.protocol || "https:"}//${e.slice(2)}` : e;
|
|
3185
|
+
}
|
|
3186
|
+
/**
|
|
3187
|
+
* Home page URL of this wiki
|
|
3188
|
+
* @description Generally same as the Mainpage URL,
|
|
3189
|
+
* but after MediaWiki 1.34,
|
|
3190
|
+
* it can be set to the website root directory.
|
|
3191
|
+
* @example "https://mediawiki.org/wiki/Main_Page" (In most cases)
|
|
3192
|
+
* @example "https://mediawiki.org/" ($wgMainPageIsDomainRoot = true)
|
|
3193
|
+
*/
|
|
3194
|
+
get landingPageUrl() {
|
|
3195
|
+
return this.general.base;
|
|
3196
|
+
}
|
|
3197
|
+
get mainPageName() {
|
|
3198
|
+
return this.general.mainpage;
|
|
3199
|
+
}
|
|
3200
|
+
/**
|
|
3201
|
+
* Exact Mainpage URL of this wiki
|
|
3202
|
+
* @example "https://mediawiki.org/wiki/Main_Page"
|
|
3203
|
+
*/
|
|
3204
|
+
get mainPageUrl() {
|
|
3205
|
+
return this.getUrl(this.mainPageName);
|
|
3206
|
+
}
|
|
3207
|
+
/**
|
|
3208
|
+
* Article path, with the $1 placeholder
|
|
3209
|
+
* @example "/wiki/$1"
|
|
3210
|
+
*/
|
|
3211
|
+
get articlePath() {
|
|
3212
|
+
return this.general.articlepath;
|
|
3213
|
+
}
|
|
3214
|
+
/**
|
|
3215
|
+
* Script path, without trailing slash
|
|
3216
|
+
* @example "/w"
|
|
3217
|
+
*/
|
|
3218
|
+
get scriptPath() {
|
|
3219
|
+
return this.general.scriptpath;
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* Article base URL, with the $1 placeholder
|
|
3223
|
+
* @example "https://mediawiki.org/wiki/$1"
|
|
3224
|
+
*/
|
|
3225
|
+
get articleBaseUrl() {
|
|
3226
|
+
return `${this.baseUrl}${this.articlePath}`;
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Script base URL, without trailing slash
|
|
3230
|
+
* @example "https://mediawiki.org/w"
|
|
3231
|
+
*/
|
|
3232
|
+
get scriptBaseUrl() {
|
|
3233
|
+
return `${this.baseUrl}${this.scriptPath}`;
|
|
3234
|
+
}
|
|
3235
|
+
// utils
|
|
3236
|
+
getSciprtUrl(e = "index") {
|
|
3237
|
+
return `${this.scriptBaseUrl}/${e.replace(/\.php$/, "")}.php`;
|
|
3238
|
+
}
|
|
3239
|
+
/** Get mainpage URL */
|
|
3240
|
+
getMainpageUrl(e) {
|
|
3241
|
+
return Ft(this.siteInfo.general.base, e).toString();
|
|
3242
|
+
}
|
|
3243
|
+
getUrl(e, t) {
|
|
3244
|
+
const r = Ut(t);
|
|
3245
|
+
let n;
|
|
3246
|
+
return typeof e == "string" && e !== "" ? n = new URL(`${this.articleBaseUrl.replace("$1", e)}`) : typeof e == "number" ? (r.set("curid", e.toString()), n = new URL(this.getSciprtUrl("index"))) : n = new URL(this.getSciprtUrl("index")), n.search = r.toString(), n.toString();
|
|
3247
|
+
}
|
|
3248
|
+
hasRight(e) {
|
|
3249
|
+
return this.userRights.includes(e);
|
|
3250
|
+
}
|
|
3251
|
+
hasAnyRight(...e) {
|
|
3252
|
+
return e.some((t) => this.hasRight(t));
|
|
3253
|
+
}
|
|
3254
|
+
hasEveryRights(...e) {
|
|
3255
|
+
return e.every((t) => this.hasRight(t));
|
|
3256
|
+
}
|
|
3257
|
+
inGroup(e) {
|
|
3258
|
+
return this.userGroups.includes(e);
|
|
3259
|
+
}
|
|
3260
|
+
inAnyGroup(...e) {
|
|
3261
|
+
return this.userGroups.some((t) => e.includes(t));
|
|
3262
|
+
}
|
|
3263
|
+
getBlockInfo() {
|
|
3264
|
+
return this.isUserBlocked ? {
|
|
3265
|
+
blockid: this.userInfo.blockid,
|
|
3266
|
+
blockedby: this.userInfo.blockedbyid,
|
|
3267
|
+
blockedbyid: this.userInfo.blockedbyid,
|
|
3268
|
+
blockreason: this.userInfo.blockreason,
|
|
3269
|
+
blockedtimestamp: this.userInfo.blockedtimestamp,
|
|
3270
|
+
blockexpiry: this.userInfo.blockexpiry
|
|
3271
|
+
} : null;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
Je = Yr(Wt);
|
|
3275
|
+
pe = tn(Je, 0, "WikiMetadataService", Ht, pe);
|
|
3276
|
+
en(Je, 1, pe);
|
|
3277
|
+
const rn = (() => {
|
|
3278
|
+
const i = /* @__PURE__ */ Symbol.for("IPE.GlobalMemoryStorage");
|
|
3279
|
+
return i in globalThis || (globalThis[i] = xi()), globalThis[i];
|
|
3280
|
+
})();
|
|
3281
|
+
class nn {
|
|
3282
|
+
constructor(e, t, r = 1 / 0, n, s = "localStorage") {
|
|
3283
|
+
this.dbName = e, this.storeName = t, this.ttl = r, this.version = n, this.engine = s, typeof r != "number" && (this.ttl = Number(r)), (isNaN(this.ttl) || this.ttl <= 0) && (this.ttl = 1 / 0), this.engine === "localStorage" && "localStorage" in window ? this.db = window.localStorage : this.engine === "sessionStorage" && "sessionStorage" in window ? this.db = window.sessionStorage : this.db = rn;
|
|
3284
|
+
}
|
|
3285
|
+
// Key builder
|
|
3286
|
+
makeKey(e) {
|
|
3287
|
+
return `${this.dbName ? this.dbName + ":" : ""}${this.storeName ? this.storeName + "/" : ""}${e}`;
|
|
3288
|
+
}
|
|
3289
|
+
// Internal load & validation
|
|
3290
|
+
load(e) {
|
|
3291
|
+
const t = this.getRaw(e);
|
|
3292
|
+
if (t === null) return null;
|
|
3293
|
+
let r;
|
|
3294
|
+
try {
|
|
3295
|
+
r = JSON.parse(t);
|
|
3296
|
+
} catch {
|
|
3297
|
+
return this.deleteSync(e), null;
|
|
3298
|
+
}
|
|
3299
|
+
const n = r;
|
|
3300
|
+
return typeof n.time != "number" || !("value" in n) ? (this.deleteSync(e), null) : typeof this.version < "u" && typeof this.version < "u" && n.version !== this.version ? (this.deleteSync(e), null) : n;
|
|
3301
|
+
}
|
|
3302
|
+
getRaw(e) {
|
|
3303
|
+
const t = this.makeKey(e);
|
|
3304
|
+
return this.db.getItem(t);
|
|
3305
|
+
}
|
|
3306
|
+
setRaw(e, t) {
|
|
3307
|
+
const r = this.makeKey(e);
|
|
3308
|
+
try {
|
|
3309
|
+
this.db.setItem(r, t);
|
|
3310
|
+
} catch {
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
deleteSync(e) {
|
|
3314
|
+
const t = this.makeKey(e);
|
|
3315
|
+
this.db.removeItem(t);
|
|
3316
|
+
}
|
|
3317
|
+
isExpired(e, t = this.ttl) {
|
|
3318
|
+
return e ? Date.now() - e.time > t : !1;
|
|
3319
|
+
}
|
|
3320
|
+
async get(e, t = this.ttl, r) {
|
|
3321
|
+
const n = this.load(e), s = this.isExpired(n, t);
|
|
3322
|
+
if (!n || s) {
|
|
3323
|
+
if (typeof r == "function") {
|
|
3324
|
+
const o = await r();
|
|
3325
|
+
return await this.set(e, o), o;
|
|
3326
|
+
}
|
|
3327
|
+
return null;
|
|
3328
|
+
}
|
|
3329
|
+
return n.value;
|
|
3330
|
+
}
|
|
3331
|
+
async set(e, t) {
|
|
3332
|
+
const r = Date.now();
|
|
3333
|
+
if (typeof e == "string") {
|
|
3334
|
+
const o = e, a = t;
|
|
3335
|
+
if (a === null || typeof a > "u") {
|
|
3336
|
+
await this.delete(o);
|
|
3337
|
+
return;
|
|
3338
|
+
}
|
|
3339
|
+
const f = { time: r, value: a, version: this.version };
|
|
3340
|
+
return this.setRaw(o, JSON.stringify(f)), f;
|
|
3341
|
+
}
|
|
3342
|
+
const n = e, s = {};
|
|
3343
|
+
for (const [o, a] of Object.entries(n)) {
|
|
3344
|
+
if (a === null || typeof a > "u") {
|
|
3345
|
+
this.deleteSync(o);
|
|
3346
|
+
continue;
|
|
3347
|
+
}
|
|
3348
|
+
const f = { time: r, value: a, version: this.version };
|
|
3349
|
+
this.setRaw(o, JSON.stringify(f)), s[o] = f;
|
|
3350
|
+
}
|
|
3351
|
+
return s;
|
|
3352
|
+
}
|
|
3353
|
+
async has(e, t = this.ttl) {
|
|
3354
|
+
const r = this.load(e);
|
|
3355
|
+
return r !== null && !this.isExpired(r, t);
|
|
3356
|
+
}
|
|
3357
|
+
async delete(e) {
|
|
3358
|
+
this.deleteSync(e);
|
|
3359
|
+
}
|
|
3360
|
+
async updatedAt(e) {
|
|
3361
|
+
const t = this.load(e);
|
|
3362
|
+
return t ? t.time : 0;
|
|
3363
|
+
}
|
|
3364
|
+
async clear() {
|
|
3365
|
+
const e = this.makeKey(""), t = [];
|
|
3366
|
+
for (let r = 0; r < this.db.length; r++) {
|
|
3367
|
+
const n = this.db.key(r);
|
|
3368
|
+
n && n.startsWith(e) && t.push(n);
|
|
3369
|
+
}
|
|
3370
|
+
for (const r of t) this.db.removeItem(r);
|
|
3371
|
+
return this;
|
|
3372
|
+
}
|
|
3373
|
+
// Async generators
|
|
3374
|
+
async *keys() {
|
|
3375
|
+
const e = this.makeKey("");
|
|
3376
|
+
for (let t = 0; t < this.db.length; t++) {
|
|
3377
|
+
const r = this.db.key(t);
|
|
3378
|
+
r && r.startsWith(e) && (yield r.slice(e.length));
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
async *values() {
|
|
3382
|
+
for await (const e of this.keys()) {
|
|
3383
|
+
const t = this.load(e);
|
|
3384
|
+
if (t) {
|
|
3385
|
+
if (this.isExpired(t)) {
|
|
3386
|
+
this.deleteSync(e);
|
|
3387
|
+
continue;
|
|
3388
|
+
}
|
|
3389
|
+
yield t;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
async *entries() {
|
|
3394
|
+
for await (const e of this.keys()) {
|
|
3395
|
+
const t = this.load(e);
|
|
3396
|
+
if (t) {
|
|
3397
|
+
if (this.isExpired(t)) {
|
|
3398
|
+
this.deleteSync(e);
|
|
3399
|
+
continue;
|
|
3400
|
+
}
|
|
3401
|
+
yield [e, t];
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
var L;
|
|
3407
|
+
((i) => {
|
|
3408
|
+
i.cache = /* @__PURE__ */ new Map(), i.defaults = Object.freeze({ iterBatch: 100, retry: { attempts: 3, baseDelayMs: 16 } }), i.sleep = (u) => new Promise((p) => setTimeout(p, u));
|
|
3409
|
+
function e(u) {
|
|
3410
|
+
const p = u?.name ?? "";
|
|
3411
|
+
return p === "AbortError" || p === "InvalidStateError" || p === "TransactionInactiveError" || p === "UnknownError";
|
|
3412
|
+
}
|
|
3413
|
+
i.shouldReconnect = e;
|
|
3414
|
+
async function t(u, p, y) {
|
|
3415
|
+
const _ = Math.max(1, u.attempts);
|
|
3416
|
+
for (let g = 0; g < _; g++)
|
|
3417
|
+
try {
|
|
3418
|
+
return await p(g);
|
|
3419
|
+
} catch (w) {
|
|
3420
|
+
if (g === _ - 1) throw w;
|
|
3421
|
+
await y?.(w, g);
|
|
3422
|
+
const O = u.baseDelayMs * Math.pow(2, g) + Math.floor(Math.random() * 10);
|
|
3423
|
+
await (0, i.sleep)(O);
|
|
3424
|
+
}
|
|
3425
|
+
throw new Error("withRetry exhausted unexpectedly");
|
|
3426
|
+
}
|
|
3427
|
+
i.withRetry = t;
|
|
3428
|
+
function r(u, p, y) {
|
|
3429
|
+
return new Promise((_, g) => {
|
|
3430
|
+
const w = indexedDB.open(u, p);
|
|
3431
|
+
w.onupgradeneeded = () => {
|
|
3432
|
+
try {
|
|
3433
|
+
const O = w.result, C = w.transaction;
|
|
3434
|
+
y?.(O, C);
|
|
3435
|
+
} catch (O) {
|
|
3436
|
+
g(O);
|
|
3437
|
+
}
|
|
3438
|
+
}, w.onerror = () => g(w.error), w.onblocked = () => {
|
|
3439
|
+
}, w.onsuccess = () => {
|
|
3440
|
+
const O = w.result;
|
|
3441
|
+
O.onversionchange = () => {
|
|
3442
|
+
try {
|
|
3443
|
+
O.close();
|
|
3444
|
+
} finally {
|
|
3445
|
+
i.cache.delete(u);
|
|
3446
|
+
}
|
|
3447
|
+
}, _(O);
|
|
3448
|
+
};
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
async function n(u, p, y) {
|
|
3452
|
+
let _ = !u.objectStoreNames.contains(p), g = [];
|
|
3453
|
+
if (!_ && y?.indexes?.length) {
|
|
3454
|
+
const C = u.transaction(p, "readonly"), l = C.objectStore(p), c = new Set(Array.from(l.indexNames));
|
|
3455
|
+
g = (y.indexes || []).filter((h) => !c.has(h.name)), await new Promise((h, d) => {
|
|
3456
|
+
C.oncomplete = () => h(), C.onabort = () => d(C.error), C.onerror = () => d(C.error);
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
if (!_ && g.length === 0) return u;
|
|
3460
|
+
const w = u.version + 1;
|
|
3461
|
+
u.close();
|
|
3462
|
+
const O = await r(u.name, w, (C, l) => {
|
|
3463
|
+
let c;
|
|
3464
|
+
C.objectStoreNames.contains(p) ? c = l.objectStore(p) : c = C.createObjectStore(p, {
|
|
3465
|
+
keyPath: y?.keyPath ?? void 0,
|
|
3466
|
+
autoIncrement: !!y?.autoIncrement
|
|
3467
|
+
});
|
|
3468
|
+
for (const h of g)
|
|
3469
|
+
c.indexNames.contains(h.name) || c.createIndex(h.name, h.keyPath, h.options);
|
|
3470
|
+
});
|
|
3471
|
+
return O.onversionchange = () => {
|
|
3472
|
+
try {
|
|
3473
|
+
O.close();
|
|
3474
|
+
} finally {
|
|
3475
|
+
i.cache.delete(O.name);
|
|
3476
|
+
}
|
|
3477
|
+
}, O;
|
|
3478
|
+
}
|
|
3479
|
+
async function s(u, p, y) {
|
|
3480
|
+
let _ = i.cache.get(u);
|
|
3481
|
+
return _ ? (_ = _.then((g) => n(g, p, y)), i.cache.set(u, _)) : (_ = (async () => {
|
|
3482
|
+
const g = await r(u);
|
|
3483
|
+
return n(g, p, y);
|
|
3484
|
+
})(), i.cache.set(u, _)), _;
|
|
3485
|
+
}
|
|
3486
|
+
i.getDB = s;
|
|
3487
|
+
async function o(u) {
|
|
3488
|
+
const p = i.cache.get(u);
|
|
3489
|
+
if (i.cache.delete(u), p)
|
|
3490
|
+
try {
|
|
3491
|
+
(await p).close();
|
|
3492
|
+
} catch {
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
i.closeConnection = o;
|
|
3496
|
+
function a(u) {
|
|
3497
|
+
return new Promise((p, y) => {
|
|
3498
|
+
u.onsuccess = () => p(u.result), u.onerror = () => y(u.error);
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
i.asyncRequest = a;
|
|
3502
|
+
function f(u) {
|
|
3503
|
+
return new Promise((p, y) => {
|
|
3504
|
+
u.oncomplete = () => p(), u.onabort = () => y(u.error ?? new DOMException("Aborted", "AbortError")), u.onerror = () => y(u.error ?? new DOMException("TransactionError", "UnknownError"));
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
i.waitTx = f;
|
|
3508
|
+
})(L || (L = {}));
|
|
3509
|
+
class sn {
|
|
3510
|
+
constructor(e, t, r = {}) {
|
|
3511
|
+
this.dbName = e, this.storeName = t, this.options = r;
|
|
3512
|
+
}
|
|
3513
|
+
get _iterBatch() {
|
|
3514
|
+
return this.options.iterBatch ?? L.defaults.iterBatch;
|
|
3515
|
+
}
|
|
3516
|
+
get _retryCfg() {
|
|
3517
|
+
const e = this.options.retry ?? L.defaults.retry;
|
|
3518
|
+
return { attempts: e.attempts ?? 3, baseDelayMs: e.baseDelayMs ?? 16 };
|
|
3519
|
+
}
|
|
3520
|
+
async _withStore(e, t) {
|
|
3521
|
+
const r = this._retryCfg;
|
|
3522
|
+
return L.withRetry(
|
|
3523
|
+
r,
|
|
3524
|
+
async () => {
|
|
3525
|
+
const n = await L.getDB(this.dbName, this.storeName, this.options.ensure);
|
|
3526
|
+
try {
|
|
3527
|
+
const s = n.transaction(this.storeName, e), o = s.objectStore(this.storeName), a = await t(o);
|
|
3528
|
+
return await L.waitTx(s), a;
|
|
3529
|
+
} catch (s) {
|
|
3530
|
+
throw s;
|
|
3531
|
+
}
|
|
3532
|
+
},
|
|
3533
|
+
async (n) => {
|
|
3534
|
+
L.shouldReconnect(n) && await L.closeConnection(this.dbName);
|
|
3535
|
+
}
|
|
3536
|
+
);
|
|
3537
|
+
}
|
|
3538
|
+
async get(e) {
|
|
3539
|
+
return this._withStore("readonly", async (t) => {
|
|
3540
|
+
const r = await L.asyncRequest(t.get(e));
|
|
3541
|
+
return r === void 0 ? void 0 : r;
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
async set(e, t) {
|
|
3545
|
+
return await this._withStore("readwrite", async (r) => {
|
|
3546
|
+
const n = this.options.ensure?.keyPath != null ? r.put(t) : r.put(t, e);
|
|
3547
|
+
await L.asyncRequest(n);
|
|
3548
|
+
}), this;
|
|
3549
|
+
}
|
|
3550
|
+
async delete(e) {
|
|
3551
|
+
return this._withStore("readwrite", async (t) => {
|
|
3552
|
+
const r = await L.asyncRequest(t.get(e)) !== void 0;
|
|
3553
|
+
return await L.asyncRequest(t.delete(e)), r;
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3556
|
+
async clear() {
|
|
3557
|
+
await this._withStore("readwrite", async (e) => {
|
|
3558
|
+
await L.asyncRequest(e.clear());
|
|
3559
|
+
});
|
|
3560
|
+
}
|
|
3561
|
+
async has(e) {
|
|
3562
|
+
return await this.get(e) !== void 0;
|
|
3563
|
+
}
|
|
3564
|
+
async count() {
|
|
3565
|
+
return this._withStore("readonly", async (e) => await L.asyncRequest(e.count()) ?? 0);
|
|
3566
|
+
}
|
|
3567
|
+
async *_iterateEntries() {
|
|
3568
|
+
let e = null, t = !1;
|
|
3569
|
+
const r = Math.max(1, this._iterBatch);
|
|
3570
|
+
for (; !t; ) {
|
|
3571
|
+
const n = await this._withStore("readonly", async (s) => {
|
|
3572
|
+
const o = [], a = e === null ? void 0 : IDBKeyRange.lowerBound(e, !0);
|
|
3573
|
+
return await new Promise((f, u) => {
|
|
3574
|
+
const p = s.openCursor(a);
|
|
3575
|
+
p.onerror = () => u(p.error), p.onsuccess = () => {
|
|
3576
|
+
const y = p.result;
|
|
3577
|
+
if (!y) {
|
|
3578
|
+
t = !0, f();
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
o.push([y.key, y.value]), e = y.key, o.length >= r ? f() : y.continue();
|
|
3582
|
+
};
|
|
3583
|
+
}), o;
|
|
3584
|
+
});
|
|
3585
|
+
for (const s of n) yield s;
|
|
3586
|
+
if (n.length === 0) break;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
entries() {
|
|
3590
|
+
return this._iterateEntries();
|
|
3591
|
+
}
|
|
3592
|
+
async *keys() {
|
|
3593
|
+
for await (const [e] of this.entries()) yield e;
|
|
3594
|
+
}
|
|
3595
|
+
async *values() {
|
|
3596
|
+
for await (const [, e] of this.entries()) yield e;
|
|
3597
|
+
}
|
|
3598
|
+
[Symbol.asyncIterator]() {
|
|
3599
|
+
return this.entries()[Symbol.asyncIterator]();
|
|
3600
|
+
}
|
|
3601
|
+
async forEach(e) {
|
|
3602
|
+
for await (const [t, r] of this.entries())
|
|
3603
|
+
await e(r, t, this);
|
|
3604
|
+
}
|
|
3605
|
+
async getMany(e) {
|
|
3606
|
+
const t = /* @__PURE__ */ new Map();
|
|
3607
|
+
for await (const r of e) t.set(r, void 0);
|
|
3608
|
+
return await this._withStore("readonly", async (r) => {
|
|
3609
|
+
await Promise.all(
|
|
3610
|
+
t.keys().map(async (n) => {
|
|
3611
|
+
const s = await L.asyncRequest(r.get(n));
|
|
3612
|
+
t.set(n, s === void 0 ? void 0 : s);
|
|
3613
|
+
})
|
|
3614
|
+
);
|
|
3615
|
+
}), t;
|
|
3616
|
+
}
|
|
3617
|
+
async setMany(e) {
|
|
3618
|
+
const t = this.options.ensure?.keyPath != null;
|
|
3619
|
+
return await this._withStore("readwrite", async (r) => {
|
|
3620
|
+
for await (const [n, s] of e) {
|
|
3621
|
+
const o = t ? r.put(s) : r.put(s, n);
|
|
3622
|
+
await L.asyncRequest(o);
|
|
3623
|
+
}
|
|
3624
|
+
}), this;
|
|
3625
|
+
}
|
|
3626
|
+
async deleteMany(e) {
|
|
3627
|
+
let t = 0;
|
|
3628
|
+
return await this._withStore("readwrite", async (r) => {
|
|
3629
|
+
for await (const n of e)
|
|
3630
|
+
await L.asyncRequest(r.get(n)) !== void 0 && t++, await L.asyncRequest(r.delete(n));
|
|
3631
|
+
}), t;
|
|
3632
|
+
}
|
|
3633
|
+
async disconnect() {
|
|
3634
|
+
await L.closeConnection(this.dbName);
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
class on {
|
|
3638
|
+
constructor(e, t, r = 1 / 0, n) {
|
|
3639
|
+
this.dbName = e, this.storeName = t, this.ttl = r, this.version = n, this.db = new sn(e, t), this.keys = this.db.keys.bind(this.db), this.values = this.db.values.bind(this.db), this.entries = this.db.entries.bind(this.db), typeof this.ttl != "number" && (this.ttl = Number(this.ttl)), (isNaN(this.ttl) || this.ttl <= 0) && (this.ttl = 1 / 0), this._clearExpiredEntries().catch(() => {
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
async _clearExpiredEntries() {
|
|
3643
|
+
if (this.ttl === 1 / 0) return;
|
|
3644
|
+
const e = Date.now(), t = [];
|
|
3645
|
+
for await (const [r, n] of this.db.entries())
|
|
3646
|
+
typeof n.time == "number" && e - n.time > this.ttl && t.push(r);
|
|
3647
|
+
t.length > 0 && await this.db.deleteMany(t);
|
|
3648
|
+
}
|
|
3649
|
+
async get(e, t = this.ttl, r) {
|
|
3650
|
+
const n = await this.loadFromDB(e), s = this.checkIfExpired(n, t);
|
|
3651
|
+
if (!n || s) {
|
|
3652
|
+
if (typeof r == "function") {
|
|
3653
|
+
const o = await r();
|
|
3654
|
+
return await this.set(e, o), o;
|
|
3655
|
+
}
|
|
3656
|
+
return null;
|
|
3657
|
+
}
|
|
3658
|
+
return n.value;
|
|
3659
|
+
}
|
|
3660
|
+
async set(e, t) {
|
|
3661
|
+
const r = Date.now();
|
|
3662
|
+
if (typeof e == "string") {
|
|
3663
|
+
const f = e, u = t;
|
|
3664
|
+
if (u === null || typeof u > "u")
|
|
3665
|
+
return this.delete(f);
|
|
3666
|
+
const p = {
|
|
3667
|
+
time: r,
|
|
3668
|
+
value: u,
|
|
3669
|
+
version: this.version
|
|
3670
|
+
};
|
|
3671
|
+
return await this.db.set(f, p), p;
|
|
3672
|
+
}
|
|
3673
|
+
const n = e, s = [], o = [], a = {};
|
|
3674
|
+
for (const [f, u] of Object.entries(n))
|
|
3675
|
+
if (u === null || typeof u > "u")
|
|
3676
|
+
o.push(f);
|
|
3677
|
+
else {
|
|
3678
|
+
const p = { time: r, value: u, version: this.version };
|
|
3679
|
+
s.push([f, p]), a[f] = p;
|
|
3680
|
+
}
|
|
3681
|
+
return s.length > 0 && await this.db.setMany(s), o.length > 0 && await this.db.deleteMany(o), a;
|
|
3682
|
+
}
|
|
3683
|
+
async has(e, t = this.ttl) {
|
|
3684
|
+
const r = await this.loadFromDB(e), n = this.checkIfExpired(r, t);
|
|
3685
|
+
return r !== null && !n;
|
|
3686
|
+
}
|
|
3687
|
+
async delete(e) {
|
|
3688
|
+
await this.db.delete(e);
|
|
3689
|
+
}
|
|
3690
|
+
async updatedAt(e) {
|
|
3691
|
+
const t = await this.loadFromDB(e);
|
|
3692
|
+
return t ? t.time : 0;
|
|
3693
|
+
}
|
|
3694
|
+
async loadFromDB(e) {
|
|
3695
|
+
const t = await this.db.get(e);
|
|
3696
|
+
if (t === void 0)
|
|
3697
|
+
return null;
|
|
3698
|
+
if (typeof t.time != "number" || typeof t.value > "u") {
|
|
3699
|
+
try {
|
|
3700
|
+
await this.delete(e);
|
|
3701
|
+
} catch {
|
|
3702
|
+
}
|
|
3703
|
+
return null;
|
|
3704
|
+
}
|
|
3705
|
+
if (typeof this.version < "u" && typeof this.version < "u" && t.version !== this.version) {
|
|
3706
|
+
try {
|
|
3707
|
+
await this.delete(e);
|
|
3708
|
+
} catch {
|
|
3709
|
+
}
|
|
3710
|
+
return null;
|
|
3711
|
+
}
|
|
3712
|
+
return t;
|
|
3713
|
+
}
|
|
3714
|
+
checkIfExpired(e, t = this.ttl) {
|
|
3715
|
+
return e ? Date.now() - e.time > t : !1;
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* [DANGER] Use with caution!
|
|
3719
|
+
* Delete all data from the database.
|
|
3720
|
+
*/
|
|
3721
|
+
async clear() {
|
|
3722
|
+
return await this.db.clear(), this;
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
class an extends z {
|
|
3726
|
+
constructor(e, t) {
|
|
3727
|
+
super(e, "storage", !1), this.config = t, this.kv = this.createDatabase("key-val", 0, 1, "indexedDB"), this.simpleKV = this.createDatabase("~", 0, 1, "localStorage"), this.memoryKV = this.createDatabase("~", 0, 1, "memory");
|
|
3728
|
+
}
|
|
3729
|
+
createDatabase(e, t, r, n = "indexedDB") {
|
|
3730
|
+
const s = "indexedDB" in window && window.indexedDB !== null;
|
|
3731
|
+
switch (n === "indexedDB" && !s && (n = "localStorage"), n) {
|
|
3732
|
+
case "indexedDB":
|
|
3733
|
+
return new on(this.config.dbName, e, t, r);
|
|
3734
|
+
case "localStorage":
|
|
3735
|
+
case "sessionStorage":
|
|
3736
|
+
case "memory":
|
|
3737
|
+
return new nn(this.config.dbName, e, t, r, n);
|
|
3738
|
+
default:
|
|
3739
|
+
throw new Error(`Unsupported storage engine: ${n}`);
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
function Gt(i) {
|
|
3744
|
+
return function(e) {
|
|
3745
|
+
return e.PreferencesSchema = i, e;
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
var cn = Object.create, Ye = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, Vt = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), Jt = (i) => {
|
|
3749
|
+
throw TypeError(i);
|
|
3750
|
+
}, hn = (i, e, t) => e in i ? Ye(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, un = (i, e) => Ye(i, "name", { value: e, configurable: !0 }), fn = (i) => [, , , cn(i?.[Vt("metadata")] ?? null)], dn = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Yt = (i) => i !== void 0 && typeof i != "function" ? Jt("Function expected") : i, pn = (i, e, t, r, n) => ({ kind: dn[i], name: e, metadata: r, addInitializer: (s) => t._ ? Jt("Already initialized") : n.push(Yt(s || null)) }), gn = (i, e) => hn(e, Vt("metadata"), i[3]), mn = (i, e, t, r) => {
|
|
3751
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
3752
|
+
return r;
|
|
3753
|
+
}, yn = (i, e, t, r, n, s) => {
|
|
3754
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && ln(n, t));
|
|
3755
|
+
un(n, t);
|
|
3756
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
3757
|
+
f = pn(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, Yt(o) && (n = o);
|
|
3758
|
+
return gn(i, n), g && Ye(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
3759
|
+
}, Xt, Xe, Qt;
|
|
3760
|
+
Xt = [F(["preferences"]), Gt(
|
|
3761
|
+
$.object({
|
|
3762
|
+
theme: $.union([
|
|
3763
|
+
$.const("auto").description("Follow system"),
|
|
3764
|
+
$.const("light").description("Light mode"),
|
|
3765
|
+
$.const("dark").description("Dark mode"),
|
|
3766
|
+
$.const("fandom").description("Follow Fandom")
|
|
3767
|
+
]).default("auto").description("Theme preference")
|
|
3768
|
+
}).description("Theme settings").extra("category", "general")
|
|
3769
|
+
)];
|
|
3770
|
+
class ge extends (Qt = z) {
|
|
3771
|
+
constructor(e) {
|
|
3772
|
+
super(e, "theme", !1), this.ctx = e, this._mediaQueryList = null, this._observer = null, this._handleSystemThemeChange = this._onSystemThemeChange.bind(this), this._handleBodyClassChange = this._onBodyClassChange.bind(this);
|
|
3773
|
+
}
|
|
3774
|
+
async start() {
|
|
3775
|
+
this._mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)"), this._mediaQueryList.addEventListener("change", this._handleSystemThemeChange), this._observer = new MutationObserver(this._handleBodyClassChange), await this.applyTheme(), this.ctx.on("preferences/changed", async ({ changes: e }) => {
|
|
3776
|
+
"theme" in e && await this.applyTheme();
|
|
3777
|
+
});
|
|
3778
|
+
}
|
|
3779
|
+
stop() {
|
|
3780
|
+
this._mediaQueryList && this._mediaQueryList.removeEventListener("change", this._handleSystemThemeChange), this._observer?.disconnect();
|
|
3781
|
+
}
|
|
3782
|
+
async _onSystemThemeChange() {
|
|
3783
|
+
await this.applyTheme();
|
|
3784
|
+
}
|
|
3785
|
+
async _onBodyClassChange() {
|
|
3786
|
+
await this.applyTheme();
|
|
3787
|
+
}
|
|
3788
|
+
async applyTheme() {
|
|
3789
|
+
const e = await this.ctx.preferences.get("theme") || "auto";
|
|
3790
|
+
this.updateFandomObserver(e);
|
|
3791
|
+
const t = this.getTheme(e);
|
|
3792
|
+
this.applyThemeClass(t), this.ctx.emit("theme/changed", { ctx: this.ctx, theme: t });
|
|
3793
|
+
}
|
|
3794
|
+
// don't run observer unless using fandom option
|
|
3795
|
+
updateFandomObserver(e) {
|
|
3796
|
+
e === "fandom" ? this._observer?.observe(document.body, {
|
|
3797
|
+
attributes: !0,
|
|
3798
|
+
attributeFilter: ["class"]
|
|
3799
|
+
}) : this._observer?.disconnect();
|
|
3800
|
+
}
|
|
3801
|
+
getTheme(e) {
|
|
3802
|
+
if (e === "auto")
|
|
3803
|
+
return this._mediaQueryList?.matches ? "dark" : "light";
|
|
3804
|
+
if (e === "fandom") {
|
|
3805
|
+
const t = document.body;
|
|
3806
|
+
return t.classList.contains("theme-fandomdesktop-dark") || t.classList.contains("theme-fandommobile-dark") ? "dark" : "light";
|
|
3807
|
+
}
|
|
3808
|
+
return e;
|
|
3809
|
+
}
|
|
3810
|
+
applyThemeClass(e) {
|
|
3811
|
+
const t = document.body;
|
|
3812
|
+
e === "dark" ? (t.classList.add("ipe-theme-dark"), t.setAttribute("data-ipe-theme", "dark")) : (t.classList.remove("ipe-theme-dark"), t.setAttribute("data-ipe-theme", "light"));
|
|
3813
|
+
}
|
|
3814
|
+
get currentTheme() {
|
|
3815
|
+
return document.body.classList.contains("ipe-theme-dark") ? "dark" : "light";
|
|
3816
|
+
}
|
|
3817
|
+
}
|
|
3818
|
+
Xe = fn(Qt);
|
|
3819
|
+
ge = yn(Xe, 0, "ThemeService", Xt, ge);
|
|
3820
|
+
mn(Xe, 1, ge);
|
|
3821
|
+
class wn extends z {
|
|
3822
|
+
constructor(e) {
|
|
3823
|
+
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage = ki(this.ctx.api);
|
|
3824
|
+
}
|
|
3825
|
+
static {
|
|
3826
|
+
this.inject = ["api"];
|
|
3827
|
+
}
|
|
3828
|
+
async createInstance(e, t = !1) {
|
|
3829
|
+
return await this.WikiPage.newFromApi(e);
|
|
3830
|
+
}
|
|
3831
|
+
async newFromTitle(e, t = !1, r, n = !1) {
|
|
3832
|
+
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: r }, n);
|
|
3833
|
+
}
|
|
3834
|
+
async newFromPageId(e, t, r = !1) {
|
|
3835
|
+
return this.createInstance({ pageids: e, rvsection: t }, r);
|
|
3836
|
+
}
|
|
3837
|
+
async newFromRevision(e, t, r = !1) {
|
|
3838
|
+
return await this.createInstance({ revids: e, rvsection: t }, r);
|
|
3839
|
+
}
|
|
3840
|
+
newBlankPage(e = {}) {
|
|
3841
|
+
return this.WikiPage.newBlankPage(e);
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
class Qe extends z {
|
|
3845
|
+
constructor(e) {
|
|
3846
|
+
super(e, "wikiTitle", !0), this.ctx = e, this.logger = this.ctx.logger("WikiTitleService"), this._cachedTitles = /* @__PURE__ */ new Map(), this.wiki = this.ctx.wiki, this.wikiBaseUrl = this.wiki.baseUrl, this.wikiArticlePath = this.wiki.articlePath.replace("$1", ""), this.wikiArticleBaseUrl = this.wiki.articleBaseUrl.replace("$1", ""), this.wikiIndexPhpUrl = this.wiki.getSciprtUrl("index.php"), this.Title = Si(this.ctx.wiki.siteInfo);
|
|
3847
|
+
}
|
|
3848
|
+
static {
|
|
3849
|
+
this.inject = ["wiki", "wikiPage"];
|
|
3850
|
+
}
|
|
3851
|
+
newTitle(e, t) {
|
|
3852
|
+
return typeof e == "string" ? new this.Title(e, t) : e;
|
|
3853
|
+
}
|
|
3854
|
+
newMainPageTitle() {
|
|
3855
|
+
return this.newTitle(this.ctx.wiki.mainPageName);
|
|
3856
|
+
}
|
|
3857
|
+
async newTitleFromUrl(e) {
|
|
3858
|
+
const t = this.parseWikiLink(e);
|
|
3859
|
+
return t?.title ? t.title : t?.pageId ? this.newTitleFromPageId(t.pageId) : null;
|
|
3860
|
+
}
|
|
3861
|
+
async newTitleFromAnyId(e, t = !1) {
|
|
3862
|
+
const { title: r, pageId: n, revId: s } = e ?? {};
|
|
3863
|
+
if (typeof r == "string")
|
|
3864
|
+
return this.newTitle(r);
|
|
3865
|
+
let o, a;
|
|
3866
|
+
if (s ? (o = parseInt(s.toString(), 10), a = "revid") : n && (o = parseInt(n.toString(), 10), a = "pageid"), !o || !a || isNaN(o) || o <= 0)
|
|
3867
|
+
throw new Error("Invalid id or kind", { cause: e });
|
|
3868
|
+
if (!t && this._cachedTitles.has(`${a}:${o}`))
|
|
3869
|
+
return await this._cachedTitles.get(`${a}:${o}`);
|
|
3870
|
+
const { promise: f, resolve: u, reject: p } = wt();
|
|
3871
|
+
this._cachedTitles.set(`${a}:${o}`, f);
|
|
3872
|
+
try {
|
|
3873
|
+
const { wikiPage: y } = this.ctx;
|
|
3874
|
+
let _ = null;
|
|
3875
|
+
if (a === "pageid")
|
|
3876
|
+
_ = await y.newFromPageId(o);
|
|
3877
|
+
else if (a === "revid")
|
|
3878
|
+
_ = await y.newFromRevision(o);
|
|
3879
|
+
else
|
|
3880
|
+
throw new Error(`Invalid kind: ${a}`);
|
|
3881
|
+
u(this.newTitle(_.title));
|
|
3882
|
+
} catch (y) {
|
|
3883
|
+
this._cachedTitles.delete(`${a}:${o}`), p(y);
|
|
3884
|
+
}
|
|
3885
|
+
return f;
|
|
3886
|
+
}
|
|
3887
|
+
async newTitleFromPageId(e) {
|
|
3888
|
+
return this.newTitleFromAnyId({ pageId: e });
|
|
3889
|
+
}
|
|
3890
|
+
async newTitleFromRevision(e) {
|
|
3891
|
+
return this.newTitleFromAnyId({ revId: e });
|
|
3892
|
+
}
|
|
3893
|
+
/**
|
|
3894
|
+
* Resolve **special** special pages to it's real target
|
|
3895
|
+
*
|
|
3896
|
+
* If target is self or cannot be resolved, return null
|
|
3897
|
+
* @example
|
|
3898
|
+
* ```
|
|
3899
|
+
* Special:MyPage -> User:<username>
|
|
3900
|
+
* Special:Edit/Page_Title -> Page_Title
|
|
3901
|
+
* Special:NewSection/Page_Title -> Page_Title (section=new)
|
|
3902
|
+
* ```
|
|
3903
|
+
*/
|
|
3904
|
+
resolveSpecialPageTarget(e) {
|
|
3905
|
+
const t = typeof e == "string" ? this.newTitle(e) : e;
|
|
3906
|
+
if (!t || t.getNamespaceId() !== -1)
|
|
3907
|
+
return null;
|
|
3908
|
+
let r, n, s = "view";
|
|
3909
|
+
const o = t.getMainDBKey().split("/").slice(1).join("/") || "";
|
|
3910
|
+
if (t.isSpecial("edit") && o)
|
|
3911
|
+
r = o, s = "edit";
|
|
3912
|
+
else if (t.isSpecial("talkpage") && o) {
|
|
3913
|
+
const a = t.newTitle(o).getTalkPage();
|
|
3914
|
+
if (!a)
|
|
3915
|
+
return null;
|
|
3916
|
+
r = a.getPrefixedDBKey();
|
|
3917
|
+
} else if (t.isSpecial("mypage"))
|
|
3918
|
+
r = t.newTitle(this.ctx.wiki.userInfo.name, 2).getPrefixedDBKey() + (o ? `/${o}` : "");
|
|
3919
|
+
else if (t.isSpecial("mytalk"))
|
|
3920
|
+
r = t.newTitle(this.ctx.wiki.userInfo.name, 3).getPrefixedDBKey() + (o ? `/${o}` : "");
|
|
3921
|
+
else if (t.isSpecial("newsection") && o)
|
|
3922
|
+
r = o, n = "new", s = "edit";
|
|
3923
|
+
else
|
|
3924
|
+
return null;
|
|
3925
|
+
return {
|
|
3926
|
+
title: new this.Title(r),
|
|
3927
|
+
section: n,
|
|
3928
|
+
action: s
|
|
3929
|
+
};
|
|
3930
|
+
}
|
|
3931
|
+
isWikiLink(e) {
|
|
3932
|
+
return e.startsWith(this.wikiArticleBaseUrl) || e.startsWith(this.wikiIndexPhpUrl) || // Some servers allow index.php to be omitted
|
|
3933
|
+
e.startsWith(`${this.wikiBaseUrl}/?`) || // It's the landing page
|
|
3934
|
+
e === this.ctx.wiki.landingPageUrl;
|
|
3935
|
+
}
|
|
3936
|
+
static {
|
|
3937
|
+
this.REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i;
|
|
3938
|
+
}
|
|
3939
|
+
validateHrefAttr(e) {
|
|
3940
|
+
return typeof e != "string" ? !1 : !Qe.REG_SKIPPED_HREF.test(e);
|
|
3941
|
+
}
|
|
3942
|
+
parseWikiLink(e) {
|
|
3943
|
+
if (!e || typeof e == "string" && !this.validateHrefAttr(e))
|
|
3944
|
+
return null;
|
|
3945
|
+
const t = Ft(e);
|
|
3946
|
+
if (!this.isWikiLink(t.toString()))
|
|
3947
|
+
return null;
|
|
3948
|
+
const r = t.searchParams, n = t.hash.replace("#", ""), s = r.get("action") || "view", o = r.get("title") || "", a = parseInt(r.get("curid") || "0", 10), f = parseInt(r.get("oldid") || "0", 10);
|
|
3949
|
+
let u = o || (() => {
|
|
3950
|
+
try {
|
|
3951
|
+
return decodeURIComponent(t.pathname.substring(this.wikiArticlePath.length));
|
|
3952
|
+
} catch (g) {
|
|
3953
|
+
return this.logger.error("parseLink", t, g), "";
|
|
3954
|
+
}
|
|
3955
|
+
})();
|
|
3956
|
+
u.endsWith("index.php") && (u = "");
|
|
3957
|
+
let p, y, _;
|
|
3958
|
+
if (f)
|
|
3959
|
+
_ = f;
|
|
3960
|
+
else if (a)
|
|
3961
|
+
y = a;
|
|
3962
|
+
else if (u)
|
|
3963
|
+
p = this.newTitle(u);
|
|
3964
|
+
else if (t.origin + t.pathname === this.ctx.wiki.landingPageUrl)
|
|
3965
|
+
p = this.newMainPageTitle();
|
|
3966
|
+
else
|
|
3967
|
+
return null;
|
|
3968
|
+
return {
|
|
3969
|
+
title: p,
|
|
3970
|
+
pageId: y,
|
|
3971
|
+
revId: _,
|
|
3972
|
+
url: t,
|
|
3973
|
+
params: r,
|
|
3974
|
+
hash: n,
|
|
3975
|
+
action: s
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
const Zt = (i) => typeof i == "function";
|
|
3980
|
+
async function bn(i) {
|
|
3981
|
+
return Zt(i) ? await i() : i;
|
|
3982
|
+
}
|
|
3983
|
+
function gs(i) {
|
|
3984
|
+
return Zt(i) ? i() : i;
|
|
3985
|
+
}
|
|
3986
|
+
var vn = Object.create, Ze = Object.defineProperty, _n = Object.getOwnPropertyDescriptor, ei = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), ti = (i) => {
|
|
3987
|
+
throw TypeError(i);
|
|
3988
|
+
}, xn = (i, e, t) => e in i ? Ze(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, kn = (i, e) => Ze(i, "name", { value: e, configurable: !0 }), Sn = (i) => [, , , vn(i?.[ei("metadata")] ?? null)], $n = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ii = (i) => i !== void 0 && typeof i != "function" ? ti("Function expected") : i, En = (i, e, t, r, n) => ({ kind: $n[i], name: e, metadata: r, addInitializer: (s) => t._ ? ti("Already initialized") : n.push(ii(s || null)) }), Cn = (i, e) => xn(e, ei("metadata"), i[3]), An = (i, e, t, r) => {
|
|
3989
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
3990
|
+
return r;
|
|
3991
|
+
}, On = (i, e, t, r, n, s) => {
|
|
3992
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && _n(n, t));
|
|
3993
|
+
kn(n, t);
|
|
3994
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
3995
|
+
f = En(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, ii(o) && (n = o);
|
|
3996
|
+
return Cn(i, n), g && Ze(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
3997
|
+
}, ri, et, ni;
|
|
3998
|
+
ri = [F(["storage", "wiki"])];
|
|
3999
|
+
class me extends (ni = z) {
|
|
4000
|
+
constructor(e) {
|
|
4001
|
+
super(e, "preferences", !0), this.ctx = e, this.db = void 0, this.customRegistries = [], this.categoryDefinitions = [], this._defaultPreferences = {}, e.set("prefs", this), this.db = e.storage.createDatabase(`preferences:${e.wiki.userInfo.id}`, 1 / 0);
|
|
4002
|
+
try {
|
|
4003
|
+
this._migrageFromLegacyMasterDB();
|
|
4004
|
+
} catch {
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
get logger() {
|
|
4008
|
+
return this.ctx.logger("PREFERENCES");
|
|
4009
|
+
}
|
|
4010
|
+
async start() {
|
|
4011
|
+
}
|
|
4012
|
+
async get(e, t) {
|
|
4013
|
+
if (!e)
|
|
4014
|
+
return this.getAll();
|
|
4015
|
+
t ??= () => {
|
|
4016
|
+
const n = this.defaultOf(e);
|
|
4017
|
+
return this.logger.debug(e, `(fallback value: ${n})`), n;
|
|
4018
|
+
};
|
|
4019
|
+
const r = await this.db.get(e, void 0);
|
|
4020
|
+
return r !== null ? r : await bn(t);
|
|
4021
|
+
}
|
|
4022
|
+
/**
|
|
4023
|
+
* 获取全部注册的配置项以及最终生效的值
|
|
4024
|
+
* 未保存的配置项将使用默认值
|
|
4025
|
+
*/
|
|
4026
|
+
async getAll() {
|
|
4027
|
+
const e = this.loadDefaultConfigs();
|
|
4028
|
+
for await (const [t, r] of this.db.entries())
|
|
4029
|
+
t !== "_touched" && t in e && (e[t] = r.value);
|
|
4030
|
+
return e;
|
|
4031
|
+
}
|
|
4032
|
+
async set(e, t) {
|
|
4033
|
+
return (await this.setMany({ [e]: t }))[e];
|
|
4034
|
+
}
|
|
4035
|
+
async setMany(e) {
|
|
4036
|
+
const t = this.loadDefaultConfigs(), r = {};
|
|
4037
|
+
for (const [n, s] of Object.entries(e))
|
|
4038
|
+
s === t[n] || s === void 0 ? r[n] = void 0 : r[n] = s;
|
|
4039
|
+
return await this.db.set(r), this.ctx.emit("preferences/changed", { ctx: this.ctx, input: e, changes: r }), r;
|
|
4040
|
+
}
|
|
4041
|
+
defaultOf(e) {
|
|
4042
|
+
return this._defaultPreferences[e] ??= this.loadDefaultConfigs()[e];
|
|
4043
|
+
}
|
|
4044
|
+
/**
|
|
4045
|
+
* Get exportable configurations
|
|
4046
|
+
* - exclude values that are the same as the default value
|
|
4047
|
+
* - exclude invalid or undefined values
|
|
4048
|
+
* - sort by keys
|
|
4049
|
+
*/
|
|
4050
|
+
async getExportableRecord(e) {
|
|
4051
|
+
e ??= await this.getAll();
|
|
4052
|
+
const t = this.loadDefaultConfigs(), r = {};
|
|
4053
|
+
return Object.entries(t).sort(([n], [s]) => n.localeCompare(s)).forEach(([n, s]) => {
|
|
4054
|
+
const o = e[n];
|
|
4055
|
+
o !== void 0 && o !== s && (r[n] = o);
|
|
4056
|
+
}), r;
|
|
4057
|
+
}
|
|
4058
|
+
loadDefaultConfigs() {
|
|
4059
|
+
const e = {};
|
|
4060
|
+
return this.getConfigRegistries().forEach((t) => {
|
|
4061
|
+
try {
|
|
4062
|
+
const r = t.schema({});
|
|
4063
|
+
Object.entries(r).forEach(([n, s]) => {
|
|
4064
|
+
e[n] = s;
|
|
4065
|
+
});
|
|
4066
|
+
} catch {
|
|
4067
|
+
}
|
|
4068
|
+
}), Object.entries(e).forEach(([t, r]) => {
|
|
4069
|
+
this._defaultPreferences[t] = r;
|
|
4070
|
+
}), e;
|
|
4071
|
+
}
|
|
4072
|
+
registerCustomConfig(e, t, r) {
|
|
4073
|
+
const n = {
|
|
4074
|
+
name: e,
|
|
4075
|
+
schema: t,
|
|
4076
|
+
category: r || "general"
|
|
4077
|
+
}, s = this.customRegistries.findIndex((o) => o.name === e);
|
|
4078
|
+
return s >= 0 ? this.customRegistries[s] = n : this.customRegistries.push(n), this;
|
|
4079
|
+
}
|
|
4080
|
+
getConfigRegistries(e) {
|
|
4081
|
+
return Array.from(this.ctx.registry.entries()).map(([t]) => t === null ? {
|
|
4082
|
+
name: "@root",
|
|
4083
|
+
schema: be?.PreferencesSchema || null
|
|
4084
|
+
} : {
|
|
4085
|
+
name: t.name,
|
|
4086
|
+
schema: t?.PreferencesSchema || null
|
|
4087
|
+
}).filter((t) => t.schema !== null).map((t) => ({
|
|
4088
|
+
...t,
|
|
4089
|
+
category: t.schema.meta.category || "general"
|
|
4090
|
+
})).concat(this.customRegistries).filter((t) => !e || t.category === e);
|
|
4091
|
+
}
|
|
4092
|
+
getAllSchema() {
|
|
4093
|
+
return new $(
|
|
4094
|
+
$.intersect(this.getConfigRegistries().map((e) => e.schema))
|
|
4095
|
+
);
|
|
4096
|
+
}
|
|
4097
|
+
defineCategory(e) {
|
|
4098
|
+
const t = this.categoryDefinitions.findIndex((r) => r.name === e.name);
|
|
4099
|
+
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((r, n) => (r.index ?? 0) - (n.index ?? 0)), this;
|
|
4100
|
+
}
|
|
4101
|
+
getConfigCategories() {
|
|
4102
|
+
return this.categoryDefinitions;
|
|
4103
|
+
}
|
|
4104
|
+
async _migrageFromLegacyMasterDB() {
|
|
4105
|
+
const e = this.ctx.storage.createDatabase("preferences", 1 / 0);
|
|
4106
|
+
let t = 0;
|
|
4107
|
+
for await (const [r, n] of e.entries())
|
|
4108
|
+
r !== "_touched" && (await this.db.set(r, n.value), t++);
|
|
4109
|
+
return t && this.logger.info(`Migrated ${t} preferences from master DB`), await e.clear(), await e?.db?.disconnect?.(), t;
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
et = Sn(ni);
|
|
4113
|
+
me = On(et, 0, "PreferencesService", ri, me);
|
|
4114
|
+
An(et, 1, me);
|
|
4115
|
+
var tt = /* @__PURE__ */ ((i) => (i.ANALYTICS_API_BASE = "https://analytics.ipe.wiki/api/v6", i.ANALYTICS_DASH_URL = "https://analytics.ipe.wiki", i.GITHUB_URL = "https://github.com/inpageedit/inpageedit-next", i.GITHUB_OWNER = "inpageedit", i.GITHUB_REPO = "inpageedit-next", i.HOME_URL = "https://www.ipe.wiki/", i.UPDATE_LOGS_URL = "https://www.ipe.wiki/changelogs/", i.PLUGIN_REGISTRY_URL = "https://registry.ipe.wiki/registry.v1.json", i.I18N_INDEX_URL = "https://registry.ipe.wiki/i18n/index.json", i.QQ_GROUP_ID = "1026023666", i))(tt || {});
|
|
4116
|
+
const si = "", oi = "", Pn = /\\\{/g, In = /\\\}/g, Ln = new RegExp(si, "g"), Rn = new RegExp(oi, "g");
|
|
4117
|
+
function mt(i) {
|
|
4118
|
+
const e = i ? { ...i } : void 0;
|
|
4119
|
+
return (r, ...n) => jn(e, r, ...n);
|
|
4120
|
+
}
|
|
4121
|
+
function jn(i, e, ...t) {
|
|
4122
|
+
if (!e) return "";
|
|
4123
|
+
let r = String(e).replace(Pn, si).replace(In, oi), n = {}, s = [];
|
|
4124
|
+
t.length === 1 && Array.isArray(t[0]) ? s = t[0] : t.length === 1 && Dn(t[0]) ? n = t[0] : t.length > 0 && (s = t);
|
|
4125
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
4126
|
+
if (s && s.length)
|
|
4127
|
+
for (let a = 0; a < s.length; a++)
|
|
4128
|
+
o[`$${a + 1}`] = s[a];
|
|
4129
|
+
if (n && Object.keys(n).length)
|
|
4130
|
+
for (const a of Object.keys(n)) o[a] = n[a];
|
|
4131
|
+
if (i && Object.keys(i).length)
|
|
4132
|
+
for (const a of Object.keys(i))
|
|
4133
|
+
typeof o[a] > "u" && (o[a] = i[a]);
|
|
4134
|
+
return r = r.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g, (a, f) => {
|
|
4135
|
+
const u = String(f).trim();
|
|
4136
|
+
if (!u) return "";
|
|
4137
|
+
try {
|
|
4138
|
+
const p = Tn(u, o);
|
|
4139
|
+
return p == null ? "" : String(p);
|
|
4140
|
+
} catch {
|
|
4141
|
+
return "";
|
|
4142
|
+
}
|
|
4143
|
+
}), r.replace(Ln, "{").replace(Rn, "}");
|
|
4144
|
+
}
|
|
4145
|
+
function Dn(i) {
|
|
4146
|
+
return typeof i == "object" && i !== null && i.constructor === Object;
|
|
4147
|
+
}
|
|
4148
|
+
const Tn = Mn();
|
|
4149
|
+
function Mn() {
|
|
4150
|
+
const i = /* @__PURE__ */ new Set([
|
|
4151
|
+
"eval",
|
|
4152
|
+
"Object",
|
|
4153
|
+
"Array",
|
|
4154
|
+
"String",
|
|
4155
|
+
"Number",
|
|
4156
|
+
"Boolean",
|
|
4157
|
+
"Date",
|
|
4158
|
+
"Math",
|
|
4159
|
+
"JSON",
|
|
4160
|
+
"undefined",
|
|
4161
|
+
"null",
|
|
4162
|
+
"true",
|
|
4163
|
+
"false",
|
|
4164
|
+
"NaN",
|
|
4165
|
+
"Infinity",
|
|
4166
|
+
"isNaN",
|
|
4167
|
+
"isFinite",
|
|
4168
|
+
"parseInt",
|
|
4169
|
+
"parseFloat"
|
|
4170
|
+
]), e = new Function(
|
|
4171
|
+
"__expr__",
|
|
4172
|
+
"ctx",
|
|
4173
|
+
`
|
|
4174
|
+
try {
|
|
4175
|
+
with (ctx) {
|
|
4176
|
+
return (eval(__expr__));
|
|
4177
|
+
}
|
|
4178
|
+
} catch (e) {
|
|
4179
|
+
throw e;
|
|
4180
|
+
}
|
|
4181
|
+
`
|
|
4182
|
+
);
|
|
4183
|
+
return (t, r) => {
|
|
4184
|
+
const n = new Proxy(r, {
|
|
4185
|
+
has: (s, o) => typeof o == "symbol" ? o in s : !(typeof o == "string" && (i.has(o) || o === "__expr__")),
|
|
4186
|
+
get: (s, o) => {
|
|
4187
|
+
if (o in s)
|
|
4188
|
+
return s[o];
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
return e(t, n);
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
function ai(i) {
|
|
4195
|
+
return i.charAt(0).toLowerCase() + i.slice(1);
|
|
4196
|
+
}
|
|
4197
|
+
function te(i) {
|
|
4198
|
+
return ai(i).replace(/_/g, "-").replace(/.[A-Z]+/g, (e) => e[0] + "-" + e.slice(1).toLowerCase());
|
|
4199
|
+
}
|
|
4200
|
+
function ms(i) {
|
|
4201
|
+
return ai(i).replace(/-/g, "_").replace(/.[A-Z]+/g, (e) => e[0] + "_" + e.slice(1).toLowerCase());
|
|
4202
|
+
}
|
|
4203
|
+
function H(i, e) {
|
|
4204
|
+
let t = i[0] ?? "";
|
|
4205
|
+
for (let r = 0; r < e.length; r++)
|
|
4206
|
+
t += String(e[r]) + (i[r + 1] ?? "");
|
|
4207
|
+
return t;
|
|
4208
|
+
}
|
|
4209
|
+
class Nn {
|
|
4210
|
+
constructor(e, t) {
|
|
4211
|
+
this.languages = /* @__PURE__ */ new Map(), this.currentLanguage = "en", this.missingKeys = /* @__PURE__ */ new Map(), this.usedKeys = /* @__PURE__ */ new Set();
|
|
4212
|
+
const r = t?.language || "en";
|
|
4213
|
+
this.currentLanguage = r, this.interpolate = mt(t?.globals), e && Object.keys(e).length && this.setLanguageData(r, e);
|
|
4214
|
+
}
|
|
4215
|
+
setGlobals(e) {
|
|
4216
|
+
return this.interpolate = mt(e), this;
|
|
4217
|
+
}
|
|
4218
|
+
set(e, t) {
|
|
4219
|
+
const r = this.currentLanguage, n = this.ensureLanguageMap(r);
|
|
4220
|
+
if (typeof e == "string" && typeof t == "string")
|
|
4221
|
+
n.set(e, t);
|
|
4222
|
+
else if (typeof e == "object") {
|
|
4223
|
+
const s = this.toStringRecord(e);
|
|
4224
|
+
for (const [o, a] of Object.entries(s))
|
|
4225
|
+
n.set(o, a);
|
|
4226
|
+
}
|
|
4227
|
+
return this;
|
|
4228
|
+
}
|
|
4229
|
+
setLanguageData(e, t) {
|
|
4230
|
+
e = te(e).toLowerCase();
|
|
4231
|
+
const r = this.ensureLanguageMap(e), n = this.toStringRecord(t);
|
|
4232
|
+
for (const [s, o] of Object.entries(n))
|
|
4233
|
+
r.set(s, o);
|
|
4234
|
+
return this;
|
|
4235
|
+
}
|
|
4236
|
+
setLanguage(e) {
|
|
4237
|
+
return e = te(e).toLowerCase(), this.currentLanguage = e, this;
|
|
4238
|
+
}
|
|
4239
|
+
getLanguage() {
|
|
4240
|
+
return this.currentLanguage;
|
|
4241
|
+
}
|
|
4242
|
+
hasLanguage(e) {
|
|
4243
|
+
e = te(e).toLowerCase();
|
|
4244
|
+
const t = this.languages.get(e);
|
|
4245
|
+
return t && Object.keys(t).length > 0;
|
|
4246
|
+
}
|
|
4247
|
+
toStringRecord(e, t) {
|
|
4248
|
+
const r = {};
|
|
4249
|
+
for (const [n, s] of Object.entries(e)) {
|
|
4250
|
+
const o = t ? `${t}.${n}` : n;
|
|
4251
|
+
if (s && typeof s == "object" && !Array.isArray(s)) {
|
|
4252
|
+
const a = this.toStringRecord(s, o);
|
|
4253
|
+
for (const [f, u] of Object.entries(a))
|
|
4254
|
+
r[f] = String(u);
|
|
4255
|
+
} else
|
|
4256
|
+
r[o] = String(s);
|
|
4257
|
+
}
|
|
4258
|
+
return r;
|
|
4259
|
+
}
|
|
4260
|
+
has(e) {
|
|
4261
|
+
const t = this.resolveLanguageOrder(this.currentLanguage);
|
|
4262
|
+
for (const r of t)
|
|
4263
|
+
if (this.languages.get(r)?.has(e)) return !0;
|
|
4264
|
+
return !1;
|
|
4265
|
+
}
|
|
4266
|
+
get(e) {
|
|
4267
|
+
this.recordUsedKey(e);
|
|
4268
|
+
const t = this.resolveLanguageOrder(this.currentLanguage), r = [];
|
|
4269
|
+
for (const n of t) {
|
|
4270
|
+
const o = this.languages.get(n)?.get(e);
|
|
4271
|
+
if (typeof o < "u")
|
|
4272
|
+
return r.length && this.recordMissing(e, r), o;
|
|
4273
|
+
r.push(n);
|
|
4274
|
+
}
|
|
4275
|
+
r.length && this.recordMissing(e, r);
|
|
4276
|
+
}
|
|
4277
|
+
translate(e, ...t) {
|
|
4278
|
+
if (!e)
|
|
4279
|
+
return "";
|
|
4280
|
+
if (this.currentLanguage === "qqx")
|
|
4281
|
+
return `⧼${e}⧽`;
|
|
4282
|
+
const r = this.get(e);
|
|
4283
|
+
return typeof r > "u" ? this.interpolate(e, ...t) : this.interpolate(r, ...t);
|
|
4284
|
+
}
|
|
4285
|
+
$(...e) {
|
|
4286
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
4287
|
+
const n = e[0], s = e.slice(1), o = H(n, s);
|
|
4288
|
+
return this.translate(o);
|
|
4289
|
+
}
|
|
4290
|
+
const r = e;
|
|
4291
|
+
return (n, ...s) => {
|
|
4292
|
+
const o = H(n, s);
|
|
4293
|
+
return this.translate(o, ...r);
|
|
4294
|
+
};
|
|
4295
|
+
}
|
|
4296
|
+
/**
|
|
4297
|
+
* [payload as template] Return the raw message without interpolation
|
|
4298
|
+
* @example
|
|
4299
|
+
* ```
|
|
4300
|
+
* i18n.rawMsg('Hello, {{ name }}')
|
|
4301
|
+
* // good: "你好,{{ name }}"
|
|
4302
|
+
* // missing: "Hello, {{ name }}"
|
|
4303
|
+
* ```
|
|
4304
|
+
*/
|
|
4305
|
+
translateRaw(e) {
|
|
4306
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? e : "";
|
|
4307
|
+
}
|
|
4308
|
+
$raw(...e) {
|
|
4309
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
4310
|
+
const r = e[0], n = e.slice(1), s = H(r, n);
|
|
4311
|
+
return this.translateRaw(s);
|
|
4312
|
+
}
|
|
4313
|
+
return (r, ...n) => {
|
|
4314
|
+
const s = H(r, n);
|
|
4315
|
+
return this.translateRaw(s);
|
|
4316
|
+
};
|
|
4317
|
+
}
|
|
4318
|
+
message(e, ...t) {
|
|
4319
|
+
if (!e)
|
|
4320
|
+
return "";
|
|
4321
|
+
if (this.currentLanguage === "qqx")
|
|
4322
|
+
return `⧼${e}⧽`;
|
|
4323
|
+
const r = this.get(e);
|
|
4324
|
+
return typeof r > "u" ? `(${e})` : this.interpolate(r, ...t);
|
|
4325
|
+
}
|
|
4326
|
+
$$(...e) {
|
|
4327
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
4328
|
+
const n = e[0], s = e.slice(1), o = H(n, s);
|
|
4329
|
+
return this.message(o);
|
|
4330
|
+
}
|
|
4331
|
+
const r = e;
|
|
4332
|
+
return (n, ...s) => {
|
|
4333
|
+
const o = H(n, s);
|
|
4334
|
+
return this.message(o, ...r);
|
|
4335
|
+
};
|
|
4336
|
+
}
|
|
4337
|
+
/**
|
|
4338
|
+
* [payload as key] Return the raw message without interpolation
|
|
4339
|
+
* @example
|
|
4340
|
+
* ```
|
|
4341
|
+
* i18n.rawMsg('greeting')
|
|
4342
|
+
* // good: "你好,{{ name }}"
|
|
4343
|
+
* // missing: "(greeting)"
|
|
4344
|
+
* ```
|
|
4345
|
+
*/
|
|
4346
|
+
messageRaw(e) {
|
|
4347
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? `(${e})` : "";
|
|
4348
|
+
}
|
|
4349
|
+
$$raw(...e) {
|
|
4350
|
+
if (Array.isArray(e[0]) && e[0].raw) {
|
|
4351
|
+
const r = e[0], n = e.slice(1), s = H(r, n);
|
|
4352
|
+
return this.messageRaw(s);
|
|
4353
|
+
}
|
|
4354
|
+
return (r, ...n) => {
|
|
4355
|
+
const s = H(r, n);
|
|
4356
|
+
return this.messageRaw(s);
|
|
4357
|
+
};
|
|
4358
|
+
}
|
|
4359
|
+
getAvailableLanguages() {
|
|
4360
|
+
return Array.from(this.languages.keys());
|
|
4361
|
+
}
|
|
4362
|
+
ensureLanguageMap(e) {
|
|
4363
|
+
let t = this.languages.get(e);
|
|
4364
|
+
return t || (t = /* @__PURE__ */ new Map(), this.languages.set(e, t)), t;
|
|
4365
|
+
}
|
|
4366
|
+
resolveLanguageOrder(e) {
|
|
4367
|
+
const t = e;
|
|
4368
|
+
return t === "en" ? ["en"] : [t, "en"];
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* 获取缺失键报告:
|
|
4372
|
+
* { foo: ['zh', 'zh-hans', 'en'] }
|
|
4373
|
+
*/
|
|
4374
|
+
getMissingReport() {
|
|
4375
|
+
return Object.fromEntries(this.missingKeys.entries());
|
|
4376
|
+
}
|
|
4377
|
+
/**
|
|
4378
|
+
* 清空缺失键记录
|
|
4379
|
+
*/
|
|
4380
|
+
clearMissingReport() {
|
|
4381
|
+
this.missingKeys.clear();
|
|
4382
|
+
}
|
|
4383
|
+
recordMissing(e, t) {
|
|
4384
|
+
if (!t.length) return;
|
|
4385
|
+
const r = this.missingKeys.get(e) || [];
|
|
4386
|
+
for (const n of t)
|
|
4387
|
+
r.includes(n) || r.push(n);
|
|
4388
|
+
this.missingKeys.set(e, r);
|
|
4389
|
+
}
|
|
4390
|
+
recordUsedKey(e) {
|
|
4391
|
+
this.usedKeys.add(e);
|
|
4392
|
+
}
|
|
4393
|
+
getUsedKeys() {
|
|
4394
|
+
return Array.from(this.usedKeys);
|
|
4395
|
+
}
|
|
4396
|
+
generateBlankKeyRecord() {
|
|
4397
|
+
const e = {};
|
|
4398
|
+
for (const t of this.getUsedKeys())
|
|
4399
|
+
e[t] = "";
|
|
4400
|
+
return e;
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
var Bn = Object.create, it = Object.defineProperty, Un = Object.getOwnPropertyDescriptor, ci = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), li = (i) => {
|
|
4404
|
+
throw TypeError(i);
|
|
4405
|
+
}, Fn = (i, e, t) => e in i ? it(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, zn = (i, e) => it(i, "name", { value: e, configurable: !0 }), Kn = (i) => [, , , Bn(i?.[ci("metadata")] ?? null)], qn = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], hi = (i) => i !== void 0 && typeof i != "function" ? li("Function expected") : i, Hn = (i, e, t, r, n) => ({ kind: qn[i], name: e, metadata: r, addInitializer: (s) => t._ ? li("Already initialized") : n.push(hi(s || null)) }), Wn = (i, e) => Fn(e, ci("metadata"), i[3]), Gn = (i, e, t, r) => {
|
|
4406
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
4407
|
+
return r;
|
|
4408
|
+
}, Vn = (i, e, t, r, n, s) => {
|
|
4409
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && Un(n, t));
|
|
4410
|
+
zn(n, t);
|
|
4411
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
4412
|
+
f = Hn(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, hi(o) && (n = o);
|
|
4413
|
+
return Wn(i, n), g && it(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
4414
|
+
}, ui, rt, fi;
|
|
4415
|
+
const yt = new $(
|
|
4416
|
+
$.object({
|
|
4417
|
+
manifest_version: $.const(1).required(),
|
|
4418
|
+
base_language: $.string().required(),
|
|
4419
|
+
last_modified: $.string().required(),
|
|
4420
|
+
languages: $.dict(
|
|
4421
|
+
$.object({
|
|
4422
|
+
file: $.string().required(),
|
|
4423
|
+
fallback: $.string(),
|
|
4424
|
+
iso_name: $.string(),
|
|
4425
|
+
endonym: $.string(),
|
|
4426
|
+
data: $.transform(
|
|
4427
|
+
$.dict($.any()).default({}),
|
|
4428
|
+
(i) => Object.keys(i).length > 0 ? i : void 0
|
|
4429
|
+
)
|
|
4430
|
+
})
|
|
4431
|
+
).required()
|
|
4432
|
+
})
|
|
4433
|
+
);
|
|
4434
|
+
ui = [F(["wiki", "preferences"]), Gt(
|
|
4435
|
+
$.object({
|
|
4436
|
+
"i18n.index_url": $.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(
|
|
4437
|
+
tt.I18N_INDEX_URL
|
|
4438
|
+
)
|
|
4439
|
+
}).description("").extra("category", "general")
|
|
4440
|
+
)];
|
|
4441
|
+
class ye extends (fi = z) {
|
|
4442
|
+
constructor(e) {
|
|
4443
|
+
super(e, "i18n", !1), this.ctx = e, this.logger = void 0, this._indexUrl = void 0, this._indexCache = null, this.manager = void 0, this.i18nIndexDB = void 0, this.i18nDataDB = void 0, this.$ = void 0, this.$raw = void 0, this.$$ = void 0, this.$$raw = void 0, this.logger = this.ctx.logger("I18nService"), this.manager = new Nn(
|
|
4444
|
+
{},
|
|
4445
|
+
{
|
|
4446
|
+
language: "",
|
|
4447
|
+
globals: {
|
|
4448
|
+
userName: this.ctx.wiki.userInfo.name || "",
|
|
4449
|
+
userId: this.ctx.wiki.userInfo.id || 0,
|
|
4450
|
+
siteName: this.ctx.wiki.siteInfo.general.sitename || ""
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
), this.i18nIndexDB = e.storage.createDatabase(
|
|
4454
|
+
"i18n-index",
|
|
4455
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
4456
|
+
// 3 days
|
|
4457
|
+
this.ctx.version,
|
|
4458
|
+
"indexedDB"
|
|
4459
|
+
), this.i18nDataDB = e.storage.createDatabase(
|
|
4460
|
+
"i18n-data",
|
|
4461
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
4462
|
+
// 3 days
|
|
4463
|
+
this.ctx.version,
|
|
4464
|
+
"indexedDB"
|
|
4465
|
+
), this.$ = this.manager.$.bind(this.manager), this.$raw = this.manager.$raw.bind(this.manager), this.$$ = this.manager.$$.bind(this.manager), this.$$raw = this.manager.$$raw.bind(this.manager);
|
|
4466
|
+
}
|
|
4467
|
+
async start() {
|
|
4468
|
+
this.ctx.preferences.registerCustomConfig(
|
|
4469
|
+
"language",
|
|
4470
|
+
$.object({
|
|
4471
|
+
language: $.union([
|
|
4472
|
+
"@user",
|
|
4473
|
+
"@site",
|
|
4474
|
+
$.string().description("Custom language code")
|
|
4475
|
+
]).description("UI language").default("@user")
|
|
4476
|
+
}).description("UI language")
|
|
4477
|
+
), this.ctx.on("clear-cache", this.onClearCache.bind(this));
|
|
4478
|
+
const e = this._indexUrl = await this.ctx.preferences.get("i18n.index_url") || "";
|
|
4479
|
+
if (!e) {
|
|
4480
|
+
this.logger.error("I18n index URL is not set"), this.setupShortcuts();
|
|
4481
|
+
return;
|
|
4482
|
+
}
|
|
4483
|
+
let t = null;
|
|
4484
|
+
try {
|
|
4485
|
+
t = await this.getI18nIndex(e);
|
|
4486
|
+
} catch (s) {
|
|
4487
|
+
this.logger.error("Failed to fetch i18n index", s), this.setupShortcuts();
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
this._indexCache = t, Object.entries(t.languages).forEach(([s, o]) => {
|
|
4491
|
+
o.data && Object.keys(o.data).length > 0 && this.manager.setLanguageData(s, o.data);
|
|
4492
|
+
});
|
|
4493
|
+
const r = await this.ctx.preferences.get("language"), n = this.normalizeLanguageCode(r);
|
|
4494
|
+
this.logger.debug("Settings", { prefer: r, normalized: n });
|
|
4495
|
+
try {
|
|
4496
|
+
await this.switchLanguage(n), this.logger.info(`Initialized for language: ${this.language}`);
|
|
4497
|
+
} catch (s) {
|
|
4498
|
+
this.logger.error("Failed to fetch i18n index", s), this.manager.setLanguage("en");
|
|
4499
|
+
}
|
|
4500
|
+
this.ctx.preferences.registerCustomConfig(
|
|
4501
|
+
"language",
|
|
4502
|
+
$.object({
|
|
4503
|
+
language: $.union([
|
|
4504
|
+
$.const("@user").description(this.$`Same as your personal language`),
|
|
4505
|
+
$.const("@site").description(this.$`Same as the site language`),
|
|
4506
|
+
...this.getAvailableLanguageCodes().map(
|
|
4507
|
+
({ code: s, endonym: o, iso_name: a }) => $.const(s).description(o || a || s)
|
|
4508
|
+
)
|
|
4509
|
+
]).default("@user")
|
|
4510
|
+
}).description(this.$`InPageEdit UI language`)
|
|
4511
|
+
), this.setupShortcuts(), this.ctx.on("preferences/changed", async ({ changes: s }) => {
|
|
4512
|
+
if (!("language" in s)) return;
|
|
4513
|
+
const o = this.normalizeLanguageCode(await this.ctx.preferences.get("language"));
|
|
4514
|
+
o && o !== this.language && await this.switchLanguage(o);
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4517
|
+
setupShortcuts() {
|
|
4518
|
+
if (!this.manager) throw new Error("I18nManager is not initialized");
|
|
4519
|
+
this.ctx.set("$", this.manager.$.bind(this.manager)), this.ctx.set("$raw", this.manager.$raw.bind(this.manager)), this.ctx.set("$$", this.manager.$$.bind(this.manager)), this.ctx.set("$$raw", this.manager.$$raw.bind(this.manager));
|
|
4520
|
+
}
|
|
4521
|
+
normalizeLanguageCode(e) {
|
|
4522
|
+
return !e || typeof e != "string" ? "en" : (e === "@user" && (e = this.ctx.wiki.userInfo.options.language || "en"), e === "@site" && (e = this.ctx.wiki.siteInfo.general.lang || "en"), te(String(e)).toLowerCase());
|
|
4523
|
+
}
|
|
4524
|
+
get language() {
|
|
4525
|
+
return this.manager.getLanguage();
|
|
4526
|
+
}
|
|
4527
|
+
/**
|
|
4528
|
+
* 主动设置偏好值(会触发 preferences/changed,从而热切换)
|
|
4529
|
+
*/
|
|
4530
|
+
async setLanguagePreference(e) {
|
|
4531
|
+
await this.ctx.preferences.set("language", e);
|
|
4532
|
+
}
|
|
4533
|
+
/**
|
|
4534
|
+
* 直接切换到具体语言(不修改偏好值)
|
|
4535
|
+
*/
|
|
4536
|
+
async switchLanguage(e) {
|
|
4537
|
+
const t = this.normalizeLanguageCode(e);
|
|
4538
|
+
await this.ensureLanguageLoaded(t), this.manager.setLanguage(t), this.ctx.emit("i18n/changed", { ctx: this.ctx, language: t });
|
|
4539
|
+
}
|
|
4540
|
+
/**
|
|
4541
|
+
* 为指定语言注册(或合并)消息。
|
|
4542
|
+
* - 推荐加命名空间避免冲突:{ myPlugin: { key: 'value' } }
|
|
4543
|
+
* - 若 language 为当前语言,将立即可用;必要时你可以手动触发 UI 刷新或监听 i18n/changed。
|
|
4544
|
+
*/
|
|
4545
|
+
async registerMessages(e, t, r) {
|
|
4546
|
+
const n = r?.namespace ? { [r.namespace]: t } : t;
|
|
4547
|
+
this.manager.setLanguageData(e, n), e === this.language && this.ctx.emit("i18n/changed", { ctx: this.ctx, language: this.language });
|
|
4548
|
+
}
|
|
4549
|
+
/**
|
|
4550
|
+
* 列出可用语言与文件(来源于 index.json)
|
|
4551
|
+
*/
|
|
4552
|
+
getAvailableLanguageCodes() {
|
|
4553
|
+
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
4554
|
+
return Object.entries(this._indexCache.languages).filter(([e, t]) => !t.fallback).reduce(
|
|
4555
|
+
(e, [t, r]) => (e.push({ code: t, ...r }), e),
|
|
4556
|
+
[]
|
|
4557
|
+
);
|
|
4558
|
+
}
|
|
4559
|
+
findLanguageMeta(e, t) {
|
|
4560
|
+
const r = te(String(t)).toLowerCase(), n = e.languages[r];
|
|
4561
|
+
if (n)
|
|
4562
|
+
return {
|
|
4563
|
+
code: r,
|
|
4564
|
+
...n
|
|
4565
|
+
};
|
|
4566
|
+
{
|
|
4567
|
+
const s = e.languages.en;
|
|
4568
|
+
if (s)
|
|
4569
|
+
return {
|
|
4570
|
+
code: "en",
|
|
4571
|
+
...s
|
|
4572
|
+
};
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
async getI18nIndex(e, t = !1) {
|
|
4576
|
+
if (!t) {
|
|
4577
|
+
const n = await this.i18nIndexDB.get(e);
|
|
4578
|
+
if (n)
|
|
4579
|
+
try {
|
|
4580
|
+
return yt(n);
|
|
4581
|
+
} catch (s) {
|
|
4582
|
+
this.logger.error("Failed to parse cached i18n index", s), this.i18nIndexDB.delete(e);
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
const r = await this.fetchI18nIndex(e);
|
|
4586
|
+
return this.i18nIndexDB.set(e, r), r;
|
|
4587
|
+
}
|
|
4588
|
+
async fetchI18nIndex(e) {
|
|
4589
|
+
const t = await fetch(e).then((r) => r.json());
|
|
4590
|
+
return yt(t);
|
|
4591
|
+
}
|
|
4592
|
+
async ensureLanguageLoaded(e) {
|
|
4593
|
+
if (!this.manager || !this._indexCache) throw new Error("I18nManager is not initialized");
|
|
4594
|
+
if (this.manager.hasLanguage(e))
|
|
4595
|
+
return this.logger.debug("Language already loaded", e);
|
|
4596
|
+
const t = await this.getLanguageData(e);
|
|
4597
|
+
this.manager.setLanguageData(e, t), this.logger.debug("Language data ensured", e, t);
|
|
4598
|
+
}
|
|
4599
|
+
async getLanguageData(e, t = !1) {
|
|
4600
|
+
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
4601
|
+
const r = this.findLanguageMeta(this._indexCache, e);
|
|
4602
|
+
if (!r) return {};
|
|
4603
|
+
const n = `${this._indexUrl}#${r.file}`;
|
|
4604
|
+
if (!t) {
|
|
4605
|
+
const o = await this.i18nDataDB.get(n);
|
|
4606
|
+
if (o && Object.keys(o).length > 0)
|
|
4607
|
+
return this.logger.debug("Using cached language data", e, o), o;
|
|
4608
|
+
}
|
|
4609
|
+
const s = r.data || await fetch(new URL(r.file, this._indexUrl).toString()).then((o) => o.json());
|
|
4610
|
+
return this.i18nDataDB.set(n, s), this.logger.debug("Language data fetched", e, r.file, s), s;
|
|
4611
|
+
}
|
|
4612
|
+
/**
|
|
4613
|
+
* 获取缺失键报告,形如:
|
|
4614
|
+
* { foo: ['zh', 'zh-hans', 'en'] }
|
|
4615
|
+
*/
|
|
4616
|
+
getMissingReport() {
|
|
4617
|
+
return this.manager.getMissingReport();
|
|
4618
|
+
}
|
|
4619
|
+
/**
|
|
4620
|
+
* 清空缺失键记录
|
|
4621
|
+
*/
|
|
4622
|
+
clearMissingReport() {
|
|
4623
|
+
this.manager.clearMissingReport();
|
|
4624
|
+
}
|
|
4625
|
+
async onClearCache() {
|
|
4626
|
+
await this.i18nIndexDB.clear(), await this.i18nDataDB.clear();
|
|
4627
|
+
}
|
|
4628
|
+
}
|
|
4629
|
+
rt = Kn(fi);
|
|
4630
|
+
ye = Vn(rt, 0, "I18nService", ui, ye);
|
|
4631
|
+
Gn(rt, 1, ye);
|
|
4632
|
+
const Jn = new TextEncoder();
|
|
4633
|
+
function Yn(i) {
|
|
4634
|
+
if (typeof i == "string") return Jn.encode(i);
|
|
4635
|
+
if (i instanceof ArrayBuffer) return new Uint8Array(i);
|
|
4636
|
+
if (ArrayBuffer.isView(i))
|
|
4637
|
+
return new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
|
|
4638
|
+
throw new TypeError("Unsupported input type");
|
|
4639
|
+
}
|
|
4640
|
+
function Xn(i) {
|
|
4641
|
+
let e = "";
|
|
4642
|
+
for (let t = 0; t < i.length; t++) {
|
|
4643
|
+
const r = i[t].toString(16).padStart(2, "0");
|
|
4644
|
+
e += r;
|
|
4645
|
+
}
|
|
4646
|
+
return e;
|
|
4647
|
+
}
|
|
4648
|
+
function Qn(i, e) {
|
|
4649
|
+
return i << e | i >>> 32 - e;
|
|
4650
|
+
}
|
|
4651
|
+
const Zn = [
|
|
4652
|
+
7,
|
|
4653
|
+
12,
|
|
4654
|
+
17,
|
|
4655
|
+
22,
|
|
4656
|
+
7,
|
|
4657
|
+
12,
|
|
4658
|
+
17,
|
|
4659
|
+
22,
|
|
4660
|
+
7,
|
|
4661
|
+
12,
|
|
4662
|
+
17,
|
|
4663
|
+
22,
|
|
4664
|
+
7,
|
|
4665
|
+
12,
|
|
4666
|
+
17,
|
|
4667
|
+
22,
|
|
4668
|
+
5,
|
|
4669
|
+
9,
|
|
4670
|
+
14,
|
|
4671
|
+
20,
|
|
4672
|
+
5,
|
|
4673
|
+
9,
|
|
4674
|
+
14,
|
|
4675
|
+
20,
|
|
4676
|
+
5,
|
|
4677
|
+
9,
|
|
4678
|
+
14,
|
|
4679
|
+
20,
|
|
4680
|
+
5,
|
|
4681
|
+
9,
|
|
4682
|
+
14,
|
|
4683
|
+
20,
|
|
4684
|
+
4,
|
|
4685
|
+
11,
|
|
4686
|
+
16,
|
|
4687
|
+
23,
|
|
4688
|
+
4,
|
|
4689
|
+
11,
|
|
4690
|
+
16,
|
|
4691
|
+
23,
|
|
4692
|
+
4,
|
|
4693
|
+
11,
|
|
4694
|
+
16,
|
|
4695
|
+
23,
|
|
4696
|
+
4,
|
|
4697
|
+
11,
|
|
4698
|
+
16,
|
|
4699
|
+
23,
|
|
4700
|
+
6,
|
|
4701
|
+
10,
|
|
4702
|
+
15,
|
|
4703
|
+
21,
|
|
4704
|
+
6,
|
|
4705
|
+
10,
|
|
4706
|
+
15,
|
|
4707
|
+
21,
|
|
4708
|
+
6,
|
|
4709
|
+
10,
|
|
4710
|
+
15,
|
|
4711
|
+
21,
|
|
4712
|
+
6,
|
|
4713
|
+
10,
|
|
4714
|
+
15,
|
|
4715
|
+
21
|
|
4716
|
+
], es = new Array(64).fill(0).map((i, e) => Math.floor(Math.abs(Math.sin(e + 1)) * 2 ** 32) >>> 0);
|
|
4717
|
+
function ts(i) {
|
|
4718
|
+
const e = Yn(i), t = (56 - (e.length + 1) % 64 + 64) % 64, r = e.length + 1 + t + 8, n = new Uint8Array(r);
|
|
4719
|
+
n.set(e, 0), n[e.length] = 128;
|
|
4720
|
+
const s = e.length, o = s << 3 >>> 0, a = s >>> 29 >>> 0, f = new DataView(n.buffer);
|
|
4721
|
+
f.setUint32(r - 8, o, !0), f.setUint32(r - 4, a, !0);
|
|
4722
|
+
let u = 1732584193, p = 4023233417, y = 2562383102, _ = 271733878;
|
|
4723
|
+
const g = new Uint32Array(16);
|
|
4724
|
+
for (let C = 0; C < n.length; C += 64) {
|
|
4725
|
+
for (let m = 0; m < 16; m++) g[m] = f.getUint32(C + m * 4, !0);
|
|
4726
|
+
let l = u, c = p, h = y, d = _;
|
|
4727
|
+
for (let m = 0; m < 64; m++) {
|
|
4728
|
+
let v, x;
|
|
4729
|
+
m < 16 ? (v = c & h | ~c & d, x = m) : m < 32 ? (v = d & c | ~d & h, x = (5 * m + 1) % 16) : m < 48 ? (v = c ^ h ^ d, x = (3 * m + 5) % 16) : (v = h ^ (c | ~d), x = 7 * m % 16);
|
|
4730
|
+
const A = d, ke = l + v + es[m] + g[x] >>> 0;
|
|
4731
|
+
d = h, h = c, c = c + Qn(ke, Zn[m]) >>> 0, l = A;
|
|
4732
|
+
}
|
|
4733
|
+
u = u + l >>> 0, p = p + c >>> 0, y = y + h >>> 0, _ = _ + d >>> 0;
|
|
4734
|
+
}
|
|
4735
|
+
const w = new Uint8Array(16), O = new DataView(w.buffer);
|
|
4736
|
+
return O.setUint32(0, u, !0), O.setUint32(4, p, !0), O.setUint32(8, y, !0), O.setUint32(12, _, !0), w;
|
|
4737
|
+
}
|
|
4738
|
+
var is = Object.create, nt = Object.defineProperty, rs = Object.getOwnPropertyDescriptor, di = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), pi = (i) => {
|
|
4739
|
+
throw TypeError(i);
|
|
4740
|
+
}, ns = (i, e, t) => e in i ? nt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, ss = (i, e) => nt(i, "name", { value: e, configurable: !0 }), os = (i) => [, , , is(i?.[di("metadata")] ?? null)], as = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], gi = (i) => i !== void 0 && typeof i != "function" ? pi("Function expected") : i, cs = (i, e, t, r, n) => ({ kind: as[i], name: e, metadata: r, addInitializer: (s) => t._ ? pi("Already initialized") : n.push(gi(s || null)) }), ls = (i, e) => ns(e, di("metadata"), i[3]), hs = (i, e, t, r) => {
|
|
4741
|
+
for (var n = 0, s = i[e >> 1], o = s && s.length; n < o; n++) s[n].call(t);
|
|
4742
|
+
return r;
|
|
4743
|
+
}, us = (i, e, t, r, n, s) => {
|
|
4744
|
+
var o, a, f, u = e & 7, p = !1, y = 0, _ = i[y] || (i[y] = []), g = u && (n = n.prototype, u < 5 && (u > 3 || !p) && rs(n, t));
|
|
4745
|
+
ss(n, t);
|
|
4746
|
+
for (var w = r.length - 1; w >= 0; w--)
|
|
4747
|
+
f = cs(u, t, a = {}, i[3], _), o = (0, r[w])(n, f), a._ = 1, gi(o) && (n = o);
|
|
4748
|
+
return ls(i, n), g && nt(n, t, g), p ? u ^ 4 ? s : g : n;
|
|
4749
|
+
}, mi, st, yi;
|
|
4750
|
+
mi = [F(["wiki", "wikiTitle", "wikiPage", "apiService"])];
|
|
4751
|
+
class we extends (yi = z) {
|
|
4752
|
+
constructor(e) {
|
|
4753
|
+
super(e, "wikiFile", !0), this.ctx = e;
|
|
4754
|
+
}
|
|
4755
|
+
get fileRepos() {
|
|
4756
|
+
return this.ctx.wiki.fileRepos || [];
|
|
4757
|
+
}
|
|
4758
|
+
get defaultFileRepo() {
|
|
4759
|
+
return this.fileRepos[0];
|
|
4760
|
+
}
|
|
4761
|
+
get localFileRepo() {
|
|
4762
|
+
return this.fileRepos.find((e) => e.local);
|
|
4763
|
+
}
|
|
4764
|
+
get writableFileRepo() {
|
|
4765
|
+
return this.fileRepos.find((e) => e.canUpload);
|
|
4766
|
+
}
|
|
4767
|
+
getFileName(e) {
|
|
4768
|
+
if (e = this.ctx.wikiTitle.newTitle(e, 6), ![6, -2].includes(e.getNamespaceId()))
|
|
4769
|
+
throw new Error("Not a file title");
|
|
4770
|
+
return e.getMainDBKey().split("/").pop() || "";
|
|
4771
|
+
}
|
|
4772
|
+
getHashPath(e, t = 2) {
|
|
4773
|
+
const r = this.getFileName(e), n = Xn(ts(r));
|
|
4774
|
+
let s = [];
|
|
4775
|
+
for (let o = 1; o <= t; o++)
|
|
4776
|
+
s.push(n.slice(0, o));
|
|
4777
|
+
return s.push(r), s.join("/");
|
|
4778
|
+
}
|
|
4779
|
+
getFileUrl(e, t) {
|
|
4780
|
+
if (t = t || this.defaultFileRepo, !t)
|
|
4781
|
+
throw new Error("No file repository found");
|
|
4782
|
+
const r = this.getHashPath(e);
|
|
4783
|
+
return new URL(`${t.rootUrl}/${r}`, location.origin).toString();
|
|
4784
|
+
}
|
|
4785
|
+
async upload(e, t) {
|
|
4786
|
+
if (t = t || this.writableFileRepo, !t?.canUpload)
|
|
4787
|
+
throw new Error("No writable file repository found");
|
|
4788
|
+
if (!e.file && !e.url && !e.chunk && !e.filekey)
|
|
4789
|
+
throw new Error('At least one of "file", "url", "chunk", or "filekey" is required');
|
|
4790
|
+
return this.ctx.apiService.getClientByFileRepo(t).postWithToken(
|
|
4791
|
+
"csrf",
|
|
4792
|
+
{
|
|
4793
|
+
action: "upload",
|
|
4794
|
+
...e
|
|
4795
|
+
},
|
|
4796
|
+
{ fexiosOptions: { timeout: 0 } }
|
|
4797
|
+
);
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
st = os(yi);
|
|
4801
|
+
we = us(st, 0, "WikiFileService", mi, we);
|
|
4802
|
+
hs(st, 1, we);
|
|
4803
|
+
class be extends N {
|
|
4804
|
+
constructor(e) {
|
|
4805
|
+
super({
|
|
4806
|
+
name: "InPageEdit"
|
|
4807
|
+
}), this.version = "0.16.0", this.Endpoints = tt, this.schema = $, this.config = $i(be.DEFAULT_CONFIG, e), this.logger = or({
|
|
4808
|
+
name: "IPE",
|
|
4809
|
+
color: "#33aaff",
|
|
4810
|
+
level: this.config.logLevel
|
|
4811
|
+
}), this.#e();
|
|
4812
|
+
}
|
|
4813
|
+
static {
|
|
4814
|
+
this.DEFAULT_CONFIG = {
|
|
4815
|
+
apiConfigs: {},
|
|
4816
|
+
legacyPreferences: {},
|
|
4817
|
+
logLevel: Ot.info,
|
|
4818
|
+
storageNamespace: "InPageEdit",
|
|
4819
|
+
autoloadStyles: !0,
|
|
4820
|
+
autoInstallCorePlugins: !0
|
|
4821
|
+
};
|
|
4822
|
+
}
|
|
4823
|
+
async #e() {
|
|
4824
|
+
await this.#i(), this.config.autoInstallCorePlugins && this.#r(), this.#n();
|
|
4825
|
+
}
|
|
4826
|
+
async #i() {
|
|
4827
|
+
this.plugin(ye), this.plugin(cr, this.config.apiConfigs), this.plugin(fe), this.plugin(br), this.plugin(Hr), this.plugin(me), this.plugin(an, { dbName: this.config.storageNamespace }), this.plugin(ge), this.plugin(we), this.plugin(pe), this.plugin(wn), this.plugin(Qe), this.#t([
|
|
4828
|
+
"i18n",
|
|
4829
|
+
"$",
|
|
4830
|
+
"$$",
|
|
4831
|
+
"api",
|
|
4832
|
+
"currentPage",
|
|
4833
|
+
"resourceLoader",
|
|
4834
|
+
"modal",
|
|
4835
|
+
"preferences",
|
|
4836
|
+
"storage",
|
|
4837
|
+
"theme",
|
|
4838
|
+
"wikiPage",
|
|
4839
|
+
"wikiTitle",
|
|
4840
|
+
// WikiMetadataService
|
|
4841
|
+
"wiki",
|
|
4842
|
+
"getUrl",
|
|
4843
|
+
"getSciprtUrl",
|
|
4844
|
+
"getMainpageUrl"
|
|
4845
|
+
]);
|
|
4846
|
+
}
|
|
4847
|
+
#t(e) {
|
|
4848
|
+
if (!Array.isArray(e) || e.length === 0) return this;
|
|
4849
|
+
for (const t of e) {
|
|
4850
|
+
const r = this[be.internal][t];
|
|
4851
|
+
r?.type === "service" && (r.builtin = !0);
|
|
4852
|
+
}
|
|
4853
|
+
return this;
|
|
4854
|
+
}
|
|
4855
|
+
// TODO: 这里不应该硬编码,暂时先这样
|
|
4856
|
+
async #r() {
|
|
4857
|
+
[
|
|
4858
|
+
import("./index-NWWeW3tX.js").then(({ PluginAnalytics: t }) => t),
|
|
4859
|
+
import("./index-BPTMltVf.js").then(
|
|
4860
|
+
({ PluginInArticleLinks: t }) => t
|
|
4861
|
+
),
|
|
4862
|
+
import("./index-bQ0CVu3l.js").then(({ PluginPluginStore: t }) => t),
|
|
4863
|
+
import("./index-BYlcHc-O.js").then(
|
|
4864
|
+
({ PluginPreferencesUI: t }) => t
|
|
4865
|
+
),
|
|
4866
|
+
import("./index-B32tFyLB.js").then(({ PluginQuickEdit: t }) => t),
|
|
4867
|
+
import("./index-CVCy0wPP.js").then(({ PluginQuickMove: t }) => t),
|
|
4868
|
+
import("./index-DZa9mxN4.js").then(
|
|
4869
|
+
({ PluginQuickPreview: t }) => t
|
|
4870
|
+
),
|
|
4871
|
+
import("./index-Dm2vgYkZ.js").then(({ PluginQuickDiff: t }) => t),
|
|
4872
|
+
import("./index-1tsXE6ax.js").then(
|
|
4873
|
+
({ PluginQuickRedirect: t }) => t
|
|
4874
|
+
),
|
|
4875
|
+
import("./index-CAtPo7xJ.js").then(({ PluginQuickUpload: t }) => t),
|
|
4876
|
+
import("./index-ygc4AMy4.js").then(({ PluginQuickUsage: t }) => t),
|
|
4877
|
+
import("./index-C4qm_X_A.js").then(({ PluginToolbox: t }) => t)
|
|
4878
|
+
].forEach(async (t) => {
|
|
4879
|
+
this.plugin(await t);
|
|
4880
|
+
});
|
|
4881
|
+
}
|
|
4882
|
+
// TODO: 应该抽象到 PluginTheme 中去,暂时先硬编码
|
|
4883
|
+
async #n() {
|
|
4884
|
+
this.inject(["resourceLoader"], (e) => {
|
|
4885
|
+
this.config.autoloadStyles && e.resourceLoader.loadStyle(import.meta.resolve("./style.css"));
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
async withInject(e) {
|
|
4889
|
+
const { promise: t, resolve: r } = wt();
|
|
4890
|
+
return this.inject(e, (n) => {
|
|
4891
|
+
r(n);
|
|
4892
|
+
}), t;
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
export {
|
|
4896
|
+
Ot as $,
|
|
4897
|
+
cr as A,
|
|
4898
|
+
Pe as C,
|
|
4899
|
+
tt as E,
|
|
4900
|
+
Yi as F,
|
|
4901
|
+
be as I,
|
|
4902
|
+
ct as M,
|
|
4903
|
+
de as N,
|
|
4904
|
+
Ge as P,
|
|
4905
|
+
Gt as R,
|
|
4906
|
+
$ as S,
|
|
4907
|
+
ge as T,
|
|
4908
|
+
we as W,
|
|
4909
|
+
F as a,
|
|
4910
|
+
Et as b,
|
|
4911
|
+
Ji as c,
|
|
4912
|
+
z as d,
|
|
4913
|
+
Vi as e,
|
|
4914
|
+
or as f,
|
|
4915
|
+
gs as g,
|
|
4916
|
+
ps as h,
|
|
4917
|
+
ms as i,
|
|
4918
|
+
an as j,
|
|
4919
|
+
fe as k,
|
|
4920
|
+
R as l,
|
|
4921
|
+
ze as m,
|
|
4922
|
+
Hr as n,
|
|
4923
|
+
me as o,
|
|
4924
|
+
te as p,
|
|
4925
|
+
ft as q,
|
|
4926
|
+
br as r,
|
|
4927
|
+
b as s,
|
|
4928
|
+
pe as t,
|
|
4929
|
+
wn as u,
|
|
4930
|
+
Qe as v
|
|
4931
|
+
};
|
|
4932
|
+
//# sourceMappingURL=index-QnWieXQc.js.map
|