@inpageedit/core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/dist/{BasePlugin-Bf2UuIHF.js → BasePlugin-CU8beLYu.js} +17 -26
- package/dist/BasePlugin-CU8beLYu.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-B-gPsC2n.js} +124 -128
- package/dist/PluginPrefSync-B-gPsC2n.js.map +1 -0
- package/dist/PluginStoreApp-CDteVCBG.js +453 -0
- package/dist/PluginStoreApp-CDteVCBG.js.map +1 -0
- package/dist/{endpoints-DgyuoRZd.js → Preferences-85Q9FAmb.js} +589 -565
- package/dist/Preferences-85Q9FAmb.js.map +1 -0
- package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/{index-BuYNq7f3.js → index-19CgGBI0.js} +1419 -921
- package/dist/index-19CgGBI0.js.map +1 -0
- package/dist/{index-B7c6jL9x.js → index-BKIf3i0I.js} +146 -137
- package/dist/index-BKIf3i0I.js.map +1 -0
- package/dist/{index-CCRMmnwk.js → index-BrtFJ-M0.js} +67 -66
- package/dist/index-BrtFJ-M0.js.map +1 -0
- package/dist/index-CG38LlAh.js.map +1 -1
- package/dist/index-CM_6yF2v.js.map +1 -1
- package/dist/index-CQr1DJ8n.js +173 -0
- package/dist/index-CQr1DJ8n.js.map +1 -0
- package/dist/{index-BQ-cHWkJ.js → index-CVTBg5O9.js} +66 -48
- package/dist/index-CVTBg5O9.js.map +1 -0
- package/dist/index-Ci82vLXg.js +179 -0
- package/dist/index-Ci82vLXg.js.map +1 -0
- package/dist/{index-BwdWyHLe.js → index-D3iZhRMJ.js} +93 -93
- package/dist/index-D3iZhRMJ.js.map +1 -0
- package/dist/index-DD5CVCfD.js.map +1 -1
- package/dist/{index-BJ7_Q1mB.js → index-DGtq21uW.js} +17 -16
- package/dist/index-DGtq21uW.js.map +1 -0
- package/dist/index-DXL7teb0.js +394 -0
- package/dist/index-DXL7teb0.js.map +1 -0
- package/dist/index-DjPpAyfE.js +116 -0
- package/dist/index-DjPpAyfE.js.map +1 -0
- package/dist/{index-eSlbrNqF.js → index-rpiO9fpc.js} +4 -5
- package/dist/{index-eSlbrNqF.js.map → index-rpiO9fpc.js.map} +1 -1
- package/dist/index.d.ts +327 -26
- 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-BuYNq7f3.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
|
@@ -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, p as H, R as Lt, E as Fe, g as At } from "./Preferences-85Q9FAmb.js";
|
|
3
|
+
import { j as k, P as Tt } from "./index-CM_6yF2v.js";
|
|
4
|
+
var qe = /* @__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))(qe || {});
|
|
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 Ct = 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 Pt(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 = It[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
|
+
Oe
|
|
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;`, Oe);
|
|
134
134
|
}
|
|
135
135
|
return [i, t];
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
const
|
|
139
|
-
},
|
|
138
|
+
const Te = () => {
|
|
139
|
+
}, Oe = "color:inherit; background:transparent; text-decoration:none;", It = {
|
|
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 Pt(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 Dt(r) {
|
|
166
|
+
return new Ct(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
|
+
}, Mt = 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 Ut(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 = Bt(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 = jt(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 Bt(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 jt(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) && !qt(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, Ht(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 qt(r) {
|
|
275
|
+
return r >= 57344 && r <= 63743 || r >= 983040 && r <= 1048573 || r >= 1048576 && r <= 1114109;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function Ht(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 F = 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 Ce(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/") || !Ut(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 F(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 F(r, a);
|
|
351
351
|
} else {
|
|
352
352
|
if (e === "stream")
|
|
353
|
-
return new
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
return new F(
|
|
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 F(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 Mt(
|
|
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 F(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 Ce(
|
|
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 Ce(
|
|
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 Kt = de.create, Ie = Kt();
|
|
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 B = 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 = B.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 (B.is(n))
|
|
1035
1035
|
return n.isBadTokenError();
|
|
1036
1036
|
{
|
|
1037
1037
|
const o = i(n);
|
|
1038
|
-
return new
|
|
1038
|
+
return new B(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
|
+
}, Wt = (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
|
+
}, zt = () => {
|
|
1113
|
+
}, Gt = async (r, e) => {
|
|
1114
1114
|
let t = 0;
|
|
1115
|
-
const { retry: i = 3, onRetry:
|
|
1115
|
+
const { retry: i = 3, onRetry: s = zt, 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 q = 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 = Wt(
|
|
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 B(
|
|
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 B(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 Gt(
|
|
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 || B.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
|
+
q.INIT_DEFAULT_PARAMS = {
|
|
1286
1286
|
action: "query",
|
|
1287
1287
|
errorformat: "plaintext",
|
|
1288
1288
|
format: "json",
|
|
1289
1289
|
formatversion: 2
|
|
1290
|
-
},
|
|
1290
|
+
}, q.DEFAULT_CONFIGS = {
|
|
1291
1291
|
baseURL: void 0,
|
|
1292
1292
|
fexiosConfigs: {
|
|
1293
1293
|
responseType: "json"
|
|
1294
1294
|
},
|
|
1295
|
-
defaultParams:
|
|
1295
|
+
defaultParams: q.INIT_DEFAULT_PARAMS,
|
|
1296
1296
|
throwOnApiError: !1
|
|
1297
|
-
},
|
|
1298
|
-
let
|
|
1299
|
-
let
|
|
1297
|
+
}, q.createRequestHandler = Ye;
|
|
1298
|
+
let Xe = q;
|
|
1299
|
+
let Yt = 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 Xt {
|
|
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 Yt({
|
|
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 Qt = Object.create, me = Object.defineProperty, Vt = Object.getOwnPropertyDescriptor, Qe = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), Ve = (r) => {
|
|
1341
|
+
throw TypeError(r);
|
|
1342
|
+
}, Zt = (r, e, t) => e in r ? me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Jt = (r, e) => me(r, "name", { value: e, configurable: !0 }), ei = (r) => [, , , Qt(r?.[Qe("metadata")] ?? null)], ti = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ze = (r) => r !== void 0 && typeof r != "function" ? Ve("Function expected") : r, ii = (r, e, t, i, s) => ({ kind: ti[r], name: e, metadata: i, addInitializer: (n) => t._ ? Ve("Already initialized") : s.push(Ze(n || null)) }), si = (r, e) => Zt(e, Qe("metadata"), r[3]), ri = (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
|
+
}, ni = (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) && Vt(s, t));
|
|
1347
|
+
Jt(s, t);
|
|
1348
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
1349
|
+
c = ii(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, Ze(o) && (s = o);
|
|
1350
|
+
return si(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 = ei(et);
|
|
1411
|
+
J = ni(ye, 0, "CurrentPageService", Je, J);
|
|
1412
|
+
ri(ye, 1, J);
|
|
1413
|
+
class oi 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 ai(r) {
|
|
1464
|
+
return typeof r == "boolean";
|
|
1465
1465
|
}
|
|
1466
|
-
function
|
|
1467
|
-
return
|
|
1466
|
+
function li(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 ci(r) {
|
|
1482
|
+
return !!(r && r.isComponent);
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1484
|
+
function hi(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 ui(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 di(r, e) {
|
|
1541
|
+
return r + e.charAt(0).toUpperCase() + e.substring(1);
|
|
1542
1542
|
}
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1543
|
+
const fi = ["Webkit", "ms", "Moz", "O"];
|
|
1544
|
+
oe(ge).forEach((r) => {
|
|
1545
|
+
fi.forEach((e) => {
|
|
1546
|
+
ge[di(e, r)] = 0;
|
|
1547
1547
|
});
|
|
1548
1548
|
});
|
|
1549
|
-
const
|
|
1550
|
-
var
|
|
1551
|
-
return
|
|
1552
|
-
})(
|
|
1553
|
-
function
|
|
1554
|
-
return
|
|
1549
|
+
const gi = Symbol.for("jsx-dom:type");
|
|
1550
|
+
var it = /* @__PURE__ */ (function(r) {
|
|
1551
|
+
return r.ShadowRoot = "ShadowRoot", r;
|
|
1552
|
+
})(it || {});
|
|
1553
|
+
function pi(r) {
|
|
1554
|
+
return r != null && r[gi] === it.ShadowRoot;
|
|
1555
1555
|
}
|
|
1556
|
-
const
|
|
1557
|
-
function
|
|
1558
|
-
return !
|
|
1556
|
+
const mi = "http://www.w3.org/2000/svg", yi = "http://www.w3.org/1999/xlink", wi = "http://www.w3.org/XML/1998/namespace";
|
|
1557
|
+
function st(r) {
|
|
1558
|
+
return !ai(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 bi = {
|
|
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
|
+
}, vi = /^(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 _i(r) {
|
|
1620
1620
|
const e = document.createDocumentFragment();
|
|
1621
|
-
return
|
|
1621
|
+
return ae(r.children, e), e;
|
|
1622
1622
|
}
|
|
1623
|
-
function
|
|
1623
|
+
function Si(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 && bi[r] === 0 && (i = {
|
|
1634
1634
|
...i,
|
|
1635
|
-
namespaceURI:
|
|
1635
|
+
namespaceURI: mi
|
|
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), $i(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 = ci(r) ? Si(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
1659
|
}
|
|
1660
|
-
function
|
|
1661
|
-
|
|
1662
|
-
}
|
|
1663
|
-
function
|
|
1664
|
-
if (
|
|
1665
|
-
|
|
1666
|
-
else if (
|
|
1667
|
-
|
|
1668
|
-
else if (
|
|
1669
|
-
|
|
1670
|
-
else if (
|
|
1671
|
-
|
|
1672
|
-
else if (
|
|
1673
|
-
const t = e.attachShadow(
|
|
1674
|
-
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
function
|
|
1678
|
-
for (const t of [...
|
|
1679
|
-
|
|
1660
|
+
function be(r, e) {
|
|
1661
|
+
ui(r) ? r.current = e : G(r) && r(e);
|
|
1662
|
+
}
|
|
1663
|
+
function ae(r, e) {
|
|
1664
|
+
if (hi(r))
|
|
1665
|
+
Ei(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 (li(r))
|
|
1671
|
+
ce(r, e);
|
|
1672
|
+
else if (pi(r)) {
|
|
1673
|
+
const t = e.attachShadow(r.attr);
|
|
1674
|
+
ae(r.children, t), be(r.ref, t);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
function Ei(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 ki(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, yi, Q(r, ":"), e);
|
|
1703
1703
|
return;
|
|
1704
1704
|
case "xmlnsXlink":
|
|
1705
|
-
|
|
1705
|
+
N(t, Q(r, ":"), e);
|
|
1706
1706
|
return;
|
|
1707
1707
|
case "xmlBase":
|
|
1708
1708
|
case "xmlLang":
|
|
1709
1709
|
case "xmlSpace":
|
|
1710
|
-
|
|
1710
|
+
De(t, wi, Q(r, ":"), e);
|
|
1711
1711
|
return;
|
|
1712
1712
|
}
|
|
1713
|
-
switch (
|
|
1713
|
+
switch (r) {
|
|
1714
1714
|
case "htmlFor":
|
|
1715
|
-
|
|
1715
|
+
N(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) : N(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 ? N(t, r, "") : e !== !1 && e != null && (t instanceof SVGElement && !vi.test(r) ? N(t, Q(r, "-"), e) : N(t, r, e));
|
|
1776
1776
|
}
|
|
1777
|
-
function
|
|
1778
|
-
|
|
1777
|
+
function N(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 $i(r, e) {
|
|
1784
|
+
for (const t of oe(r))
|
|
1785
|
+
ki(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 Ri = 0;
|
|
1790
|
+
const Me = (r) => `${r}-${++Ri}`;
|
|
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 xi = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform), nt = ["ctrl", "alt", "shift", "meta"];
|
|
1818
|
+
function Li(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(xi ? "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 Ai(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 Ti {
|
|
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 Ti();
|
|
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 = Li(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 = Ai(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(_i, { 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(Tt, { 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 Ci {
|
|
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 Ii = Object.create, _e = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, lt = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), ct = (r) => {
|
|
2592
|
+
throw TypeError(r);
|
|
2593
|
+
}, Di = (r, e, t) => e in r ? _e(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Mi = (r, e) => _e(r, "name", { value: e, configurable: !0 }), Ui = (r) => [, , , Ii(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, Bi = (r, e, t, i, s) => ({ kind: Ni[r], name: e, metadata: i, addInitializer: (n) => t._ ? ct("Already initialized") : s.push(ht(n || null)) }), ji = (r, e) => Di(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
|
+
}, qi = (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) && Pi(s, t));
|
|
2598
|
+
Mi(s, t);
|
|
2599
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
2600
|
+
c = Bi(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, ht(o) && (s = o);
|
|
2601
|
+
return ji(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,59 @@ 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.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
|
-
|
|
2678
|
+
onClick: (i) => {
|
|
2679
|
+
i.preventDefault(), Promise.all(
|
|
2676
2680
|
Object.keys(this.QUERY_DATA).map(
|
|
2677
|
-
(
|
|
2681
|
+
(s) => this.invalidateCache(s)
|
|
2678
2682
|
)
|
|
2679
2683
|
).then(() => {
|
|
2680
2684
|
window.location.reload();
|
|
2681
2685
|
});
|
|
2682
2686
|
},
|
|
2683
|
-
children:
|
|
2687
|
+
children: [
|
|
2688
|
+
"🧹 ",
|
|
2689
|
+
t`Clear caches & Reload`
|
|
2690
|
+
]
|
|
2684
2691
|
}
|
|
2685
2692
|
)
|
|
2686
2693
|
] })
|
|
@@ -2696,8 +2703,8 @@ class J extends (rt = I) {
|
|
|
2696
2703
|
if (i)
|
|
2697
2704
|
return this._data[e] = i, this.logger.debug("Using cached", e, i), i;
|
|
2698
2705
|
{
|
|
2699
|
-
const
|
|
2700
|
-
return this.saveToCache(e,
|
|
2706
|
+
const s = await this.fetchFromApi(e);
|
|
2707
|
+
return this.saveToCache(e, s), this._data[e] = s, this.logger.debug("Fetched from API", e, s), s;
|
|
2701
2708
|
}
|
|
2702
2709
|
}
|
|
2703
2710
|
getCacheKey(e) {
|
|
@@ -2837,12 +2844,12 @@ class J extends (rt = I) {
|
|
|
2837
2844
|
}
|
|
2838
2845
|
/** Get mainpage URL */
|
|
2839
2846
|
getMainpageUrl(e) {
|
|
2840
|
-
return
|
|
2847
|
+
return at(this.siteInfo.general.base, e).toString();
|
|
2841
2848
|
}
|
|
2842
2849
|
getUrl(e, t) {
|
|
2843
|
-
const i =
|
|
2844
|
-
let
|
|
2845
|
-
return typeof e == "string" && e !== "" ?
|
|
2850
|
+
const i = ot(t);
|
|
2851
|
+
let s;
|
|
2852
|
+
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
2853
|
}
|
|
2847
2854
|
hasRight(e) {
|
|
2848
2855
|
return this.userRights.includes(e);
|
|
@@ -2870,16 +2877,16 @@ class J extends (rt = I) {
|
|
|
2870
2877
|
} : null;
|
|
2871
2878
|
}
|
|
2872
2879
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
const
|
|
2877
|
-
const
|
|
2878
|
-
return
|
|
2880
|
+
Se = Ui(dt);
|
|
2881
|
+
te = qi(Se, 0, "WikiMetadataService", ut, te);
|
|
2882
|
+
Fi(Se, 1, te);
|
|
2883
|
+
const Hi = (() => {
|
|
2884
|
+
const r = Symbol.for("IPE.GlobalMemoryStorage");
|
|
2885
|
+
return r in globalThis || (globalThis[r] = $t()), globalThis[r];
|
|
2879
2886
|
})();
|
|
2880
|
-
class
|
|
2881
|
-
constructor(e, t, i = 1 / 0,
|
|
2882
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
2887
|
+
class Ki {
|
|
2888
|
+
constructor(e, t, i = 1 / 0, s, n = "localStorage") {
|
|
2889
|
+
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 = Hi;
|
|
2883
2890
|
}
|
|
2884
2891
|
// Key builder
|
|
2885
2892
|
makeKey(e) {
|
|
@@ -2895,8 +2902,8 @@ class Li {
|
|
|
2895
2902
|
} catch {
|
|
2896
2903
|
return this.deleteSync(e), null;
|
|
2897
2904
|
}
|
|
2898
|
-
const
|
|
2899
|
-
return typeof
|
|
2905
|
+
const s = i;
|
|
2906
|
+
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
2907
|
}
|
|
2901
2908
|
getRaw(e) {
|
|
2902
2909
|
const t = this.makeKey(e);
|
|
@@ -2917,15 +2924,15 @@ class Li {
|
|
|
2917
2924
|
return e ? Date.now() - e.time > t : !1;
|
|
2918
2925
|
}
|
|
2919
2926
|
async get(e, t = this.ttl, i) {
|
|
2920
|
-
const
|
|
2921
|
-
if (!
|
|
2927
|
+
const s = this.load(e), n = this.isExpired(s, t);
|
|
2928
|
+
if (!s || n) {
|
|
2922
2929
|
if (typeof i == "function") {
|
|
2923
2930
|
const o = await i();
|
|
2924
2931
|
return await this.set(e, o), o;
|
|
2925
2932
|
}
|
|
2926
2933
|
return null;
|
|
2927
2934
|
}
|
|
2928
|
-
return
|
|
2935
|
+
return s.value;
|
|
2929
2936
|
}
|
|
2930
2937
|
async set(e, t) {
|
|
2931
2938
|
const i = Date.now();
|
|
@@ -2938,8 +2945,8 @@ class Li {
|
|
|
2938
2945
|
const c = { time: i, value: a, version: this.version };
|
|
2939
2946
|
return this.setRaw(o, JSON.stringify(c)), c;
|
|
2940
2947
|
}
|
|
2941
|
-
const
|
|
2942
|
-
for (const [o, a] of Object.entries(
|
|
2948
|
+
const s = e, n = {};
|
|
2949
|
+
for (const [o, a] of Object.entries(s)) {
|
|
2943
2950
|
if (a === null || typeof a > "u") {
|
|
2944
2951
|
this.deleteSync(o);
|
|
2945
2952
|
continue;
|
|
@@ -2963,8 +2970,8 @@ class Li {
|
|
|
2963
2970
|
async clear() {
|
|
2964
2971
|
const e = this.makeKey(""), t = [];
|
|
2965
2972
|
for (let i = 0; i < this.db.length; i++) {
|
|
2966
|
-
const
|
|
2967
|
-
|
|
2973
|
+
const s = this.db.key(i);
|
|
2974
|
+
s && s.startsWith(e) && t.push(s);
|
|
2968
2975
|
}
|
|
2969
2976
|
for (const i of t) this.db.removeItem(i);
|
|
2970
2977
|
return this;
|
|
@@ -3002,172 +3009,172 @@ class Li {
|
|
|
3002
3009
|
}
|
|
3003
3010
|
}
|
|
3004
3011
|
}
|
|
3005
|
-
var
|
|
3006
|
-
((
|
|
3007
|
-
|
|
3012
|
+
var b;
|
|
3013
|
+
((r) => {
|
|
3014
|
+
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
3015
|
function e(l) {
|
|
3009
3016
|
const h = l?.name ?? "";
|
|
3010
3017
|
return h === "AbortError" || h === "InvalidStateError" || h === "TransactionInactiveError" || h === "UnknownError";
|
|
3011
3018
|
}
|
|
3012
|
-
|
|
3019
|
+
r.shouldReconnect = e;
|
|
3013
3020
|
async function t(l, h, d) {
|
|
3014
3021
|
const u = Math.max(1, l.attempts);
|
|
3015
3022
|
for (let f = 0; f < u; f++)
|
|
3016
3023
|
try {
|
|
3017
3024
|
return await h(f);
|
|
3018
|
-
} catch (
|
|
3019
|
-
if (f === u - 1) throw
|
|
3020
|
-
await d?.(
|
|
3021
|
-
const
|
|
3022
|
-
await (0,
|
|
3025
|
+
} catch (g) {
|
|
3026
|
+
if (f === u - 1) throw g;
|
|
3027
|
+
await d?.(g, f);
|
|
3028
|
+
const p = l.baseDelayMs * Math.pow(2, f) + Math.floor(Math.random() * 10);
|
|
3029
|
+
await (0, r.sleep)(p);
|
|
3023
3030
|
}
|
|
3024
3031
|
throw new Error("withRetry exhausted unexpectedly");
|
|
3025
3032
|
}
|
|
3026
|
-
|
|
3033
|
+
r.withRetry = t;
|
|
3027
3034
|
function i(l, h, d) {
|
|
3028
3035
|
return new Promise((u, f) => {
|
|
3029
|
-
const
|
|
3030
|
-
|
|
3036
|
+
const g = indexedDB.open(l, h);
|
|
3037
|
+
g.onupgradeneeded = () => {
|
|
3031
3038
|
try {
|
|
3032
|
-
const
|
|
3033
|
-
d?.(
|
|
3034
|
-
} catch (
|
|
3035
|
-
f(
|
|
3039
|
+
const p = g.result, y = g.transaction;
|
|
3040
|
+
d?.(p, y);
|
|
3041
|
+
} catch (p) {
|
|
3042
|
+
f(p);
|
|
3036
3043
|
}
|
|
3037
|
-
},
|
|
3038
|
-
},
|
|
3039
|
-
const
|
|
3040
|
-
|
|
3044
|
+
}, g.onerror = () => f(g.error), g.onblocked = () => {
|
|
3045
|
+
}, g.onsuccess = () => {
|
|
3046
|
+
const p = g.result;
|
|
3047
|
+
p.onversionchange = () => {
|
|
3041
3048
|
try {
|
|
3042
|
-
|
|
3049
|
+
p.close();
|
|
3043
3050
|
} finally {
|
|
3044
|
-
|
|
3051
|
+
r.cache.delete(l);
|
|
3045
3052
|
}
|
|
3046
|
-
}, u(
|
|
3053
|
+
}, u(p);
|
|
3047
3054
|
};
|
|
3048
3055
|
});
|
|
3049
3056
|
}
|
|
3050
|
-
async function
|
|
3057
|
+
async function s(l, h, d) {
|
|
3051
3058
|
let u = !l.objectStoreNames.contains(h), f = [];
|
|
3052
3059
|
if (!u && d?.indexes?.length) {
|
|
3053
|
-
const
|
|
3054
|
-
f = (d.indexes || []).filter((O) => !
|
|
3055
|
-
|
|
3060
|
+
const y = l.transaction(h, "readonly"), L = y.objectStore(h), U = new Set(Array.from(L.indexNames));
|
|
3061
|
+
f = (d.indexes || []).filter((O) => !U.has(O.name)), await new Promise((O, Le) => {
|
|
3062
|
+
y.oncomplete = () => O(), y.onabort = () => Le(y.error), y.onerror = () => Le(y.error);
|
|
3056
3063
|
});
|
|
3057
3064
|
}
|
|
3058
3065
|
if (!u && f.length === 0) return l;
|
|
3059
|
-
const
|
|
3066
|
+
const g = l.version + 1;
|
|
3060
3067
|
l.close();
|
|
3061
|
-
const
|
|
3062
|
-
let
|
|
3063
|
-
|
|
3068
|
+
const p = await i(l.name, g, (y, L) => {
|
|
3069
|
+
let U;
|
|
3070
|
+
y.objectStoreNames.contains(h) ? U = L.objectStore(h) : U = y.createObjectStore(h, {
|
|
3064
3071
|
keyPath: d?.keyPath ?? void 0,
|
|
3065
3072
|
autoIncrement: !!d?.autoIncrement
|
|
3066
3073
|
});
|
|
3067
3074
|
for (const O of f)
|
|
3068
|
-
|
|
3075
|
+
U.indexNames.contains(O.name) || U.createIndex(O.name, O.keyPath, O.options);
|
|
3069
3076
|
});
|
|
3070
|
-
return
|
|
3077
|
+
return p.onversionchange = () => {
|
|
3071
3078
|
try {
|
|
3072
|
-
|
|
3079
|
+
p.close();
|
|
3073
3080
|
} finally {
|
|
3074
|
-
|
|
3081
|
+
r.cache.delete(p.name);
|
|
3075
3082
|
}
|
|
3076
|
-
},
|
|
3083
|
+
}, p;
|
|
3077
3084
|
}
|
|
3078
3085
|
async function n(l, h, d) {
|
|
3079
|
-
let u =
|
|
3080
|
-
return u ? (u = u.then((f) =>
|
|
3086
|
+
let u = r.cache.get(l);
|
|
3087
|
+
return u ? (u = u.then((f) => s(f, h, d)), r.cache.set(l, u)) : (u = (async () => {
|
|
3081
3088
|
const f = await i(l);
|
|
3082
|
-
return
|
|
3083
|
-
})(),
|
|
3089
|
+
return s(f, h, d);
|
|
3090
|
+
})(), r.cache.set(l, u)), u;
|
|
3084
3091
|
}
|
|
3085
|
-
|
|
3092
|
+
r.getDB = n;
|
|
3086
3093
|
async function o(l) {
|
|
3087
|
-
const h =
|
|
3088
|
-
if (
|
|
3094
|
+
const h = r.cache.get(l);
|
|
3095
|
+
if (r.cache.delete(l), h)
|
|
3089
3096
|
try {
|
|
3090
3097
|
(await h).close();
|
|
3091
3098
|
} catch {
|
|
3092
3099
|
}
|
|
3093
3100
|
}
|
|
3094
|
-
|
|
3101
|
+
r.closeConnection = o;
|
|
3095
3102
|
function a(l) {
|
|
3096
3103
|
return new Promise((h, d) => {
|
|
3097
3104
|
l.onsuccess = () => h(l.result), l.onerror = () => d(l.error);
|
|
3098
3105
|
});
|
|
3099
3106
|
}
|
|
3100
|
-
|
|
3107
|
+
r.asyncRequest = a;
|
|
3101
3108
|
function c(l) {
|
|
3102
3109
|
return new Promise((h, d) => {
|
|
3103
3110
|
l.oncomplete = () => h(), l.onabort = () => d(l.error ?? new DOMException("Aborted", "AbortError")), l.onerror = () => d(l.error ?? new DOMException("TransactionError", "UnknownError"));
|
|
3104
3111
|
});
|
|
3105
3112
|
}
|
|
3106
|
-
|
|
3107
|
-
})(
|
|
3108
|
-
class
|
|
3113
|
+
r.waitTx = c;
|
|
3114
|
+
})(b || (b = {}));
|
|
3115
|
+
class Wi {
|
|
3109
3116
|
constructor(e, t, i = {}) {
|
|
3110
3117
|
this.dbName = e, this.storeName = t, this.options = i;
|
|
3111
3118
|
}
|
|
3112
3119
|
get _iterBatch() {
|
|
3113
|
-
return this.options.iterBatch ??
|
|
3120
|
+
return this.options.iterBatch ?? b.defaults.iterBatch;
|
|
3114
3121
|
}
|
|
3115
3122
|
get _retryCfg() {
|
|
3116
|
-
const e = this.options.retry ??
|
|
3123
|
+
const e = this.options.retry ?? b.defaults.retry;
|
|
3117
3124
|
return { attempts: e.attempts ?? 3, baseDelayMs: e.baseDelayMs ?? 16 };
|
|
3118
3125
|
}
|
|
3119
3126
|
async _withStore(e, t) {
|
|
3120
3127
|
const i = this._retryCfg;
|
|
3121
|
-
return
|
|
3128
|
+
return b.withRetry(
|
|
3122
3129
|
i,
|
|
3123
3130
|
async () => {
|
|
3124
|
-
const
|
|
3131
|
+
const s = await b.getDB(this.dbName, this.storeName, this.options.ensure);
|
|
3125
3132
|
try {
|
|
3126
|
-
const n =
|
|
3127
|
-
return await
|
|
3133
|
+
const n = s.transaction(this.storeName, e), o = n.objectStore(this.storeName), a = await t(o);
|
|
3134
|
+
return await b.waitTx(n), a;
|
|
3128
3135
|
} catch (n) {
|
|
3129
3136
|
throw n;
|
|
3130
3137
|
}
|
|
3131
3138
|
},
|
|
3132
|
-
async (
|
|
3133
|
-
|
|
3139
|
+
async (s) => {
|
|
3140
|
+
b.shouldReconnect(s) && await b.closeConnection(this.dbName);
|
|
3134
3141
|
}
|
|
3135
3142
|
);
|
|
3136
3143
|
}
|
|
3137
3144
|
async get(e) {
|
|
3138
3145
|
return this._withStore("readonly", async (t) => {
|
|
3139
|
-
const i = await
|
|
3146
|
+
const i = await b.asyncRequest(t.get(e));
|
|
3140
3147
|
return i === void 0 ? void 0 : i;
|
|
3141
3148
|
});
|
|
3142
3149
|
}
|
|
3143
3150
|
async set(e, t) {
|
|
3144
3151
|
return await this._withStore("readwrite", async (i) => {
|
|
3145
|
-
const
|
|
3146
|
-
await
|
|
3152
|
+
const s = this.options.ensure?.keyPath != null ? i.put(t) : i.put(t, e);
|
|
3153
|
+
await b.asyncRequest(s);
|
|
3147
3154
|
}), this;
|
|
3148
3155
|
}
|
|
3149
3156
|
async delete(e) {
|
|
3150
3157
|
return this._withStore("readwrite", async (t) => {
|
|
3151
|
-
const i = await
|
|
3152
|
-
return await
|
|
3158
|
+
const i = await b.asyncRequest(t.get(e)) !== void 0;
|
|
3159
|
+
return await b.asyncRequest(t.delete(e)), i;
|
|
3153
3160
|
});
|
|
3154
3161
|
}
|
|
3155
3162
|
async clear() {
|
|
3156
3163
|
await this._withStore("readwrite", async (e) => {
|
|
3157
|
-
await
|
|
3164
|
+
await b.asyncRequest(e.clear());
|
|
3158
3165
|
});
|
|
3159
3166
|
}
|
|
3160
3167
|
async has(e) {
|
|
3161
3168
|
return await this.get(e) !== void 0;
|
|
3162
3169
|
}
|
|
3163
3170
|
async count() {
|
|
3164
|
-
return this._withStore("readonly", async (e) => await
|
|
3171
|
+
return this._withStore("readonly", async (e) => await b.asyncRequest(e.count()) ?? 0);
|
|
3165
3172
|
}
|
|
3166
3173
|
async *_iterateEntries() {
|
|
3167
3174
|
let e = null, t = !1;
|
|
3168
3175
|
const i = Math.max(1, this._iterBatch);
|
|
3169
3176
|
for (; !t; ) {
|
|
3170
|
-
const
|
|
3177
|
+
const s = await this._withStore("readonly", async (n) => {
|
|
3171
3178
|
const o = [], a = e === null ? void 0 : IDBKeyRange.lowerBound(e, !0);
|
|
3172
3179
|
return await new Promise((c, l) => {
|
|
3173
3180
|
const h = n.openCursor(a);
|
|
@@ -3181,8 +3188,8 @@ class Oi {
|
|
|
3181
3188
|
};
|
|
3182
3189
|
}), o;
|
|
3183
3190
|
});
|
|
3184
|
-
for (const n of
|
|
3185
|
-
if (
|
|
3191
|
+
for (const n of s) yield n;
|
|
3192
|
+
if (s.length === 0) break;
|
|
3186
3193
|
}
|
|
3187
3194
|
}
|
|
3188
3195
|
entries() {
|
|
@@ -3206,9 +3213,9 @@ class Oi {
|
|
|
3206
3213
|
for await (const i of e) t.set(i, void 0);
|
|
3207
3214
|
return await this._withStore("readonly", async (i) => {
|
|
3208
3215
|
await Promise.all(
|
|
3209
|
-
t.keys().map(async (
|
|
3210
|
-
const n = await
|
|
3211
|
-
t.set(
|
|
3216
|
+
t.keys().map(async (s) => {
|
|
3217
|
+
const n = await b.asyncRequest(i.get(s));
|
|
3218
|
+
t.set(s, n === void 0 ? void 0 : n);
|
|
3212
3219
|
})
|
|
3213
3220
|
);
|
|
3214
3221
|
}), t;
|
|
@@ -3216,45 +3223,45 @@ class Oi {
|
|
|
3216
3223
|
async setMany(e) {
|
|
3217
3224
|
const t = this.options.ensure?.keyPath != null;
|
|
3218
3225
|
return await this._withStore("readwrite", async (i) => {
|
|
3219
|
-
for await (const [
|
|
3220
|
-
const o = t ? i.put(n) : i.put(n,
|
|
3221
|
-
await
|
|
3226
|
+
for await (const [s, n] of e) {
|
|
3227
|
+
const o = t ? i.put(n) : i.put(n, s);
|
|
3228
|
+
await b.asyncRequest(o);
|
|
3222
3229
|
}
|
|
3223
3230
|
}), this;
|
|
3224
3231
|
}
|
|
3225
3232
|
async deleteMany(e) {
|
|
3226
3233
|
let t = 0;
|
|
3227
3234
|
return await this._withStore("readwrite", async (i) => {
|
|
3228
|
-
for await (const
|
|
3229
|
-
await
|
|
3235
|
+
for await (const s of e)
|
|
3236
|
+
await b.asyncRequest(i.get(s)) !== void 0 && t++, await b.asyncRequest(i.delete(s));
|
|
3230
3237
|
}), t;
|
|
3231
3238
|
}
|
|
3232
3239
|
async disconnect() {
|
|
3233
|
-
await
|
|
3240
|
+
await b.closeConnection(this.dbName);
|
|
3234
3241
|
}
|
|
3235
3242
|
}
|
|
3236
|
-
class
|
|
3237
|
-
constructor(e, t, i = 1 / 0,
|
|
3238
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
3243
|
+
class zi {
|
|
3244
|
+
constructor(e, t, i = 1 / 0, s) {
|
|
3245
|
+
this.dbName = e, this.storeName = t, this.ttl = i, this.version = s, this.db = new Wi(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
3246
|
});
|
|
3240
3247
|
}
|
|
3241
3248
|
async _clearExpiredEntries() {
|
|
3242
3249
|
if (this.ttl === 1 / 0) return;
|
|
3243
3250
|
const e = Date.now(), t = [];
|
|
3244
|
-
for await (const [i,
|
|
3245
|
-
typeof
|
|
3251
|
+
for await (const [i, s] of this.db.entries())
|
|
3252
|
+
typeof s.time == "number" && e - s.time > this.ttl && t.push(i);
|
|
3246
3253
|
t.length > 0 && await this.db.deleteMany(t);
|
|
3247
3254
|
}
|
|
3248
3255
|
async get(e, t = this.ttl, i) {
|
|
3249
|
-
const
|
|
3250
|
-
if (!
|
|
3256
|
+
const s = await this.loadFromDB(e), n = this.checkIfExpired(s, t);
|
|
3257
|
+
if (!s || n) {
|
|
3251
3258
|
if (typeof i == "function") {
|
|
3252
3259
|
const o = await i();
|
|
3253
3260
|
return await this.set(e, o), o;
|
|
3254
3261
|
}
|
|
3255
3262
|
return null;
|
|
3256
3263
|
}
|
|
3257
|
-
return
|
|
3264
|
+
return s.value;
|
|
3258
3265
|
}
|
|
3259
3266
|
async set(e, t) {
|
|
3260
3267
|
const i = Date.now();
|
|
@@ -3269,8 +3276,8 @@ class xi {
|
|
|
3269
3276
|
};
|
|
3270
3277
|
return await this.db.set(c, h), h;
|
|
3271
3278
|
}
|
|
3272
|
-
const
|
|
3273
|
-
for (const [c, l] of Object.entries(
|
|
3279
|
+
const s = e, n = [], o = [], a = {};
|
|
3280
|
+
for (const [c, l] of Object.entries(s))
|
|
3274
3281
|
if (l === null || typeof l > "u")
|
|
3275
3282
|
o.push(c);
|
|
3276
3283
|
else {
|
|
@@ -3280,8 +3287,8 @@ class xi {
|
|
|
3280
3287
|
return n.length > 0 && await this.db.setMany(n), o.length > 0 && await this.db.deleteMany(o), a;
|
|
3281
3288
|
}
|
|
3282
3289
|
async has(e, t = this.ttl) {
|
|
3283
|
-
const i = await this.loadFromDB(e),
|
|
3284
|
-
return i !== null && !
|
|
3290
|
+
const i = await this.loadFromDB(e), s = this.checkIfExpired(i, t);
|
|
3291
|
+
return i !== null && !s;
|
|
3285
3292
|
}
|
|
3286
3293
|
async delete(e) {
|
|
3287
3294
|
await this.db.delete(e);
|
|
@@ -3301,7 +3308,7 @@ class xi {
|
|
|
3301
3308
|
}
|
|
3302
3309
|
return null;
|
|
3303
3310
|
}
|
|
3304
|
-
if (typeof this.version
|
|
3311
|
+
if (typeof this.version < "u" && typeof this.version < "u" && t.version !== this.version) {
|
|
3305
3312
|
try {
|
|
3306
3313
|
await this.delete(e);
|
|
3307
3314
|
} catch {
|
|
@@ -3321,27 +3328,27 @@ class xi {
|
|
|
3321
3328
|
return await this.db.clear(), this;
|
|
3322
3329
|
}
|
|
3323
3330
|
}
|
|
3324
|
-
class
|
|
3331
|
+
class Gi extends I {
|
|
3325
3332
|
constructor(e, t) {
|
|
3326
3333
|
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
3334
|
}
|
|
3328
|
-
createDatabase(e, t, i,
|
|
3335
|
+
createDatabase(e, t, i, s = "indexedDB") {
|
|
3329
3336
|
const n = "indexedDB" in window && window.indexedDB !== null;
|
|
3330
|
-
switch (
|
|
3337
|
+
switch (s === "indexedDB" && !n && (s = "localStorage"), s) {
|
|
3331
3338
|
case "indexedDB":
|
|
3332
|
-
return new
|
|
3339
|
+
return new zi(this.config.dbName, e, t, i);
|
|
3333
3340
|
case "localStorage":
|
|
3334
3341
|
case "sessionStorage":
|
|
3335
3342
|
case "memory":
|
|
3336
|
-
return new
|
|
3343
|
+
return new Ki(this.config.dbName, e, t, i, s);
|
|
3337
3344
|
default:
|
|
3338
|
-
throw new Error(`Unsupported storage engine: ${
|
|
3345
|
+
throw new Error(`Unsupported storage engine: ${s}`);
|
|
3339
3346
|
}
|
|
3340
3347
|
}
|
|
3341
3348
|
}
|
|
3342
|
-
class
|
|
3349
|
+
class Yi extends I {
|
|
3343
3350
|
constructor(e) {
|
|
3344
|
-
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage =
|
|
3351
|
+
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage = Rt(this.ctx.api);
|
|
3345
3352
|
}
|
|
3346
3353
|
static {
|
|
3347
3354
|
this.inject = ["api"];
|
|
@@ -3349,8 +3356,8 @@ class Pi extends I {
|
|
|
3349
3356
|
async createInstance(e, t = !1) {
|
|
3350
3357
|
return await this.WikiPage.newFromApi(e);
|
|
3351
3358
|
}
|
|
3352
|
-
async newFromTitle(e, t = !1, i,
|
|
3353
|
-
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i },
|
|
3359
|
+
async newFromTitle(e, t = !1, i, s = !1) {
|
|
3360
|
+
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i }, s);
|
|
3354
3361
|
}
|
|
3355
3362
|
async newFromPageId(e, t, i = !1) {
|
|
3356
3363
|
return this.createInstance({ pageids: e, rvsection: t }, i);
|
|
@@ -3362,9 +3369,9 @@ class Pi extends I {
|
|
|
3362
3369
|
return this.WikiPage.newBlankPage(e);
|
|
3363
3370
|
}
|
|
3364
3371
|
}
|
|
3365
|
-
class
|
|
3372
|
+
class Ee extends I {
|
|
3366
3373
|
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 =
|
|
3374
|
+
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
3375
|
}
|
|
3369
3376
|
static {
|
|
3370
3377
|
this.inject = ["wiki", "wikiPage"];
|
|
@@ -3380,15 +3387,15 @@ class ve extends I {
|
|
|
3380
3387
|
return t?.title ? t.title : t?.pageId ? this.newTitleFromPageId(t.pageId) : null;
|
|
3381
3388
|
}
|
|
3382
3389
|
async newTitleFromAnyId(e, t = !1) {
|
|
3383
|
-
const { title: i, pageId:
|
|
3390
|
+
const { title: i, pageId: s, revId: n } = e ?? {};
|
|
3384
3391
|
if (typeof i == "string")
|
|
3385
3392
|
return this.newTitle(i);
|
|
3386
3393
|
let o, a;
|
|
3387
|
-
if (n ? (o = parseInt(n.toString(), 10), a = "revid") :
|
|
3394
|
+
if (n ? (o = parseInt(n.toString(), 10), a = "revid") : s && (o = parseInt(s.toString(), 10), a = "pageid"), !o || !a || isNaN(o) || o <= 0)
|
|
3388
3395
|
throw new Error("Invalid id or kind", { cause: e });
|
|
3389
3396
|
if (!t && this._cachedTitles.has(`${a}:${o}`))
|
|
3390
3397
|
return await this._cachedTitles.get(`${a}:${o}`);
|
|
3391
|
-
const { promise: c, resolve: l, reject: h } =
|
|
3398
|
+
const { promise: c, resolve: l, reject: h } = je();
|
|
3392
3399
|
this._cachedTitles.set(`${a}:${o}`, c);
|
|
3393
3400
|
try {
|
|
3394
3401
|
const { wikiPage: d } = this.ctx;
|
|
@@ -3426,7 +3433,7 @@ class ve extends I {
|
|
|
3426
3433
|
const t = typeof e == "string" ? this.newTitle(e) : e;
|
|
3427
3434
|
if (!t || t.getNamespaceId() !== -1)
|
|
3428
3435
|
return null;
|
|
3429
|
-
let i,
|
|
3436
|
+
let i, s, n = "view";
|
|
3430
3437
|
const o = t.getMainDBKey().split("/").slice(1).join("/") || "";
|
|
3431
3438
|
if (t.isSpecial("edit") && o)
|
|
3432
3439
|
i = o, n = "edit";
|
|
@@ -3440,12 +3447,12 @@ class ve extends I {
|
|
|
3440
3447
|
else if (t.isSpecial("mytalk"))
|
|
3441
3448
|
i = t.newTitle(this.ctx.wiki.userInfo.name, 3).getPrefixedDBKey() + (o ? `/${o}` : "");
|
|
3442
3449
|
else if (t.isSpecial("newsection") && o)
|
|
3443
|
-
i = o,
|
|
3450
|
+
i = o, s = "new", n = "edit";
|
|
3444
3451
|
else
|
|
3445
3452
|
return null;
|
|
3446
3453
|
return {
|
|
3447
3454
|
title: new this.Title(i),
|
|
3448
|
-
section:
|
|
3455
|
+
section: s,
|
|
3449
3456
|
action: n
|
|
3450
3457
|
};
|
|
3451
3458
|
}
|
|
@@ -3458,15 +3465,15 @@ class ve extends I {
|
|
|
3458
3465
|
this.REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i;
|
|
3459
3466
|
}
|
|
3460
3467
|
validateHrefAttr(e) {
|
|
3461
|
-
return typeof e != "string" ? !1 : !
|
|
3468
|
+
return typeof e != "string" ? !1 : !Ee.REG_SKIPPED_HREF.test(e);
|
|
3462
3469
|
}
|
|
3463
3470
|
parseWikiLink(e) {
|
|
3464
3471
|
if (!e || typeof e == "string" && !this.validateHrefAttr(e))
|
|
3465
3472
|
return null;
|
|
3466
|
-
const t =
|
|
3473
|
+
const t = at(e);
|
|
3467
3474
|
if (!this.isWikiLink(t.toString()))
|
|
3468
3475
|
return null;
|
|
3469
|
-
const i = t.searchParams,
|
|
3476
|
+
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
3477
|
let l = o || (() => {
|
|
3471
3478
|
try {
|
|
3472
3479
|
return decodeURIComponent(t.pathname.substring(this.wikiArticlePath.length));
|
|
@@ -3492,29 +3499,29 @@ class ve extends I {
|
|
|
3492
3499
|
revId: u,
|
|
3493
3500
|
url: t,
|
|
3494
3501
|
params: i,
|
|
3495
|
-
hash:
|
|
3502
|
+
hash: s,
|
|
3496
3503
|
action: n
|
|
3497
3504
|
};
|
|
3498
3505
|
}
|
|
3499
3506
|
}
|
|
3500
|
-
const
|
|
3501
|
-
async function
|
|
3502
|
-
return
|
|
3507
|
+
const Xi = (r) => typeof r == "function";
|
|
3508
|
+
async function Qi(r) {
|
|
3509
|
+
return Xi(r) ? await r() : r;
|
|
3503
3510
|
}
|
|
3504
|
-
var
|
|
3505
|
-
throw TypeError(
|
|
3506
|
-
},
|
|
3507
|
-
for (var
|
|
3511
|
+
var Vi = Object.create, ke = Object.defineProperty, Zi = Object.getOwnPropertyDescriptor, ft = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), gt = (r) => {
|
|
3512
|
+
throw TypeError(r);
|
|
3513
|
+
}, Ji = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, es = (r, e) => ke(r, "name", { value: e, configurable: !0 }), ts = (r) => [, , , Vi(r?.[ft("metadata")] ?? null)], is = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], pt = (r) => r !== void 0 && typeof r != "function" ? gt("Function expected") : r, ss = (r, e, t, i, s) => ({ kind: is[r], name: e, metadata: i, addInitializer: (n) => t._ ? gt("Already initialized") : s.push(pt(n || null)) }), rs = (r, e) => Ji(e, ft("metadata"), r[3]), ns = (r, e, t, i) => {
|
|
3514
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
3508
3515
|
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
|
|
3516
|
+
}, os = (r, e, t, i, s, n) => {
|
|
3517
|
+
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) && Zi(s, t));
|
|
3518
|
+
es(s, t);
|
|
3519
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
3520
|
+
c = ss(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, pt(o) && (s = o);
|
|
3521
|
+
return rs(r, s), f && ke(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
3522
|
+
}, mt, $e, yt;
|
|
3523
|
+
mt = [ne(["storage", "wiki"])];
|
|
3524
|
+
class ie extends (yt = I) {
|
|
3518
3525
|
constructor(e) {
|
|
3519
3526
|
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
3527
|
try {
|
|
@@ -3526,27 +3533,16 @@ class ee extends (ct = I) {
|
|
|
3526
3533
|
return this.ctx.logger("PREFERENCES");
|
|
3527
3534
|
}
|
|
3528
3535
|
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
3536
|
}
|
|
3541
3537
|
async get(e, t) {
|
|
3542
3538
|
if (!e)
|
|
3543
3539
|
return this.getAll();
|
|
3544
3540
|
t ??= () => {
|
|
3545
|
-
const
|
|
3546
|
-
return this.logger.debug(e, `(fallback value: ${
|
|
3541
|
+
const s = this.defaultOf(e);
|
|
3542
|
+
return this.logger.debug(e, `(fallback value: ${s})`), s;
|
|
3547
3543
|
};
|
|
3548
3544
|
const i = await this.db.get(e, void 0);
|
|
3549
|
-
return i !== null ? i : await
|
|
3545
|
+
return i !== null ? i : await Qi(t);
|
|
3550
3546
|
}
|
|
3551
3547
|
/**
|
|
3552
3548
|
* 获取全部注册的配置项以及最终生效的值
|
|
@@ -3563,8 +3559,8 @@ class ee extends (ct = I) {
|
|
|
3563
3559
|
}
|
|
3564
3560
|
async setMany(e) {
|
|
3565
3561
|
const t = this.loadDefaultConfigs(), i = {};
|
|
3566
|
-
for (const [
|
|
3567
|
-
n === t[
|
|
3562
|
+
for (const [s, n] of Object.entries(e))
|
|
3563
|
+
n === t[s] || n === void 0 ? i[s] = void 0 : i[s] = n;
|
|
3568
3564
|
return await this.db.set(i), this.ctx.emit("preferences/changed", { ctx: this.ctx, input: e, changes: i }), i;
|
|
3569
3565
|
}
|
|
3570
3566
|
defaultOf(e) {
|
|
@@ -3579,9 +3575,9 @@ class ee extends (ct = I) {
|
|
|
3579
3575
|
async getExportableRecord(e) {
|
|
3580
3576
|
e ??= await this.getAll();
|
|
3581
3577
|
const t = this.loadDefaultConfigs(), i = {};
|
|
3582
|
-
return Object.entries(t).sort(([
|
|
3583
|
-
const o = e[
|
|
3584
|
-
o !== void 0 && o !== n && (i[
|
|
3578
|
+
return Object.entries(t).sort(([s], [n]) => s.localeCompare(n)).forEach(([s, n]) => {
|
|
3579
|
+
const o = e[s];
|
|
3580
|
+
o !== void 0 && o !== n && (i[s] = o);
|
|
3585
3581
|
}), i;
|
|
3586
3582
|
}
|
|
3587
3583
|
loadDefaultConfigs() {
|
|
@@ -3589,8 +3585,8 @@ class ee extends (ct = I) {
|
|
|
3589
3585
|
return this.getConfigRegistries().forEach((t) => {
|
|
3590
3586
|
try {
|
|
3591
3587
|
const i = t.schema({});
|
|
3592
|
-
Object.entries(i).forEach(([
|
|
3593
|
-
e[
|
|
3588
|
+
Object.entries(i).forEach(([s, n]) => {
|
|
3589
|
+
e[s] = n;
|
|
3594
3590
|
});
|
|
3595
3591
|
} catch {
|
|
3596
3592
|
}
|
|
@@ -3599,16 +3595,17 @@ class ee extends (ct = I) {
|
|
|
3599
3595
|
}), e;
|
|
3600
3596
|
}
|
|
3601
3597
|
registerCustomConfig(e, t, i) {
|
|
3602
|
-
|
|
3598
|
+
const s = {
|
|
3603
3599
|
name: e,
|
|
3604
3600
|
schema: t,
|
|
3605
3601
|
category: i || "general"
|
|
3606
|
-
}
|
|
3602
|
+
}, n = this.customRegistries.findIndex((o) => o.name === e);
|
|
3603
|
+
return n >= 0 ? this.customRegistries[n] = s : this.customRegistries.push(s), this;
|
|
3607
3604
|
}
|
|
3608
3605
|
getConfigRegistries(e) {
|
|
3609
3606
|
return Array.from(this.ctx.registry.entries()).map(([t]) => t === null ? {
|
|
3610
3607
|
name: "@root",
|
|
3611
|
-
schema:
|
|
3608
|
+
schema: re?.PreferencesSchema || null
|
|
3612
3609
|
} : {
|
|
3613
3610
|
name: t.name,
|
|
3614
3611
|
schema: t?.PreferencesSchema || null
|
|
@@ -3618,13 +3615,13 @@ class ee extends (ct = I) {
|
|
|
3618
3615
|
})).concat(this.customRegistries).filter((t) => !e || t.category === e);
|
|
3619
3616
|
}
|
|
3620
3617
|
getAllSchema() {
|
|
3621
|
-
return new
|
|
3622
|
-
|
|
3618
|
+
return new m(
|
|
3619
|
+
m.intersect(this.getConfigRegistries().map((e) => e.schema))
|
|
3623
3620
|
);
|
|
3624
3621
|
}
|
|
3625
3622
|
defineCategory(e) {
|
|
3626
3623
|
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,
|
|
3624
|
+
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((i, s) => (i.index ?? 0) - (s.index ?? 0)), this;
|
|
3628
3625
|
}
|
|
3629
3626
|
getConfigCategories() {
|
|
3630
3627
|
return this.categoryDefinitions;
|
|
@@ -3632,36 +3629,537 @@ class ee extends (ct = I) {
|
|
|
3632
3629
|
async _migrageFromLegacyMasterDB() {
|
|
3633
3630
|
const e = this.ctx.storage.createDatabase("preferences", 1 / 0);
|
|
3634
3631
|
let t = 0;
|
|
3635
|
-
for await (const [i,
|
|
3636
|
-
i !== "_touched" && (await this.db.set(i,
|
|
3632
|
+
for await (const [i, s] of e.entries())
|
|
3633
|
+
i !== "_touched" && (await this.db.set(i, s.value), t++);
|
|
3637
3634
|
return t && this.logger.info(`Migrated ${t} preferences from master DB`), await e.clear(), await e?.db?.disconnect?.(), t;
|
|
3638
3635
|
}
|
|
3639
3636
|
}
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3637
|
+
$e = ts(yt);
|
|
3638
|
+
ie = os($e, 0, "PreferencesService", mt, ie);
|
|
3639
|
+
ns($e, 1, ie);
|
|
3640
|
+
const wt = "", bt = "", as = /\\\{/g, ls = /\\\}/g, cs = new RegExp(wt, "g"), hs = new RegExp(bt, "g");
|
|
3641
|
+
function Ne(r) {
|
|
3642
|
+
const e = r ? { ...r } : void 0;
|
|
3643
|
+
return (i, ...s) => us(e, i, ...s);
|
|
3644
|
+
}
|
|
3645
|
+
function us(r, e, ...t) {
|
|
3646
|
+
if (!e) return "";
|
|
3647
|
+
let i = String(e).replace(as, wt).replace(ls, bt), s = {}, n = [];
|
|
3648
|
+
t.length === 1 && Array.isArray(t[0]) ? n = t[0] : t.length === 1 && ds(t[0]) ? s = t[0] : t.length > 0 && (n = t);
|
|
3649
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
3650
|
+
if (n && n.length)
|
|
3651
|
+
for (let a = 0; a < n.length; a++)
|
|
3652
|
+
o[`$${a + 1}`] = n[a];
|
|
3653
|
+
if (s && Object.keys(s).length)
|
|
3654
|
+
for (const a of Object.keys(s)) o[a] = s[a];
|
|
3655
|
+
if (r && Object.keys(r).length)
|
|
3656
|
+
for (const a of Object.keys(r))
|
|
3657
|
+
typeof o[a] > "u" && (o[a] = r[a]);
|
|
3658
|
+
return i = i.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g, (a, c) => {
|
|
3659
|
+
const l = String(c).trim();
|
|
3660
|
+
if (!l) return "";
|
|
3661
|
+
try {
|
|
3662
|
+
const h = fs(l, o);
|
|
3663
|
+
return h == null ? "" : String(h);
|
|
3664
|
+
} catch {
|
|
3665
|
+
return "";
|
|
3666
|
+
}
|
|
3667
|
+
}), i.replace(cs, "{").replace(hs, "}");
|
|
3668
|
+
}
|
|
3669
|
+
function ds(r) {
|
|
3670
|
+
return typeof r == "object" && r !== null && r.constructor === Object;
|
|
3671
|
+
}
|
|
3672
|
+
const fs = gs();
|
|
3673
|
+
function gs() {
|
|
3674
|
+
const r = /* @__PURE__ */ new Set([
|
|
3675
|
+
"eval",
|
|
3676
|
+
"Object",
|
|
3677
|
+
"Array",
|
|
3678
|
+
"String",
|
|
3679
|
+
"Number",
|
|
3680
|
+
"Boolean",
|
|
3681
|
+
"Date",
|
|
3682
|
+
"Math",
|
|
3683
|
+
"JSON",
|
|
3684
|
+
"undefined",
|
|
3685
|
+
"null",
|
|
3686
|
+
"true",
|
|
3687
|
+
"false",
|
|
3688
|
+
"NaN",
|
|
3689
|
+
"Infinity",
|
|
3690
|
+
"isNaN",
|
|
3691
|
+
"isFinite",
|
|
3692
|
+
"parseInt",
|
|
3693
|
+
"parseFloat"
|
|
3694
|
+
]), e = new Function(
|
|
3695
|
+
"__expr__",
|
|
3696
|
+
"ctx",
|
|
3697
|
+
`
|
|
3698
|
+
try {
|
|
3699
|
+
with (ctx) {
|
|
3700
|
+
return (eval(__expr__));
|
|
3701
|
+
}
|
|
3702
|
+
} catch (e) {
|
|
3703
|
+
throw e;
|
|
3704
|
+
}
|
|
3705
|
+
`
|
|
3706
|
+
);
|
|
3707
|
+
return (t, i) => {
|
|
3708
|
+
const s = new Proxy(i, {
|
|
3709
|
+
has: (n, o) => typeof o == "symbol" ? o in n : !(typeof o == "string" && (r.has(o) || o === "__expr__")),
|
|
3710
|
+
get: (n, o) => {
|
|
3711
|
+
if (o in n)
|
|
3712
|
+
return n[o];
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3715
|
+
return e(t, s);
|
|
3716
|
+
};
|
|
3717
|
+
}
|
|
3718
|
+
function C(r, e) {
|
|
3719
|
+
let t = r[0] ?? "";
|
|
3720
|
+
for (let i = 0; i < e.length; i++)
|
|
3721
|
+
t += String(e[i]) + (r[i + 1] ?? "");
|
|
3722
|
+
return t;
|
|
3723
|
+
}
|
|
3724
|
+
class ps {
|
|
3725
|
+
constructor(e, t) {
|
|
3726
|
+
this.languages = /* @__PURE__ */ new Map(), this.currentLanguage = "en", this.missingKeys = /* @__PURE__ */ new Map(), this.usedKeys = /* @__PURE__ */ new Set();
|
|
3727
|
+
const i = t?.language || "en";
|
|
3728
|
+
this.currentLanguage = i, this.interpolate = Ne(t?.globals), e && Object.keys(e).length && this.setLanguageData(i, e);
|
|
3729
|
+
}
|
|
3730
|
+
setGlobals(e) {
|
|
3731
|
+
return this.interpolate = Ne(e), this;
|
|
3732
|
+
}
|
|
3733
|
+
set(e, t) {
|
|
3734
|
+
const i = this.currentLanguage, s = this.ensureLanguageMap(i);
|
|
3735
|
+
if (typeof e == "string" && typeof t == "string")
|
|
3736
|
+
s.set(e, t);
|
|
3737
|
+
else if (typeof e == "object") {
|
|
3738
|
+
const n = this.toStringRecord(e);
|
|
3739
|
+
for (const [o, a] of Object.entries(n))
|
|
3740
|
+
s.set(o, a);
|
|
3741
|
+
}
|
|
3742
|
+
return this;
|
|
3743
|
+
}
|
|
3744
|
+
setLanguageData(e, t) {
|
|
3745
|
+
e = H(e).toLowerCase();
|
|
3746
|
+
const i = this.ensureLanguageMap(e), s = this.toStringRecord(t);
|
|
3747
|
+
for (const [n, o] of Object.entries(s))
|
|
3748
|
+
i.set(n, o);
|
|
3749
|
+
return this;
|
|
3750
|
+
}
|
|
3751
|
+
setLanguage(e) {
|
|
3752
|
+
return e = H(e).toLowerCase(), this.currentLanguage = e, this;
|
|
3753
|
+
}
|
|
3754
|
+
getLanguage() {
|
|
3755
|
+
return this.currentLanguage;
|
|
3756
|
+
}
|
|
3757
|
+
hasLanguage(e) {
|
|
3758
|
+
e = H(e).toLowerCase();
|
|
3759
|
+
const t = this.languages.get(e);
|
|
3760
|
+
return t && Object.keys(t).length > 0;
|
|
3761
|
+
}
|
|
3762
|
+
toStringRecord(e, t) {
|
|
3763
|
+
const i = {};
|
|
3764
|
+
for (const [s, n] of Object.entries(e)) {
|
|
3765
|
+
const o = t ? `${t}.${s}` : s;
|
|
3766
|
+
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
3767
|
+
const a = this.toStringRecord(n, o);
|
|
3768
|
+
for (const [c, l] of Object.entries(a))
|
|
3769
|
+
i[c] = String(l);
|
|
3770
|
+
} else
|
|
3771
|
+
i[o] = String(n);
|
|
3772
|
+
}
|
|
3773
|
+
return i;
|
|
3774
|
+
}
|
|
3775
|
+
has(e) {
|
|
3776
|
+
const t = this.resolveLanguageOrder(this.currentLanguage);
|
|
3777
|
+
for (const i of t)
|
|
3778
|
+
if (this.languages.get(i)?.has(e)) return !0;
|
|
3779
|
+
return !1;
|
|
3780
|
+
}
|
|
3781
|
+
get(e) {
|
|
3782
|
+
this.recordUsedKey(e);
|
|
3783
|
+
const t = this.resolveLanguageOrder(this.currentLanguage), i = [];
|
|
3784
|
+
for (const s of t) {
|
|
3785
|
+
const o = this.languages.get(s)?.get(e);
|
|
3786
|
+
if (typeof o < "u")
|
|
3787
|
+
return i.length && this.recordMissing(e, i), o;
|
|
3788
|
+
i.push(s);
|
|
3789
|
+
}
|
|
3790
|
+
i.length && this.recordMissing(e, i);
|
|
3791
|
+
}
|
|
3792
|
+
translate(e, ...t) {
|
|
3793
|
+
if (!e)
|
|
3794
|
+
return "";
|
|
3795
|
+
if (this.currentLanguage === "qqx")
|
|
3796
|
+
return `⧼${e}⧽`;
|
|
3797
|
+
const i = this.get(e);
|
|
3798
|
+
return typeof i > "u" ? this.interpolate(e, ...t) : this.interpolate(i, ...t);
|
|
3799
|
+
}
|
|
3800
|
+
$(...e) {
|
|
3801
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3802
|
+
const s = e[0], n = e.slice(1), o = C(s, n);
|
|
3803
|
+
return this.translate(o);
|
|
3804
|
+
}
|
|
3805
|
+
const i = e;
|
|
3806
|
+
return (s, ...n) => {
|
|
3807
|
+
const o = C(s, n);
|
|
3808
|
+
return this.translate(o, ...i);
|
|
3809
|
+
};
|
|
3810
|
+
}
|
|
3811
|
+
/**
|
|
3812
|
+
* [payload as template] Return the raw message without interpolation
|
|
3813
|
+
* @example
|
|
3814
|
+
* ```
|
|
3815
|
+
* i18n.rawMsg('Hello, {{ name }}')
|
|
3816
|
+
* // good: "你好,{{ name }}"
|
|
3817
|
+
* // missing: "Hello, {{ name }}"
|
|
3818
|
+
* ```
|
|
3819
|
+
*/
|
|
3820
|
+
translateRaw(e) {
|
|
3821
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? e : "";
|
|
3822
|
+
}
|
|
3823
|
+
$raw(...e) {
|
|
3824
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3825
|
+
const i = e[0], s = e.slice(1), n = C(i, s);
|
|
3826
|
+
return this.translateRaw(n);
|
|
3827
|
+
}
|
|
3828
|
+
return (i, ...s) => {
|
|
3829
|
+
const n = C(i, s);
|
|
3830
|
+
return this.translateRaw(n);
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
message(e, ...t) {
|
|
3834
|
+
if (!e)
|
|
3835
|
+
return "";
|
|
3836
|
+
if (this.currentLanguage === "qqx")
|
|
3837
|
+
return `⧼${e}⧽`;
|
|
3838
|
+
const i = this.get(e);
|
|
3839
|
+
return typeof i > "u" ? `(${e})` : this.interpolate(i, ...t);
|
|
3840
|
+
}
|
|
3841
|
+
$$(...e) {
|
|
3842
|
+
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
3843
|
+
const s = e[0], n = e.slice(1), o = C(s, n);
|
|
3844
|
+
return this.message(o);
|
|
3845
|
+
}
|
|
3846
|
+
const i = e;
|
|
3847
|
+
return (s, ...n) => {
|
|
3848
|
+
const o = C(s, n);
|
|
3849
|
+
return this.message(o, ...i);
|
|
3850
|
+
};
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* [payload as key] Return the raw message without interpolation
|
|
3854
|
+
* @example
|
|
3855
|
+
* ```
|
|
3856
|
+
* i18n.rawMsg('greeting')
|
|
3857
|
+
* // good: "你好,{{ name }}"
|
|
3858
|
+
* // missing: "(greeting)"
|
|
3859
|
+
* ```
|
|
3860
|
+
*/
|
|
3861
|
+
messageRaw(e) {
|
|
3862
|
+
return e ? this.currentLanguage === "qqx" ? `⧼${e}⧽` : this.get(e) ?? `(${e})` : "";
|
|
3863
|
+
}
|
|
3864
|
+
$$raw(...e) {
|
|
3865
|
+
if (Array.isArray(e[0]) && e[0].raw) {
|
|
3866
|
+
const i = e[0], s = e.slice(1), n = C(i, s);
|
|
3867
|
+
return this.messageRaw(n);
|
|
3868
|
+
}
|
|
3869
|
+
return (i, ...s) => {
|
|
3870
|
+
const n = C(i, s);
|
|
3871
|
+
return this.messageRaw(n);
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
getAvailableLanguages() {
|
|
3875
|
+
return Array.from(this.languages.keys());
|
|
3876
|
+
}
|
|
3877
|
+
ensureLanguageMap(e) {
|
|
3878
|
+
let t = this.languages.get(e);
|
|
3879
|
+
return t || (t = /* @__PURE__ */ new Map(), this.languages.set(e, t)), t;
|
|
3880
|
+
}
|
|
3881
|
+
resolveLanguageOrder(e) {
|
|
3882
|
+
const t = e;
|
|
3883
|
+
return t === "en" ? ["en"] : [t, "en"];
|
|
3884
|
+
}
|
|
3885
|
+
/**
|
|
3886
|
+
* 获取缺失键报告:
|
|
3887
|
+
* { foo: ['zh', 'zh-hans', 'en'] }
|
|
3888
|
+
*/
|
|
3889
|
+
getMissingReport() {
|
|
3890
|
+
return Object.fromEntries(this.missingKeys.entries());
|
|
3891
|
+
}
|
|
3892
|
+
/**
|
|
3893
|
+
* 清空缺失键记录
|
|
3894
|
+
*/
|
|
3895
|
+
clearMissingReport() {
|
|
3896
|
+
this.missingKeys.clear();
|
|
3897
|
+
}
|
|
3898
|
+
recordMissing(e, t) {
|
|
3899
|
+
if (!t.length) return;
|
|
3900
|
+
const i = this.missingKeys.get(e) || [];
|
|
3901
|
+
for (const s of t)
|
|
3902
|
+
i.includes(s) || i.push(s);
|
|
3903
|
+
this.missingKeys.set(e, i);
|
|
3904
|
+
}
|
|
3905
|
+
recordUsedKey(e) {
|
|
3906
|
+
this.usedKeys.add(e);
|
|
3907
|
+
}
|
|
3908
|
+
getUsedKeys() {
|
|
3909
|
+
return Array.from(this.usedKeys);
|
|
3910
|
+
}
|
|
3911
|
+
generateBlankKeyRecord() {
|
|
3912
|
+
const e = {};
|
|
3913
|
+
for (const t of this.getUsedKeys())
|
|
3914
|
+
e[t] = "";
|
|
3915
|
+
return e;
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
var ms = Object.create, Re = Object.defineProperty, ys = Object.getOwnPropertyDescriptor, vt = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), _t = (r) => {
|
|
3919
|
+
throw TypeError(r);
|
|
3920
|
+
}, ws = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, bs = (r, e) => Re(r, "name", { value: e, configurable: !0 }), vs = (r) => [, , , ms(r?.[vt("metadata")] ?? null)], _s = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], St = (r) => r !== void 0 && typeof r != "function" ? _t("Function expected") : r, Ss = (r, e, t, i, s) => ({ kind: _s[r], name: e, metadata: i, addInitializer: (n) => t._ ? _t("Already initialized") : s.push(St(n || null)) }), Es = (r, e) => ws(e, vt("metadata"), r[3]), ks = (r, e, t, i) => {
|
|
3921
|
+
for (var s = 0, n = r[e >> 1], o = n && n.length; s < o; s++) n[s].call(t);
|
|
3922
|
+
return i;
|
|
3923
|
+
}, $s = (r, e, t, i, s, n) => {
|
|
3924
|
+
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) && ys(s, t));
|
|
3925
|
+
bs(s, t);
|
|
3926
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
3927
|
+
c = Ss(l, t, a = {}, r[3], u), o = (0, i[g])(s, c), a._ = 1, St(o) && (s = o);
|
|
3928
|
+
return Es(r, s), f && Re(s, t, f), h ? l ^ 4 ? n : f : s;
|
|
3929
|
+
}, Et, xe, kt;
|
|
3930
|
+
const Be = new m(
|
|
3931
|
+
m.object({
|
|
3932
|
+
manifest_version: m.const(1).required(),
|
|
3933
|
+
base_language: m.string().required(),
|
|
3934
|
+
last_modified: m.string().required(),
|
|
3935
|
+
languages: m.dict(
|
|
3936
|
+
m.object({
|
|
3937
|
+
file: m.string().required(),
|
|
3938
|
+
fallback: m.string(),
|
|
3939
|
+
data: m.transform(
|
|
3940
|
+
m.dict(m.any()).default({}),
|
|
3941
|
+
(r) => Object.keys(r).length > 0 ? r : void 0
|
|
3942
|
+
)
|
|
3943
|
+
})
|
|
3944
|
+
).required()
|
|
3945
|
+
})
|
|
3946
|
+
);
|
|
3947
|
+
Et = [ne(["wiki", "preferences"]), Lt(
|
|
3948
|
+
m.object({
|
|
3949
|
+
"i18n.index_url": m.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(
|
|
3950
|
+
Fe.I18N_INDEX_URL
|
|
3951
|
+
)
|
|
3952
|
+
}).description("").extra("category", "general")
|
|
3953
|
+
)];
|
|
3954
|
+
class se extends (kt = I) {
|
|
3955
|
+
constructor(e) {
|
|
3956
|
+
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 ps(
|
|
3957
|
+
{},
|
|
3958
|
+
{
|
|
3959
|
+
language: "",
|
|
3960
|
+
globals: {
|
|
3961
|
+
getUrl: (...t) => e.wiki.getUrl(...t)
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
), this.i18nIndexDB = e.storage.createDatabase(
|
|
3965
|
+
"i18n-index",
|
|
3966
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
3967
|
+
// 3 days
|
|
3968
|
+
this.ctx.version,
|
|
3969
|
+
"indexedDB"
|
|
3970
|
+
), this.i18nDataDB = e.storage.createDatabase(
|
|
3971
|
+
"i18n-data",
|
|
3972
|
+
1e3 * 60 * 60 * 24 * 3,
|
|
3973
|
+
// 3 days
|
|
3974
|
+
this.ctx.version,
|
|
3975
|
+
"indexedDB"
|
|
3976
|
+
), 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);
|
|
3977
|
+
}
|
|
3978
|
+
async start() {
|
|
3979
|
+
this.ctx.preferences.registerCustomConfig(
|
|
3980
|
+
"language",
|
|
3981
|
+
m.object({
|
|
3982
|
+
language: m.union([
|
|
3983
|
+
"@user",
|
|
3984
|
+
"@site",
|
|
3985
|
+
m.string().description("Custom language code")
|
|
3986
|
+
]).description("UI language").default("@user")
|
|
3987
|
+
}).description("UI language")
|
|
3988
|
+
);
|
|
3989
|
+
const e = this._indexUrl = await this.ctx.preferences.get("i18n.index_url") || "";
|
|
3990
|
+
if (!e) {
|
|
3991
|
+
this.logger.error("I18n index URL is not set"), this.setupShortcuts();
|
|
3992
|
+
return;
|
|
3993
|
+
}
|
|
3994
|
+
let t = null;
|
|
3995
|
+
try {
|
|
3996
|
+
t = await this.getI18nIndex(e);
|
|
3997
|
+
} catch (n) {
|
|
3998
|
+
this.logger.error("Failed to fetch i18n index", n), this.setupShortcuts();
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
this._indexCache = t, Object.entries(t.languages).forEach(([n, o]) => {
|
|
4002
|
+
o.data && Object.keys(o.data).length > 0 && this.manager.setLanguageData(n, o.data);
|
|
4003
|
+
});
|
|
4004
|
+
const i = await this.ctx.preferences.get("language"), s = this.normalizeLanguageCode(i);
|
|
4005
|
+
this.logger.debug("Settings", { prefer: i, normalized: s });
|
|
4006
|
+
try {
|
|
4007
|
+
await this.switchLanguage(s), this.logger.info(`Initialized for language: ${this.language}`);
|
|
4008
|
+
} catch (n) {
|
|
4009
|
+
this.logger.error("Failed to fetch i18n index", n), this.manager.setLanguage("en");
|
|
4010
|
+
}
|
|
4011
|
+
this.ctx.preferences.registerCustomConfig(
|
|
4012
|
+
"language",
|
|
4013
|
+
m.object({
|
|
4014
|
+
language: m.union([
|
|
4015
|
+
m.const("@user").description(this.$`Same as your personal language`),
|
|
4016
|
+
m.const("@site").description(this.$`Same as the site language`),
|
|
4017
|
+
...this.getAvailableLanguageCodes().map((n) => m.const(n).description(n))
|
|
4018
|
+
]).default("@user")
|
|
4019
|
+
}).description(this.$`InPageEdit UI language`)
|
|
4020
|
+
), this.setupShortcuts(), this.ctx.on("preferences/changed", async ({ changes: n }) => {
|
|
4021
|
+
if (!("language" in n)) return;
|
|
4022
|
+
const o = this.normalizeLanguageCode(n.language);
|
|
4023
|
+
o && o !== this.language && await this.switchLanguage(o);
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
setupShortcuts() {
|
|
4027
|
+
if (!this.manager) throw new Error("I18nManager is not initialized");
|
|
4028
|
+
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));
|
|
4029
|
+
}
|
|
4030
|
+
normalizeLanguageCode(e) {
|
|
4031
|
+
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());
|
|
4032
|
+
}
|
|
4033
|
+
get language() {
|
|
4034
|
+
return this.manager.getLanguage();
|
|
4035
|
+
}
|
|
4036
|
+
/**
|
|
4037
|
+
* 主动设置偏好值(会触发 preferences/changed,从而热切换)
|
|
4038
|
+
*/
|
|
4039
|
+
async setLanguagePreference(e) {
|
|
4040
|
+
await this.ctx.preferences.set("language", e);
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* 直接切换到具体语言(不修改偏好值)
|
|
4044
|
+
*/
|
|
4045
|
+
async switchLanguage(e) {
|
|
4046
|
+
const t = this.normalizeLanguageCode(e);
|
|
4047
|
+
await this.ensureLanguageLoaded(t), this.manager.setLanguage(t), this.ctx.emit("i18n/changed", { ctx: this.ctx, language: t });
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
4050
|
+
* 为指定语言注册(或合并)消息。
|
|
4051
|
+
* - 推荐加命名空间避免冲突:{ myPlugin: { key: 'value' } }
|
|
4052
|
+
* - 若 language 为当前语言,将立即可用;必要时你可以手动触发 UI 刷新或监听 i18n/changed。
|
|
4053
|
+
*/
|
|
4054
|
+
async registerMessages(e, t, i) {
|
|
4055
|
+
const s = i?.namespace ? { [i.namespace]: t } : t;
|
|
4056
|
+
this.manager.setLanguageData(e, s), e === this.language && this.ctx.emit("i18n/changed", { ctx: this.ctx, language: this.language });
|
|
4057
|
+
}
|
|
4058
|
+
/**
|
|
4059
|
+
* 列出可用语言与文件(来源于 index.json)
|
|
4060
|
+
*/
|
|
4061
|
+
getAvailableLanguageCodes() {
|
|
4062
|
+
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
4063
|
+
return Object.entries(this._indexCache.languages).filter(([e, t]) => !t.fallback).reduce((e, [t, i]) => (e.push(t), e), []);
|
|
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 Be(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 Be(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
|
+
}
|
|
4132
|
+
xe = vs(kt);
|
|
4133
|
+
se = $s(xe, 0, "I18nService", Et, se);
|
|
4134
|
+
ks(xe, 1, se);
|
|
4135
|
+
class re extends At {
|
|
3644
4136
|
constructor(e) {
|
|
3645
4137
|
super({
|
|
3646
4138
|
name: "InPageEdit"
|
|
3647
|
-
}), this.version = "0.
|
|
4139
|
+
}), this.version = "0.14.0", this.Endpoints = Fe, this.schema = m, this.config = K(re.DEFAULT_CONFIG, e), this.logger = Dt({
|
|
3648
4140
|
name: "IPE",
|
|
3649
4141
|
color: "#33aaff",
|
|
3650
4142
|
level: this.config.logLevel
|
|
3651
|
-
}), this.#e()
|
|
4143
|
+
}), this.#e();
|
|
3652
4144
|
}
|
|
3653
4145
|
static {
|
|
3654
4146
|
this.DEFAULT_CONFIG = {
|
|
3655
4147
|
apiConfigs: {},
|
|
3656
4148
|
legacyPreferences: {},
|
|
3657
|
-
logLevel:
|
|
4149
|
+
logLevel: qe.info,
|
|
3658
4150
|
storageNamespace: "InPageEdit",
|
|
3659
4151
|
autoloadStyles: !0,
|
|
3660
4152
|
autoInstallCorePlugins: !0
|
|
3661
4153
|
};
|
|
3662
4154
|
}
|
|
3663
4155
|
async #e() {
|
|
3664
|
-
|
|
4156
|
+
await this.#i(), this.config.autoInstallCorePlugins && this.#s(), this.#r();
|
|
4157
|
+
}
|
|
4158
|
+
async #i() {
|
|
4159
|
+
this.plugin(se), this.plugin(Xt, this.config.apiConfigs), this.plugin(J), this.plugin(oi), this.plugin(Ci), this.plugin(ie), this.plugin(Gi, { dbName: this.config.storageNamespace }), this.plugin(te), this.plugin(Yi), this.plugin(Ee), this.#t([
|
|
4160
|
+
"i18n",
|
|
4161
|
+
"$",
|
|
4162
|
+
"$$",
|
|
3665
4163
|
"api",
|
|
3666
4164
|
"currentPage",
|
|
3667
4165
|
"resourceLoader",
|
|
@@ -3677,68 +4175,68 @@ class te extends ft {
|
|
|
3677
4175
|
"getMainpageUrl"
|
|
3678
4176
|
]);
|
|
3679
4177
|
}
|
|
3680
|
-
#
|
|
3681
|
-
if (
|
|
4178
|
+
#t(e) {
|
|
4179
|
+
if (!Array.isArray(e) || e.length === 0) return this;
|
|
3682
4180
|
for (const t of e) {
|
|
3683
|
-
const i = this[
|
|
4181
|
+
const i = this[re.internal][t];
|
|
3684
4182
|
i?.type === "service" && (i.builtin = !0);
|
|
3685
4183
|
}
|
|
3686
4184
|
return this;
|
|
3687
4185
|
}
|
|
3688
4186
|
// TODO: 这里不应该硬编码,暂时先这样
|
|
3689
|
-
async #
|
|
4187
|
+
async #s() {
|
|
3690
4188
|
[
|
|
3691
|
-
import("./index-
|
|
3692
|
-
import("./index-
|
|
4189
|
+
import("./index-CVTBg5O9.js").then(({ PluginAnalytics: t }) => t),
|
|
4190
|
+
import("./index-DGtq21uW.js").then(
|
|
3693
4191
|
({ PluginInArticleLinks: t }) => t
|
|
3694
4192
|
),
|
|
3695
|
-
import("./index-
|
|
3696
|
-
import("./index-
|
|
4193
|
+
import("./index-D3iZhRMJ.js").then(({ PluginPluginStore: t }) => t),
|
|
4194
|
+
import("./index-BKIf3i0I.js").then(
|
|
3697
4195
|
({ PluginPreferencesUI: t }) => t
|
|
3698
4196
|
),
|
|
3699
|
-
import("./index-
|
|
3700
|
-
import("./index-
|
|
3701
|
-
import("./index-
|
|
4197
|
+
import("./index-DXL7teb0.js").then(({ PluginQuickEdit: t }) => t),
|
|
4198
|
+
import("./index-Ci82vLXg.js").then(({ PluginQuickMove: t }) => t),
|
|
4199
|
+
import("./index-DjPpAyfE.js").then(
|
|
3702
4200
|
({ PluginQuickPreview: t }) => t
|
|
3703
4201
|
),
|
|
3704
|
-
import("./index-
|
|
3705
|
-
import("./index-
|
|
4202
|
+
import("./index-BrtFJ-M0.js").then(({ PluginQuickDiff: t }) => t),
|
|
4203
|
+
import("./index-CQr1DJ8n.js").then(
|
|
3706
4204
|
({ PluginQuickRedirect: t }) => t
|
|
3707
4205
|
),
|
|
3708
|
-
import("./index-
|
|
4206
|
+
import("./index-rpiO9fpc.js").then(({ PluginToolbox: t }) => t)
|
|
3709
4207
|
].forEach(async (t) => {
|
|
3710
4208
|
this.plugin(await t);
|
|
3711
4209
|
});
|
|
3712
4210
|
}
|
|
3713
4211
|
// TODO: 应该抽象到 PluginTheme 中去,暂时先硬编码
|
|
3714
|
-
async #
|
|
4212
|
+
async #r() {
|
|
3715
4213
|
this.inject(["resourceLoader"], (e) => {
|
|
3716
4214
|
this.config.autoloadStyles && e.resourceLoader.loadStyle(import.meta.resolve("./style.css"));
|
|
3717
4215
|
});
|
|
3718
4216
|
}
|
|
3719
4217
|
async withInject(e) {
|
|
3720
|
-
const { promise: t, resolve: i } =
|
|
3721
|
-
return this.inject(e, (
|
|
3722
|
-
i(
|
|
4218
|
+
const { promise: t, resolve: i } = je();
|
|
4219
|
+
return this.inject(e, (s) => {
|
|
4220
|
+
i(s);
|
|
3723
4221
|
}), t;
|
|
3724
4222
|
}
|
|
3725
4223
|
}
|
|
3726
4224
|
export {
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
b,
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
4225
|
+
qe as $,
|
|
4226
|
+
Xt as A,
|
|
4227
|
+
J as C,
|
|
4228
|
+
re as I,
|
|
4229
|
+
Ci as M,
|
|
4230
|
+
ee as N,
|
|
4231
|
+
ve as P,
|
|
4232
|
+
oi as R,
|
|
4233
|
+
Dt as S,
|
|
4234
|
+
te as W,
|
|
4235
|
+
Gi as a,
|
|
4236
|
+
v as b,
|
|
4237
|
+
ie as c,
|
|
4238
|
+
Yi as d,
|
|
4239
|
+
Ee as e,
|
|
4240
|
+
Ct as m
|
|
3743
4241
|
};
|
|
3744
|
-
//# sourceMappingURL=index-
|
|
4242
|
+
//# sourceMappingURL=index-19CgGBI0.js.map
|