@inpageedit/core 0.14.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BasePlugin-DD7l-5Xw.js → BasePlugin-BCVSn9QJ.js} +2 -2
- package/dist/{BasePlugin-DD7l-5Xw.js.map → BasePlugin-BCVSn9QJ.js.map} +1 -1
- package/dist/InputBox-CZ1v4_l3.js +50 -0
- package/dist/InputBox-CZ1v4_l3.js.map +1 -0
- package/dist/PluginImagesUsed-Bq_C_rgg.js +90 -0
- package/dist/PluginImagesUsed-Bq_C_rgg.js.map +1 -0
- package/dist/{PluginPrefSync-CbFuuC19.js → PluginPrefSync-DP5NyPnI.js} +4 -4
- package/dist/{PluginPrefSync-CbFuuC19.js.map → PluginPrefSync-DP5NyPnI.js.map} +1 -1
- package/dist/{PluginStoreApp-MbC3G9tu.js → PluginStoreApp-_YWpLgfs.js} +2 -2
- package/dist/{PluginStoreApp-MbC3G9tu.js.map → PluginStoreApp-_YWpLgfs.js.map} +1 -1
- package/dist/PluginTemplatesUsed-DS_rHctR.js +76 -0
- package/dist/PluginTemplatesUsed-DS_rHctR.js.map +1 -0
- package/dist/Preferences-DqtjY7XU.js +1541 -0
- package/dist/Preferences-DqtjY7XU.js.map +1 -0
- package/dist/browser-DR-yCqVg.js +1160 -0
- package/dist/browser-DR-yCqVg.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/{index-BpQ6VGMz.js → index-B9VO3swL.js} +108 -63
- package/dist/index-B9VO3swL.js.map +1 -0
- package/dist/{index-BanevHQ2.js → index-C3t-Xj3e.js} +85 -82
- package/dist/index-C3t-Xj3e.js.map +1 -0
- package/dist/{index-WfXtYVMt.js → index-CS1kidKF.js} +149 -117
- package/dist/index-CS1kidKF.js.map +1 -0
- package/dist/index-Cb2_vqBl.js +44 -0
- package/dist/index-Cb2_vqBl.js.map +1 -0
- package/dist/{index-B3jld2sl.js → index-CbdkXGs7.js} +4 -4
- package/dist/{index-B3jld2sl.js.map → index-CbdkXGs7.js.map} +1 -1
- package/dist/{index-DxaqNWv4.js → index-CcAmmXbb.js} +904 -704
- package/dist/index-CcAmmXbb.js.map +1 -0
- package/dist/index-Cq8xPcEY.js +170 -0
- package/dist/index-Cq8xPcEY.js.map +1 -0
- package/dist/{index-DensW9qt.js → index-DPA1ptYq.js} +5 -5
- package/dist/index-DPA1ptYq.js.map +1 -0
- package/dist/{index-BjDTD66_.js → index-DVvsTsLI.js} +29 -15
- package/dist/index-DVvsTsLI.js.map +1 -0
- package/dist/{index-CnR6CqkM.js → index-DjyjqpeO.js} +2 -2
- package/dist/{index-CnR6CqkM.js.map → index-DjyjqpeO.js.map} +1 -1
- package/dist/index-FvMu0Ka0.js +342 -0
- package/dist/index-FvMu0Ka0.js.map +1 -0
- package/dist/index-mFwJhDwE.js +168 -0
- package/dist/index-mFwJhDwE.js.map +1 -0
- package/dist/{index-De25v1_Q.js → index-n5KKWE9v.js} +6 -6
- package/dist/index-n5KKWE9v.js.map +1 -0
- package/dist/{index-DKCZDN-Q.js → index-rKL4D_7I.js} +5 -5
- package/dist/{index-DKCZDN-Q.js.map → index-rKL4D_7I.js.map} +1 -1
- package/dist/index.d.ts +334 -148
- package/dist/index.js +5 -5
- package/dist/models/index.js +1 -1
- package/dist/plugins/index.js +18 -14
- package/dist/plugins/index.js.map +1 -1
- package/dist/services/index.js +9 -8
- package/dist/style.css +1 -1
- package/lib/index.umd.js +14 -12
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +4 -2
- package/dist/InputBox-nQKtiWtZ.js +0 -30
- package/dist/InputBox-nQKtiWtZ.js.map +0 -1
- package/dist/Preferences-C10tZMl1.js +0 -2701
- package/dist/Preferences-C10tZMl1.js.map +0 -1
- package/dist/index-7R2LfhNn.js +0 -220
- package/dist/index-7R2LfhNn.js.map +0 -1
- package/dist/index-BXNyXvre.js +0 -116
- package/dist/index-BXNyXvre.js.map +0 -1
- package/dist/index-BanevHQ2.js.map +0 -1
- package/dist/index-BjDTD66_.js.map +0 -1
- package/dist/index-BpQ6VGMz.js.map +0 -1
- package/dist/index-De25v1_Q.js.map +0 -1
- package/dist/index-DensW9qt.js.map +0 -1
- package/dist/index-DxaqNWv4.js.map +0 -1
- package/dist/index-WfXtYVMt.js.map +0 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { u as mt, c as wt, a as yt } from "./index-DVvsTsLI.js";
|
|
2
|
+
import { c as L, q as _e, I as j, S as p, d as Pe, i as bt, p as O, R as vt, E as Re, j as _t } from "./Preferences-DqtjY7XU.js";
|
|
3
|
+
import { J as $e, e as $t, A as St } from "./browser-DR-yCqVg.js";
|
|
4
|
+
import { j as E, P as xt } from "./index-CM_6yF2v.js";
|
|
5
|
+
var De = /* @__PURE__ */ ((n) => (n[n.debug = -1] = "debug", n[n.log = 0] = "log", n[n.info = 1] = "info", n[n.warn = 2] = "warn", n[n.error = 3] = "error", n[n.silent = 4] = "silent", n))(De || {});
|
|
6
|
+
const te = globalThis || window, ie = Symbol.for("__IPE_LOGGER_COLOR_MAP__");
|
|
7
|
+
te[ie] || (te[ie] = /* @__PURE__ */ new Map());
|
|
8
|
+
const Q = te[ie];
|
|
9
|
+
function F(n) {
|
|
9
10
|
let e = 2166136261;
|
|
10
|
-
for (let t = 0; t <
|
|
11
|
-
e ^=
|
|
11
|
+
for (let t = 0; t < n.length; t++)
|
|
12
|
+
e ^= n.charCodeAt(t), e = (e >>> 0) * 16777619;
|
|
12
13
|
return e >>> 0;
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
+
const Se = [
|
|
15
16
|
[350, 360],
|
|
16
17
|
[0, 15],
|
|
17
18
|
[15, 30],
|
|
@@ -23,41 +24,41 @@ const me = [
|
|
|
23
24
|
[140, 160],
|
|
24
25
|
[160, 180]
|
|
25
26
|
];
|
|
26
|
-
function
|
|
27
|
-
const t =
|
|
28
|
-
let
|
|
27
|
+
function kt(n, e) {
|
|
28
|
+
const t = Se.length, i = F(n) % t, [s, r] = Se[i], o = r - s, a = F(n + ":" + e), c = s + a % (o || 1), l = F(n + ":s"), h = F(n + ":l");
|
|
29
|
+
let u, f;
|
|
29
30
|
if (e === "name")
|
|
30
|
-
|
|
31
|
+
u = 62 + l % 18, f = 30 + h % 12;
|
|
31
32
|
else {
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
const d = c >= 0 && c < 50 || c > 330 && c < 360, g = c >= 200 && c <= 300;
|
|
34
|
+
u = 55 + l % 20, g ? f = 55 + h % 8 : d ? f = 48 + h % 6 : f = 50 + h % 8, u < 60 && (u += 5);
|
|
34
35
|
}
|
|
35
|
-
return `hsl(${c}, ${
|
|
36
|
+
return `hsl(${c}, ${u}%, ${f}%)`;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function z(n, e) {
|
|
38
39
|
if (e)
|
|
39
|
-
return
|
|
40
|
-
const t =
|
|
40
|
+
return Q.set(n, e), e;
|
|
41
|
+
const t = Q.get(n);
|
|
41
42
|
if (t) return t;
|
|
42
|
-
const i =
|
|
43
|
-
return
|
|
43
|
+
const i = n.startsWith("name:") ? "name" : "group", s = kt(n, i);
|
|
44
|
+
return Q.set(n, s), s;
|
|
44
45
|
}
|
|
45
|
-
class
|
|
46
|
+
class oe {
|
|
46
47
|
/**
|
|
47
48
|
* Note: constructor returns a callable Proxy so that you can do `logger('group')`.
|
|
48
49
|
*/
|
|
49
50
|
constructor(e = {}) {
|
|
50
51
|
this._custom = (t) => {
|
|
51
|
-
if (!this._enabled(t.level)) return
|
|
52
|
-
const [i,
|
|
53
|
-
return this._consoleMethod(t.method).bind(console, i, ...
|
|
52
|
+
if (!this._enabled(t.level)) return xe;
|
|
53
|
+
const [i, s] = this._prefix(t.label);
|
|
54
|
+
return this._consoleMethod(t.method).bind(console, i, ...s);
|
|
54
55
|
}, this._name = e.name, this._nameColor = e.color, this._groupPath = e._groupPath ? [...e._groupPath] : [], this._dynamicLevels = { ...e._dynamicLevels }, this._levelRef = e._levelRef ?? {
|
|
55
56
|
value: e.level ?? 1
|
|
56
57
|
/* info */
|
|
57
|
-
}, this._name &&
|
|
58
|
+
}, this._name && z(`name:${this._name}`, this._nameColor), this._installBuiltinLevels();
|
|
58
59
|
for (const t of Object.keys(this._dynamicLevels))
|
|
59
60
|
this._installLevelGetter(t, this._dynamicLevels[t]);
|
|
60
|
-
return
|
|
61
|
+
return Ct(this);
|
|
61
62
|
}
|
|
62
63
|
// ---------- public API ----------
|
|
63
64
|
get level() {
|
|
@@ -68,7 +69,7 @@ class te {
|
|
|
68
69
|
}
|
|
69
70
|
/** Create a sub-logger with a group label */
|
|
70
71
|
group(e, t) {
|
|
71
|
-
return e &&
|
|
72
|
+
return e && z(`group:${e}`, t?.color), new oe({
|
|
72
73
|
name: this._name,
|
|
73
74
|
color: this._nameColor,
|
|
74
75
|
_groupPath: [...this._groupPath, e],
|
|
@@ -107,10 +108,10 @@ class te {
|
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
_method(e) {
|
|
110
|
-
const t =
|
|
111
|
-
if (!this._enabled(t.level)) return
|
|
112
|
-
const [i,
|
|
113
|
-
return this._consoleMethod(e).bind(console, i, ...
|
|
111
|
+
const t = Et[e];
|
|
112
|
+
if (!this._enabled(t.level)) return xe;
|
|
113
|
+
const [i, s] = this._prefix(t.label);
|
|
114
|
+
return this._consoleMethod(e).bind(console, i, ...s);
|
|
114
115
|
}
|
|
115
116
|
_consoleMethod(e) {
|
|
116
117
|
return (console[e] || console.log).bind(console);
|
|
@@ -122,53 +123,53 @@ class te {
|
|
|
122
123
|
const t = [];
|
|
123
124
|
let i = "";
|
|
124
125
|
if (this._name) {
|
|
125
|
-
const
|
|
126
|
+
const s = z(`name:${this._name}`, this._nameColor);
|
|
126
127
|
i += `%c${this._name}%c`, t.push(
|
|
127
|
-
`background:${
|
|
128
|
-
|
|
128
|
+
`background:${s}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,
|
|
129
|
+
ke
|
|
129
130
|
);
|
|
130
131
|
}
|
|
131
132
|
if (e && (i += ` ${e}`), this._groupPath.length) {
|
|
132
|
-
const
|
|
133
|
-
i += ` %c${
|
|
133
|
+
const s = this._groupPath.join("/"), r = z(`group:${s}`);
|
|
134
|
+
i += ` %c${s}%c`, t.push(`color:${r}; text-decoration: underline;`, ke);
|
|
134
135
|
}
|
|
135
136
|
return [i, t];
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
const
|
|
139
|
-
},
|
|
139
|
+
const xe = () => {
|
|
140
|
+
}, ke = "color:inherit; background:transparent; text-decoration:none;", Et = {
|
|
140
141
|
debug: { level: -1, label: "", method: "debug" },
|
|
141
142
|
log: { level: 0, label: "", method: "log" },
|
|
142
143
|
info: { level: 1, label: "[I]", method: "info" },
|
|
143
144
|
warn: { level: 2, label: "[W]", method: "warn" },
|
|
144
145
|
error: { level: 3, label: "[E]", method: "error" }
|
|
145
146
|
};
|
|
146
|
-
function
|
|
147
|
+
function Ct(n) {
|
|
147
148
|
const e = function(t, i) {
|
|
148
|
-
return
|
|
149
|
+
return n.group(t, i);
|
|
149
150
|
};
|
|
150
151
|
return new Proxy(e, {
|
|
151
|
-
get(t, i,
|
|
152
|
-
return
|
|
152
|
+
get(t, i, s) {
|
|
153
|
+
return n[i];
|
|
153
154
|
},
|
|
154
|
-
set(t, i,
|
|
155
|
-
return
|
|
155
|
+
set(t, i, s) {
|
|
156
|
+
return n[i] = s, !0;
|
|
156
157
|
},
|
|
157
|
-
apply(t, i,
|
|
158
|
-
return
|
|
158
|
+
apply(t, i, s) {
|
|
159
|
+
return n.group(s[0], s[1]);
|
|
159
160
|
},
|
|
160
161
|
has(t, i) {
|
|
161
|
-
return i in
|
|
162
|
+
return i in n;
|
|
162
163
|
}
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
|
-
function
|
|
166
|
-
return new
|
|
166
|
+
function It(n) {
|
|
167
|
+
return new oe(n);
|
|
167
168
|
}
|
|
168
|
-
class
|
|
169
|
+
class Lt {
|
|
169
170
|
constructor(e, t = {}) {
|
|
170
|
-
this.ctx = e, location?.href && t?.baseURL?.toString()?.startsWith("/") && (t.baseURL = new URL(t.baseURL, location.origin));
|
|
171
|
-
const i = new
|
|
171
|
+
this.ctx = e, this.options = t, this._apiClients = /* @__PURE__ */ new Map(), location?.href && t?.baseURL?.toString()?.startsWith("/") && (t.baseURL = new URL(t.baseURL, location.origin));
|
|
172
|
+
const i = this.api = new $e({
|
|
172
173
|
baseURL: t.baseURL.toString(),
|
|
173
174
|
fexiosConfigs: {
|
|
174
175
|
headers: {
|
|
@@ -179,23 +180,41 @@ class pt {
|
|
|
179
180
|
},
|
|
180
181
|
throwOnApiError: !0
|
|
181
182
|
});
|
|
182
|
-
e.set("api", i);
|
|
183
|
+
e.set("api", i), e.set("apiService", this);
|
|
184
|
+
}
|
|
185
|
+
getClientByFileRepo(e) {
|
|
186
|
+
const t = new URL(`${e.scriptDirUrl}/api.php`, location.origin), i = t.toString();
|
|
187
|
+
if (i === this.ctx.root.config.apiConfigs.baseURL?.toString())
|
|
188
|
+
return this.ctx.api;
|
|
189
|
+
if (!this._apiClients.has(i)) {
|
|
190
|
+
const s = t.origin === location.origin, r = {
|
|
191
|
+
baseURL: t.toString(),
|
|
192
|
+
throwOnApiError: !0
|
|
193
|
+
}, o = s ? new $e(r) : new $t(r);
|
|
194
|
+
o.request.on("beforeRequest", (a) => {
|
|
195
|
+
a.headers = o.request.mergeHeaders(a.headers, {
|
|
196
|
+
"x-api-user-agent": null,
|
|
197
|
+
"x-mw-token-name": null
|
|
198
|
+
});
|
|
199
|
+
}), this._apiClients.set(i, o);
|
|
200
|
+
}
|
|
201
|
+
return this._apiClients.get(i);
|
|
183
202
|
}
|
|
184
203
|
}
|
|
185
|
-
var
|
|
186
|
-
throw TypeError(
|
|
187
|
-
},
|
|
188
|
-
for (var
|
|
204
|
+
var At = Object.create, ae = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, Te = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), Me = (n) => {
|
|
205
|
+
throw TypeError(n);
|
|
206
|
+
}, Rt = (n, e, t) => e in n ? ae(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, Dt = (n, e) => ae(n, "name", { value: e, configurable: !0 }), Tt = (n) => [, , , At(n?.[Te("metadata")] ?? null)], Mt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ue = (n) => n !== void 0 && typeof n != "function" ? Me("Function expected") : n, Ut = (n, e, t, i, s) => ({ kind: Mt[n], name: e, metadata: i, addInitializer: (r) => t._ ? Me("Already initialized") : s.push(Ue(r || null)) }), Bt = (n, e) => Rt(e, Te("metadata"), n[3]), Ot = (n, e, t, i) => {
|
|
207
|
+
for (var s = 0, r = n[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
|
|
189
208
|
return i;
|
|
190
|
-
},
|
|
191
|
-
var o, a, c, l = e & 7, h = !1,
|
|
192
|
-
|
|
209
|
+
}, Nt = (n, e, t, i, s, r) => {
|
|
210
|
+
var o, a, c, l = e & 7, h = !1, u = 0, f = n[u] || (n[u] = []), d = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Pt(s, t));
|
|
211
|
+
Dt(s, t);
|
|
193
212
|
for (var g = i.length - 1; g >= 0; g--)
|
|
194
|
-
c =
|
|
195
|
-
return
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
class
|
|
213
|
+
c = Ut(l, t, a = {}, n[3], f), o = (0, i[g])(s, c), a._ = 1, Ue(o) && (s = o);
|
|
214
|
+
return Bt(n, s), d && ae(s, t, d), h ? l ^ 4 ? r : d : s;
|
|
215
|
+
}, Be, le, Oe;
|
|
216
|
+
Be = [j(["wiki", "wikiTitle"])];
|
|
217
|
+
class H extends (Oe = L) {
|
|
199
218
|
constructor(e) {
|
|
200
219
|
super(e, "currentPage", !1), this.ctx = e, this.url = new URL(window.location.href), this.isMainPage = void 0, this.wikiTitle = void 0;
|
|
201
220
|
}
|
|
@@ -209,17 +228,17 @@ class N extends (Ae = C) {
|
|
|
209
228
|
window.removeEventListener("popstate", this.#t.bind(this));
|
|
210
229
|
}
|
|
211
230
|
async #e() {
|
|
212
|
-
await this.#
|
|
231
|
+
await this.#s(), await this.#n();
|
|
213
232
|
}
|
|
214
233
|
#i() {
|
|
215
234
|
const e = Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");
|
|
216
235
|
if (window[e])
|
|
217
236
|
return;
|
|
218
237
|
const t = history.pushState, i = history.replaceState;
|
|
219
|
-
history.pushState = function(
|
|
220
|
-
t.apply(this, [
|
|
221
|
-
}, history.replaceState = function(
|
|
222
|
-
i.apply(this, [
|
|
238
|
+
history.pushState = function(s, r, o) {
|
|
239
|
+
t.apply(this, [s, r, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: s }));
|
|
240
|
+
}, history.replaceState = function(s, r, o) {
|
|
241
|
+
i.apply(this, [s, r, o]), window.dispatchEvent(new PopStateEvent("popstate", { state: s }));
|
|
223
242
|
}, window[e] = !0;
|
|
224
243
|
}
|
|
225
244
|
async #t(e) {
|
|
@@ -230,19 +249,19 @@ class N extends (Ae = C) {
|
|
|
230
249
|
return this.url.searchParams;
|
|
231
250
|
}
|
|
232
251
|
get canonicalUrl() {
|
|
233
|
-
const e = (
|
|
252
|
+
const e = (_e('link[rel="alternate"][hreflang="x-default"]') || _e('link[rel="canonical"]'))?.href;
|
|
234
253
|
let t = null;
|
|
235
254
|
return e && (t = new URL(e, location.origin)), Reflect.defineProperty(this, "canonicalUrl", {
|
|
236
255
|
get: () => t
|
|
237
256
|
}), t;
|
|
238
257
|
}
|
|
239
|
-
async #
|
|
258
|
+
async #n() {
|
|
240
259
|
const t = this.wikiTitle?.getMainDBKey() === this.ctx.wiki.mainPageName;
|
|
241
260
|
return Reflect.defineProperty(this, "isMainPage", {
|
|
242
261
|
get: () => t
|
|
243
262
|
}), t;
|
|
244
263
|
}
|
|
245
|
-
async #
|
|
264
|
+
async #s() {
|
|
246
265
|
let e = null;
|
|
247
266
|
return this.canonicalUrl ? e = await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl) : e = await this.ctx.wikiTitle.newTitleFromUrl(this.url), Object.freeze(e), Reflect.defineProperty(this, "wikiTitle", {
|
|
248
267
|
get: () => e
|
|
@@ -252,10 +271,10 @@ class N extends (Ae = C) {
|
|
|
252
271
|
return this.params.get("action") || "view";
|
|
253
272
|
}
|
|
254
273
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
class
|
|
274
|
+
le = Tt(Oe);
|
|
275
|
+
H = Nt(le, 0, "CurrentPageService", Be, H);
|
|
276
|
+
Ot(le, 1, H);
|
|
277
|
+
class jt extends L {
|
|
259
278
|
constructor(e) {
|
|
260
279
|
super(e, "resourceLoader", !0), this.ctx = e;
|
|
261
280
|
}
|
|
@@ -265,8 +284,8 @@ class Et extends C {
|
|
|
265
284
|
loadScript(e, t) {
|
|
266
285
|
if (!e)
|
|
267
286
|
return Promise.resolve(null);
|
|
268
|
-
const i = `script:${e}`,
|
|
269
|
-
return
|
|
287
|
+
const i = `script:${e}`, s = document.querySelector(`[data-ipe="${i}"]`);
|
|
288
|
+
return s ? Promise.resolve(s) : new Promise((o, a) => {
|
|
270
289
|
const c = document.createElement("script");
|
|
271
290
|
c.src = e, c.dataset.ipe = i, t && Object.entries(t).forEach(([l, h]) => {
|
|
272
291
|
typeof h > "u" || h === !1 || h === null ? c.removeAttribute(l) : c.setAttribute(l, h);
|
|
@@ -276,11 +295,11 @@ class Et extends C {
|
|
|
276
295
|
loadStyle(e, t) {
|
|
277
296
|
if (!e)
|
|
278
297
|
return Promise.resolve(null);
|
|
279
|
-
const i = `style:${e}`,
|
|
280
|
-
return
|
|
298
|
+
const i = `style:${e}`, s = document.querySelector(`[data-ipe="${i}"]`);
|
|
299
|
+
return s ? Promise.resolve(s) : new Promise((o, a) => {
|
|
281
300
|
const c = document.createElement("link");
|
|
282
|
-
c.rel = "stylesheet", c.href = e, c.dataset.ipe = i, t && Object.entries(t).forEach(([h,
|
|
283
|
-
typeof
|
|
301
|
+
c.rel = "stylesheet", c.href = e, c.dataset.ipe = i, t && Object.entries(t).forEach(([h, u]) => {
|
|
302
|
+
typeof u > "u" || u === !1 || u === null ? c.removeAttribute(h) : c.setAttribute(h, u);
|
|
284
303
|
}), (document.querySelector('meta[name="ipe-styles"]') || (() => {
|
|
285
304
|
const h = document.createElement("meta");
|
|
286
305
|
return h.id = "ipe-styles", h.name = "ipe-styles", document.head.insertAdjacentElement("afterbegin", h), h;
|
|
@@ -304,40 +323,40 @@ class Et extends C {
|
|
|
304
323
|
return e.startsWith("http") || e.startsWith("//") ? e : import.meta.resolve(e);
|
|
305
324
|
}
|
|
306
325
|
}
|
|
307
|
-
const
|
|
308
|
-
function
|
|
309
|
-
return typeof
|
|
326
|
+
const J = Object.keys;
|
|
327
|
+
function Ft(n) {
|
|
328
|
+
return typeof n == "boolean";
|
|
310
329
|
}
|
|
311
|
-
function
|
|
312
|
-
return
|
|
330
|
+
function zt(n) {
|
|
331
|
+
return n && typeof n.nodeType == "number";
|
|
313
332
|
}
|
|
314
|
-
function
|
|
315
|
-
return typeof
|
|
333
|
+
function ce(n) {
|
|
334
|
+
return typeof n == "string";
|
|
316
335
|
}
|
|
317
|
-
function
|
|
318
|
-
return typeof
|
|
336
|
+
function Ne(n) {
|
|
337
|
+
return typeof n == "number";
|
|
319
338
|
}
|
|
320
|
-
function
|
|
321
|
-
return typeof
|
|
339
|
+
function D(n) {
|
|
340
|
+
return typeof n == "object" ? n !== null : N(n);
|
|
322
341
|
}
|
|
323
|
-
function
|
|
324
|
-
return typeof
|
|
342
|
+
function N(n) {
|
|
343
|
+
return typeof n == "function";
|
|
325
344
|
}
|
|
326
|
-
function
|
|
327
|
-
return !!(
|
|
345
|
+
function Kt(n) {
|
|
346
|
+
return !!(n && n.isComponent);
|
|
328
347
|
}
|
|
329
|
-
function
|
|
330
|
-
return
|
|
348
|
+
function Ht(n) {
|
|
349
|
+
return D(n) && typeof n.length == "number" && typeof n.nodeType != "number";
|
|
331
350
|
}
|
|
332
|
-
function
|
|
333
|
-
if (
|
|
334
|
-
for (const t of
|
|
335
|
-
e(
|
|
351
|
+
function ne(n, e) {
|
|
352
|
+
if (n)
|
|
353
|
+
for (const t of J(n))
|
|
354
|
+
e(n[t], t);
|
|
336
355
|
}
|
|
337
|
-
function
|
|
338
|
-
return
|
|
356
|
+
function Wt(n) {
|
|
357
|
+
return D(n) && "current" in n;
|
|
339
358
|
}
|
|
340
|
-
const
|
|
359
|
+
const se = {
|
|
341
360
|
animationIterationCount: 0,
|
|
342
361
|
borderImageOutset: 0,
|
|
343
362
|
borderImageSlice: 0,
|
|
@@ -382,30 +401,30 @@ const Q = {
|
|
|
382
401
|
strokeOpacity: 0,
|
|
383
402
|
strokeWidth: 0
|
|
384
403
|
};
|
|
385
|
-
function
|
|
386
|
-
return
|
|
404
|
+
function qt(n, e) {
|
|
405
|
+
return n + e.charAt(0).toUpperCase() + e.substring(1);
|
|
387
406
|
}
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
407
|
+
const Gt = ["Webkit", "ms", "Moz", "O"];
|
|
408
|
+
J(se).forEach((n) => {
|
|
409
|
+
Gt.forEach((e) => {
|
|
410
|
+
se[qt(e, n)] = 0;
|
|
392
411
|
});
|
|
393
412
|
});
|
|
394
|
-
const
|
|
395
|
-
var
|
|
396
|
-
return
|
|
397
|
-
})(
|
|
398
|
-
function
|
|
399
|
-
return
|
|
413
|
+
const Xt = Symbol.for("jsx-dom:type");
|
|
414
|
+
var je = /* @__PURE__ */ (function(n) {
|
|
415
|
+
return n.ShadowRoot = "ShadowRoot", n;
|
|
416
|
+
})(je || {});
|
|
417
|
+
function Yt(n) {
|
|
418
|
+
return n != null && n[Xt] === je.ShadowRoot;
|
|
400
419
|
}
|
|
401
|
-
const
|
|
402
|
-
function
|
|
403
|
-
return !
|
|
420
|
+
const Vt = "http://www.w3.org/2000/svg", Jt = "http://www.w3.org/1999/xlink", Zt = "http://www.w3.org/XML/1998/namespace";
|
|
421
|
+
function Fe(n) {
|
|
422
|
+
return !Ft(n) && n != null;
|
|
404
423
|
}
|
|
405
|
-
function
|
|
406
|
-
return Array.isArray(
|
|
424
|
+
function re(n) {
|
|
425
|
+
return Array.isArray(n) ? n.map(re).filter(Boolean).join(" ") : D(n) ? Symbol.iterator in n ? re(Array.from(n)) : J(n).filter((e) => n[e]).join(" ") : Fe(n) ? "" + n : "";
|
|
407
426
|
}
|
|
408
|
-
const
|
|
427
|
+
const Qt = {
|
|
409
428
|
animate: 0,
|
|
410
429
|
circle: 0,
|
|
411
430
|
clipPath: 0,
|
|
@@ -460,83 +479,83 @@ const Ut = {
|
|
|
460
479
|
tspan: 0,
|
|
461
480
|
use: 0,
|
|
462
481
|
view: 0
|
|
463
|
-
},
|
|
464
|
-
function
|
|
482
|
+
}, ei = /^(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)/;
|
|
483
|
+
function ti(n) {
|
|
465
484
|
const e = document.createDocumentFragment();
|
|
466
|
-
return
|
|
485
|
+
return Z(n.children, e), e;
|
|
467
486
|
}
|
|
468
|
-
function
|
|
487
|
+
function ii(n, e, t) {
|
|
469
488
|
e = {
|
|
470
489
|
...e,
|
|
471
490
|
children: t
|
|
472
491
|
};
|
|
473
|
-
const i = new
|
|
474
|
-
return "ref" in e &&
|
|
492
|
+
const i = new n(e), s = i.render();
|
|
493
|
+
return "ref" in e && he(e.ref, i), s;
|
|
475
494
|
}
|
|
476
|
-
function m(
|
|
495
|
+
function m(n, e) {
|
|
477
496
|
let { children: t, ...i } = e;
|
|
478
|
-
!i.namespaceURI &&
|
|
497
|
+
!i.namespaceURI && Qt[n] === 0 && (i = {
|
|
479
498
|
...i,
|
|
480
|
-
namespaceURI:
|
|
499
|
+
namespaceURI: Vt
|
|
481
500
|
});
|
|
482
|
-
let
|
|
483
|
-
if (
|
|
484
|
-
if (
|
|
501
|
+
let s;
|
|
502
|
+
if (ce(n)) {
|
|
503
|
+
if (s = i.namespaceURI ? document.createElementNS(i.namespaceURI, n) : document.createElement(n), ri(i, s), Z(t, s), s instanceof window.HTMLSelectElement && i.value != null)
|
|
485
504
|
if (i.multiple === !0 && Array.isArray(i.value)) {
|
|
486
505
|
const r = i.value.map((o) => String(o));
|
|
487
|
-
|
|
506
|
+
s.querySelectorAll("option").forEach(
|
|
488
507
|
(o) => o.selected = r.includes(o.value)
|
|
489
508
|
);
|
|
490
509
|
} else
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
} else if (
|
|
494
|
-
|
|
495
|
-
...
|
|
510
|
+
s.value = i.value;
|
|
511
|
+
he(i.ref, s);
|
|
512
|
+
} else if (N(n))
|
|
513
|
+
D(n.defaultProps) && (i = {
|
|
514
|
+
...n.defaultProps,
|
|
496
515
|
...i
|
|
497
|
-
}),
|
|
516
|
+
}), s = Kt(n) ? ii(n, i, t) : n({
|
|
498
517
|
...i,
|
|
499
518
|
children: t
|
|
500
519
|
});
|
|
501
520
|
else
|
|
502
|
-
throw new TypeError(`Invalid JSX element type: ${
|
|
503
|
-
return
|
|
521
|
+
throw new TypeError(`Invalid JSX element type: ${n}`);
|
|
522
|
+
return s;
|
|
523
|
+
}
|
|
524
|
+
function he(n, e) {
|
|
525
|
+
Wt(n) ? n.current = e : N(n) && n(e);
|
|
526
|
+
}
|
|
527
|
+
function Z(n, e) {
|
|
528
|
+
if (Ht(n))
|
|
529
|
+
ni(n, e);
|
|
530
|
+
else if (ce(n) || Ne(n))
|
|
531
|
+
ee(document.createTextNode(n), e);
|
|
532
|
+
else if (n === null)
|
|
533
|
+
ee(document.createComment(""), e);
|
|
534
|
+
else if (zt(n))
|
|
535
|
+
ee(n, e);
|
|
536
|
+
else if (Yt(n)) {
|
|
537
|
+
const t = e.attachShadow(n.attr);
|
|
538
|
+
Z(n.children, t), he(n.ref, t);
|
|
539
|
+
}
|
|
504
540
|
}
|
|
505
|
-
function
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
function q(s, e) {
|
|
509
|
-
if (Pt(s))
|
|
510
|
-
Kt(s, e);
|
|
511
|
-
else if (ne(s) || De(s))
|
|
512
|
-
Y(document.createTextNode(s), e);
|
|
513
|
-
else if (s === null)
|
|
514
|
-
Y(document.createComment(""), e);
|
|
515
|
-
else if (It(s))
|
|
516
|
-
Y(s, e);
|
|
517
|
-
else if (Mt(s)) {
|
|
518
|
-
const t = e.attachShadow(s.attr);
|
|
519
|
-
q(s.children, t), re(s.ref, t);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
function Kt(s, e) {
|
|
523
|
-
for (const t of [...s])
|
|
524
|
-
q(t, e);
|
|
541
|
+
function ni(n, e) {
|
|
542
|
+
for (const t of [...n])
|
|
543
|
+
Z(t, e);
|
|
525
544
|
return e;
|
|
526
545
|
}
|
|
527
|
-
function
|
|
528
|
-
e instanceof window.HTMLTemplateElement ? e.content.appendChild(
|
|
546
|
+
function ee(n, e) {
|
|
547
|
+
e instanceof window.HTMLTemplateElement ? e.content.appendChild(n) : e.appendChild(n);
|
|
529
548
|
}
|
|
530
|
-
function
|
|
531
|
-
return
|
|
549
|
+
function K(n, e) {
|
|
550
|
+
return n.replace(/[A-Z]/g, (t) => e + t.toLowerCase());
|
|
532
551
|
}
|
|
533
|
-
function
|
|
534
|
-
e == null || e === !1 || (Array.isArray(e) ? e.forEach((t) =>
|
|
535
|
-
i.indexOf("-") === 0 ?
|
|
552
|
+
function ze(n, e) {
|
|
553
|
+
e == null || e === !1 || (Array.isArray(e) ? e.forEach((t) => ze(n, t)) : ce(e) ? n.setAttribute("style", e) : D(e) && ne(e, (t, i) => {
|
|
554
|
+
i.indexOf("-") === 0 ? n.style.setProperty(i, t) : Ne(t) && se[i] !== 0 ? n.style[i] = t + "px" : n.style[i] = t;
|
|
536
555
|
}));
|
|
537
556
|
}
|
|
538
|
-
function
|
|
539
|
-
switch (
|
|
557
|
+
function si(n, e, t) {
|
|
558
|
+
switch (n) {
|
|
540
559
|
case "xlinkActuate":
|
|
541
560
|
case "xlinkArcrole":
|
|
542
561
|
case "xlinkHref":
|
|
@@ -544,33 +563,33 @@ function Ht(s, e, t) {
|
|
|
544
563
|
case "xlinkShow":
|
|
545
564
|
case "xlinkTitle":
|
|
546
565
|
case "xlinkType":
|
|
547
|
-
|
|
566
|
+
Ee(t, Jt, K(n, ":"), e);
|
|
548
567
|
return;
|
|
549
568
|
case "xmlnsXlink":
|
|
550
|
-
|
|
569
|
+
T(t, K(n, ":"), e);
|
|
551
570
|
return;
|
|
552
571
|
case "xmlBase":
|
|
553
572
|
case "xmlLang":
|
|
554
573
|
case "xmlSpace":
|
|
555
|
-
|
|
574
|
+
Ee(t, Zt, K(n, ":"), e);
|
|
556
575
|
return;
|
|
557
576
|
}
|
|
558
|
-
switch (
|
|
577
|
+
switch (n) {
|
|
559
578
|
case "htmlFor":
|
|
560
|
-
|
|
579
|
+
T(t, "for", e);
|
|
561
580
|
return;
|
|
562
581
|
case "dataset":
|
|
563
|
-
|
|
564
|
-
i != null && (t.dataset[
|
|
582
|
+
ne(e, (i, s) => {
|
|
583
|
+
i != null && (t.dataset[s] = i);
|
|
565
584
|
});
|
|
566
585
|
return;
|
|
567
586
|
case "innerHTML":
|
|
568
587
|
case "innerText":
|
|
569
588
|
case "textContent":
|
|
570
|
-
|
|
589
|
+
Fe(e) && (t[n] = e);
|
|
571
590
|
return;
|
|
572
591
|
case "dangerouslySetInnerHTML":
|
|
573
|
-
|
|
592
|
+
D(e) && (t.innerHTML = e.__html);
|
|
574
593
|
return;
|
|
575
594
|
case "value":
|
|
576
595
|
if (e == null || t instanceof window.HTMLSelectElement)
|
|
@@ -585,28 +604,28 @@ function Ht(s, e, t) {
|
|
|
585
604
|
return;
|
|
586
605
|
case "class":
|
|
587
606
|
case "className":
|
|
588
|
-
|
|
607
|
+
N(e) ? e(t) : T(t, "class", re(e));
|
|
589
608
|
return;
|
|
590
609
|
case "ref":
|
|
591
610
|
case "namespaceURI":
|
|
592
611
|
return;
|
|
593
612
|
case "style":
|
|
594
|
-
|
|
613
|
+
ze(t, e);
|
|
595
614
|
return;
|
|
596
615
|
case "on":
|
|
597
616
|
case "onCapture":
|
|
598
|
-
|
|
599
|
-
t.addEventListener(
|
|
617
|
+
ne(e, (i, s) => {
|
|
618
|
+
t.addEventListener(s, i, n === "onCapture");
|
|
600
619
|
});
|
|
601
620
|
return;
|
|
602
621
|
}
|
|
603
|
-
if (
|
|
604
|
-
if (
|
|
605
|
-
let i =
|
|
606
|
-
const
|
|
607
|
-
if (i === "ondoubleclick" ? i = "ondblclick" :
|
|
622
|
+
if (N(e)) {
|
|
623
|
+
if (n[0] === "o" && n[1] === "n") {
|
|
624
|
+
let i = n.toLowerCase();
|
|
625
|
+
const s = i.endsWith("capture");
|
|
626
|
+
if (i === "ondoubleclick" ? i = "ondblclick" : s && i === "ondoubleclickcapture" && (i = "ondblclickcapture"), !s && t[i] === null)
|
|
608
627
|
t[i] = e;
|
|
609
|
-
else if (
|
|
628
|
+
else if (s)
|
|
610
629
|
t.addEventListener(
|
|
611
630
|
i.substring(2, i.length - 7),
|
|
612
631
|
e,
|
|
@@ -614,33 +633,33 @@ function Ht(s, e, t) {
|
|
|
614
633
|
);
|
|
615
634
|
else {
|
|
616
635
|
let r;
|
|
617
|
-
i in window ? r = i.substring(2) : r = i[2] +
|
|
636
|
+
i in window ? r = i.substring(2) : r = i[2] + n.slice(3), t.addEventListener(r, e);
|
|
618
637
|
}
|
|
619
638
|
}
|
|
620
|
-
} else
|
|
639
|
+
} else D(e) ? t[n] = e : e === !0 ? T(t, n, "") : e !== !1 && e != null && (t instanceof SVGElement && !ei.test(n) ? T(t, K(n, "-"), e) : T(t, n, e));
|
|
621
640
|
}
|
|
622
|
-
function
|
|
623
|
-
|
|
641
|
+
function T(n, e, t) {
|
|
642
|
+
n.setAttribute(e, t);
|
|
624
643
|
}
|
|
625
|
-
function
|
|
626
|
-
|
|
644
|
+
function Ee(n, e, t, i) {
|
|
645
|
+
n.setAttributeNS(e, t, i);
|
|
627
646
|
}
|
|
628
|
-
function
|
|
629
|
-
for (const t of
|
|
630
|
-
|
|
647
|
+
function ri(n, e) {
|
|
648
|
+
for (const t of J(n))
|
|
649
|
+
si(t, n[t], e);
|
|
631
650
|
return e;
|
|
632
651
|
}
|
|
633
|
-
var
|
|
634
|
-
let
|
|
635
|
-
const
|
|
636
|
-
function
|
|
637
|
-
return
|
|
652
|
+
var ue = /* @__PURE__ */ ((n) => (n.Init = "modal.init", n.BeforeShow = "modal.beforeShow", n.Show = "modal.show", n.BeforeClose = "modal.beforeClose", n.Close = "modal.close", n.Destroy = "modal.destroy", n.ToastShow = "toast.show", n.ToastClose = "toast.close", n))(ue || {});
|
|
653
|
+
let oi = 0;
|
|
654
|
+
const Ce = (n) => `${n}-${++oi}`;
|
|
655
|
+
function B(n) {
|
|
656
|
+
return n instanceof Node ? n : document.createTextNode(String(n));
|
|
638
657
|
}
|
|
639
|
-
function
|
|
640
|
-
if (!
|
|
641
|
-
return
|
|
658
|
+
function I(n, e) {
|
|
659
|
+
if (!n) throw new Error(`${e ?? "Element"} not found`);
|
|
660
|
+
return n;
|
|
642
661
|
}
|
|
643
|
-
function
|
|
662
|
+
function Ie(n) {
|
|
644
663
|
const e = [
|
|
645
664
|
"a[href]",
|
|
646
665
|
"button:not([disabled])",
|
|
@@ -649,60 +668,60 @@ function _e(s) {
|
|
|
649
668
|
"textarea:not([disabled])",
|
|
650
669
|
'[tabindex]:not([tabindex="-1"])'
|
|
651
670
|
].join(",");
|
|
652
|
-
return Array.from(
|
|
671
|
+
return Array.from(n.querySelectorAll(e)).filter(
|
|
653
672
|
(t) => !!(t.offsetWidth || t.offsetHeight || t.getClientRects().length)
|
|
654
673
|
);
|
|
655
674
|
}
|
|
656
|
-
function
|
|
657
|
-
const t = document.createElement(
|
|
675
|
+
function x(n, e = {}) {
|
|
676
|
+
const t = document.createElement(n);
|
|
658
677
|
if (e.className && (t.className = e.className), e.html != null && (t.innerHTML = e.html), e.text != null && (t.textContent = e.text), e.attrs)
|
|
659
|
-
for (const [i,
|
|
678
|
+
for (const [i, s] of Object.entries(e.attrs)) t.setAttribute(i, s);
|
|
660
679
|
return t;
|
|
661
680
|
}
|
|
662
|
-
const
|
|
663
|
-
function
|
|
664
|
-
if (!
|
|
665
|
-
const e = String(
|
|
681
|
+
const ai = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform), Ke = ["ctrl", "alt", "shift", "meta"];
|
|
682
|
+
function li(n) {
|
|
683
|
+
if (!n) return null;
|
|
684
|
+
const e = String(n).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean), t = [];
|
|
666
685
|
let i = null;
|
|
667
|
-
const
|
|
686
|
+
const s = (o) => {
|
|
668
687
|
t.includes(o) || t.push(o);
|
|
669
688
|
};
|
|
670
689
|
for (const o of e) {
|
|
671
690
|
let a = o;
|
|
672
691
|
if (a === "control" || a === "ctrl") {
|
|
673
|
-
|
|
692
|
+
s("ctrl");
|
|
674
693
|
continue;
|
|
675
694
|
}
|
|
676
695
|
if (a === "alt" || a === "option") {
|
|
677
|
-
|
|
696
|
+
s("alt");
|
|
678
697
|
continue;
|
|
679
698
|
}
|
|
680
699
|
if (a === "shift") {
|
|
681
|
-
|
|
700
|
+
s("shift");
|
|
682
701
|
continue;
|
|
683
702
|
}
|
|
684
703
|
if (a === "meta" || a === "cmd" || a === "command" || a === "super") {
|
|
685
|
-
|
|
704
|
+
s("meta");
|
|
686
705
|
continue;
|
|
687
706
|
}
|
|
688
707
|
if (a === "mod") {
|
|
689
|
-
|
|
708
|
+
s(ai ? "meta" : "ctrl");
|
|
690
709
|
continue;
|
|
691
710
|
}
|
|
692
711
|
a === "esc" && (a = "escape"), a === "return" && (a = "enter"), (a === "space" || a === "spacebar") && (a = "space"), i = a;
|
|
693
712
|
}
|
|
694
|
-
const r =
|
|
713
|
+
const r = Ke.filter((o) => t.includes(o));
|
|
695
714
|
return !i || i === "" ? r.length ? r.join("+") : null : r.length ? `${r.join("+")}+${i}` : i;
|
|
696
715
|
}
|
|
697
|
-
function
|
|
716
|
+
function ci(n) {
|
|
698
717
|
const e = [];
|
|
699
|
-
|
|
700
|
-
let t =
|
|
718
|
+
n.ctrlKey && e.push("ctrl"), n.altKey && e.push("alt"), n.shiftKey && e.push("shift"), n.metaKey && e.push("meta");
|
|
719
|
+
let t = n.key;
|
|
701
720
|
t === " " && (t = "space");
|
|
702
|
-
const i = (t.length, t.toLowerCase()),
|
|
703
|
-
return
|
|
721
|
+
const i = (t.length, t.toLowerCase()), s = Ke.filter((r) => e.includes(r));
|
|
722
|
+
return s.length ? `${s.join("+")}+${i}` : i;
|
|
704
723
|
}
|
|
705
|
-
class
|
|
724
|
+
class hi {
|
|
706
725
|
constructor() {
|
|
707
726
|
this.zBase = 1e3, this.stack = [];
|
|
708
727
|
}
|
|
@@ -716,9 +735,9 @@ class Vt {
|
|
|
716
735
|
return this.stack[this.stack.length - 1];
|
|
717
736
|
}
|
|
718
737
|
closeAll(e, t) {
|
|
719
|
-
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)),
|
|
738
|
+
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), s = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
720
739
|
[...this.stack].reverse().forEach((r) => {
|
|
721
|
-
const o = r.modalId, a =
|
|
740
|
+
const o = r.modalId, a = s.size ? s.has(r.pluginName) : !0, c = i.has(o);
|
|
722
741
|
a && !c && r.close();
|
|
723
742
|
});
|
|
724
743
|
}
|
|
@@ -735,17 +754,17 @@ class Vt {
|
|
|
735
754
|
document.body.classList.remove("ipe-modal-no-scroll");
|
|
736
755
|
}
|
|
737
756
|
}
|
|
738
|
-
const
|
|
739
|
-
class
|
|
757
|
+
const k = new hi();
|
|
758
|
+
class W {
|
|
740
759
|
constructor(e = {}) {
|
|
741
|
-
this.backdropId =
|
|
760
|
+
this.backdropId = Ce("ipe-modal-backdrop"), this.modalId = Ce("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 = ue, this._hooks = [], this.startCloseTimer = (t) => {
|
|
742
761
|
this.stopCloseTimer(), this.closeTimer = window.setTimeout(() => this.close(), t);
|
|
743
762
|
}, this.stopCloseTimer = () => {
|
|
744
763
|
this.closeTimer && window.clearTimeout(this.closeTimer), this.closeTimer = void 0;
|
|
745
764
|
}, this.onDragMove = (t) => {
|
|
746
765
|
if (!this.isDragging) return;
|
|
747
766
|
t.preventDefault();
|
|
748
|
-
const i = t.clientX - this.dragStartX,
|
|
767
|
+
const i = t.clientX - this.dragStartX, s = t.clientY - this.dragStartY, r = this.get$modal(), o = this.modalStartX + i, a = this.modalStartY + s;
|
|
749
768
|
r.style.left = `${o}px`, r.style.top = `${a}px`;
|
|
750
769
|
}, this.onDragEnd = () => {
|
|
751
770
|
if (!this.isDragging) return;
|
|
@@ -754,7 +773,7 @@ class U {
|
|
|
754
773
|
t.classList.remove("is-dragging"), i.style.animation = "none", requestAnimationFrame(() => {
|
|
755
774
|
this.applyAnimation(!0);
|
|
756
775
|
});
|
|
757
|
-
}, this.options = { ...
|
|
776
|
+
}, this.options = { ...W.DEFAULT_OPTIONS, ...e }, this.options.backdrop === !1 && e.bodyScroll === void 0 && (this.options.bodyScroll = !0);
|
|
758
777
|
}
|
|
759
778
|
get isDestroyed() {
|
|
760
779
|
return this._isDestroyed;
|
|
@@ -788,52 +807,52 @@ class U {
|
|
|
788
807
|
if (this.$modal) return this;
|
|
789
808
|
const e = this.options.backdrop !== !1;
|
|
790
809
|
let t;
|
|
791
|
-
e && (t =
|
|
810
|
+
e && (t = x("div", {
|
|
792
811
|
className: "ipe-modal-backdrop",
|
|
793
812
|
attrs: { id: this.backdropId, "data-modal-id": this.modalId }
|
|
794
813
|
}));
|
|
795
|
-
const i =
|
|
814
|
+
const i = x("div", {
|
|
796
815
|
className: "ipe-modal-modal",
|
|
797
816
|
attrs: { id: this.modalId, role: "dialog", "aria-modal": "true", tabindex: "-1" }
|
|
798
817
|
});
|
|
799
818
|
if (i.modal = this, !e) {
|
|
800
819
|
i.classList.add("no-backdrop");
|
|
801
|
-
const
|
|
802
|
-
i.style.top = `${
|
|
803
|
-
i.style.left = `${g +
|
|
820
|
+
const d = window.pageYOffset || document.documentElement.scrollTop, g = window.pageXOffset || document.documentElement.scrollLeft, w = window.innerWidth;
|
|
821
|
+
i.style.top = `${d + 60}px`, this.once("modal.show", () => {
|
|
822
|
+
i.style.left = `${g + w / 2 - i.offsetWidth / 2}px`;
|
|
804
823
|
});
|
|
805
824
|
}
|
|
806
|
-
const
|
|
825
|
+
const s = x("div", {
|
|
807
826
|
className: `ipe-modal-modal__window size--${this.options.sizeClass || "auto"} plugin--${this.pluginName}`
|
|
808
827
|
});
|
|
809
|
-
|
|
810
|
-
const r =
|
|
828
|
+
s.modal = this;
|
|
829
|
+
const r = x("div", { className: "ipe-modal-modal__header" }), o = `${this.modalId}-title`, a = x("h2", {
|
|
811
830
|
className: "ipe-modal-modal__title",
|
|
812
831
|
attrs: { id: o, role: "heading", "aria-level": "2" }
|
|
813
832
|
});
|
|
814
833
|
i.setAttribute("aria-labelledby", o);
|
|
815
|
-
const c =
|
|
834
|
+
const c = x("div", { className: "ipe-modal-modal__icons" });
|
|
816
835
|
if (this.options.closeIcon) {
|
|
817
|
-
const
|
|
836
|
+
const d = x("button", {
|
|
818
837
|
className: "ipe-modal-modal__close",
|
|
819
838
|
attrs: { type: "button", "aria-label": "Close" },
|
|
820
839
|
html: "×"
|
|
821
840
|
});
|
|
822
|
-
|
|
841
|
+
d.addEventListener("click", () => {
|
|
823
842
|
let g = !0;
|
|
824
843
|
typeof this.options.onClickClose == "function" ? this.options.onClickClose(this) === !1 && (g = !1) : this.options.onClickClose === !1 && (g = !1), g && this.close();
|
|
825
|
-
}), c.appendChild(
|
|
844
|
+
}), c.appendChild(d);
|
|
826
845
|
}
|
|
827
846
|
r.append(a, c), this.options.draggable && e && (this.options.draggable = !1), this.options.draggable && (r.style.cursor = "move", r.style.userSelect = "none", r.addEventListener("pointerdown", this.onDragStart.bind(this)), i.classList.add("is-draggable"));
|
|
828
|
-
const l =
|
|
847
|
+
const l = x("div", { className: "ipe-modal-modal__content" }), h = x("div", { className: "ipe-modal-modal__footer" }), u = x("div", {
|
|
829
848
|
className: "ipe-modal-modal__buttons ipe-modal-modal__buttons--left"
|
|
830
|
-
}), f =
|
|
849
|
+
}), f = x("div", {
|
|
831
850
|
className: "ipe-modal-modal__buttons ipe-modal-modal__buttons--right"
|
|
832
851
|
});
|
|
833
|
-
return h.append(
|
|
834
|
-
this.options.outSideClose &&
|
|
835
|
-
}), this.options.draggable &&
|
|
836
|
-
|
|
852
|
+
return h.append(u, f), s.append(r, l, h), i.appendChild(s), this.$backdrop = t, this.$modal = i, this.$window = s, this.$header = r, this.$title = a, this.$icons = c, this.$content = l, this.$footer = h, this.$buttonsLeft = u, this.$buttonsRight = f, 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", (d) => {
|
|
853
|
+
this.options.outSideClose && d.target === t && this.close();
|
|
854
|
+
}), this.options.draggable && s.addEventListener("pointerdown", (d) => {
|
|
855
|
+
d.target && s.contains(d.target) && this.bringToFront();
|
|
837
856
|
}), this.onKeyDown = this.onKeyDown.bind(this), this.emit(
|
|
838
857
|
"modal.init"
|
|
839
858
|
/* Init */
|
|
@@ -843,12 +862,12 @@ class U {
|
|
|
843
862
|
if (this.$modal || this.init(), !this.$modal) throw new Error("Failed to initialize modal");
|
|
844
863
|
if (this.isOpen) return this;
|
|
845
864
|
{
|
|
846
|
-
const i = this.emit("modal.beforeShow", !0),
|
|
847
|
-
if (!i || !
|
|
865
|
+
const i = this.emit("modal.beforeShow", !0), s = this.options.beforeShow ? this.options.beforeShow(this) !== !1 : !0;
|
|
866
|
+
if (!i || !s) return this;
|
|
848
867
|
}
|
|
849
|
-
this.lastFocused = document.activeElement ?? null, this.$backdrop && document.body.appendChild(this.$backdrop), document.body.appendChild(this.$modal), this.shouldLockBodyOnOpen() &&
|
|
868
|
+
this.lastFocused = document.activeElement ?? null, this.$backdrop && document.body.appendChild(this.$backdrop), document.body.appendChild(this.$modal), this.shouldLockBodyOnOpen() && k.lockBodyScroll(), requestAnimationFrame(() => {
|
|
850
869
|
this.$backdrop?.classList.add("is-open"), this.$modal.classList.add("is-open"), this.applyAnimation(!0), this.focusFirst();
|
|
851
|
-
}), document.addEventListener("keydown", this.onKeyDown),
|
|
870
|
+
}), document.addEventListener("keydown", this.onKeyDown), k.push(this), this.isOpen = !0, this.options.onShow?.(this), this.emit(
|
|
852
871
|
"modal.show"
|
|
853
872
|
/* Show */
|
|
854
873
|
);
|
|
@@ -874,10 +893,10 @@ class U {
|
|
|
874
893
|
const a = () => {
|
|
875
894
|
o || (o = !0, this.destroy(), this.options.onClose?.(this));
|
|
876
895
|
}, c = (l, h) => {
|
|
877
|
-
const
|
|
878
|
-
l.removeEventListener(h,
|
|
896
|
+
const u = () => {
|
|
897
|
+
l.removeEventListener(h, u), a();
|
|
879
898
|
};
|
|
880
|
-
l.addEventListener(h,
|
|
899
|
+
l.addEventListener(h, u, { once: !0 });
|
|
881
900
|
};
|
|
882
901
|
return r > 0 && this.$window ? (c(this.$window, "transitionend"), c(this.$window, "animationend"), window.setTimeout(a, r + 20)) : window.setTimeout(a, r), this;
|
|
883
902
|
}
|
|
@@ -889,23 +908,23 @@ class U {
|
|
|
889
908
|
let t = !1;
|
|
890
909
|
const i = () => {
|
|
891
910
|
t || (t = !0, this.destroy(), this.options.onClose?.(this));
|
|
892
|
-
},
|
|
911
|
+
}, s = (r, o) => {
|
|
893
912
|
const a = () => {
|
|
894
913
|
r.removeEventListener(o, a), i();
|
|
895
914
|
};
|
|
896
915
|
r.addEventListener(o, a, { once: !0 });
|
|
897
916
|
};
|
|
898
|
-
return e > 0 && this.$window ? (
|
|
917
|
+
return e > 0 && this.$window ? (s(this.$window, "transitionend"), s(this.$window, "animationend"), window.setTimeout(i, e + 20)) : window.setTimeout(i, e), this;
|
|
899
918
|
}
|
|
900
919
|
/** Immediately removes DOM and listeners */
|
|
901
920
|
destroy() {
|
|
902
921
|
if (this._isDestroyed) return this;
|
|
903
922
|
if (this.stopCloseTimer(), document.removeEventListener("keydown", this.onKeyDown), this.isDragging && this.onDragEnd(), this.$window?.removeEventListener("mouseenter", this.stopCloseTimer), this.isToast) {
|
|
904
923
|
this.$window?.parentElement && this.$window.parentElement.removeChild(this.$window);
|
|
905
|
-
const e =
|
|
906
|
-
e !== -1 &&
|
|
924
|
+
const e = R.indexOf(this);
|
|
925
|
+
e !== -1 && R.splice(e, 1);
|
|
907
926
|
} else
|
|
908
|
-
this.$backdrop?.parentElement && this.$backdrop.parentElement.removeChild(this.$backdrop), this.$modal?.parentElement && this.$modal.parentElement.removeChild(this.$modal),
|
|
927
|
+
this.$backdrop?.parentElement && this.$backdrop.parentElement.removeChild(this.$backdrop), this.$modal?.parentElement && this.$modal.parentElement.removeChild(this.$modal), k.remove(this), this.shouldUnlockBodyOnClose() && k.unlockBodyScroll();
|
|
909
928
|
return this.isOpen = !1, this.lastFocused?.focus?.(), this.emit(
|
|
910
929
|
"modal.destroy"
|
|
911
930
|
/* Destroy */
|
|
@@ -916,50 +935,50 @@ class U {
|
|
|
916
935
|
return this.$backdrop;
|
|
917
936
|
}
|
|
918
937
|
get$modal() {
|
|
919
|
-
return
|
|
938
|
+
return I(this.$modal, "modal");
|
|
920
939
|
}
|
|
921
940
|
get$window() {
|
|
922
|
-
return
|
|
941
|
+
return I(this.$window, "window");
|
|
923
942
|
}
|
|
924
943
|
get$header() {
|
|
925
|
-
return
|
|
944
|
+
return I(this.$header, "header");
|
|
926
945
|
}
|
|
927
946
|
get$title() {
|
|
928
|
-
return
|
|
947
|
+
return I(this.$title, "title");
|
|
929
948
|
}
|
|
930
949
|
get$content() {
|
|
931
|
-
return
|
|
950
|
+
return I(this.$content, "content");
|
|
932
951
|
}
|
|
933
952
|
get$icons() {
|
|
934
|
-
return
|
|
953
|
+
return I(this.$icons, "icons");
|
|
935
954
|
}
|
|
936
955
|
get$buttons(e) {
|
|
937
|
-
return e === "leftButtons" ?
|
|
956
|
+
return e === "leftButtons" ? I(this.$buttonsLeft, "leftButtons") : e === "rightButtons" ? I(this.$buttonsRight, "rightButtons") : I(this.$footer, "buttons");
|
|
938
957
|
}
|
|
939
958
|
// ------------------------------ content ------------------------------- //
|
|
940
959
|
setTitle(e) {
|
|
941
960
|
const t = this.get$title();
|
|
942
|
-
return t.innerHTML = "", t.append(
|
|
961
|
+
return t.innerHTML = "", t.append(B(e)), this;
|
|
943
962
|
}
|
|
944
963
|
setContent(e, t = "replace") {
|
|
945
964
|
const i = this.get$content();
|
|
946
|
-
return t === "replace" ? (i.innerHTML = "", i.append(
|
|
965
|
+
return t === "replace" ? (i.innerHTML = "", i.append(B(e))) : t === "append" ? i.append(B(e)) : i.prepend(B(e)), this;
|
|
947
966
|
}
|
|
948
967
|
setIcons(e) {
|
|
949
968
|
const t = this.get$icons();
|
|
950
969
|
t.innerHTML = "";
|
|
951
970
|
for (const i of e) {
|
|
952
|
-
const
|
|
971
|
+
const s = x("button", {
|
|
953
972
|
className: `ipe-modal-modal__icon ${i.className}`,
|
|
954
973
|
attrs: { type: "button" }
|
|
955
974
|
});
|
|
956
|
-
|
|
975
|
+
s.addEventListener("click", i.method), t.appendChild(s);
|
|
957
976
|
}
|
|
958
977
|
return this;
|
|
959
978
|
}
|
|
960
979
|
setButtons(e, t) {
|
|
961
|
-
const i = this.$buttonsLeft,
|
|
962
|
-
[i,
|
|
980
|
+
const i = this.$buttonsLeft, s = this.$buttonsRight;
|
|
981
|
+
[i, s].forEach((o) => o.innerHTML = ""), this.buttonElsLeft = [], this.buttonElsRight = [], this.keyMap.clear();
|
|
963
982
|
const r = t ?? this.$footer;
|
|
964
983
|
if (r === this.$footer)
|
|
965
984
|
e.forEach((o) => this.addButton(o)), e.length === 0 && (this.$footer.style.display = "none");
|
|
@@ -973,10 +992,10 @@ class U {
|
|
|
973
992
|
return this;
|
|
974
993
|
}
|
|
975
994
|
generateButton(e) {
|
|
976
|
-
const t = e.type ?? "button", i = t === "link" ?
|
|
995
|
+
const t = e.type ?? "button", i = t === "link" ? x("a") : x("button", { attrs: { type: "button" } });
|
|
977
996
|
e.id && (i.id = e.id), i.className = `ipe-modal-btn ${e.className ?? ""}`.trim();
|
|
978
|
-
const
|
|
979
|
-
if (i.append(
|
|
997
|
+
const s = B(e.label ?? "OK");
|
|
998
|
+
if (i.append(s), t === "link" && e.href && (i.href = e.href), e.method && i.addEventListener("click", (r) => {
|
|
980
999
|
if (i._ipe_tmpDisabled) {
|
|
981
1000
|
r.preventDefault(), r.stopPropagation();
|
|
982
1001
|
return;
|
|
@@ -994,7 +1013,7 @@ class U {
|
|
|
994
1013
|
if (e.keyPress) {
|
|
995
1014
|
const r = String(e.keyPress).split(/[\,\|]+/g).map((o) => o.trim()).filter(Boolean);
|
|
996
1015
|
for (const o of r) {
|
|
997
|
-
const a =
|
|
1016
|
+
const a = li(o);
|
|
998
1017
|
a && this.keyMap.set(a, i);
|
|
999
1018
|
}
|
|
1000
1019
|
}
|
|
@@ -1003,18 +1022,18 @@ class U {
|
|
|
1003
1022
|
/** Dynamically add button(s) into footer. Supports insertion index per side. */
|
|
1004
1023
|
addButton(e, t) {
|
|
1005
1024
|
this.$footer && (this.$footer.style.display = "");
|
|
1006
|
-
const i = e.side ?? "right",
|
|
1007
|
-
return a >=
|
|
1025
|
+
const i = e.side ?? "right", s = i === "left" ? this.$buttonsLeft : this.$buttonsRight, r = i === "left" ? this.buttonElsLeft : this.buttonElsRight, o = this.generateButton(e), a = Math.max(0, Math.min(t ?? r.length, r.length));
|
|
1026
|
+
return a >= s.children.length ? s.appendChild(o) : s.insertBefore(o, s.children[a]), r.splice(a, 0, o), this;
|
|
1008
1027
|
}
|
|
1009
1028
|
/** Remove button by element / id / global index (left first, then right). */
|
|
1010
1029
|
removeButton(e) {
|
|
1011
|
-
const t = this.buttonElsLeft, i = this.buttonElsRight,
|
|
1030
|
+
const t = this.buttonElsLeft, i = this.buttonElsRight, s = [...t, ...i];
|
|
1012
1031
|
let r = null;
|
|
1013
1032
|
if (e === "*")
|
|
1014
|
-
return
|
|
1033
|
+
return s.forEach((a) => {
|
|
1015
1034
|
this.keyMap.delete(a.id), a.parentElement?.removeChild(a);
|
|
1016
1035
|
}), this.$footer && (this.$footer.style.display = "none"), this;
|
|
1017
|
-
if (typeof e == "number" ? r =
|
|
1036
|
+
if (typeof e == "number" ? r = s[e] ?? null : typeof e == "string" ? r = s.find((a) => a.id === e) ?? null : e instanceof HTMLElement && (r = s.find((a) => a === e) ?? null), !r) return this;
|
|
1018
1037
|
for (const [a, c] of this.keyMap.entries()) c === r && this.keyMap.delete(a);
|
|
1019
1038
|
let o = t.indexOf(r);
|
|
1020
1039
|
return o !== -1 ? (t.splice(o, 1), r.parentElement?.removeChild(r)) : (o = i.indexOf(r), o !== -1 && (i.splice(o, 1), r.parentElement?.removeChild(r))), t.length === 0 && i.length === 0 && this.$footer && (this.$footer.style.display = "none"), this;
|
|
@@ -1023,8 +1042,8 @@ class U {
|
|
|
1023
1042
|
return this.get$modal().classList.toggle("is-fullscreen"), this;
|
|
1024
1043
|
}
|
|
1025
1044
|
setModalHeight(e, t = "height") {
|
|
1026
|
-
const i = this.get$window(),
|
|
1027
|
-
return i.style[t] = `${
|
|
1045
|
+
const i = this.get$window(), s = Math.max(0, window.innerHeight - e);
|
|
1046
|
+
return i.style[t] = `${s}px`, s;
|
|
1028
1047
|
}
|
|
1029
1048
|
setOptions(e, t) {
|
|
1030
1049
|
return typeof e == "string" ? this.options[e] = t : Object.assign(this.options, e), this;
|
|
@@ -1037,8 +1056,8 @@ class U {
|
|
|
1037
1056
|
}
|
|
1038
1057
|
// ------------------------------ helpers ------------------------------- //
|
|
1039
1058
|
applyAnimation(e) {
|
|
1040
|
-
const t = this.get$modal(), i = this.get$window(),
|
|
1041
|
-
!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)),
|
|
1059
|
+
const t = this.get$modal(), i = this.get$window(), s = this.$backdrop, r = this.options.modalAnimation ?? this.options.animation, o = typeof r == "string" ? r : r && (e ? r.show : r.hide), a = this.options.backdropAnimation ?? this.options.animation, c = typeof a == "string" ? a : a && (e ? a.show : a.hide);
|
|
1060
|
+
!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"));
|
|
1042
1061
|
}
|
|
1043
1062
|
on(e, t) {
|
|
1044
1063
|
return this._hooks.push({ type: e, listener: t }), () => this.off(e, t);
|
|
@@ -1049,25 +1068,25 @@ class U {
|
|
|
1049
1068
|
), this;
|
|
1050
1069
|
}
|
|
1051
1070
|
once(e, t) {
|
|
1052
|
-
const i = this.on(e, (
|
|
1071
|
+
const i = this.on(e, (s) => (i(), t(s)));
|
|
1053
1072
|
return i;
|
|
1054
1073
|
}
|
|
1055
1074
|
emit(e, t) {
|
|
1056
1075
|
const i = this._hooks.filter((a) => a.type === e);
|
|
1057
|
-
let
|
|
1076
|
+
let s = !0;
|
|
1058
1077
|
for (const a of i) {
|
|
1059
1078
|
const c = new CustomEvent(e, { detail: this, cancelable: t }), l = a.listener(c);
|
|
1060
|
-
if (c.defaultPrevented && (
|
|
1079
|
+
if (c.defaultPrevented && (s = !1), l === !1 && (s = !1), !s) break;
|
|
1061
1080
|
}
|
|
1062
1081
|
const r = this.$modal ?? document.body, o = new CustomEvent(e, { detail: this, cancelable: t });
|
|
1063
|
-
return (!r.dispatchEvent(o) || o.defaultPrevented) && (
|
|
1082
|
+
return (!r.dispatchEvent(o) || o.defaultPrevented) && (s = !1), s;
|
|
1064
1083
|
}
|
|
1065
1084
|
focusFirst() {
|
|
1066
|
-
const e = this.get$modal(), t =
|
|
1085
|
+
const e = this.get$modal(), t = Ie(e);
|
|
1067
1086
|
t.length ? t[0].focus() : e.focus({ preventScroll: !0 });
|
|
1068
1087
|
}
|
|
1069
1088
|
onKeyDown(e) {
|
|
1070
|
-
if (
|
|
1089
|
+
if (k.top() !== this) return;
|
|
1071
1090
|
if (e.key === "Escape") {
|
|
1072
1091
|
e.preventDefault(), this.close();
|
|
1073
1092
|
return;
|
|
@@ -1075,15 +1094,15 @@ class U {
|
|
|
1075
1094
|
const t = this.get$modal();
|
|
1076
1095
|
if (!t.contains(document.activeElement)) return;
|
|
1077
1096
|
if (e.key === "Tab") {
|
|
1078
|
-
const a =
|
|
1097
|
+
const a = Ie(t);
|
|
1079
1098
|
if (!a.length) return;
|
|
1080
1099
|
const c = a[0], l = a[a.length - 1], h = document.activeElement;
|
|
1081
1100
|
e.shiftKey && h === c ? (e.preventDefault(), l.focus()) : !e.shiftKey && h === l && (e.preventDefault(), c.focus());
|
|
1082
1101
|
}
|
|
1083
|
-
const i = e.ctrlKey || e.altKey || e.metaKey,
|
|
1084
|
-
if (!i && (
|
|
1102
|
+
const i = e.ctrlKey || e.altKey || e.metaKey, s = e.target;
|
|
1103
|
+
if (!i && (s && ["INPUT", "TEXTAREA"].includes(s.tagName) || s.contentEditable === "true"))
|
|
1085
1104
|
return;
|
|
1086
|
-
const r =
|
|
1105
|
+
const r = ci(e), o = this.keyMap.get(r);
|
|
1087
1106
|
if (o) {
|
|
1088
1107
|
e.preventDefault(), o.click();
|
|
1089
1108
|
return;
|
|
@@ -1094,19 +1113,19 @@ class U {
|
|
|
1094
1113
|
}
|
|
1095
1114
|
/** Bring this modal to the top of the stack. */
|
|
1096
1115
|
bringToFront() {
|
|
1097
|
-
return
|
|
1116
|
+
return k.remove(this), k.push(this), this;
|
|
1098
1117
|
}
|
|
1099
1118
|
isAnimationDisabled() {
|
|
1100
1119
|
const e = this.options.modalAnimation ?? this.options.animation;
|
|
1101
1120
|
return e === !1 || e == null;
|
|
1102
1121
|
}
|
|
1103
1122
|
shouldLockBodyOnOpen() {
|
|
1104
|
-
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !
|
|
1123
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !k.stack.some(
|
|
1105
1124
|
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
1106
1125
|
);
|
|
1107
1126
|
}
|
|
1108
1127
|
shouldUnlockBodyOnClose() {
|
|
1109
|
-
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !
|
|
1128
|
+
return this.options.backdrop === !1 || this.options.bodyScroll !== !1 ? !1 : !k.stack.some(
|
|
1110
1129
|
(e) => e !== this && e.options.backdrop !== !1 && e.options.bodyScroll === !1
|
|
1111
1130
|
);
|
|
1112
1131
|
}
|
|
@@ -1121,10 +1140,10 @@ class U {
|
|
|
1121
1140
|
/** Show as toast (no backdrop, container stack). */
|
|
1122
1141
|
showToast(e) {
|
|
1123
1142
|
this.$window || this.init();
|
|
1124
|
-
const t =
|
|
1143
|
+
const t = ui(e.position ?? "top right"), i = this.get$window();
|
|
1125
1144
|
this.isToast = !0, i.style.pointerEvents = "auto", this.applyAnimation(!0), t.appendChild(i);
|
|
1126
|
-
const
|
|
1127
|
-
return
|
|
1145
|
+
const s = (typeof this.options.closeAfter == "number" ? this.options.closeAfter : this.options.closeAfter?.time) ?? 3e3, r = (typeof this.options.closeAfter == "number" ? !0 : this.options.closeAfter?.resetOnHover) ?? !0;
|
|
1146
|
+
return s > 0 && (this.startCloseTimer(s), r && (i.addEventListener("mouseenter", this.stopCloseTimer), i.addEventListener("mouseleave", () => this.startCloseTimer(s)))), this.isOpen = !0, this.options.onShow?.(this), R.push(this), this.emit(
|
|
1128
1147
|
"toast.show"
|
|
1129
1148
|
/* ToastShow */
|
|
1130
1149
|
), this.emit(
|
|
@@ -1141,24 +1160,24 @@ class U {
|
|
|
1141
1160
|
}
|
|
1142
1161
|
static close(e) {
|
|
1143
1162
|
if (!e) {
|
|
1144
|
-
const r =
|
|
1163
|
+
const r = k.top();
|
|
1145
1164
|
return r?.close(), r;
|
|
1146
1165
|
}
|
|
1147
|
-
const t = typeof e == "string" ? e : e.id, i =
|
|
1166
|
+
const t = typeof e == "string" ? e : e.id, i = k.stack.find((r) => r.modalId === t);
|
|
1148
1167
|
if (i)
|
|
1149
1168
|
return i.close(), i;
|
|
1150
|
-
const
|
|
1151
|
-
return
|
|
1169
|
+
const s = R.find((r) => r.modalId === t);
|
|
1170
|
+
return s?.close(), s;
|
|
1152
1171
|
}
|
|
1153
1172
|
static closeAll(e, t) {
|
|
1154
|
-
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)),
|
|
1155
|
-
return
|
|
1156
|
-
const o = r.modalId, a =
|
|
1173
|
+
const i = new Set((Array.isArray(t) ? t : t ? [t] : []).map(String)), s = new Set((Array.isArray(e) ? e : e ? [e] : []).map(String));
|
|
1174
|
+
return k.closeAll(e, t), [...R].forEach((r) => {
|
|
1175
|
+
const o = r.modalId, a = s.size ? s.has(r.pluginName) : !0, c = i.has(o);
|
|
1157
1176
|
a && !c && r.close();
|
|
1158
|
-
}),
|
|
1177
|
+
}), k.top() ?? new W();
|
|
1159
1178
|
}
|
|
1160
1179
|
static removeAll() {
|
|
1161
|
-
|
|
1180
|
+
k.removeAll(), [...R].forEach((e) => e.destroy());
|
|
1162
1181
|
}
|
|
1163
1182
|
static dialog(e, t) {
|
|
1164
1183
|
const i = new this({
|
|
@@ -1167,8 +1186,8 @@ class U {
|
|
|
1167
1186
|
{
|
|
1168
1187
|
label: "OK",
|
|
1169
1188
|
className: "is-primary is-ghost",
|
|
1170
|
-
method: (
|
|
1171
|
-
t?.(
|
|
1189
|
+
method: (s, r) => {
|
|
1190
|
+
t?.(s, r), s.defaultPrevented || i.close();
|
|
1172
1191
|
},
|
|
1173
1192
|
keyPress: "Enter"
|
|
1174
1193
|
}
|
|
@@ -1179,14 +1198,14 @@ class U {
|
|
|
1179
1198
|
}
|
|
1180
1199
|
static confirm(e, t) {
|
|
1181
1200
|
e.title ??= "Confirm", e.content ??= "Are you sure you want to perform this action?";
|
|
1182
|
-
const i = e.okBtn ?? { label: "OK", className: "is-primary is-ghost" },
|
|
1201
|
+
const i = e.okBtn ?? { label: "OK", className: "is-primary is-ghost" }, s = e.cancelBtn ?? { label: "Cancel", className: "is-danger is-ghost" };
|
|
1183
1202
|
return new this({
|
|
1184
1203
|
sizeClass: "dialog",
|
|
1185
1204
|
...e,
|
|
1186
1205
|
buttons: [
|
|
1187
1206
|
{
|
|
1188
|
-
label:
|
|
1189
|
-
className:
|
|
1207
|
+
label: s.label,
|
|
1208
|
+
className: s.className,
|
|
1190
1209
|
keyPress: "n",
|
|
1191
1210
|
method: (r, o) => {
|
|
1192
1211
|
t?.(!1, o, r), o.close();
|
|
@@ -1313,13 +1332,13 @@ class U {
|
|
|
1313
1332
|
}
|
|
1314
1333
|
}
|
|
1315
1334
|
static notify(e, t, i) {
|
|
1316
|
-
if (t?.overrideOther && [...
|
|
1335
|
+
if (t?.overrideOther && [...R].forEach((a) => a.close()), typeof t.title > "u") {
|
|
1317
1336
|
const a = e || "Notification";
|
|
1318
1337
|
t.title = a[0].toUpperCase() + a.slice(1).toLowerCase();
|
|
1319
1338
|
}
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
|
|
1339
|
+
const s = t.icon ?? this.getDefaultNotifyIcon(e);
|
|
1340
|
+
s && (s instanceof Element && s.classList.add("ipe-modal-notify-icon"), t.title = /* @__PURE__ */ m(ti, { children: [
|
|
1341
|
+
s,
|
|
1323
1342
|
t.title
|
|
1324
1343
|
] })), 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) => {
|
|
1325
1344
|
i?.(!0, c, a), c.close();
|
|
@@ -1344,16 +1363,16 @@ class U {
|
|
|
1344
1363
|
});
|
|
1345
1364
|
}
|
|
1346
1365
|
}
|
|
1347
|
-
const
|
|
1348
|
-
function
|
|
1349
|
-
const e = "ipe-modal-toast-container", t = `${e}-${
|
|
1366
|
+
const R = [];
|
|
1367
|
+
function ui(n = "top right") {
|
|
1368
|
+
const e = "ipe-modal-toast-container", t = `${e}-${n.replace(/[\s-\.|\/]+/g, "-")}`;
|
|
1350
1369
|
let i = document.getElementById(t);
|
|
1351
|
-
return i || (i =
|
|
1352
|
-
className: `${e} ${
|
|
1353
|
-
attrs: { id: t, "data-position":
|
|
1370
|
+
return i || (i = x("div", {
|
|
1371
|
+
className: `${e} ${n}`,
|
|
1372
|
+
attrs: { id: t, "data-position": n }
|
|
1354
1373
|
}), document.body.appendChild(i)), i;
|
|
1355
1374
|
}
|
|
1356
|
-
class
|
|
1375
|
+
class b extends W {
|
|
1357
1376
|
constructor(e = {}) {
|
|
1358
1377
|
e.className ||= "", e.className += " theme-ipe", e.modalAnimation ||= {
|
|
1359
1378
|
show: "ipe-modal-fade-in",
|
|
@@ -1368,7 +1387,7 @@ class y extends U {
|
|
|
1368
1387
|
this._tmpDisabledActiveInputs = t, t.forEach((i) => {
|
|
1369
1388
|
i.disabled = !0;
|
|
1370
1389
|
}), this.get$content().append(
|
|
1371
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ E(
|
|
1372
1391
|
"div",
|
|
1373
1392
|
{
|
|
1374
1393
|
id: "ipe-modalLoadingWrapper",
|
|
@@ -1384,7 +1403,7 @@ class y extends U {
|
|
|
1384
1403
|
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
1385
1404
|
zIndex: 2e3
|
|
1386
1405
|
},
|
|
1387
|
-
children: /* @__PURE__ */
|
|
1406
|
+
children: /* @__PURE__ */ E(xt, { style: { width: "80%", maxWidth: "800px" } })
|
|
1388
1407
|
}
|
|
1389
1408
|
)
|
|
1390
1409
|
);
|
|
@@ -1397,66 +1416,67 @@ class y extends U {
|
|
|
1397
1416
|
}
|
|
1398
1417
|
}
|
|
1399
1418
|
}
|
|
1400
|
-
class
|
|
1419
|
+
class di {
|
|
1401
1420
|
constructor(e) {
|
|
1402
|
-
this.ctx = e, this.IPEModal =
|
|
1403
|
-
|
|
1421
|
+
this.ctx = e, this.IPEModal = b, this.IPEModalEvent = ue, this.show = b.show.bind(b), this.createObject = b.createObject.bind(b), this.close = b.close.bind(b), this.closeAll = b.closeAll.bind(b), this.removeAll = b.removeAll.bind(b), this.dialog = b.dialog.bind(b), this.confirm = b.confirm.bind(b), this.notify = b.notify.bind(b), e.set("modal", this), e.on("dispose", () => {
|
|
1422
|
+
b.closeAll();
|
|
1404
1423
|
});
|
|
1405
1424
|
}
|
|
1406
1425
|
}
|
|
1407
|
-
const
|
|
1408
|
-
if (!
|
|
1426
|
+
const He = (n) => {
|
|
1427
|
+
if (!n)
|
|
1409
1428
|
return new URLSearchParams();
|
|
1410
|
-
if (
|
|
1411
|
-
return
|
|
1412
|
-
if (typeof
|
|
1429
|
+
if (n instanceof URLSearchParams)
|
|
1430
|
+
return n;
|
|
1431
|
+
if (typeof n != "object" || n?.constructor !== Object)
|
|
1413
1432
|
throw new TypeError("only plain object is supported");
|
|
1414
1433
|
const e = new URLSearchParams();
|
|
1415
|
-
for (const [t, i] of Object.entries(
|
|
1434
|
+
for (const [t, i] of Object.entries(n))
|
|
1416
1435
|
if (i != null) {
|
|
1417
1436
|
if (Array.isArray(i)) {
|
|
1418
|
-
for (const
|
|
1419
|
-
e.append(t,
|
|
1437
|
+
for (const s of i)
|
|
1438
|
+
e.append(t, s?.toString());
|
|
1420
1439
|
continue;
|
|
1421
1440
|
}
|
|
1422
1441
|
if (typeof i == "object" && i !== null && i.constructor === Object) {
|
|
1423
|
-
for (const [
|
|
1424
|
-
r != null && e.set(`${t}[${
|
|
1442
|
+
for (const [s, r] of Object.entries(i))
|
|
1443
|
+
r != null && e.set(`${t}[${s}]`, r?.toString());
|
|
1425
1444
|
continue;
|
|
1426
1445
|
}
|
|
1427
1446
|
e.set(t, i?.toString());
|
|
1428
1447
|
}
|
|
1429
1448
|
return e;
|
|
1430
|
-
},
|
|
1431
|
-
const i = typeof
|
|
1449
|
+
}, We = (n, e, t) => {
|
|
1450
|
+
const i = typeof n == "string" ? new URL(n, window?.location?.origin) : new URL(n), s = new URLSearchParams(i.search), r = He(e);
|
|
1432
1451
|
for (const [o, a] of r.entries())
|
|
1433
|
-
|
|
1434
|
-
return i.search =
|
|
1452
|
+
s.set(o, a);
|
|
1453
|
+
return i.search = s.toString(), i.hash = "", i;
|
|
1435
1454
|
};
|
|
1436
|
-
var
|
|
1437
|
-
throw TypeError(
|
|
1438
|
-
},
|
|
1439
|
-
for (var
|
|
1455
|
+
var fi = Object.create, de = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, qe = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), Ge = (n) => {
|
|
1456
|
+
throw TypeError(n);
|
|
1457
|
+
}, pi = (n, e, t) => e in n ? de(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, mi = (n, e) => de(n, "name", { value: e, configurable: !0 }), wi = (n) => [, , , fi(n?.[qe("metadata")] ?? null)], yi = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Xe = (n) => n !== void 0 && typeof n != "function" ? Ge("Function expected") : n, bi = (n, e, t, i, s) => ({ kind: yi[n], name: e, metadata: i, addInitializer: (r) => t._ ? Ge("Already initialized") : s.push(Xe(r || null)) }), vi = (n, e) => pi(e, qe("metadata"), n[3]), _i = (n, e, t, i) => {
|
|
1458
|
+
for (var s = 0, r = n[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
|
|
1440
1459
|
return i;
|
|
1441
|
-
},
|
|
1442
|
-
var o, a, c, l = e & 7, h = !1,
|
|
1443
|
-
|
|
1460
|
+
}, $i = (n, e, t, i, s, r) => {
|
|
1461
|
+
var o, a, c, l = e & 7, h = !1, u = 0, f = n[u] || (n[u] = []), d = l && (s = s.prototype, l < 5 && (l > 3 || !h) && gi(s, t));
|
|
1462
|
+
mi(s, t);
|
|
1444
1463
|
for (var g = i.length - 1; g >= 0; g--)
|
|
1445
|
-
c =
|
|
1446
|
-
return
|
|
1447
|
-
},
|
|
1448
|
-
|
|
1449
|
-
class
|
|
1464
|
+
c = bi(l, t, a = {}, n[3], f), o = (0, i[g])(s, c), a._ = 1, Xe(o) && (s = o);
|
|
1465
|
+
return vi(n, s), d && de(s, t, d), h ? l ^ 4 ? r : d : s;
|
|
1466
|
+
}, Ye, fe, Ve;
|
|
1467
|
+
Ye = [j(["api", "storage"])];
|
|
1468
|
+
class q extends (Ve = L) {
|
|
1450
1469
|
constructor(e) {
|
|
1451
|
-
super(e, "wiki", !1), this.ctx = e, this._data = {}, this.CACHE_VERSION =
|
|
1470
|
+
super(e, "wiki", !1), this.ctx = e, this._data = {}, this.CACHE_VERSION = 4, this.CACHE_TTL = {
|
|
1452
1471
|
siteinfo: 1e3 * 60 * 60 * 24 * 3,
|
|
1453
1472
|
// 3 days
|
|
1454
1473
|
userinfo: 1e3 * 60 * 30
|
|
1455
1474
|
// 30 minutes
|
|
1456
1475
|
}, this.QUERY_DATA = {
|
|
1457
1476
|
siteinfo: {
|
|
1458
|
-
meta: "siteinfo",
|
|
1459
|
-
siprop: "general|specialpagealiases|namespacealiases|namespaces|magicwords"
|
|
1477
|
+
meta: "siteinfo|filerepoinfo",
|
|
1478
|
+
siprop: "general|specialpagealiases|namespacealiases|namespaces|magicwords",
|
|
1479
|
+
friprop: "canUpload|displayname|initialCapital|local|name|rootUrl|scriptDirUrl|thumbUrl|url"
|
|
1460
1480
|
},
|
|
1461
1481
|
userinfo: { meta: "userinfo", uiprop: "groups|rights|blockinfo|options" }
|
|
1462
1482
|
}, this.CACHE_DB = void 0, this.mwConfig = {
|
|
@@ -1486,11 +1506,11 @@ class j extends (Ke = C) {
|
|
|
1486
1506
|
"WikiMetadataService",
|
|
1487
1507
|
p.object({
|
|
1488
1508
|
WikiMetadataService: p.const(
|
|
1489
|
-
/* @__PURE__ */
|
|
1490
|
-
/* @__PURE__ */
|
|
1491
|
-
/* @__PURE__ */
|
|
1492
|
-
/* @__PURE__ */
|
|
1493
|
-
/* @__PURE__ */
|
|
1509
|
+
/* @__PURE__ */ E("div", { children: [
|
|
1510
|
+
/* @__PURE__ */ E("h3", { children: t`Wiki Informations` }),
|
|
1511
|
+
/* @__PURE__ */ E("ul", { children: [
|
|
1512
|
+
/* @__PURE__ */ E("li", { children: [
|
|
1513
|
+
/* @__PURE__ */ E("strong", { children: [
|
|
1494
1514
|
t`Site`,
|
|
1495
1515
|
":"
|
|
1496
1516
|
] }),
|
|
@@ -1500,23 +1520,23 @@ class j extends (Ke = C) {
|
|
|
1500
1520
|
this.landingPageUrl,
|
|
1501
1521
|
")"
|
|
1502
1522
|
] }),
|
|
1503
|
-
/* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1523
|
+
/* @__PURE__ */ E("li", { children: [
|
|
1524
|
+
/* @__PURE__ */ E("strong", { children: t`User` }),
|
|
1505
1525
|
": ",
|
|
1506
1526
|
this.userInfo.name,
|
|
1507
1527
|
" (ID: ",
|
|
1508
1528
|
this.userInfo.id,
|
|
1509
1529
|
")"
|
|
1510
1530
|
] }),
|
|
1511
|
-
/* @__PURE__ */
|
|
1512
|
-
/* @__PURE__ */
|
|
1531
|
+
/* @__PURE__ */ E("li", { children: [
|
|
1532
|
+
/* @__PURE__ */ E("strong", { children: t`Groups` }),
|
|
1513
1533
|
": ",
|
|
1514
1534
|
this.userGroups.join(", ") || "None"
|
|
1515
1535
|
] })
|
|
1516
1536
|
] }),
|
|
1517
|
-
/* @__PURE__ */
|
|
1518
|
-
/* @__PURE__ */
|
|
1519
|
-
/* @__PURE__ */
|
|
1537
|
+
/* @__PURE__ */ E("div", { children: [
|
|
1538
|
+
/* @__PURE__ */ E("p", { style: { fontStyle: "italic" }, children: t`If the information shown above is incorrect (for example, the user is not you), click the button below.` }),
|
|
1539
|
+
/* @__PURE__ */ E(
|
|
1520
1540
|
"button",
|
|
1521
1541
|
{
|
|
1522
1542
|
className: "btn danger",
|
|
@@ -1542,8 +1562,8 @@ class j extends (Ke = C) {
|
|
|
1542
1562
|
if (i)
|
|
1543
1563
|
return this._data[e] = i, this.logger.debug("Using cached", e, i), i;
|
|
1544
1564
|
{
|
|
1545
|
-
const
|
|
1546
|
-
return this.saveToCache(e,
|
|
1565
|
+
const s = await this.fetchFromApi(e);
|
|
1566
|
+
return this.saveToCache(e, s), this._data[e] = s, this.logger.debug("Fetched from API", e, s), s;
|
|
1547
1567
|
}
|
|
1548
1568
|
}
|
|
1549
1569
|
getCacheKey(e) {
|
|
@@ -1623,6 +1643,10 @@ class j extends (Ke = C) {
|
|
|
1623
1643
|
get userRights() {
|
|
1624
1644
|
return this.userInfo.rights;
|
|
1625
1645
|
}
|
|
1646
|
+
// fileRepoInfo
|
|
1647
|
+
get fileRepos() {
|
|
1648
|
+
return this.siteInfo.repos || [];
|
|
1649
|
+
}
|
|
1626
1650
|
/**
|
|
1627
1651
|
* Base URL, without trailing slash
|
|
1628
1652
|
* @example "https://mediawiki.org"
|
|
@@ -1686,12 +1710,12 @@ class j extends (Ke = C) {
|
|
|
1686
1710
|
}
|
|
1687
1711
|
/** Get mainpage URL */
|
|
1688
1712
|
getMainpageUrl(e) {
|
|
1689
|
-
return
|
|
1713
|
+
return We(this.siteInfo.general.base, e).toString();
|
|
1690
1714
|
}
|
|
1691
1715
|
getUrl(e, t) {
|
|
1692
|
-
const i =
|
|
1693
|
-
let
|
|
1694
|
-
return typeof e == "string" && e !== "" ?
|
|
1716
|
+
const i = He(t);
|
|
1717
|
+
let s;
|
|
1718
|
+
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();
|
|
1695
1719
|
}
|
|
1696
1720
|
hasRight(e) {
|
|
1697
1721
|
return this.userRights.includes(e);
|
|
@@ -1719,16 +1743,16 @@ class j extends (Ke = C) {
|
|
|
1719
1743
|
} : null;
|
|
1720
1744
|
}
|
|
1721
1745
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
const
|
|
1726
|
-
const
|
|
1727
|
-
return
|
|
1746
|
+
fe = wi(Ve);
|
|
1747
|
+
q = $i(fe, 0, "WikiMetadataService", Ye, q);
|
|
1748
|
+
_i(fe, 1, q);
|
|
1749
|
+
const Si = (() => {
|
|
1750
|
+
const n = Symbol.for("IPE.GlobalMemoryStorage");
|
|
1751
|
+
return n in globalThis || (globalThis[n] = mt()), globalThis[n];
|
|
1728
1752
|
})();
|
|
1729
|
-
class
|
|
1730
|
-
constructor(e, t, i = 1 / 0,
|
|
1731
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
1753
|
+
class xi {
|
|
1754
|
+
constructor(e, t, i = 1 / 0, s, r = "localStorage") {
|
|
1755
|
+
this.dbName = e, this.storeName = t, this.ttl = i, this.version = s, this.engine = r, 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 = Si;
|
|
1732
1756
|
}
|
|
1733
1757
|
// Key builder
|
|
1734
1758
|
makeKey(e) {
|
|
@@ -1744,8 +1768,8 @@ class hi {
|
|
|
1744
1768
|
} catch {
|
|
1745
1769
|
return this.deleteSync(e), null;
|
|
1746
1770
|
}
|
|
1747
|
-
const
|
|
1748
|
-
return typeof
|
|
1771
|
+
const s = i;
|
|
1772
|
+
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;
|
|
1749
1773
|
}
|
|
1750
1774
|
getRaw(e) {
|
|
1751
1775
|
const t = this.makeKey(e);
|
|
@@ -1766,15 +1790,15 @@ class hi {
|
|
|
1766
1790
|
return e ? Date.now() - e.time > t : !1;
|
|
1767
1791
|
}
|
|
1768
1792
|
async get(e, t = this.ttl, i) {
|
|
1769
|
-
const
|
|
1770
|
-
if (!
|
|
1793
|
+
const s = this.load(e), r = this.isExpired(s, t);
|
|
1794
|
+
if (!s || r) {
|
|
1771
1795
|
if (typeof i == "function") {
|
|
1772
1796
|
const o = await i();
|
|
1773
1797
|
return await this.set(e, o), o;
|
|
1774
1798
|
}
|
|
1775
1799
|
return null;
|
|
1776
1800
|
}
|
|
1777
|
-
return
|
|
1801
|
+
return s.value;
|
|
1778
1802
|
}
|
|
1779
1803
|
async set(e, t) {
|
|
1780
1804
|
const i = Date.now();
|
|
@@ -1787,8 +1811,8 @@ class hi {
|
|
|
1787
1811
|
const c = { time: i, value: a, version: this.version };
|
|
1788
1812
|
return this.setRaw(o, JSON.stringify(c)), c;
|
|
1789
1813
|
}
|
|
1790
|
-
const
|
|
1791
|
-
for (const [o, a] of Object.entries(
|
|
1814
|
+
const s = e, r = {};
|
|
1815
|
+
for (const [o, a] of Object.entries(s)) {
|
|
1792
1816
|
if (a === null || typeof a > "u") {
|
|
1793
1817
|
this.deleteSync(o);
|
|
1794
1818
|
continue;
|
|
@@ -1812,8 +1836,8 @@ class hi {
|
|
|
1812
1836
|
async clear() {
|
|
1813
1837
|
const e = this.makeKey(""), t = [];
|
|
1814
1838
|
for (let i = 0; i < this.db.length; i++) {
|
|
1815
|
-
const
|
|
1816
|
-
|
|
1839
|
+
const s = this.db.key(i);
|
|
1840
|
+
s && s.startsWith(e) && t.push(s);
|
|
1817
1841
|
}
|
|
1818
1842
|
for (const i of t) this.db.removeItem(i);
|
|
1819
1843
|
return this;
|
|
@@ -1851,187 +1875,187 @@ class hi {
|
|
|
1851
1875
|
}
|
|
1852
1876
|
}
|
|
1853
1877
|
}
|
|
1854
|
-
var
|
|
1855
|
-
((
|
|
1856
|
-
|
|
1878
|
+
var y;
|
|
1879
|
+
((n) => {
|
|
1880
|
+
n.cache = /* @__PURE__ */ new Map(), n.defaults = Object.freeze({ iterBatch: 100, retry: { attempts: 3, baseDelayMs: 16 } }), n.sleep = (l) => new Promise((h) => setTimeout(h, l));
|
|
1857
1881
|
function e(l) {
|
|
1858
1882
|
const h = l?.name ?? "";
|
|
1859
1883
|
return h === "AbortError" || h === "InvalidStateError" || h === "TransactionInactiveError" || h === "UnknownError";
|
|
1860
1884
|
}
|
|
1861
|
-
|
|
1862
|
-
async function t(l, h,
|
|
1885
|
+
n.shouldReconnect = e;
|
|
1886
|
+
async function t(l, h, u) {
|
|
1863
1887
|
const f = Math.max(1, l.attempts);
|
|
1864
|
-
for (let
|
|
1888
|
+
for (let d = 0; d < f; d++)
|
|
1865
1889
|
try {
|
|
1866
|
-
return await h(
|
|
1890
|
+
return await h(d);
|
|
1867
1891
|
} catch (g) {
|
|
1868
|
-
if (
|
|
1869
|
-
await
|
|
1870
|
-
const
|
|
1871
|
-
await (0,
|
|
1892
|
+
if (d === f - 1) throw g;
|
|
1893
|
+
await u?.(g, d);
|
|
1894
|
+
const w = l.baseDelayMs * Math.pow(2, d) + Math.floor(Math.random() * 10);
|
|
1895
|
+
await (0, n.sleep)(w);
|
|
1872
1896
|
}
|
|
1873
1897
|
throw new Error("withRetry exhausted unexpectedly");
|
|
1874
1898
|
}
|
|
1875
|
-
|
|
1876
|
-
function i(l, h,
|
|
1877
|
-
return new Promise((f,
|
|
1899
|
+
n.withRetry = t;
|
|
1900
|
+
function i(l, h, u) {
|
|
1901
|
+
return new Promise((f, d) => {
|
|
1878
1902
|
const g = indexedDB.open(l, h);
|
|
1879
1903
|
g.onupgradeneeded = () => {
|
|
1880
1904
|
try {
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1883
|
-
} catch (
|
|
1884
|
-
|
|
1905
|
+
const w = g.result, S = g.transaction;
|
|
1906
|
+
u?.(w, S);
|
|
1907
|
+
} catch (w) {
|
|
1908
|
+
d(w);
|
|
1885
1909
|
}
|
|
1886
|
-
}, g.onerror = () =>
|
|
1910
|
+
}, g.onerror = () => d(g.error), g.onblocked = () => {
|
|
1887
1911
|
}, g.onsuccess = () => {
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1912
|
+
const w = g.result;
|
|
1913
|
+
w.onversionchange = () => {
|
|
1890
1914
|
try {
|
|
1891
|
-
|
|
1915
|
+
w.close();
|
|
1892
1916
|
} finally {
|
|
1893
|
-
|
|
1917
|
+
n.cache.delete(l);
|
|
1894
1918
|
}
|
|
1895
|
-
}, f(
|
|
1919
|
+
}, f(w);
|
|
1896
1920
|
};
|
|
1897
1921
|
});
|
|
1898
1922
|
}
|
|
1899
|
-
async function
|
|
1900
|
-
let f = !l.objectStoreNames.contains(h),
|
|
1901
|
-
if (!f &&
|
|
1902
|
-
const S = l.transaction(h, "readonly"),
|
|
1903
|
-
|
|
1904
|
-
S.oncomplete = () =>
|
|
1923
|
+
async function s(l, h, u) {
|
|
1924
|
+
let f = !l.objectStoreNames.contains(h), d = [];
|
|
1925
|
+
if (!f && u?.indexes?.length) {
|
|
1926
|
+
const S = l.transaction(h, "readonly"), P = S.objectStore(h), v = new Set(Array.from(P.indexNames));
|
|
1927
|
+
d = (u.indexes || []).filter((_) => !v.has(_.name)), await new Promise((_, C) => {
|
|
1928
|
+
S.oncomplete = () => _(), S.onabort = () => C(S.error), S.onerror = () => C(S.error);
|
|
1905
1929
|
});
|
|
1906
1930
|
}
|
|
1907
|
-
if (!f &&
|
|
1931
|
+
if (!f && d.length === 0) return l;
|
|
1908
1932
|
const g = l.version + 1;
|
|
1909
1933
|
l.close();
|
|
1910
|
-
const
|
|
1911
|
-
let
|
|
1912
|
-
S.objectStoreNames.contains(h) ?
|
|
1913
|
-
keyPath:
|
|
1914
|
-
autoIncrement: !!
|
|
1934
|
+
const w = await i(l.name, g, (S, P) => {
|
|
1935
|
+
let v;
|
|
1936
|
+
S.objectStoreNames.contains(h) ? v = P.objectStore(h) : v = S.createObjectStore(h, {
|
|
1937
|
+
keyPath: u?.keyPath ?? void 0,
|
|
1938
|
+
autoIncrement: !!u?.autoIncrement
|
|
1915
1939
|
});
|
|
1916
|
-
for (const
|
|
1917
|
-
|
|
1940
|
+
for (const _ of d)
|
|
1941
|
+
v.indexNames.contains(_.name) || v.createIndex(_.name, _.keyPath, _.options);
|
|
1918
1942
|
});
|
|
1919
|
-
return
|
|
1943
|
+
return w.onversionchange = () => {
|
|
1920
1944
|
try {
|
|
1921
|
-
|
|
1945
|
+
w.close();
|
|
1922
1946
|
} finally {
|
|
1923
|
-
|
|
1947
|
+
n.cache.delete(w.name);
|
|
1924
1948
|
}
|
|
1925
|
-
},
|
|
1949
|
+
}, w;
|
|
1926
1950
|
}
|
|
1927
|
-
async function r(l, h,
|
|
1928
|
-
let f =
|
|
1929
|
-
return f ? (f = f.then((
|
|
1930
|
-
const
|
|
1931
|
-
return
|
|
1932
|
-
})(),
|
|
1951
|
+
async function r(l, h, u) {
|
|
1952
|
+
let f = n.cache.get(l);
|
|
1953
|
+
return f ? (f = f.then((d) => s(d, h, u)), n.cache.set(l, f)) : (f = (async () => {
|
|
1954
|
+
const d = await i(l);
|
|
1955
|
+
return s(d, h, u);
|
|
1956
|
+
})(), n.cache.set(l, f)), f;
|
|
1933
1957
|
}
|
|
1934
|
-
|
|
1958
|
+
n.getDB = r;
|
|
1935
1959
|
async function o(l) {
|
|
1936
|
-
const h =
|
|
1937
|
-
if (
|
|
1960
|
+
const h = n.cache.get(l);
|
|
1961
|
+
if (n.cache.delete(l), h)
|
|
1938
1962
|
try {
|
|
1939
1963
|
(await h).close();
|
|
1940
1964
|
} catch {
|
|
1941
1965
|
}
|
|
1942
1966
|
}
|
|
1943
|
-
|
|
1967
|
+
n.closeConnection = o;
|
|
1944
1968
|
function a(l) {
|
|
1945
|
-
return new Promise((h,
|
|
1946
|
-
l.onsuccess = () => h(l.result), l.onerror = () =>
|
|
1969
|
+
return new Promise((h, u) => {
|
|
1970
|
+
l.onsuccess = () => h(l.result), l.onerror = () => u(l.error);
|
|
1947
1971
|
});
|
|
1948
1972
|
}
|
|
1949
|
-
|
|
1973
|
+
n.asyncRequest = a;
|
|
1950
1974
|
function c(l) {
|
|
1951
|
-
return new Promise((h,
|
|
1952
|
-
l.oncomplete = () => h(), l.onabort = () =>
|
|
1975
|
+
return new Promise((h, u) => {
|
|
1976
|
+
l.oncomplete = () => h(), l.onabort = () => u(l.error ?? new DOMException("Aborted", "AbortError")), l.onerror = () => u(l.error ?? new DOMException("TransactionError", "UnknownError"));
|
|
1953
1977
|
});
|
|
1954
1978
|
}
|
|
1955
|
-
|
|
1956
|
-
})(
|
|
1957
|
-
class
|
|
1979
|
+
n.waitTx = c;
|
|
1980
|
+
})(y || (y = {}));
|
|
1981
|
+
class ki {
|
|
1958
1982
|
constructor(e, t, i = {}) {
|
|
1959
1983
|
this.dbName = e, this.storeName = t, this.options = i;
|
|
1960
1984
|
}
|
|
1961
1985
|
get _iterBatch() {
|
|
1962
|
-
return this.options.iterBatch ??
|
|
1986
|
+
return this.options.iterBatch ?? y.defaults.iterBatch;
|
|
1963
1987
|
}
|
|
1964
1988
|
get _retryCfg() {
|
|
1965
|
-
const e = this.options.retry ??
|
|
1989
|
+
const e = this.options.retry ?? y.defaults.retry;
|
|
1966
1990
|
return { attempts: e.attempts ?? 3, baseDelayMs: e.baseDelayMs ?? 16 };
|
|
1967
1991
|
}
|
|
1968
1992
|
async _withStore(e, t) {
|
|
1969
1993
|
const i = this._retryCfg;
|
|
1970
|
-
return
|
|
1994
|
+
return y.withRetry(
|
|
1971
1995
|
i,
|
|
1972
1996
|
async () => {
|
|
1973
|
-
const
|
|
1997
|
+
const s = await y.getDB(this.dbName, this.storeName, this.options.ensure);
|
|
1974
1998
|
try {
|
|
1975
|
-
const r =
|
|
1976
|
-
return await
|
|
1999
|
+
const r = s.transaction(this.storeName, e), o = r.objectStore(this.storeName), a = await t(o);
|
|
2000
|
+
return await y.waitTx(r), a;
|
|
1977
2001
|
} catch (r) {
|
|
1978
2002
|
throw r;
|
|
1979
2003
|
}
|
|
1980
2004
|
},
|
|
1981
|
-
async (
|
|
1982
|
-
|
|
2005
|
+
async (s) => {
|
|
2006
|
+
y.shouldReconnect(s) && await y.closeConnection(this.dbName);
|
|
1983
2007
|
}
|
|
1984
2008
|
);
|
|
1985
2009
|
}
|
|
1986
2010
|
async get(e) {
|
|
1987
2011
|
return this._withStore("readonly", async (t) => {
|
|
1988
|
-
const i = await
|
|
2012
|
+
const i = await y.asyncRequest(t.get(e));
|
|
1989
2013
|
return i === void 0 ? void 0 : i;
|
|
1990
2014
|
});
|
|
1991
2015
|
}
|
|
1992
2016
|
async set(e, t) {
|
|
1993
2017
|
return await this._withStore("readwrite", async (i) => {
|
|
1994
|
-
const
|
|
1995
|
-
await
|
|
2018
|
+
const s = this.options.ensure?.keyPath != null ? i.put(t) : i.put(t, e);
|
|
2019
|
+
await y.asyncRequest(s);
|
|
1996
2020
|
}), this;
|
|
1997
2021
|
}
|
|
1998
2022
|
async delete(e) {
|
|
1999
2023
|
return this._withStore("readwrite", async (t) => {
|
|
2000
|
-
const i = await
|
|
2001
|
-
return await
|
|
2024
|
+
const i = await y.asyncRequest(t.get(e)) !== void 0;
|
|
2025
|
+
return await y.asyncRequest(t.delete(e)), i;
|
|
2002
2026
|
});
|
|
2003
2027
|
}
|
|
2004
2028
|
async clear() {
|
|
2005
2029
|
await this._withStore("readwrite", async (e) => {
|
|
2006
|
-
await
|
|
2030
|
+
await y.asyncRequest(e.clear());
|
|
2007
2031
|
});
|
|
2008
2032
|
}
|
|
2009
2033
|
async has(e) {
|
|
2010
2034
|
return await this.get(e) !== void 0;
|
|
2011
2035
|
}
|
|
2012
2036
|
async count() {
|
|
2013
|
-
return this._withStore("readonly", async (e) => await
|
|
2037
|
+
return this._withStore("readonly", async (e) => await y.asyncRequest(e.count()) ?? 0);
|
|
2014
2038
|
}
|
|
2015
2039
|
async *_iterateEntries() {
|
|
2016
2040
|
let e = null, t = !1;
|
|
2017
2041
|
const i = Math.max(1, this._iterBatch);
|
|
2018
2042
|
for (; !t; ) {
|
|
2019
|
-
const
|
|
2043
|
+
const s = await this._withStore("readonly", async (r) => {
|
|
2020
2044
|
const o = [], a = e === null ? void 0 : IDBKeyRange.lowerBound(e, !0);
|
|
2021
2045
|
return await new Promise((c, l) => {
|
|
2022
2046
|
const h = r.openCursor(a);
|
|
2023
2047
|
h.onerror = () => l(h.error), h.onsuccess = () => {
|
|
2024
|
-
const
|
|
2025
|
-
if (!
|
|
2048
|
+
const u = h.result;
|
|
2049
|
+
if (!u) {
|
|
2026
2050
|
t = !0, c();
|
|
2027
2051
|
return;
|
|
2028
2052
|
}
|
|
2029
|
-
o.push([
|
|
2053
|
+
o.push([u.key, u.value]), e = u.key, o.length >= i ? c() : u.continue();
|
|
2030
2054
|
};
|
|
2031
2055
|
}), o;
|
|
2032
2056
|
});
|
|
2033
|
-
for (const r of
|
|
2034
|
-
if (
|
|
2057
|
+
for (const r of s) yield r;
|
|
2058
|
+
if (s.length === 0) break;
|
|
2035
2059
|
}
|
|
2036
2060
|
}
|
|
2037
2061
|
entries() {
|
|
@@ -2055,9 +2079,9 @@ class di {
|
|
|
2055
2079
|
for await (const i of e) t.set(i, void 0);
|
|
2056
2080
|
return await this._withStore("readonly", async (i) => {
|
|
2057
2081
|
await Promise.all(
|
|
2058
|
-
t.keys().map(async (
|
|
2059
|
-
const r = await
|
|
2060
|
-
t.set(
|
|
2082
|
+
t.keys().map(async (s) => {
|
|
2083
|
+
const r = await y.asyncRequest(i.get(s));
|
|
2084
|
+
t.set(s, r === void 0 ? void 0 : r);
|
|
2061
2085
|
})
|
|
2062
2086
|
);
|
|
2063
2087
|
}), t;
|
|
@@ -2065,45 +2089,45 @@ class di {
|
|
|
2065
2089
|
async setMany(e) {
|
|
2066
2090
|
const t = this.options.ensure?.keyPath != null;
|
|
2067
2091
|
return await this._withStore("readwrite", async (i) => {
|
|
2068
|
-
for await (const [
|
|
2069
|
-
const o = t ? i.put(r) : i.put(r,
|
|
2070
|
-
await
|
|
2092
|
+
for await (const [s, r] of e) {
|
|
2093
|
+
const o = t ? i.put(r) : i.put(r, s);
|
|
2094
|
+
await y.asyncRequest(o);
|
|
2071
2095
|
}
|
|
2072
2096
|
}), this;
|
|
2073
2097
|
}
|
|
2074
2098
|
async deleteMany(e) {
|
|
2075
2099
|
let t = 0;
|
|
2076
2100
|
return await this._withStore("readwrite", async (i) => {
|
|
2077
|
-
for await (const
|
|
2078
|
-
await
|
|
2101
|
+
for await (const s of e)
|
|
2102
|
+
await y.asyncRequest(i.get(s)) !== void 0 && t++, await y.asyncRequest(i.delete(s));
|
|
2079
2103
|
}), t;
|
|
2080
2104
|
}
|
|
2081
2105
|
async disconnect() {
|
|
2082
|
-
await
|
|
2106
|
+
await y.closeConnection(this.dbName);
|
|
2083
2107
|
}
|
|
2084
2108
|
}
|
|
2085
|
-
class
|
|
2086
|
-
constructor(e, t, i = 1 / 0,
|
|
2087
|
-
this.dbName = e, this.storeName = t, this.ttl = i, this.version =
|
|
2109
|
+
class Ei {
|
|
2110
|
+
constructor(e, t, i = 1 / 0, s) {
|
|
2111
|
+
this.dbName = e, this.storeName = t, this.ttl = i, this.version = s, this.db = new ki(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(() => {
|
|
2088
2112
|
});
|
|
2089
2113
|
}
|
|
2090
2114
|
async _clearExpiredEntries() {
|
|
2091
2115
|
if (this.ttl === 1 / 0) return;
|
|
2092
2116
|
const e = Date.now(), t = [];
|
|
2093
|
-
for await (const [i,
|
|
2094
|
-
typeof
|
|
2117
|
+
for await (const [i, s] of this.db.entries())
|
|
2118
|
+
typeof s.time == "number" && e - s.time > this.ttl && t.push(i);
|
|
2095
2119
|
t.length > 0 && await this.db.deleteMany(t);
|
|
2096
2120
|
}
|
|
2097
2121
|
async get(e, t = this.ttl, i) {
|
|
2098
|
-
const
|
|
2099
|
-
if (!
|
|
2122
|
+
const s = await this.loadFromDB(e), r = this.checkIfExpired(s, t);
|
|
2123
|
+
if (!s || r) {
|
|
2100
2124
|
if (typeof i == "function") {
|
|
2101
2125
|
const o = await i();
|
|
2102
2126
|
return await this.set(e, o), o;
|
|
2103
2127
|
}
|
|
2104
2128
|
return null;
|
|
2105
2129
|
}
|
|
2106
|
-
return
|
|
2130
|
+
return s.value;
|
|
2107
2131
|
}
|
|
2108
2132
|
async set(e, t) {
|
|
2109
2133
|
const i = Date.now();
|
|
@@ -2118,8 +2142,8 @@ class ui {
|
|
|
2118
2142
|
};
|
|
2119
2143
|
return await this.db.set(c, h), h;
|
|
2120
2144
|
}
|
|
2121
|
-
const
|
|
2122
|
-
for (const [c, l] of Object.entries(
|
|
2145
|
+
const s = e, r = [], o = [], a = {};
|
|
2146
|
+
for (const [c, l] of Object.entries(s))
|
|
2123
2147
|
if (l === null || typeof l > "u")
|
|
2124
2148
|
o.push(c);
|
|
2125
2149
|
else {
|
|
@@ -2129,8 +2153,8 @@ class ui {
|
|
|
2129
2153
|
return r.length > 0 && await this.db.setMany(r), o.length > 0 && await this.db.deleteMany(o), a;
|
|
2130
2154
|
}
|
|
2131
2155
|
async has(e, t = this.ttl) {
|
|
2132
|
-
const i = await this.loadFromDB(e),
|
|
2133
|
-
return i !== null && !
|
|
2156
|
+
const i = await this.loadFromDB(e), s = this.checkIfExpired(i, t);
|
|
2157
|
+
return i !== null && !s;
|
|
2134
2158
|
}
|
|
2135
2159
|
async delete(e) {
|
|
2136
2160
|
await this.db.delete(e);
|
|
@@ -2170,27 +2194,27 @@ class ui {
|
|
|
2170
2194
|
return await this.db.clear(), this;
|
|
2171
2195
|
}
|
|
2172
2196
|
}
|
|
2173
|
-
class
|
|
2197
|
+
class Ci extends L {
|
|
2174
2198
|
constructor(e, t) {
|
|
2175
2199
|
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");
|
|
2176
2200
|
}
|
|
2177
|
-
createDatabase(e, t, i,
|
|
2201
|
+
createDatabase(e, t, i, s = "indexedDB") {
|
|
2178
2202
|
const r = "indexedDB" in window && window.indexedDB !== null;
|
|
2179
|
-
switch (
|
|
2203
|
+
switch (s === "indexedDB" && !r && (s = "localStorage"), s) {
|
|
2180
2204
|
case "indexedDB":
|
|
2181
|
-
return new
|
|
2205
|
+
return new Ei(this.config.dbName, e, t, i);
|
|
2182
2206
|
case "localStorage":
|
|
2183
2207
|
case "sessionStorage":
|
|
2184
2208
|
case "memory":
|
|
2185
|
-
return new
|
|
2209
|
+
return new xi(this.config.dbName, e, t, i, s);
|
|
2186
2210
|
default:
|
|
2187
|
-
throw new Error(`Unsupported storage engine: ${
|
|
2211
|
+
throw new Error(`Unsupported storage engine: ${s}`);
|
|
2188
2212
|
}
|
|
2189
2213
|
}
|
|
2190
2214
|
}
|
|
2191
|
-
class
|
|
2215
|
+
class Ii extends L {
|
|
2192
2216
|
constructor(e) {
|
|
2193
|
-
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage =
|
|
2217
|
+
super(e, "wikiPage", !0), this.ctx = e, this.WikiPage = wt(this.ctx.api);
|
|
2194
2218
|
}
|
|
2195
2219
|
static {
|
|
2196
2220
|
this.inject = ["api"];
|
|
@@ -2198,8 +2222,8 @@ class gi extends C {
|
|
|
2198
2222
|
async createInstance(e, t = !1) {
|
|
2199
2223
|
return await this.WikiPage.newFromApi(e);
|
|
2200
2224
|
}
|
|
2201
|
-
async newFromTitle(e, t = !1, i,
|
|
2202
|
-
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i },
|
|
2225
|
+
async newFromTitle(e, t = !1, i, s = !1) {
|
|
2226
|
+
return this.createInstance({ titles: e.toString(), converttitles: t, rvsection: i }, s);
|
|
2203
2227
|
}
|
|
2204
2228
|
async newFromPageId(e, t, i = !1) {
|
|
2205
2229
|
return this.createInstance({ pageids: e, rvsection: t }, i);
|
|
@@ -2211,15 +2235,15 @@ class gi extends C {
|
|
|
2211
2235
|
return this.WikiPage.newBlankPage(e);
|
|
2212
2236
|
}
|
|
2213
2237
|
}
|
|
2214
|
-
class
|
|
2238
|
+
class ge extends L {
|
|
2215
2239
|
constructor(e) {
|
|
2216
|
-
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 =
|
|
2240
|
+
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 = yt(this.ctx.wiki.siteInfo);
|
|
2217
2241
|
}
|
|
2218
2242
|
static {
|
|
2219
2243
|
this.inject = ["wiki", "wikiPage"];
|
|
2220
2244
|
}
|
|
2221
2245
|
newTitle(e, t) {
|
|
2222
|
-
return new this.Title(e, t);
|
|
2246
|
+
return typeof e == "string" ? new this.Title(e, t) : e;
|
|
2223
2247
|
}
|
|
2224
2248
|
newMainPageTitle() {
|
|
2225
2249
|
return this.newTitle(this.ctx.wiki.mainPageName);
|
|
@@ -2229,28 +2253,28 @@ class ce extends C {
|
|
|
2229
2253
|
return t?.title ? t.title : t?.pageId ? this.newTitleFromPageId(t.pageId) : null;
|
|
2230
2254
|
}
|
|
2231
2255
|
async newTitleFromAnyId(e, t = !1) {
|
|
2232
|
-
const { title: i, pageId:
|
|
2256
|
+
const { title: i, pageId: s, revId: r } = e ?? {};
|
|
2233
2257
|
if (typeof i == "string")
|
|
2234
2258
|
return this.newTitle(i);
|
|
2235
2259
|
let o, a;
|
|
2236
|
-
if (r ? (o = parseInt(r.toString(), 10), a = "revid") :
|
|
2260
|
+
if (r ? (o = parseInt(r.toString(), 10), a = "revid") : s && (o = parseInt(s.toString(), 10), a = "pageid"), !o || !a || isNaN(o) || o <= 0)
|
|
2237
2261
|
throw new Error("Invalid id or kind", { cause: e });
|
|
2238
2262
|
if (!t && this._cachedTitles.has(`${a}:${o}`))
|
|
2239
2263
|
return await this._cachedTitles.get(`${a}:${o}`);
|
|
2240
|
-
const { promise: c, resolve: l, reject: h } =
|
|
2264
|
+
const { promise: c, resolve: l, reject: h } = Pe();
|
|
2241
2265
|
this._cachedTitles.set(`${a}:${o}`, c);
|
|
2242
2266
|
try {
|
|
2243
|
-
const { wikiPage:
|
|
2267
|
+
const { wikiPage: u } = this.ctx;
|
|
2244
2268
|
let f = null;
|
|
2245
2269
|
if (a === "pageid")
|
|
2246
|
-
f = await
|
|
2270
|
+
f = await u.newFromPageId(o);
|
|
2247
2271
|
else if (a === "revid")
|
|
2248
|
-
f = await
|
|
2272
|
+
f = await u.newFromRevision(o);
|
|
2249
2273
|
else
|
|
2250
2274
|
throw new Error(`Invalid kind: ${a}`);
|
|
2251
2275
|
l(this.newTitle(f.title));
|
|
2252
|
-
} catch (
|
|
2253
|
-
this._cachedTitles.delete(`${a}:${o}`), h(
|
|
2276
|
+
} catch (u) {
|
|
2277
|
+
this._cachedTitles.delete(`${a}:${o}`), h(u);
|
|
2254
2278
|
}
|
|
2255
2279
|
return c;
|
|
2256
2280
|
}
|
|
@@ -2275,7 +2299,7 @@ class ce extends C {
|
|
|
2275
2299
|
const t = typeof e == "string" ? this.newTitle(e) : e;
|
|
2276
2300
|
if (!t || t.getNamespaceId() !== -1)
|
|
2277
2301
|
return null;
|
|
2278
|
-
let i,
|
|
2302
|
+
let i, s, r = "view";
|
|
2279
2303
|
const o = t.getMainDBKey().split("/").slice(1).join("/") || "";
|
|
2280
2304
|
if (t.isSpecial("edit") && o)
|
|
2281
2305
|
i = o, r = "edit";
|
|
@@ -2289,12 +2313,12 @@ class ce extends C {
|
|
|
2289
2313
|
else if (t.isSpecial("mytalk"))
|
|
2290
2314
|
i = t.newTitle(this.ctx.wiki.userInfo.name, 3).getPrefixedDBKey() + (o ? `/${o}` : "");
|
|
2291
2315
|
else if (t.isSpecial("newsection") && o)
|
|
2292
|
-
i = o,
|
|
2316
|
+
i = o, s = "new", r = "edit";
|
|
2293
2317
|
else
|
|
2294
2318
|
return null;
|
|
2295
2319
|
return {
|
|
2296
2320
|
title: new this.Title(i),
|
|
2297
|
-
section:
|
|
2321
|
+
section: s,
|
|
2298
2322
|
action: r
|
|
2299
2323
|
};
|
|
2300
2324
|
}
|
|
@@ -2307,28 +2331,28 @@ class ce extends C {
|
|
|
2307
2331
|
this.REG_SKIPPED_HREF = /^(#|javascript:|vbscript:|file:)/i;
|
|
2308
2332
|
}
|
|
2309
2333
|
validateHrefAttr(e) {
|
|
2310
|
-
return typeof e != "string" ? !1 : !
|
|
2334
|
+
return typeof e != "string" ? !1 : !ge.REG_SKIPPED_HREF.test(e);
|
|
2311
2335
|
}
|
|
2312
2336
|
parseWikiLink(e) {
|
|
2313
2337
|
if (!e || typeof e == "string" && !this.validateHrefAttr(e))
|
|
2314
2338
|
return null;
|
|
2315
|
-
const t =
|
|
2339
|
+
const t = We(e);
|
|
2316
2340
|
if (!this.isWikiLink(t.toString()))
|
|
2317
2341
|
return null;
|
|
2318
|
-
const i = t.searchParams,
|
|
2342
|
+
const i = t.searchParams, s = t.hash.replace("#", ""), r = i.get("action") || "view", o = i.get("title") || "", a = parseInt(i.get("curid") || "0", 10), c = parseInt(i.get("oldid") || "0", 10);
|
|
2319
2343
|
let l = o || (() => {
|
|
2320
2344
|
try {
|
|
2321
2345
|
return decodeURIComponent(t.pathname.substring(this.wikiArticlePath.length));
|
|
2322
|
-
} catch (
|
|
2323
|
-
return this.logger.error("parseLink", t,
|
|
2346
|
+
} catch (d) {
|
|
2347
|
+
return this.logger.error("parseLink", t, d), "";
|
|
2324
2348
|
}
|
|
2325
2349
|
})();
|
|
2326
2350
|
l.endsWith("index.php") && (l = "");
|
|
2327
|
-
let h,
|
|
2351
|
+
let h, u, f;
|
|
2328
2352
|
if (c)
|
|
2329
2353
|
f = c;
|
|
2330
2354
|
else if (a)
|
|
2331
|
-
|
|
2355
|
+
u = a;
|
|
2332
2356
|
else if (l)
|
|
2333
2357
|
h = this.newTitle(l);
|
|
2334
2358
|
else if (t.origin + t.pathname === this.ctx.wiki.landingPageUrl)
|
|
@@ -2337,29 +2361,29 @@ class ce extends C {
|
|
|
2337
2361
|
return null;
|
|
2338
2362
|
return {
|
|
2339
2363
|
title: h,
|
|
2340
|
-
pageId:
|
|
2364
|
+
pageId: u,
|
|
2341
2365
|
revId: f,
|
|
2342
2366
|
url: t,
|
|
2343
2367
|
params: i,
|
|
2344
|
-
hash:
|
|
2368
|
+
hash: s,
|
|
2345
2369
|
action: r
|
|
2346
2370
|
};
|
|
2347
2371
|
}
|
|
2348
2372
|
}
|
|
2349
|
-
var
|
|
2350
|
-
throw TypeError(
|
|
2351
|
-
},
|
|
2352
|
-
for (var
|
|
2373
|
+
var Li = Object.create, pe = Object.defineProperty, Ai = Object.getOwnPropertyDescriptor, Je = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), Ze = (n) => {
|
|
2374
|
+
throw TypeError(n);
|
|
2375
|
+
}, Pi = (n, e, t) => e in n ? pe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, Ri = (n, e) => pe(n, "name", { value: e, configurable: !0 }), Di = (n) => [, , , Li(n?.[Je("metadata")] ?? null)], Ti = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Qe = (n) => n !== void 0 && typeof n != "function" ? Ze("Function expected") : n, Mi = (n, e, t, i, s) => ({ kind: Ti[n], name: e, metadata: i, addInitializer: (r) => t._ ? Ze("Already initialized") : s.push(Qe(r || null)) }), Ui = (n, e) => Pi(e, Je("metadata"), n[3]), Bi = (n, e, t, i) => {
|
|
2376
|
+
for (var s = 0, r = n[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
|
|
2353
2377
|
return i;
|
|
2354
|
-
},
|
|
2355
|
-
var o, a, c, l = e & 7, h = !1,
|
|
2356
|
-
|
|
2378
|
+
}, Oi = (n, e, t, i, s, r) => {
|
|
2379
|
+
var o, a, c, l = e & 7, h = !1, u = 0, f = n[u] || (n[u] = []), d = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Ai(s, t));
|
|
2380
|
+
Ri(s, t);
|
|
2357
2381
|
for (var g = i.length - 1; g >= 0; g--)
|
|
2358
|
-
c =
|
|
2359
|
-
return
|
|
2360
|
-
},
|
|
2361
|
-
|
|
2362
|
-
class
|
|
2382
|
+
c = Mi(l, t, a = {}, n[3], f), o = (0, i[g])(s, c), a._ = 1, Qe(o) && (s = o);
|
|
2383
|
+
return Ui(n, s), d && pe(s, t, d), h ? l ^ 4 ? r : d : s;
|
|
2384
|
+
}, et, me, tt;
|
|
2385
|
+
et = [j(["storage", "wiki"])];
|
|
2386
|
+
class G extends (tt = L) {
|
|
2363
2387
|
constructor(e) {
|
|
2364
2388
|
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);
|
|
2365
2389
|
try {
|
|
@@ -2376,11 +2400,11 @@ class F extends (Xe = C) {
|
|
|
2376
2400
|
if (!e)
|
|
2377
2401
|
return this.getAll();
|
|
2378
2402
|
t ??= () => {
|
|
2379
|
-
const
|
|
2380
|
-
return this.logger.debug(e, `(fallback value: ${
|
|
2403
|
+
const s = this.defaultOf(e);
|
|
2404
|
+
return this.logger.debug(e, `(fallback value: ${s})`), s;
|
|
2381
2405
|
};
|
|
2382
2406
|
const i = await this.db.get(e, void 0);
|
|
2383
|
-
return i !== null ? i : await
|
|
2407
|
+
return i !== null ? i : await bt(t);
|
|
2384
2408
|
}
|
|
2385
2409
|
/**
|
|
2386
2410
|
* 获取全部注册的配置项以及最终生效的值
|
|
@@ -2397,8 +2421,8 @@ class F extends (Xe = C) {
|
|
|
2397
2421
|
}
|
|
2398
2422
|
async setMany(e) {
|
|
2399
2423
|
const t = this.loadDefaultConfigs(), i = {};
|
|
2400
|
-
for (const [
|
|
2401
|
-
r === t[
|
|
2424
|
+
for (const [s, r] of Object.entries(e))
|
|
2425
|
+
r === t[s] || r === void 0 ? i[s] = void 0 : i[s] = r;
|
|
2402
2426
|
return await this.db.set(i), this.ctx.emit("preferences/changed", { ctx: this.ctx, input: e, changes: i }), i;
|
|
2403
2427
|
}
|
|
2404
2428
|
defaultOf(e) {
|
|
@@ -2413,9 +2437,9 @@ class F extends (Xe = C) {
|
|
|
2413
2437
|
async getExportableRecord(e) {
|
|
2414
2438
|
e ??= await this.getAll();
|
|
2415
2439
|
const t = this.loadDefaultConfigs(), i = {};
|
|
2416
|
-
return Object.entries(t).sort(([
|
|
2417
|
-
const o = e[
|
|
2418
|
-
o !== void 0 && o !== r && (i[
|
|
2440
|
+
return Object.entries(t).sort(([s], [r]) => s.localeCompare(r)).forEach(([s, r]) => {
|
|
2441
|
+
const o = e[s];
|
|
2442
|
+
o !== void 0 && o !== r && (i[s] = o);
|
|
2419
2443
|
}), i;
|
|
2420
2444
|
}
|
|
2421
2445
|
loadDefaultConfigs() {
|
|
@@ -2423,8 +2447,8 @@ class F extends (Xe = C) {
|
|
|
2423
2447
|
return this.getConfigRegistries().forEach((t) => {
|
|
2424
2448
|
try {
|
|
2425
2449
|
const i = t.schema({});
|
|
2426
|
-
Object.entries(i).forEach(([
|
|
2427
|
-
e[
|
|
2450
|
+
Object.entries(i).forEach(([s, r]) => {
|
|
2451
|
+
e[s] = r;
|
|
2428
2452
|
});
|
|
2429
2453
|
} catch {
|
|
2430
2454
|
}
|
|
@@ -2433,17 +2457,17 @@ class F extends (Xe = C) {
|
|
|
2433
2457
|
}), e;
|
|
2434
2458
|
}
|
|
2435
2459
|
registerCustomConfig(e, t, i) {
|
|
2436
|
-
const
|
|
2460
|
+
const s = {
|
|
2437
2461
|
name: e,
|
|
2438
2462
|
schema: t,
|
|
2439
2463
|
category: i || "general"
|
|
2440
2464
|
}, r = this.customRegistries.findIndex((o) => o.name === e);
|
|
2441
|
-
return r >= 0 ? this.customRegistries[r] =
|
|
2465
|
+
return r >= 0 ? this.customRegistries[r] = s : this.customRegistries.push(s), this;
|
|
2442
2466
|
}
|
|
2443
2467
|
getConfigRegistries(e) {
|
|
2444
2468
|
return Array.from(this.ctx.registry.entries()).map(([t]) => t === null ? {
|
|
2445
2469
|
name: "@root",
|
|
2446
|
-
schema:
|
|
2470
|
+
schema: V?.PreferencesSchema || null
|
|
2447
2471
|
} : {
|
|
2448
2472
|
name: t.name,
|
|
2449
2473
|
schema: t?.PreferencesSchema || null
|
|
@@ -2459,7 +2483,7 @@ class F extends (Xe = C) {
|
|
|
2459
2483
|
}
|
|
2460
2484
|
defineCategory(e) {
|
|
2461
2485
|
const t = this.categoryDefinitions.findIndex((i) => i.name === e.name);
|
|
2462
|
-
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((i,
|
|
2486
|
+
return t < 0 ? this.categoryDefinitions.push(e) : this.categoryDefinitions[t] = e, this.categoryDefinitions.sort((i, s) => (i.index ?? 0) - (s.index ?? 0)), this;
|
|
2463
2487
|
}
|
|
2464
2488
|
getConfigCategories() {
|
|
2465
2489
|
return this.categoryDefinitions;
|
|
@@ -2467,49 +2491,49 @@ class F extends (Xe = C) {
|
|
|
2467
2491
|
async _migrageFromLegacyMasterDB() {
|
|
2468
2492
|
const e = this.ctx.storage.createDatabase("preferences", 1 / 0);
|
|
2469
2493
|
let t = 0;
|
|
2470
|
-
for await (const [i,
|
|
2471
|
-
i !== "_touched" && (await this.db.set(i,
|
|
2494
|
+
for await (const [i, s] of e.entries())
|
|
2495
|
+
i !== "_touched" && (await this.db.set(i, s.value), t++);
|
|
2472
2496
|
return t && this.logger.info(`Migrated ${t} preferences from master DB`), await e.clear(), await e?.db?.disconnect?.(), t;
|
|
2473
2497
|
}
|
|
2474
2498
|
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
const
|
|
2479
|
-
function
|
|
2480
|
-
const e =
|
|
2481
|
-
return (i, ...
|
|
2499
|
+
me = Di(tt);
|
|
2500
|
+
G = Oi(me, 0, "PreferencesService", et, G);
|
|
2501
|
+
Bi(me, 1, G);
|
|
2502
|
+
const it = "", nt = "", Ni = /\\\{/g, ji = /\\\}/g, Fi = new RegExp(it, "g"), zi = new RegExp(nt, "g");
|
|
2503
|
+
function Le(n) {
|
|
2504
|
+
const e = n ? { ...n } : void 0;
|
|
2505
|
+
return (i, ...s) => Ki(e, i, ...s);
|
|
2482
2506
|
}
|
|
2483
|
-
function
|
|
2507
|
+
function Ki(n, e, ...t) {
|
|
2484
2508
|
if (!e) return "";
|
|
2485
|
-
let i = String(e).replace(
|
|
2486
|
-
t.length === 1 && Array.isArray(t[0]) ? r = t[0] : t.length === 1 &&
|
|
2509
|
+
let i = String(e).replace(Ni, it).replace(ji, nt), s = {}, r = [];
|
|
2510
|
+
t.length === 1 && Array.isArray(t[0]) ? r = t[0] : t.length === 1 && Hi(t[0]) ? s = t[0] : t.length > 0 && (r = t);
|
|
2487
2511
|
const o = /* @__PURE__ */ Object.create(null);
|
|
2488
2512
|
if (r && r.length)
|
|
2489
2513
|
for (let a = 0; a < r.length; a++)
|
|
2490
2514
|
o[`$${a + 1}`] = r[a];
|
|
2491
|
-
if (n && Object.keys(n).length)
|
|
2492
|
-
for (const a of Object.keys(n)) o[a] = n[a];
|
|
2493
2515
|
if (s && Object.keys(s).length)
|
|
2494
|
-
for (const a of Object.keys(s))
|
|
2495
|
-
|
|
2516
|
+
for (const a of Object.keys(s)) o[a] = s[a];
|
|
2517
|
+
if (n && Object.keys(n).length)
|
|
2518
|
+
for (const a of Object.keys(n))
|
|
2519
|
+
typeof o[a] > "u" && (o[a] = n[a]);
|
|
2496
2520
|
return i = i.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g, (a, c) => {
|
|
2497
2521
|
const l = String(c).trim();
|
|
2498
2522
|
if (!l) return "";
|
|
2499
2523
|
try {
|
|
2500
|
-
const h =
|
|
2524
|
+
const h = Wi(l, o);
|
|
2501
2525
|
return h == null ? "" : String(h);
|
|
2502
2526
|
} catch {
|
|
2503
2527
|
return "";
|
|
2504
2528
|
}
|
|
2505
|
-
}), i.replace(
|
|
2529
|
+
}), i.replace(Fi, "{").replace(zi, "}");
|
|
2506
2530
|
}
|
|
2507
|
-
function
|
|
2508
|
-
return typeof
|
|
2531
|
+
function Hi(n) {
|
|
2532
|
+
return typeof n == "object" && n !== null && n.constructor === Object;
|
|
2509
2533
|
}
|
|
2510
|
-
const
|
|
2511
|
-
function
|
|
2512
|
-
const
|
|
2534
|
+
const Wi = qi();
|
|
2535
|
+
function qi() {
|
|
2536
|
+
const n = /* @__PURE__ */ new Set([
|
|
2513
2537
|
"eval",
|
|
2514
2538
|
"Object",
|
|
2515
2539
|
"Array",
|
|
@@ -2543,64 +2567,64 @@ function Di() {
|
|
|
2543
2567
|
`
|
|
2544
2568
|
);
|
|
2545
2569
|
return (t, i) => {
|
|
2546
|
-
const
|
|
2547
|
-
has: (r, o) => typeof o == "symbol" ? o in r : !(typeof o == "string" && (
|
|
2570
|
+
const s = new Proxy(i, {
|
|
2571
|
+
has: (r, o) => typeof o == "symbol" ? o in r : !(typeof o == "string" && (n.has(o) || o === "__expr__")),
|
|
2548
2572
|
get: (r, o) => {
|
|
2549
2573
|
if (o in r)
|
|
2550
2574
|
return r[o];
|
|
2551
2575
|
}
|
|
2552
2576
|
});
|
|
2553
|
-
return e(t,
|
|
2577
|
+
return e(t, s);
|
|
2554
2578
|
};
|
|
2555
2579
|
}
|
|
2556
|
-
function
|
|
2557
|
-
let t =
|
|
2580
|
+
function A(n, e) {
|
|
2581
|
+
let t = n[0] ?? "";
|
|
2558
2582
|
for (let i = 0; i < e.length; i++)
|
|
2559
|
-
t += String(e[i]) + (
|
|
2583
|
+
t += String(e[i]) + (n[i + 1] ?? "");
|
|
2560
2584
|
return t;
|
|
2561
2585
|
}
|
|
2562
|
-
class
|
|
2586
|
+
class Gi {
|
|
2563
2587
|
constructor(e, t) {
|
|
2564
2588
|
this.languages = /* @__PURE__ */ new Map(), this.currentLanguage = "en", this.missingKeys = /* @__PURE__ */ new Map(), this.usedKeys = /* @__PURE__ */ new Set();
|
|
2565
2589
|
const i = t?.language || "en";
|
|
2566
|
-
this.currentLanguage = i, this.interpolate =
|
|
2590
|
+
this.currentLanguage = i, this.interpolate = Le(t?.globals), e && Object.keys(e).length && this.setLanguageData(i, e);
|
|
2567
2591
|
}
|
|
2568
2592
|
setGlobals(e) {
|
|
2569
|
-
return this.interpolate =
|
|
2593
|
+
return this.interpolate = Le(e), this;
|
|
2570
2594
|
}
|
|
2571
2595
|
set(e, t) {
|
|
2572
|
-
const i = this.currentLanguage,
|
|
2596
|
+
const i = this.currentLanguage, s = this.ensureLanguageMap(i);
|
|
2573
2597
|
if (typeof e == "string" && typeof t == "string")
|
|
2574
|
-
|
|
2598
|
+
s.set(e, t);
|
|
2575
2599
|
else if (typeof e == "object") {
|
|
2576
2600
|
const r = this.toStringRecord(e);
|
|
2577
2601
|
for (const [o, a] of Object.entries(r))
|
|
2578
|
-
|
|
2602
|
+
s.set(o, a);
|
|
2579
2603
|
}
|
|
2580
2604
|
return this;
|
|
2581
2605
|
}
|
|
2582
2606
|
setLanguageData(e, t) {
|
|
2583
|
-
e =
|
|
2584
|
-
const i = this.ensureLanguageMap(e),
|
|
2585
|
-
for (const [r, o] of Object.entries(
|
|
2607
|
+
e = O(e).toLowerCase();
|
|
2608
|
+
const i = this.ensureLanguageMap(e), s = this.toStringRecord(t);
|
|
2609
|
+
for (const [r, o] of Object.entries(s))
|
|
2586
2610
|
i.set(r, o);
|
|
2587
2611
|
return this;
|
|
2588
2612
|
}
|
|
2589
2613
|
setLanguage(e) {
|
|
2590
|
-
return e =
|
|
2614
|
+
return e = O(e).toLowerCase(), this.currentLanguage = e, this;
|
|
2591
2615
|
}
|
|
2592
2616
|
getLanguage() {
|
|
2593
2617
|
return this.currentLanguage;
|
|
2594
2618
|
}
|
|
2595
2619
|
hasLanguage(e) {
|
|
2596
|
-
e =
|
|
2620
|
+
e = O(e).toLowerCase();
|
|
2597
2621
|
const t = this.languages.get(e);
|
|
2598
2622
|
return t && Object.keys(t).length > 0;
|
|
2599
2623
|
}
|
|
2600
2624
|
toStringRecord(e, t) {
|
|
2601
2625
|
const i = {};
|
|
2602
|
-
for (const [
|
|
2603
|
-
const o = t ? `${t}.${
|
|
2626
|
+
for (const [s, r] of Object.entries(e)) {
|
|
2627
|
+
const o = t ? `${t}.${s}` : s;
|
|
2604
2628
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
2605
2629
|
const a = this.toStringRecord(r, o);
|
|
2606
2630
|
for (const [c, l] of Object.entries(a))
|
|
@@ -2619,11 +2643,11 @@ class Ti {
|
|
|
2619
2643
|
get(e) {
|
|
2620
2644
|
this.recordUsedKey(e);
|
|
2621
2645
|
const t = this.resolveLanguageOrder(this.currentLanguage), i = [];
|
|
2622
|
-
for (const
|
|
2623
|
-
const o = this.languages.get(
|
|
2646
|
+
for (const s of t) {
|
|
2647
|
+
const o = this.languages.get(s)?.get(e);
|
|
2624
2648
|
if (typeof o < "u")
|
|
2625
2649
|
return i.length && this.recordMissing(e, i), o;
|
|
2626
|
-
i.push(
|
|
2650
|
+
i.push(s);
|
|
2627
2651
|
}
|
|
2628
2652
|
i.length && this.recordMissing(e, i);
|
|
2629
2653
|
}
|
|
@@ -2637,12 +2661,12 @@ class Ti {
|
|
|
2637
2661
|
}
|
|
2638
2662
|
$(...e) {
|
|
2639
2663
|
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
2640
|
-
const
|
|
2664
|
+
const s = e[0], r = e.slice(1), o = A(s, r);
|
|
2641
2665
|
return this.translate(o);
|
|
2642
2666
|
}
|
|
2643
2667
|
const i = e;
|
|
2644
|
-
return (
|
|
2645
|
-
const o =
|
|
2668
|
+
return (s, ...r) => {
|
|
2669
|
+
const o = A(s, r);
|
|
2646
2670
|
return this.translate(o, ...i);
|
|
2647
2671
|
};
|
|
2648
2672
|
}
|
|
@@ -2660,11 +2684,11 @@ class Ti {
|
|
|
2660
2684
|
}
|
|
2661
2685
|
$raw(...e) {
|
|
2662
2686
|
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
2663
|
-
const i = e[0],
|
|
2687
|
+
const i = e[0], s = e.slice(1), r = A(i, s);
|
|
2664
2688
|
return this.translateRaw(r);
|
|
2665
2689
|
}
|
|
2666
|
-
return (i, ...
|
|
2667
|
-
const r =
|
|
2690
|
+
return (i, ...s) => {
|
|
2691
|
+
const r = A(i, s);
|
|
2668
2692
|
return this.translateRaw(r);
|
|
2669
2693
|
};
|
|
2670
2694
|
}
|
|
@@ -2678,12 +2702,12 @@ class Ti {
|
|
|
2678
2702
|
}
|
|
2679
2703
|
$$(...e) {
|
|
2680
2704
|
if (Array.isArray(e[0]) && e[0]?.raw) {
|
|
2681
|
-
const
|
|
2705
|
+
const s = e[0], r = e.slice(1), o = A(s, r);
|
|
2682
2706
|
return this.message(o);
|
|
2683
2707
|
}
|
|
2684
2708
|
const i = e;
|
|
2685
|
-
return (
|
|
2686
|
-
const o =
|
|
2709
|
+
return (s, ...r) => {
|
|
2710
|
+
const o = A(s, r);
|
|
2687
2711
|
return this.message(o, ...i);
|
|
2688
2712
|
};
|
|
2689
2713
|
}
|
|
@@ -2701,11 +2725,11 @@ class Ti {
|
|
|
2701
2725
|
}
|
|
2702
2726
|
$$raw(...e) {
|
|
2703
2727
|
if (Array.isArray(e[0]) && e[0].raw) {
|
|
2704
|
-
const i = e[0],
|
|
2728
|
+
const i = e[0], s = e.slice(1), r = A(i, s);
|
|
2705
2729
|
return this.messageRaw(r);
|
|
2706
2730
|
}
|
|
2707
|
-
return (i, ...
|
|
2708
|
-
const r =
|
|
2731
|
+
return (i, ...s) => {
|
|
2732
|
+
const r = A(i, s);
|
|
2709
2733
|
return this.messageRaw(r);
|
|
2710
2734
|
};
|
|
2711
2735
|
}
|
|
@@ -2736,8 +2760,8 @@ class Ti {
|
|
|
2736
2760
|
recordMissing(e, t) {
|
|
2737
2761
|
if (!t.length) return;
|
|
2738
2762
|
const i = this.missingKeys.get(e) || [];
|
|
2739
|
-
for (const
|
|
2740
|
-
i.includes(
|
|
2763
|
+
for (const s of t)
|
|
2764
|
+
i.includes(s) || i.push(s);
|
|
2741
2765
|
this.missingKeys.set(e, i);
|
|
2742
2766
|
}
|
|
2743
2767
|
recordUsedKey(e) {
|
|
@@ -2753,19 +2777,19 @@ class Ti {
|
|
|
2753
2777
|
return e;
|
|
2754
2778
|
}
|
|
2755
2779
|
}
|
|
2756
|
-
var
|
|
2757
|
-
throw TypeError(
|
|
2758
|
-
},
|
|
2759
|
-
for (var
|
|
2780
|
+
var Xi = Object.create, we = Object.defineProperty, Yi = Object.getOwnPropertyDescriptor, st = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), rt = (n) => {
|
|
2781
|
+
throw TypeError(n);
|
|
2782
|
+
}, Vi = (n, e, t) => e in n ? we(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, Ji = (n, e) => we(n, "name", { value: e, configurable: !0 }), Zi = (n) => [, , , Xi(n?.[st("metadata")] ?? null)], Qi = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ot = (n) => n !== void 0 && typeof n != "function" ? rt("Function expected") : n, en = (n, e, t, i, s) => ({ kind: Qi[n], name: e, metadata: i, addInitializer: (r) => t._ ? rt("Already initialized") : s.push(ot(r || null)) }), tn = (n, e) => Vi(e, st("metadata"), n[3]), nn = (n, e, t, i) => {
|
|
2783
|
+
for (var s = 0, r = n[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
|
|
2760
2784
|
return i;
|
|
2761
|
-
},
|
|
2762
|
-
var o, a, c, l = e & 7, h = !1,
|
|
2763
|
-
|
|
2785
|
+
}, sn = (n, e, t, i, s, r) => {
|
|
2786
|
+
var o, a, c, l = e & 7, h = !1, u = 0, f = n[u] || (n[u] = []), d = l && (s = s.prototype, l < 5 && (l > 3 || !h) && Yi(s, t));
|
|
2787
|
+
Ji(s, t);
|
|
2764
2788
|
for (var g = i.length - 1; g >= 0; g--)
|
|
2765
|
-
c =
|
|
2766
|
-
return
|
|
2767
|
-
},
|
|
2768
|
-
const
|
|
2789
|
+
c = en(l, t, a = {}, n[3], f), o = (0, i[g])(s, c), a._ = 1, ot(o) && (s = o);
|
|
2790
|
+
return tn(n, s), d && we(s, t, d), h ? l ^ 4 ? r : d : s;
|
|
2791
|
+
}, at, ye, lt;
|
|
2792
|
+
const Ae = new p(
|
|
2769
2793
|
p.object({
|
|
2770
2794
|
manifest_version: p.const(1).required(),
|
|
2771
2795
|
base_language: p.string().required(),
|
|
@@ -2778,27 +2802,29 @@ const Se = new p(
|
|
|
2778
2802
|
endonym: p.string(),
|
|
2779
2803
|
data: p.transform(
|
|
2780
2804
|
p.dict(p.any()).default({}),
|
|
2781
|
-
(
|
|
2805
|
+
(n) => Object.keys(n).length > 0 ? n : void 0
|
|
2782
2806
|
)
|
|
2783
2807
|
})
|
|
2784
2808
|
).required()
|
|
2785
2809
|
})
|
|
2786
2810
|
);
|
|
2787
|
-
|
|
2811
|
+
at = [j(["wiki", "preferences"]), vt(
|
|
2788
2812
|
p.object({
|
|
2789
2813
|
"i18n.index_url": p.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(
|
|
2790
|
-
|
|
2814
|
+
Re.I18N_INDEX_URL
|
|
2791
2815
|
)
|
|
2792
2816
|
}).description("").extra("category", "general")
|
|
2793
2817
|
)];
|
|
2794
|
-
class
|
|
2818
|
+
class X extends (lt = L) {
|
|
2795
2819
|
constructor(e) {
|
|
2796
|
-
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
|
|
2820
|
+
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 Gi(
|
|
2797
2821
|
{},
|
|
2798
2822
|
{
|
|
2799
2823
|
language: "",
|
|
2800
2824
|
globals: {
|
|
2801
|
-
|
|
2825
|
+
userName: this.ctx.wiki.userInfo.name || "",
|
|
2826
|
+
userId: this.ctx.wiki.userInfo.id || 0,
|
|
2827
|
+
siteName: this.ctx.wiki.siteInfo.general.sitename || ""
|
|
2802
2828
|
}
|
|
2803
2829
|
}
|
|
2804
2830
|
), this.i18nIndexDB = e.storage.createDatabase(
|
|
@@ -2841,10 +2867,10 @@ class z extends (tt = C) {
|
|
|
2841
2867
|
this._indexCache = t, Object.entries(t.languages).forEach(([r, o]) => {
|
|
2842
2868
|
o.data && Object.keys(o.data).length > 0 && this.manager.setLanguageData(r, o.data);
|
|
2843
2869
|
});
|
|
2844
|
-
const i = await this.ctx.preferences.get("language"),
|
|
2845
|
-
this.logger.debug("Settings", { prefer: i, normalized:
|
|
2870
|
+
const i = await this.ctx.preferences.get("language"), s = this.normalizeLanguageCode(i);
|
|
2871
|
+
this.logger.debug("Settings", { prefer: i, normalized: s });
|
|
2846
2872
|
try {
|
|
2847
|
-
await this.switchLanguage(
|
|
2873
|
+
await this.switchLanguage(s), this.logger.info(`Initialized for language: ${this.language}`);
|
|
2848
2874
|
} catch (r) {
|
|
2849
2875
|
this.logger.error("Failed to fetch i18n index", r), this.manager.setLanguage("en");
|
|
2850
2876
|
}
|
|
@@ -2870,7 +2896,7 @@ class z extends (tt = C) {
|
|
|
2870
2896
|
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));
|
|
2871
2897
|
}
|
|
2872
2898
|
normalizeLanguageCode(e) {
|
|
2873
|
-
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"),
|
|
2899
|
+
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"), O(String(e)).toLowerCase());
|
|
2874
2900
|
}
|
|
2875
2901
|
get language() {
|
|
2876
2902
|
return this.manager.getLanguage();
|
|
@@ -2894,8 +2920,8 @@ class z extends (tt = C) {
|
|
|
2894
2920
|
* - 若 language 为当前语言,将立即可用;必要时你可以手动触发 UI 刷新或监听 i18n/changed。
|
|
2895
2921
|
*/
|
|
2896
2922
|
async registerMessages(e, t, i) {
|
|
2897
|
-
const
|
|
2898
|
-
this.manager.setLanguageData(e,
|
|
2923
|
+
const s = i?.namespace ? { [i.namespace]: t } : t;
|
|
2924
|
+
this.manager.setLanguageData(e, s), e === this.language && this.ctx.emit("i18n/changed", { ctx: this.ctx, language: this.language });
|
|
2899
2925
|
}
|
|
2900
2926
|
/**
|
|
2901
2927
|
* 列出可用语言与文件(来源于 index.json)
|
|
@@ -2908,11 +2934,11 @@ class z extends (tt = C) {
|
|
|
2908
2934
|
);
|
|
2909
2935
|
}
|
|
2910
2936
|
findLanguageMeta(e, t) {
|
|
2911
|
-
const i =
|
|
2912
|
-
if (
|
|
2937
|
+
const i = O(String(t)).toLowerCase(), s = e.languages[i];
|
|
2938
|
+
if (s)
|
|
2913
2939
|
return {
|
|
2914
2940
|
code: i,
|
|
2915
|
-
...
|
|
2941
|
+
...s
|
|
2916
2942
|
};
|
|
2917
2943
|
{
|
|
2918
2944
|
const r = e.languages.en;
|
|
@@ -2925,10 +2951,10 @@ class z extends (tt = C) {
|
|
|
2925
2951
|
}
|
|
2926
2952
|
async getI18nIndex(e, t = !1) {
|
|
2927
2953
|
if (!t) {
|
|
2928
|
-
const
|
|
2929
|
-
if (
|
|
2954
|
+
const s = await this.i18nIndexDB.get(e);
|
|
2955
|
+
if (s)
|
|
2930
2956
|
try {
|
|
2931
|
-
return
|
|
2957
|
+
return Ae(s);
|
|
2932
2958
|
} catch (r) {
|
|
2933
2959
|
this.logger.error("Failed to parse cached i18n index", r), this.i18nIndexDB.delete(e);
|
|
2934
2960
|
}
|
|
@@ -2938,7 +2964,7 @@ class z extends (tt = C) {
|
|
|
2938
2964
|
}
|
|
2939
2965
|
async fetchI18nIndex(e) {
|
|
2940
2966
|
const t = await fetch(e).then((i) => i.json());
|
|
2941
|
-
return
|
|
2967
|
+
return Ae(t);
|
|
2942
2968
|
}
|
|
2943
2969
|
async ensureLanguageLoaded(e) {
|
|
2944
2970
|
if (!this.manager || !this._indexCache) throw new Error("I18nManager is not initialized");
|
|
@@ -2951,14 +2977,14 @@ class z extends (tt = C) {
|
|
|
2951
2977
|
if (!this._indexCache) throw new Error("I18n index is not loaded");
|
|
2952
2978
|
const i = this.findLanguageMeta(this._indexCache, e);
|
|
2953
2979
|
if (!i) return {};
|
|
2954
|
-
const
|
|
2980
|
+
const s = `${this._indexUrl}#${i.file}`;
|
|
2955
2981
|
if (!t) {
|
|
2956
|
-
const o = await this.i18nDataDB.get(
|
|
2982
|
+
const o = await this.i18nDataDB.get(s);
|
|
2957
2983
|
if (o && Object.keys(o).length > 0)
|
|
2958
2984
|
return this.logger.debug("Using cached language data", e, o), o;
|
|
2959
2985
|
}
|
|
2960
2986
|
const r = i.data || await fetch(new URL(i.file, this._indexUrl).toString()).then((o) => o.json());
|
|
2961
|
-
return this.i18nDataDB.set(
|
|
2987
|
+
return this.i18nDataDB.set(s, r), this.logger.debug("Language data fetched", e, i.file, r), r;
|
|
2962
2988
|
}
|
|
2963
2989
|
/**
|
|
2964
2990
|
* 获取缺失键报告,形如:
|
|
@@ -2977,14 +3003,185 @@ class z extends (tt = C) {
|
|
|
2977
3003
|
await this.i18nIndexDB.clear(), await this.i18nDataDB.clear();
|
|
2978
3004
|
}
|
|
2979
3005
|
}
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3006
|
+
ye = Zi(lt);
|
|
3007
|
+
X = sn(ye, 0, "I18nService", at, X);
|
|
3008
|
+
nn(ye, 1, X);
|
|
3009
|
+
const rn = new TextEncoder();
|
|
3010
|
+
function on(n) {
|
|
3011
|
+
if (typeof n == "string") return rn.encode(n);
|
|
3012
|
+
if (n instanceof ArrayBuffer) return new Uint8Array(n);
|
|
3013
|
+
if (ArrayBuffer.isView(n))
|
|
3014
|
+
return new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
3015
|
+
throw new TypeError("Unsupported input type");
|
|
3016
|
+
}
|
|
3017
|
+
function an(n) {
|
|
3018
|
+
let e = "";
|
|
3019
|
+
for (let t = 0; t < n.length; t++) {
|
|
3020
|
+
const i = n[t].toString(16).padStart(2, "0");
|
|
3021
|
+
e += i;
|
|
3022
|
+
}
|
|
3023
|
+
return e;
|
|
3024
|
+
}
|
|
3025
|
+
function ln(n, e) {
|
|
3026
|
+
return n << e | n >>> 32 - e;
|
|
3027
|
+
}
|
|
3028
|
+
const cn = [
|
|
3029
|
+
7,
|
|
3030
|
+
12,
|
|
3031
|
+
17,
|
|
3032
|
+
22,
|
|
3033
|
+
7,
|
|
3034
|
+
12,
|
|
3035
|
+
17,
|
|
3036
|
+
22,
|
|
3037
|
+
7,
|
|
3038
|
+
12,
|
|
3039
|
+
17,
|
|
3040
|
+
22,
|
|
3041
|
+
7,
|
|
3042
|
+
12,
|
|
3043
|
+
17,
|
|
3044
|
+
22,
|
|
3045
|
+
5,
|
|
3046
|
+
9,
|
|
3047
|
+
14,
|
|
3048
|
+
20,
|
|
3049
|
+
5,
|
|
3050
|
+
9,
|
|
3051
|
+
14,
|
|
3052
|
+
20,
|
|
3053
|
+
5,
|
|
3054
|
+
9,
|
|
3055
|
+
14,
|
|
3056
|
+
20,
|
|
3057
|
+
5,
|
|
3058
|
+
9,
|
|
3059
|
+
14,
|
|
3060
|
+
20,
|
|
3061
|
+
4,
|
|
3062
|
+
11,
|
|
3063
|
+
16,
|
|
3064
|
+
23,
|
|
3065
|
+
4,
|
|
3066
|
+
11,
|
|
3067
|
+
16,
|
|
3068
|
+
23,
|
|
3069
|
+
4,
|
|
3070
|
+
11,
|
|
3071
|
+
16,
|
|
3072
|
+
23,
|
|
3073
|
+
4,
|
|
3074
|
+
11,
|
|
3075
|
+
16,
|
|
3076
|
+
23,
|
|
3077
|
+
6,
|
|
3078
|
+
10,
|
|
3079
|
+
15,
|
|
3080
|
+
21,
|
|
3081
|
+
6,
|
|
3082
|
+
10,
|
|
3083
|
+
15,
|
|
3084
|
+
21,
|
|
3085
|
+
6,
|
|
3086
|
+
10,
|
|
3087
|
+
15,
|
|
3088
|
+
21,
|
|
3089
|
+
6,
|
|
3090
|
+
10,
|
|
3091
|
+
15,
|
|
3092
|
+
21
|
|
3093
|
+
], hn = new Array(64).fill(0).map((n, e) => Math.floor(Math.abs(Math.sin(e + 1)) * 2 ** 32) >>> 0);
|
|
3094
|
+
function un(n) {
|
|
3095
|
+
const e = on(n), t = (56 - (e.length + 1) % 64 + 64) % 64, i = e.length + 1 + t + 8, s = new Uint8Array(i);
|
|
3096
|
+
s.set(e, 0), s[e.length] = 128;
|
|
3097
|
+
const r = e.length, o = r << 3 >>> 0, a = r >>> 29 >>> 0, c = new DataView(s.buffer);
|
|
3098
|
+
c.setUint32(i - 8, o, !0), c.setUint32(i - 4, a, !0);
|
|
3099
|
+
let l = 1732584193, h = 4023233417, u = 2562383102, f = 271733878;
|
|
3100
|
+
const d = new Uint32Array(16);
|
|
3101
|
+
for (let S = 0; S < s.length; S += 64) {
|
|
3102
|
+
for (let $ = 0; $ < 16; $++) d[$] = c.getUint32(S + $ * 4, !0);
|
|
3103
|
+
let P = l, v = h, _ = u, C = f;
|
|
3104
|
+
for (let $ = 0; $ < 64; $++) {
|
|
3105
|
+
let M, U;
|
|
3106
|
+
$ < 16 ? (M = v & _ | ~v & C, U = $) : $ < 32 ? (M = C & v | ~C & _, U = (5 * $ + 1) % 16) : $ < 48 ? (M = v ^ _ ^ C, U = (3 * $ + 5) % 16) : (M = _ ^ (v | ~C), U = 7 * $ % 16);
|
|
3107
|
+
const gt = C, pt = P + M + hn[$] + d[U] >>> 0;
|
|
3108
|
+
C = _, _ = v, v = v + ln(pt, cn[$]) >>> 0, P = gt;
|
|
3109
|
+
}
|
|
3110
|
+
l = l + P >>> 0, h = h + v >>> 0, u = u + _ >>> 0, f = f + C >>> 0;
|
|
3111
|
+
}
|
|
3112
|
+
const g = new Uint8Array(16), w = new DataView(g.buffer);
|
|
3113
|
+
return w.setUint32(0, l, !0), w.setUint32(4, h, !0), w.setUint32(8, u, !0), w.setUint32(12, f, !0), g;
|
|
3114
|
+
}
|
|
3115
|
+
var dn = Object.create, be = Object.defineProperty, fn = Object.getOwnPropertyDescriptor, ct = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), ht = (n) => {
|
|
3116
|
+
throw TypeError(n);
|
|
3117
|
+
}, gn = (n, e, t) => e in n ? be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, pn = (n, e) => be(n, "name", { value: e, configurable: !0 }), mn = (n) => [, , , dn(n?.[ct("metadata")] ?? null)], wn = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ut = (n) => n !== void 0 && typeof n != "function" ? ht("Function expected") : n, yn = (n, e, t, i, s) => ({ kind: wn[n], name: e, metadata: i, addInitializer: (r) => t._ ? ht("Already initialized") : s.push(ut(r || null)) }), bn = (n, e) => gn(e, ct("metadata"), n[3]), vn = (n, e, t, i) => {
|
|
3118
|
+
for (var s = 0, r = n[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
|
|
3119
|
+
return i;
|
|
3120
|
+
}, _n = (n, e, t, i, s, r) => {
|
|
3121
|
+
var o, a, c, l = e & 7, h = !1, u = 0, f = n[u] || (n[u] = []), d = l && (s = s.prototype, l < 5 && (l > 3 || !h) && fn(s, t));
|
|
3122
|
+
pn(s, t);
|
|
3123
|
+
for (var g = i.length - 1; g >= 0; g--)
|
|
3124
|
+
c = yn(l, t, a = {}, n[3], f), o = (0, i[g])(s, c), a._ = 1, ut(o) && (s = o);
|
|
3125
|
+
return bn(n, s), d && be(s, t, d), h ? l ^ 4 ? r : d : s;
|
|
3126
|
+
}, dt, ve, ft;
|
|
3127
|
+
dt = [j(["wiki", "wikiTitle", "wikiPage", "apiService"])];
|
|
3128
|
+
class Y extends (ft = L) {
|
|
3129
|
+
constructor(e) {
|
|
3130
|
+
super(e, "wikiFile", !0), this.ctx = e;
|
|
3131
|
+
}
|
|
3132
|
+
get fileRepos() {
|
|
3133
|
+
return this.ctx.wiki.fileRepos || [];
|
|
3134
|
+
}
|
|
3135
|
+
get defaultFileRepo() {
|
|
3136
|
+
return this.fileRepos[0];
|
|
3137
|
+
}
|
|
3138
|
+
get localFileRepo() {
|
|
3139
|
+
return this.fileRepos.find((e) => e.local);
|
|
3140
|
+
}
|
|
3141
|
+
get writableFileRepo() {
|
|
3142
|
+
return this.fileRepos.find((e) => e.canUpload);
|
|
3143
|
+
}
|
|
3144
|
+
getFileName(e) {
|
|
3145
|
+
if (e = this.ctx.wikiTitle.newTitle(e, 6), ![6, -2].includes(e.getNamespaceId()))
|
|
3146
|
+
throw new Error("Not a file title");
|
|
3147
|
+
return e.getMainDBKey().split("/").pop() || "";
|
|
3148
|
+
}
|
|
3149
|
+
getHashPath(e, t = 2) {
|
|
3150
|
+
const i = this.getFileName(e), s = an(un(i));
|
|
3151
|
+
let r = [];
|
|
3152
|
+
for (let o = 1; o <= t; o++)
|
|
3153
|
+
r.push(s.slice(0, o));
|
|
3154
|
+
return r.push(i), r.join("/");
|
|
3155
|
+
}
|
|
3156
|
+
getFileUrl(e, t) {
|
|
3157
|
+
if (t = t || this.defaultFileRepo, !t)
|
|
3158
|
+
throw new Error("No file repository found");
|
|
3159
|
+
const i = this.getHashPath(e);
|
|
3160
|
+
return new URL(`${t.rootUrl}/${i}`, location.origin).toString();
|
|
3161
|
+
}
|
|
3162
|
+
async upload(e, t) {
|
|
3163
|
+
if (t = t || this.writableFileRepo, !t?.canUpload)
|
|
3164
|
+
throw new Error("No writable file repository found");
|
|
3165
|
+
if (!e.file && !e.url && !e.chunk && !e.filekey)
|
|
3166
|
+
throw new Error('At least one of "file", "url", "chunk", or "filekey" is required');
|
|
3167
|
+
return this.ctx.apiService.getClientByFileRepo(t).postWithToken(
|
|
3168
|
+
"csrf",
|
|
3169
|
+
{
|
|
3170
|
+
action: "upload",
|
|
3171
|
+
...e
|
|
3172
|
+
},
|
|
3173
|
+
{ fexiosOptions: { timeout: 0 } }
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
ve = mn(ft);
|
|
3178
|
+
Y = _n(ve, 0, "WikiFileService", dt, Y);
|
|
3179
|
+
vn(ve, 1, Y);
|
|
3180
|
+
class V extends _t {
|
|
2984
3181
|
constructor(e) {
|
|
2985
3182
|
super({
|
|
2986
3183
|
name: "InPageEdit"
|
|
2987
|
-
}), this.version = "0.
|
|
3184
|
+
}), this.version = "0.15.0", this.Endpoints = Re, this.schema = p, this.config = St(V.DEFAULT_CONFIG, e), this.logger = It({
|
|
2988
3185
|
name: "IPE",
|
|
2989
3186
|
color: "#33aaff",
|
|
2990
3187
|
level: this.config.logLevel
|
|
@@ -2994,17 +3191,17 @@ class K extends lt {
|
|
|
2994
3191
|
this.DEFAULT_CONFIG = {
|
|
2995
3192
|
apiConfigs: {},
|
|
2996
3193
|
legacyPreferences: {},
|
|
2997
|
-
logLevel:
|
|
3194
|
+
logLevel: De.info,
|
|
2998
3195
|
storageNamespace: "InPageEdit",
|
|
2999
3196
|
autoloadStyles: !0,
|
|
3000
3197
|
autoInstallCorePlugins: !0
|
|
3001
3198
|
};
|
|
3002
3199
|
}
|
|
3003
3200
|
async #e() {
|
|
3004
|
-
await this.#i(), this.config.autoInstallCorePlugins && this.#
|
|
3201
|
+
await this.#i(), this.config.autoInstallCorePlugins && this.#n(), this.#s();
|
|
3005
3202
|
}
|
|
3006
3203
|
async #i() {
|
|
3007
|
-
this.plugin(
|
|
3204
|
+
this.plugin(X), this.plugin(Lt, this.config.apiConfigs), this.plugin(H), this.plugin(jt), this.plugin(di), this.plugin(G), this.plugin(Ci, { dbName: this.config.storageNamespace }), this.plugin(Y), this.plugin(q), this.plugin(Ii), this.plugin(ge), this.#t([
|
|
3008
3205
|
"i18n",
|
|
3009
3206
|
"$",
|
|
3010
3207
|
"$$",
|
|
@@ -3026,65 +3223,68 @@ class K extends lt {
|
|
|
3026
3223
|
#t(e) {
|
|
3027
3224
|
if (!Array.isArray(e) || e.length === 0) return this;
|
|
3028
3225
|
for (const t of e) {
|
|
3029
|
-
const i = this[
|
|
3226
|
+
const i = this[V.internal][t];
|
|
3030
3227
|
i?.type === "service" && (i.builtin = !0);
|
|
3031
3228
|
}
|
|
3032
3229
|
return this;
|
|
3033
3230
|
}
|
|
3034
3231
|
// TODO: 这里不应该硬编码,暂时先这样
|
|
3035
|
-
async #
|
|
3232
|
+
async #n() {
|
|
3036
3233
|
[
|
|
3037
|
-
import("./index-
|
|
3038
|
-
import("./index-
|
|
3234
|
+
import("./index-C3t-Xj3e.js").then(({ PluginAnalytics: t }) => t),
|
|
3235
|
+
import("./index-Cq8xPcEY.js").then(
|
|
3039
3236
|
({ PluginInArticleLinks: t }) => t
|
|
3040
3237
|
),
|
|
3041
|
-
import("./index-
|
|
3042
|
-
import("./index-
|
|
3238
|
+
import("./index-CbdkXGs7.js").then(({ PluginPluginStore: t }) => t),
|
|
3239
|
+
import("./index-rKL4D_7I.js").then(
|
|
3043
3240
|
({ PluginPreferencesUI: t }) => t
|
|
3044
3241
|
),
|
|
3045
|
-
import("./index-
|
|
3046
|
-
import("./index-
|
|
3047
|
-
import("./index-
|
|
3242
|
+
import("./index-CS1kidKF.js").then(({ PluginQuickEdit: t }) => t),
|
|
3243
|
+
import("./index-DPA1ptYq.js").then(({ PluginQuickMove: t }) => t),
|
|
3244
|
+
import("./index-mFwJhDwE.js").then(
|
|
3048
3245
|
({ PluginQuickPreview: t }) => t
|
|
3049
3246
|
),
|
|
3050
|
-
import("./index-
|
|
3051
|
-
import("./index-
|
|
3247
|
+
import("./index-B9VO3swL.js").then(({ PluginQuickDiff: t }) => t),
|
|
3248
|
+
import("./index-n5KKWE9v.js").then(
|
|
3052
3249
|
({ PluginQuickRedirect: t }) => t
|
|
3053
3250
|
),
|
|
3054
|
-
import("./index-
|
|
3251
|
+
import("./index-FvMu0Ka0.js").then(({ PluginQuickUpload: t }) => t),
|
|
3252
|
+
import("./index-Cb2_vqBl.js").then(({ PluginQuickUsage: t }) => t),
|
|
3253
|
+
import("./index-DjyjqpeO.js").then(({ PluginToolbox: t }) => t)
|
|
3055
3254
|
].forEach(async (t) => {
|
|
3056
3255
|
this.plugin(await t);
|
|
3057
3256
|
});
|
|
3058
3257
|
}
|
|
3059
3258
|
// TODO: 应该抽象到 PluginTheme 中去,暂时先硬编码
|
|
3060
|
-
async #
|
|
3259
|
+
async #s() {
|
|
3061
3260
|
this.inject(["resourceLoader"], (e) => {
|
|
3062
3261
|
this.config.autoloadStyles && e.resourceLoader.loadStyle(import.meta.resolve("./style.css"));
|
|
3063
3262
|
});
|
|
3064
3263
|
}
|
|
3065
3264
|
async withInject(e) {
|
|
3066
|
-
const { promise: t, resolve: i } =
|
|
3067
|
-
return this.inject(e, (
|
|
3068
|
-
i(
|
|
3265
|
+
const { promise: t, resolve: i } = Pe();
|
|
3266
|
+
return this.inject(e, (s) => {
|
|
3267
|
+
i(s);
|
|
3069
3268
|
}), t;
|
|
3070
3269
|
}
|
|
3071
3270
|
}
|
|
3072
3271
|
export {
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3272
|
+
De as $,
|
|
3273
|
+
Lt as A,
|
|
3274
|
+
H as C,
|
|
3275
|
+
V as I,
|
|
3276
|
+
di as M,
|
|
3277
|
+
W as N,
|
|
3278
|
+
ue as P,
|
|
3279
|
+
jt as R,
|
|
3280
|
+
It as S,
|
|
3281
|
+
Y as W,
|
|
3282
|
+
Ci as a,
|
|
3283
|
+
b,
|
|
3284
|
+
G as c,
|
|
3285
|
+
q as d,
|
|
3286
|
+
Ii as e,
|
|
3287
|
+
ge as f,
|
|
3288
|
+
oe as m
|
|
3089
3289
|
};
|
|
3090
|
-
//# sourceMappingURL=index-
|
|
3290
|
+
//# sourceMappingURL=index-CcAmmXbb.js.map
|