@inpageedit/core 0.17.3 → 0.18.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/InPageEdit.js +2 -2
- package/dist/{PluginImagesUsed-DWpe6M-r.js → PluginImagesUsed-D9D4IRJt.js} +2 -2
- package/dist/{PluginImagesUsed-DWpe6M-r.js.map → PluginImagesUsed-D9D4IRJt.js.map} +1 -1
- package/dist/{PluginPrefSync-CmVHL2wx.js → PluginPrefSync-DzmDUTF-.js} +2 -2
- package/dist/{PluginPrefSync-CmVHL2wx.js.map → PluginPrefSync-DzmDUTF-.js.map} +1 -1
- package/dist/{PluginStoreApp-CmLstT3F.js → PluginStoreApp-BifScxOt.js} +2 -2
- package/dist/{PluginStoreApp-CmLstT3F.js.map → PluginStoreApp-BifScxOt.js.map} +1 -1
- package/dist/{PluginTemplatesUsed-BjRYFXHz.js → PluginTemplatesUsed-De0Y5yo9.js} +2 -2
- package/dist/{PluginTemplatesUsed-BjRYFXHz.js.map → PluginTemplatesUsed-De0Y5yo9.js.map} +1 -1
- package/dist/core.js +2 -2
- package/dist/{index-DTU2DZU6.js → index-9I-lTJju.js} +153 -143
- package/dist/index-9I-lTJju.js.map +1 -0
- package/dist/{index-C0spLL-i.js → index-Ay5PsdkH.js} +250 -248
- package/dist/{index-C0spLL-i.js.map → index-Ay5PsdkH.js.map} +1 -1
- package/dist/{index-CkSdNy0U.js → index-B5tbjHvN.js} +2 -2
- package/dist/{index-CkSdNy0U.js.map → index-B5tbjHvN.js.map} +1 -1
- package/dist/{index-BYgh1HkH.js → index-B6Zxq3gX.js} +2 -2
- package/dist/{index-BYgh1HkH.js.map → index-B6Zxq3gX.js.map} +1 -1
- package/dist/{index-BVMm7Dix.js → index-BVuMfFbP.js} +3 -3
- package/dist/{index-BVMm7Dix.js.map → index-BVuMfFbP.js.map} +1 -1
- package/dist/{index-DvFkW8lL.js → index-BwGWWeee.js} +2 -2
- package/dist/{index-DvFkW8lL.js.map → index-BwGWWeee.js.map} +1 -1
- package/dist/{index-Dfdy54gH.js → index-Cn0EjRz9.js} +2 -2
- package/dist/{index-Dfdy54gH.js.map → index-Cn0EjRz9.js.map} +1 -1
- package/dist/{index-LvMaeDQn.js → index-D3hnOW_f.js} +8 -8
- package/dist/{index-LvMaeDQn.js.map → index-D3hnOW_f.js.map} +1 -1
- package/dist/{index-D-8cyCdX.js → index-D6AvNjpW.js} +31 -27
- package/dist/index-D6AvNjpW.js.map +1 -0
- package/dist/{index-BbvMbIgz.js → index-DiWAbu-c.js} +3 -3
- package/dist/{index-BbvMbIgz.js.map → index-DiWAbu-c.js.map} +1 -1
- package/dist/{index-CUDVeUEv.js → index-DkyIt0u7.js} +2 -2
- package/dist/{index-CUDVeUEv.js.map → index-DkyIt0u7.js.map} +1 -1
- package/dist/{index-BlVSMvH-.js → index-JE9-Xotj.js} +246 -221
- package/dist/index-JE9-Xotj.js.map +1 -0
- package/dist/{index-JvsrhizC.js → index-b29qTV0M.js} +3 -3
- package/dist/{index-JvsrhizC.js.map → index-b29qTV0M.js.map} +1 -1
- package/dist/{index-Ce-zc5RR.js → index-mLleTCbq.js} +2 -2
- package/dist/{index-Ce-zc5RR.js.map → index-mLleTCbq.js.map} +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +2 -2
- package/dist/models/index.js +1 -1
- package/dist/plugins/index.js +12 -12
- package/dist/services/index.js +1 -1
- package/lib/index.umd.js +18 -18
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-BlVSMvH-.js.map +0 -1
- package/dist/index-D-8cyCdX.js.map +0 -1
- package/dist/index-DTU2DZU6.js.map +0 -1
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
function x(
|
|
1
|
+
function x(o) {
|
|
2
2
|
if (typeof globalThis.structuredClone == "function")
|
|
3
3
|
try {
|
|
4
|
-
return globalThis.structuredClone(
|
|
4
|
+
return globalThis.structuredClone(o);
|
|
5
5
|
} catch {
|
|
6
6
|
}
|
|
7
|
-
return q(
|
|
7
|
+
return q(o, /* @__PURE__ */ new WeakMap());
|
|
8
8
|
}
|
|
9
|
-
function q(
|
|
10
|
-
if (typeof
|
|
11
|
-
const t = e.get(
|
|
9
|
+
function q(o, e) {
|
|
10
|
+
if (typeof o != "object" || o === null) return o;
|
|
11
|
+
const t = e.get(o);
|
|
12
12
|
if (t) return t;
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
return new RegExp(
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
18
|
-
return new URLSearchParams(
|
|
19
|
-
if (
|
|
20
|
-
if (ArrayBuffer.isView(
|
|
21
|
-
if (
|
|
13
|
+
if (o instanceof Date) return new Date(o.getTime());
|
|
14
|
+
if (o instanceof RegExp)
|
|
15
|
+
return new RegExp(o.source, o.flags);
|
|
16
|
+
if (o instanceof URL) return new URL(o.toString());
|
|
17
|
+
if (o instanceof URLSearchParams)
|
|
18
|
+
return new URLSearchParams(o.toString());
|
|
19
|
+
if (o instanceof ArrayBuffer) return o.slice(0);
|
|
20
|
+
if (ArrayBuffer.isView(o)) {
|
|
21
|
+
if (o instanceof DataView)
|
|
22
22
|
return new DataView(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
o.buffer.slice(0),
|
|
24
|
+
o.byteOffset,
|
|
25
|
+
o.byteLength
|
|
26
26
|
);
|
|
27
|
-
const i =
|
|
27
|
+
const i = o, c = i.constructor;
|
|
28
28
|
return new c(i.buffer.slice(0), i.byteOffset, i.length);
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if (o instanceof Map) {
|
|
31
31
|
const i = /* @__PURE__ */ new Map();
|
|
32
|
-
return e.set(
|
|
32
|
+
return e.set(o, i), o.forEach((c, l) => {
|
|
33
33
|
i.set(q(l, e), q(c, e));
|
|
34
34
|
}), i;
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
36
|
+
if (o instanceof Set) {
|
|
37
37
|
const i = /* @__PURE__ */ new Set();
|
|
38
|
-
return e.set(
|
|
38
|
+
return e.set(o, i), o.forEach((c) => i.add(q(c, e))), i;
|
|
39
39
|
}
|
|
40
|
-
if (Array.isArray(
|
|
41
|
-
const i = new Array(
|
|
42
|
-
e.set(
|
|
40
|
+
if (Array.isArray(o)) {
|
|
41
|
+
const i = new Array(o.length);
|
|
42
|
+
e.set(o, i);
|
|
43
43
|
for (let c = 0; c < i.length; c++)
|
|
44
|
-
i[c] = q(
|
|
44
|
+
i[c] = q(o[c], e);
|
|
45
45
|
return i;
|
|
46
46
|
}
|
|
47
|
-
const s = Object.getPrototypeOf(
|
|
48
|
-
e.set(
|
|
49
|
-
const
|
|
50
|
-
for (const i of Reflect.ownKeys(
|
|
51
|
-
const c =
|
|
47
|
+
const s = Object.getPrototypeOf(o), r = Object.create(s);
|
|
48
|
+
e.set(o, r);
|
|
49
|
+
const n = Object.getOwnPropertyDescriptors(o);
|
|
50
|
+
for (const i of Reflect.ownKeys(n)) {
|
|
51
|
+
const c = n[i];
|
|
52
52
|
"value" in c && (c.value = q(c.value, e)), Object.defineProperty(r, i, c);
|
|
53
53
|
}
|
|
54
54
|
return r;
|
|
55
55
|
}
|
|
56
|
-
function S(
|
|
57
|
-
if (typeof
|
|
56
|
+
function S(o) {
|
|
57
|
+
if (typeof o != "object" || o === null)
|
|
58
58
|
return !1;
|
|
59
|
-
const e = Object.getPrototypeOf(
|
|
59
|
+
const e = Object.getPrototypeOf(o);
|
|
60
60
|
return e === Object.prototype || e === null;
|
|
61
61
|
}
|
|
62
|
-
const W = function(
|
|
63
|
-
const e = this.constructor.prototype, t = Reflect.get(e,
|
|
62
|
+
const W = function(o) {
|
|
63
|
+
const e = this.constructor.prototype, t = Reflect.get(e, o, e);
|
|
64
64
|
function s(...r) {
|
|
65
65
|
return Reflect.apply(t, s, r);
|
|
66
66
|
}
|
|
67
67
|
Reflect.setPrototypeOf(s, e);
|
|
68
68
|
for (const r of Reflect.ownKeys(t)) {
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const n = Reflect.getOwnPropertyDescriptor(t, r);
|
|
70
|
+
n && Reflect.defineProperty(s, r, n);
|
|
71
71
|
}
|
|
72
72
|
return s;
|
|
73
73
|
};
|
|
74
74
|
W.prototype = Object.create(Function.prototype);
|
|
75
75
|
const X = W;
|
|
76
|
-
function A(
|
|
77
|
-
const t = x(
|
|
76
|
+
function A(o, ...e) {
|
|
77
|
+
const t = x(o || {});
|
|
78
78
|
for (const s of e)
|
|
79
79
|
if (s != null)
|
|
80
80
|
for (const r of Reflect.ownKeys(s)) {
|
|
81
|
-
const
|
|
82
|
-
if (typeof
|
|
83
|
-
if (
|
|
81
|
+
const n = s[r];
|
|
82
|
+
if (typeof n > "u") continue;
|
|
83
|
+
if (n === null) {
|
|
84
84
|
delete t[r];
|
|
85
85
|
continue;
|
|
86
86
|
}
|
|
87
87
|
const i = t[r];
|
|
88
|
-
S(i) && S(
|
|
88
|
+
S(i) && S(n) ? t[r] = A(i, n) : t[r] = x(n);
|
|
89
89
|
}
|
|
90
90
|
return t;
|
|
91
91
|
}
|
|
92
|
-
var R = /* @__PURE__ */ ((
|
|
92
|
+
var R = /* @__PURE__ */ ((o) => (o.BODY_USED = "BODY_USED", o.NO_BODY_READER = "NO_BODY_READER", o.TIMEOUT = "TIMEOUT", o.NETWORK_ERROR = "NETWORK_ERROR", o.BODY_NOT_ALLOWED = "BODY_NOT_ALLOWED", o.HOOK_CONTEXT_CHANGED = "HOOK_CONTEXT_CHANGED", o.ABORTED_BY_HOOK = "ABORTED_BY_HOOK", o.INVALID_HOOK_CALLBACK = "INVALID_HOOK_CALLBACK", o.UNEXPECTED_HOOK_RETURN = "UNEXPECTED_HOOK_RETURN", o.UNSUPPORTED_RESPONSE_TYPE = "UNSUPPORTED_RESPONSE_TYPE", o.FEATURE_MOVED_TO_PLUGIN = "FEATURE_MOVED_TO_PLUGIN", o.BODY_TRANSFORM_ERROR = "BODY_TRANSFORM_ERROR", o))(R || {});
|
|
93
93
|
class y extends Error {
|
|
94
94
|
constructor(e, t, s, r) {
|
|
95
95
|
super(t, r), this.code = e, this.context = s;
|
|
@@ -109,22 +109,22 @@ class C extends y {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
var E;
|
|
112
|
-
((
|
|
113
|
-
|
|
112
|
+
((o) => {
|
|
113
|
+
o.makeSearchParams = (s) => {
|
|
114
114
|
if (!s)
|
|
115
115
|
return new URLSearchParams();
|
|
116
116
|
if (s instanceof URLSearchParams)
|
|
117
117
|
return s;
|
|
118
118
|
if (typeof s != "object" || s?.constructor !== Object)
|
|
119
119
|
throw new TypeError("only plain object is supported");
|
|
120
|
-
const r = new URLSearchParams(),
|
|
120
|
+
const r = new URLSearchParams(), n = (l, a) => {
|
|
121
121
|
a != null && r.append(l, a);
|
|
122
122
|
}, i = (l, a) => {
|
|
123
123
|
a != null && r.set(l, a);
|
|
124
124
|
}, c = (l, a) => {
|
|
125
125
|
if (a != null) {
|
|
126
126
|
if (Array.isArray(a)) {
|
|
127
|
-
for (const f of a)
|
|
127
|
+
for (const f of a) n(l, f?.toString());
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
if (typeof a == "object" && a.constructor === Object) {
|
|
@@ -134,10 +134,10 @@ var E;
|
|
|
134
134
|
if (h) {
|
|
135
135
|
const w = `${p}[]`;
|
|
136
136
|
if (Array.isArray(u))
|
|
137
|
-
for (const N of u)
|
|
138
|
-
else typeof u == "object" && u !== null && u.constructor === Object ? c(`${p}[]`, u) :
|
|
137
|
+
for (const N of u) n(w, N?.toString());
|
|
138
|
+
else typeof u == "object" && u !== null && u.constructor === Object ? c(`${p}[]`, u) : n(w, u?.toString());
|
|
139
139
|
} else if (Array.isArray(u))
|
|
140
|
-
for (const w of u)
|
|
140
|
+
for (const w of u) n(p, w?.toString());
|
|
141
141
|
else typeof u == "object" && u !== null && u.constructor === Object ? c(p, u) : i(p, u?.toString());
|
|
142
142
|
}
|
|
143
143
|
return;
|
|
@@ -148,12 +148,12 @@ var E;
|
|
|
148
148
|
for (const [l, a] of Object.entries(s))
|
|
149
149
|
c(l, a);
|
|
150
150
|
return r;
|
|
151
|
-
},
|
|
152
|
-
const c = typeof window < "u" && window.location?.origin || "http://localhost", l = typeof s == "string" ? new URL(s, i ?? c) : new URL(s), a = (0,
|
|
153
|
-
return l.search = u.toString(), typeof
|
|
154
|
-
},
|
|
155
|
-
typeof s == "string" && (s = (0,
|
|
156
|
-
const r = {},
|
|
151
|
+
}, o.makeQueryString = (s) => (0, o.makeSearchParams)(s).toString(), o.makeURL = (s, r, n, i) => {
|
|
152
|
+
const c = typeof window < "u" && window.location?.origin || "http://localhost", l = typeof s == "string" ? new URL(s, i ?? c) : new URL(s), a = (0, o.toQueryRecord)(l.searchParams), f = (0, o.mergeQueries)(a, r || {}), u = (0, o.makeSearchParams)(f);
|
|
153
|
+
return l.search = u.toString(), typeof n < "u" && (l.hash = n), l;
|
|
154
|
+
}, o.toQueryRecord = (s) => {
|
|
155
|
+
typeof s == "string" && (s = (0, o.fromString)(s));
|
|
156
|
+
const r = {}, n = (c) => {
|
|
157
157
|
if (!c.includes("[")) return { path: [c], forceArray: !1 };
|
|
158
158
|
const a = [c.slice(0, c.indexOf("["))], f = /\[([^\]]*)\]/g;
|
|
159
159
|
let u, h = !1, d = !1;
|
|
@@ -168,31 +168,31 @@ var E;
|
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
for (const [c, l] of s.entries()) {
|
|
171
|
-
const { path: a, forceArray: f } =
|
|
171
|
+
const { path: a, forceArray: f } = n(String(c));
|
|
172
172
|
i(r, a, l?.toString(), f);
|
|
173
173
|
}
|
|
174
174
|
return r;
|
|
175
|
-
},
|
|
175
|
+
}, o.fromString = (s) => {
|
|
176
176
|
const r = s.trim();
|
|
177
177
|
if (!r) return new URLSearchParams();
|
|
178
178
|
if (r.startsWith("?")) return new URLSearchParams(r.slice(1));
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
const i = r.indexOf("#",
|
|
179
|
+
const n = r.indexOf("?");
|
|
180
|
+
if (n >= 0) {
|
|
181
|
+
const i = r.indexOf("#", n + 1), c = r.slice(n + 1, i >= 0 ? i : void 0);
|
|
182
182
|
return new URLSearchParams(c);
|
|
183
183
|
}
|
|
184
184
|
return new URLSearchParams(r);
|
|
185
|
-
},
|
|
185
|
+
}, o.mergeQueries = (...s) => {
|
|
186
186
|
const r = {};
|
|
187
|
-
for (const
|
|
188
|
-
|
|
187
|
+
for (const n of s)
|
|
188
|
+
n != null && t(r, e(n));
|
|
189
189
|
return r;
|
|
190
190
|
};
|
|
191
191
|
function e(s) {
|
|
192
192
|
if (!s) return {};
|
|
193
193
|
if (s instanceof URLSearchParams || s instanceof FormData || s instanceof Map)
|
|
194
|
-
return (0,
|
|
195
|
-
if (typeof s == "string") return (0,
|
|
194
|
+
return (0, o.toQueryRecord)(s);
|
|
195
|
+
if (typeof s == "string") return (0, o.toQueryRecord)((0, o.fromString)(s));
|
|
196
196
|
if (S(s)) return s;
|
|
197
197
|
throw new TypeError(
|
|
198
198
|
`unsupported type transformation, got: ${Object.prototype.toString.call(
|
|
@@ -201,14 +201,14 @@ var E;
|
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
function t(s, r) {
|
|
204
|
-
for (const [
|
|
204
|
+
for (const [n, i] of Object.entries(r)) {
|
|
205
205
|
if (i === void 0) continue;
|
|
206
206
|
if (i === null) {
|
|
207
|
-
delete s[
|
|
207
|
+
delete s[n];
|
|
208
208
|
continue;
|
|
209
209
|
}
|
|
210
|
-
const c = s[
|
|
211
|
-
S(c) && S(i) ? t(c, i) : s[
|
|
210
|
+
const c = s[n];
|
|
211
|
+
S(c) && S(i) ? t(c, i) : s[n] = x(i);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
})(E || (E = {}));
|
|
@@ -229,27 +229,27 @@ class Q {
|
|
|
229
229
|
url;
|
|
230
230
|
redirected;
|
|
231
231
|
}
|
|
232
|
-
const H = (
|
|
233
|
-
const e =
|
|
232
|
+
const H = (o) => {
|
|
233
|
+
const e = o.reduce((r, n) => r + n.length, 0), t = new Uint8Array(e);
|
|
234
234
|
let s = 0;
|
|
235
|
-
for (const r of
|
|
235
|
+
for (const r of o)
|
|
236
236
|
t.set(r, s), s += r.length;
|
|
237
237
|
return t;
|
|
238
238
|
};
|
|
239
|
-
async function J(
|
|
240
|
-
const s =
|
|
239
|
+
async function J(o, e, t) {
|
|
240
|
+
const s = o.getReader();
|
|
241
241
|
if (!s)
|
|
242
242
|
throw new y(
|
|
243
243
|
R.NO_BODY_READER,
|
|
244
244
|
"Failed to get ReadableStream from response body"
|
|
245
245
|
);
|
|
246
246
|
const r = [];
|
|
247
|
-
let
|
|
247
|
+
let n = 0;
|
|
248
248
|
try {
|
|
249
249
|
for (; ; ) {
|
|
250
250
|
const { done: c, value: l } = await s.read();
|
|
251
251
|
if (c) break;
|
|
252
|
-
r.push(l),
|
|
252
|
+
r.push(l), n += l.length, t && e > 0 && t(n / e, H(r));
|
|
253
253
|
}
|
|
254
254
|
} finally {
|
|
255
255
|
s.releaseLock?.();
|
|
@@ -257,21 +257,21 @@ async function J(n, e, t) {
|
|
|
257
257
|
const i = H(r);
|
|
258
258
|
return t?.(1, i), i;
|
|
259
259
|
}
|
|
260
|
-
const Z = (
|
|
261
|
-
if (
|
|
262
|
-
if (
|
|
260
|
+
const Z = (o) => {
|
|
261
|
+
if (o) {
|
|
262
|
+
if (o.includes("application/json") || o.endsWith("+json"))
|
|
263
263
|
return "json";
|
|
264
|
-
if (
|
|
265
|
-
if (
|
|
264
|
+
if (o.startsWith("text/")) return "text";
|
|
265
|
+
if (o.includes("multipart/form-data") || o.includes("application/x-www-form-urlencoded"))
|
|
266
266
|
return "form";
|
|
267
|
-
if (/^image\//.test(
|
|
267
|
+
if (/^image\//.test(o) || /^video\//.test(o) || /^audio\//.test(o) || o.includes("application/pdf"))
|
|
268
268
|
return "blob";
|
|
269
|
-
if (
|
|
269
|
+
if (o.includes("application/octet-stream") || o.includes("application/zip") || o.includes("application/x-tar") || o.includes("application/x-7z-compressed") || o.includes("application/x-gzip"))
|
|
270
270
|
return "arrayBuffer";
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
async function F(
|
|
274
|
-
const
|
|
273
|
+
async function F(o, e, t, s, r) {
|
|
274
|
+
const n = o.clone(), i = o.headers.get("content-type")?.toLowerCase() ?? "", c = o.headers.get("content-length"), l = c ? Number(c) : 0, a = o.headers.get("upgrade")?.toLowerCase(), f = o.headers.get("connection")?.toLowerCase();
|
|
275
275
|
if (e === "ws" || e === "stream")
|
|
276
276
|
throw new y(
|
|
277
277
|
R.FEATURE_MOVED_TO_PLUGIN,
|
|
@@ -294,9 +294,9 @@ async function F(n, e, t, s, r) {
|
|
|
294
294
|
let p;
|
|
295
295
|
try {
|
|
296
296
|
if (u === "form")
|
|
297
|
-
p = await
|
|
297
|
+
p = await n.formData();
|
|
298
298
|
else {
|
|
299
|
-
const m = await J(
|
|
299
|
+
const m = await J(n.body, l, t);
|
|
300
300
|
if (u === "arrayBuffer")
|
|
301
301
|
p = m.buffer.slice(
|
|
302
302
|
m.byteOffset,
|
|
@@ -330,7 +330,7 @@ async function F(n, e, t, s, r) {
|
|
|
330
330
|
} catch (m) {
|
|
331
331
|
if (!(m instanceof Error)) throw m;
|
|
332
332
|
try {
|
|
333
|
-
p = await
|
|
333
|
+
p = await n.text(), u = "text";
|
|
334
334
|
} catch {
|
|
335
335
|
throw new y(
|
|
336
336
|
R.BODY_TRANSFORM_ERROR,
|
|
@@ -341,7 +341,7 @@ async function F(n, e, t, s, r) {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
const w = new Q(
|
|
344
|
-
|
|
344
|
+
o,
|
|
345
345
|
p,
|
|
346
346
|
u
|
|
347
347
|
), N = s?.(w);
|
|
@@ -350,8 +350,8 @@ async function F(n, e, t, s, r) {
|
|
|
350
350
|
return w;
|
|
351
351
|
}
|
|
352
352
|
var k;
|
|
353
|
-
((
|
|
354
|
-
|
|
353
|
+
((o) => {
|
|
354
|
+
o.makeHeaders = (e) => {
|
|
355
355
|
if (!e) return new Headers();
|
|
356
356
|
if (e instanceof Headers) return new Headers(e);
|
|
357
357
|
const t = new Headers();
|
|
@@ -359,8 +359,8 @@ var k;
|
|
|
359
359
|
for (const [s, r] of e.entries())
|
|
360
360
|
if (r != null)
|
|
361
361
|
if (Array.isArray(r))
|
|
362
|
-
for (const
|
|
363
|
-
|
|
362
|
+
for (const n of r)
|
|
363
|
+
n != null && t.append(s, String(n));
|
|
364
364
|
else
|
|
365
365
|
t.append(s, String(r));
|
|
366
366
|
return t;
|
|
@@ -369,8 +369,8 @@ var k;
|
|
|
369
369
|
for (const [s, r] of Object.entries(e))
|
|
370
370
|
if (r != null)
|
|
371
371
|
if (Array.isArray(r))
|
|
372
|
-
for (const
|
|
373
|
-
|
|
372
|
+
for (const n of r)
|
|
373
|
+
n != null && t.append(s, String(n));
|
|
374
374
|
else
|
|
375
375
|
t.append(s, String(r));
|
|
376
376
|
return t;
|
|
@@ -378,7 +378,7 @@ var k;
|
|
|
378
378
|
throw new TypeError(
|
|
379
379
|
"only plain object, Map/ReadonlyMap, or Headers is supported"
|
|
380
380
|
);
|
|
381
|
-
},
|
|
381
|
+
}, o.toHeaderRecord = (e) => {
|
|
382
382
|
if (e instanceof Headers) {
|
|
383
383
|
const t = {};
|
|
384
384
|
return e.forEach((s, r) => {
|
|
@@ -390,11 +390,11 @@ var k;
|
|
|
390
390
|
for (const [s, r] of e.entries())
|
|
391
391
|
if (r != null)
|
|
392
392
|
if (Array.isArray(r)) {
|
|
393
|
-
const
|
|
394
|
-
|
|
393
|
+
const n = r.filter((i) => i != null).map((i) => String(i));
|
|
394
|
+
n.length && (t[s] = (t[s] ?? []).concat(n));
|
|
395
395
|
} else {
|
|
396
|
-
const
|
|
397
|
-
t[s] = t[s] ? [...t[s],
|
|
396
|
+
const n = String(r);
|
|
397
|
+
t[s] = t[s] ? [...t[s], n] : [n];
|
|
398
398
|
}
|
|
399
399
|
return t;
|
|
400
400
|
}
|
|
@@ -403,20 +403,20 @@ var k;
|
|
|
403
403
|
e
|
|
404
404
|
)}`
|
|
405
405
|
);
|
|
406
|
-
},
|
|
406
|
+
}, o.mergeHeaders = (...e) => {
|
|
407
407
|
const t = new Headers(), s = (r) => {
|
|
408
|
-
for (const [
|
|
408
|
+
for (const [n, i] of Object.entries(r))
|
|
409
409
|
if (i !== void 0) {
|
|
410
410
|
if (i === null) {
|
|
411
|
-
t.delete(
|
|
411
|
+
t.delete(n);
|
|
412
412
|
continue;
|
|
413
413
|
}
|
|
414
414
|
if (Array.isArray(i)) {
|
|
415
|
-
t.delete(
|
|
415
|
+
t.delete(n);
|
|
416
416
|
for (const c of i)
|
|
417
|
-
c != null && t.append(
|
|
417
|
+
c != null && t.append(n, String(c));
|
|
418
418
|
} else
|
|
419
|
-
t.set(
|
|
419
|
+
t.set(n, String(i));
|
|
420
420
|
}
|
|
421
421
|
};
|
|
422
422
|
for (const r of e) {
|
|
@@ -431,8 +431,8 @@ var k;
|
|
|
431
431
|
s(r);
|
|
432
432
|
continue;
|
|
433
433
|
}
|
|
434
|
-
const
|
|
435
|
-
for (const [i, c] of Object.entries(
|
|
434
|
+
const n = (0, o.toHeaderRecord)(r);
|
|
435
|
+
for (const [i, c] of Object.entries(n)) {
|
|
436
436
|
t.delete(i);
|
|
437
437
|
for (const l of c) t.append(i, l);
|
|
438
438
|
}
|
|
@@ -486,65 +486,65 @@ class g extends X {
|
|
|
486
486
|
);
|
|
487
487
|
}
|
|
488
488
|
attachLegacyAliases(e) {
|
|
489
|
-
const t = () => e.request, s = () => e.runtime, r = (
|
|
489
|
+
const t = () => e.request, s = () => e.runtime, r = (n, i) => {
|
|
490
490
|
try {
|
|
491
|
-
Object.defineProperty(e,
|
|
491
|
+
Object.defineProperty(e, n, { configurable: !0, ...i });
|
|
492
492
|
} catch {
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
r("url", {
|
|
496
496
|
get: () => t().url,
|
|
497
|
-
set: (
|
|
498
|
-
t().url =
|
|
497
|
+
set: (n) => {
|
|
498
|
+
t().url = n?.toString?.() ?? String(n);
|
|
499
499
|
}
|
|
500
500
|
}), r("method", {
|
|
501
501
|
get: () => t().method,
|
|
502
|
-
set: (
|
|
502
|
+
set: (n) => t().method = n
|
|
503
503
|
}), r("headers", {
|
|
504
504
|
get: () => t().headers,
|
|
505
|
-
set: (
|
|
506
|
-
}), r("query", { get: () => t().query, set: (
|
|
505
|
+
set: (n) => t().headers = n
|
|
506
|
+
}), r("query", { get: () => t().query, set: (n) => t().query = n }), r("body", { get: () => t().body, set: (n) => t().body = n }), r("baseURL", {
|
|
507
507
|
get: () => t().baseURL,
|
|
508
|
-
set: (
|
|
508
|
+
set: (n) => t().baseURL = n
|
|
509
509
|
}), r("timeout", {
|
|
510
510
|
get: () => t().timeout,
|
|
511
|
-
set: (
|
|
511
|
+
set: (n) => t().timeout = n
|
|
512
512
|
}), r("credentials", {
|
|
513
513
|
get: () => t().credentials,
|
|
514
|
-
set: (
|
|
515
|
-
}), r("cache", { get: () => t().cache, set: (
|
|
514
|
+
set: (n) => t().credentials = n
|
|
515
|
+
}), r("cache", { get: () => t().cache, set: (n) => t().cache = n }), r("mode", { get: () => t().mode, set: (n) => t().mode = n }), r("fetch", { get: () => t().fetch, set: (n) => t().fetch = n }), r("shouldThrow", {
|
|
516
516
|
get: () => t().shouldThrow,
|
|
517
|
-
set: (
|
|
517
|
+
set: (n) => t().shouldThrow = n
|
|
518
518
|
}), r("responseType", {
|
|
519
519
|
get: () => t().responseType,
|
|
520
|
-
set: (
|
|
520
|
+
set: (n) => t().responseType = n
|
|
521
521
|
}), r("abortController", {
|
|
522
522
|
get: () => s().abortController,
|
|
523
|
-
set: (
|
|
523
|
+
set: (n) => s().abortController = n
|
|
524
524
|
}), r("onProgress", {
|
|
525
525
|
get: () => s().onProgress,
|
|
526
|
-
set: (
|
|
526
|
+
set: (n) => s().onProgress = n
|
|
527
527
|
}), r("customEnv", {
|
|
528
528
|
get: () => s().customEnv,
|
|
529
|
-
set: (
|
|
529
|
+
set: (n) => s().customEnv = n
|
|
530
530
|
}), r("rawRequest", {
|
|
531
531
|
get: () => t().rawRequest,
|
|
532
|
-
set: (
|
|
532
|
+
set: (n) => t().rawRequest = n
|
|
533
533
|
}), r("data", {
|
|
534
534
|
get: () => e.response ? e.response.data : void 0,
|
|
535
|
-
set: (
|
|
536
|
-
e.response && (e.response.data =
|
|
535
|
+
set: (n) => {
|
|
536
|
+
e.response && (e.response.data = n);
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
}
|
|
540
540
|
finalizeContext(e, t) {
|
|
541
|
-
const s = e.response, r = s?.rawResponse ?? e.rawResponse,
|
|
541
|
+
const s = e.response, r = s?.rawResponse ?? e.rawResponse, n = e.request;
|
|
542
542
|
Object.defineProperties(e, {
|
|
543
543
|
url: { get: () => r?.url || t },
|
|
544
544
|
data: { get: () => s.data },
|
|
545
545
|
headers: { get: () => r.headers },
|
|
546
546
|
responseType: { get: () => s.responseType },
|
|
547
|
-
rawRequest: { get: () =>
|
|
547
|
+
rawRequest: { get: () => n.rawRequest }
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
550
|
async request(e, t) {
|
|
@@ -552,7 +552,7 @@ class g extends X {
|
|
|
552
552
|
let r = t || {};
|
|
553
553
|
typeof e == "string" || e instanceof URL ? r = { ...t || {}, url: e } : typeof e == "object" && (r = e);
|
|
554
554
|
const {
|
|
555
|
-
abortController:
|
|
555
|
+
abortController: n,
|
|
556
556
|
onProgress: i,
|
|
557
557
|
customEnv: c,
|
|
558
558
|
...l
|
|
@@ -566,7 +566,7 @@ class g extends X {
|
|
|
566
566
|
url: r.url?.toString?.() ?? String(r.url)
|
|
567
567
|
},
|
|
568
568
|
runtime: {
|
|
569
|
-
abortController:
|
|
569
|
+
abortController: n,
|
|
570
570
|
onProgress: i,
|
|
571
571
|
customEnv: c
|
|
572
572
|
},
|
|
@@ -665,8 +665,8 @@ class g extends X {
|
|
|
665
665
|
mergeQueries = E.mergeQueries;
|
|
666
666
|
mergeHeaders = k.mergeHeaders;
|
|
667
667
|
applyDefaults(e) {
|
|
668
|
-
const t = e, s = globalThis.location?.href || "http://localhost", r = t.baseURL || this.baseConfigs.baseURL || s,
|
|
669
|
-
|
|
668
|
+
const t = e, s = globalThis.location?.href || "http://localhost", r = t.baseURL || this.baseConfigs.baseURL || s, n = new URL(r, s), i = new URL(t.url.toString(), n), c = E.toQueryRecord(
|
|
669
|
+
n.searchParams
|
|
670
670
|
), l = E.toQueryRecord(
|
|
671
671
|
i.searchParams
|
|
672
672
|
), a = E.mergeQueries(
|
|
@@ -690,7 +690,7 @@ class g extends X {
|
|
|
690
690
|
}) {
|
|
691
691
|
const r = this.hooks.filter((i) => i.event === e);
|
|
692
692
|
if (r.length === 0) return t;
|
|
693
|
-
const
|
|
693
|
+
const n = async (i, c) => {
|
|
694
694
|
const l = i;
|
|
695
695
|
if (l.rawResponse = c, !l.request?.rawRequest)
|
|
696
696
|
try {
|
|
@@ -733,7 +733,7 @@ class g extends X {
|
|
|
733
733
|
);
|
|
734
734
|
if (f instanceof Response) {
|
|
735
735
|
if (s.shouldHandleShortCircuitResponse !== !1)
|
|
736
|
-
return
|
|
736
|
+
return n(t, f);
|
|
737
737
|
t.rawResponse = f;
|
|
738
738
|
} else f && typeof f == "object" && f[a] === a && (t = f);
|
|
739
739
|
}
|
|
@@ -809,30 +809,30 @@ class g extends X {
|
|
|
809
809
|
const ee = g.create;
|
|
810
810
|
ee();
|
|
811
811
|
var v;
|
|
812
|
-
((
|
|
812
|
+
((o) => {
|
|
813
813
|
function e(s) {
|
|
814
814
|
return Array.isArray(s) ? s.join("|") : typeof s == "boolean" || s === null ? s ? "1" : void 0 : typeof s == "number" ? "" + s : s;
|
|
815
815
|
}
|
|
816
|
-
|
|
816
|
+
o.normalizeParamValue = e;
|
|
817
817
|
function t(s) {
|
|
818
818
|
const r = (i) => i && (i instanceof URLSearchParams || i instanceof FormData);
|
|
819
819
|
if (s == null)
|
|
820
820
|
return;
|
|
821
|
-
const
|
|
821
|
+
const n = new FormData();
|
|
822
822
|
if (r(s))
|
|
823
823
|
return s.forEach((i, c) => {
|
|
824
824
|
const l = e(i);
|
|
825
|
-
l != null &&
|
|
826
|
-
}),
|
|
825
|
+
l != null && n.append(c, l);
|
|
826
|
+
}), n;
|
|
827
827
|
if (S(s))
|
|
828
828
|
return Object.entries(s).forEach(([i, c]) => {
|
|
829
829
|
const l = e(c);
|
|
830
|
-
l != null &&
|
|
831
|
-
}),
|
|
830
|
+
l != null && n.append(i, l);
|
|
831
|
+
}), n;
|
|
832
832
|
}
|
|
833
|
-
|
|
833
|
+
o.normalizeBody = t;
|
|
834
834
|
})(v || (v = {}));
|
|
835
|
-
var M = /* @__PURE__ */ ((
|
|
835
|
+
var M = /* @__PURE__ */ ((o) => (o.HTTP_ERROR = "HTTP_ERROR", o.LOGIN_FAILED = "LOGIN_FAILED", o.LOGIN_RETRY_LIMIT_EXCEEDED = "LOGIN_RETRY_LIMIT_EXCEEDED", o.TOKEN_RETRY_LIMIT_EXCEEDED = "TOKEN_RETRY_LIMIT_EXCEEDED", o))(M || {});
|
|
836
836
|
class b extends Error {
|
|
837
837
|
constructor(e, t = "", s) {
|
|
838
838
|
super(), this.code = e, this.message = t, this.cause = s;
|
|
@@ -865,40 +865,40 @@ class I extends Error {
|
|
|
865
865
|
return Array.isArray(e) === !1 ? [] : e.filter((t) => typeof t == "object" && !!t?.code).map((t) => t.text ? t : t.info ? { ...t, text: t.info } : t["*"] ? { ...t, text: t["*"] } : { ...t, text: "" });
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
|
-
((
|
|
869
|
-
function e(
|
|
870
|
-
if (
|
|
871
|
-
if (
|
|
872
|
-
if (
|
|
873
|
-
const i =
|
|
874
|
-
return i?.response?.data !== void 0 ? i.response.data : i?.data !== void 0 ? i.data :
|
|
875
|
-
}
|
|
876
|
-
function t(
|
|
877
|
-
return s(
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
function s(
|
|
881
|
-
let i = e(
|
|
868
|
+
((o) => {
|
|
869
|
+
function e(n) {
|
|
870
|
+
if (n == null) return;
|
|
871
|
+
if (n?.response?.data !== void 0) return n.response.data;
|
|
872
|
+
if (n?.data !== void 0) return n.data;
|
|
873
|
+
const i = n instanceof Error ? n.cause : void 0;
|
|
874
|
+
return i?.response?.data !== void 0 ? i.response.data : i?.data !== void 0 ? i.data : n || void 0;
|
|
875
|
+
}
|
|
876
|
+
function t(n) {
|
|
877
|
+
return s(n).length > 0;
|
|
878
|
+
}
|
|
879
|
+
o.includesMediaWikiApiError = t, o.normalizeMwApiErrors = I.normalizeErrors;
|
|
880
|
+
function s(n) {
|
|
881
|
+
let i = e(n);
|
|
882
882
|
if (typeof i != "object" || i === null)
|
|
883
883
|
return [];
|
|
884
884
|
const c = i?.error, l = i?.errors, a = [];
|
|
885
|
-
return c && a.push(c), Array.isArray(l) && a.push(...l), (0,
|
|
885
|
+
return c && a.push(c), Array.isArray(l) && a.push(...l), (0, o.normalizeMwApiErrors)(a);
|
|
886
886
|
}
|
|
887
|
-
|
|
888
|
-
function r(
|
|
889
|
-
if (I.is(
|
|
890
|
-
return
|
|
887
|
+
o.extractMediaWikiApiErrors = s;
|
|
888
|
+
function r(n) {
|
|
889
|
+
if (I.is(n))
|
|
890
|
+
return n.isBadTokenError();
|
|
891
891
|
{
|
|
892
|
-
const i = s(
|
|
892
|
+
const i = s(n);
|
|
893
893
|
return new I(i).isBadTokenError();
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
-
|
|
896
|
+
o.isBadTokenError = r;
|
|
897
897
|
})(b || (b = {}));
|
|
898
898
|
const z = /* @__PURE__ */ Symbol.for("__FEXIOS_SAIKOU__");
|
|
899
|
-
function Y(
|
|
900
|
-
const e =
|
|
901
|
-
baseURL:
|
|
899
|
+
function Y(o) {
|
|
900
|
+
const e = o instanceof g ? o : new g({
|
|
901
|
+
baseURL: o instanceof URL ? o.toString() : String(o),
|
|
902
902
|
responseType: "json"
|
|
903
903
|
});
|
|
904
904
|
return e[z] || (Reflect.defineProperty(e, z, {
|
|
@@ -920,47 +920,47 @@ function Y(n) {
|
|
|
920
920
|
), t)), e.on("beforeRequest", (t) => {
|
|
921
921
|
const s = new URL(t.request.url), r = E.mergeQueries(s.searchParams, t.query);
|
|
922
922
|
if (globalThis.location && (!r.origin && location.origin !== s.origin ? (r.origin = location.origin, e.baseConfigs.credentials = "include", e.baseConfigs.mode = "cors") : location.origin === s.origin && (delete r.origin, e.baseConfigs.credentials = void 0, e.baseConfigs.mode = void 0)), r.origin) {
|
|
923
|
-
const
|
|
924
|
-
delete r.origin, t.request.query = r, t.request.url = `${s.origin}${s.pathname}?origin=${
|
|
923
|
+
const n = encodeURIComponent(r.origin).replace(/\./g, "%2E");
|
|
924
|
+
delete r.origin, t.request.query = r, t.request.url = `${s.origin}${s.pathname}?origin=${n}`;
|
|
925
925
|
} else
|
|
926
926
|
t.request.query = r;
|
|
927
927
|
return t;
|
|
928
928
|
}), e._tokens = /* @__PURE__ */ new Map(), e.on("afterResponse", (t) => {
|
|
929
929
|
const { data: s } = t, r = t.runtime.customEnv?.mwTokenName;
|
|
930
930
|
r && b.isBadTokenError(s) && e._tokens.delete(r);
|
|
931
|
-
const
|
|
932
|
-
|
|
931
|
+
const n = s?.query?.tokens;
|
|
932
|
+
n && typeof n == "object" && Object.entries(n).forEach(([c, l]) => {
|
|
933
933
|
typeof l == "string" && e._tokens.set(c.replace(/token$/i, "").toLowerCase(), l);
|
|
934
934
|
});
|
|
935
935
|
const i = s?.login?.token;
|
|
936
936
|
return typeof i == "string" && e._tokens.set("login", i), t;
|
|
937
937
|
})), e;
|
|
938
938
|
}
|
|
939
|
-
const te = (
|
|
939
|
+
const te = (o, e, t) => {
|
|
940
940
|
let s = { ...ne.DEFAULT_CONFIGS };
|
|
941
|
-
if (typeof
|
|
942
|
-
baseURL:
|
|
941
|
+
if (typeof o == "string" ? s = A(s, {
|
|
942
|
+
baseURL: o,
|
|
943
943
|
fexiosConfigs: e || {},
|
|
944
944
|
defaultParams: t || {},
|
|
945
945
|
throwOnApiError: !1
|
|
946
946
|
// Set a default value for throwOnApiError
|
|
947
|
-
}) : typeof
|
|
948
|
-
const { wgServer: r, wgScriptPath:
|
|
949
|
-
typeof r == "string" && typeof
|
|
947
|
+
}) : typeof o == "object" && o !== null && (s = A(s, o)), !s.baseURL && typeof window == "object" && window.mediaWiki) {
|
|
948
|
+
const { wgServer: r, wgScriptPath: n } = window.mediaWiki?.config?.get(["wgServer", "wgScriptPath"]) || {};
|
|
949
|
+
typeof r == "string" && typeof n == "string" && (s.baseURL = `${r}${n}/api.php`);
|
|
950
950
|
}
|
|
951
951
|
if (typeof s.baseURL != "string")
|
|
952
952
|
throw new Error("baseURL is required");
|
|
953
953
|
return s;
|
|
954
954
|
}, se = () => {
|
|
955
|
-
}, re = async (
|
|
955
|
+
}, re = async (o, e) => {
|
|
956
956
|
let t = 0;
|
|
957
|
-
const { retry: s = 3, onRetry: r = se, shouldRetry:
|
|
957
|
+
const { retry: s = 3, onRetry: r = se, shouldRetry: n = () => !0 } = e;
|
|
958
958
|
let i;
|
|
959
959
|
do
|
|
960
960
|
try {
|
|
961
|
-
return await
|
|
961
|
+
return await o();
|
|
962
962
|
} catch (c) {
|
|
963
|
-
if (i = c,
|
|
963
|
+
if (i = c, n(c, t))
|
|
964
964
|
r(c, t), t++;
|
|
965
965
|
else
|
|
966
966
|
throw c;
|
|
@@ -1074,11 +1074,11 @@ class ne {
|
|
|
1074
1074
|
async postWithToken(e, t, s) {
|
|
1075
1075
|
const {
|
|
1076
1076
|
tokenName: r = "token",
|
|
1077
|
-
retry:
|
|
1077
|
+
retry: n = 3,
|
|
1078
1078
|
noCache: i = !1,
|
|
1079
1079
|
fexiosOptions: c
|
|
1080
1080
|
} = s || {};
|
|
1081
|
-
if (
|
|
1081
|
+
if (n < 1)
|
|
1082
1082
|
throw new b(
|
|
1083
1083
|
M.TOKEN_RETRY_LIMIT_EXCEEDED,
|
|
1084
1084
|
"The limit of the number of times to automatically re-acquire the token has been exceeded"
|
|
@@ -1114,7 +1114,7 @@ class ne {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
},
|
|
1116
1116
|
{
|
|
1117
|
-
retry:
|
|
1117
|
+
retry: n,
|
|
1118
1118
|
onRetry: (a, f) => {
|
|
1119
1119
|
l = f + 1;
|
|
1120
1120
|
},
|
|
@@ -1173,25 +1173,25 @@ class oe {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
1175
|
const ie = () => new Proxy(new oe(), {
|
|
1176
|
-
set(
|
|
1177
|
-
return typeof e == "string" &&
|
|
1176
|
+
set(o, e, t) {
|
|
1177
|
+
return typeof e == "string" && o.setItem(e, t), !0;
|
|
1178
1178
|
},
|
|
1179
|
-
get(
|
|
1180
|
-
return typeof e == "string" && !(e in
|
|
1179
|
+
get(o, e) {
|
|
1180
|
+
return typeof e == "string" && !(e in o) ? o.getItem(e) : Reflect.get(o, e);
|
|
1181
1181
|
}
|
|
1182
1182
|
});
|
|
1183
|
-
function ae(
|
|
1183
|
+
function ae(o) {
|
|
1184
1184
|
class e {
|
|
1185
1185
|
constructor(s, r = !0) {
|
|
1186
|
-
this._loaded = r, this.api =
|
|
1187
|
-
typeof
|
|
1186
|
+
this._loaded = r, this.api = o, s.revisions?.forEach((n) => {
|
|
1187
|
+
typeof n?.slots?.main == "object" && Object.assign(n, n.slots.main);
|
|
1188
1188
|
}), this.pageInfo = {
|
|
1189
1189
|
...e.DEFAULT_PAGE_INFO,
|
|
1190
1190
|
...s
|
|
1191
1191
|
};
|
|
1192
1192
|
}
|
|
1193
1193
|
static {
|
|
1194
|
-
this.api =
|
|
1194
|
+
this.api = o;
|
|
1195
1195
|
}
|
|
1196
1196
|
static {
|
|
1197
1197
|
this.DEFAULT_QUERY_PARAMS = {
|
|
@@ -1242,23 +1242,23 @@ function ae(n) {
|
|
|
1242
1242
|
const { data: r } = await this.api.get({
|
|
1243
1243
|
...e.DEFAULT_QUERY_PARAMS,
|
|
1244
1244
|
...s
|
|
1245
|
-
}),
|
|
1246
|
-
if (!
|
|
1245
|
+
}), n = r?.query?.pages?.[0];
|
|
1246
|
+
if (!n || !n.title)
|
|
1247
1247
|
throw new Error("Invalid page info", { cause: r });
|
|
1248
|
-
return new e(
|
|
1248
|
+
return new e(n, !0);
|
|
1249
1249
|
}
|
|
1250
1250
|
static newBlankPage(s = {}) {
|
|
1251
1251
|
return new e(s, !1);
|
|
1252
1252
|
}
|
|
1253
1253
|
static async newFromAnyKind(s) {
|
|
1254
|
-
const { title: r, pageId:
|
|
1255
|
-
return i ? this.newFromApi({ revids: parseInt(i.toString(), 10) }) :
|
|
1254
|
+
const { title: r, pageId: n, revisionId: i } = s || {};
|
|
1255
|
+
return i ? this.newFromApi({ revids: parseInt(i.toString(), 10) }) : n ? this.newFromApi({ pageids: parseInt(n.toString(), 10) }) : r ? this.newFromApi({ titles: r.toString() }) : null;
|
|
1256
1256
|
}
|
|
1257
1257
|
static async newBatchFromApi(s) {
|
|
1258
|
-
const { titles: r, pageids:
|
|
1258
|
+
const { titles: r, pageids: n, revids: i, ...c } = s || {}, { data: l } = await this.api.post({
|
|
1259
1259
|
...e.DEFAULT_QUERY_PARAMS,
|
|
1260
1260
|
titles: r?.join("|") ?? void 0,
|
|
1261
|
-
pageids:
|
|
1261
|
+
pageids: n?.join("|") ?? void 0,
|
|
1262
1262
|
revids: i?.join("|") ?? void 0,
|
|
1263
1263
|
...c
|
|
1264
1264
|
});
|
|
@@ -1287,7 +1287,7 @@ function ae(n) {
|
|
|
1287
1287
|
});
|
|
1288
1288
|
}
|
|
1289
1289
|
async edit(s, r) {
|
|
1290
|
-
const
|
|
1290
|
+
const n = await this.api.postWithEditToken({
|
|
1291
1291
|
action: "edit",
|
|
1292
1292
|
title: this.title,
|
|
1293
1293
|
starttimestamp: this.pageInfo.touched,
|
|
@@ -1295,8 +1295,8 @@ function ae(n) {
|
|
|
1295
1295
|
...s,
|
|
1296
1296
|
...r
|
|
1297
1297
|
});
|
|
1298
|
-
if (
|
|
1299
|
-
return
|
|
1298
|
+
if (n.data?.edit?.result === "Success")
|
|
1299
|
+
return n;
|
|
1300
1300
|
throw new I(
|
|
1301
1301
|
[
|
|
1302
1302
|
{
|
|
@@ -1306,23 +1306,25 @@ function ae(n) {
|
|
|
1306
1306
|
docref: "https://www.mediawiki.org/wiki/API:Edit"
|
|
1307
1307
|
}
|
|
1308
1308
|
],
|
|
1309
|
-
|
|
1309
|
+
n
|
|
1310
1310
|
);
|
|
1311
1311
|
}
|
|
1312
1312
|
async createOnly(s, r) {
|
|
1313
1313
|
return this.edit(s, { createonly: 1, recreate: s.recreate, ...r });
|
|
1314
1314
|
}
|
|
1315
1315
|
async delete(s, r) {
|
|
1316
|
+
const n = this.pageInfo.title, i = this.pageInfo.pageid;
|
|
1316
1317
|
return this.api.postWithEditToken({
|
|
1317
1318
|
action: "delete",
|
|
1318
|
-
|
|
1319
|
-
|
|
1319
|
+
// only one of title or pageid should be sent
|
|
1320
|
+
title: i ? void 0 : n,
|
|
1321
|
+
pageid: i || void 0,
|
|
1320
1322
|
reason: s,
|
|
1321
1323
|
deletetalk: r?.deletetalk,
|
|
1322
1324
|
...r
|
|
1323
1325
|
});
|
|
1324
1326
|
}
|
|
1325
|
-
async moveTo(s, r,
|
|
1327
|
+
async moveTo(s, r, n) {
|
|
1326
1328
|
return this.api.postWithEditToken({
|
|
1327
1329
|
action: "move",
|
|
1328
1330
|
from: this.pageInfo.title,
|
|
@@ -1330,7 +1332,7 @@ function ae(n) {
|
|
|
1330
1332
|
reason: r,
|
|
1331
1333
|
movetalk: 1,
|
|
1332
1334
|
movesubpages: 1,
|
|
1333
|
-
...
|
|
1335
|
+
...n
|
|
1334
1336
|
});
|
|
1335
1337
|
}
|
|
1336
1338
|
// === utilities ===
|
|
@@ -1344,8 +1346,8 @@ function ae(n) {
|
|
|
1344
1346
|
const s = await e.newFromApi({
|
|
1345
1347
|
pageids: this.pageInfo.pageid,
|
|
1346
1348
|
titles: this.pageInfo.title
|
|
1347
|
-
}), r = (this.pageInfo.revisions || []).concat(s.revisions || []).sort((
|
|
1348
|
-
(
|
|
1349
|
+
}), r = (this.pageInfo.revisions || []).concat(s.revisions || []).sort((n, i) => n.revid - i.revid).reduce(
|
|
1350
|
+
(n, i) => (n.find((c) => c.revid === i.revid) || n.push(i), n),
|
|
1349
1351
|
[]
|
|
1350
1352
|
);
|
|
1351
1353
|
return this.pageInfo = s.pageInfo, this.pageInfo.revisions = r, this._loaded = !0, this;
|
|
@@ -1388,28 +1390,28 @@ function ae(n) {
|
|
|
1388
1390
|
return e;
|
|
1389
1391
|
}
|
|
1390
1392
|
const $ = /* @__PURE__ */ new WeakMap(), P = {
|
|
1391
|
-
toDBKey: (
|
|
1392
|
-
toNormalText: (
|
|
1393
|
-
ensureCase: (
|
|
1393
|
+
toDBKey: (o) => o.replace(/ /g, "_"),
|
|
1394
|
+
toNormalText: (o) => o.replace(/_/g, " "),
|
|
1395
|
+
ensureCase: (o, e) => e === "first-letter" ? o.charAt(0).toUpperCase() + o.slice(1) : o
|
|
1394
1396
|
}, U = {
|
|
1395
1397
|
/**
|
|
1396
1398
|
* 标准化特殊页面名称:转换为全小写
|
|
1397
1399
|
*/
|
|
1398
|
-
normalizeSpecialPageName: (
|
|
1400
|
+
normalizeSpecialPageName: (o) => o.toLowerCase(),
|
|
1399
1401
|
/**
|
|
1400
1402
|
* 构建特殊页面别名索引
|
|
1401
1403
|
*/
|
|
1402
|
-
buildSpecialPageIndex: (
|
|
1404
|
+
buildSpecialPageIndex: (o) => {
|
|
1403
1405
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1404
|
-
for (const r of
|
|
1405
|
-
const
|
|
1406
|
-
e.set(
|
|
1407
|
-
const i = U.normalizeSpecialPageName(
|
|
1408
|
-
s.set(i,
|
|
1406
|
+
for (const r of o.specialpagealiases) {
|
|
1407
|
+
const n = r.realname;
|
|
1408
|
+
e.set(n, n);
|
|
1409
|
+
const i = U.normalizeSpecialPageName(n);
|
|
1410
|
+
s.set(i, n);
|
|
1409
1411
|
for (const c of r.aliases) {
|
|
1410
|
-
t.set(c,
|
|
1412
|
+
t.set(c, n);
|
|
1411
1413
|
const l = U.normalizeSpecialPageName(c);
|
|
1412
|
-
s.set(l,
|
|
1414
|
+
s.set(l, n);
|
|
1413
1415
|
}
|
|
1414
1416
|
}
|
|
1415
1417
|
return { byRealName: e, byAlias: t, byNormalized: s };
|
|
@@ -1417,8 +1419,8 @@ const $ = /* @__PURE__ */ new WeakMap(), P = {
|
|
|
1417
1419
|
/**
|
|
1418
1420
|
* 查找特殊页面的真实名称
|
|
1419
1421
|
*/
|
|
1420
|
-
findSpecialPageRealName: (
|
|
1421
|
-
const t =
|
|
1422
|
+
findSpecialPageRealName: (o, e) => {
|
|
1423
|
+
const t = o.split("/")[0];
|
|
1422
1424
|
let s = e.byRealName.get(t) ?? e.byAlias.get(t);
|
|
1423
1425
|
if (s !== void 0)
|
|
1424
1426
|
return s;
|
|
@@ -1429,32 +1431,32 @@ const $ = /* @__PURE__ */ new WeakMap(), P = {
|
|
|
1429
1431
|
/**
|
|
1430
1432
|
* 标准化命名空间文本:转换为全小写+下划线格式
|
|
1431
1433
|
*/
|
|
1432
|
-
normalizeNamespaceText: (
|
|
1433
|
-
buildIndex: (
|
|
1434
|
+
normalizeNamespaceText: (o) => o.replace(/[_\s]+/g, "_").toLowerCase().replace(/^_+|_+$/g, ""),
|
|
1435
|
+
buildIndex: (o) => {
|
|
1434
1436
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
1435
|
-
for (const [
|
|
1436
|
-
const c = parseInt(
|
|
1437
|
+
for (const [n, i] of Object.entries(o.namespaces)) {
|
|
1438
|
+
const c = parseInt(n);
|
|
1437
1439
|
e.set(i.name, c), t.set(i.canonical ?? "", c);
|
|
1438
1440
|
const l = O.normalizeNamespaceText(i.name), a = O.normalizeNamespaceText(i.canonical ?? "");
|
|
1439
1441
|
r.set(l, c), r.set(a, c);
|
|
1440
1442
|
}
|
|
1441
|
-
for (const
|
|
1442
|
-
s.set(
|
|
1443
|
-
const i = O.normalizeNamespaceText(
|
|
1444
|
-
r.set(i,
|
|
1443
|
+
for (const n of o.namespacealiases) {
|
|
1444
|
+
s.set(n.alias, n.id);
|
|
1445
|
+
const i = O.normalizeNamespaceText(n.alias);
|
|
1446
|
+
r.set(i, n.id);
|
|
1445
1447
|
}
|
|
1446
1448
|
return { byName: e, byCanonical: t, byAlias: s, byNormalized: r };
|
|
1447
1449
|
},
|
|
1448
|
-
findNamespaceId: (
|
|
1449
|
-
let t = e.byName.get(
|
|
1450
|
+
findNamespaceId: (o, e) => {
|
|
1451
|
+
let t = e.byName.get(o) ?? e.byCanonical.get(o) ?? e.byAlias.get(o);
|
|
1450
1452
|
if (t !== void 0)
|
|
1451
1453
|
return t;
|
|
1452
|
-
const s = O.normalizeNamespaceText(
|
|
1454
|
+
const s = O.normalizeNamespaceText(o);
|
|
1453
1455
|
return e.byNormalized.get(s) ?? null;
|
|
1454
1456
|
},
|
|
1455
|
-
isTalkPage: (
|
|
1456
|
-
getDefaultNamespaceInfo: (
|
|
1457
|
-
id:
|
|
1457
|
+
isTalkPage: (o) => o % 2 === 1 && o > 0,
|
|
1458
|
+
getDefaultNamespaceInfo: (o) => ({
|
|
1459
|
+
id: o,
|
|
1458
1460
|
name: "",
|
|
1459
1461
|
canonical: "",
|
|
1460
1462
|
case: "first-letter",
|
|
@@ -1463,11 +1465,11 @@ const $ = /* @__PURE__ */ new WeakMap(), P = {
|
|
|
1463
1465
|
subpages: !1
|
|
1464
1466
|
})
|
|
1465
1467
|
};
|
|
1466
|
-
function ce(
|
|
1467
|
-
const e = $.get(
|
|
1468
|
+
function ce(o) {
|
|
1469
|
+
const e = $.get(o);
|
|
1468
1470
|
if (e)
|
|
1469
1471
|
return e;
|
|
1470
|
-
const t = O.buildIndex(
|
|
1472
|
+
const t = O.buildIndex(o), s = U.buildSpecialPageIndex(o);
|
|
1471
1473
|
class r {
|
|
1472
1474
|
constructor(i, c) {
|
|
1473
1475
|
if (this.newTitle = r.create.bind(r), this.toText = this.getPrefixedText.bind(this), this.toString = this.getPrefixedDBKey.bind(this), this.#t = i || "", this.#e = c ?? 0, c === void 0)
|
|
@@ -1480,7 +1482,7 @@ function ce(n) {
|
|
|
1480
1482
|
throw new Error("Invalid title");
|
|
1481
1483
|
}
|
|
1482
1484
|
static {
|
|
1483
|
-
this._meta =
|
|
1485
|
+
this._meta = o;
|
|
1484
1486
|
}
|
|
1485
1487
|
static {
|
|
1486
1488
|
this._namespaceIndex = t;
|
|
@@ -1644,7 +1646,7 @@ function ce(n) {
|
|
|
1644
1646
|
};
|
|
1645
1647
|
}
|
|
1646
1648
|
}
|
|
1647
|
-
return $.set(
|
|
1649
|
+
return $.set(o, r), r;
|
|
1648
1650
|
}
|
|
1649
1651
|
export {
|
|
1650
1652
|
I as M,
|
|
@@ -1658,4 +1660,4 @@ export {
|
|
|
1658
1660
|
te as r,
|
|
1659
1661
|
ie as u
|
|
1660
1662
|
};
|
|
1661
|
-
//# sourceMappingURL=index-
|
|
1663
|
+
//# sourceMappingURL=index-Ay5PsdkH.js.map
|