@inpageedit/core 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +13 -4
- package/dist/{BasePlugin-Bf2UuIHF.js → BasePlugin-YOi2_vUo.js} +17 -26
- package/dist/BasePlugin-YOi2_vUo.js.map +1 -0
- package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
- package/dist/InputBox-nQKtiWtZ.js.map +1 -1
- package/dist/{PluginPrefSync-Dn1Xsiqz.js → PluginPrefSync-jTNlRQE-.js} +124 -128
- package/dist/PluginPrefSync-jTNlRQE-.js.map +1 -0
- package/dist/PluginStoreApp-CGNxKXAN.js +453 -0
- package/dist/PluginStoreApp-CGNxKXAN.js.map +1 -0
- package/dist/{endpoints-DgyuoRZd.js → Preferences-BF2fcXrn.js} +608 -576
- package/dist/Preferences-BF2fcXrn.js.map +1 -0
- package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index-3NZkG2a3.js +116 -0
- package/dist/index-3NZkG2a3.js.map +1 -0
- package/dist/{index-BJ7_Q1mB.js → index-BBNseJXG.js} +17 -16
- package/dist/index-BBNseJXG.js.map +1 -0
- package/dist/{index-BQ-cHWkJ.js → index-Bb0FiU2c.js} +66 -48
- package/dist/index-Bb0FiU2c.js.map +1 -0
- package/dist/{index-DqA6EAM6.js → index-BgkZW91u.js} +1429 -928
- package/dist/index-BgkZW91u.js.map +1 -0
- package/dist/index-BrYKe18j.js +179 -0
- package/dist/index-BrYKe18j.js.map +1 -0
- package/dist/index-CG38LlAh.js.map +1 -1
- package/dist/index-CM_6yF2v.js.map +1 -1
- package/dist/index-D-fW3ESK.js +195 -0
- package/dist/index-D-fW3ESK.js.map +1 -0
- package/dist/index-D6zFqL2u.js +173 -0
- package/dist/index-D6zFqL2u.js.map +1 -0
- package/dist/{index-CCRMmnwk.js → index-D97lUU3h.js} +67 -66
- package/dist/index-D97lUU3h.js.map +1 -0
- package/dist/index-DD5CVCfD.js.map +1 -1
- package/dist/{index-B7c6jL9x.js → index-DELHsLHS.js} +146 -137
- package/dist/index-DELHsLHS.js.map +1 -0
- package/dist/{index-BwdWyHLe.js → index-DTHY5rAO.js} +93 -93
- package/dist/index-DTHY5rAO.js.map +1 -0
- package/dist/index-DmLoihN1.js +394 -0
- package/dist/index-DmLoihN1.js.map +1 -0
- package/dist/index.d.ts +362 -43
- package/dist/index.js +32 -26
- package/dist/index.js.map +1 -1
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/index.js +174 -154
- package/dist/models/index.js.map +1 -1
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/index.js +10 -10
- package/dist/services/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/vueHooks-l04s8cIl.js.map +1 -1
- package/lib/index.umd.js +20 -12
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +4 -4
- package/dist/BasePlugin-Bf2UuIHF.js.map +0 -1
- package/dist/PluginPrefSync-Dn1Xsiqz.js.map +0 -1
- package/dist/PluginStoreApp-CpOLArL7.js +0 -452
- package/dist/PluginStoreApp-CpOLArL7.js.map +0 -1
- package/dist/Preferences-DS4-CFWe.js +0 -9
- package/dist/Preferences-DS4-CFWe.js.map +0 -1
- package/dist/endpoints-DgyuoRZd.js.map +0 -1
- package/dist/index-2RfILgXm.js +0 -180
- package/dist/index-2RfILgXm.js.map +0 -1
- package/dist/index-B7c6jL9x.js.map +0 -1
- package/dist/index-BJ7_Q1mB.js.map +0 -1
- package/dist/index-BNh95-x2.js +0 -115
- package/dist/index-BNh95-x2.js.map +0 -1
- package/dist/index-BQ-cHWkJ.js.map +0 -1
- package/dist/index-BwdWyHLe.js.map +0 -1
- package/dist/index-CCRMmnwk.js.map +0 -1
- package/dist/index-CnIpUF9x.js +0 -173
- package/dist/index-CnIpUF9x.js.map +0 -1
- package/dist/index-CyG7_IYz.js +0 -394
- package/dist/index-CyG7_IYz.js.map +0 -1
- package/dist/index-DqA6EAM6.js.map +0 -1
- package/dist/index-eSlbrNqF.js +0 -146
- package/dist/index-eSlbrNqF.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useMemoryStorage as
|
|
2
|
-
import {
|
|
3
|
-
import { j as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
function
|
|
1
|
+
import { useMemoryStorage as $t, createWikiPageModel as Rt, createWikiTitleModel as xt } from "./models/index.js";
|
|
2
|
+
import { c as I, I as ne, S as m, d as je, h as Lt, p as H, R as At, E as qe, i as Tt } from "./Preferences-BF2fcXrn.js";
|
|
3
|
+
import { j as k, P as Ct } from "./index-CM_6yF2v.js";
|
|
4
|
+
var Fe = /* @__PURE__ */ ((r) => (r[r.debug = -1] = "debug", r[r.log = 0] = "log", r[r.info = 1] = "info", r[r.warn = 2] = "warn", r[r.error = 3] = "error", r[r.silent = 4] = "silent", r))(Fe || {});
|
|
5
|
+
const he = globalThis || window, ue = Symbol.for("__IPE_LOGGER_COLOR_MAP__");
|
|
6
|
+
he[ue] || (he[ue] = /* @__PURE__ */ new Map());
|
|
7
|
+
const le = he[ue];
|
|
8
|
+
function Y(r) {
|
|
9
9
|
let e = 2166136261;
|
|
10
|
-
for (let t = 0; t <
|
|
11
|
-
e ^=
|
|
10
|
+
for (let t = 0; t < r.length; t++)
|
|
11
|
+
e ^= r.charCodeAt(t), e = (e >>> 0) * 16777619;
|
|
12
12
|
return e >>> 0;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const Ae = [
|
|
15
15
|
[350, 360],
|
|
16
16
|
[0, 15],
|
|
17
17
|
[15, 30],
|
|
@@ -23,41 +23,41 @@ const _e = [
|
|
|
23
23
|
[140, 160],
|
|
24
24
|
[160, 180]
|
|
25
25
|
];
|
|
26
|
-
function
|
|
27
|
-
const t =
|
|
26
|
+
function Ot(r, e) {
|
|
27
|
+
const t = Ae.length, i = Y(r) % t, [s, n] = Ae[i], o = n - s, a = Y(r + ":" + e), c = s + a % (o || 1), l = Y(r + ":s"), h = Y(r + ":l");
|
|
28
28
|
let d, u;
|
|
29
29
|
if (e === "name")
|
|
30
30
|
d = 62 + l % 18, u = 30 + h % 12;
|
|
31
31
|
else {
|
|
32
|
-
const f = c >= 0 && c < 50 || c > 330 && c < 360,
|
|
33
|
-
d = 55 + l % 20,
|
|
32
|
+
const f = c >= 0 && c < 50 || c > 330 && c < 360, g = c >= 200 && c <= 300;
|
|
33
|
+
d = 55 + l % 20, g ? u = 55 + h % 8 : f ? u = 48 + h % 6 : u = 50 + h % 8, d < 60 && (d += 5);
|
|
34
34
|
}
|
|
35
35
|
return `hsl(${c}, ${d}%, ${u}%)`;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function X(r, e) {
|
|
38
38
|
if (e)
|
|
39
|
-
return
|
|
40
|
-
const t =
|
|
39
|
+
return le.set(r, e), e;
|
|
40
|
+
const t = le.get(r);
|
|
41
41
|
if (t) return t;
|
|
42
|
-
const i =
|
|
43
|
-
return
|
|
42
|
+
const i = r.startsWith("name:") ? "name" : "group", s = Ot(r, i);
|
|
43
|
+
return le.set(r, s), s;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let It = class He {
|
|
46
46
|
/**
|
|
47
47
|
* Note: constructor returns a callable Proxy so that you can do `logger('group')`.
|
|
48
48
|
*/
|
|
49
49
|
constructor(e = {}) {
|
|
50
50
|
this._custom = (t) => {
|
|
51
|
-
if (!this._enabled(t.level)) return
|
|
52
|
-
const [i,
|
|
53
|
-
return this._consoleMethod(t.method).bind(console, i, ...
|
|
51
|
+
if (!this._enabled(t.level)) return Te;
|
|
52
|
+
const [i, s] = this._prefix(t.label);
|
|
53
|
+
return this._consoleMethod(t.method).bind(console, i, ...s);
|
|
54
54
|
}, this._name = e.name, this._nameColor = e.color, this._groupPath = e._groupPath ? [...e._groupPath] : [], this._dynamicLevels = { ...e._dynamicLevels }, this._levelRef = e._levelRef ?? {
|
|
55
55
|
value: e.level ?? 1
|
|
56
56
|
/* info */
|
|
57
|
-
}, this._name &&
|
|
57
|
+
}, this._name && X(`name:${this._name}`, this._nameColor), this._installBuiltinLevels();
|
|
58
58
|
for (const t of Object.keys(this._dynamicLevels))
|
|
59
59
|
this._installLevelGetter(t, this._dynamicLevels[t]);
|
|
60
|
-
return
|
|
60
|
+
return Dt(this);
|
|
61
61
|
}
|
|
62
62
|
// ---------- public API ----------
|
|
63
63
|
get level() {
|
|
@@ -68,7 +68,7 @@ let yt = class De {
|
|
|
68
68
|
}
|
|
69
69
|
/** Create a sub-logger with a group label */
|
|
70
70
|
group(e, t) {
|
|
71
|
-
return e &&
|
|
71
|
+
return e && X(`group:${e}`, t?.color), new He({
|
|
72
72
|
name: this._name,
|
|
73
73
|
color: this._nameColor,
|
|
74
74
|
_groupPath: [...this._groupPath, e],
|
|
@@ -107,10 +107,10 @@ let yt = class De {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
_method(e) {
|
|
110
|
-
const t =
|
|
111
|
-
if (!this._enabled(t.level)) return
|
|
112
|
-
const [i,
|
|
113
|
-
return this._consoleMethod(e).bind(console, i, ...
|
|
110
|
+
const t = Pt[e];
|
|
111
|
+
if (!this._enabled(t.level)) return Te;
|
|
112
|
+
const [i, s] = this._prefix(t.label);
|
|
113
|
+
return this._consoleMethod(e).bind(console, i, ...s);
|
|
114
114
|
}
|
|
115
115
|
_consoleMethod(e) {
|
|
116
116
|
return (console[e] || console.log).bind(console);
|
|
@@ -122,94 +122,94 @@ let yt = class De {
|
|
|
122
122
|
const t = [];
|
|
123
123
|
let i = "";
|
|
124
124
|
if (this._name) {
|
|
125
|
-
const
|
|
125
|
+
const s = X(`name:${this._name}`, this._nameColor);
|
|
126
126
|
i += `%c${this._name}%c`, t.push(
|
|
127
|
-
`background:${
|
|
128
|
-
|
|
127
|
+
`background:${s}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,
|
|
128
|
+
Ce
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
if (e && (i += ` ${e}`), this._groupPath.length) {
|
|
132
|
-
const
|
|
133
|
-
i += ` %c${
|
|
132
|
+
const s = this._groupPath.join("/"), n = X(`group:${s}`);
|
|
133
|
+
i += ` %c${s}%c`, t.push(`color:${n}; text-decoration: underline;`, Ce);
|
|
134
134
|
}
|
|
135
135
|
return [i, t];
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
const
|
|
139
|
-
},
|
|
138
|
+
const Te = () => {
|
|
139
|
+
}, Ce = "color:inherit; background:transparent; text-decoration:none;", Pt = {
|
|
140
140
|
debug: { level: -1, label: "", method: "debug" },
|
|
141
141
|
log: { level: 0, label: "", method: "log" },
|
|
142
142
|
info: { level: 1, label: "[I]", method: "info" },
|
|
143
143
|
warn: { level: 2, label: "[W]", method: "warn" },
|
|
144
144
|
error: { level: 3, label: "[E]", method: "error" }
|
|
145
145
|
};
|
|
146
|
-
function
|
|
146
|
+
function Dt(r) {
|
|
147
147
|
const e = function(t, i) {
|
|
148
|
-
return
|
|
148
|
+
return r.group(t, i);
|
|
149
149
|
};
|
|
150
150
|
return new Proxy(e, {
|
|
151
|
-
get(t, i,
|
|
152
|
-
return
|
|
151
|
+
get(t, i, s) {
|
|
152
|
+
return r[i];
|
|
153
153
|
},
|
|
154
|
-
set(t, i,
|
|
155
|
-
return
|
|
154
|
+
set(t, i, s) {
|
|
155
|
+
return r[i] = s, !0;
|
|
156
156
|
},
|
|
157
|
-
apply(t, i,
|
|
158
|
-
return
|
|
157
|
+
apply(t, i, s) {
|
|
158
|
+
return r.group(s[0], s[1]);
|
|
159
159
|
},
|
|
160
160
|
has(t, i) {
|
|
161
|
-
return i in
|
|
161
|
+
return i in r;
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
return new
|
|
165
|
+
function Mt(r) {
|
|
166
|
+
return new It(r);
|
|
167
167
|
}
|
|
168
|
-
var
|
|
169
|
-
let
|
|
170
|
-
constructor(e, t, i,
|
|
171
|
-
super(t,
|
|
168
|
+
var x = /* @__PURE__ */ ((r) => (r.BODY_USED = "BODY_USED", r.NO_BODY_READER = "NO_BODY_READER", r.TIMEOUT = "TIMEOUT", r.NETWORK_ERROR = "NETWORK_ERROR", r.BODY_NOT_ALLOWED = "BODY_NOT_ALLOWED", r.HOOK_CONTEXT_CHANGED = "HOOK_CONTEXT_CHANGED", r.ABORTED_BY_HOOK = "ABORTED_BY_HOOK", r.INVALID_HOOK_CALLBACK = "INVALID_HOOK_CALLBACK", r.UNEXPECTED_HOOK_RETURN = "UNEXPECTED_HOOK_RETURN", r))(x || {});
|
|
169
|
+
let $ = class Ke extends Error {
|
|
170
|
+
constructor(e, t, i, s) {
|
|
171
|
+
super(t, s), this.code = e, this.context = i;
|
|
172
172
|
}
|
|
173
173
|
name = "FexiosError";
|
|
174
174
|
static is(e) {
|
|
175
|
-
return e?.constructor ===
|
|
175
|
+
return e?.constructor === Ke;
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, Ut = class We extends $ {
|
|
178
178
|
constructor(e, t, i) {
|
|
179
179
|
super(t.statusText, e, void 0, i), this.response = t;
|
|
180
180
|
}
|
|
181
181
|
name = "FexiosResponseError";
|
|
182
182
|
static is(e) {
|
|
183
|
-
return e?.constructor ===
|
|
183
|
+
return e?.constructor === We;
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
function
|
|
187
|
-
if (!(
|
|
186
|
+
function Bt(r, e = 2048) {
|
|
187
|
+
if (!(r instanceof Uint8Array))
|
|
188
188
|
throw new TypeError("Input must be a Uint8Array");
|
|
189
|
-
if (
|
|
189
|
+
if (r.length === 0)
|
|
190
190
|
return !0;
|
|
191
191
|
const t = Math.min(
|
|
192
|
-
Math.max(
|
|
192
|
+
Math.max(r.length, 256),
|
|
193
193
|
e
|
|
194
|
-
), i =
|
|
195
|
-
if (
|
|
194
|
+
), i = r.slice(0, t);
|
|
195
|
+
if (Nt(i))
|
|
196
196
|
return !1;
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
197
|
+
const s = jt(i);
|
|
198
|
+
if (s.nullByteRatio > 0.05 || s.highByteRatio > 0.95)
|
|
199
199
|
return !1;
|
|
200
200
|
const n = ["utf-8", "utf-16le", "utf-16be", "iso-8859-1"];
|
|
201
201
|
let o = -1, a = !1;
|
|
202
202
|
for (const c of n)
|
|
203
203
|
try {
|
|
204
|
-
const l = new TextDecoder(c, { fatal: !0 }).decode(i), h =
|
|
204
|
+
const l = new TextDecoder(c, { fatal: !0 }).decode(i), h = qt(l);
|
|
205
205
|
h > o && (o = h, a = h > 0.7);
|
|
206
206
|
} catch {
|
|
207
207
|
continue;
|
|
208
208
|
}
|
|
209
209
|
return a;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
if (
|
|
211
|
+
function Nt(r) {
|
|
212
|
+
if (r.length < 4) return !1;
|
|
213
213
|
const e = [
|
|
214
214
|
[137, 80, 78, 71],
|
|
215
215
|
// PNG
|
|
@@ -237,10 +237,10 @@ function Et(s) {
|
|
|
237
237
|
// RIFF (AVI, WAV, etc.)
|
|
238
238
|
];
|
|
239
239
|
for (const t of e)
|
|
240
|
-
if (
|
|
240
|
+
if (r.length >= t.length) {
|
|
241
241
|
let i = !0;
|
|
242
|
-
for (let
|
|
243
|
-
if (s
|
|
242
|
+
for (let s = 0; s < t.length; s++)
|
|
243
|
+
if (r[s] !== t[s]) {
|
|
244
244
|
i = !1;
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
@@ -248,33 +248,33 @@ function Et(s) {
|
|
|
248
248
|
}
|
|
249
249
|
return !1;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function jt(r) {
|
|
252
252
|
let e = 0, t = 0, i = 0;
|
|
253
|
-
for (const
|
|
254
|
-
|
|
253
|
+
for (const s of r)
|
|
254
|
+
s === 0 && e++, s > 127 && t++, (s < 32 && s !== 9 && s !== 10 && s !== 13 || s === 127) && i++;
|
|
255
255
|
return {
|
|
256
|
-
nullByteRatio: e /
|
|
257
|
-
highByteRatio: t /
|
|
258
|
-
controlCharRatio: i /
|
|
256
|
+
nullByteRatio: e / r.length,
|
|
257
|
+
highByteRatio: t / r.length,
|
|
258
|
+
controlCharRatio: i / r.length
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
if (
|
|
261
|
+
function qt(r) {
|
|
262
|
+
if (r.length === 0) return 1;
|
|
263
263
|
let e = 1, t = 0;
|
|
264
|
-
for (let
|
|
265
|
-
const n = s
|
|
266
|
-
n >= 32 && n <= 126 || n === 9 || n === 10 || n === 13 || n === 32 ? t++ : n > 127 && n < 65534 ? !
|
|
264
|
+
for (let s = 0; s < r.length; s++) {
|
|
265
|
+
const n = r[s].charCodeAt(0);
|
|
266
|
+
n >= 32 && n <= 126 || n === 9 || n === 10 || n === 13 || n === 32 ? t++ : n > 127 && n < 65534 ? !Ft(n) && !Ht(n) && t++ : e -= 0.1;
|
|
267
267
|
}
|
|
268
|
-
const i = t /
|
|
269
|
-
return e *= i,
|
|
268
|
+
const i = t / r.length;
|
|
269
|
+
return e *= i, Kt(r) && (e *= 1.1), Math.max(0, Math.min(1, e));
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
return
|
|
271
|
+
function Ft(r) {
|
|
272
|
+
return r >= 0 && r <= 31 || r >= 127 && r <= 159;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
return
|
|
274
|
+
function Ht(r) {
|
|
275
|
+
return r >= 57344 && r <= 63743 || r >= 983040 && r <= 1048573 || r >= 1048576 && r <= 1114109;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function Kt(r) {
|
|
278
278
|
return [
|
|
279
279
|
/\b\w+\b/,
|
|
280
280
|
// Words
|
|
@@ -288,38 +288,38 @@ function At(s) {
|
|
|
288
288
|
// Chinese characters
|
|
289
289
|
/\d+/
|
|
290
290
|
// Numbers
|
|
291
|
-
].some((e) => e.test(
|
|
291
|
+
].some((e) => e.test(r));
|
|
292
292
|
}
|
|
293
|
-
function A(
|
|
294
|
-
if (typeof
|
|
293
|
+
function A(r) {
|
|
294
|
+
if (typeof r != "object" || r === null || Object.prototype.toString.call(r) !== "[object Object]")
|
|
295
295
|
return !1;
|
|
296
|
-
const e = Object.getPrototypeOf(
|
|
296
|
+
const e = Object.getPrototypeOf(r);
|
|
297
297
|
return e === Object.prototype || e === null;
|
|
298
298
|
}
|
|
299
|
-
const
|
|
300
|
-
const t = (
|
|
301
|
-
if (Array.isArray(
|
|
302
|
-
if (A(
|
|
299
|
+
const K = (r, ...e) => {
|
|
300
|
+
const t = (s) => {
|
|
301
|
+
if (Array.isArray(s)) return s.slice();
|
|
302
|
+
if (A(s)) {
|
|
303
303
|
const n = {};
|
|
304
|
-
for (const o of Reflect.ownKeys(
|
|
304
|
+
for (const o of Reflect.ownKeys(s)) n[o] = t(s[o]);
|
|
305
305
|
return n;
|
|
306
306
|
}
|
|
307
|
-
return
|
|
308
|
-
}, i = t(
|
|
309
|
-
for (const
|
|
310
|
-
if (
|
|
311
|
-
for (const n of Reflect.ownKeys(
|
|
312
|
-
const o =
|
|
307
|
+
return s;
|
|
308
|
+
}, i = t(r);
|
|
309
|
+
for (const s of e)
|
|
310
|
+
if (s != null)
|
|
311
|
+
for (const n of Reflect.ownKeys(s)) {
|
|
312
|
+
const o = s[n];
|
|
313
313
|
if (typeof o > "u") continue;
|
|
314
314
|
const a = i[n];
|
|
315
|
-
A(a) && A(o) ? i[n] =
|
|
315
|
+
A(a) && A(o) ? i[n] = K(a, o) : i[n] = t(o);
|
|
316
316
|
}
|
|
317
317
|
return i;
|
|
318
318
|
};
|
|
319
|
-
let
|
|
319
|
+
let q = class {
|
|
320
320
|
constructor(e, t, i) {
|
|
321
|
-
this.rawResponse = e, this.data = t, this.ok = e.ok, this.status = e.status, this.statusText = e.statusText, this.headers = e.headers, Object.entries(i || {}).forEach(([
|
|
322
|
-
this[
|
|
321
|
+
this.rawResponse = e, this.data = t, this.ok = e.ok, this.status = e.status, this.statusText = e.statusText, this.headers = e.headers, Object.entries(i || {}).forEach(([s, n]) => {
|
|
322
|
+
this[s] = n;
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
325
|
ok;
|
|
@@ -327,50 +327,50 @@ let B = class {
|
|
|
327
327
|
statusText;
|
|
328
328
|
headers;
|
|
329
329
|
};
|
|
330
|
-
async function
|
|
331
|
-
if (
|
|
332
|
-
throw new
|
|
333
|
-
|
|
330
|
+
async function Oe(r, e, t) {
|
|
331
|
+
if (r.bodyUsed)
|
|
332
|
+
throw new $(
|
|
333
|
+
x.BODY_USED,
|
|
334
334
|
"Response body has already been used or locked"
|
|
335
335
|
);
|
|
336
|
-
const i =
|
|
337
|
-
if ((
|
|
338
|
-
const a = new WebSocket(
|
|
336
|
+
const i = r.headers.get("content-type") || "", s = Number(r.headers.get("content-length")) || 0, n = (a, c) => c === "json" || a.startsWith("application/json"), o = (a, c, l) => l === "blob" || a.startsWith("image/") && !a.startsWith("image/svg") || a.startsWith("video/") || a.startsWith("audio/") || !Bt(c);
|
|
337
|
+
if ((r.status === 101 || r.status === 426 || r.headers.get("upgrade")) && typeof globalThis.WebSocket < "u") {
|
|
338
|
+
const a = new WebSocket(r.url);
|
|
339
339
|
return await new Promise((c, l) => {
|
|
340
340
|
a.onopen = c, a.onerror = l;
|
|
341
|
-
}), new
|
|
341
|
+
}), new q(r, a, {
|
|
342
342
|
ok: !0,
|
|
343
343
|
status: 101,
|
|
344
344
|
statusText: "Switching Protocols"
|
|
345
345
|
});
|
|
346
346
|
} else if (i.startsWith("text/event-stream") && !["text", "json"].includes(e || "") && typeof globalThis.EventSource < "u") {
|
|
347
|
-
const a = new EventSource(
|
|
347
|
+
const a = new EventSource(r.url);
|
|
348
348
|
return await new Promise((c, l) => {
|
|
349
349
|
a.onopen = c, a.onerror = l;
|
|
350
|
-
}), new
|
|
350
|
+
}), new q(r, a);
|
|
351
351
|
} else {
|
|
352
352
|
if (e === "stream")
|
|
353
|
-
return new
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
return new q(
|
|
354
|
+
r,
|
|
355
|
+
r.body
|
|
356
356
|
);
|
|
357
357
|
{
|
|
358
|
-
const a =
|
|
358
|
+
const a = r.clone().body?.getReader();
|
|
359
359
|
if (!a)
|
|
360
|
-
throw new
|
|
361
|
-
|
|
360
|
+
throw new $(
|
|
361
|
+
x.NO_BODY_READER,
|
|
362
362
|
"Failed to get ReadableStream from response body"
|
|
363
363
|
);
|
|
364
364
|
let c = new Uint8Array();
|
|
365
365
|
for (; ; ) {
|
|
366
366
|
const { done: h, value: d } = await a.read();
|
|
367
367
|
if (h) break;
|
|
368
|
-
if (d && (c = new Uint8Array([...c, ...d]), t &&
|
|
369
|
-
const u = Math.min(c.length /
|
|
368
|
+
if (d && (c = new Uint8Array([...c, ...d]), t && s > 0)) {
|
|
369
|
+
const u = Math.min(c.length / s, 1);
|
|
370
370
|
t(u, c);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
const l = new
|
|
373
|
+
const l = new q(r, void 0);
|
|
374
374
|
if (e === "arrayBuffer")
|
|
375
375
|
return l.data = c.buffer, l;
|
|
376
376
|
if (n(i, e))
|
|
@@ -380,7 +380,7 @@ async function $e(s, e, t) {
|
|
|
380
380
|
} catch {
|
|
381
381
|
}
|
|
382
382
|
if (typeof l.data != "string" && o(i, c, e) ? l.data = new Blob([c], {
|
|
383
|
-
type:
|
|
383
|
+
type: r.headers.get("content-type") || void 0
|
|
384
384
|
}) : l.data = new TextDecoder().decode(c), typeof l.data == "string" && e !== "text") {
|
|
385
385
|
const h = l.data.trim(), d = h[0], u = h[h.length - 1];
|
|
386
386
|
if (d === "{" && u === "}" || d === "[" && u === "]")
|
|
@@ -391,21 +391,21 @@ async function $e(s, e, t) {
|
|
|
391
391
|
}
|
|
392
392
|
if (typeof l.data > "u" && (l.data = c.length > 0 ? c : void 0), l.ok)
|
|
393
393
|
return l;
|
|
394
|
-
throw new
|
|
395
|
-
`Request failed with status code ${
|
|
394
|
+
throw new Ut(
|
|
395
|
+
`Request failed with status code ${r.status}`,
|
|
396
396
|
l
|
|
397
397
|
);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
var
|
|
402
|
-
((
|
|
403
|
-
|
|
404
|
-
if (!
|
|
401
|
+
var V;
|
|
402
|
+
((r) => {
|
|
403
|
+
r.makeSearchParams = (s) => {
|
|
404
|
+
if (!s)
|
|
405
405
|
return new URLSearchParams();
|
|
406
|
-
if (
|
|
407
|
-
return
|
|
408
|
-
if (typeof
|
|
406
|
+
if (s instanceof URLSearchParams)
|
|
407
|
+
return s;
|
|
408
|
+
if (typeof s != "object" || s?.constructor !== Object)
|
|
409
409
|
throw new TypeError("only plain object is supported");
|
|
410
410
|
const n = new URLSearchParams(), o = (l, h) => {
|
|
411
411
|
h != null && n.append(l, h);
|
|
@@ -420,29 +420,29 @@ var X;
|
|
|
420
420
|
if (typeof h == "object" && h.constructor === Object) {
|
|
421
421
|
for (const [d, u] of Object.entries(h)) {
|
|
422
422
|
if (u == null) continue;
|
|
423
|
-
const f = d.endsWith("[]"),
|
|
423
|
+
const f = d.endsWith("[]"), g = f ? d.slice(0, -2) : d, p = `${l}[${g}]`;
|
|
424
424
|
if (f) {
|
|
425
|
-
const
|
|
425
|
+
const y = `${p}[]`;
|
|
426
426
|
if (Array.isArray(u))
|
|
427
|
-
for (const
|
|
428
|
-
else typeof u == "object" && u !== null && u.constructor === Object ? c(`${
|
|
427
|
+
for (const L of u) o(y, L?.toString());
|
|
428
|
+
else typeof u == "object" && u !== null && u.constructor === Object ? c(`${p}[]`, u) : o(y, u?.toString());
|
|
429
429
|
} else if (Array.isArray(u))
|
|
430
|
-
for (const
|
|
431
|
-
else typeof u == "object" && u !== null && u.constructor === Object ? c(
|
|
430
|
+
for (const y of u) o(p, y?.toString());
|
|
431
|
+
else typeof u == "object" && u !== null && u.constructor === Object ? c(p, u) : a(p, u?.toString());
|
|
432
432
|
}
|
|
433
433
|
return;
|
|
434
434
|
}
|
|
435
435
|
a(l, h?.toString());
|
|
436
436
|
}
|
|
437
437
|
};
|
|
438
|
-
for (const [l, h] of Object.entries(
|
|
438
|
+
for (const [l, h] of Object.entries(s))
|
|
439
439
|
c(l, h);
|
|
440
440
|
return n;
|
|
441
|
-
},
|
|
442
|
-
const c = typeof window < "u" && window.location?.origin || "http://localhost", l = typeof
|
|
441
|
+
}, r.makeQueryString = (s) => (0, r.makeSearchParams)(s).toString(), r.makeURL = (s, n, o, a) => {
|
|
442
|
+
const c = typeof window < "u" && window.location?.origin || "http://localhost", l = typeof s == "string" ? new URL(s, a ?? c) : new URL(s), h = (0, r.toQueryRecord)(l.searchParams), d = (0, r.mergeQueries)(h, n || {}), u = (0, r.makeSearchParams)(d);
|
|
443
443
|
return l.search = u.toString(), l.hash = o || "", l;
|
|
444
|
-
},
|
|
445
|
-
typeof
|
|
444
|
+
}, r.toQueryRecord = (s) => {
|
|
445
|
+
typeof s == "string" && (s = (0, r.fromString)(s));
|
|
446
446
|
const n = {}, o = (c) => {
|
|
447
447
|
if (!c.includes("[")) return { path: [c], forceArray: !1 };
|
|
448
448
|
const l = [c.slice(0, c.indexOf("["))], h = /\[([^\]]*)\]/g;
|
|
@@ -453,17 +453,17 @@ var X;
|
|
|
453
453
|
}, a = (c, l, h, d) => {
|
|
454
454
|
let u = c;
|
|
455
455
|
for (let f = 0; f < l.length; f++) {
|
|
456
|
-
const
|
|
457
|
-
f === l.length - 1 ? d ? u[
|
|
456
|
+
const g = l[f];
|
|
457
|
+
f === l.length - 1 ? d ? u[g] === void 0 ? u[g] = [h] : Array.isArray(u[g]) ? u[g].push(h) : u[g] = [u[g], h] : u[g] === void 0 ? u[g] = h : Array.isArray(u[g]) ? u[g].push(h) : u[g] = [u[g], h] : ((u[g] === void 0 || typeof u[g] != "object" || Array.isArray(u[g])) && (u[g] = {}), u = u[g]);
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
|
-
for (const [c, l] of
|
|
460
|
+
for (const [c, l] of s.entries()) {
|
|
461
461
|
const { path: h, forceArray: d } = o(String(c));
|
|
462
462
|
a(n, h, l?.toString(), d);
|
|
463
463
|
}
|
|
464
464
|
return n;
|
|
465
|
-
},
|
|
466
|
-
const n =
|
|
465
|
+
}, r.fromString = (s) => {
|
|
466
|
+
const n = s.trim();
|
|
467
467
|
if (!n) return new URLSearchParams();
|
|
468
468
|
if (n.startsWith("?")) return new URLSearchParams(n.slice(1));
|
|
469
469
|
const o = n.indexOf("?");
|
|
@@ -472,108 +472,108 @@ var X;
|
|
|
472
472
|
return new URLSearchParams(c);
|
|
473
473
|
}
|
|
474
474
|
return new URLSearchParams(n);
|
|
475
|
-
},
|
|
476
|
-
const o = e(t(
|
|
475
|
+
}, r.mergeQueries = (s, ...n) => {
|
|
476
|
+
const o = e(t(s));
|
|
477
477
|
for (const a of n)
|
|
478
478
|
a != null && i(o, t(a));
|
|
479
479
|
return o;
|
|
480
480
|
};
|
|
481
|
-
function e(
|
|
482
|
-
if (Array.isArray(
|
|
483
|
-
if (A(
|
|
481
|
+
function e(s) {
|
|
482
|
+
if (Array.isArray(s)) return s.map(e);
|
|
483
|
+
if (A(s)) {
|
|
484
484
|
const n = {};
|
|
485
|
-
for (const [o, a] of Object.entries(
|
|
485
|
+
for (const [o, a] of Object.entries(s)) n[o] = e(a);
|
|
486
486
|
return n;
|
|
487
487
|
}
|
|
488
|
-
if (
|
|
488
|
+
if (s instanceof Map) {
|
|
489
489
|
const n = {};
|
|
490
|
-
for (const [o, a] of
|
|
490
|
+
for (const [o, a] of s.entries()) n[o] = e(a);
|
|
491
491
|
return n;
|
|
492
492
|
}
|
|
493
|
-
return
|
|
493
|
+
return s;
|
|
494
494
|
}
|
|
495
|
-
function t(
|
|
496
|
-
if (!
|
|
497
|
-
if (
|
|
498
|
-
return (0,
|
|
499
|
-
if (typeof
|
|
500
|
-
if (A(
|
|
495
|
+
function t(s) {
|
|
496
|
+
if (!s) return {};
|
|
497
|
+
if (s instanceof URLSearchParams || s instanceof FormData || s instanceof Map)
|
|
498
|
+
return (0, r.toQueryRecord)(s);
|
|
499
|
+
if (typeof s == "string") return (0, r.toQueryRecord)((0, r.fromString)(s));
|
|
500
|
+
if (A(s)) return s;
|
|
501
501
|
throw new TypeError(
|
|
502
502
|
`unsupported type transformation, got: ${Object.prototype.toString.call(
|
|
503
|
-
|
|
503
|
+
s
|
|
504
504
|
)}`
|
|
505
505
|
);
|
|
506
506
|
}
|
|
507
|
-
function i(
|
|
507
|
+
function i(s, n) {
|
|
508
508
|
for (const [o, a] of Object.entries(n)) {
|
|
509
509
|
if (a === void 0) continue;
|
|
510
510
|
if (a === null) {
|
|
511
|
-
delete
|
|
511
|
+
delete s[o];
|
|
512
512
|
continue;
|
|
513
513
|
}
|
|
514
|
-
const c =
|
|
515
|
-
A(c) && A(a) ? i(c, a) :
|
|
514
|
+
const c = s[o];
|
|
515
|
+
A(c) && A(a) ? i(c, a) : s[o] = e(a);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
})(
|
|
519
|
-
const
|
|
520
|
-
const e = this.constructor.prototype, t = Reflect.get(e,
|
|
521
|
-
function i(...
|
|
522
|
-
return Reflect.apply(t, i,
|
|
518
|
+
})(V || (V = {}));
|
|
519
|
+
const ze = function(r) {
|
|
520
|
+
const e = this.constructor.prototype, t = Reflect.get(e, r, e);
|
|
521
|
+
function i(...s) {
|
|
522
|
+
return Reflect.apply(t, i, s);
|
|
523
523
|
}
|
|
524
524
|
Reflect.setPrototypeOf(i, e);
|
|
525
|
-
for (const
|
|
526
|
-
const n = Reflect.getOwnPropertyDescriptor(t,
|
|
527
|
-
n && Reflect.defineProperty(i,
|
|
525
|
+
for (const s of Reflect.ownKeys(t)) {
|
|
526
|
+
const n = Reflect.getOwnPropertyDescriptor(t, s);
|
|
527
|
+
n && Reflect.defineProperty(i, s, n);
|
|
528
528
|
}
|
|
529
529
|
return i;
|
|
530
530
|
};
|
|
531
|
-
|
|
532
|
-
var
|
|
533
|
-
((
|
|
534
|
-
|
|
531
|
+
ze.prototype = Object.create(Function.prototype);
|
|
532
|
+
var W;
|
|
533
|
+
((r) => {
|
|
534
|
+
r.makeHeaders = (e) => {
|
|
535
535
|
if (!e) return new Headers();
|
|
536
536
|
if (e instanceof Headers) return new Headers(e);
|
|
537
537
|
const t = new Headers();
|
|
538
538
|
if (e instanceof Map) {
|
|
539
|
-
for (const [i,
|
|
540
|
-
if (
|
|
541
|
-
if (Array.isArray(
|
|
542
|
-
for (const n of
|
|
539
|
+
for (const [i, s] of e.entries())
|
|
540
|
+
if (s != null)
|
|
541
|
+
if (Array.isArray(s))
|
|
542
|
+
for (const n of s)
|
|
543
543
|
n != null && t.append(i, String(n));
|
|
544
544
|
else
|
|
545
|
-
t.append(i, String(
|
|
545
|
+
t.append(i, String(s));
|
|
546
546
|
return t;
|
|
547
547
|
}
|
|
548
548
|
if (A(e)) {
|
|
549
|
-
for (const [i,
|
|
550
|
-
if (
|
|
551
|
-
if (Array.isArray(
|
|
552
|
-
for (const n of
|
|
549
|
+
for (const [i, s] of Object.entries(e))
|
|
550
|
+
if (s != null)
|
|
551
|
+
if (Array.isArray(s))
|
|
552
|
+
for (const n of s)
|
|
553
553
|
n != null && t.append(i, String(n));
|
|
554
554
|
else
|
|
555
|
-
t.append(i, String(
|
|
555
|
+
t.append(i, String(s));
|
|
556
556
|
return t;
|
|
557
557
|
}
|
|
558
558
|
throw new TypeError(
|
|
559
559
|
"only plain object, Map/ReadonlyMap, or Headers is supported"
|
|
560
560
|
);
|
|
561
|
-
},
|
|
561
|
+
}, r.toHeaderRecord = (e) => {
|
|
562
562
|
if (e instanceof Headers) {
|
|
563
563
|
const t = {};
|
|
564
|
-
return e.forEach((i,
|
|
565
|
-
t[
|
|
564
|
+
return e.forEach((i, s) => {
|
|
565
|
+
t[s] = t[s] ? [...t[s], i] : [i];
|
|
566
566
|
}), t;
|
|
567
567
|
}
|
|
568
568
|
if (e instanceof Map) {
|
|
569
569
|
const t = {};
|
|
570
|
-
for (const [i,
|
|
571
|
-
if (
|
|
572
|
-
if (Array.isArray(
|
|
573
|
-
const n =
|
|
570
|
+
for (const [i, s] of e.entries())
|
|
571
|
+
if (s != null)
|
|
572
|
+
if (Array.isArray(s)) {
|
|
573
|
+
const n = s.filter((o) => o != null).map((o) => String(o));
|
|
574
574
|
n.length && (t[i] = (t[i] ?? []).concat(n));
|
|
575
575
|
} else {
|
|
576
|
-
const n = String(
|
|
576
|
+
const n = String(s);
|
|
577
577
|
t[i] = t[i] ? [...t[i], n] : [n];
|
|
578
578
|
}
|
|
579
579
|
return t;
|
|
@@ -583,8 +583,8 @@ var H;
|
|
|
583
583
|
e
|
|
584
584
|
)}`
|
|
585
585
|
);
|
|
586
|
-
},
|
|
587
|
-
const i = e instanceof Headers ? new Headers(e) : (0,
|
|
586
|
+
}, r.mergeHeaders = (e, ...t) => {
|
|
587
|
+
const i = e instanceof Headers ? new Headers(e) : (0, r.makeHeaders)(e), s = (n) => {
|
|
588
588
|
for (const [o, a] of Object.entries(n))
|
|
589
589
|
if (a !== void 0) {
|
|
590
590
|
if (a === null) {
|
|
@@ -608,10 +608,10 @@ var H;
|
|
|
608
608
|
continue;
|
|
609
609
|
}
|
|
610
610
|
if (A(n)) {
|
|
611
|
-
|
|
611
|
+
s(n);
|
|
612
612
|
continue;
|
|
613
613
|
}
|
|
614
|
-
const o = (0,
|
|
614
|
+
const o = (0, r.toHeaderRecord)(n);
|
|
615
615
|
for (const [a, c] of Object.entries(o)) {
|
|
616
616
|
i.delete(a);
|
|
617
617
|
for (const l of c) i.append(a, l);
|
|
@@ -619,8 +619,8 @@ var H;
|
|
|
619
619
|
}
|
|
620
620
|
return i;
|
|
621
621
|
};
|
|
622
|
-
})(
|
|
623
|
-
let
|
|
622
|
+
})(W || (W = {}));
|
|
623
|
+
let de = class _ extends ze {
|
|
624
624
|
static FINAL_SYMBOL = Symbol("FEXIOS_FINAL_CONTEXT");
|
|
625
625
|
static NORMALIZED_SYMBOL = Symbol("FEXIOS_NORMALIZED_QUERY");
|
|
626
626
|
baseConfigs;
|
|
@@ -651,21 +651,21 @@ let le = class v extends Ne {
|
|
|
651
651
|
"trace"
|
|
652
652
|
];
|
|
653
653
|
constructor(e = {}) {
|
|
654
|
-
super("request"), this.baseConfigs =
|
|
654
|
+
super("request"), this.baseConfigs = K(_.DEFAULT_CONFIGS, e), _.ALL_METHODS.forEach(
|
|
655
655
|
(t) => this.createMethodShortcut(t.toLowerCase())
|
|
656
656
|
);
|
|
657
657
|
}
|
|
658
658
|
async request(e, t) {
|
|
659
659
|
let i = t = t || {};
|
|
660
|
-
if (typeof e == "string" || e instanceof URL ? i.url = e.toString() : typeof e == "object" && (i =
|
|
660
|
+
if (typeof e == "string" || e instanceof URL ? i.url = e.toString() : typeof e == "object" && (i = K(e, i)), i = await this.emit("beforeInit", i, {
|
|
661
661
|
shouldAdjustRequestParams: !0,
|
|
662
662
|
shouldHandleShortCircuitResponse: !0
|
|
663
|
-
}), i[
|
|
664
|
-
if (
|
|
663
|
+
}), i[_.FINAL_SYMBOL]) return i;
|
|
664
|
+
if (_.METHODS_WITHOUT_BODY.includes(
|
|
665
665
|
i.method?.toLocaleLowerCase()
|
|
666
666
|
) && i.body)
|
|
667
|
-
throw new
|
|
668
|
-
|
|
667
|
+
throw new $(
|
|
668
|
+
x.BODY_NOT_ALLOWED,
|
|
669
669
|
`Request method "${i.method}" does not allow body`
|
|
670
670
|
);
|
|
671
671
|
if (i = await this.emit("beforeRequest", i, {
|
|
@@ -675,23 +675,23 @@ let le = class v extends Ne {
|
|
|
675
675
|
requestOptionsOverridesURLSearchParams: !0,
|
|
676
676
|
preRequestOptionsOverridesURLSearchParams: !0,
|
|
677
677
|
postRequestOptionsOverridesURLSearchParams: !0
|
|
678
|
-
}), i[
|
|
679
|
-
let
|
|
678
|
+
}), i[_.FINAL_SYMBOL]) return i;
|
|
679
|
+
let s;
|
|
680
680
|
const n = {};
|
|
681
|
-
if (typeof i.body < "u" && i.body !== null && (i.body instanceof Blob || i.body instanceof FormData || i.body instanceof URLSearchParams ?
|
|
681
|
+
if (typeof i.body < "u" && i.body !== null && (i.body instanceof Blob || i.body instanceof FormData || i.body instanceof URLSearchParams ? s = i.body : typeof i.body == "object" && i.body !== null ? (s = JSON.stringify(i.body), i.headers = this.mergeHeaders(i.headers, {
|
|
682
682
|
"Content-Type": "application/json"
|
|
683
|
-
})) :
|
|
683
|
+
})) : s = i.body), !W.makeHeaders(
|
|
684
684
|
t.headers || {}
|
|
685
|
-
).get("content-type") &&
|
|
685
|
+
).get("content-type") && s && (s instanceof FormData || s instanceof URLSearchParams ? n["content-type"] = null : typeof s == "string" && typeof i.body == "object" ? n["content-type"] = "application/json" : s instanceof Blob && (n["content-type"] = s.type || "application/octet-stream")), i.body = s, i = await this.emit("afterBodyTransformed", i, {
|
|
686
686
|
shouldAdjustRequestParams: !0,
|
|
687
687
|
shouldHandleShortCircuitResponse: !0,
|
|
688
688
|
preAdjust: !0,
|
|
689
689
|
postRequestOptionsOverridesURLSearchParams: !0
|
|
690
|
-
}), i[
|
|
690
|
+
}), i[_.FINAL_SYMBOL]) return i;
|
|
691
691
|
const o = i.abortController || globalThis.AbortController ? new AbortController() : void 0, a = i.baseURL || this.baseConfigs.baseURL || globalThis.location?.href || "http://localhost", c = new URL(
|
|
692
692
|
i.url.toString(),
|
|
693
693
|
a
|
|
694
|
-
), l =
|
|
694
|
+
), l = V.makeURL(
|
|
695
695
|
c,
|
|
696
696
|
i.query,
|
|
697
697
|
c.hash
|
|
@@ -700,7 +700,7 @@ let le = class v extends Ne {
|
|
|
700
700
|
credentials: i.credentials,
|
|
701
701
|
cache: i.cache,
|
|
702
702
|
mode: i.mode,
|
|
703
|
-
headers:
|
|
703
|
+
headers: W.mergeHeaders(
|
|
704
704
|
this.baseConfigs.headers,
|
|
705
705
|
i.headers || {},
|
|
706
706
|
n
|
|
@@ -710,48 +710,48 @@ let le = class v extends Ne {
|
|
|
710
710
|
});
|
|
711
711
|
if (i.rawRequest = h, i = await this.emit("beforeActualFetch", i, {
|
|
712
712
|
shouldHandleShortCircuitResponse: !0
|
|
713
|
-
}), i[
|
|
713
|
+
}), i[_.FINAL_SYMBOL]) return i;
|
|
714
714
|
const d = i.timeout || this.baseConfigs.timeout || 60 * 1e3;
|
|
715
715
|
if (i.url.startsWith("ws"))
|
|
716
716
|
try {
|
|
717
717
|
const f = new WebSocket(i.url);
|
|
718
|
-
return await new Promise((
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
new
|
|
722
|
-
|
|
718
|
+
return await new Promise((g, p) => {
|
|
719
|
+
const y = setTimeout(() => {
|
|
720
|
+
p(
|
|
721
|
+
new $(
|
|
722
|
+
x.TIMEOUT,
|
|
723
723
|
`WebSocket connection timed out after ${d}ms`,
|
|
724
724
|
i
|
|
725
725
|
)
|
|
726
726
|
);
|
|
727
727
|
}, d);
|
|
728
728
|
f.onopen = () => {
|
|
729
|
-
clearTimeout(
|
|
730
|
-
}, f.onerror = (
|
|
731
|
-
clearTimeout(
|
|
732
|
-
new
|
|
733
|
-
|
|
729
|
+
clearTimeout(y), g();
|
|
730
|
+
}, f.onerror = (L) => {
|
|
731
|
+
clearTimeout(y), p(
|
|
732
|
+
new $(
|
|
733
|
+
x.NETWORK_ERROR,
|
|
734
734
|
"WebSocket connection failed",
|
|
735
735
|
i
|
|
736
736
|
)
|
|
737
737
|
);
|
|
738
|
-
}, f.onclose = (
|
|
739
|
-
|
|
740
|
-
new
|
|
741
|
-
|
|
742
|
-
`WebSocket closed with code ${
|
|
738
|
+
}, f.onclose = (L) => {
|
|
739
|
+
L.code !== 1e3 && (clearTimeout(y), p(
|
|
740
|
+
new $(
|
|
741
|
+
x.NETWORK_ERROR,
|
|
742
|
+
`WebSocket closed with code ${L.code}`,
|
|
743
743
|
i
|
|
744
744
|
)
|
|
745
745
|
));
|
|
746
746
|
};
|
|
747
|
-
}), i.rawResponse = new Response(), i.response = new
|
|
747
|
+
}), i.rawResponse = new Response(), i.response = new q(i.rawResponse, f, {
|
|
748
748
|
ok: !0,
|
|
749
749
|
status: 101,
|
|
750
750
|
statusText: "Switching Protocols"
|
|
751
751
|
}), i.data = f, i.headers = new Headers(), this.emit("afterResponse", i);
|
|
752
752
|
} catch (f) {
|
|
753
|
-
throw f instanceof
|
|
754
|
-
|
|
753
|
+
throw f instanceof $ ? f : new $(
|
|
754
|
+
x.NETWORK_ERROR,
|
|
755
755
|
`WebSocket creation failed: ${f}`,
|
|
756
756
|
i
|
|
757
757
|
);
|
|
@@ -761,31 +761,31 @@ let le = class v extends Ne {
|
|
|
761
761
|
o && (u = setTimeout(() => {
|
|
762
762
|
o.abort();
|
|
763
763
|
}, d));
|
|
764
|
-
const f = await (t.fetch || this.baseConfigs.fetch || globalThis.fetch)(i.rawRequest).catch((
|
|
765
|
-
throw u && clearTimeout(u), o?.signal.aborted ? new
|
|
766
|
-
|
|
764
|
+
const f = await (t.fetch || this.baseConfigs.fetch || globalThis.fetch)(i.rawRequest).catch((g) => {
|
|
765
|
+
throw u && clearTimeout(u), o?.signal.aborted ? new $(
|
|
766
|
+
x.TIMEOUT,
|
|
767
767
|
`Request timed out after ${d}ms`,
|
|
768
768
|
i
|
|
769
|
-
) : new
|
|
769
|
+
) : new $(x.NETWORK_ERROR, g.message, i);
|
|
770
770
|
});
|
|
771
|
-
return u && clearTimeout(u), i.rawResponse = f, i.response = await
|
|
771
|
+
return u && clearTimeout(u), i.rawResponse = f, i.response = await Oe(
|
|
772
772
|
f,
|
|
773
773
|
i.responseType,
|
|
774
|
-
(
|
|
775
|
-
t?.onProgress?.(
|
|
774
|
+
(g, p) => {
|
|
775
|
+
t?.onProgress?.(g, p);
|
|
776
776
|
}
|
|
777
777
|
), i.data = i.response.data, i.headers = i.response.headers, this.emit("afterResponse", i);
|
|
778
778
|
} catch (f) {
|
|
779
779
|
throw u && clearTimeout(u), f;
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
|
-
mergeQueries =
|
|
783
|
-
mergeHeaders =
|
|
782
|
+
mergeQueries = V.mergeQueries;
|
|
783
|
+
mergeHeaders = W.mergeHeaders;
|
|
784
784
|
normalizeContext(e, t = {}) {
|
|
785
|
-
const i = e,
|
|
786
|
-
|
|
785
|
+
const i = e, s = i.baseURL || this.baseConfigs.baseURL || globalThis.location?.href || "http://localhost", n = new URL(
|
|
786
|
+
s,
|
|
787
787
|
globalThis.location?.href || "http://localhost"
|
|
788
|
-
), o = new URL(i.url.toString(), n), a = !!i[
|
|
788
|
+
), o = new URL(i.url.toString(), n), a = !!i[_.NORMALIZED_SYMBOL];
|
|
789
789
|
i.baseURL = n ? n.origin : o.origin;
|
|
790
790
|
let c;
|
|
791
791
|
a ? c = t.requestOptionsOverridesURLSearchParams ? this.mergeQueries({}, o.search, i.query) : this.mergeQueries({}, i.query, o.search) : (c = t.requestOptionsOverridesURLSearchParams ? this.mergeQueries(
|
|
@@ -798,12 +798,12 @@ let le = class v extends Ne {
|
|
|
798
798
|
this.baseConfigs.query,
|
|
799
799
|
i.query,
|
|
800
800
|
o.search
|
|
801
|
-
), i[
|
|
801
|
+
), i[_.NORMALIZED_SYMBOL] = !0), i.query = c;
|
|
802
802
|
const l = new URL(o);
|
|
803
803
|
return l.search = "", i.url = l.toString(), i;
|
|
804
804
|
}
|
|
805
805
|
async emit(e, t, i = {}) {
|
|
806
|
-
const
|
|
806
|
+
const s = this.hooks.filter((n) => n.event === e);
|
|
807
807
|
if (i?.shouldAdjustRequestParams && i?.preAdjust)
|
|
808
808
|
try {
|
|
809
809
|
t = this.normalizeContext(t, {
|
|
@@ -813,7 +813,7 @@ let le = class v extends Ne {
|
|
|
813
813
|
}
|
|
814
814
|
try {
|
|
815
815
|
let n = 0;
|
|
816
|
-
for (const o of
|
|
816
|
+
for (const o of s) {
|
|
817
817
|
const a = `${e}#${o.action.name || `anonymous#${n}`}`, c = Symbol("FEXIOS_HOOK_CONTEXT");
|
|
818
818
|
t[c] = c;
|
|
819
819
|
const l = t.url;
|
|
@@ -828,31 +828,31 @@ let le = class v extends Ne {
|
|
|
828
828
|
}
|
|
829
829
|
let d = await o.action.call(this, t);
|
|
830
830
|
if (d === void 0 && (d = t), d === !1)
|
|
831
|
-
throw new
|
|
832
|
-
|
|
831
|
+
throw new $(
|
|
832
|
+
x.ABORTED_BY_HOOK,
|
|
833
833
|
`Request aborted by hook "${a}"`,
|
|
834
834
|
t
|
|
835
835
|
);
|
|
836
836
|
if (d instanceof Response) {
|
|
837
|
-
const u = d, f = { ...t, rawResponse: u },
|
|
837
|
+
const u = d, f = { ...t, rawResponse: u }, g = await Oe(
|
|
838
838
|
u,
|
|
839
839
|
t.responseType,
|
|
840
|
-
(
|
|
841
|
-
t.onProgress?.(
|
|
840
|
+
(p, y) => {
|
|
841
|
+
t.onProgress?.(p, y);
|
|
842
842
|
}
|
|
843
843
|
);
|
|
844
|
-
if (f.response =
|
|
845
|
-
const
|
|
846
|
-
return
|
|
844
|
+
if (f.response = g, f.data = g.data, f.headers = g.headers, e !== "afterResponse") {
|
|
845
|
+
const p = await this.emit("afterResponse", f);
|
|
846
|
+
return p[_.FINAL_SYMBOL] = !0, p;
|
|
847
847
|
} else
|
|
848
|
-
return f[
|
|
848
|
+
return f[_.FINAL_SYMBOL] = !0, f;
|
|
849
849
|
} else if (typeof d == "object" && d[c] === c)
|
|
850
850
|
t = d;
|
|
851
851
|
else {
|
|
852
852
|
const u = globalThis["".concat("console")];
|
|
853
853
|
try {
|
|
854
|
-
throw new
|
|
855
|
-
|
|
854
|
+
throw new $(
|
|
855
|
+
x.HOOK_CONTEXT_CHANGED,
|
|
856
856
|
`Hook "${a}" should return the original FexiosContext or return false to abort the request, but got "${d}".`
|
|
857
857
|
);
|
|
858
858
|
} catch (f) {
|
|
@@ -865,20 +865,20 @@ let le = class v extends Ne {
|
|
|
865
865
|
t.url.toString(),
|
|
866
866
|
u
|
|
867
867
|
);
|
|
868
|
-
let
|
|
868
|
+
let g = {};
|
|
869
869
|
if (h)
|
|
870
870
|
try {
|
|
871
|
-
|
|
871
|
+
g = JSON.parse(h);
|
|
872
872
|
} catch {
|
|
873
873
|
}
|
|
874
|
-
const
|
|
875
|
-
|
|
874
|
+
const p = t.query || {}, y = this.mergeQueries(
|
|
875
|
+
g,
|
|
876
876
|
f.search,
|
|
877
|
-
|
|
877
|
+
p
|
|
878
878
|
);
|
|
879
|
-
t.query =
|
|
880
|
-
const
|
|
881
|
-
|
|
879
|
+
t.query = y;
|
|
880
|
+
const L = new URL(f);
|
|
881
|
+
L.search = "", t.url = L.toString();
|
|
882
882
|
} catch {
|
|
883
883
|
}
|
|
884
884
|
delete t[c], n++;
|
|
@@ -890,8 +890,8 @@ let le = class v extends Ne {
|
|
|
890
890
|
}
|
|
891
891
|
on(e, t, i = !1) {
|
|
892
892
|
if (typeof t != "function")
|
|
893
|
-
throw new
|
|
894
|
-
|
|
893
|
+
throw new $(
|
|
894
|
+
x.INVALID_HOOK_CALLBACK,
|
|
895
895
|
`Hook should be a function, but got "${typeof t}"`
|
|
896
896
|
);
|
|
897
897
|
return this.hooks[i ? "unshift" : "push"]({
|
|
@@ -919,23 +919,23 @@ let le = class v extends Ne {
|
|
|
919
919
|
};
|
|
920
920
|
createMethodShortcut(e) {
|
|
921
921
|
return Reflect.defineProperty(this, e, {
|
|
922
|
-
get: () => (t, i,
|
|
922
|
+
get: () => (t, i, s) => (_.METHODS_WITHOUT_BODY.includes(
|
|
923
923
|
e.toLocaleLowerCase()
|
|
924
|
-
) ?
|
|
925
|
-
...
|
|
924
|
+
) ? s = i : (s = s || {}, s.body = i), this.request(t, {
|
|
925
|
+
...s,
|
|
926
926
|
method: e
|
|
927
927
|
}))
|
|
928
928
|
}), this;
|
|
929
929
|
}
|
|
930
930
|
extends(e) {
|
|
931
|
-
const t = new
|
|
931
|
+
const t = new _(K(this.baseConfigs, e));
|
|
932
932
|
return t.hooks = [...this.hooks], t._plugins = new Map(this._plugins), t._plugins.forEach(async (i) => {
|
|
933
933
|
await t.plugin(i);
|
|
934
934
|
}), t;
|
|
935
935
|
}
|
|
936
|
-
create =
|
|
936
|
+
create = _.create;
|
|
937
937
|
static create(e) {
|
|
938
|
-
return new
|
|
938
|
+
return new _(e);
|
|
939
939
|
}
|
|
940
940
|
_plugins = /* @__PURE__ */ new Map();
|
|
941
941
|
async plugin(e) {
|
|
@@ -943,7 +943,7 @@ let le = class v extends Ne {
|
|
|
943
943
|
if (this._plugins.has(e.name))
|
|
944
944
|
return this;
|
|
945
945
|
const t = await e.install(this);
|
|
946
|
-
if (this._plugins.set(e.name, e), t instanceof
|
|
946
|
+
if (this._plugins.set(e.name, e), t instanceof _)
|
|
947
947
|
return t;
|
|
948
948
|
}
|
|
949
949
|
return this;
|
|
@@ -954,20 +954,20 @@ let le = class v extends Ne {
|
|
|
954
954
|
/** @deprecated Use `mergeQueries` instead */
|
|
955
955
|
mergeQuery = this.mergeQueries;
|
|
956
956
|
};
|
|
957
|
-
const
|
|
958
|
-
typeof globalThis < "u" ? globalThis.fexios =
|
|
959
|
-
var
|
|
960
|
-
((
|
|
957
|
+
const Wt = de.create, Ie = Wt();
|
|
958
|
+
typeof globalThis < "u" ? globalThis.fexios = Ie : typeof window < "u" && (window.fexios = Ie);
|
|
959
|
+
var Z;
|
|
960
|
+
((r) => {
|
|
961
961
|
function e(i) {
|
|
962
962
|
return Array.isArray(i) ? i.join("|") : typeof i == "boolean" || i === null ? i ? "1" : void 0 : typeof i == "number" ? "" + i : i;
|
|
963
963
|
}
|
|
964
|
-
|
|
964
|
+
r.normalizeParamValue = e;
|
|
965
965
|
function t(i) {
|
|
966
|
-
const
|
|
966
|
+
const s = (o) => o && (o instanceof URLSearchParams || o instanceof FormData);
|
|
967
967
|
if (i == null)
|
|
968
968
|
return;
|
|
969
969
|
const n = new FormData();
|
|
970
|
-
if (
|
|
970
|
+
if (s(i))
|
|
971
971
|
return i.forEach((o, a) => {
|
|
972
972
|
const c = e(o);
|
|
973
973
|
c != null && n.append(a, c);
|
|
@@ -978,9 +978,9 @@ var Q;
|
|
|
978
978
|
c != null && n.append(o, c);
|
|
979
979
|
}), n;
|
|
980
980
|
}
|
|
981
|
-
|
|
982
|
-
})(
|
|
983
|
-
var
|
|
981
|
+
r.normalizeBody = t;
|
|
982
|
+
})(Z || (Z = {}));
|
|
983
|
+
var z = /* @__PURE__ */ ((r) => (r.HTTP_ERROR = "HTTP_ERROR", r.LOGIN_FAILED = "LOGIN_FAILED", r.LOGIN_RETRY_LIMIT_EXCEEDED = "LOGIN_RETRY_LIMIT_EXCEEDED", r.TOKEN_RETRY_LIMIT_EXCEEDED = "TOKEN_RETRY_LIMIT_EXCEEDED", r))(z || {});
|
|
984
984
|
class R extends Error {
|
|
985
985
|
constructor(e, t = "", i) {
|
|
986
986
|
super(), this.code = e, this.message = t, this.cause = i, this.name = "WikiSaikouError";
|
|
@@ -989,9 +989,9 @@ class R extends Error {
|
|
|
989
989
|
return e instanceof this && (t === void 0 || e.code === t);
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
|
-
let
|
|
992
|
+
let N = class Ge extends Error {
|
|
993
993
|
constructor(e, t) {
|
|
994
|
-
super(), this.errors = e, this.cause = t, this.name = "MediaWikiApiError", this.errors =
|
|
994
|
+
super(), this.errors = e, this.cause = t, this.name = "MediaWikiApiError", this.errors = Ge.normalizeErrors(e), this.message = e.map((i) => i.text).filter(Boolean).join(`
|
|
995
995
|
`), this.code = this.isBadTokenError() ? "badtoken" : this.errors[0]?.code || "Unknown Error";
|
|
996
996
|
}
|
|
997
997
|
get firstError() {
|
|
@@ -1010,7 +1010,7 @@ let U = class Be extends Error {
|
|
|
1010
1010
|
return Array.isArray(e) === !1 ? [] : e.filter((t) => typeof t == "object" && !!t?.code).map((t) => t.text ? t : t.info ? { ...t, text: t.info } : t["*"] ? { ...t, text: t["*"] } : { ...t, text: "" });
|
|
1011
1011
|
}
|
|
1012
1012
|
};
|
|
1013
|
-
((
|
|
1013
|
+
((r) => {
|
|
1014
1014
|
function e(n) {
|
|
1015
1015
|
if (n == null) return;
|
|
1016
1016
|
if (n?.response?.data !== void 0) return n.response.data;
|
|
@@ -1021,37 +1021,37 @@ let U = class Be extends Error {
|
|
|
1021
1021
|
function t(n) {
|
|
1022
1022
|
return i(n).length > 0;
|
|
1023
1023
|
}
|
|
1024
|
-
|
|
1024
|
+
r.includesMediaWikiApiError = t, r.normalizeMwApiErrors = N.normalizeErrors;
|
|
1025
1025
|
function i(n) {
|
|
1026
1026
|
let o = e(n);
|
|
1027
1027
|
if (typeof o != "object" || o === null)
|
|
1028
1028
|
return [];
|
|
1029
1029
|
const a = o?.error, c = o?.errors, l = [];
|
|
1030
|
-
return a && l.push(a), Array.isArray(c) && l.push(...c), (0,
|
|
1030
|
+
return a && l.push(a), Array.isArray(c) && l.push(...c), (0, r.normalizeMwApiErrors)(l);
|
|
1031
1031
|
}
|
|
1032
|
-
|
|
1033
|
-
function
|
|
1034
|
-
if (
|
|
1032
|
+
r.extractMediaWikiApiErrors = i;
|
|
1033
|
+
function s(n) {
|
|
1034
|
+
if (N.is(n))
|
|
1035
1035
|
return n.isBadTokenError();
|
|
1036
1036
|
{
|
|
1037
1037
|
const o = i(n);
|
|
1038
|
-
return new
|
|
1038
|
+
return new N(o).isBadTokenError();
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
|
|
1041
|
+
r.isBadTokenError = s;
|
|
1042
1042
|
})(R || (R = {}));
|
|
1043
|
-
const
|
|
1044
|
-
function
|
|
1045
|
-
const e =
|
|
1046
|
-
baseURL:
|
|
1043
|
+
const Pe = Symbol.for("__FEXIOS_SAIKOU__");
|
|
1044
|
+
function Ye(r) {
|
|
1045
|
+
const e = r instanceof de ? r : new de({
|
|
1046
|
+
baseURL: r instanceof URL ? r.toString() : String(r),
|
|
1047
1047
|
responseType: "json"
|
|
1048
1048
|
});
|
|
1049
|
-
return e[
|
|
1049
|
+
return e[Pe] || (Reflect.defineProperty(e, Pe, {
|
|
1050
1050
|
get: () => !0,
|
|
1051
1051
|
enumerable: !1,
|
|
1052
1052
|
configurable: !1
|
|
1053
1053
|
}), e._tokens = /* @__PURE__ */ new Map(), e.on("afterResponse", (t) => {
|
|
1054
|
-
const { data: i, rawRequest:
|
|
1054
|
+
const { data: i, rawRequest: s } = t, n = s?.headers.get("x-mw-token-name");
|
|
1055
1055
|
n && R.isBadTokenError(i) && e._tokens.delete(n);
|
|
1056
1056
|
const o = i?.query?.tokens;
|
|
1057
1057
|
o && typeof o == "object" && Object.entries(o).forEach(([c, l]) => {
|
|
@@ -1064,11 +1064,11 @@ function je(s) {
|
|
|
1064
1064
|
return t;
|
|
1065
1065
|
if (t.body === void 0 || t.body === null)
|
|
1066
1066
|
return t.body = void 0, t;
|
|
1067
|
-
const i = t.body =
|
|
1068
|
-
return i.has("format") &&
|
|
1069
|
-
}), e.on("beforeInit", (t) => (t.query =
|
|
1070
|
-
const i = new URL(t.url),
|
|
1071
|
-
if (globalThis.location && (!
|
|
1067
|
+
const i = t.body = Z.normalizeBody(t.body), s = new URLSearchParams(t.query);
|
|
1068
|
+
return i.has("format") && s.delete("format"), i.has("formatversion") && s.delete("formatversion"), i.has("action") && s.delete("action"), i.has("origin") && (s.set("origin", "" + i.get("origin")), i.delete("origin")), t.query = Object.fromEntries(s.entries()), t;
|
|
1069
|
+
}), e.on("beforeInit", (t) => (t.query = Z.normalizeBody(t.query) || {}, t)), e.on("beforeRequest", (t) => {
|
|
1070
|
+
const i = new URL(t.url), s = i.searchParams;
|
|
1071
|
+
if (globalThis.location && (!s.has("origin") && location.origin !== i.origin ? (s.set("origin", location.origin), e.baseConfigs.credentials = "include", e.baseConfigs.mode = "cors") : location.origin === i.origin && (s.delete("origin"), e.baseConfigs.credentials = void 0, e.baseConfigs.mode = void 0)), i.searchParams.has("origin")) {
|
|
1072
1072
|
const n = encodeURIComponent(
|
|
1073
1073
|
i.searchParams.get("origin") || ""
|
|
1074
1074
|
).replace(/\./g, "%2E");
|
|
@@ -1077,7 +1077,7 @@ function je(s) {
|
|
|
1077
1077
|
return t;
|
|
1078
1078
|
})), e;
|
|
1079
1079
|
}
|
|
1080
|
-
const
|
|
1080
|
+
const D = (r, ...e) => {
|
|
1081
1081
|
const t = (n) => Object.prototype.toString.call(n) === "[object Object]", i = (n) => {
|
|
1082
1082
|
if (Array.isArray(n)) return n.slice();
|
|
1083
1083
|
if (t(n)) {
|
|
@@ -1086,55 +1086,55 @@ const C = (s, ...e) => {
|
|
|
1086
1086
|
return o;
|
|
1087
1087
|
}
|
|
1088
1088
|
return n;
|
|
1089
|
-
},
|
|
1089
|
+
}, s = i(r);
|
|
1090
1090
|
for (const n of e)
|
|
1091
1091
|
if (n != null)
|
|
1092
1092
|
for (const o of Reflect.ownKeys(n)) {
|
|
1093
1093
|
const a = n[o];
|
|
1094
1094
|
if (typeof a > "u") continue;
|
|
1095
|
-
const c =
|
|
1096
|
-
t(c) && t(a) ?
|
|
1095
|
+
const c = s[o];
|
|
1096
|
+
t(c) && t(a) ? s[o] = D(c, a) : s[o] = i(a);
|
|
1097
1097
|
}
|
|
1098
|
-
return
|
|
1099
|
-
},
|
|
1100
|
-
let i = { ...
|
|
1101
|
-
if (typeof
|
|
1102
|
-
baseURL:
|
|
1098
|
+
return s;
|
|
1099
|
+
}, zt = (r, e, t) => {
|
|
1100
|
+
let i = { ...Xe.DEFAULT_CONFIGS };
|
|
1101
|
+
if (typeof r == "string" ? i = D(i, {
|
|
1102
|
+
baseURL: r,
|
|
1103
1103
|
fexiosConfigs: e || {},
|
|
1104
1104
|
defaultParams: t || {}
|
|
1105
|
-
}) : typeof
|
|
1106
|
-
const { wgServer:
|
|
1107
|
-
typeof
|
|
1105
|
+
}) : typeof r == "object" && r !== null && (i = D(i, r)), !i.baseURL && typeof window == "object" && window.mediaWiki) {
|
|
1106
|
+
const { wgServer: s, wgScriptPath: n } = window.mediaWiki?.config?.get(["wgServer", "wgScriptPath"]) || {};
|
|
1107
|
+
typeof s == "string" && typeof n == "string" && (i.baseURL = `${s}${n}/api.php`);
|
|
1108
1108
|
}
|
|
1109
1109
|
if (typeof i.baseURL != "string")
|
|
1110
1110
|
throw new Error("baseURL is required");
|
|
1111
1111
|
return i;
|
|
1112
|
-
},
|
|
1113
|
-
},
|
|
1112
|
+
}, Gt = () => {
|
|
1113
|
+
}, Yt = async (r, e) => {
|
|
1114
1114
|
let t = 0;
|
|
1115
|
-
const { retry: i = 3, onRetry:
|
|
1115
|
+
const { retry: i = 3, onRetry: s = Gt, shouldRetry: n = () => !0 } = e;
|
|
1116
1116
|
let o;
|
|
1117
1117
|
do
|
|
1118
1118
|
try {
|
|
1119
|
-
return await
|
|
1119
|
+
return await r();
|
|
1120
1120
|
} catch (a) {
|
|
1121
1121
|
if (o = a, n(a, t))
|
|
1122
|
-
|
|
1122
|
+
s(a, t), t++;
|
|
1123
1123
|
else
|
|
1124
1124
|
throw a;
|
|
1125
1125
|
}
|
|
1126
1126
|
while (t < i);
|
|
1127
1127
|
throw o || new Error("Retry failed");
|
|
1128
1128
|
};
|
|
1129
|
-
const
|
|
1129
|
+
const F = class {
|
|
1130
1130
|
constructor(e, t, i) {
|
|
1131
1131
|
this.version = "7.1.2", this.token = this.getToken;
|
|
1132
|
-
const
|
|
1132
|
+
const s = this.config = zt(
|
|
1133
1133
|
e,
|
|
1134
1134
|
t,
|
|
1135
1135
|
i
|
|
1136
1136
|
);
|
|
1137
|
-
this.request =
|
|
1137
|
+
this.request = Ye(s.baseURL);
|
|
1138
1138
|
}
|
|
1139
1139
|
setBaseURL(e) {
|
|
1140
1140
|
return this.config.baseURL = e, this.request.baseConfigs.baseURL = e, this;
|
|
@@ -1144,10 +1144,10 @@ const j = class {
|
|
|
1144
1144
|
return this.runRequestWithApiErrorMapping(
|
|
1145
1145
|
() => this.request.get(
|
|
1146
1146
|
"",
|
|
1147
|
-
|
|
1147
|
+
D(
|
|
1148
1148
|
{},
|
|
1149
1149
|
this.config.fexiosConfigs,
|
|
1150
|
-
{ query:
|
|
1150
|
+
{ query: D(this.config.defaultParams, e) },
|
|
1151
1151
|
t
|
|
1152
1152
|
)
|
|
1153
1153
|
)
|
|
@@ -1158,7 +1158,7 @@ const j = class {
|
|
|
1158
1158
|
() => this.request.post(
|
|
1159
1159
|
"",
|
|
1160
1160
|
e,
|
|
1161
|
-
|
|
1161
|
+
D(
|
|
1162
1162
|
{},
|
|
1163
1163
|
this.config.fexiosConfigs,
|
|
1164
1164
|
{
|
|
@@ -1179,7 +1179,7 @@ const j = class {
|
|
|
1179
1179
|
const t = await e();
|
|
1180
1180
|
return this.handleApiResponse(t);
|
|
1181
1181
|
} catch (t) {
|
|
1182
|
-
throw this.config.throwOnApiError && R.includesMediaWikiApiError(t) ? new
|
|
1182
|
+
throw this.config.throwOnApiError && R.includesMediaWikiApiError(t) ? new N(
|
|
1183
1183
|
R.extractMediaWikiApiErrors(t),
|
|
1184
1184
|
t
|
|
1185
1185
|
) : t;
|
|
@@ -1188,7 +1188,7 @@ const j = class {
|
|
|
1188
1188
|
throwIfApiError(e) {
|
|
1189
1189
|
const t = R.extractMediaWikiApiErrors(e);
|
|
1190
1190
|
if (t.length > 0)
|
|
1191
|
-
throw new
|
|
1191
|
+
throw new N(t, e);
|
|
1192
1192
|
}
|
|
1193
1193
|
handleApiResponse(e) {
|
|
1194
1194
|
return this.config.throwOnApiError && this.throwIfApiError(e.data), e;
|
|
@@ -1212,18 +1212,18 @@ const j = class {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
async postWithToken(e, t, i) {
|
|
1214
1214
|
const {
|
|
1215
|
-
tokenName:
|
|
1215
|
+
tokenName: s = "token",
|
|
1216
1216
|
retry: n = 3,
|
|
1217
1217
|
noCache: o = !1,
|
|
1218
1218
|
fexiosOptions: a
|
|
1219
1219
|
} = i || {};
|
|
1220
1220
|
if (n < 1)
|
|
1221
1221
|
throw new R(
|
|
1222
|
-
|
|
1222
|
+
z.TOKEN_RETRY_LIMIT_EXCEEDED,
|
|
1223
1223
|
"The limit of the number of times to automatically re-acquire the token has been exceeded"
|
|
1224
1224
|
);
|
|
1225
1225
|
let c = 0;
|
|
1226
|
-
return
|
|
1226
|
+
return Yt(
|
|
1227
1227
|
async () => {
|
|
1228
1228
|
const l = await this.getToken(
|
|
1229
1229
|
e,
|
|
@@ -1232,10 +1232,10 @@ const j = class {
|
|
|
1232
1232
|
try {
|
|
1233
1233
|
const h = await this.post(
|
|
1234
1234
|
{
|
|
1235
|
-
[
|
|
1235
|
+
[s]: l,
|
|
1236
1236
|
...t
|
|
1237
1237
|
},
|
|
1238
|
-
|
|
1238
|
+
D(a || {}, {
|
|
1239
1239
|
headers: { "x-mw-token-name": e }
|
|
1240
1240
|
})
|
|
1241
1241
|
);
|
|
@@ -1243,8 +1243,8 @@ const j = class {
|
|
|
1243
1243
|
throw h;
|
|
1244
1244
|
return h;
|
|
1245
1245
|
} catch (h) {
|
|
1246
|
-
throw R.isBadTokenError(h) || h?.ok === !1 ||
|
|
1247
|
-
|
|
1246
|
+
throw R.isBadTokenError(h) || h?.ok === !1 || N.is(h) ? h : new R(
|
|
1247
|
+
z.HTTP_ERROR,
|
|
1248
1248
|
"Network/transport or SDK-internal error (not a MediaWiki API error)",
|
|
1249
1249
|
h
|
|
1250
1250
|
);
|
|
@@ -1259,7 +1259,7 @@ const j = class {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
).catch((l) => {
|
|
1261
1261
|
throw R.isBadTokenError(l) || l?.ok === !1 ? new R(
|
|
1262
|
-
|
|
1262
|
+
z.TOKEN_RETRY_LIMIT_EXCEEDED,
|
|
1263
1263
|
"Retry attempts for acquiring/using token exhausted",
|
|
1264
1264
|
l
|
|
1265
1265
|
) : l;
|
|
@@ -1282,24 +1282,24 @@ const j = class {
|
|
|
1282
1282
|
return this.config.fexiosConfigs;
|
|
1283
1283
|
}
|
|
1284
1284
|
};
|
|
1285
|
-
|
|
1285
|
+
F.INIT_DEFAULT_PARAMS = {
|
|
1286
1286
|
action: "query",
|
|
1287
1287
|
errorformat: "plaintext",
|
|
1288
1288
|
format: "json",
|
|
1289
1289
|
formatversion: 2
|
|
1290
|
-
},
|
|
1290
|
+
}, F.DEFAULT_CONFIGS = {
|
|
1291
1291
|
baseURL: void 0,
|
|
1292
1292
|
fexiosConfigs: {
|
|
1293
1293
|
responseType: "json"
|
|
1294
1294
|
},
|
|
1295
|
-
defaultParams:
|
|
1295
|
+
defaultParams: F.INIT_DEFAULT_PARAMS,
|
|
1296
1296
|
throwOnApiError: !1
|
|
1297
|
-
},
|
|
1298
|
-
let
|
|
1299
|
-
let
|
|
1297
|
+
}, F.createRequestHandler = Ye;
|
|
1298
|
+
let Xe = F;
|
|
1299
|
+
let Xt = class extends Xe {
|
|
1300
1300
|
async clientLogin(e, t, i) {
|
|
1301
1301
|
i ||= {}, !i.logincontinue && !i.loginreturnurl && (i.loginreturnurl = location?.origin);
|
|
1302
|
-
const
|
|
1302
|
+
const s = await this.postWithToken(
|
|
1303
1303
|
"login",
|
|
1304
1304
|
{
|
|
1305
1305
|
action: "clientlogin",
|
|
@@ -1311,19 +1311,19 @@ let Pt = class extends Fe {
|
|
|
1311
1311
|
tokenName: "logintoken"
|
|
1312
1312
|
}
|
|
1313
1313
|
);
|
|
1314
|
-
if (
|
|
1315
|
-
return
|
|
1314
|
+
if (s?.data?.clientlogin?.status === "PASS")
|
|
1315
|
+
return s.data.clientlogin;
|
|
1316
1316
|
throw new R(
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1317
|
+
z.LOGIN_FAILED,
|
|
1318
|
+
s.data.clientlogin.message,
|
|
1319
|
+
s
|
|
1320
1320
|
);
|
|
1321
1321
|
}
|
|
1322
1322
|
};
|
|
1323
|
-
class
|
|
1323
|
+
class Qt {
|
|
1324
1324
|
constructor(e, t = {}) {
|
|
1325
1325
|
this.ctx = e, location?.href && t?.baseURL?.toString()?.startsWith("/") && (t.baseURL = new URL(t.baseURL, location.origin));
|
|
1326
|
-
const i = new
|
|
1326
|
+
const i = new Xt({
|
|
1327
1327
|
baseURL: t.baseURL.toString(),
|
|
1328
1328
|
fexiosConfigs: {
|
|
1329
1329
|
headers: {
|
|
@@ -1337,20 +1337,20 @@ class It {
|
|
|
1337
1337
|
e.set("api", i);
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
|
-
var
|
|
1341
|
-
throw TypeError(
|
|
1342
|
-
},
|
|
1343
|
-
for (var
|
|
1340
|
+
var Vt = Object.create, me = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Qe = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), Ve = (r) => {
|
|
1341
|
+
throw TypeError(r);
|
|
1342
|
+
}, Jt = (r, e, t) => e in r ? me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ei = (r, e) => me(r, "name", { value: e, configurable: !0 }), ti = (r) => [, , , Vt(r?.[Qe("metadata")] ?? null)], ii = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ze = (r) => r !== void 0 && typeof r != "function" ? Ve("Function expected") : r, si = (r, e, t, i, s) => ({ kind: ii[r], name: e, metadata: i, addInitializer: (n) => t._ ? Ve("Already initialized") : s.push(Ze(n || null)) }), ri = (r, e) => Jt(e, Qe("metadata"), r[3]), ni = (r, e, t, i) => {
|
|
1343
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
1344
1344
|
return i;
|
|
1345
|
-
},
|
|
1346
|
-
var o, a, c, l = e & 7, h = !1, d = 0, u =
|
|
1347
|
-
|
|
1348
|
-
for (var
|
|
1349
|
-
c =
|
|
1350
|
-
return
|
|
1351
|
-
},
|
|
1352
|
-
|
|
1353
|
-
class
|
|
1345
|
+
}, oi = (r, e, t, i, s, n) => {
|
|
1346
|
+
var o, a, c, l = e & 7, h = !1, d = 0, u = r[d] || (r[d] = []), f = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Zt(s, t));
|
|
1347
|
+
ei(s, t);
|
|
1348
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
1349
|
+
c = si(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, Ze(o) && (s = o);
|
|
1350
|
+
return ri(r, s), f && me(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
1351
|
+
}, Je, ye, et;
|
|
1352
|
+
Je = [ne(["wiki", "wikiTitle"])];
|
|
1353
|
+
class J extends (et = I) {
|
|
1354
1354
|
constructor(e) {
|
|
1355
1355
|
super(e, "currentPage", !1), this.ctx = e, this.url = new URL(window.location.href), this.isMainPage = void 0, this.wikiTitle = void 0;
|
|
1356
1356
|
}
|
|
@@ -1371,10 +1371,10 @@ class V extends (ze = I) {
|
|
|
1371
1371
|
if (window[e])
|
|
1372
1372
|
return;
|
|
1373
1373
|
const t = history.pushState, i = history.replaceState;
|
|
1374
|
-
history.pushState = function(
|
|
1375
|
-
t.apply(this, [
|
|
1376
|
-
}, history.replaceState = function(
|
|
1377
|
-
i.apply(this, [
|
|
1374
|
+
history.pushState = function(s, n, o) {
|
|
1375
|
+
t.apply(this, [s, n, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: s }));
|
|
1376
|
+
}, history.replaceState = function(s, n, o) {
|
|
1377
|
+
i.apply(this, [s, n, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: s }));
|
|
1378
1378
|
}, window[e] = !0;
|
|
1379
1379
|
}
|
|
1380
1380
|
async #t(e) {
|
|
@@ -1407,10 +1407,10 @@ class V extends (ze = I) {
|
|
|
1407
1407
|
return this.params.get("action") || "view";
|
|
1408
1408
|
}
|
|
1409
1409
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
class
|
|
1410
|
+
ye = ti(et);
|
|
1411
|
+
J = oi(ye, 0, "CurrentPageService", Je, J);
|
|
1412
|
+
ni(ye, 1, J);
|
|
1413
|
+
class ai extends I {
|
|
1414
1414
|
constructor(e) {
|
|
1415
1415
|
super(e, "resourceLoader", !0), this.ctx = e;
|
|
1416
1416
|
}
|
|
@@ -1420,8 +1420,8 @@ class Kt extends I {
|
|
|
1420
1420
|
loadScript(e, t) {
|
|
1421
1421
|
if (!e)
|
|
1422
1422
|
return Promise.resolve(null);
|
|
1423
|
-
const i = `script:${e}`,
|
|
1424
|
-
return
|
|
1423
|
+
const i = `script:${e}`, s = document.querySelector(`[data-ipe="${i}"]`);
|
|
1424
|
+
return s ? Promise.resolve(s) : new Promise((o, a) => {
|
|
1425
1425
|
const c = document.createElement("script");
|
|
1426
1426
|
c.src = e, c.dataset.ipe = i, t && Object.entries(t).forEach(([l, h]) => {
|
|
1427
1427
|
typeof h > "u" || h === !1 || h === null ? c.removeAttribute(l) : c.setAttribute(l, h);
|
|
@@ -1431,8 +1431,8 @@ class Kt extends I {
|
|
|
1431
1431
|
loadStyle(e, t) {
|
|
1432
1432
|
if (!e)
|
|
1433
1433
|
return Promise.resolve(null);
|
|
1434
|
-
const i = `style:${e}`,
|
|
1435
|
-
return
|
|
1434
|
+
const i = `style:${e}`, s = document.querySelector(`[data-ipe="${i}"]`);
|
|
1435
|
+
return s ? Promise.resolve(s) : new Promise((o, a) => {
|
|
1436
1436
|
const c = document.createElement("link");
|
|
1437
1437
|
c.rel = "stylesheet", c.href = e, c.dataset.ipe = i, t && Object.entries(t).forEach(([h, d]) => {
|
|
1438
1438
|
typeof d > "u" || d === !1 || d === null ? c.removeAttribute(h) : c.setAttribute(h, d);
|
|
@@ -1459,40 +1459,40 @@ class Kt extends I {
|
|
|
1459
1459
|
return e.startsWith("http") || e.startsWith("//") ? e : import.meta.resolve(e);
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
|
-
const
|
|
1463
|
-
function
|
|
1464
|
-
return typeof
|
|
1462
|
+
const oe = Object.keys;
|
|
1463
|
+
function li(r) {
|
|
1464
|
+
return typeof r == "boolean";
|
|
1465
1465
|
}
|
|
1466
|
-
function
|
|
1467
|
-
return
|
|
1466
|
+
function ci(r) {
|
|
1467
|
+
return r && typeof r.nodeType == "number";
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1470
|
-
return typeof
|
|
1469
|
+
function we(r) {
|
|
1470
|
+
return typeof r == "string";
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1473
|
-
return typeof
|
|
1472
|
+
function tt(r) {
|
|
1473
|
+
return typeof r == "number";
|
|
1474
1474
|
}
|
|
1475
|
-
function
|
|
1476
|
-
return typeof
|
|
1475
|
+
function M(r) {
|
|
1476
|
+
return typeof r == "object" ? r !== null : G(r);
|
|
1477
1477
|
}
|
|
1478
|
-
function
|
|
1479
|
-
return typeof
|
|
1478
|
+
function G(r) {
|
|
1479
|
+
return typeof r == "function";
|
|
1480
1480
|
}
|
|
1481
|
-
function
|
|
1482
|
-
return !!(
|
|
1481
|
+
function hi(r) {
|
|
1482
|
+
return !!(r && r.isComponent);
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1484
|
+
function ui(r) {
|
|
1485
|
+
return M(r) && typeof r.length == "number" && typeof r.nodeType != "number";
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1488
|
-
if (
|
|
1489
|
-
for (const t of
|
|
1490
|
-
e(
|
|
1487
|
+
function fe(r, e) {
|
|
1488
|
+
if (r)
|
|
1489
|
+
for (const t of oe(r))
|
|
1490
|
+
e(r[t], t);
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return
|
|
1492
|
+
function di(r) {
|
|
1493
|
+
return M(r) && "current" in r;
|
|
1494
1494
|
}
|
|
1495
|
-
const
|
|
1495
|
+
const ge = {
|
|
1496
1496
|
animationIterationCount: 0,
|
|
1497
1497
|
borderImageOutset: 0,
|
|
1498
1498
|
borderImageSlice: 0,
|
|
@@ -1537,30 +1537,30 @@ const he = {
|
|
|
1537
1537
|
strokeOpacity: 0,
|
|
1538
1538
|
strokeWidth: 0
|
|
1539
1539
|
};
|
|
1540
|
-
function
|
|
1541
|
-
return
|
|
1540
|
+
function fi(r, e) {
|
|
1541
|
+
return r + e.charAt(0).toUpperCase() + e.substring(1);
|
|
1542
1542
|
}
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1543
|
+
const gi = ["Webkit", "ms", "Moz", "O"];
|
|
1544
|
+
oe(ge).forEach((r) => {
|
|
1545
|
+
gi.forEach((e) => {
|
|
1546
|
+
ge[fi(e, r)] = 0;
|
|
1547
1547
|
});
|
|
1548
1548
|
});
|
|
1549
|
-
const
|
|
1550
|
-
var
|
|
1551
|
-
return
|
|
1552
|
-
})(
|
|
1553
|
-
function
|
|
1554
|
-
return
|
|
1549
|
+
const pi = Symbol.for("jsx-dom:type");
|
|
1550
|
+
var it = /* @__PURE__ */ (function(r) {
|
|
1551
|
+
return r.ShadowRoot = "ShadowRoot", r;
|
|
1552
|
+
})(it || {});
|
|
1553
|
+
function mi(r) {
|
|
1554
|
+
return r != null && r[pi] === it.ShadowRoot;
|
|
1555
1555
|
}
|
|
1556
|
-
const
|
|
1557
|
-
function
|
|
1558
|
-
return !
|
|
1556
|
+
const yi = "http://www.w3.org/2000/svg", wi = "http://www.w3.org/1999/xlink", bi = "http://www.w3.org/XML/1998/namespace";
|
|
1557
|
+
function st(r) {
|
|
1558
|
+
return !li(r) && r != null;
|
|
1559
1559
|
}
|
|
1560
|
-
function
|
|
1561
|
-
return Array.isArray(
|
|
1560
|
+
function pe(r) {
|
|
1561
|
+
return Array.isArray(r) ? r.map(pe).filter(Boolean).join(" ") : M(r) ? Symbol.iterator in r ? pe(Array.from(r)) : oe(r).filter((e) => r[e]).join(" ") : st(r) ? "" + r : "";
|
|
1562
1562
|
}
|
|
1563
|
-
const
|
|
1563
|
+
const vi = {
|
|
1564
1564
|
animate: 0,
|
|
1565
1565
|
circle: 0,
|
|
1566
1566
|
clipPath: 0,
|
|
@@ -1615,83 +1615,83 @@ const ri = {
|
|
|
1615
1615
|
tspan: 0,
|
|
1616
1616
|
use: 0,
|
|
1617
1617
|
view: 0
|
|
1618
|
-
},
|
|
1619
|
-
function
|
|
1618
|
+
}, _i = /^(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)/;
|
|
1619
|
+
function Si(r) {
|
|
1620
1620
|
const e = document.createDocumentFragment();
|
|
1621
|
-
return
|
|
1621
|
+
return ae(r.children, e), e;
|
|
1622
1622
|
}
|
|
1623
|
-
function
|
|
1623
|
+
function Ei(r, e, t) {
|
|
1624
1624
|
e = {
|
|
1625
1625
|
...e,
|
|
1626
1626
|
children: t
|
|
1627
1627
|
};
|
|
1628
|
-
const i = new
|
|
1629
|
-
return "ref" in e &&
|
|
1628
|
+
const i = new r(e), s = i.render();
|
|
1629
|
+
return "ref" in e && be(e.ref, i), s;
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1631
|
+
function w(r, e) {
|
|
1632
1632
|
let { children: t, ...i } = e;
|
|
1633
|
-
!i.namespaceURI &&
|
|
1633
|
+
!i.namespaceURI && vi[r] === 0 && (i = {
|
|
1634
1634
|
...i,
|
|
1635
|
-
namespaceURI:
|
|
1635
|
+
namespaceURI: yi
|
|
1636
1636
|
});
|
|
1637
|
-
let
|
|
1638
|
-
if (
|
|
1639
|
-
if (
|
|
1637
|
+
let s;
|
|
1638
|
+
if (we(r)) {
|
|
1639
|
+
if (s = i.namespaceURI ? document.createElementNS(i.namespaceURI, r) : document.createElement(r), Ri(i, s), ae(t, s), s instanceof window.HTMLSelectElement && i.value != null)
|
|
1640
1640
|
if (i.multiple === !0 && Array.isArray(i.value)) {
|
|
1641
1641
|
const n = i.value.map((o) => String(o));
|
|
1642
|
-
|
|
1642
|
+
s.querySelectorAll("option").forEach(
|
|
1643
1643
|
(o) => o.selected = n.includes(o.value)
|
|
1644
1644
|
);
|
|
1645
1645
|
} else
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
} else if (
|
|
1649
|
-
|
|
1650
|
-
...
|
|
1646
|
+
s.value = i.value;
|
|
1647
|
+
be(i.ref, s);
|
|
1648
|
+
} else if (G(r))
|
|
1649
|
+
M(r.defaultProps) && (i = {
|
|
1650
|
+
...r.defaultProps,
|
|
1651
1651
|
...i
|
|
1652
|
-
}),
|
|
1652
|
+
}), s = hi(r) ? Ei(r, i, t) : r({
|
|
1653
1653
|
...i,
|
|
1654
1654
|
children: t
|
|
1655
1655
|
});
|
|
1656
1656
|
else
|
|
1657
|
-
throw new TypeError(`Invalid JSX element type: ${
|
|
1658
|
-
return
|
|
1657
|
+
throw new TypeError(`Invalid JSX element type: ${r}`);
|
|
1658
|
+
return s;
|
|
1659
|
+
}
|
|
1660
|
+
function be(r, e) {
|
|
1661
|
+
di(r) ? r.current = e : G(r) && r(e);
|
|
1662
|
+
}
|
|
1663
|
+
function ae(r, e) {
|
|
1664
|
+
if (ui(r))
|
|
1665
|
+
ki(r, e);
|
|
1666
|
+
else if (we(r) || tt(r))
|
|
1667
|
+
ce(document.createTextNode(r), e);
|
|
1668
|
+
else if (r === null)
|
|
1669
|
+
ce(document.createComment(""), e);
|
|
1670
|
+
else if (ci(r))
|
|
1671
|
+
ce(r, e);
|
|
1672
|
+
else if (mi(r)) {
|
|
1673
|
+
const t = e.attachShadow(r.attr);
|
|
1674
|
+
ae(r.children, t), be(r.ref, t);
|
|
1675
|
+
}
|
|
1659
1676
|
}
|
|
1660
|
-
function
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
function se(s, e) {
|
|
1664
|
-
if (Xt(s))
|
|
1665
|
-
li(s, e);
|
|
1666
|
-
else if (me(s) || Ye(s))
|
|
1667
|
-
ne(document.createTextNode(s), e);
|
|
1668
|
-
else if (s === null)
|
|
1669
|
-
ne(document.createComment(""), e);
|
|
1670
|
-
else if (Yt(s))
|
|
1671
|
-
ne(s, e);
|
|
1672
|
-
else if (ei(s)) {
|
|
1673
|
-
const t = e.attachShadow(s.attr);
|
|
1674
|
-
se(s.children, t), ge(s.ref, t);
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
function li(s, e) {
|
|
1678
|
-
for (const t of [...s])
|
|
1679
|
-
se(t, e);
|
|
1677
|
+
function ki(r, e) {
|
|
1678
|
+
for (const t of [...r])
|
|
1679
|
+
ae(t, e);
|
|
1680
1680
|
return e;
|
|
1681
1681
|
}
|
|
1682
|
-
function
|
|
1683
|
-
e instanceof window.HTMLTemplateElement ? e.content.appendChild(
|
|
1682
|
+
function ce(r, e) {
|
|
1683
|
+
e instanceof window.HTMLTemplateElement ? e.content.appendChild(r) : e.appendChild(r);
|
|
1684
1684
|
}
|
|
1685
|
-
function
|
|
1686
|
-
return
|
|
1685
|
+
function Q(r, e) {
|
|
1686
|
+
return r.replace(/[A-Z]/g, (t) => e + t.toLowerCase());
|
|
1687
1687
|
}
|
|
1688
|
-
function
|
|
1689
|
-
e == null || e === !1 || (Array.isArray(e) ? e.forEach((t) =>
|
|
1690
|
-
i.indexOf("-") === 0 ?
|
|
1688
|
+
function rt(r, e) {
|
|
1689
|
+
e == null || e === !1 || (Array.isArray(e) ? e.forEach((t) => rt(r, t)) : we(e) ? r.setAttribute("style", e) : M(e) && fe(e, (t, i) => {
|
|
1690
|
+
i.indexOf("-") === 0 ? r.style.setProperty(i, t) : tt(t) && ge[i] !== 0 ? r.style[i] = t + "px" : r.style[i] = t;
|
|
1691
1691
|
}));
|
|
1692
1692
|
}
|
|
1693
|
-
function
|
|
1694
|
-
switch (
|
|
1693
|
+
function $i(r, e, t) {
|
|
1694
|
+
switch (r) {
|
|
1695
1695
|
case "xlinkActuate":
|
|
1696
1696
|
case "xlinkArcrole":
|
|
1697
1697
|
case "xlinkHref":
|
|
@@ -1699,33 +1699,33 @@ function ci(s, e, t) {
|
|
|
1699
1699
|
case "xlinkShow":
|
|
1700
1700
|
case "xlinkTitle":
|
|
1701
1701
|
case "xlinkType":
|
|
1702
|
-
|
|
1702
|
+
De(t, wi, Q(r, ":"), e);
|
|
1703
1703
|
return;
|
|
1704
1704
|
case "xmlnsXlink":
|
|
1705
|
-
|
|
1705
|
+
B(t, Q(r, ":"), e);
|
|
1706
1706
|
return;
|
|
1707
1707
|
case "xmlBase":
|
|
1708
1708
|
case "xmlLang":
|
|
1709
1709
|
case "xmlSpace":
|
|
1710
|
-
|
|
1710
|
+
De(t, bi, Q(r, ":"), e);
|
|
1711
1711
|
return;
|
|
1712
1712
|
}
|
|
1713
|
-
switch (
|
|
1713
|
+
switch (r) {
|
|
1714
1714
|
case "htmlFor":
|
|
1715
|
-
|
|
1715
|
+
B(t, "for", e);
|
|
1716
1716
|
return;
|
|
1717
1717
|
case "dataset":
|
|
1718
|
-
|
|
1719
|
-
i != null && (t.dataset[
|
|
1718
|
+
fe(e, (i, s) => {
|
|
1719
|
+
i != null && (t.dataset[s] = i);
|
|
1720
1720
|
});
|
|
1721
1721
|
return;
|
|
1722
1722
|
case "innerHTML":
|
|
1723
1723
|
case "innerText":
|
|
1724
1724
|
case "textContent":
|
|
1725
|
-
|
|
1725
|
+
st(e) && (t[r] = e);
|
|
1726
1726
|
return;
|
|
1727
1727
|
case "dangerouslySetInnerHTML":
|
|
1728
|
-
|
|
1728
|
+
M(e) && (t.innerHTML = e.__html);
|
|
1729
1729
|
return;
|
|
1730
1730
|
case "value":
|
|
1731
1731
|
if (e == null || t instanceof window.HTMLSelectElement)
|
|
@@ -1740,28 +1740,28 @@ function ci(s, e, t) {
|
|
|
1740
1740
|
return;
|
|
1741
1741
|
case "class":
|
|
1742
1742
|
case "className":
|
|
1743
|
-
|
|
1743
|
+
G(e) ? e(t) : B(t, "class", pe(e));
|
|
1744
1744
|
return;
|
|
1745
1745
|
case "ref":
|
|
1746
1746
|
case "namespaceURI":
|
|
1747
1747
|
return;
|
|
1748
1748
|
case "style":
|
|
1749
|
-
|
|
1749
|
+
rt(t, e);
|
|
1750
1750
|
return;
|
|
1751
1751
|
case "on":
|
|
1752
1752
|
case "onCapture":
|
|
1753
|
-
|
|
1754
|
-
t.addEventListener(
|
|
1753
|
+
fe(e, (i, s) => {
|
|
1754
|
+
t.addEventListener(s, i, r === "onCapture");
|
|
1755
1755
|
});
|
|
1756
1756
|
return;
|
|
1757
1757
|
}
|
|
1758
|
-
if (
|
|
1759
|
-
if (
|
|
1760
|
-
let i =
|
|
1761
|
-
const
|
|
1762
|
-
if (i === "ondoubleclick" ? i = "ondblclick" :
|
|
1758
|
+
if (G(e)) {
|
|
1759
|
+
if (r[0] === "o" && r[1] === "n") {
|
|
1760
|
+
let i = r.toLowerCase();
|
|
1761
|
+
const s = i.endsWith("capture");
|
|
1762
|
+
if (i === "ondoubleclick" ? i = "ondblclick" : s && i === "ondoubleclickcapture" && (i = "ondblclickcapture"), !s && t[i] === null)
|
|
1763
1763
|
t[i] = e;
|
|
1764
|
-
else if (
|
|
1764
|
+
else if (s)
|
|
1765
1765
|
t.addEventListener(
|
|
1766
1766
|
i.substring(2, i.length - 7),
|
|
1767
1767
|
e,
|
|
@@ -1769,33 +1769,33 @@ function ci(s, e, t) {
|
|
|
1769
1769
|
);
|
|
1770
1770
|
else {
|
|
1771
1771
|
let n;
|
|
1772
|
-
i in window ? n = i.substring(2) : n = i[2] +
|
|
1772
|
+
i in window ? n = i.substring(2) : n = i[2] + r.slice(3), t.addEventListener(n, e);
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
|
-
} else
|
|
1775
|
+
} else M(e) ? t[r] = e : e === !0 ? B(t, r, "") : e !== !1 && e != null && (t instanceof SVGElement && !_i.test(r) ? B(t, Q(r, "-"), e) : B(t, r, e));
|
|
1776
1776
|
}
|
|
1777
|
-
function
|
|
1778
|
-
|
|
1777
|
+
function B(r, e, t) {
|
|
1778
|
+
r.setAttribute(e, t);
|
|
1779
1779
|
}
|
|
1780
|
-
function
|
|
1781
|
-
|
|
1780
|
+
function De(r, e, t, i) {
|
|
1781
|
+
r.setAttributeNS(e, t, i);
|
|
1782
1782
|
}
|
|
1783
|
-
function
|
|
1784
|
-
for (const t of
|
|
1785
|
-
|
|
1783
|
+
function Ri(r, e) {
|
|
1784
|
+
for (const t of oe(r))
|
|
1785
|
+
$i(t, r[t], e);
|
|
1786
1786
|
return e;
|
|
1787
1787
|
}
|
|
1788
|
-
var
|
|
1789
|
-
let
|
|
1790
|
-
const
|
|
1791
|
-
function
|
|
1792
|
-
return
|
|
1788
|
+
var ve = /* @__PURE__ */ ((r) => (r.Init = "modal.init", r.BeforeShow = "modal.beforeShow", r.Show = "modal.show", r.BeforeClose = "modal.beforeClose", r.Close = "modal.close", r.Destroy = "modal.destroy", r.ToastShow = "toast.show", r.ToastClose = "toast.close", r))(ve || {});
|
|
1789
|
+
let xi = 0;
|
|
1790
|
+
const Me = (r) => `${r}-${++xi}`;
|
|
1791
|
+
function j(r) {
|
|
1792
|
+
return r instanceof Node ? r : document.createTextNode(String(r));
|
|
1793
1793
|
}
|
|
1794
|
-
function
|
|
1795
|
-
if (!
|
|
1796
|
-
return
|
|
1794
|
+
function T(r, e) {
|
|
1795
|
+
if (!r) throw new Error(`${e ?? "Element"} not found`);
|
|
1796
|
+
return r;
|
|
1797
1797
|
}
|
|
1798
|
-
function
|
|
1798
|
+
function Ue(r) {
|
|
1799
1799
|
const e = [
|
|
1800
1800
|
"a[href]",
|
|
1801
1801
|
"button:not([disabled])",
|
|
@@ -1804,60 +1804,60 @@ function Ce(s) {
|
|
|
1804
1804
|
"textarea:not([disabled])",
|
|
1805
1805
|
'[tabindex]:not([tabindex="-1"])'
|
|
1806
1806
|
].join(",");
|
|
1807
|
-
return Array.from(
|
|
1807
|
+
return Array.from(r.querySelectorAll(e)).filter(
|
|
1808
1808
|
(t) => !!(t.offsetWidth || t.offsetHeight || t.getClientRects().length)
|
|
1809
1809
|
);
|
|
1810
1810
|
}
|
|
1811
|
-
function S(
|
|
1812
|
-
const t = document.createElement(
|
|
1811
|
+
function S(r, e = {}) {
|
|
1812
|
+
const t = document.createElement(r);
|
|
1813
1813
|
if (e.className && (t.className = e.className), e.html != null && (t.innerHTML = e.html), e.text != null && (t.textContent = e.text), e.attrs)
|
|
1814
|
-
for (const [i,
|
|
1814
|
+
for (const [i, s] of Object.entries(e.attrs)) t.setAttribute(i, s);
|
|
1815
1815
|
return t;
|
|
1816
1816
|
}
|
|
1817
|
-
const
|
|
1818
|
-
function
|
|
1819
|
-
if (!
|
|
1820
|
-
const e = String(
|
|
1817
|
+
const Li = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform), nt = ["ctrl", "alt", "shift", "meta"];
|
|
1818
|
+
function Ai(r) {
|
|
1819
|
+
if (!r) return null;
|
|
1820
|
+
const e = String(r).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean), t = [];
|
|
1821
1821
|
let i = null;
|
|
1822
|
-
const
|
|
1822
|
+
const s = (o) => {
|
|
1823
1823
|
t.includes(o) || t.push(o);
|
|
1824
1824
|
};
|
|
1825
1825
|
for (const o of e) {
|
|
1826
1826
|
let a = o;
|
|
1827
1827
|
if (a === "control" || a === "ctrl") {
|
|
1828
|
-
|
|
1828
|
+
s("ctrl");
|
|
1829
1829
|
continue;
|
|
1830
1830
|
}
|
|
1831
1831
|
if (a === "alt" || a === "option") {
|
|
1832
|
-
|
|
1832
|
+
s("alt");
|
|
1833
1833
|
continue;
|
|
1834
1834
|
}
|
|
1835
1835
|
if (a === "shift") {
|
|
1836
|
-
|
|
1836
|
+
s("shift");
|
|
1837
1837
|
continue;
|
|
1838
1838
|
}
|
|
1839
1839
|
if (a === "meta" || a === "cmd" || a === "command" || a === "super") {
|
|
1840
|
-
|
|
1840
|
+
s("meta");
|
|
1841
1841
|
continue;
|
|
1842
1842
|
}
|
|
1843
1843
|
if (a === "mod") {
|
|
1844
|
-
|
|
1844
|
+
s(Li ? "meta" : "ctrl");
|
|
1845
1845
|
continue;
|
|
1846
1846
|
}
|
|
1847
1847
|
a === "esc" && (a = "escape"), a === "return" && (a = "enter"), (a === "space" || a === "spacebar") && (a = "space"), i = a;
|
|
1848
1848
|
}
|
|
1849
|
-
const n =
|
|
1849
|
+
const n = nt.filter((o) => t.includes(o));
|
|
1850
1850
|
return !i || i === "" ? n.length ? n.join("+") : null : n.length ? `${n.join("+")}+${i}` : i;
|
|
1851
1851
|
}
|
|
1852
|
-
function
|
|
1852
|
+
function Ti(r) {
|
|
1853
1853
|
const e = [];
|
|
1854
|
-
|
|
1855
|
-
let t =
|
|
1854
|
+
r.ctrlKey && e.push("ctrl"), r.altKey && e.push("alt"), r.shiftKey && e.push("shift"), r.metaKey && e.push("meta");
|
|
1855
|
+
let t = r.key;
|
|
1856
1856
|
t === " " && (t = "space");
|
|
1857
|
-
const i = (t.length, t.toLowerCase()),
|
|
1858
|
-
return
|
|
1857
|
+
const i = (t.length, t.toLowerCase()), s = nt.filter((n) => e.includes(n));
|
|
1858
|
+
return s.length ? `${s.join("+")}+${i}` : i;
|
|
1859
1859
|
}
|
|
1860
|
-
class
|
|
1860
|
+
class Ci {
|
|
1861
1861
|
constructor() {
|
|
1862
1862
|
this.zBase = 1e3, this.stack = [];
|
|
1863
1863
|
}
|
|
@@ -1871,9 +1871,9 @@ class mi {
|
|
|
1871
1871
|
return this.stack[this.stack.length - 1];
|
|
1872
1872
|
}
|
|
1873
1873
|
closeAll(e, t) {
|
|
1874
|
-
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)),
|
|
1874
|
+
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), s = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
1875
1875
|
[...this.stack].reverse().forEach((n) => {
|
|
1876
|
-
const o = n.modalId, a =
|
|
1876
|
+
const o = n.modalId, a = s.size ? s.has(n.pluginName) : !0, c = i.has(o);
|
|
1877
1877
|
a && !c && n.close();
|
|
1878
1878
|
});
|
|
1879
1879
|
}
|
|
@@ -1890,17 +1890,17 @@ class mi {
|
|
|
1890
1890
|
document.body.classList.remove("ipe-modal-no-scroll");
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
|
-
const
|
|
1894
|
-
class
|
|
1893
|
+
const E = new Ci();
|
|
1894
|
+
class ee {
|
|
1895
1895
|
constructor(e = {}) {
|
|
1896
|
-
this.backdropId =
|
|
1896
|
+
this.backdropId = Me("ipe-modal-backdrop"), this.modalId = Me("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 = ve, this._hooks = [], this.startCloseTimer = (t) => {
|
|
1897
1897
|
this.stopCloseTimer(), this.closeTimer = window.setTimeout(() => this.close(), t);
|
|
1898
1898
|
}, this.stopCloseTimer = () => {
|
|
1899
1899
|
this.closeTimer && window.clearTimeout(this.closeTimer), this.closeTimer = void 0;
|
|
1900
1900
|
}, this.onDragMove = (t) => {
|
|
1901
1901
|
if (!this.isDragging) return;
|
|
1902
1902
|
t.preventDefault();
|
|
1903
|
-
const i = t.clientX - this.dragStartX,
|
|
1903
|
+
const i = t.clientX - this.dragStartX, s = t.clientY - this.dragStartY, n = this.get$modal(), o = this.modalStartX + i, a = this.modalStartY + s;
|
|
1904
1904
|
n.style.left = `${o}px`, n.style.top = `${a}px`;
|
|
1905
1905
|
}, this.onDragEnd = () => {
|
|
1906
1906
|
if (!this.isDragging) return;
|
|
@@ -1909,7 +1909,7 @@ class Z {
|
|
|
1909
1909
|
t.classList.remove("is-dragging"), i.style.animation = "none", requestAnimationFrame(() => {
|
|
1910
1910
|
this.applyAnimation(!0);
|
|
1911
1911
|
});
|
|
1912
|
-
}, this.options = { ...
|
|
1912
|
+
}, this.options = { ...ee.DEFAULT_OPTIONS, ...e }, this.options.backdrop === !1 && e.bodyScroll === void 0 && (this.options.bodyScroll = !0);
|
|
1913
1913
|
}
|
|
1914
1914
|
get isDestroyed() {
|
|
1915
1915
|
return this._isDestroyed;
|
|
@@ -1953,15 +1953,15 @@ class Z {
|
|
|
1953
1953
|
});
|
|
1954
1954
|
if (i.modal = this, !e) {
|
|
1955
1955
|
i.classList.add("no-backdrop");
|
|
1956
|
-
const f = window.pageYOffset || document.documentElement.scrollTop,
|
|
1956
|
+
const f = window.pageYOffset || document.documentElement.scrollTop, g = window.pageXOffset || document.documentElement.scrollLeft, p = window.innerWidth;
|
|
1957
1957
|
i.style.top = `${f + 60}px`, this.once("modal.show", () => {
|
|
1958
|
-
i.style.left = `${
|
|
1958
|
+
i.style.left = `${g + p / 2 - i.offsetWidth / 2}px`;
|
|
1959
1959
|
});
|
|
1960
1960
|
}
|
|
1961
|
-
const
|
|
1961
|
+
const s = S("div", {
|
|
1962
1962
|
className: `ipe-modal-modal__window size--${this.options.sizeClass || "auto"} plugin--${this.pluginName}`
|
|
1963
1963
|
});
|
|
1964
|
-
|
|
1964
|
+
s.modal = this;
|
|
1965
1965
|
const n = S("div", { className: "ipe-modal-modal__header" }), o = `${this.modalId}-title`, a = S("h2", {
|
|
1966
1966
|
className: "ipe-modal-modal__title",
|
|
1967
1967
|
attrs: { id: o, role: "heading", "aria-level": "2" }
|
|
@@ -1975,8 +1975,8 @@ class Z {
|
|
|
1975
1975
|
html: "×"
|
|
1976
1976
|
});
|
|
1977
1977
|
f.addEventListener("click", () => {
|
|
1978
|
-
let
|
|
1979
|
-
typeof this.options.onClickClose == "function" ? this.options.onClickClose(this) === !1 && (
|
|
1978
|
+
let g = !0;
|
|
1979
|
+
typeof this.options.onClickClose == "function" ? this.options.onClickClose(this) === !1 && (g = !1) : this.options.onClickClose === !1 && (g = !1), g && this.close();
|
|
1980
1980
|
}), c.appendChild(f);
|
|
1981
1981
|
}
|
|
1982
1982
|
n.append(a, c), this.options.draggable && e && (this.options.draggable = !1), this.options.draggable && (n.style.cursor = "move", n.style.userSelect = "none", n.addEventListener("pointerdown", this.onDragStart.bind(this)), i.classList.add("is-draggable"));
|
|
@@ -1985,10 +1985,10 @@ class Z {
|
|
|
1985
1985
|
}), u = S("div", {
|
|
1986
1986
|
className: "ipe-modal-modal__buttons ipe-modal-modal__buttons--right"
|
|
1987
1987
|
});
|
|
1988
|
-
return h.append(d, u),
|
|
1988
|
+
return h.append(d, u), s.append(n, l, h), i.appendChild(s), this.$backdrop = t, this.$modal = i, this.$window = s, this.$header = n, this.$title = a, this.$icons = c, this.$content = l, this.$footer = h, this.$buttonsLeft = d, this.$buttonsRight = u, 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) : h.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", (f) => {
|
|
1989
1989
|
this.options.outSideClose && f.target === t && this.close();
|
|
1990
|
-
}), this.options.draggable &&
|
|
1991
|
-
f.target &&
|
|
1990
|
+
}), this.options.draggable && s.addEventListener("pointerdown", (f) => {
|
|
1991
|
+
f.target && s.contains(f.target) && this.bringToFront();
|
|
1992
1992
|
}), this.onKeyDown = this.onKeyDown.bind(this), this.emit(
|
|
1993
1993
|
"modal.init"
|
|
1994
1994
|
/* Init */
|
|
@@ -1998,12 +1998,12 @@ class Z {
|
|
|
1998
1998
|
if (this.$modal || this.init(), !this.$modal) throw new Error("Failed to initialize modal");
|
|
1999
1999
|
if (this.isOpen) return this;
|
|
2000
2000
|
{
|
|
2001
|
-
const i = this.emit("modal.beforeShow", !0),
|
|
2002
|
-
if (!i || !
|
|
2001
|
+
const i = this.emit("modal.beforeShow", !0), s = this.options.beforeShow ? this.options.beforeShow(this) !== !1 : !0;
|
|
2002
|
+
if (!i || !s) return this;
|
|
2003
2003
|
}
|
|
2004
|
-
this.lastFocused = document.activeElement ?? null, this.$backdrop && document.body.appendChild(this.$backdrop), document.body.appendChild(this.$modal), this.shouldLockBodyOnOpen() &&
|
|
2004
|
+
this.lastFocused = document.activeElement ?? null, this.$backdrop && document.body.appendChild(this.$backdrop), document.body.appendChild(this.$modal), this.shouldLockBodyOnOpen() && E.lockBodyScroll(), requestAnimationFrame(() => {
|
|
2005
2005
|
this.$backdrop?.classList.add("is-open"), this.$modal.classList.add("is-open"), this.applyAnimation(!0), this.focusFirst();
|
|
2006
|
-
}), document.addEventListener("keydown", this.onKeyDown),
|
|
2006
|
+
}), document.addEventListener("keydown", this.onKeyDown), E.push(this), this.isOpen = !0, this.options.onShow?.(this), this.emit(
|
|
2007
2007
|
"modal.show"
|
|
2008
2008
|
/* Show */
|
|
2009
2009
|
);
|
|
@@ -2044,23 +2044,23 @@ class Z {
|
|
|
2044
2044
|
let t = !1;
|
|
2045
2045
|
const i = () => {
|
|
2046
2046
|
t || (t = !0, this.destroy(), this.options.onClose?.(this));
|
|
2047
|
-
},
|
|
2047
|
+
}, s = (n, o) => {
|
|
2048
2048
|
const a = () => {
|
|
2049
2049
|
n.removeEventListener(o, a), i();
|
|
2050
2050
|
};
|
|
2051
2051
|
n.addEventListener(o, a, { once: !0 });
|
|
2052
2052
|
};
|
|
2053
|
-
return e > 0 && this.$window ? (
|
|
2053
|
+
return e > 0 && this.$window ? (s(this.$window, "transitionend"), s(this.$window, "animationend"), window.setTimeout(i, e + 20)) : window.setTimeout(i, e), this;
|
|
2054
2054
|
}
|
|
2055
2055
|
/** Immediately removes DOM and listeners */
|
|
2056
2056
|
destroy() {
|
|
2057
2057
|
if (this._isDestroyed) return this;
|
|
2058
2058
|
if (this.stopCloseTimer(), document.removeEventListener("keydown", this.onKeyDown), this.isDragging && this.onDragEnd(), this.$window?.removeEventListener("mouseenter", this.stopCloseTimer), this.isToast) {
|
|
2059
2059
|
this.$window?.parentElement && this.$window.parentElement.removeChild(this.$window);
|
|
2060
|
-
const e =
|
|
2061
|
-
e !== -1 &&
|
|
2060
|
+
const e = P.indexOf(this);
|
|
2061
|
+
e !== -1 && P.splice(e, 1);
|
|
2062
2062
|
} else
|
|
2063
|
-
this.$backdrop?.parentElement && this.$backdrop.parentElement.removeChild(this.$backdrop), this.$modal?.parentElement && this.$modal.parentElement.removeChild(this.$modal),
|
|
2063
|
+
this.$backdrop?.parentElement && this.$backdrop.parentElement.removeChild(this.$backdrop), this.$modal?.parentElement && this.$modal.parentElement.removeChild(this.$modal), E.remove(this), this.shouldUnlockBodyOnClose() && E.unlockBodyScroll();
|
|
2064
2064
|
return this.isOpen = !1, this.lastFocused?.focus?.(), this.emit(
|
|
2065
2065
|
"modal.destroy"
|
|
2066
2066
|
/* Destroy */
|
|
@@ -2071,50 +2071,50 @@ class Z {
|
|
|
2071
2071
|
return this.$backdrop;
|
|
2072
2072
|
}
|
|
2073
2073
|
get$modal() {
|
|
2074
|
-
return
|
|
2074
|
+
return T(this.$modal, "modal");
|
|
2075
2075
|
}
|
|
2076
2076
|
get$window() {
|
|
2077
|
-
return
|
|
2077
|
+
return T(this.$window, "window");
|
|
2078
2078
|
}
|
|
2079
2079
|
get$header() {
|
|
2080
|
-
return
|
|
2080
|
+
return T(this.$header, "header");
|
|
2081
2081
|
}
|
|
2082
2082
|
get$title() {
|
|
2083
|
-
return
|
|
2083
|
+
return T(this.$title, "title");
|
|
2084
2084
|
}
|
|
2085
2085
|
get$content() {
|
|
2086
|
-
return
|
|
2086
|
+
return T(this.$content, "content");
|
|
2087
2087
|
}
|
|
2088
2088
|
get$icons() {
|
|
2089
|
-
return
|
|
2089
|
+
return T(this.$icons, "icons");
|
|
2090
2090
|
}
|
|
2091
2091
|
get$buttons(e) {
|
|
2092
|
-
return e === "leftButtons" ?
|
|
2092
|
+
return e === "leftButtons" ? T(this.$buttonsLeft, "leftButtons") : e === "rightButtons" ? T(this.$buttonsRight, "rightButtons") : T(this.$footer, "buttons");
|
|
2093
2093
|
}
|
|
2094
2094
|
// ------------------------------ content ------------------------------- //
|
|
2095
2095
|
setTitle(e) {
|
|
2096
2096
|
const t = this.get$title();
|
|
2097
|
-
return t.innerHTML = "", t.append(
|
|
2097
|
+
return t.innerHTML = "", t.append(j(e)), this;
|
|
2098
2098
|
}
|
|
2099
2099
|
setContent(e, t = "replace") {
|
|
2100
2100
|
const i = this.get$content();
|
|
2101
|
-
return t === "replace" ? (i.innerHTML = "", i.append(
|
|
2101
|
+
return t === "replace" ? (i.innerHTML = "", i.append(j(e))) : t === "append" ? i.append(j(e)) : i.prepend(j(e)), this;
|
|
2102
2102
|
}
|
|
2103
2103
|
setIcons(e) {
|
|
2104
2104
|
const t = this.get$icons();
|
|
2105
2105
|
t.innerHTML = "";
|
|
2106
2106
|
for (const i of e) {
|
|
2107
|
-
const
|
|
2107
|
+
const s = S("button", {
|
|
2108
2108
|
className: `ipe-modal-modal__icon ${i.className}`,
|
|
2109
2109
|
attrs: { type: "button" }
|
|
2110
2110
|
});
|
|
2111
|
-
|
|
2111
|
+
s.addEventListener("click", i.method), t.appendChild(s);
|
|
2112
2112
|
}
|
|
2113
2113
|
return this;
|
|
2114
2114
|
}
|
|
2115
2115
|
setButtons(e, t) {
|
|
2116
|
-
const i = this.$buttonsLeft,
|
|
2117
|
-
[i,
|
|
2116
|
+
const i = this.$buttonsLeft, s = this.$buttonsRight;
|
|
2117
|
+
[i, s].forEach((o) => o.innerHTML = ""), this.buttonElsLeft = [], this.buttonElsRight = [], this.keyMap.clear();
|
|
2118
2118
|
const n = t ?? this.$footer;
|
|
2119
2119
|
if (n === this.$footer)
|
|
2120
2120
|
e.forEach((o) => this.addButton(o)), e.length === 0 && (this.$footer.style.display = "none");
|
|
@@ -2130,8 +2130,8 @@ class Z {
|
|
|
2130
2130
|
generateButton(e) {
|
|
2131
2131
|
const t = e.type ?? "button", i = t === "link" ? S("a") : S("button", { attrs: { type: "button" } });
|
|
2132
2132
|
e.id && (i.id = e.id), i.className = `ipe-modal-btn ${e.className ?? ""}`.trim();
|
|
2133
|
-
const
|
|
2134
|
-
if (i.append(
|
|
2133
|
+
const s = j(e.label ?? "OK");
|
|
2134
|
+
if (i.append(s), t === "link" && e.href && (i.href = e.href), e.method && i.addEventListener("click", (n) => {
|
|
2135
2135
|
if (i._ipe_tmpDisabled) {
|
|
2136
2136
|
n.preventDefault(), n.stopPropagation();
|
|
2137
2137
|
return;
|
|
@@ -2149,7 +2149,7 @@ class Z {
|
|
|
2149
2149
|
if (e.keyPress) {
|
|
2150
2150
|
const n = String(e.keyPress).split(/[\,\|]+/g).map((o) => o.trim()).filter(Boolean);
|
|
2151
2151
|
for (const o of n) {
|
|
2152
|
-
const a =
|
|
2152
|
+
const a = Ai(o);
|
|
2153
2153
|
a && this.keyMap.set(a, i);
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
@@ -2158,18 +2158,18 @@ class Z {
|
|
|
2158
2158
|
/** Dynamically add button(s) into footer. Supports insertion index per side. */
|
|
2159
2159
|
addButton(e, t) {
|
|
2160
2160
|
this.$footer && (this.$footer.style.display = "");
|
|
2161
|
-
const i = e.side ?? "right",
|
|
2162
|
-
return a >=
|
|
2161
|
+
const i = e.side ?? "right", s = i === "left" ? this.$buttonsLeft : this.$buttonsRight, n = i === "left" ? this.buttonElsLeft : this.buttonElsRight, o = this.generateButton(e), a = Math.max(0, Math.min(t ?? n.length, n.length));
|
|
2162
|
+
return a >= s.children.length ? s.appendChild(o) : s.insertBefore(o, s.children[a]), n.splice(a, 0, o), this;
|
|
2163
2163
|
}
|
|
2164
2164
|
/** Remove button by element / id / global index (left first, then right). */
|
|
2165
2165
|
removeButton(e) {
|
|
2166
|
-
const t = this.buttonElsLeft, i = this.buttonElsRight,
|
|
2166
|
+
const t = this.buttonElsLeft, i = this.buttonElsRight, s = [...t, ...i];
|
|
2167
2167
|
let n = null;
|
|
2168
2168
|
if (e === "*")
|
|
2169
|
-
return
|
|
2169
|
+
return s.forEach((a) => {
|
|
2170
2170
|
this.keyMap.delete(a.id), a.parentElement?.removeChild(a);
|
|
2171
2171
|
}), this.$footer && (this.$footer.style.display = "none"), this;
|
|
2172
|
-
if (typeof e == "number" ? n =
|
|
2172
|
+
if (typeof e == "number" ? n = s[e] ?? null : typeof e == "string" ? n = s.find((a) => a.id === e) ?? null : e instanceof HTMLElement && (n = s.find((a) => a === e) ?? null), !n) return this;
|
|
2173
2173
|
for (const [a, c] of this.keyMap.entries()) c === n && this.keyMap.delete(a);
|
|
2174
2174
|
let o = t.indexOf(n);
|
|
2175
2175
|
return o !== -1 ? (t.splice(o, 1), n.parentElement?.removeChild(n)) : (o = i.indexOf(n), o !== -1 && (i.splice(o, 1), n.parentElement?.removeChild(n))), t.length === 0 && i.length === 0 && this.$footer && (this.$footer.style.display = "none"), this;
|
|
@@ -2178,8 +2178,8 @@ class Z {
|
|
|
2178
2178
|
return this.get$modal().classList.toggle("is-fullscreen"), this;
|
|
2179
2179
|
}
|
|
2180
2180
|
setModalHeight(e, t = "height") {
|
|
2181
|
-
const i = this.get$window(),
|
|
2182
|
-
return i.style[t] = `${
|
|
2181
|
+
const i = this.get$window(), s = Math.max(0, window.innerHeight - e);
|
|
2182
|
+
return i.style[t] = `${s}px`, s;
|
|
2183
2183
|
}
|
|
2184
2184
|
setOptions(e, t) {
|
|
2185
2185
|
return typeof e == "string" ? this.options[e] = t : Object.assign(this.options, e), this;
|
|
@@ -2192,8 +2192,8 @@ class Z {
|
|
|
2192
2192
|
}
|
|
2193
2193
|
// ------------------------------ helpers ------------------------------- //
|
|
2194
2194
|
applyAnimation(e) {
|
|
2195
|
-
const t = this.get$modal(), i = this.get$window(),
|
|
2196
|
-
!o || o === !1 ? (t.style.transition = "none", i.style.animation = "none", i.style.removeProperty("--ipe-modal-anim")) : (t.style.removeProperty("transition"), i.style.setProperty("--ipe-modal-anim", o)),
|
|
2195
|
+
const t = this.get$modal(), i = this.get$window(), s = this.$backdrop, n = this.options.modalAnimation ?? this.options.animation, o = typeof n == "string" ? n : n && (e ? n.show : n.hide), a = this.options.backdropAnimation ?? this.options.animation, c = typeof a == "string" ? a : a && (e ? a.show : a.hide);
|
|
2196
|
+
!o || o === !1 ? (t.style.transition = "none", i.style.animation = "none", i.style.removeProperty("--ipe-modal-anim")) : (t.style.removeProperty("transition"), i.style.setProperty("--ipe-modal-anim", o)), s && (!c || c === !1 ? s.style.transition = "none" : s.style.removeProperty("transition"));
|
|
2197
2197
|
}
|
|
2198
2198
|
on(e, t) {
|
|
2199
2199
|
return this._hooks.push({ type: e, listener: t }), () => this.off(e, t);
|
|
@@ -2204,25 +2204,25 @@ class Z {
|
|
|
2204
2204
|
), this;
|
|
2205
2205
|
}
|
|
2206
2206
|
once(e, t) {
|
|
2207
|
-
const i = this.on(e, (
|
|
2207
|
+
const i = this.on(e, (s) => (i(), t(s)));
|
|
2208
2208
|
return i;
|
|
2209
2209
|
}
|
|
2210
2210
|
emit(e, t) {
|
|
2211
2211
|
const i = this._hooks.filter((a) => a.type === e);
|
|
2212
|
-
let
|
|
2212
|
+
let s = !0;
|
|
2213
2213
|
for (const a of i) {
|
|
2214
2214
|
const c = new CustomEvent(e, { detail: this, cancelable: t }), l = a.listener(c);
|
|
2215
|
-
if (c.defaultPrevented && (
|
|
2215
|
+
if (c.defaultPrevented && (s = !1), l === !1 && (s = !1), !s) break;
|
|
2216
2216
|
}
|
|
2217
2217
|
const n = this.$modal ?? document.body, o = new CustomEvent(e, { detail: this, cancelable: t });
|
|
2218
|
-
return (!n.dispatchEvent(o) || o.defaultPrevented) && (
|
|
2218
|
+
return (!n.dispatchEvent(o) || o.defaultPrevented) && (s = !1), s;
|
|
2219
2219
|
}
|
|
2220
2220
|
focusFirst() {
|
|
2221
|
-
const e = this.get$modal(), t =
|
|
2221
|
+
const e = this.get$modal(), t = Ue(e);
|
|
2222
2222
|
t.length ? t[0].focus() : e.focus({ preventScroll: !0 });
|
|
2223
2223
|
}
|
|
2224
2224
|
onKeyDown(e) {
|
|
2225
|
-
if (
|
|
2225
|
+
if (E.top() !== this) return;
|
|
2226
2226
|
if (e.key === "Escape") {
|
|
2227
2227
|
e.preventDefault(), this.close();
|
|
2228
2228
|
return;
|
|
@@ -2230,15 +2230,15 @@ class Z {
|
|
|
2230
2230
|
const t = this.get$modal();
|
|
2231
2231
|
if (!t.contains(document.activeElement)) return;
|
|
2232
2232
|
if (e.key === "Tab") {
|
|
2233
|
-
const a =
|
|
2233
|
+
const a = Ue(t);
|
|
2234
2234
|
if (!a.length) return;
|
|
2235
2235
|
const c = a[0], l = a[a.length - 1], h = document.activeElement;
|
|
2236
2236
|
e.shiftKey && h === c ? (e.preventDefault(), l.focus()) : !e.shiftKey && h === l && (e.preventDefault(), c.focus());
|
|
2237
2237
|
}
|
|
2238
|
-
const i = e.ctrlKey || e.altKey || e.metaKey,
|
|
2239
|
-
if (!i && (
|
|
2238
|
+
const i = e.ctrlKey || e.altKey || e.metaKey, s = e.target;
|
|
2239
|
+
if (!i && (s && ["INPUT", "TEXTAREA"].includes(s.tagName) || s.contentEditable === "true"))
|
|
2240
2240
|
return;
|
|
2241
|
-
const n =
|
|
2241
|
+
const n = Ti(e), o = this.keyMap.get(n);
|
|
2242
2242
|
if (o) {
|
|
2243
2243
|
e.preventDefault(), o.click();
|
|
2244
2244
|
return;
|
|
@@ -2249,19 +2249,19 @@ class Z {
|
|
|
2249
2249
|
}
|
|
2250
2250
|
/** Bring this modal to the top of the stack. */
|
|
2251
2251
|
bringToFront() {
|
|
2252
|
-
return
|
|
2252
|
+
return E.remove(this), E.push(this), this;
|
|
2253
2253
|
}
|
|
2254
2254
|
isAnimationDisabled() {
|
|
2255
2255
|
const e = this.options.modalAnimation ?? this.options.animation;
|
|
2256
2256
|
return e === !1 || e == null;
|
|
2257
2257
|
}
|
|
2258
2258
|
shouldLockBodyOnOpen() {
|
|
2259
|
-
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !
|
|
2259
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !E.stack.some(
|
|
2260
2260
|
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
2261
2261
|
);
|
|
2262
2262
|
}
|
|
2263
2263
|
shouldUnlockBodyOnClose() {
|
|
2264
|
-
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !
|
|
2264
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !E.stack.some(
|
|
2265
2265
|
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
2266
2266
|
);
|
|
2267
2267
|
}
|
|
@@ -2276,10 +2276,10 @@ class Z {
|
|
|
2276
2276
|
/** Show as toast (no backdrop, container stack). */
|
|
2277
2277
|
showToast(e) {
|
|
2278
2278
|
this.$window || this.init();
|
|
2279
|
-
const t =
|
|
2279
|
+
const t = Oi(e.position ?? "top right"), i = this.get$window();
|
|
2280
2280
|
this.isToast = !0, i.style.pointerEvents = "auto", this.applyAnimation(!0), t.appendChild(i);
|
|
2281
|
-
const
|
|
2282
|
-
return
|
|
2281
|
+
const s = (typeof this.options.closeAfter == "number" ? this.options.closeAfter : this.options.closeAfter?.time) ?? 3e3, n = (typeof this.options.closeAfter == "number" ? !0 : this.options.closeAfter?.resetOnHover) ?? !0;
|
|
2282
|
+
return s > 0 && (this.startCloseTimer(s), n && (i.addEventListener("mouseenter", this.stopCloseTimer), i.addEventListener("mouseleave", () => this.startCloseTimer(s)))), this.isOpen = !0, this.options.onShow?.(this), P.push(this), this.emit(
|
|
2283
2283
|
"toast.show"
|
|
2284
2284
|
/* ToastShow */
|
|
2285
2285
|
), this.emit(
|
|
@@ -2296,24 +2296,24 @@ class Z {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
static close(e) {
|
|
2298
2298
|
if (!e) {
|
|
2299
|
-
const n =
|
|
2299
|
+
const n = E.top();
|
|
2300
2300
|
return n?.close(), n;
|
|
2301
2301
|
}
|
|
2302
|
-
const t = typeof e == "string" ? e : e.id, i =
|
|
2302
|
+
const t = typeof e == "string" ? e : e.id, i = E.stack.find((n) => n.modalId === t);
|
|
2303
2303
|
if (i)
|
|
2304
2304
|
return i.close(), i;
|
|
2305
|
-
const
|
|
2306
|
-
return
|
|
2305
|
+
const s = P.find((n) => n.modalId === t);
|
|
2306
|
+
return s?.close(), s;
|
|
2307
2307
|
}
|
|
2308
2308
|
static closeAll(e, t) {
|
|
2309
|
-
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)),
|
|
2310
|
-
return
|
|
2311
|
-
const o = n.modalId, a =
|
|
2309
|
+
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), s = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
2310
|
+
return E.closeAll(e, t), [...P].forEach((n) => {
|
|
2311
|
+
const o = n.modalId, a = s.size ? s.has(n.pluginName) : !0, c = i.has(o);
|
|
2312
2312
|
a && !c && n.close();
|
|
2313
|
-
}),
|
|
2313
|
+
}), E.top() ?? new ee();
|
|
2314
2314
|
}
|
|
2315
2315
|
static removeAll() {
|
|
2316
|
-
|
|
2316
|
+
E.removeAll(), [...P].forEach((e) => e.destroy());
|
|
2317
2317
|
}
|
|
2318
2318
|
static dialog(e, t) {
|
|
2319
2319
|
const i = new this({
|
|
@@ -2322,8 +2322,8 @@ class Z {
|
|
|
2322
2322
|
{
|
|
2323
2323
|
label: "OK",
|
|
2324
2324
|
className: "is-primary is-ghost",
|
|
2325
|
-
method: (
|
|
2326
|
-
t?.(
|
|
2325
|
+
method: (s, n) => {
|
|
2326
|
+
t?.(s, n), s.defaultPrevented || i.close();
|
|
2327
2327
|
},
|
|
2328
2328
|
keyPress: "Enter"
|
|
2329
2329
|
}
|
|
@@ -2334,14 +2334,14 @@ class Z {
|
|
|
2334
2334
|
}
|
|
2335
2335
|
static confirm(e, t) {
|
|
2336
2336
|
e.title ??= "Confirm", e.content ??= "Are you sure you want to perform this action?";
|
|
2337
|
-
const i = e.okBtn ?? { label: "OK", className: "is-primary is-ghost" },
|
|
2337
|
+
const i = e.okBtn ?? { label: "OK", className: "is-primary is-ghost" }, s = e.cancelBtn ?? { label: "Cancel", className: "is-danger is-ghost" };
|
|
2338
2338
|
return new this({
|
|
2339
2339
|
sizeClass: "dialog",
|
|
2340
2340
|
...e,
|
|
2341
2341
|
buttons: [
|
|
2342
2342
|
{
|
|
2343
|
-
label:
|
|
2344
|
-
className:
|
|
2343
|
+
label: s.label,
|
|
2344
|
+
className: s.className,
|
|
2345
2345
|
keyPress: "n",
|
|
2346
2346
|
method: (n, o) => {
|
|
2347
2347
|
t?.(!1, o, n), o.close();
|
|
@@ -2361,7 +2361,7 @@ class Z {
|
|
|
2361
2361
|
static getDefaultNotifyIcon(e) {
|
|
2362
2362
|
switch (e) {
|
|
2363
2363
|
case "success":
|
|
2364
|
-
return /* @__PURE__ */
|
|
2364
|
+
return /* @__PURE__ */ w(
|
|
2365
2365
|
"svg",
|
|
2366
2366
|
{
|
|
2367
2367
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2371,13 +2371,13 @@ class Z {
|
|
|
2371
2371
|
fill: "currentColor",
|
|
2372
2372
|
class: "icon icon-tabler icons-tabler-filled icon-tabler-circle-check",
|
|
2373
2373
|
children: [
|
|
2374
|
-
/* @__PURE__ */
|
|
2375
|
-
/* @__PURE__ */
|
|
2374
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2375
|
+
/* @__PURE__ */ w("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" })
|
|
2376
2376
|
]
|
|
2377
2377
|
}
|
|
2378
2378
|
);
|
|
2379
2379
|
case "error":
|
|
2380
|
-
return /* @__PURE__ */
|
|
2380
|
+
return /* @__PURE__ */ w(
|
|
2381
2381
|
"svg",
|
|
2382
2382
|
{
|
|
2383
2383
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2387,13 +2387,13 @@ class Z {
|
|
|
2387
2387
|
fill: "currentColor",
|
|
2388
2388
|
class: "icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",
|
|
2389
2389
|
children: [
|
|
2390
|
-
/* @__PURE__ */
|
|
2391
|
-
/* @__PURE__ */
|
|
2390
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2391
|
+
/* @__PURE__ */ w("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" })
|
|
2392
2392
|
]
|
|
2393
2393
|
}
|
|
2394
2394
|
);
|
|
2395
2395
|
case "warning":
|
|
2396
|
-
return /* @__PURE__ */
|
|
2396
|
+
return /* @__PURE__ */ w(
|
|
2397
2397
|
"svg",
|
|
2398
2398
|
{
|
|
2399
2399
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2403,13 +2403,13 @@ class Z {
|
|
|
2403
2403
|
fill: "currentColor",
|
|
2404
2404
|
class: "icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",
|
|
2405
2405
|
children: [
|
|
2406
|
-
/* @__PURE__ */
|
|
2407
|
-
/* @__PURE__ */
|
|
2406
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2407
|
+
/* @__PURE__ */ w("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" })
|
|
2408
2408
|
]
|
|
2409
2409
|
}
|
|
2410
2410
|
);
|
|
2411
2411
|
case "info":
|
|
2412
|
-
return /* @__PURE__ */
|
|
2412
|
+
return /* @__PURE__ */ w(
|
|
2413
2413
|
"svg",
|
|
2414
2414
|
{
|
|
2415
2415
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2419,13 +2419,13 @@ class Z {
|
|
|
2419
2419
|
fill: "currentColor",
|
|
2420
2420
|
class: "icon icon-tabler icons-tabler-filled icon-tabler-info-circle",
|
|
2421
2421
|
children: [
|
|
2422
|
-
/* @__PURE__ */
|
|
2423
|
-
/* @__PURE__ */
|
|
2422
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2423
|
+
/* @__PURE__ */ w("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" })
|
|
2424
2424
|
]
|
|
2425
2425
|
}
|
|
2426
2426
|
);
|
|
2427
2427
|
case "dialog":
|
|
2428
|
-
return /* @__PURE__ */
|
|
2428
|
+
return /* @__PURE__ */ w(
|
|
2429
2429
|
"svg",
|
|
2430
2430
|
{
|
|
2431
2431
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2439,16 +2439,16 @@ class Z {
|
|
|
2439
2439
|
"stroke-linejoin": "round",
|
|
2440
2440
|
class: "icon icon-tabler icons-tabler-outline icon-tabler-message-dots",
|
|
2441
2441
|
children: [
|
|
2442
|
-
/* @__PURE__ */
|
|
2443
|
-
/* @__PURE__ */
|
|
2444
|
-
/* @__PURE__ */
|
|
2445
|
-
/* @__PURE__ */
|
|
2446
|
-
/* @__PURE__ */
|
|
2442
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2443
|
+
/* @__PURE__ */ w("path", { d: "M12 11v.01" }),
|
|
2444
|
+
/* @__PURE__ */ w("path", { d: "M8 11v.01" }),
|
|
2445
|
+
/* @__PURE__ */ w("path", { d: "M16 11v.01" }),
|
|
2446
|
+
/* @__PURE__ */ w("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" })
|
|
2447
2447
|
]
|
|
2448
2448
|
}
|
|
2449
2449
|
);
|
|
2450
2450
|
case "confirm":
|
|
2451
|
-
return /* @__PURE__ */
|
|
2451
|
+
return /* @__PURE__ */ w(
|
|
2452
2452
|
"svg",
|
|
2453
2453
|
{
|
|
2454
2454
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2458,8 +2458,8 @@ class Z {
|
|
|
2458
2458
|
fill: "currentColor",
|
|
2459
2459
|
class: "icon icon-tabler icons-tabler-filled icon-tabler-copy-check",
|
|
2460
2460
|
children: [
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
/* @__PURE__ */
|
|
2461
|
+
/* @__PURE__ */ w("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
2462
|
+
/* @__PURE__ */ w("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" })
|
|
2463
2463
|
]
|
|
2464
2464
|
}
|
|
2465
2465
|
);
|
|
@@ -2468,13 +2468,13 @@ class Z {
|
|
|
2468
2468
|
}
|
|
2469
2469
|
}
|
|
2470
2470
|
static notify(e, t, i) {
|
|
2471
|
-
if (t?.overrideOther && [...
|
|
2471
|
+
if (t?.overrideOther && [...P].forEach((a) => a.close()), typeof t.title > "u") {
|
|
2472
2472
|
const a = e || "Notification";
|
|
2473
2473
|
t.title = a[0].toUpperCase() + a.slice(1).toLowerCase();
|
|
2474
2474
|
}
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2477
|
-
|
|
2475
|
+
const s = t.icon ?? this.getDefaultNotifyIcon(e);
|
|
2476
|
+
s && (s instanceof Element && s.classList.add("ipe-modal-notify-icon"), t.title = /* @__PURE__ */ w(Si, { children: [
|
|
2477
|
+
s,
|
|
2478
2478
|
t.title
|
|
2479
2479
|
] })), 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, c) => {
|
|
2480
2480
|
i?.(!0, c, a), c.close();
|
|
@@ -2499,16 +2499,16 @@ class Z {
|
|
|
2499
2499
|
});
|
|
2500
2500
|
}
|
|
2501
2501
|
}
|
|
2502
|
-
const
|
|
2503
|
-
function
|
|
2504
|
-
const e = "ipe-modal-toast-container", t = `${e}-${
|
|
2502
|
+
const P = [];
|
|
2503
|
+
function Oi(r = "top right") {
|
|
2504
|
+
const e = "ipe-modal-toast-container", t = `${e}-${r.replace(/[\s-\.|\/]+/g, "-")}`;
|
|
2505
2505
|
let i = document.getElementById(t);
|
|
2506
2506
|
return i || (i = S("div", {
|
|
2507
|
-
className: `${e} ${
|
|
2508
|
-
attrs: { id: t, "data-position":
|
|
2507
|
+
className: `${e} ${r}`,
|
|
2508
|
+
attrs: { id: t, "data-position": r }
|
|
2509
2509
|
}), document.body.appendChild(i)), i;
|
|
2510
2510
|
}
|
|
2511
|
-
class
|
|
2511
|
+
class v extends ee {
|
|
2512
2512
|
constructor(e = {}) {
|
|
2513
2513
|
e.className ||= "", e.className += " theme-ipe", e.modalAnimation ||= {
|
|
2514
2514
|
show: "ipe-modal-fade-in",
|
|
@@ -2523,7 +2523,7 @@ class b extends Z {
|
|
|
2523
2523
|
this._tmpDisabledActiveInputs = t, t.forEach((i) => {
|
|
2524
2524
|
i.disabled = !0;
|
|
2525
2525
|
}), this.get$content().append(
|
|
2526
|
-
/* @__PURE__ */
|
|
2526
|
+
/* @__PURE__ */ k(
|
|
2527
2527
|
"div",
|
|
2528
2528
|
{
|
|
2529
2529
|
id: "ipe-modalLoadingWrapper",
|
|
@@ -2539,7 +2539,7 @@ class b extends Z {
|
|
|
2539
2539
|
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
2540
2540
|
zIndex: 2e3
|
|
2541
2541
|
},
|
|
2542
|
-
children: /* @__PURE__ */
|
|
2542
|
+
children: /* @__PURE__ */ k(Ct, { style: { width: "80%", maxWidth: "800px" } })
|
|
2543
2543
|
}
|
|
2544
2544
|
)
|
|
2545
2545
|
);
|
|
@@ -2552,56 +2552,56 @@ class b extends Z {
|
|
|
2552
2552
|
}
|
|
2553
2553
|
}
|
|
2554
2554
|
}
|
|
2555
|
-
class
|
|
2555
|
+
class Ii {
|
|
2556
2556
|
constructor(e) {
|
|
2557
|
-
this.ctx = e, this.IPEModal =
|
|
2558
|
-
|
|
2557
|
+
this.ctx = e, this.IPEModal = v, this.IPEModalEvent = ve, this.show = v.show.bind(v), this.createObject = v.createObject.bind(v), this.close = v.close.bind(v), this.closeAll = v.closeAll.bind(v), this.removeAll = v.removeAll.bind(v), this.dialog = v.dialog.bind(v), this.confirm = v.confirm.bind(v), this.notify = v.notify.bind(v), e.set("modal", this), e.on("dispose", () => {
|
|
2558
|
+
v.closeAll();
|
|
2559
2559
|
});
|
|
2560
2560
|
}
|
|
2561
2561
|
}
|
|
2562
|
-
const
|
|
2563
|
-
if (!
|
|
2562
|
+
const ot = (r) => {
|
|
2563
|
+
if (!r)
|
|
2564
2564
|
return new URLSearchParams();
|
|
2565
|
-
if (
|
|
2566
|
-
return
|
|
2567
|
-
if (typeof
|
|
2565
|
+
if (r instanceof URLSearchParams)
|
|
2566
|
+
return r;
|
|
2567
|
+
if (typeof r != "object" || r?.constructor !== Object)
|
|
2568
2568
|
throw new TypeError("only plain object is supported");
|
|
2569
2569
|
const e = new URLSearchParams();
|
|
2570
|
-
for (const [t, i] of Object.entries(
|
|
2570
|
+
for (const [t, i] of Object.entries(r))
|
|
2571
2571
|
if (i != null) {
|
|
2572
2572
|
if (Array.isArray(i)) {
|
|
2573
|
-
for (const
|
|
2574
|
-
e.append(t,
|
|
2573
|
+
for (const s of i)
|
|
2574
|
+
e.append(t, s?.toString());
|
|
2575
2575
|
continue;
|
|
2576
2576
|
}
|
|
2577
2577
|
if (typeof i == "object" && i !== null && i.constructor === Object) {
|
|
2578
|
-
for (const [
|
|
2579
|
-
n != null && e.set(`${t}[${
|
|
2578
|
+
for (const [s, n] of Object.entries(i))
|
|
2579
|
+
n != null && e.set(`${t}[${s}]`, n?.toString());
|
|
2580
2580
|
continue;
|
|
2581
2581
|
}
|
|
2582
2582
|
e.set(t, i?.toString());
|
|
2583
2583
|
}
|
|
2584
2584
|
return e;
|
|
2585
|
-
},
|
|
2586
|
-
const i = typeof
|
|
2585
|
+
}, at = (r, e, t) => {
|
|
2586
|
+
const i = typeof r == "string" ? new URL(r, window?.location?.origin) : new URL(r), s = new URLSearchParams(i.search), n = ot(e);
|
|
2587
2587
|
for (const [o, a] of n.entries())
|
|
2588
|
-
|
|
2589
|
-
return i.search =
|
|
2588
|
+
s.set(o, a);
|
|
2589
|
+
return i.search = s.toString(), i.hash = "", i;
|
|
2590
2590
|
};
|
|
2591
|
-
var
|
|
2592
|
-
throw TypeError(
|
|
2593
|
-
},
|
|
2594
|
-
for (var
|
|
2591
|
+
var Pi = Object.create, _e = Object.defineProperty, Di = Object.getOwnPropertyDescriptor, lt = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), ct = (r) => {
|
|
2592
|
+
throw TypeError(r);
|
|
2593
|
+
}, Mi = (r, e, t) => e in r ? _e(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Ui = (r, e) => _e(r, "name", { value: e, configurable: !0 }), Bi = (r) => [, , , Pi(r?.[lt("metadata")] ?? null)], Ni = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ht = (r) => r !== void 0 && typeof r != "function" ? ct("Function expected") : r, ji = (r, e, t, i, s) => ({ kind: Ni[r], name: e, metadata: i, addInitializer: (n) => t._ ? ct("Already initialized") : s.push(ht(n || null)) }), qi = (r, e) => Mi(e, lt("metadata"), r[3]), Fi = (r, e, t, i) => {
|
|
2594
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
2595
2595
|
return i;
|
|
2596
|
-
},
|
|
2597
|
-
var o, a, c, l = e & 7, h = !1, d = 0, u =
|
|
2598
|
-
|
|
2599
|
-
for (var
|
|
2600
|
-
c =
|
|
2601
|
-
return
|
|
2602
|
-
},
|
|
2603
|
-
|
|
2604
|
-
class
|
|
2596
|
+
}, Hi = (r, e, t, i, s, n) => {
|
|
2597
|
+
var o, a, c, l = e & 7, h = !1, d = 0, u = r[d] || (r[d] = []), f = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Di(s, t));
|
|
2598
|
+
Ui(s, t);
|
|
2599
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
2600
|
+
c = ji(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, ht(o) && (s = o);
|
|
2601
|
+
return qi(r, s), f && _e(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
2602
|
+
}, ut, Se, dt;
|
|
2603
|
+
ut = [ne(["api", "storage"])];
|
|
2604
|
+
class te extends (dt = I) {
|
|
2605
2605
|
constructor(e) {
|
|
2606
2606
|
super(e, "wiki", !1), this.ctx = e, this._data = {}, this.CACHE_VERSION = 3, this.CACHE_TTL = {
|
|
2607
2607
|
siteinfo: 1e3 * 60 * 60 * 24 * 3,
|
|
@@ -2635,52 +2635,53 @@ class J extends (rt = I) {
|
|
|
2635
2635
|
async start() {
|
|
2636
2636
|
await Promise.all(
|
|
2637
2637
|
Object.keys(this.QUERY_DATA).map((e) => this.initData(e))
|
|
2638
|
-
), 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) => {
|
|
2638
|
+
), 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) => {
|
|
2639
|
+
const t = e.$;
|
|
2639
2640
|
e.preferences.registerCustomConfig(
|
|
2640
2641
|
"WikiMetadataService",
|
|
2641
|
-
|
|
2642
|
-
WikiMetadataService:
|
|
2643
|
-
/* @__PURE__ */
|
|
2644
|
-
/* @__PURE__ */
|
|
2645
|
-
/* @__PURE__ */
|
|
2646
|
-
/* @__PURE__ */
|
|
2647
|
-
/* @__PURE__ */
|
|
2642
|
+
m.object({
|
|
2643
|
+
WikiMetadataService: m.const(
|
|
2644
|
+
/* @__PURE__ */ k("div", { children: [
|
|
2645
|
+
/* @__PURE__ */ k("h3", { children: t`Wiki Informations` }),
|
|
2646
|
+
/* @__PURE__ */ k("ul", { children: [
|
|
2647
|
+
/* @__PURE__ */ k("li", { children: [
|
|
2648
|
+
/* @__PURE__ */ k("strong", { children: [
|
|
2649
|
+
t`Site`,
|
|
2650
|
+
":"
|
|
2651
|
+
] }),
|
|
2648
2652
|
" ",
|
|
2649
2653
|
this.general.sitename,
|
|
2650
2654
|
" (",
|
|
2651
2655
|
this.landingPageUrl,
|
|
2652
2656
|
")"
|
|
2653
2657
|
] }),
|
|
2654
|
-
/* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */
|
|
2658
|
+
/* @__PURE__ */ k("li", { children: [
|
|
2659
|
+
/* @__PURE__ */ k("strong", { children: t`User` }),
|
|
2656
2660
|
": ",
|
|
2657
2661
|
this.userInfo.name,
|
|
2658
2662
|
" (ID: ",
|
|
2659
2663
|
this.userInfo.id,
|
|
2660
2664
|
")"
|
|
2661
2665
|
] }),
|
|
2662
|
-
/* @__PURE__ */
|
|
2663
|
-
/* @__PURE__ */
|
|
2666
|
+
/* @__PURE__ */ k("li", { children: [
|
|
2667
|
+
/* @__PURE__ */ k("strong", { children: t`Groups` }),
|
|
2664
2668
|
": ",
|
|
2665
2669
|
this.userGroups.join(", ") || "None"
|
|
2666
2670
|
] })
|
|
2667
2671
|
] }),
|
|
2668
|
-
/* @__PURE__ */
|
|
2669
|
-
/* @__PURE__ */
|
|
2670
|
-
/* @__PURE__ */
|
|
2672
|
+
/* @__PURE__ */ k("div", { children: [
|
|
2673
|
+
/* @__PURE__ */ k("p", { style: { fontStyle: "italic" }, children: t`If the information shown above is incorrect (for example, the user is not you), click the button below.` }),
|
|
2674
|
+
/* @__PURE__ */ k(
|
|
2671
2675
|
"button",
|
|
2672
2676
|
{
|
|
2673
2677
|
className: "btn danger",
|
|
2674
|
-
onClick: (
|
|
2675
|
-
|
|
2676
|
-
Object.keys(this.QUERY_DATA).map(
|
|
2677
|
-
(i) => this.invalidateCache(i)
|
|
2678
|
-
)
|
|
2679
|
-
).then(() => {
|
|
2680
|
-
window.location.reload();
|
|
2681
|
-
});
|
|
2678
|
+
onClick: async (i) => {
|
|
2679
|
+
i.preventDefault(), await e.serial("clear-cache") || window.location.reload();
|
|
2682
2680
|
},
|
|
2683
|
-
children:
|
|
2681
|
+
children: [
|
|
2682
|
+
"🧹 ",
|
|
2683
|
+
t`Clear caches & Reload`
|
|
2684
|
+
]
|
|
2684
2685
|
}
|
|
2685
2686
|
)
|
|
2686
2687
|
] })
|
|
@@ -2696,8 +2697,8 @@ class J extends (rt = I) {
|
|
|
2696
2697
|
if (i)
|
|
2697
2698
|
return this._data[e] = i, this.logger.debug("Using cached", e, i), i;
|
|
2698
2699
|
{
|
|
2699
|
-
const
|
|
2700
|
-
return this.saveToCache(e,
|
|
2700
|
+
const s = await this.fetchFromApi(e);
|
|
2701
|
+
return this.saveToCache(e, s), this._data[e] = s, this.logger.debug("Fetched from API", e, s), s;
|
|
2701
2702
|
}
|
|
2702
2703
|
}
|
|
2703
2704
|
getCacheKey(e) {
|
|
@@ -2725,6 +2726,9 @@ class J extends (rt = I) {
|
|
|
2725
2726
|
const t = this.getCacheKey(e);
|
|
2726
2727
|
return this.CACHE_DB.delete(t);
|
|
2727
2728
|
}
|
|
2729
|
+
async onClearCache() {
|
|
2730
|
+
await this.CACHE_DB.clear();
|
|
2731
|
+
}
|
|
2728
2732
|
// ====== shortcuts ======
|
|
2729
2733
|
get _raw() {
|
|
2730
2734
|
return this._data;
|
|
@@ -2837,12 +2841,12 @@ class J extends (rt = I) {
|
|
|
2837
2841
|
}
|
|
2838
2842
|
/** Get mainpage URL */
|
|
2839
2843
|
getMainpageUrl(e) {
|
|
2840
|
-
return
|
|
2844
|
+
return at(this.siteInfo.general.base, e).toString();
|
|
2841
2845
|
}
|
|
2842
2846
|
getUrl(e, t) {
|
|
2843
|
-
const i =
|
|
2844
|
-
let
|
|
2845
|
-
return typeof e == "string" && e !== "" ?
|
|
2847
|
+
const i = ot(t);
|
|
2848
|
+
let s;
|
|
2849
|
+
return typeof e == "string" && e !== "" ? s = new URL(`${this.articleBaseUrl.replace("$1", e)}`) : typeof e == "number" ? (i.set("curid", e.toString()), s = new URL(this.getSciprtUrl("index"))) : s = new URL(this.getSciprtUrl("index")), s.search = i.toString(), s.toString();
|
|
2846
2850
|
}
|
|
2847
2851
|
hasRight(e) {
|
|
2848
2852
|
return this.userRights.includes(e);
|
|
@@ -2870,16 +2874,16 @@ class J extends (rt = I) {
|
|
|
2870
2874
|
} : null;
|
|
2871
2875
|
}
|
|
2872
2876
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
const
|
|
2877
|
-
const
|
|
2878
|
-
return
|
|
2877
|
+
Se = Bi(dt);
|
|
2878
|
+
te = Hi(Se, 0, "WikiMetadataService", ut, te);
|
|
2879
|
+
Fi(Se, 1, te);
|
|
2880
|
+
const Ki = (() => {
|
|
2881
|
+
const r = Symbol.for("IPE.GlobalMemoryStorage");
|
|
2882
|
+
return r in globalThis || (globalThis[r] = $t()), globalThis[r];
|
|
2879
2883
|
})();
|
|
2880
|
-
class
|
|
2881
|
-
constructor(e, t, i = 1 / 0,
|
|
2882
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
2884
|
+
class Wi {
|
|
2885
|
+
constructor(e, t, i = 1 / 0, s, n = "localStorage") {
|
|
2886
|
+
this.dbName = e, this.storeName = t, this.ttl = i, this.version = s, this.engine = n, typeof i != "number" && (this.ttl = Number(i)), (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 = Ki;
|
|
2883
2887
|
}
|
|
2884
2888
|
// Key builder
|
|
2885
2889
|
makeKey(e) {
|
|
@@ -2895,8 +2899,8 @@ class Li {
|
|
|
2895
2899
|
} catch {
|
|
2896
2900
|
return this.deleteSync(e), null;
|
|
2897
2901
|
}
|
|
2898
|
-
const
|
|
2899
|
-
return typeof
|
|
2902
|
+
const s = i;
|
|
2903
|
+
return typeof s.time != "number" || !("value" in s) ? (this.deleteSync(e), null) : typeof this.version < "u" && typeof this.version < "u" && s.version !== this.version ? (this.deleteSync(e), null) : s;
|
|
2900
2904
|
}
|
|
2901
2905
|
getRaw(e) {
|
|
2902
2906
|
const t = this.makeKey(e);
|
|
@@ -2917,15 +2921,15 @@ class Li {
|
|
|
2917
2921
|
return e ? Date.now() - e.time > t : !1;
|
|
2918
2922
|
}
|
|
2919
2923
|
async get(e, t = this.ttl, i) {
|
|
2920
|
-
const
|
|
2921
|
-
if (!
|
|
2924
|
+
const s = this.load(e), n = this.isExpired(s, t);
|
|
2925
|
+
if (!s || n) {
|
|
2922
2926
|
if (typeof i == "function") {
|
|
2923
2927
|
const o = await i();
|
|
2924
2928
|
return await this.set(e, o), o;
|
|
2925
2929
|
}
|
|
2926
2930
|
return null;
|
|
2927
2931
|
}
|
|
2928
|
-
return
|
|
2932
|
+
return s.value;
|
|
2929
2933
|
}
|
|
2930
2934
|
async set(e, t) {
|
|
2931
2935
|
const i = Date.now();
|
|
@@ -2938,8 +2942,8 @@ class Li {
|
|
|
2938
2942
|
const c = { time: i, value: a, version: this.version };
|
|
2939
2943
|
return this.setRaw(o, JSON.stringify(c)), c;
|
|
2940
2944
|
}
|
|
2941
|
-
const
|
|
2942
|
-
for (const [o, a] of Object.entries(
|
|
2945
|
+
const s = e, n = {};
|
|
2946
|
+
for (const [o, a] of Object.entries(s)) {
|
|
2943
2947
|
if (a === null || typeof a > "u") {
|
|
2944
2948
|
this.deleteSync(o);
|
|
2945
2949
|
continue;
|
|
@@ -2963,8 +2967,8 @@ class Li {
|
|
|
2963
2967
|
async clear() {
|
|
2964
2968
|
const e = this.makeKey(""), t = [];
|
|
2965
2969
|
for (let i = 0; i < this.db.length; i++) {
|
|
2966
|
-
const
|
|
2967
|
-
|
|
2970
|
+
const s = this.db.key(i);
|
|
2971
|
+
s && s.startsWith(e) && t.push(s);
|
|
2968
2972
|
}
|
|
2969
2973
|
for (const i of t) this.db.removeItem(i);
|
|
2970
2974
|
return this;
|
|
@@ -3002,172 +3006,172 @@ class Li {
|
|
|
3002
3006
|
}
|
|
3003
3007
|
}
|
|
3004
3008
|
}
|
|
3005
|
-
var
|
|
3006
|
-
((
|
|
3007
|
-
|
|
3009
|
+
var b;
|
|
3010
|
+
((r) => {
|
|
3011
|
+
r.cache = /* @__PURE__ */ new Map(), r.defaults = Object.freeze({ iterBatch: 100, retry: { attempts: 3, baseDelayMs: 16 } }), r.sleep = (l) => new Promise((h) => setTimeout(h, l));
|
|
3008
3012
|
function e(l) {
|
|
3009
3013
|
const h = l?.name ?? "";
|
|
3010
3014
|
return h === "AbortError" || h === "InvalidStateError" || h === "TransactionInactiveError" || h === "UnknownError";
|
|
3011
3015
|
}
|
|
3012
|
-
|
|
3016
|
+
r.shouldReconnect = e;
|
|
3013
3017
|
async function t(l, h, d) {
|
|
3014
3018
|
const u = Math.max(1, l.attempts);
|
|
3015
3019
|
for (let f = 0; f < u; f++)
|
|
3016
3020
|
try {
|
|
3017
3021
|
return await h(f);
|
|
3018
|
-
} catch (
|
|
3019
|
-
if (f === u - 1) throw
|
|
3020
|
-
await d?.(
|
|
3021
|
-
const
|
|
3022
|
-
await (0,
|
|
3022
|
+
} catch (g) {
|
|
3023
|
+
if (f === u - 1) throw g;
|
|
3024
|
+
await d?.(g, f);
|
|
3025
|
+
const p = l.baseDelayMs * Math.pow(2, f) + Math.floor(Math.random() * 10);
|
|
3026
|
+
await (0, r.sleep)(p);
|
|
3023
3027
|
}
|
|
3024
3028
|
throw new Error("withRetry exhausted unexpectedly");
|
|
3025
3029
|
}
|
|
3026
|
-
|
|
3030
|
+
r.withRetry = t;
|
|
3027
3031
|
function i(l, h, d) {
|
|
3028
3032
|
return new Promise((u, f) => {
|
|
3029
|
-
const
|
|
3030
|
-
|
|
3033
|
+
const g = indexedDB.open(l, h);
|
|
3034
|
+
g.onupgradeneeded = () => {
|
|
3031
3035
|
try {
|
|
3032
|
-
const
|
|
3033
|
-
d?.(
|
|
3034
|
-
} catch (
|
|
3035
|
-
f(
|
|
3036
|
+
const p = g.result, y = g.transaction;
|
|
3037
|
+
d?.(p, y);
|
|
3038
|
+
} catch (p) {
|
|
3039
|
+
f(p);
|
|
3036
3040
|
}
|
|
3037
|
-
},
|
|
3038
|
-
},
|
|
3039
|
-
const
|
|
3040
|
-
|
|
3041
|
+
}, g.onerror = () => f(g.error), g.onblocked = () => {
|
|
3042
|
+
}, g.onsuccess = () => {
|
|
3043
|
+
const p = g.result;
|
|
3044
|
+
p.onversionchange = () => {
|
|
3041
3045
|
try {
|
|
3042
|
-
|
|
3046
|
+
p.close();
|
|
3043
3047
|
} finally {
|
|
3044
|
-
|
|
3048
|
+
r.cache.delete(l);
|
|
3045
3049
|
}
|
|
3046
|
-
}, u(
|
|
3050
|
+
}, u(p);
|
|
3047
3051
|
};
|
|
3048
3052
|
});
|
|
3049
3053
|
}
|
|
3050
|
-
async function
|
|
3054
|
+
async function s(l, h, d) {
|
|
3051
3055
|
let u = !l.objectStoreNames.contains(h), f = [];
|
|
3052
3056
|
if (!u && d?.indexes?.length) {
|
|
3053
|
-
const
|
|
3054
|
-
f = (d.indexes || []).filter((
|
|
3055
|
-
|
|
3057
|
+
const y = l.transaction(h, "readonly"), L = y.objectStore(h), U = new Set(Array.from(L.indexNames));
|
|
3058
|
+
f = (d.indexes || []).filter((C) => !U.has(C.name)), await new Promise((C, Le) => {
|
|
3059
|
+
y.oncomplete = () => C(), y.onabort = () => Le(y.error), y.onerror = () => Le(y.error);
|
|
3056
3060
|
});
|
|
3057
3061
|
}
|
|
3058
3062
|
if (!u && f.length === 0) return l;
|
|
3059
|
-
const
|
|
3063
|
+
const g = l.version + 1;
|
|
3060
3064
|
l.close();
|
|
3061
|
-
const
|
|
3062
|
-
let
|
|
3063
|
-
|
|
3065
|
+
const p = await i(l.name, g, (y, L) => {
|
|
3066
|
+
let U;
|
|
3067
|
+
y.objectStoreNames.contains(h) ? U = L.objectStore(h) : U = y.createObjectStore(h, {
|
|
3064
3068
|
keyPath: d?.keyPath ?? void 0,
|
|
3065
3069
|
autoIncrement: !!d?.autoIncrement
|
|
3066
3070
|
});
|
|
3067
|
-
for (const
|
|
3068
|
-
|
|
3071
|
+
for (const C of f)
|
|
3072
|
+
U.indexNames.contains(C.name) || U.createIndex(C.name, C.keyPath, C.options);
|
|
3069
3073
|
});
|
|
3070
|
-
return
|
|
3074
|
+
return p.onversionchange = () => {
|
|
3071
3075
|
try {
|
|
3072
|
-
|
|
3076
|
+
p.close();
|
|
3073
3077
|
} finally {
|
|
3074
|
-
|
|
3078
|
+
r.cache.delete(p.name);
|
|
3075
3079
|
}
|
|
3076
|
-
},
|
|
3080
|
+
}, p;
|
|
3077
3081
|
}
|
|
3078
3082
|
async function n(l, h, d) {
|
|
3079
|
-
let u =
|
|
3080
|
-
return u ? (u = u.then((f) =>
|
|
3083
|
+
let u = r.cache.get(l);
|
|
3084
|
+
return u ? (u = u.then((f) => s(f, h, d)), r.cache.set(l, u)) : (u = (async () => {
|
|
3081
3085
|
const f = await i(l);
|
|
3082
|
-
return
|
|
3083
|
-
})(),
|
|
3086
|
+
return s(f, h, d);
|
|
3087
|
+
})(), r.cache.set(l, u)), u;
|
|
3084
3088
|
}
|
|
3085
|
-
|
|
3089
|
+
r.getDB = n;
|
|
3086
3090
|
async function o(l) {
|
|
3087
|
-
const h =
|
|
3088
|
-
if (
|
|
3091
|
+
const h = r.cache.get(l);
|
|
3092
|
+
if (r.cache.delete(l), h)
|
|
3089
3093
|
try {
|
|
3090
3094
|
(await h).close();
|
|
3091
3095
|
} catch {
|
|
3092
3096
|
}
|
|
3093
3097
|
}
|
|
3094
|
-
|
|
3098
|
+
r.closeConnection = o;
|
|
3095
3099
|
function a(l) {
|
|
3096
3100
|
return new Promise((h, d) => {
|
|
3097
3101
|
l.onsuccess = () => h(l.result), l.onerror = () => d(l.error);
|
|
3098
3102
|
});
|
|
3099
3103
|
}
|
|
3100
|
-
|
|
3104
|
+
r.asyncRequest = a;
|
|
3101
3105
|
function c(l) {
|
|
3102
3106
|
return new Promise((h, d) => {
|
|
3103
3107
|
l.oncomplete = () => h(), l.onabort = () => d(l.error ?? new DOMException("Aborted", "AbortError")), l.onerror = () => d(l.error ?? new DOMException("TransactionError", "UnknownError"));
|
|
3104
3108
|
});
|
|
3105
3109
|
}
|
|
3106
|
-
|
|
3107
|
-
})(
|
|
3108
|
-
class
|
|
3110
|
+
r.waitTx = c;
|
|
3111
|
+
})(b || (b = {}));
|
|
3112
|
+
class zi {
|
|
3109
3113
|
constructor(e, t, i = {}) {
|
|
3110
3114
|
this.dbName = e, this.storeName = t, this.options = i;
|
|
3111
3115
|
}
|
|
3112
3116
|
get _iterBatch() {
|
|
3113
|
-
return this.options.iterBatch ??
|
|
3117
|
+
return this.options.iterBatch ?? b.defaults.iterBatch;
|
|
3114
3118
|
}
|
|
3115
3119
|
get _retryCfg() {
|
|
3116
|
-
const e = this.options.retry ??
|
|
3120
|
+
const e = this.options.retry ?? b.defaults.retry;
|
|
3117
3121
|
return { attempts: e.attempts ?? 3, baseDelayMs: e.baseDelayMs ?? 16 };
|
|
3118
3122
|
}
|
|
3119
3123
|
async _withStore(e, t) {
|
|
3120
3124
|
const i = this._retryCfg;
|
|
3121
|
-
return
|
|
3125
|
+
return b.withRetry(
|
|
3122
3126
|
i,
|
|
3123
3127
|
async () => {
|
|
3124
|
-
const
|
|
3128
|
+
const s = await b.getDB(this.dbName, this.storeName, this.options.ensure);
|
|
3125
3129
|
try {
|
|
3126
|
-
const n =
|
|
3127
|
-
return await
|
|
3130
|
+
const n = s.transaction(this.storeName, e), o = n.objectStore(this.storeName), a = await t(o);
|
|
3131
|
+
return await b.waitTx(n), a;
|
|
3128
3132
|
} catch (n) {
|
|
3129
3133
|
throw n;
|
|
3130
3134
|
}
|
|
3131
3135
|
},
|
|
3132
|
-
async (
|
|
3133
|
-
|
|
3136
|
+
async (s) => {
|
|
3137
|
+
b.shouldReconnect(s) && await b.closeConnection(this.dbName);
|
|
3134
3138
|
}
|
|
3135
3139
|
);
|
|
3136
3140
|
}
|
|
3137
3141
|
async get(e) {
|
|
3138
3142
|
return this._withStore("readonly", async (t) => {
|
|
3139
|
-
const i = await
|
|
3143
|
+
const i = await b.asyncRequest(t.get(e));
|
|
3140
3144
|
return i === void 0 ? void 0 : i;
|
|
3141
3145
|
});
|
|
3142
3146
|
}
|
|
3143
3147
|
async set(e, t) {
|
|
3144
3148
|
return await this._withStore("readwrite", async (i) => {
|
|
3145
|
-
const
|
|
3146
|
-
await
|
|
3149
|
+
const s = this.options.ensure?.keyPath != null ? i.put(t) : i.put(t, e);
|
|
3150
|
+
await b.asyncRequest(s);
|
|
3147
3151
|
}), this;
|
|
3148
3152
|
}
|
|
3149
3153
|
async delete(e) {
|
|
3150
3154
|
return this._withStore("readwrite", async (t) => {
|
|
3151
|
-
const i = await
|
|
3152
|
-
return await
|
|
3155
|
+
const i = await b.asyncRequest(t.get(e)) !== void 0;
|
|
3156
|
+
return await b.asyncRequest(t.delete(e)), i;
|
|
3153
3157
|
});
|
|
3154
3158
|
}
|
|
3155
3159
|
async clear() {
|
|
3156
3160
|
await this._withStore("readwrite", async (e) => {
|
|
3157
|
-
await
|
|
3161
|
+
await b.asyncRequest(e.clear());
|
|
3158
3162
|
});
|
|
3159
3163
|
}
|
|
3160
3164
|
async has(e) {
|
|
3161
3165
|
return await this.get(e) !== void 0;
|
|
3162
3166
|
}
|
|
3163
3167
|
async count() {
|
|
3164
|
-
return this._withStore("readonly", async (e) => await
|
|
3168
|
+
return this._withStore("readonly", async (e) => await b.asyncRequest(e.count()) ?? 0);
|
|
3165
3169
|
}
|
|
3166
3170
|
async *_iterateEntries() {
|
|
3167
3171
|
let e = null, t = !1;
|
|
3168
3172
|
const i = Math.max(1, this._iterBatch);
|
|
3169
3173
|
for (; !t; ) {
|
|
3170
|
-
const
|
|
3174
|
+
const s = await this._withStore("readonly", async (n) => {
|
|
3171
3175
|
const o = [], a = e === null ? void 0 : IDBKeyRange.lowerBound(e, !0);
|
|
3172
3176
|
return await new Promise((c, l) => {
|
|
3173
3177
|
const h = n.openCursor(a);
|
|
@@ -3181,8 +3185,8 @@ class Oi {
|
|
|
3181
3185
|
};
|
|
3182
3186
|
}), o;
|
|
3183
3187
|
});
|
|
3184
|
-
for (const n of
|
|
3185
|
-
if (
|
|
3188
|
+
for (const n of s) yield n;
|
|
3189
|
+
if (s.length === 0) break;
|
|
3186
3190
|
}
|
|
3187
3191
|
}
|
|
3188
3192
|
entries() {
|
|
@@ -3206,9 +3210,9 @@ class Oi {
|
|
|
3206
3210
|
for await (const i of e) t.set(i, void 0);
|
|
3207
3211
|
return await this._withStore("readonly", async (i) => {
|
|
3208
3212
|
await Promise.all(
|
|
3209
|
-
t.keys().map(async (
|
|
3210
|
-
const n = await
|
|
3211
|
-
t.set(
|
|
3213
|
+
t.keys().map(async (s) => {
|
|
3214
|
+
const n = await b.asyncRequest(i.get(s));
|
|
3215
|
+
t.set(s, n === void 0 ? void 0 : n);
|
|
3212
3216
|
})
|
|
3213
3217
|
);
|
|
3214
3218
|
}), t;
|
|
@@ -3216,45 +3220,45 @@ class Oi {
|
|
|
3216
3220
|
async setMany(e) {
|
|
3217
3221
|
const t = this.options.ensure?.keyPath != null;
|
|
3218
3222
|
return await this._withStore("readwrite", async (i) => {
|
|
3219
|
-
for await (const [
|
|
3220
|
-
const o = t ? i.put(n) : i.put(n,
|
|
3221
|
-
await
|
|
3223
|
+
for await (const [s, n] of e) {
|
|
3224
|
+
const o = t ? i.put(n) : i.put(n, s);
|
|
3225
|
+
await b.asyncRequest(o);
|
|
3222
3226
|
}
|
|
3223
3227
|
}), this;
|
|
3224
3228
|
}
|
|
3225
3229
|
async deleteMany(e) {
|
|
3226
3230
|
let t = 0;
|
|
3227
3231
|
return await this._withStore("readwrite", async (i) => {
|
|
3228
|
-
for await (const
|
|
3229
|
-
await
|
|
3232
|
+
for await (const s of e)
|
|
3233
|
+
await b.asyncRequest(i.get(s)) !== void 0 && t++, await b.asyncRequest(i.delete(s));
|
|
3230
3234
|
}), t;
|
|
3231
3235
|
}
|
|
3232
3236
|
async disconnect() {
|
|
3233
|
-
await
|
|
3237
|
+
await b.closeConnection(this.dbName);
|
|
3234
3238
|
}
|
|
3235
3239
|
}
|
|
3236
|
-
class
|
|
3237
|
-
constructor(e, t, i = 1 / 0,
|
|
3238
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
3240
|
+
class Gi {
|
|
3241
|
+
constructor(e, t, i = 1 / 0, s) {
|
|
3242
|
+
this.dbName = e, this.storeName = t, this.ttl = i, this.version = s, this.db = new zi(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(() => {
|
|
3239
3243
|
});
|
|
3240
3244
|
}
|
|
3241
3245
|
async _clearExpiredEntries() {
|
|
3242
3246
|
if (this.ttl === 1 / 0) return;
|
|
3243
3247
|
const e = Date.now(), t = [];
|
|
3244
|
-
for await (const [i,
|
|
3245
|
-
typeof
|
|
3248
|
+
for await (const [i, s] of this.db.entries())
|
|
3249
|
+
typeof s.time == "number" && e - s.time > this.ttl && t.push(i);
|
|
3246
3250
|
t.length > 0 && await this.db.deleteMany(t);
|
|
3247
3251
|
}
|
|
3248
3252
|
async get(e, t = this.ttl, i) {
|
|
3249
|
-
const
|
|
3250
|
-
if (!
|
|
3253
|
+
const s = await this.loadFromDB(e), n = this.checkIfExpired(s, t);
|
|
3254
|
+
if (!s || n) {
|
|
3251
3255
|
if (typeof i == "function") {
|
|
3252
3256
|
const o = await i();
|
|
3253
3257
|
return await this.set(e, o), o;
|
|
3254
3258
|
}
|
|
3255
3259
|
return null;
|
|
3256
3260
|
}
|
|
3257
|
-
return
|
|
3261
|
+
return s.value;
|
|
3258
3262
|
}
|
|
3259
3263
|
async set(e, t) {
|
|
3260
3264
|
const i = Date.now();
|
|
@@ -3269,8 +3273,8 @@ class xi {
|
|
|
3269
3273
|
};
|
|
3270
3274
|
return await this.db.set(c, h), h;
|
|
3271
3275
|
}
|
|
3272
|
-
const
|
|
3273
|
-
for (const [c, l] of Object.entries(
|
|
3276
|
+
const s = e, n = [], o = [], a = {};
|
|
3277
|
+
for (const [c, l] of Object.entries(s))
|
|
3274
3278
|
if (l === null || typeof l > "u")
|
|
3275
3279
|
o.push(c);
|
|
3276
3280
|
else {
|
|
@@ -3280,8 +3284,8 @@ class xi {
|
|
|
3280
3284
|
return n.length > 0 && await this.db.setMany(n), o.length > 0 && await this.db.deleteMany(o), a;
|
|
3281
3285
|
}
|
|
3282
3286
|
async has(e, t = this.ttl) {
|
|
3283
|
-
const i = await this.loadFromDB(e),
|
|
3284
|
-
return i !== null && !
|
|
3287
|
+
const i = await this.loadFromDB(e), s = this.checkIfExpired(i, t);
|
|
3288
|
+
return i !== null && !s;
|
|
3285
3289
|
}
|
|
3286
3290
|
async delete(e) {
|
|
3287
3291
|
await this.db.delete(e);
|
|
@@ -3301,7 +3305,7 @@ class xi {
|
|
|
3301
3305
|
}
|
|
3302
3306
|
return null;
|
|
3303
3307
|
}
|
|
3304
|
-
if (typeof this.version
|
|
3308
|
+
if (typeof this.version < "u" && typeof this.version < "u" && t.version !== this.version) {
|
|
3305
3309
|
try {
|
|
3306
3310
|
await this.delete(e);
|
|
3307
3311
|
} catch {
|
|
@@ -3321,27 +3325,27 @@ class xi {
|
|
|
3321
3325
|
return await this.db.clear(), this;
|
|
3322
3326
|
}
|
|
3323
3327
|
}
|
|
3324
|
-
class
|
|
3328
|
+
class Yi extends I {
|
|
3325
3329
|
constructor(e, t) {
|
|
3326
3330
|
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");
|
|
3327
3331
|
}
|
|
3328
|
-
createDatabase(e, t, i,
|
|
3332
|
+
createDatabase(e, t, i, s = "indexedDB") {
|
|
3329
3333
|
const n = "indexedDB" in window && window.indexedDB !== null;
|
|
3330
|
-
switch (
|
|
3334
|
+
switch (s === "indexedDB" && !n && (s = "localStorage"), s) {
|
|
3331
3335
|
case "indexedDB":
|
|
3332
|
-
return new
|
|
3336
|
+
return new Gi(this.config.dbName, e, t, i);
|
|
3333
3337
|
case "localStorage":
|
|
3334
3338
|
case "sessionStorage":
|
|
3335
3339
|
case "memory":
|
|
3336
|
-
return new
|
|
3340
|
+
return new Wi(this.config.dbName, e, t, i, s);
|
|
3337
3341
|
default:
|
|
3338
|
-
throw new Error(`Unsupported storage engine: ${
|
|
3342
|
+
throw new Error(`Unsupported storage engine: ${s}`);
|
|
3339
3343
|
}
|
|
3340
3344
|
}
|
|
3341
3345
|
}
|
|
3342
|
-
class
|
|
3346
|
+
class Xi extends I {
|
|
3343
3347
|
constructor(e) {
|
|
3344
|
-
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage =
|
|
3348
|
+
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage = Rt(this.ctx.api);
|
|
3345
3349
|
}
|
|
3346
3350
|
static {
|
|
3347
3351
|
this.inject = ["api"];
|
|
@@ -3349,8 +3353,8 @@ class Pi extends I {
|
|
|
3349
3353
|
async createInstance(e, t = !1) {
|
|
3350
3354
|
return await this.WikiPage.newFromApi(e);
|
|
3351
3355
|
}
|
|
3352
|
-
async newFromTitle(e, t = !1, i,
|
|
3353
|
-
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i },
|
|
3356
|
+
async newFromTitle(e, t = !1, i, s = !1) {
|
|
3357
|
+
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i }, s);
|
|
3354
3358
|
}
|
|
3355
3359
|
async newFromPageId(e, t, i = !1) {
|
|
3356
3360
|
return this.createInstance({ pageids: e, rvsection: t }, i);
|
|
@@ -3362,9 +3366,9 @@ class Pi extends I {
|
|
|
3362
3366
|
return this.WikiPage.newBlankPage(e);
|
|
3363
3367
|
}
|
|
3364
3368
|
}
|
|
3365
|
-
class
|
|
3369
|
+
class Ee extends I {
|
|
3366
3370
|
constructor(e) {
|
|
3367
|
-
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 =
|
|
3371
|
+
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 = xt(this.ctx.wiki.siteInfo);
|
|
3368
3372
|
}
|
|
3369
3373
|
static {
|
|
3370
3374
|
this.inject = ["wiki", "wikiPage"];
|
|
@@ -3380,15 +3384,15 @@ class ve extends I {
|
|
|
3380
3384
|
return t?.title ? t.title : t?.pageId ? this.newTitleFromPageId(t.pageId) : null;
|
|
3381
3385
|
}
|
|
3382
3386
|
async newTitleFromAnyId(e, t = !1) {
|
|
3383
|
-
const { title: i, pageId:
|
|
3387
|
+
const { title: i, pageId: s, revId: n } = e ?? {};
|
|
3384
3388
|
if (typeof i == "string")
|
|
3385
3389
|
return this.newTitle(i);
|
|
3386
3390
|
let o, a;
|
|
3387
|
-
if (n ? (o = parseInt(n.toString(), 10), a = "revid") :
|
|
3391
|
+
if (n ? (o = parseInt(n.toString(), 10), a = "revid") : s && (o = parseInt(s.toString(), 10), a = "pageid"), !o || !a || isNaN(o) || o <= 0)
|
|
3388
3392
|
throw new Error("Invalid id or kind", { cause: e });
|
|
3389
3393
|
if (!t && this._cachedTitles.has(`${a}:${o}`))
|
|
3390
3394
|
return await this._cachedTitles.get(`${a}:${o}`);
|
|
3391
|
-
const { promise: c, resolve: l, reject: h } =
|
|
3395
|
+
const { promise: c, resolve: l, reject: h } = je();
|
|
3392
3396
|
this._cachedTitles.set(`${a}:${o}`, c);
|
|
3393
3397
|
try {
|
|
3394
3398
|
const { wikiPage: d } = this.ctx;
|
|
@@ -3426,7 +3430,7 @@ class ve extends I {
|
|
|
3426
3430
|
const t = typeof e == "string" ? this.newTitle(e) : e;
|
|
3427
3431
|
if (!t || t.getNamespaceId() !== -1)
|
|
3428
3432
|
return null;
|
|
3429
|
-
let i,
|
|
3433
|
+
let i, s, n = "view";
|
|
3430
3434
|
const o = t.getMainDBKey().split("/").slice(1).join("/") || "";
|
|
3431
3435
|
if (t.isSpecial("edit") && o)
|
|
3432
3436
|
i = o, n = "edit";
|
|
@@ -3440,12 +3444,12 @@ class ve extends I {
|
|
|
3440
3444
|
else if (t.isSpecial("mytalk"))
|
|
3441
3445
|
i = t.newTitle(this.ctx.wiki.userInfo.name, 3).getPrefixedDBKey() + (o ? `/${o}` : "");
|
|
3442
3446
|
else if (t.isSpecial("newsection") && o)
|
|
3443
|
-
i = o,
|
|
3447
|
+
i = o, s = "new", n = "edit";
|
|
3444
3448
|
else
|
|
3445
3449
|
return null;
|
|
3446
3450
|
return {
|
|
3447
3451
|
title: new this.Title(i),
|
|
3448
|
-
section:
|
|
3452
|
+
section: s,
|
|
3449
3453
|
action: n
|
|
3450
3454
|
};
|
|
3451
3455
|
}
|
|
@@ -3458,15 +3462,15 @@ class ve extends I {
|
|
|
3458
3462
|
this.REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i;
|
|
3459
3463
|
}
|
|
3460
3464
|
validateHrefAttr(e) {
|
|
3461
|
-
return typeof e != "string" ? !1 : !
|
|
3465
|
+
return typeof e != "string" ? !1 : !Ee.REG_SKIPPED_HREF.test(e);
|
|
3462
3466
|
}
|
|
3463
3467
|
parseWikiLink(e) {
|
|
3464
3468
|
if (!e || typeof e == "string" && !this.validateHrefAttr(e))
|
|
3465
3469
|
return null;
|
|
3466
|
-
const t =
|
|
3470
|
+
const t = at(e);
|
|
3467
3471
|
if (!this.isWikiLink(t.toString()))
|
|
3468
3472
|
return null;
|
|
3469
|
-
const i = t.searchParams,
|
|
3473
|
+
const i = t.searchParams, s = t.hash.replace("#", ""), n = i.get("action") || "view", o = i.get("title") || "", a = parseInt(i.get("curid") || "0", 10), c = parseInt(i.get("oldid") || "0", 10);
|
|
3470
3474
|
let l = o || (() => {
|
|
3471
3475
|
try {
|
|
3472
3476
|
return decodeURIComponent(t.pathname.substring(this.wikiArticlePath.length));
|
|
@@ -3492,29 +3496,25 @@ class ve extends I {
|
|
|
3492
3496
|
revId: u,
|
|
3493
3497
|
url: t,
|
|
3494
3498
|
params: i,
|
|
3495
|
-
hash:
|
|
3499
|
+
hash: s,
|
|
3496
3500
|
action: n
|
|
3497
3501
|
};
|
|
3498
3502
|
}
|
|
3499
3503
|
}
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
var Mi = Object.create, Se = Object.defineProperty, Ui = Object.getOwnPropertyDescriptor, nt = (s, e) => (e = Symbol[s]) ? e : Symbol.for("Symbol." + s), ot = (s) => {
|
|
3505
|
-
throw TypeError(s);
|
|
3506
|
-
}, Ni = (s, e, t) => e in s ? Se(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, Bi = (s, e) => Se(s, "name", { value: e, configurable: !0 }), ji = (s) => [, , , Mi(s?.[nt("metadata")] ?? null)], Fi = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], at = (s) => s !== void 0 && typeof s != "function" ? ot("Function expected") : s, Hi = (s, e, t, i, r) => ({ kind: Fi[s], name: e, metadata: i, addInitializer: (n) => t._ ? ot("Already initialized") : r.push(at(n || null)) }), qi = (s, e) => Ni(e, nt("metadata"), s[3]), Wi = (s, e, t, i) => {
|
|
3507
|
-
for (var r = 0, n = s[e >> 1], o = n && n.length; r < o; r++) n[r].call(t);
|
|
3504
|
+
var Qi = Object.create, ke = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, ft = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), gt = (r) => {
|
|
3505
|
+
throw TypeError(r);
|
|
3506
|
+
}, Zi = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Ji = (r, e) => ke(r, "name", { value: e, configurable: !0 }), es = (r) => [, , , Qi(r?.[ft("metadata")] ?? null)], ts = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], pt = (r) => r !== void 0 && typeof r != "function" ? gt("Function expected") : r, is = (r, e, t, i, s) => ({ kind: ts[r], name: e, metadata: i, addInitializer: (n) => t._ ? gt("Already initialized") : s.push(pt(n || null)) }), ss = (r, e) => Zi(e, ft("metadata"), r[3]), rs = (r, e, t, i) => {
|
|
3507
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
3508
3508
|
return i;
|
|
3509
|
-
},
|
|
3510
|
-
var o, a, c, l = e & 7, h = !1, d = 0, u =
|
|
3511
|
-
|
|
3512
|
-
for (var
|
|
3513
|
-
c =
|
|
3514
|
-
return
|
|
3515
|
-
},
|
|
3516
|
-
|
|
3517
|
-
class
|
|
3509
|
+
}, ns = (r, e, t, i, s, n) => {
|
|
3510
|
+
var o, a, c, l = e & 7, h = !1, d = 0, u = r[d] || (r[d] = []), f = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Vi(s, t));
|
|
3511
|
+
Ji(s, t);
|
|
3512
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
3513
|
+
c = is(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, pt(o) && (s = o);
|
|
3514
|
+
return ss(r, s), f && ke(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
3515
|
+
}, mt, $e, yt;
|
|
3516
|
+
mt = [ne(["storage", "wiki"])];
|
|
3517
|
+
class ie extends (yt = I) {
|
|
3518
3518
|
constructor(e) {
|
|
3519
3519
|
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);
|
|
3520
3520
|
try {
|
|
@@ -3526,27 +3526,16 @@ class ee extends (ct = I) {
|
|
|
3526
3526
|
return this.ctx.logger("PREFERENCES");
|
|
3527
3527
|
}
|
|
3528
3528
|
async start() {
|
|
3529
|
-
this.defineCategory({
|
|
3530
|
-
name: "general",
|
|
3531
|
-
label: "General",
|
|
3532
|
-
description: "General settings",
|
|
3533
|
-
autoGenerateForm: !0
|
|
3534
|
-
}), this.defineCategory({
|
|
3535
|
-
name: "editor",
|
|
3536
|
-
label: "Editor",
|
|
3537
|
-
description: "Settings related to editing content",
|
|
3538
|
-
autoGenerateForm: !0
|
|
3539
|
-
});
|
|
3540
3529
|
}
|
|
3541
3530
|
async get(e, t) {
|
|
3542
3531
|
if (!e)
|
|
3543
3532
|
return this.getAll();
|
|
3544
3533
|
t ??= () => {
|
|
3545
|
-
const
|
|
3546
|
-
return this.logger.debug(e, `(fallback value: ${
|
|
3534
|
+
const s = this.defaultOf(e);
|
|
3535
|
+
return this.logger.debug(e, `(fallback value: ${s})`), s;
|
|
3547
3536
|
};
|
|
3548
3537
|
const i = await this.db.get(e, void 0);
|
|
3549
|
-
return i !== null ? i : await
|
|
3538
|
+
return i !== null ? i : await Lt(t);
|
|
3550
3539
|
}
|
|
3551
3540
|
/**
|
|
3552
3541
|
* 获取全部注册的配置项以及最终生效的值
|
|
@@ -3563,8 +3552,8 @@ class ee extends (ct = I) {
|
|
|
3563
3552
|
}
|
|
3564
3553
|
async setMany(e) {
|
|
3565
3554
|
const t = this.loadDefaultConfigs(), i = {};
|
|
3566
|
-
for (const [
|
|
3567
|
-
n === t[
|
|
3555
|
+
for (const [s, n] of Object.entries(e))
|
|
3556
|
+
n === t[s] || n === void 0 ? i[s] = void 0 : i[s] = n;
|
|
3568
3557
|
return await this.db.set(i), this.ctx.emit("preferences/changed", { ctx: this.ctx, input: e, changes: i }), i;
|
|
3569
3558
|
}
|
|
3570
3559
|
defaultOf(e) {
|
|
@@ -3579,9 +3568,9 @@ class ee extends (ct = I) {
|
|
|
3579
3568
|
async getExportableRecord(e) {
|
|
3580
3569
|
e ??= await this.getAll();
|
|
3581
3570
|
const t = this.loadDefaultConfigs(), i = {};
|
|
3582
|
-
return Object.entries(t).sort(([
|
|
3583
|
-
const o = e[
|
|
3584
|
-
o !== void 0 && o !== n && (i[
|
|
3571
|
+
return Object.entries(t).sort(([s], [n]) => s.localeCompare(n)).forEach(([s, n]) => {
|
|
3572
|
+
const o = e[s];
|
|
3573
|
+
o !== void 0 && o !== n && (i[s] = o);
|
|
3585
3574
|
}), i;
|
|
3586
3575
|
}
|
|
3587
3576
|
loadDefaultConfigs() {
|
|
@@ -3589,8 +3578,8 @@ class ee extends (ct = I) {
|
|
|
3589
3578
|
return this.getConfigRegistries().forEach((t) => {
|
|
3590
3579
|
try {
|
|
3591
3580
|
const i = t.schema({});
|
|
3592
|
-
Object.entries(i).forEach(([
|
|
3593
|
-
e[
|
|
3581
|
+
Object.entries(i).forEach(([s, n]) => {
|
|
3582
|
+
e[s] = n;
|
|
3594
3583
|
});
|
|
3595
3584
|
} catch {
|
|
3596
3585
|
}
|
|
@@ -3599,16 +3588,17 @@ class ee extends (ct = I) {
|
|
|
3599
3588
|
}), e;
|
|
3600
3589
|
}
|
|
3601
3590
|
registerCustomConfig(e, t, i) {
|
|
3602
|
-
|
|
3591
|
+
const s = {
|
|
3603
3592
|
name: e,
|
|
3604
3593
|
schema: t,
|
|
3605
3594
|
category: i || "general"
|
|
3606
|
-
}
|
|
3595
|
+
}, n = this.customRegistries.findIndex((o) => o.name === e);
|
|
3596
|
+
return n >= 0 ? this.customRegistries[n] = s : this.customRegistries.push(s), this;
|
|
3607
3597
|
}
|
|
3608
3598
|
getConfigRegistries(e) {
|
|
3609
3599
|
return Array.from(this.ctx.registry.entries()).map(([t]) => t === null ? {
|
|
3610
3600
|
name: "@root",
|
|
3611
|
-
schema:
|
|
3601
|
+
schema: re?.PreferencesSchema || null
|
|
3612
3602
|
} : {
|
|
3613
3603
|
name: t.name,
|
|
3614
3604
|
schema: t?.PreferencesSchema || null
|
|
@@ -3618,13 +3608,13 @@ class ee extends (ct = I) {
|
|
|
3618
3608
|
})).concat(this.customRegistries).filter((t) => !e || t.category === e);
|
|
3619
3609
|
}
|
|
3620
3610
|
getAllSchema() {
|
|
3621
|
-
return new
|
|
3622
|
-
|
|
3611
|
+
return new m(
|
|
3612
|
+
m.intersect(this.getConfigRegistries().map((e) => e.schema))
|
|
3623
3613
|
);
|
|
3624
3614
|
}
|
|
3625
3615
|
defineCategory(e) {
|
|
3626
3616
|
const t = this.categoryDefinitions.findIndex((i) => i.name === e.name);
|
|
3627
|
-
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((i,
|
|
3617
|
+
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((i, s) => (i.index ?? 0) - (s.index ?? 0)), this;
|
|
3628
3618
|
}
|
|
3629
3619
|
getConfigCategories() {
|
|
3630
3620
|
return this.categoryDefinitions;
|
|
@@ -3632,36 +3622,547 @@ class ee extends (ct = I) {
|
|
|
3632
3622
|
async _migrageFromLegacyMasterDB() {
|
|
3633
3623
|
const e = this.ctx.storage.createDatabase("preferences", 1 / 0);
|
|
3634
3624
|
let t = 0;
|
|
3635
|
-
for await (const [i,
|
|
3636
|
-
i !== "_touched" && (await this.db.set(i,
|
|
3625
|
+
for await (const [i, s] of e.entries())
|
|
3626
|
+
i !== "_touched" && (await this.db.set(i, s.value), t++);
|
|
3637
3627
|
return t && this.logger.info(`Migrated ${t} preferences from master DB`), await e.clear(), await e?.db?.disconnect?.(), t;
|
|
3638
3628
|
}
|
|
3639
3629
|
}
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3630
|
+
$e = es(yt);
|
|
3631
|
+
ie = ns($e, 0, "PreferencesService", mt, ie);
|
|
3632
|
+
rs($e, 1, ie);
|
|
3633
|
+
const wt = "", bt = "", os = /\\\{/g, as = /\\\}/g, ls = new RegExp(wt, "g"), cs = new RegExp(bt, "g");
|
|
3634
|
+
function Be(r) {
|
|
3635
|
+
const e = r ? { ...r } : void 0;
|
|
3636
|
+
return (i, ...s) => hs(e, i, ...s);
|
|
3637
|
+
}
|
|
3638
|
+
function hs(r, e, ...t) {
|
|
3639
|
+
if (!e) return "";
|
|
3640
|
+
let i = String(e).replace(os, wt).replace(as, bt), s = {}, n = [];
|
|
3641
|
+
t.length === 1 && Array.isArray(t[0]) ? n = t[0] : t.length === 1 && us(t[0]) ? s = t[0] : t.length > 0 && (n = t);
|
|
3642
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
3643
|
+
if (n && n.length)
|
|
3644
|
+
for (let a = 0; a < n.length; a++)
|
|
3645
|
+
o[`$${a + 1}`] = n[a];
|
|
3646
|
+
if (s && Object.keys(s).length)
|
|
3647
|
+
for (const a of Object.keys(s)) o[a] = s[a];
|
|
3648
|
+
if (r && Object.keys(r).length)
|
|
3649
|
+
for (const a of Object.keys(r))
|
|
3650
|
+
typeof o[a] > "u" && (o[a] = r[a]);
|
|
3651
|
+
return i = i.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g, (a, c) => {
|
|
3652
|
+
const l = String(c).trim();
|
|
3653
|
+
if (!l) return "";
|
|
3654
|
+
try {
|
|
3655
|
+
const h = ds(l, o);
|
|
3656
|
+
return h == null ? "" : String(h);
|
|
3657
|
+
} catch {
|
|
3658
|
+
return "";
|
|
3659
|
+
}
|
|
3660
|
+
}), i.replace(ls, "{").replace(cs, "}");
|
|
3661
|
+
}
|
|
3662
|
+
function us(r) {
|
|
3663
|
+
return typeof r == "object" && r !== null && r.constructor === Object;
|
|
3664
|
+
}
|
|
3665
|
+
const ds = fs();
|
|
3666
|
+
function fs() {
|
|
3667
|
+
const r = /* @__PURE__ */ new Set([
|
|
3668
|
+
"eval",
|
|
3669
|
+
"Object",
|
|
3670
|
+
"Array",
|
|
3671
|
+
"String",
|
|
3672
|
+
"Number",
|
|
3673
|
+
"Boolean",
|
|
3674
|
+
"Date",
|
|
3675
|
+
"Math",
|
|
3676
|
+
"JSON",
|
|
3677
|
+
"undefined",
|
|
3678
|
+
"null",
|
|
3679
|
+
"true",
|
|
3680
|
+
"false",
|
|
3681
|
+
"NaN",
|
|
3682
|
+
"Infinity",
|
|
3683
|
+
"isNaN",
|
|
3684
|
+
"isFinite",
|
|
3685
|
+
"parseInt",
|
|
3686
|
+
"parseFloat"
|
|
3687
|
+
]), e = new Function(
|
|
3688
|
+
"__expr__",
|
|
3689
|
+
"ctx",
|
|
3690
|
+
`
|
|
3691
|
+
try {
|
|
3692
|
+
with (ctx) {
|
|
3693
|
+
return (eval(__expr__));
|
|
3694
|
+
}
|
|
3695
|
+
} catch (e) {
|
|
3696
|
+
throw e;
|
|
3697
|
+
}
|
|
3698
|
+
`
|
|
3699
|
+
);
|
|
3700
|
+
return (t, i) => {
|
|
3701
|
+
const s = new Proxy(i, {
|
|
3702
|
+
has: (n, o) => typeof o == "symbol" ? o in n : !(typeof o == "string" && (r.has(o) || o === "__expr__")),
|
|
3703
|
+
get: (n, o) => {
|
|
3704
|
+
if (o in n)
|
|
3705
|
+
return n[o];
|
|
3706
|
+
}
|
|
3707
|
+
});
|
|
3708
|
+
return e(t, s);
|
|
3709
|
+
};
|
|
3710
|
+
}
|
|
3711
|
+
function O(r, e) {
|
|
3712
|
+
let t = r[0] ?? "";
|
|
3713
|
+
for (let i = 0; i < e.length; i++)
|
|
3714
|
+
t += String(e[i]) + (r[i + 1] ?? "");
|
|
3715
|
+
return t;
|
|
3716
|
+
}
|
|
3717
|
+
class gs {
|
|
3718
|
+
constructor(e, t) {
|
|
3719
|
+
this.languages = /* @__PURE__ */ new Map(), this.currentLanguage = "en", this.missingKeys = /* @__PURE__ */ new Map(), this.usedKeys = /* @__PURE__ */ new Set();
|
|
3720
|
+
const i = t?.language || "en";
|
|
3721
|
+
this.currentLanguage = i, this.interpolate = Be(t?.globals), e && Object.keys(e).length && this.setLanguageData(i, e);
|
|
3722
|
+
}
|
|
3723
|
+
setGlobals(e) {
|
|
3724
|
+
return this.interpolate = Be(e), this;
|
|
3725
|
+
}
|
|
3726
|
+
set(e, t) {
|
|
3727
|
+
const i = this.currentLanguage, s = this.ensureLanguageMap(i);
|
|
3728
|
+
if (typeof e == "string" && typeof t == "string")
|
|
3729
|
+
s.set(e, t);
|
|
3730
|
+
else if (typeof e == "object") {
|
|
3731
|
+
const n = this.toStringRecord(e);
|
|
3732
|
+
for (const [o, a] of Object.entries(n))
|
|
3733
|
+
s.set(o, a);
|
|
3734
|
+
}
|
|
3735
|
+
return this;
|
|
3736
|
+
}
|
|
3737
|
+
setLanguageData(e, t) {
|
|
3738
|
+
e = H(e).toLowerCase();
|
|
3739
|
+
const i = this.ensureLanguageMap(e), s = this.toStringRecord(t);
|
|
3740
|
+
for (const [n, o] of Object.entries(s))
|
|
3741
|
+
i.set(n, o);
|
|
3742
|
+
return this;
|
|
3743
|
+
}
|
|
3744
|
+
setLanguage(e) {
|
|
3745
|
+
return e = H(e).toLowerCase(), this.currentLanguage = e, this;
|
|
3746
|
+
}
|
|
3747
|
+
getLanguage() {
|
|
3748
|
+
return this.currentLanguage;
|
|
3749
|
+
}
|
|
3750
|
+
hasLanguage(e) {
|
|
3751
|
+
e = H(e).toLowerCase();
|
|
3752
|
+
const t = this.languages.get(e);
|
|
3753
|
+
return t && Object.keys(t).length > 0;
|
|
3754
|
+
}
|
|
3755
|
+
toStringRecord(e, t) {
|
|
3756
|
+
const i = {};
|
|
3757
|
+
for (const [s, n] of Object.entries(e)) {
|
|
3758
|
+
const o = t ? `${t}.${s}` : s;
|
|
3759
|
+
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
3760
|
+
const a = this.toStringRecord(n, o);
|
|
3761
|
+
for (const [c, l] of Object.entries(a))
|
|
3762
|
+
i[c] = String(l);
|
|
3763
|
+
} else
|
|
3764
|
+
i[o] = String(n);
|
|
3765
|
+
}
|
|
3766
|
+
return i;
|
|
3767
|
+
}
|
|
3768
|
+
has(e) {
|
|
3769
|
+
const t = this.resolveLanguageOrder(this.currentLanguage);
|
|
3770
|
+
for (const i of t)
|
|
3771
|
+
if (this.languages.get(i)?.has(e)) return !0;
|
|
3772
|
+
return !1;
|
|
3773
|
+
}
|
|
3774
|
+
get(e) {
|
|
3775
|
+
this.recordUsedKey(e);
|
|
3776
|
+
const t = this.resolveLanguageOrder(this.currentLanguage), i = [];
|
|
3777
|
+
for (const s of t) {
|
|
3778
|
+
const o = this.languages.get(s)?.get(e);
|
|
3779
|
+
if (typeof o < "u")
|
|
3780
|
+
return i.length && this.recordMissing(e, i), o;
|
|
3781
|
+
i.push(s);
|
|
3782
|
+
}
|
|
3783
|
+
i.length && this.recordMissing(e, i);
|
|
3784
|
+
}
|
|
3785
|
+
translate(e, ...t) {
|
|
3786
|
+
if (!e)
|
|
3787
|
+
return "";
|
|
3788
|
+
if (this.currentLanguage === "qqx")
|
|
3789
|
+
return `⧼${e}⧽`;
|
|
3790
|
+
const i = this.get(e);
|
|
3791
|
+
return typeof i > "u" ? this.interpolate(e, ...t) : this.interpolate(i, ...t);
|
|
3792
|
+
}
|
|
3793
|
+
$(...e) {
|
|
3794
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3795
|
+
const s = e[0], n = e.slice(1), o = O(s, n);
|
|
3796
|
+
return this.translate(o);
|
|
3797
|
+
}
|
|
3798
|
+
const i = e;
|
|
3799
|
+
return (s, ...n) => {
|
|
3800
|
+
const o = O(s, n);
|
|
3801
|
+
return this.translate(o, ...i);
|
|
3802
|
+
};
|
|
3803
|
+
}
|
|
3804
|
+
/**
|
|
3805
|
+
* [payload as template] Return the raw message without interpolation
|
|
3806
|
+
* @example
|
|
3807
|
+
* ```
|
|
3808
|
+
* i18n.rawMsg('Hello, {{ name }}')
|
|
3809
|
+
* // good: "你好,{{ name }}"
|
|
3810
|
+
* // missing: "Hello, {{ name }}"
|
|
3811
|
+
* ```
|
|
3812
|
+
*/
|
|
3813
|
+
translateRaw(e) {
|
|
3814
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? e : "";
|
|
3815
|
+
}
|
|
3816
|
+
$raw(...e) {
|
|
3817
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3818
|
+
const i = e[0], s = e.slice(1), n = O(i, s);
|
|
3819
|
+
return this.translateRaw(n);
|
|
3820
|
+
}
|
|
3821
|
+
return (i, ...s) => {
|
|
3822
|
+
const n = O(i, s);
|
|
3823
|
+
return this.translateRaw(n);
|
|
3824
|
+
};
|
|
3825
|
+
}
|
|
3826
|
+
message(e, ...t) {
|
|
3827
|
+
if (!e)
|
|
3828
|
+
return "";
|
|
3829
|
+
if (this.currentLanguage === "qqx")
|
|
3830
|
+
return `⧼${e}⧽`;
|
|
3831
|
+
const i = this.get(e);
|
|
3832
|
+
return typeof i > "u" ? `(${e})` : this.interpolate(i, ...t);
|
|
3833
|
+
}
|
|
3834
|
+
$$(...e) {
|
|
3835
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3836
|
+
const s = e[0], n = e.slice(1), o = O(s, n);
|
|
3837
|
+
return this.message(o);
|
|
3838
|
+
}
|
|
3839
|
+
const i = e;
|
|
3840
|
+
return (s, ...n) => {
|
|
3841
|
+
const o = O(s, n);
|
|
3842
|
+
return this.message(o, ...i);
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3845
|
+
/**
|
|
3846
|
+
* [payload as key] Return the raw message without interpolation
|
|
3847
|
+
* @example
|
|
3848
|
+
* ```
|
|
3849
|
+
* i18n.rawMsg('greeting')
|
|
3850
|
+
* // good: "你好,{{ name }}"
|
|
3851
|
+
* // missing: "(greeting)"
|
|
3852
|
+
* ```
|
|
3853
|
+
*/
|
|
3854
|
+
messageRaw(e) {
|
|
3855
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? `(${e})` : "";
|
|
3856
|
+
}
|
|
3857
|
+
$$raw(...e) {
|
|
3858
|
+
if (Array.isArray(e[0]) && e[0].raw) {
|
|
3859
|
+
const i = e[0], s = e.slice(1), n = O(i, s);
|
|
3860
|
+
return this.messageRaw(n);
|
|
3861
|
+
}
|
|
3862
|
+
return (i, ...s) => {
|
|
3863
|
+
const n = O(i, s);
|
|
3864
|
+
return this.messageRaw(n);
|
|
3865
|
+
};
|
|
3866
|
+
}
|
|
3867
|
+
getAvailableLanguages() {
|
|
3868
|
+
return Array.from(this.languages.keys());
|
|
3869
|
+
}
|
|
3870
|
+
ensureLanguageMap(e) {
|
|
3871
|
+
let t = this.languages.get(e);
|
|
3872
|
+
return t || (t = /* @__PURE__ */ new Map(), this.languages.set(e, t)), t;
|
|
3873
|
+
}
|
|
3874
|
+
resolveLanguageOrder(e) {
|
|
3875
|
+
const t = e;
|
|
3876
|
+
return t === "en" ? ["en"] : [t, "en"];
|
|
3877
|
+
}
|
|
3878
|
+
/**
|
|
3879
|
+
* 获取缺失键报告:
|
|
3880
|
+
* { foo: ['zh', 'zh-hans', 'en'] }
|
|
3881
|
+
*/
|
|
3882
|
+
getMissingReport() {
|
|
3883
|
+
return Object.fromEntries(this.missingKeys.entries());
|
|
3884
|
+
}
|
|
3885
|
+
/**
|
|
3886
|
+
* 清空缺失键记录
|
|
3887
|
+
*/
|
|
3888
|
+
clearMissingReport() {
|
|
3889
|
+
this.missingKeys.clear();
|
|
3890
|
+
}
|
|
3891
|
+
recordMissing(e, t) {
|
|
3892
|
+
if (!t.length) return;
|
|
3893
|
+
const i = this.missingKeys.get(e) || [];
|
|
3894
|
+
for (const s of t)
|
|
3895
|
+
i.includes(s) || i.push(s);
|
|
3896
|
+
this.missingKeys.set(e, i);
|
|
3897
|
+
}
|
|
3898
|
+
recordUsedKey(e) {
|
|
3899
|
+
this.usedKeys.add(e);
|
|
3900
|
+
}
|
|
3901
|
+
getUsedKeys() {
|
|
3902
|
+
return Array.from(this.usedKeys);
|
|
3903
|
+
}
|
|
3904
|
+
generateBlankKeyRecord() {
|
|
3905
|
+
const e = {};
|
|
3906
|
+
for (const t of this.getUsedKeys())
|
|
3907
|
+
e[t] = "";
|
|
3908
|
+
return e;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
var ps = Object.create, Re = Object.defineProperty, ms = Object.getOwnPropertyDescriptor, vt = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), _t = (r) => {
|
|
3912
|
+
throw TypeError(r);
|
|
3913
|
+
}, ys = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ws = (r, e) => Re(r, "name", { value: e, configurable: !0 }), bs = (r) => [, , , ps(r?.[vt("metadata")] ?? null)], vs = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], St = (r) => r !== void 0 && typeof r != "function" ? _t("Function expected") : r, _s = (r, e, t, i, s) => ({ kind: vs[r], name: e, metadata: i, addInitializer: (n) => t._ ? _t("Already initialized") : s.push(St(n || null)) }), Ss = (r, e) => ys(e, vt("metadata"), r[3]), Es = (r, e, t, i) => {
|
|
3914
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
3915
|
+
return i;
|
|
3916
|
+
}, ks = (r, e, t, i, s, n) => {
|
|
3917
|
+
var o, a, c, l = e & 7, h = !1, d = 0, u = r[d] || (r[d] = []), f = l && (s = s.prototype, l < 5 && (l > 3 || !h) && ms(s, t));
|
|
3918
|
+
ws(s, t);
|
|
3919
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
3920
|
+
c = _s(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, St(o) && (s = o);
|
|
3921
|
+
return Ss(r, s), f && Re(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
3922
|
+
}, Et, xe, kt;
|
|
3923
|
+
const Ne = new m(
|
|
3924
|
+
m.object({
|
|
3925
|
+
manifest_version: m.const(1).required(),
|
|
3926
|
+
base_language: m.string().required(),
|
|
3927
|
+
last_modified: m.string().required(),
|
|
3928
|
+
languages: m.dict(
|
|
3929
|
+
m.object({
|
|
3930
|
+
file: m.string().required(),
|
|
3931
|
+
fallback: m.string(),
|
|
3932
|
+
iso_name: m.string(),
|
|
3933
|
+
endonym: m.string(),
|
|
3934
|
+
data: m.transform(
|
|
3935
|
+
m.dict(m.any()).default({}),
|
|
3936
|
+
(r) => Object.keys(r).length > 0 ? r : void 0
|
|
3937
|
+
)
|
|
3938
|
+
})
|
|
3939
|
+
).required()
|
|
3940
|
+
})
|
|
3941
|
+
);
|
|
3942
|
+
Et = [ne(["wiki", "preferences"]), At(
|
|
3943
|
+
m.object({
|
|
3944
|
+
"i18n.index_url": m.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(
|
|
3945
|
+
qe.I18N_INDEX_URL
|
|
3946
|
+
)
|
|
3947
|
+
}).description("").extra("category", "general")
|
|
3948
|
+
)];
|
|
3949
|
+
class se extends (kt = I) {
|
|
3950
|
+
constructor(e) {
|
|
3951
|
+
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 gs(
|
|
3952
|
+
{},
|
|
3953
|
+
{
|
|
3954
|
+
language: "",
|
|
3955
|
+
globals: {
|
|
3956
|
+
getUrl: (...t) => e.wiki.getUrl(...t)
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
), this.i18nIndexDB = e.storage.createDatabase(
|
|
3960
|
+
"i18n-index",
|
|
3961
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
3962
|
+
// 3 days
|
|
3963
|
+
this.ctx.version,
|
|
3964
|
+
"indexedDB"
|
|
3965
|
+
), this.i18nDataDB = e.storage.createDatabase(
|
|
3966
|
+
"i18n-data",
|
|
3967
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
3968
|
+
// 3 days
|
|
3969
|
+
this.ctx.version,
|
|
3970
|
+
"indexedDB"
|
|
3971
|
+
), 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);
|
|
3972
|
+
}
|
|
3973
|
+
async start() {
|
|
3974
|
+
this.ctx.preferences.registerCustomConfig(
|
|
3975
|
+
"language",
|
|
3976
|
+
m.object({
|
|
3977
|
+
language: m.union([
|
|
3978
|
+
"@user",
|
|
3979
|
+
"@site",
|
|
3980
|
+
m.string().description("Custom language code")
|
|
3981
|
+
]).description("UI language").default("@user")
|
|
3982
|
+
}).description("UI language")
|
|
3983
|
+
), this.ctx.on("clear-cache", this.onClearCache.bind(this));
|
|
3984
|
+
const e = this._indexUrl = await this.ctx.preferences.get("i18n.index_url") || "";
|
|
3985
|
+
if (!e) {
|
|
3986
|
+
this.logger.error("I18n index URL is not set"), this.setupShortcuts();
|
|
3987
|
+
return;
|
|
3988
|
+
}
|
|
3989
|
+
let t = null;
|
|
3990
|
+
try {
|
|
3991
|
+
t = await this.getI18nIndex(e);
|
|
3992
|
+
} catch (n) {
|
|
3993
|
+
this.logger.error("Failed to fetch i18n index", n), this.setupShortcuts();
|
|
3994
|
+
return;
|
|
3995
|
+
}
|
|
3996
|
+
this._indexCache = t, Object.entries(t.languages).forEach(([n, o]) => {
|
|
3997
|
+
o.data && Object.keys(o.data).length > 0 && this.manager.setLanguageData(n, o.data);
|
|
3998
|
+
});
|
|
3999
|
+
const i = await this.ctx.preferences.get("language"), s = this.normalizeLanguageCode(i);
|
|
4000
|
+
this.logger.debug("Settings", { prefer: i, normalized: s });
|
|
4001
|
+
try {
|
|
4002
|
+
await this.switchLanguage(s), this.logger.info(`Initialized for language: ${this.language}`);
|
|
4003
|
+
} catch (n) {
|
|
4004
|
+
this.logger.error("Failed to fetch i18n index", n), this.manager.setLanguage("en");
|
|
4005
|
+
}
|
|
4006
|
+
this.ctx.preferences.registerCustomConfig(
|
|
4007
|
+
"language",
|
|
4008
|
+
m.object({
|
|
4009
|
+
language: m.union([
|
|
4010
|
+
m.const("@user").description(this.$`Same as your personal language`),
|
|
4011
|
+
m.const("@site").description(this.$`Same as the site language`),
|
|
4012
|
+
...this.getAvailableLanguageCodes().map(
|
|
4013
|
+
({ code: n, endonym: o, iso_name: a }) => m.const(n).description(o || a || n)
|
|
4014
|
+
)
|
|
4015
|
+
]).default("@user")
|
|
4016
|
+
}).description(this.$`InPageEdit UI language`)
|
|
4017
|
+
), this.setupShortcuts(), this.ctx.on("preferences/changed", async ({ changes: n }) => {
|
|
4018
|
+
if (!("language" in n)) return;
|
|
4019
|
+
const o = this.normalizeLanguageCode(await this.ctx.preferences.get("language"));
|
|
4020
|
+
o && o !== this.language && await this.switchLanguage(o);
|
|
4021
|
+
});
|
|
4022
|
+
}
|
|
4023
|
+
setupShortcuts() {
|
|
4024
|
+
if (!this.manager) throw new Error("I18nManager is not initialized");
|
|
4025
|
+
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));
|
|
4026
|
+
}
|
|
4027
|
+
normalizeLanguageCode(e) {
|
|
4028
|
+
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"), H(String(e)).toLowerCase());
|
|
4029
|
+
}
|
|
4030
|
+
get language() {
|
|
4031
|
+
return this.manager.getLanguage();
|
|
4032
|
+
}
|
|
4033
|
+
/**
|
|
4034
|
+
* 主动设置偏好值(会触发 preferences/changed,从而热切换)
|
|
4035
|
+
*/
|
|
4036
|
+
async setLanguagePreference(e) {
|
|
4037
|
+
await this.ctx.preferences.set("language", e);
|
|
4038
|
+
}
|
|
4039
|
+
/**
|
|
4040
|
+
* 直接切换到具体语言(不修改偏好值)
|
|
4041
|
+
*/
|
|
4042
|
+
async switchLanguage(e) {
|
|
4043
|
+
const t = this.normalizeLanguageCode(e);
|
|
4044
|
+
await this.ensureLanguageLoaded(t), this.manager.setLanguage(t), this.ctx.emit("i18n/changed", { ctx: this.ctx, language: t });
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* 为指定语言注册(或合并)消息。
|
|
4048
|
+
* - 推荐加命名空间避免冲突:{ myPlugin: { key: 'value' } }
|
|
4049
|
+
* - 若 language 为当前语言,将立即可用;必要时你可以手动触发 UI 刷新或监听 i18n/changed。
|
|
4050
|
+
*/
|
|
4051
|
+
async registerMessages(e, t, i) {
|
|
4052
|
+
const s = i?.namespace ? { [i.namespace]: t } : t;
|
|
4053
|
+
this.manager.setLanguageData(e, s), e === this.language && this.ctx.emit("i18n/changed", { ctx: this.ctx, language: this.language });
|
|
4054
|
+
}
|
|
4055
|
+
/**
|
|
4056
|
+
* 列出可用语言与文件(来源于 index.json)
|
|
4057
|
+
*/
|
|
4058
|
+
getAvailableLanguageCodes() {
|
|
4059
|
+
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
4060
|
+
return Object.entries(this._indexCache.languages).filter(([e, t]) => !t.fallback).reduce(
|
|
4061
|
+
(e, [t, i]) => (e.push({ code: t, ...i }), e),
|
|
4062
|
+
[]
|
|
4063
|
+
);
|
|
4064
|
+
}
|
|
4065
|
+
findLanguageMeta(e, t) {
|
|
4066
|
+
const i = H(String(t)).toLowerCase(), s = e.languages[i];
|
|
4067
|
+
if (s)
|
|
4068
|
+
return {
|
|
4069
|
+
code: i,
|
|
4070
|
+
...s
|
|
4071
|
+
};
|
|
4072
|
+
{
|
|
4073
|
+
const n = e.languages.en;
|
|
4074
|
+
if (n)
|
|
4075
|
+
return {
|
|
4076
|
+
code: "en",
|
|
4077
|
+
...n
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
async getI18nIndex(e, t = !1) {
|
|
4082
|
+
if (!t) {
|
|
4083
|
+
const s = await this.i18nIndexDB.get(e);
|
|
4084
|
+
if (s)
|
|
4085
|
+
try {
|
|
4086
|
+
return Ne(s);
|
|
4087
|
+
} catch (n) {
|
|
4088
|
+
this.logger.error("Failed to parse cached i18n index", n), this.i18nIndexDB.delete(e);
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
const i = await this.fetchI18nIndex(e);
|
|
4092
|
+
return this.i18nIndexDB.set(e, i), i;
|
|
4093
|
+
}
|
|
4094
|
+
async fetchI18nIndex(e) {
|
|
4095
|
+
const t = await fetch(e).then((i) => i.json());
|
|
4096
|
+
return Ne(t);
|
|
4097
|
+
}
|
|
4098
|
+
async ensureLanguageLoaded(e) {
|
|
4099
|
+
if (!this.manager || !this._indexCache) throw new Error("I18nManager is not initialized");
|
|
4100
|
+
if (this.manager.hasLanguage(e))
|
|
4101
|
+
return this.logger.debug("Language already loaded", e);
|
|
4102
|
+
const t = await this.getLanguageData(e);
|
|
4103
|
+
this.manager.setLanguageData(e, t), this.logger.debug("Language data ensured", e, t);
|
|
4104
|
+
}
|
|
4105
|
+
async getLanguageData(e, t = !1) {
|
|
4106
|
+
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
4107
|
+
const i = this.findLanguageMeta(this._indexCache, e);
|
|
4108
|
+
if (!i) return {};
|
|
4109
|
+
const s = `${this._indexUrl}#${i.file}`;
|
|
4110
|
+
if (!t) {
|
|
4111
|
+
const o = await this.i18nDataDB.get(s);
|
|
4112
|
+
if (o && Object.keys(o).length > 0)
|
|
4113
|
+
return this.logger.debug("Using cached language data", e, o), o;
|
|
4114
|
+
}
|
|
4115
|
+
const n = i.data || await fetch(new URL(i.file, this._indexUrl).toString()).then((o) => o.json());
|
|
4116
|
+
return this.i18nDataDB.set(s, n), this.logger.debug("Language data fetched", e, i.file, n), n;
|
|
4117
|
+
}
|
|
4118
|
+
/**
|
|
4119
|
+
* 获取缺失键报告,形如:
|
|
4120
|
+
* { foo: ['zh', 'zh-hans', 'en'] }
|
|
4121
|
+
*/
|
|
4122
|
+
getMissingReport() {
|
|
4123
|
+
return this.manager.getMissingReport();
|
|
4124
|
+
}
|
|
4125
|
+
/**
|
|
4126
|
+
* 清空缺失键记录
|
|
4127
|
+
*/
|
|
4128
|
+
clearMissingReport() {
|
|
4129
|
+
this.manager.clearMissingReport();
|
|
4130
|
+
}
|
|
4131
|
+
async onClearCache() {
|
|
4132
|
+
await this.i18nIndexDB.clear(), await this.i18nDataDB.clear();
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
xe = bs(kt);
|
|
4136
|
+
se = ks(xe, 0, "I18nService", Et, se);
|
|
4137
|
+
Es(xe, 1, se);
|
|
4138
|
+
class re extends Tt {
|
|
3644
4139
|
constructor(e) {
|
|
3645
4140
|
super({
|
|
3646
4141
|
name: "InPageEdit"
|
|
3647
|
-
}), this.version = "0.
|
|
4142
|
+
}), this.version = "0.14.1", this.Endpoints = qe, this.schema = m, this.config = K(re.DEFAULT_CONFIG, e), this.logger = Mt({
|
|
3648
4143
|
name: "IPE",
|
|
3649
4144
|
color: "#33aaff",
|
|
3650
4145
|
level: this.config.logLevel
|
|
3651
|
-
}), this.#e()
|
|
4146
|
+
}), this.#e();
|
|
3652
4147
|
}
|
|
3653
4148
|
static {
|
|
3654
4149
|
this.DEFAULT_CONFIG = {
|
|
3655
4150
|
apiConfigs: {},
|
|
3656
4151
|
legacyPreferences: {},
|
|
3657
|
-
logLevel:
|
|
4152
|
+
logLevel: Fe.info,
|
|
3658
4153
|
storageNamespace: "InPageEdit",
|
|
3659
4154
|
autoloadStyles: !0,
|
|
3660
4155
|
autoInstallCorePlugins: !0
|
|
3661
4156
|
};
|
|
3662
4157
|
}
|
|
3663
4158
|
async #e() {
|
|
3664
|
-
|
|
4159
|
+
await this.#i(), this.config.autoInstallCorePlugins && this.#s(), this.#r();
|
|
4160
|
+
}
|
|
4161
|
+
async #i() {
|
|
4162
|
+
this.plugin(se), this.plugin(Qt, this.config.apiConfigs), this.plugin(J), this.plugin(ai), this.plugin(Ii), this.plugin(ie), this.plugin(Yi, { dbName: this.config.storageNamespace }), this.plugin(te), this.plugin(Xi), this.plugin(Ee), this.#t([
|
|
4163
|
+
"i18n",
|
|
4164
|
+
"$",
|
|
4165
|
+
"$$",
|
|
3665
4166
|
"api",
|
|
3666
4167
|
"currentPage",
|
|
3667
4168
|
"resourceLoader",
|
|
@@ -3677,68 +4178,68 @@ class te extends ft {
|
|
|
3677
4178
|
"getMainpageUrl"
|
|
3678
4179
|
]);
|
|
3679
4180
|
}
|
|
3680
|
-
#
|
|
3681
|
-
if (
|
|
4181
|
+
#t(e) {
|
|
4182
|
+
if (!Array.isArray(e) || e.length === 0) return this;
|
|
3682
4183
|
for (const t of e) {
|
|
3683
|
-
const i = this[
|
|
4184
|
+
const i = this[re.internal][t];
|
|
3684
4185
|
i?.type === "service" && (i.builtin = !0);
|
|
3685
4186
|
}
|
|
3686
4187
|
return this;
|
|
3687
4188
|
}
|
|
3688
4189
|
// TODO: 这里不应该硬编码,暂时先这样
|
|
3689
|
-
async #
|
|
4190
|
+
async #s() {
|
|
3690
4191
|
[
|
|
3691
|
-
import("./index-
|
|
3692
|
-
import("./index-
|
|
4192
|
+
import("./index-Bb0FiU2c.js").then(({ PluginAnalytics: t }) => t),
|
|
4193
|
+
import("./index-BBNseJXG.js").then(
|
|
3693
4194
|
({ PluginInArticleLinks: t }) => t
|
|
3694
4195
|
),
|
|
3695
|
-
import("./index-
|
|
3696
|
-
import("./index-
|
|
4196
|
+
import("./index-DTHY5rAO.js").then(({ PluginPluginStore: t }) => t),
|
|
4197
|
+
import("./index-DELHsLHS.js").then(
|
|
3697
4198
|
({ PluginPreferencesUI: t }) => t
|
|
3698
4199
|
),
|
|
3699
|
-
import("./index-
|
|
3700
|
-
import("./index-
|
|
3701
|
-
import("./index-
|
|
4200
|
+
import("./index-DmLoihN1.js").then(({ PluginQuickEdit: t }) => t),
|
|
4201
|
+
import("./index-BrYKe18j.js").then(({ PluginQuickMove: t }) => t),
|
|
4202
|
+
import("./index-3NZkG2a3.js").then(
|
|
3702
4203
|
({ PluginQuickPreview: t }) => t
|
|
3703
4204
|
),
|
|
3704
|
-
import("./index-
|
|
3705
|
-
import("./index-
|
|
4205
|
+
import("./index-D97lUU3h.js").then(({ PluginQuickDiff: t }) => t),
|
|
4206
|
+
import("./index-D6zFqL2u.js").then(
|
|
3706
4207
|
({ PluginQuickRedirect: t }) => t
|
|
3707
4208
|
),
|
|
3708
|
-
import("./index-
|
|
4209
|
+
import("./index-D-fW3ESK.js").then(({ PluginToolbox: t }) => t)
|
|
3709
4210
|
].forEach(async (t) => {
|
|
3710
4211
|
this.plugin(await t);
|
|
3711
4212
|
});
|
|
3712
4213
|
}
|
|
3713
4214
|
// TODO: 应该抽象到 PluginTheme 中去,暂时先硬编码
|
|
3714
|
-
async #
|
|
4215
|
+
async #r() {
|
|
3715
4216
|
this.inject(["resourceLoader"], (e) => {
|
|
3716
4217
|
this.config.autoloadStyles && e.resourceLoader.loadStyle(import.meta.resolve("./style.css"));
|
|
3717
4218
|
});
|
|
3718
4219
|
}
|
|
3719
4220
|
async withInject(e) {
|
|
3720
|
-
const { promise: t, resolve: i } =
|
|
3721
|
-
return this.inject(e, (
|
|
3722
|
-
i(
|
|
4221
|
+
const { promise: t, resolve: i } = je();
|
|
4222
|
+
return this.inject(e, (s) => {
|
|
4223
|
+
i(s);
|
|
3723
4224
|
}), t;
|
|
3724
4225
|
}
|
|
3725
4226
|
}
|
|
3726
4227
|
export {
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
b,
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
4228
|
+
Fe as $,
|
|
4229
|
+
Qt as A,
|
|
4230
|
+
J as C,
|
|
4231
|
+
re as I,
|
|
4232
|
+
Ii as M,
|
|
4233
|
+
ee as N,
|
|
4234
|
+
ve as P,
|
|
4235
|
+
ai as R,
|
|
4236
|
+
Mt as S,
|
|
4237
|
+
te as W,
|
|
4238
|
+
Yi as a,
|
|
4239
|
+
v as b,
|
|
4240
|
+
ie as c,
|
|
4241
|
+
Xi as d,
|
|
4242
|
+
Ee as e,
|
|
4243
|
+
It as m
|
|
3743
4244
|
};
|
|
3744
|
-
//# sourceMappingURL=index-
|
|
4245
|
+
//# sourceMappingURL=index-BgkZW91u.js.map
|