@inpageedit/core 0.9.0 → 0.9.3

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.
Files changed (60) hide show
  1. package/dist/InPageEdit.d.ts +1 -1
  2. package/dist/Preferences-DS4-CFWe.js +9 -0
  3. package/dist/Preferences-DS4-CFWe.js.map +1 -0
  4. package/dist/decorators/Preferences.d.ts +2 -3
  5. package/dist/index-BJ2aqva1.js +357 -0
  6. package/dist/index-BJ2aqva1.js.map +1 -0
  7. package/dist/index-BKxuoVoX.js +5738 -0
  8. package/dist/index-BKxuoVoX.js.map +1 -0
  9. package/dist/{index-DMNUP3fg.js → index-CA_JNRF8.js} +3 -3
  10. package/dist/index-CA_JNRF8.js.map +1 -0
  11. package/dist/{index-CBQsBfc2.js → index-CMuITxgX.js} +2 -2
  12. package/dist/{index-CBQsBfc2.js.map → index-CMuITxgX.js.map} +1 -1
  13. package/dist/{index-CYdxWw9g.js → index-CNsfHvio.js} +3 -3
  14. package/dist/{index-CYdxWw9g.js.map → index-CNsfHvio.js.map} +1 -1
  15. package/dist/{index-G3k3kjCU.js → index-CiceXP5j.js} +2 -2
  16. package/dist/{index-G3k3kjCU.js.map → index-CiceXP5j.js.map} +1 -1
  17. package/dist/{index-dp6_MU68.js → index-D8zKl2eU.js} +3 -3
  18. package/dist/{index-dp6_MU68.js.map → index-D8zKl2eU.js.map} +1 -1
  19. package/dist/{index-BDVcDlsf.js → index-D968kDLW.js} +3 -3
  20. package/dist/{index-BDVcDlsf.js.map → index-D968kDLW.js.map} +1 -1
  21. package/dist/{index-D7SQwFxl.js → index-DRaYlg2d.js} +3 -3
  22. package/dist/{index-D7SQwFxl.js.map → index-DRaYlg2d.js.map} +1 -1
  23. package/dist/{index-CNsB3Vcb.js → index-DtLiqtR8.js} +1568 -1505
  24. package/dist/{index-CNsB3Vcb.js.map → index-DtLiqtR8.js.map} +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/models/WikiPage/index.d.ts +1 -2
  27. package/dist/plugins/BasePlugin.d.ts +0 -2
  28. package/dist/plugins/{preferences/ui → preferences-ui}/index.d.ts +4 -3
  29. package/dist/plugins/quick-delete/index.d.ts +2 -2
  30. package/dist/plugins/quick-diff/components/DiffTable.d.ts +2 -2
  31. package/dist/plugins/quick-diff/index.d.ts +60 -1
  32. package/dist/plugins/quick-edit/index.d.ts +2 -2
  33. package/dist/plugins/quick-move/index.d.ts +2 -2
  34. package/dist/plugins/quick-redirect/index.d.ts +2 -2
  35. package/dist/services/ApiService.d.ts +1 -1
  36. package/dist/services/CurrentPageService.d.ts +2 -2
  37. package/dist/{plugins/preferences/index.d.ts → services/PreferencesService.d.ts} +9 -9
  38. package/dist/services/WikiMetadataService.d.ts +1 -1
  39. package/dist/services/WikiPageService.d.ts +2 -2
  40. package/dist/services/WikiTitleService.d.ts +7 -3
  41. package/dist/services/storage/IDBStorage.d.ts +90 -0
  42. package/dist/services/storage/index.d.ts +53 -0
  43. package/dist/style.css +1 -1
  44. package/dist/utils/vueHooks.d.ts +2 -1
  45. package/lib/index.umd.js +36 -47
  46. package/lib/index.umd.js.map +1 -1
  47. package/lib/style.css +1 -1
  48. package/package.json +8 -14
  49. package/dist/Preferences-Bg3J5Ur9.js +0 -9
  50. package/dist/Preferences-Bg3J5Ur9.js.map +0 -1
  51. package/dist/index-9Z4ds-WM.js +0 -6339
  52. package/dist/index-9Z4ds-WM.js.map +0 -1
  53. package/dist/index-BB9MXkUv.js +0 -171
  54. package/dist/index-BB9MXkUv.js.map +0 -1
  55. package/dist/index-CADkQBg0.js +0 -1249
  56. package/dist/index-CADkQBg0.js.map +0 -1
  57. package/dist/index-DMNUP3fg.js.map +0 -1
  58. package/dist/plugins/quick-diff/JsDiffService.d.ts +0 -23
  59. package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +0 -72
  60. package/dist/services/StorageService.d.ts +0 -56
@@ -1,1249 +0,0 @@
1
- import { j as a, F as Ne, P as Ee } from "./index-CvhkVj_L.js";
2
- import { B as K, I as Se, S as P } from "./index-9Z4ds-WM.js";
3
- import { I as Pe } from "./IconQuickEdit-CAL1HXIb.js";
4
- import { R as We } from "./Preferences-Bg3J5Ur9.js";
5
- import { R as _e } from "./RadioBox-nJqWsxW2.js";
6
- import { M as Oe } from "./index-lZkYoUca.js";
7
- class N {
8
- diff(e, n, i = {}) {
9
- let s;
10
- typeof i == "function" ? (s = i, i = {}) : "callback" in i && (s = i.callback);
11
- const r = this.castInput(e, i), l = this.castInput(n, i), o = this.removeEmpty(this.tokenize(r, i)), f = this.removeEmpty(this.tokenize(l, i));
12
- return this.diffWithOptionsObj(o, f, i, s);
13
- }
14
- diffWithOptionsObj(e, n, i, s) {
15
- var r;
16
- const l = (d) => {
17
- if (d = this.postProcess(d, i), s) {
18
- setTimeout(function() {
19
- s(d);
20
- }, 0);
21
- return;
22
- } else
23
- return d;
24
- }, o = n.length, f = e.length;
25
- let h = 1, c = o + f;
26
- i.maxEditLength != null && (c = Math.min(c, i.maxEditLength));
27
- const g = (r = i.timeout) !== null && r !== void 0 ? r : 1 / 0, y = Date.now() + g, w = [{ oldPos: -1, lastComponent: void 0 }];
28
- let m = this.extractCommon(w[0], n, e, 0, i);
29
- if (w[0].oldPos + 1 >= f && m + 1 >= o)
30
- return l(this.buildValues(w[0].lastComponent, n, e));
31
- let v = -1 / 0, x = 1 / 0;
32
- const C = () => {
33
- for (let d = Math.max(v, -h); d <= Math.min(x, h); d += 2) {
34
- let u;
35
- const p = w[d - 1], k = w[d + 1];
36
- p && (w[d - 1] = void 0);
37
- let D = !1;
38
- if (k) {
39
- const E = k.oldPos - d;
40
- D = k && 0 <= E && E < o;
41
- }
42
- const b = p && p.oldPos + 1 < f;
43
- if (!D && !b) {
44
- w[d] = void 0;
45
- continue;
46
- }
47
- if (!b || D && p.oldPos < k.oldPos ? u = this.addToPath(k, !0, !1, 0, i) : u = this.addToPath(p, !1, !0, 1, i), m = this.extractCommon(u, n, e, d, i), u.oldPos + 1 >= f && m + 1 >= o)
48
- return l(this.buildValues(u.lastComponent, n, e)) || !0;
49
- w[d] = u, u.oldPos + 1 >= f && (x = Math.min(x, d - 1)), m + 1 >= o && (v = Math.max(v, d + 1));
50
- }
51
- h++;
52
- };
53
- if (s)
54
- (function d() {
55
- setTimeout(function() {
56
- if (h > c || Date.now() > y)
57
- return s(void 0);
58
- C() || d();
59
- }, 0);
60
- })();
61
- else
62
- for (; h <= c && Date.now() <= y; ) {
63
- const d = C();
64
- if (d)
65
- return d;
66
- }
67
- }
68
- addToPath(e, n, i, s, r) {
69
- const l = e.lastComponent;
70
- return l && !r.oneChangePerToken && l.added === n && l.removed === i ? {
71
- oldPos: e.oldPos + s,
72
- lastComponent: { count: l.count + 1, added: n, removed: i, previousComponent: l.previousComponent }
73
- } : {
74
- oldPos: e.oldPos + s,
75
- lastComponent: { count: 1, added: n, removed: i, previousComponent: l }
76
- };
77
- }
78
- extractCommon(e, n, i, s, r) {
79
- const l = n.length, o = i.length;
80
- let f = e.oldPos, h = f - s, c = 0;
81
- for (; h + 1 < l && f + 1 < o && this.equals(i[f + 1], n[h + 1], r); )
82
- h++, f++, c++, r.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
83
- return c && !r.oneChangePerToken && (e.lastComponent = { count: c, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = f, h;
84
- }
85
- equals(e, n, i) {
86
- return i.comparator ? i.comparator(e, n) : e === n || !!i.ignoreCase && e.toLowerCase() === n.toLowerCase();
87
- }
88
- removeEmpty(e) {
89
- const n = [];
90
- for (let i = 0; i < e.length; i++)
91
- e[i] && n.push(e[i]);
92
- return n;
93
- }
94
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
- castInput(e, n) {
96
- return e;
97
- }
98
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
99
- tokenize(e, n) {
100
- return Array.from(e);
101
- }
102
- join(e) {
103
- return e.join("");
104
- }
105
- postProcess(e, n) {
106
- return e;
107
- }
108
- get useLongestToken() {
109
- return !1;
110
- }
111
- buildValues(e, n, i) {
112
- const s = [];
113
- let r;
114
- for (; e; )
115
- s.push(e), r = e.previousComponent, delete e.previousComponent, e = r;
116
- s.reverse();
117
- const l = s.length;
118
- let o = 0, f = 0, h = 0;
119
- for (; o < l; o++) {
120
- const c = s[o];
121
- if (c.removed)
122
- c.value = this.join(i.slice(h, h + c.count)), h += c.count;
123
- else {
124
- if (!c.added && this.useLongestToken) {
125
- let g = n.slice(f, f + c.count);
126
- g = g.map(function(y, w) {
127
- const m = i[h + w];
128
- return m.length > y.length ? m : y;
129
- }), c.value = this.join(g);
130
- } else
131
- c.value = this.join(n.slice(f, f + c.count));
132
- f += c.count, c.added || (h += c.count);
133
- }
134
- }
135
- return s;
136
- }
137
- }
138
- class Te extends N {
139
- }
140
- const ee = new Te();
141
- function te(t, e, n) {
142
- return ee.diff(t, e, n);
143
- }
144
- function V(t, e) {
145
- let n;
146
- for (n = 0; n < t.length && n < e.length; n++)
147
- if (t[n] != e[n])
148
- return t.slice(0, n);
149
- return t.slice(0, n);
150
- }
151
- function Y(t, e) {
152
- let n;
153
- if (!t || !e || t[t.length - 1] != e[e.length - 1])
154
- return "";
155
- for (n = 0; n < t.length && n < e.length; n++)
156
- if (t[t.length - (n + 1)] != e[e.length - (n + 1)])
157
- return t.slice(-n);
158
- return t.slice(-n);
159
- }
160
- function $(t, e, n) {
161
- if (t.slice(0, e.length) != e)
162
- throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);
163
- return n + t.slice(e.length);
164
- }
165
- function H(t, e, n) {
166
- if (!e)
167
- return t + n;
168
- if (t.slice(-e.length) != e)
169
- throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);
170
- return t.slice(0, -e.length) + n;
171
- }
172
- function W(t, e) {
173
- return $(t, e, "");
174
- }
175
- function O(t, e) {
176
- return H(t, e, "");
177
- }
178
- function X(t, e) {
179
- return e.slice(0, Le(t, e));
180
- }
181
- function Le(t, e) {
182
- let n = 0;
183
- t.length > e.length && (n = t.length - e.length);
184
- let i = e.length;
185
- t.length < e.length && (i = t.length);
186
- const s = Array(i);
187
- let r = 0;
188
- s[0] = 0;
189
- for (let l = 1; l < i; l++) {
190
- for (e[l] == e[r] ? s[l] = s[r] : s[l] = r; r > 0 && e[l] != e[r]; )
191
- r = s[r];
192
- e[l] == e[r] && r++;
193
- }
194
- r = 0;
195
- for (let l = n; l < t.length; l++) {
196
- for (; r > 0 && t[l] != e[r]; )
197
- r = s[r];
198
- t[l] == e[r] && r++;
199
- }
200
- return r;
201
- }
202
- function Fe(t) {
203
- return t.includes(`\r
204
- `) && !t.startsWith(`
205
- `) && !t.match(/[^\r]\n/);
206
- }
207
- function Ae(t) {
208
- return !t.includes(`\r
209
- `) && t.includes(`
210
- `);
211
- }
212
- function _(t) {
213
- let e;
214
- for (e = t.length - 1; e >= 0 && t[e].match(/\s/); e--)
215
- ;
216
- return t.substring(e + 1);
217
- }
218
- function S(t) {
219
- const e = t.match(/^\s*/);
220
- return e ? e[0] : "";
221
- }
222
- const L = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}", je = new RegExp(`[${L}]+|\\s+|[^${L}]`, "ug");
223
- class Ie extends N {
224
- equals(e, n, i) {
225
- return i.ignoreCase && (e = e.toLowerCase(), n = n.toLowerCase()), e.trim() === n.trim();
226
- }
227
- tokenize(e, n = {}) {
228
- let i;
229
- if (n.intlSegmenter) {
230
- const l = n.intlSegmenter;
231
- if (l.resolvedOptions().granularity != "word")
232
- throw new Error('The segmenter passed must have a granularity of "word"');
233
- i = Array.from(l.segment(e), (o) => o.segment);
234
- } else
235
- i = e.match(je) || [];
236
- const s = [];
237
- let r = null;
238
- return i.forEach((l) => {
239
- /\s/.test(l) ? r == null ? s.push(l) : s.push(s.pop() + l) : r != null && /\s/.test(r) ? s[s.length - 1] == r ? s.push(s.pop() + l) : s.push(r + l) : s.push(l), r = l;
240
- }), s;
241
- }
242
- join(e) {
243
- return e.map((n, i) => i == 0 ? n : n.replace(/^\s+/, "")).join("");
244
- }
245
- postProcess(e, n) {
246
- if (!e || n.oneChangePerToken)
247
- return e;
248
- let i = null, s = null, r = null;
249
- return e.forEach((l) => {
250
- l.added ? s = l : l.removed ? r = l : ((s || r) && Z(i, r, s, l), i = l, s = null, r = null);
251
- }), (s || r) && Z(i, r, s, null), e;
252
- }
253
- }
254
- const ne = new Ie();
255
- function ie(t, e, n) {
256
- return n?.ignoreWhitespace != null && !n.ignoreWhitespace ? M(t, e, n) : ne.diff(t, e, n);
257
- }
258
- function Z(t, e, n, i) {
259
- if (e && n) {
260
- const s = S(e.value), r = _(e.value), l = S(n.value), o = _(n.value);
261
- if (t) {
262
- const f = V(s, l);
263
- t.value = H(t.value, l, f), e.value = W(e.value, f), n.value = W(n.value, f);
264
- }
265
- if (i) {
266
- const f = Y(r, o);
267
- i.value = $(i.value, o, f), e.value = O(e.value, f), n.value = O(n.value, f);
268
- }
269
- } else if (n) {
270
- if (t) {
271
- const s = S(n.value);
272
- n.value = n.value.substring(s.length);
273
- }
274
- if (i) {
275
- const s = S(i.value);
276
- i.value = i.value.substring(s.length);
277
- }
278
- } else if (t && i) {
279
- const s = S(i.value), r = S(e.value), l = _(e.value), o = V(s, r);
280
- e.value = W(e.value, o);
281
- const f = Y(W(s, o), l);
282
- e.value = O(e.value, f), i.value = $(i.value, s, f), t.value = H(t.value, s, s.slice(0, s.length - f.length));
283
- } else if (i) {
284
- const s = S(i.value), r = _(e.value), l = X(r, s);
285
- e.value = O(e.value, l);
286
- } else if (t) {
287
- const s = _(t.value), r = S(e.value), l = X(s, r);
288
- e.value = W(e.value, l);
289
- }
290
- }
291
- class ze extends N {
292
- tokenize(e) {
293
- const n = new RegExp(`(\\r?\\n)|[${L}]+|[^\\S\\n\\r]+|[^${L}]`, "ug");
294
- return e.match(n) || [];
295
- }
296
- }
297
- const re = new ze();
298
- function M(t, e, n) {
299
- return re.diff(t, e, n);
300
- }
301
- function $e(t, e) {
302
- if (typeof t == "function")
303
- e.callback = t;
304
- else if (t)
305
- for (const n in t)
306
- Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
307
- return e;
308
- }
309
- class He extends N {
310
- constructor() {
311
- super(...arguments), this.tokenize = le;
312
- }
313
- equals(e, n, i) {
314
- return i.ignoreWhitespace ? ((!i.newlineIsToken || !e.includes(`
315
- `)) && (e = e.trim()), (!i.newlineIsToken || !n.includes(`
316
- `)) && (n = n.trim())) : i.ignoreNewlineAtEof && !i.newlineIsToken && (e.endsWith(`
317
- `) && (e = e.slice(0, -1)), n.endsWith(`
318
- `) && (n = n.slice(0, -1))), super.equals(e, n, i);
319
- }
320
- }
321
- const R = new He();
322
- function F(t, e, n) {
323
- return R.diff(t, e, n);
324
- }
325
- function se(t, e, n) {
326
- return n = $e(n, { ignoreWhitespace: !0 }), R.diff(t, e, n);
327
- }
328
- function le(t, e) {
329
- e.stripTrailingCr && (t = t.replace(/\r\n/g, `
330
- `));
331
- const n = [], i = t.split(/(\n|\r\n)/);
332
- i[i.length - 1] || i.pop();
333
- for (let s = 0; s < i.length; s++) {
334
- const r = i[s];
335
- s % 2 && !e.newlineIsToken ? n[n.length - 1] += r : n.push(r);
336
- }
337
- return n;
338
- }
339
- function qe(t) {
340
- return t == "." || t == "!" || t == "?";
341
- }
342
- class Me extends N {
343
- tokenize(e) {
344
- var n;
345
- const i = [];
346
- let s = 0;
347
- for (let r = 0; r < e.length; r++) {
348
- if (r == e.length - 1) {
349
- i.push(e.slice(s));
350
- break;
351
- }
352
- if (qe(e[r]) && e[r + 1].match(/\s/)) {
353
- for (i.push(e.slice(s, r + 1)), r = s = r + 1; !((n = e[r + 1]) === null || n === void 0) && n.match(/\s/); )
354
- r++;
355
- i.push(e.slice(s, r + 1)), s = r + 1;
356
- }
357
- }
358
- return i;
359
- }
360
- }
361
- const oe = new Me();
362
- function fe(t, e, n) {
363
- return oe.diff(t, e, n);
364
- }
365
- class Re extends N {
366
- tokenize(e) {
367
- return e.split(/([{}:;,]|\s+)/);
368
- }
369
- }
370
- const ae = new Re();
371
- function ce(t, e, n) {
372
- return ae.diff(t, e, n);
373
- }
374
- class Je extends N {
375
- constructor() {
376
- super(...arguments), this.tokenize = le;
377
- }
378
- get useLongestToken() {
379
- return !0;
380
- }
381
- castInput(e, n) {
382
- const { undefinedReplacement: i, stringifyReplacer: s = (r, l) => typeof l > "u" ? i : l } = n;
383
- return typeof e == "string" ? e : JSON.stringify(A(e, null, null, s), null, " ");
384
- }
385
- equals(e, n, i) {
386
- return super.equals(e.replace(/,([\r\n])/g, "$1"), n.replace(/,([\r\n])/g, "$1"), i);
387
- }
388
- }
389
- const ue = new Je();
390
- function de(t, e, n) {
391
- return ue.diff(t, e, n);
392
- }
393
- function A(t, e, n, i, s) {
394
- e = e || [], n = n || [], i && (t = i(s === void 0 ? "" : s, t));
395
- let r;
396
- for (r = 0; r < e.length; r += 1)
397
- if (e[r] === t)
398
- return n[r];
399
- let l;
400
- if (Object.prototype.toString.call(t) === "[object Array]") {
401
- for (e.push(t), l = new Array(t.length), n.push(l), r = 0; r < t.length; r += 1)
402
- l[r] = A(t[r], e, n, i, String(r));
403
- return e.pop(), n.pop(), l;
404
- }
405
- if (t && t.toJSON && (t = t.toJSON()), typeof t == "object" && t !== null) {
406
- e.push(t), l = {}, n.push(l);
407
- const o = [];
408
- let f;
409
- for (f in t)
410
- Object.prototype.hasOwnProperty.call(t, f) && o.push(f);
411
- for (o.sort(), r = 0; r < o.length; r += 1)
412
- f = o[r], l[f] = A(t[f], e, n, i, f);
413
- e.pop(), n.pop();
414
- } else
415
- l = t;
416
- return l;
417
- }
418
- class Ue extends N {
419
- tokenize(e) {
420
- return e.slice();
421
- }
422
- join(e) {
423
- return e;
424
- }
425
- removeEmpty(e) {
426
- return e;
427
- }
428
- }
429
- const me = new Ue();
430
- function he(t, e, n) {
431
- return me.diff(t, e, n);
432
- }
433
- function ge(t) {
434
- return Array.isArray(t) ? t.map((e) => ge(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n, i) => {
435
- var s;
436
- return n.startsWith("\\") || n.endsWith("\r") || !((s = e.lines[i + 1]) === null || s === void 0) && s.startsWith("\\") ? n : n + "\r";
437
- }) })) });
438
- }
439
- function ve(t) {
440
- return Array.isArray(t) ? t.map((e) => ve(e)) : Object.assign(Object.assign({}, t), { hunks: t.hunks.map((e) => Object.assign(Object.assign({}, e), { lines: e.lines.map((n) => n.endsWith("\r") ? n.substring(0, n.length - 1) : n) })) });
441
- }
442
- function Qe(t) {
443
- return Array.isArray(t) || (t = [t]), !t.some((e) => e.hunks.some((n) => n.lines.some((i) => !i.startsWith("\\") && i.endsWith("\r"))));
444
- }
445
- function Be(t) {
446
- return Array.isArray(t) || (t = [t]), t.some((e) => e.hunks.some((n) => n.lines.some((i) => i.endsWith("\r")))) && t.every((e) => e.hunks.every((n) => n.lines.every((i, s) => {
447
- var r;
448
- return i.startsWith("\\") || i.endsWith("\r") || ((r = n.lines[s + 1]) === null || r === void 0 ? void 0 : r.startsWith("\\"));
449
- })));
450
- }
451
- function J(t) {
452
- const e = t.split(/\n/), n = [];
453
- let i = 0;
454
- function s() {
455
- const o = {};
456
- for (n.push(o); i < e.length; ) {
457
- const f = e[i];
458
- if (/^(---|\+\+\+|@@)\s/.test(f))
459
- break;
460
- const h = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(f);
461
- h && (o.index = h[1]), i++;
462
- }
463
- for (r(o), r(o), o.hunks = []; i < e.length; ) {
464
- const f = e[i];
465
- if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(f))
466
- break;
467
- if (/^@@/.test(f))
468
- o.hunks.push(l());
469
- else {
470
- if (f)
471
- throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(f));
472
- i++;
473
- }
474
- }
475
- }
476
- function r(o) {
477
- const f = /^(---|\+\+\+)\s+(.*)\r?$/.exec(e[i]);
478
- if (f) {
479
- const h = f[2].split(" ", 2), c = (h[1] || "").trim();
480
- let g = h[0].replace(/\\\\/g, "\\");
481
- /^".*"$/.test(g) && (g = g.substr(1, g.length - 2)), f[1] === "---" ? (o.oldFileName = g, o.oldHeader = c) : (o.newFileName = g, o.newHeader = c), i++;
482
- }
483
- }
484
- function l() {
485
- var o;
486
- const f = i, h = e[i++], c = h.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/), g = {
487
- oldStart: +c[1],
488
- oldLines: typeof c[2] > "u" ? 1 : +c[2],
489
- newStart: +c[3],
490
- newLines: typeof c[4] > "u" ? 1 : +c[4],
491
- lines: []
492
- };
493
- g.oldLines === 0 && (g.oldStart += 1), g.newLines === 0 && (g.newStart += 1);
494
- let y = 0, w = 0;
495
- for (; i < e.length && (w < g.oldLines || y < g.newLines || !((o = e[i]) === null || o === void 0) && o.startsWith("\\")); i++) {
496
- const m = e[i].length == 0 && i != e.length - 1 ? " " : e[i][0];
497
- if (m === "+" || m === "-" || m === " " || m === "\\")
498
- g.lines.push(e[i]), m === "+" ? y++ : m === "-" ? w++ : m === " " && (y++, w++);
499
- else
500
- throw new Error(`Hunk at line ${f + 1} contained invalid line ${e[i]}`);
501
- }
502
- if (!y && g.newLines === 1 && (g.newLines = 0), !w && g.oldLines === 1 && (g.oldLines = 0), y !== g.newLines)
503
- throw new Error("Added line count did not match for hunk at line " + (f + 1));
504
- if (w !== g.oldLines)
505
- throw new Error("Removed line count did not match for hunk at line " + (f + 1));
506
- return g;
507
- }
508
- for (; i < e.length; )
509
- s();
510
- return n;
511
- }
512
- function Ve(t, e, n) {
513
- let i = !0, s = !1, r = !1, l = 1;
514
- return function o() {
515
- if (i && !r) {
516
- if (s ? l++ : i = !1, t + l <= n)
517
- return t + l;
518
- r = !0;
519
- }
520
- if (!s)
521
- return r || (i = !0), e <= t - l ? t - l++ : (s = !0, o());
522
- };
523
- }
524
- function pe(t, e, n = {}) {
525
- let i;
526
- if (typeof e == "string" ? i = J(e) : Array.isArray(e) ? i = e : i = [e], i.length > 1)
527
- throw new Error("applyPatch only works with a single input.");
528
- return Ye(t, i[0], n);
529
- }
530
- function Ye(t, e, n = {}) {
531
- (n.autoConvertLineEndings || n.autoConvertLineEndings == null) && (Fe(t) && Qe(e) ? e = ge(e) : Ae(t) && Be(e) && (e = ve(e)));
532
- const i = t.split(`
533
- `), s = e.hunks, r = n.compareLine || ((m, v, x, C) => v === C), l = n.fuzzFactor || 0;
534
- let o = 0;
535
- if (l < 0 || !Number.isInteger(l))
536
- throw new Error("fuzzFactor must be a non-negative integer");
537
- if (!s.length)
538
- return t;
539
- let f = "", h = !1, c = !1;
540
- for (let m = 0; m < s[s.length - 1].lines.length; m++) {
541
- const v = s[s.length - 1].lines[m];
542
- v[0] == "\\" && (f[0] == "+" ? h = !0 : f[0] == "-" && (c = !0)), f = v;
543
- }
544
- if (h) {
545
- if (c) {
546
- if (!l && i[i.length - 1] == "")
547
- return !1;
548
- } else if (i[i.length - 1] == "")
549
- i.pop();
550
- else if (!l)
551
- return !1;
552
- } else if (c) {
553
- if (i[i.length - 1] != "")
554
- i.push("");
555
- else if (!l)
556
- return !1;
557
- }
558
- function g(m, v, x, C = 0, d = !0, u = [], p = 0) {
559
- let k = 0, D = !1;
560
- for (; C < m.length; C++) {
561
- const b = m[C], E = b.length > 0 ? b[0] : " ", z = b.length > 0 ? b.substr(1) : b;
562
- if (E === "-")
563
- if (r(v + 1, i[v], E, z))
564
- v++, k = 0;
565
- else
566
- return !x || i[v] == null ? null : (u[p] = i[v], g(m, v + 1, x - 1, C, !1, u, p + 1));
567
- if (E === "+") {
568
- if (!d)
569
- return null;
570
- u[p] = z, p++, k = 0, D = !0;
571
- }
572
- if (E === " ")
573
- if (k++, u[p] = i[v], r(v + 1, i[v], E, z))
574
- p++, d = !0, D = !1, v++;
575
- else
576
- return D || !x ? null : i[v] && (g(m, v + 1, x - 1, C + 1, !1, u, p + 1) || g(m, v + 1, x - 1, C, !1, u, p + 1)) || g(m, v, x - 1, C + 1, !1, u, p);
577
- }
578
- return p -= k, v -= k, u.length = p, {
579
- patchedLines: u,
580
- oldLineLastI: v - 1
581
- };
582
- }
583
- const y = [];
584
- let w = 0;
585
- for (let m = 0; m < s.length; m++) {
586
- const v = s[m];
587
- let x;
588
- const C = i.length - v.oldLines + l;
589
- let d;
590
- for (let u = 0; u <= l; u++) {
591
- d = v.oldStart + w - 1;
592
- const p = Ve(d, o, C);
593
- for (; d !== void 0 && (x = g(v.lines, d, u), !x); d = p())
594
- ;
595
- if (x)
596
- break;
597
- }
598
- if (!x)
599
- return !1;
600
- for (let u = o; u < d; u++)
601
- y.push(i[u]);
602
- for (let u = 0; u < x.patchedLines.length; u++) {
603
- const p = x.patchedLines[u];
604
- y.push(p);
605
- }
606
- o = x.oldLineLastI + 1, w = d + 1 - v.oldStart;
607
- }
608
- for (let m = o; m < i.length; m++)
609
- y.push(i[m]);
610
- return y.join(`
611
- `);
612
- }
613
- function Xe(t, e) {
614
- const n = typeof t == "string" ? J(t) : t;
615
- let i = 0;
616
- function s() {
617
- const r = n[i++];
618
- if (!r)
619
- return e.complete();
620
- e.loadFile(r, function(l, o) {
621
- if (l)
622
- return e.complete(l);
623
- const f = pe(o, r, e);
624
- e.patched(r, f, function(h) {
625
- if (h)
626
- return e.complete(h);
627
- s();
628
- });
629
- });
630
- }
631
- s();
632
- }
633
- function we(t) {
634
- return Array.isArray(t) ? t.map((e) => we(e)).reverse() : Object.assign(Object.assign({}, t), { oldFileName: t.newFileName, oldHeader: t.newHeader, newFileName: t.oldFileName, newHeader: t.oldHeader, hunks: t.hunks.map((e) => ({
635
- oldLines: e.newLines,
636
- oldStart: e.newStart,
637
- newLines: e.oldLines,
638
- newStart: e.oldStart,
639
- lines: e.lines.map((n) => n.startsWith("-") ? `+${n.slice(1)}` : n.startsWith("+") ? `-${n.slice(1)}` : n)
640
- })) });
641
- }
642
- function q(t, e, n, i, s, r, l) {
643
- let o;
644
- l ? typeof l == "function" ? o = { callback: l } : o = l : o = {}, typeof o.context > "u" && (o.context = 4);
645
- const f = o.context;
646
- if (o.newlineIsToken)
647
- throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
648
- if (o.callback) {
649
- const { callback: c } = o;
650
- F(n, i, Object.assign(Object.assign({}, o), { callback: (g) => {
651
- const y = h(g);
652
- c(y);
653
- } }));
654
- } else
655
- return h(F(n, i, o));
656
- function h(c) {
657
- if (!c)
658
- return;
659
- c.push({ value: "", lines: [] });
660
- function g(d) {
661
- return d.map(function(u) {
662
- return " " + u;
663
- });
664
- }
665
- const y = [];
666
- let w = 0, m = 0, v = [], x = 1, C = 1;
667
- for (let d = 0; d < c.length; d++) {
668
- const u = c[d], p = u.lines || Ge(u.value);
669
- if (u.lines = p, u.added || u.removed) {
670
- if (!w) {
671
- const k = c[d - 1];
672
- w = x, m = C, k && (v = f > 0 ? g(k.lines.slice(-f)) : [], w -= v.length, m -= v.length);
673
- }
674
- for (const k of p)
675
- v.push((u.added ? "+" : "-") + k);
676
- u.added ? C += p.length : x += p.length;
677
- } else {
678
- if (w)
679
- if (p.length <= f * 2 && d < c.length - 2)
680
- for (const k of g(p))
681
- v.push(k);
682
- else {
683
- const k = Math.min(p.length, f);
684
- for (const b of g(p.slice(0, k)))
685
- v.push(b);
686
- const D = {
687
- oldStart: w,
688
- oldLines: x - w + k,
689
- newStart: m,
690
- newLines: C - m + k,
691
- lines: v
692
- };
693
- y.push(D), w = 0, m = 0, v = [];
694
- }
695
- x += p.length, C += p.length;
696
- }
697
- }
698
- for (const d of y)
699
- for (let u = 0; u < d.lines.length; u++)
700
- d.lines[u].endsWith(`
701
- `) ? d.lines[u] = d.lines[u].slice(0, -1) : (d.lines.splice(u + 1, 0, "\"), u++);
702
- return {
703
- oldFileName: t,
704
- newFileName: e,
705
- oldHeader: s,
706
- newHeader: r,
707
- hunks: y
708
- };
709
- }
710
- }
711
- function j(t) {
712
- if (Array.isArray(t))
713
- return t.map(j).join(`
714
- `);
715
- const e = [];
716
- t.oldFileName == t.newFileName && e.push("Index: " + t.oldFileName), e.push("==================================================================="), e.push("--- " + t.oldFileName + (typeof t.oldHeader > "u" ? "" : " " + t.oldHeader)), e.push("+++ " + t.newFileName + (typeof t.newHeader > "u" ? "" : " " + t.newHeader));
717
- for (let n = 0; n < t.hunks.length; n++) {
718
- const i = t.hunks[n];
719
- i.oldLines === 0 && (i.oldStart -= 1), i.newLines === 0 && (i.newStart -= 1), e.push("@@ -" + i.oldStart + "," + i.oldLines + " +" + i.newStart + "," + i.newLines + " @@");
720
- for (const s of i.lines)
721
- e.push(s);
722
- }
723
- return e.join(`
724
- `) + `
725
- `;
726
- }
727
- function U(t, e, n, i, s, r, l) {
728
- if (typeof l == "function" && (l = { callback: l }), l?.callback) {
729
- const { callback: o } = l;
730
- q(t, e, n, i, s, r, Object.assign(Object.assign({}, l), { callback: (f) => {
731
- o(f ? j(f) : void 0);
732
- } }));
733
- } else {
734
- const o = q(t, e, n, i, s, r, l);
735
- return o ? j(o) : void 0;
736
- }
737
- }
738
- function Ze(t, e, n, i, s, r) {
739
- return U(t, t, e, n, i, s, r);
740
- }
741
- function Ge(t) {
742
- const e = t.endsWith(`
743
- `), n = t.split(`
744
- `).map((i) => i + `
745
- `);
746
- return e ? n.pop() : n.push(n.pop().slice(0, -1)), n;
747
- }
748
- function Ke(t) {
749
- const e = [];
750
- let n, i;
751
- for (let s = 0; s < t.length; s++)
752
- n = t[s], n.added ? i = 1 : n.removed ? i = -1 : i = 0, e.push([i, n.value]);
753
- return e;
754
- }
755
- function et(t) {
756
- const e = [];
757
- for (let n = 0; n < t.length; n++) {
758
- const i = t[n];
759
- i.added ? e.push("<ins>") : i.removed && e.push("<del>"), e.push(tt(i.value)), i.added ? e.push("</ins>") : i.removed && e.push("</del>");
760
- }
761
- return e.join("");
762
- }
763
- function tt(t) {
764
- let e = t;
765
- return e = e.replace(/&/g, "&amp;"), e = e.replace(/</g, "&lt;"), e = e.replace(/>/g, "&gt;"), e = e.replace(/"/g, "&quot;"), e;
766
- }
767
- const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
768
- __proto__: null,
769
- Diff: N,
770
- applyPatch: pe,
771
- applyPatches: Xe,
772
- arrayDiff: me,
773
- canonicalize: A,
774
- characterDiff: ee,
775
- convertChangesToDMP: Ke,
776
- convertChangesToXML: et,
777
- createPatch: Ze,
778
- createTwoFilesPatch: U,
779
- cssDiff: ae,
780
- diffArrays: he,
781
- diffChars: te,
782
- diffCss: ce,
783
- diffJson: de,
784
- diffLines: F,
785
- diffSentences: fe,
786
- diffTrimmedLines: se,
787
- diffWords: ie,
788
- diffWordsWithSpace: M,
789
- formatPatch: j,
790
- jsonDiff: ue,
791
- lineDiff: R,
792
- parsePatch: J,
793
- reversePatch: we,
794
- sentenceDiff: oe,
795
- structuredPatch: q,
796
- wordDiff: ne,
797
- wordsWithSpaceDiff: re
798
- }, Symbol.toStringTag, { value: "Module" }));
799
- class it {
800
- constructor(e) {
801
- this.ctx = e, this.JsDiff = nt, this.diffChars = te, this.diffWords = ie, this.diffWordsWithSpace = M, this.diffLines = F, this.diffTrimmedLines = se, this.diffSentences = fe, this.diffCss = ce, this.diffJson = de, this.diffArrays = he, this.createTwoFilesPatch = U, this.ctx.set("jsdiff", this);
802
- }
803
- }
804
- const rt = {
805
- "diff-container": "_diff-container_lq0si_2"
806
- }, st = (t) => {
807
- let { user: e, target: n, ctx: i } = t;
808
- const s = i.getUrl.bind(i);
809
- return /* @__PURE__ */ a("span", { className: "mw-userlinks", children: [
810
- /* @__PURE__ */ a("a", { href: s(`User:${e}`), className: "mw-userlink", target: n, children: e }),
811
- " ",
812
- /* @__PURE__ */ a("span", { className: "mw-usertoollinks", children: [
813
- "(",
814
- /* @__PURE__ */ a("a", { href: s(`User_talk:${e}`), className: "mw-usertoollinks-talk", target: n, children: "talk" }),
815
- " | ",
816
- /* @__PURE__ */ a(
817
- "a",
818
- {
819
- href: s(`Special:Contributions/${e}`),
820
- className: "mw-usertoollinks-contribs",
821
- target: n,
822
- children: "contribs"
823
- }
824
- ),
825
- " | ",
826
- /* @__PURE__ */ a(
827
- "a",
828
- {
829
- href: s(`Special:Block/${e}`),
830
- className: "mw-usertoollinks-block",
831
- target: n,
832
- children: "block"
833
- }
834
- ),
835
- ")"
836
- ] })
837
- ] });
838
- };
839
- var T = /* @__PURE__ */ ((t) => (t.update = "ipe:diff-table/update", t.edit = "ipe:diff-table/edit", t))(T || {});
840
- const lt = new Intl.DateTimeFormat(void 0, {
841
- dateStyle: "medium",
842
- timeStyle: "medium"
843
- }).format, G = (t) => {
844
- let e = ["diff-title"];
845
- if (t.type === "from" ? e.push("diff-otitle") : t.type === "to" && e.push("diff-ntitle"), !t.pageid || !t.userid)
846
- return /* @__PURE__ */ a("td", { colSpan: 2, className: e, children: /* @__PURE__ */ a("div", { className: "mw-diff-title--title", children: t.type === "from" ? "Original content" : t.type === "to" ? "Your content" : "" }) });
847
- const n = (i) => {
848
- i.preventDefault(), i.target.dispatchEvent(
849
- new CustomEvent("ipe:diff-table/edit", {
850
- detail: { revid: t.revid },
851
- bubbles: !0
852
- })
853
- );
854
- };
855
- return /* @__PURE__ */ a("td", { colSpan: 2, className: e, children: [
856
- /* @__PURE__ */ a("div", { className: "mw-diff-title--title", children: [
857
- t.pagetitle || t.timestamp,
858
- t.revid ? ` (rev#${t.revid})` : ""
859
- ] }),
860
- /* @__PURE__ */ a("div", { className: "mw-diff-title--actions", children: /* @__PURE__ */ a(
861
- "a",
862
- {
863
- href: t.ctx.getUrl("", { action: "edit", oldid: t.revid }),
864
- onClick: n,
865
- children: [
866
- /* @__PURE__ */ a(Pe, { style: "width: 1em; height: 1em" }),
867
- "Quick edit"
868
- ]
869
- }
870
- ) }),
871
- /* @__PURE__ */ a("div", { className: "mw-diff-title--user", children: t.username && /* @__PURE__ */ a(st, { ctx: t.ctx, user: t.username, target: "_blank" }) }),
872
- /* @__PURE__ */ a("div", { className: "mw-diff-title--timestamp", children: t.timestamp && lt(new Date(t.timestamp)) }),
873
- /* @__PURE__ */ a("div", { className: "mw-diff-title--comment", children: t.parsedcomment && /* @__PURE__ */ a(Ne, { children: [
874
- "(",
875
- /* @__PURE__ */ a("i", { innerHTML: t.parsedcomment }),
876
- ")"
877
- ] }) })
878
- ] });
879
- }, ot = (t) => {
880
- const e = t.data;
881
- if (!e.prev && !e.next)
882
- return null;
883
- const n = (i, s, r) => {
884
- i.preventDefault(), i.target.dispatchEvent(
885
- new CustomEvent("ipe:diff-table/update", {
886
- detail: { fromrev: s, torev: r },
887
- bubbles: !0
888
- })
889
- );
890
- };
891
- return /* @__PURE__ */ a("tr", { className: "mw-diff-title--navigation", children: [
892
- /* @__PURE__ */ a("td", { colSpan: 2, children: e.prev ? /* @__PURE__ */ a(
893
- "a",
894
- {
895
- href: t.ctx.getUrl("", { diff: e.prev, oldid: e.fromrevid }),
896
- onClick: (i) => n(i, e.prev, e.fromrevid),
897
- children: "← Previous"
898
- }
899
- ) : /* @__PURE__ */ a("i", { children: "Oldest version" }) }),
900
- /* @__PURE__ */ a("td", { colSpan: 2, children: e.next ? /* @__PURE__ */ a(
901
- "a",
902
- {
903
- href: t.ctx.getUrl("", { diff: e.next, oldid: e.torevid }),
904
- onClick: (i) => n(i, e.torevid, e.next),
905
- children: "Next →"
906
- }
907
- ) : /* @__PURE__ */ a("i", { children: "Newest version" }) })
908
- ] });
909
- }, ft = (t) => {
910
- const { data: e, ...n } = t, i = /* @__PURE__ */ a("table", { className: "theme-ipe diff diff-type-table", "data-mw": "interface", ...n, children: [
911
- /* @__PURE__ */ a("colgroup", { children: [
912
- /* @__PURE__ */ a("col", { className: "diff-marker" }),
913
- /* @__PURE__ */ a("col", { className: "diff-content" }),
914
- /* @__PURE__ */ a("col", { className: "diff-marker" }),
915
- /* @__PURE__ */ a("col", { className: "diff-content" })
916
- ] }),
917
- /* @__PURE__ */ a("tbody", { children: [
918
- /* @__PURE__ */ a("tr", { children: [
919
- /* @__PURE__ */ a(
920
- G,
921
- {
922
- ctx: t.ctx,
923
- type: "from",
924
- pageid: e.fromid,
925
- pagetitle: e.fromtitle,
926
- revid: e.fromrevid,
927
- size: e.fromsize,
928
- timestamp: e.fromtimestamp,
929
- username: e.fromuser,
930
- userid: e.fromuserid,
931
- comment: e.fromcomment,
932
- parsedcomment: e.fromparsedcomment
933
- }
934
- ),
935
- /* @__PURE__ */ a(
936
- G,
937
- {
938
- ctx: t.ctx,
939
- type: "to",
940
- pageid: e.toid,
941
- pagetitle: e.totitle,
942
- revid: e.torevid,
943
- size: e.tosize,
944
- timestamp: e.totimestamp,
945
- username: e.touser,
946
- userid: e.touserid,
947
- comment: e.tocomment,
948
- parsedcomment: e.toparsedcomment
949
- }
950
- )
951
- ] }),
952
- /* @__PURE__ */ a(ot, { data: e, ctx: t.ctx }),
953
- /* @__PURE__ */ a("div", { id: "diffbody" }),
954
- /* @__PURE__ */ a("tr", { className: "diff-size", style: { textAlign: "center" }, children: [
955
- /* @__PURE__ */ a("td", { colSpan: 2, className: "diff-size-old", children: e.fromsize !== void 0 && `${e.fromsize} bytes` }),
956
- /* @__PURE__ */ a("td", { colSpan: 2, className: "diff-size-new", children: e.tosize !== void 0 && `${e.tosize} bytes` })
957
- ] })
958
- ] })
959
- ] });
960
- return i.querySelector("#diffbody").outerHTML = e.body || (/* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: 4, children: /* @__PURE__ */ a(
961
- "div",
962
- {
963
- style: {
964
- display: "flex",
965
- justifyContent: "center",
966
- alignItems: "center",
967
- height: "5rem"
968
- },
969
- children: /* @__PURE__ */ a("i", { children: "No changes" })
970
- }
971
- ) }) })).outerHTML, i;
972
- }, at = (t, e = document) => e.querySelector(t), ct = (t, e = document) => e.querySelectorAll(t);
973
- var ut = Object.create, Q = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, ye = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), xe = (t) => {
974
- throw TypeError(t);
975
- }, mt = (t, e, n) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ht = (t, e) => Q(t, "name", { value: e, configurable: !0 }), gt = (t) => [, , , ut(t?.[ye("metadata")] ?? null)], vt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], ke = (t) => t !== void 0 && typeof t != "function" ? xe("Function expected") : t, pt = (t, e, n, i, s) => ({ kind: vt[t], name: e, metadata: i, addInitializer: (r) => n._ ? xe("Already initialized") : s.push(ke(r || null)) }), wt = (t, e) => mt(e, ye("metadata"), t[3]), yt = (t, e, n, i) => {
976
- for (var s = 0, r = t[e >> 1], l = r && r.length; s < l; s++) r[s].call(n);
977
- return i;
978
- }, xt = (t, e, n, i, s, r) => {
979
- var l, o, f, h = e & 7, c = !1, g = 0, y = t[g] || (t[g] = []), w = h && (s = s.prototype, h < 5 && (h > 3 || !c) && dt(s, n));
980
- ht(s, n);
981
- for (var m = i.length - 1; m >= 0; m--)
982
- f = pt(h, n, o = {}, t[3], y), l = (0, i[m])(s, f), o._ = 1, ke(l) && (s = l);
983
- return wt(t, s), w && Q(s, n, w), c ? h ^ 4 ? r : w : s;
984
- }, Ce, B, be;
985
- const De = [
986
- "diffChars",
987
- "diffWords",
988
- "diffSentences",
989
- "diffLines",
990
- "createTwoFilesPatch"
991
- ];
992
- Ce = [Se(["jsdiff", "wiki", "getUrl"]), We(
993
- P.object({
994
- "quickDiff.preferredCompareMode": P.union([P.const("jsDiff"), P.const("mwApi")]).description("The preferred comparison mode for quick diff").default("mwApi"),
995
- "quickDiff.jsDiff.defaultType": P.union(De.map((t) => P.const(t))).description("The default diff type for JsDiff").default("diffSentences")
996
- }).description("Quick Diff Preferences"),
997
- {
998
- "quickDiff.preferredCompareMode": "mwApi",
999
- "quickDiff.jsDiff.defaultType": "diffSentences"
1000
- }
1001
- )];
1002
- class I extends (be = K) {
1003
- constructor(e) {
1004
- super(e, {}, "quick-diff"), this.ctx = e, this.VALID_DIFF_TYPES = De, this.COMPARE_API_DEFAULT_OPTIONS = {
1005
- prop: [
1006
- "comment",
1007
- "diff",
1008
- "diffsize",
1009
- "ids",
1010
- "parsedcomment",
1011
- "size",
1012
- "timestamp",
1013
- "title",
1014
- "user",
1015
- "rel"
1016
- ].join("|"),
1017
- difftype: "table"
1018
- };
1019
- }
1020
- start() {
1021
- this.ctx.set("quickDiff", this), this.ctx.on("quick-edit/wiki-page", this.injectQuickEdit.bind(this)), window.RLQ.push(this.injectHistoryPage.bind(this));
1022
- }
1023
- stop() {
1024
- }
1025
- injectHistoryPage() {
1026
- const e = at("#mw-history-compare");
1027
- if (!e)
1028
- return;
1029
- ct(".mw-history-compareselectedversions-button", e).forEach((i) => {
1030
- i.after(
1031
- /* @__PURE__ */ a(
1032
- "button",
1033
- {
1034
- className: "cdx-button",
1035
- onClick: (s) => {
1036
- s.preventDefault();
1037
- const r = new FormData(e), l = Number(r.get("oldid")) || 0, o = Number(r.get("diff")) || 0;
1038
- if (!r.get("title") || !l || !o)
1039
- return this.logger.warn("Missing title or revision IDs");
1040
- this.comparePages({
1041
- fromrev: l,
1042
- torev: o
1043
- });
1044
- },
1045
- children: "Quick Diff"
1046
- }
1047
- )
1048
- );
1049
- });
1050
- }
1051
- injectQuickEdit({ modal: e, wikiPage: n, options: i }) {
1052
- if (n.pageid === 0 || i.section === "new")
1053
- return;
1054
- let s;
1055
- e.addButton(
1056
- {
1057
- label: "Diff",
1058
- side: "left",
1059
- keyPress: "ctrl-d",
1060
- className: "btn btn-secondary",
1061
- method: () => {
1062
- const r = n.title, l = n.revisions?.[0]?.content || "", o = e.get$content().querySelector('textarea[name="text"]')?.value || "";
1063
- return l === o ? this.ctx.modal.notify("info", { title: "Quick Diff", content: "No changes" }) : (s = this.comparePages(
1064
- {
1065
- fromtitle: r,
1066
- fromtext: l,
1067
- totitle: r,
1068
- totext: o,
1069
- topst: !0
1070
- },
1071
- s,
1072
- {
1073
- backdrop: !1,
1074
- draggable: !0
1075
- }
1076
- ), s);
1077
- }
1078
- },
1079
- 2
1080
- ), e.on(e.Event.Close, () => {
1081
- s?.destroy(), s = void 0;
1082
- });
1083
- }
1084
- simpleTextDiff(e, n) {
1085
- const i = this.ctx.modal.show({
1086
- title: "Quick Diff",
1087
- className: "in-page-edit ipe-quickDiff"
1088
- });
1089
- i.show();
1090
- const s = /* @__PURE__ */ a("pre", { className: rt["diff-container"] }), r = /* @__PURE__ */ a(
1091
- "div",
1092
- {
1093
- style: {
1094
- display: "flex",
1095
- gap: "1em"
1096
- },
1097
- children: this.VALID_DIFF_TYPES.map((l, o) => /* @__PURE__ */ a(
1098
- _e,
1099
- {
1100
- name: "diffType",
1101
- value: l,
1102
- label: l,
1103
- inputProps: {
1104
- checked: o === 0
1105
- }
1106
- }
1107
- ))
1108
- }
1109
- );
1110
- i.setContent(
1111
- /* @__PURE__ */ a("section", { children: [
1112
- r,
1113
- s
1114
- ] })
1115
- ), r.querySelectorAll('input[name="diffType"]').forEach((l) => {
1116
- l.addEventListener("change", () => {
1117
- const o = this.renderJsDiff(e, n, l.value);
1118
- s.textContent = "", s.appendChild(o);
1119
- });
1120
- }), r.querySelector('input[name="diffType"]').dispatchEvent(new Event("change"));
1121
- }
1122
- /**
1123
- * TODO: 类型体操
1124
- */
1125
- renderJsDiff(e, n, i = "diffSentences") {
1126
- const s = document.createDocumentFragment();
1127
- let r;
1128
- if (i === "createTwoFilesPatch") {
1129
- let l = !1;
1130
- r = this.ctx.jsdiff.createTwoFilesPatch("original.txt", "modified.txt", e, n).split(`
1131
- `).map(function(o) {
1132
- const f = {
1133
- value: o + `
1134
- `
1135
- };
1136
- return o.startsWith("@@") ? (f.chunkHeader = !0, l = !0) : l && (o.startsWith("-") ? f.removed = !0 : o.startsWith("+") && (f.added = !0)), f;
1137
- });
1138
- } else {
1139
- const l = this.ctx.jsdiff[i];
1140
- if (!l)
1141
- throw new Error(`Missing DiffEngine for ${i}`);
1142
- r = l(e, n);
1143
- }
1144
- if (!Array.isArray(r))
1145
- throw new Error("Missing diff result");
1146
- for (let l = 0; l < r.length; l++) {
1147
- if (r[l].added && r[l + 1] && r[l + 1].removed) {
1148
- const f = r[l];
1149
- r[l] = r[l + 1], r[l + 1] = f;
1150
- }
1151
- let o;
1152
- r[l].removed ? (o = document.createElement("del"), o.appendChild(document.createTextNode(r[l].value))) : r[l].added ? (o = document.createElement("ins"), o.appendChild(document.createTextNode(r[l].value))) : r[l].chunkHeader ? (o = document.createElement("span"), o.setAttribute("class", "chunk-header"), o.appendChild(document.createTextNode(r[l].value))) : o = document.createTextNode(r[l].value), s.appendChild(o);
1153
- }
1154
- return s;
1155
- }
1156
- comparePages(e, n, i) {
1157
- return !n || n.isDestroyed ? n = this.ctx.modal.createObject({
1158
- title: "Loading diff...",
1159
- content: "",
1160
- className: "quick-diff",
1161
- center: !1,
1162
- ...i
1163
- }).init() : n.removeButton("*"), n.setContent(
1164
- /* @__PURE__ */ a(
1165
- "section",
1166
- {
1167
- style: { height: "70vh", display: "flex", justifyContent: "center", alignItems: "center" },
1168
- children: /* @__PURE__ */ a(Ee, {})
1169
- }
1170
- )
1171
- ), n.bringToFront(), window.mw && mw.loader.getState("mediawiki.diff.styles") !== "ready" && mw.loader.load(["mediawiki.diff.styles"]), this.ctx.api.post({
1172
- ...this.COMPARE_API_DEFAULT_OPTIONS,
1173
- ...e,
1174
- action: "compare",
1175
- format: "json",
1176
- formatversion: 2
1177
- }).then((s) => {
1178
- if (!s.data.compare)
1179
- throw new Error("No compare data received", { cause: s });
1180
- const {
1181
- data: { compare: r }
1182
- } = s;
1183
- n.setTitle(
1184
- r.fromtitle && r.totitle ? `${r.fromtitle}${r.fromrevid ? ` (${r.fromrevid})` : ""} ⇔ ${r.totitle}${r.torevid ? ` (${r.torevid})` : ""}` : "Differences"
1185
- );
1186
- let l;
1187
- n.setContent(
1188
- /* @__PURE__ */ a(
1189
- "section",
1190
- {
1191
- style: {
1192
- minHeight: "70vh"
1193
- },
1194
- children: /* @__PURE__ */ a(ft, { ref: (o) => l = o, data: r, ctx: this.ctx })
1195
- }
1196
- )
1197
- ), l.addEventListener(
1198
- T.update,
1199
- (o) => {
1200
- o.stopPropagation(), this.comparePages(
1201
- {
1202
- fromrev: o.detail.fromrev,
1203
- torev: o.detail.torev
1204
- },
1205
- n,
1206
- i
1207
- );
1208
- },
1209
- { once: !0 }
1210
- ), this.ctx.inject(["quickEdit"], (o) => {
1211
- const f = (h) => {
1212
- h.stopPropagation(), o.quickEdit({ revision: h.detail.revid });
1213
- };
1214
- l.addEventListener(T.edit, f), n.on(n.Event.Close, () => {
1215
- l.removeEventListener(T.edit, f);
1216
- });
1217
- }), r.fromrevid && r.torevid && n.addButton({
1218
- label: "Original Compare Page",
1219
- side: "right",
1220
- className: "btn btn-secondary",
1221
- method: () => {
1222
- window.location.href = this.ctx.getUrl("", {
1223
- oldid: r.fromrevid,
1224
- diff: r.torevid
1225
- });
1226
- }
1227
- });
1228
- }).catch((s) => {
1229
- n.setContent(
1230
- /* @__PURE__ */ a(Oe, { title: "Failed to load diff", type: "error", children: /* @__PURE__ */ a("pre", { children: s instanceof Error ? s.message : String(s) }) })
1231
- );
1232
- }), n.show();
1233
- }
1234
- }
1235
- B = gt(be);
1236
- I = xt(B, 0, "PluginQuickDiffCore", Ce, I);
1237
- yt(B, 1, I);
1238
- class St extends K {
1239
- constructor(e) {
1240
- super(e, {}, "quick-diff-loader"), this.ctx = e, e.plugin(it), e.plugin(I);
1241
- }
1242
- static {
1243
- this.inject = ["api", "wikiPage", "modal"];
1244
- }
1245
- }
1246
- export {
1247
- St as PluginQuickDiff
1248
- };
1249
- //# sourceMappingURL=index-CADkQBg0.js.map