@bhsd/codemirror-mediawiki 2.19.10 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/linter.mjs +1 -1
- package/dist/main.min.js +14 -14
- package/dist/mw.min.js +20 -20
- package/dist/mwConfig.mjs +27 -20
- package/dist/static.d.ts +1 -1
- package/dist/token.d.ts +2 -1
- package/dist/wiki.min.js +20 -20
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/mediawiki.css +3 -0
- package/mw/config.ts +22 -17
- package/package.json +3 -3
- package/src/linter.ts +1 -1
- package/src/static.ts +5 -3
package/dist/mwConfig.mjs
CHANGED
|
@@ -8,30 +8,37 @@ var getObject = (key) => JSON.parse(String(localStorage.getItem(key)));
|
|
|
8
8
|
var setObject = (key, value) => {
|
|
9
9
|
localStorage.setItem(key, JSON.stringify(value));
|
|
10
10
|
};
|
|
11
|
+
var parseVersion = (version) => version.split(".", 3).map(Number);
|
|
12
|
+
var compareVersion = (version, baseVersion) => {
|
|
13
|
+
const [major, minor] = parseVersion(version), [baseMajor, baseMinor] = parseVersion(baseVersion);
|
|
14
|
+
return major > baseMajor || major === baseMajor && minor >= baseMinor;
|
|
15
|
+
};
|
|
11
16
|
|
|
12
17
|
// src/static.ts
|
|
13
18
|
var getStaticMwConfig = ({
|
|
19
|
+
variable,
|
|
14
20
|
parserFunction: [p0, p1, ...p2],
|
|
15
21
|
protocol,
|
|
16
22
|
nsid,
|
|
17
23
|
variants,
|
|
18
24
|
redirection,
|
|
19
25
|
ext,
|
|
20
|
-
doubleUnderscore: [d0, d1, d2],
|
|
26
|
+
doubleUnderscore: [d0, d1, d2, d3],
|
|
21
27
|
img
|
|
22
28
|
}, modes) => ({
|
|
23
29
|
tags: Object.fromEntries(ext.map((s) => [s, true])),
|
|
24
30
|
tagModes: modes,
|
|
25
31
|
doubleUnderscore: [
|
|
26
32
|
Object.fromEntries((d2 && d0.length === 0 ? Object.keys(d2) : d0).map((s) => [`__${s}__`, true])),
|
|
27
|
-
Object.fromEntries(d1.map((s) => [`__${s}__`, true]))
|
|
33
|
+
Object.fromEntries((d3 && d1.length === 0 ? Object.keys(d3) : d1).map((s) => [`__${s}__`, true]))
|
|
28
34
|
],
|
|
35
|
+
variableIDs: variable,
|
|
29
36
|
functionSynonyms: [
|
|
30
37
|
{
|
|
31
38
|
...p0,
|
|
32
39
|
...Object.fromEntries(p2.flat().map((s) => [s, s]))
|
|
33
40
|
},
|
|
34
|
-
Object.fromEntries(p1.map((s) => [s,
|
|
41
|
+
Array.isArray(p1) ? Object.fromEntries(p1.map((s) => [s, s.toLowerCase()])) : { ...p1 }
|
|
35
42
|
],
|
|
36
43
|
urlProtocols: `${protocol}|//`,
|
|
37
44
|
nsid,
|
|
@@ -57,6 +64,7 @@ var setConfig = (config) => {
|
|
|
57
64
|
mw.config.set("extCodeMirrorConfig", config);
|
|
58
65
|
};
|
|
59
66
|
var getMwConfig = async (modes) => {
|
|
67
|
+
var _a2;
|
|
60
68
|
if (mw.loader.getState("ext.CodeMirror") !== null && !VALID) {
|
|
61
69
|
await mw.loader.using(mw.loader.getState("ext.CodeMirror.data") ? "ext.CodeMirror.data" : "ext.CodeMirror");
|
|
62
70
|
}
|
|
@@ -66,13 +74,13 @@ var getMwConfig = async (modes) => {
|
|
|
66
74
|
setConfig(config);
|
|
67
75
|
}
|
|
68
76
|
const isIPE = config && Object.values(config.functionSynonyms[0]).includes(true), nsid = mw.config.get("wgNamespaceIds");
|
|
69
|
-
if ((config == null ? void 0 : config.img) && config.redirection && config.variants && !isIPE) {
|
|
77
|
+
if ((config == null ? void 0 : config.img) && config.redirection && config.variants && config.variableIDs && !isIPE) {
|
|
70
78
|
config.urlProtocols = config.urlProtocols.replace(/\\:/gu, ":");
|
|
71
79
|
config.tagModes = modes;
|
|
72
80
|
return { ...config, nsid };
|
|
73
81
|
} else if (location.hostname.endsWith(".moegirl.org.cn")) {
|
|
74
82
|
const parserConfig = await (await fetch(
|
|
75
|
-
`${CDN}/npm/wikiparser-node
|
|
83
|
+
`${CDN}/npm/wikiparser-node/config/moegirl.json`
|
|
76
84
|
)).json();
|
|
77
85
|
setObject("wikilintConfig", parserConfig);
|
|
78
86
|
config = getStaticMwConfig(parserConfig, modes);
|
|
@@ -83,7 +91,8 @@ var getMwConfig = async (modes) => {
|
|
|
83
91
|
siprop: [
|
|
84
92
|
"general",
|
|
85
93
|
"magicwords",
|
|
86
|
-
...config && !isIPE ? [] : ["extensiontags", "functionhooks",
|
|
94
|
+
...config && !isIPE ? [] : ["extensiontags", "functionhooks"],
|
|
95
|
+
...(config == null ? void 0 : config.variableIDs) && !isIPE ? [] : ["variables"]
|
|
87
96
|
],
|
|
88
97
|
formatversion: "2"
|
|
89
98
|
});
|
|
@@ -113,6 +122,7 @@ var getMwConfig = async (modes) => {
|
|
|
113
122
|
config.variants = variants ? variants.map(({ code }) => code) : [];
|
|
114
123
|
config.redirection = magicwords.find(({ name }) => name === "redirect").aliases;
|
|
115
124
|
config.urlProtocols = mw.config.get("wgUrlProtocols").replace(/\\:/gu, ":");
|
|
125
|
+
(_a2 = config.variableIDs) != null ? _a2 : config.variableIDs = variables;
|
|
116
126
|
}
|
|
117
127
|
setConfig(config);
|
|
118
128
|
ALL_SETTINGS_CACHE[SITE_ID] = { config, time: Date.now() };
|
|
@@ -120,39 +130,36 @@ var getMwConfig = async (modes) => {
|
|
|
120
130
|
return { ...config, nsid };
|
|
121
131
|
};
|
|
122
132
|
var getParserConfig = (minConfig, mwConfig) => {
|
|
123
|
-
var _a2;
|
|
124
133
|
let config = getObject("wikilintConfig");
|
|
125
134
|
if (config) {
|
|
126
135
|
return config;
|
|
127
136
|
}
|
|
137
|
+
const { tags, nsid, doubleUnderscore, variants, urlProtocols, redirection, functionSynonyms, img } = mwConfig, [insensitive, sensitive] = functionSynonyms;
|
|
128
138
|
config = {
|
|
129
139
|
...minConfig,
|
|
130
|
-
ext: Object.keys(
|
|
140
|
+
ext: Object.keys(tags),
|
|
131
141
|
namespaces: mw.config.get("wgFormattedNamespaces"),
|
|
132
|
-
nsid
|
|
133
|
-
doubleUnderscore:
|
|
142
|
+
nsid,
|
|
143
|
+
doubleUnderscore: doubleUnderscore.map(
|
|
134
144
|
(obj) => Object.keys(obj).map((s) => s.slice(2, -2))
|
|
135
145
|
),
|
|
136
|
-
variants
|
|
137
|
-
protocol:
|
|
138
|
-
redirection:
|
|
146
|
+
variants,
|
|
147
|
+
protocol: urlProtocols.replace(/\|\\?\/\\?\//u, ""),
|
|
148
|
+
redirection: redirection != null ? redirection : minConfig.redirection
|
|
139
149
|
};
|
|
140
150
|
if (location.hostname.endsWith(".moegirl.org.cn")) {
|
|
141
151
|
config.html[2].push("img");
|
|
142
152
|
}
|
|
143
|
-
|
|
153
|
+
config.parserFunction[0] = insensitive;
|
|
144
154
|
if (mw.loader.getState("ext.CodeMirror") === null) {
|
|
145
|
-
for (const [key, val] of Object.entries(
|
|
155
|
+
for (const [key, val] of Object.entries(insensitive)) {
|
|
146
156
|
if (!key.startsWith("#")) {
|
|
147
157
|
config.parserFunction[0][`#${key}`] = val;
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
|
-
config.parserFunction[1] = [
|
|
152
|
-
|
|
153
|
-
"="
|
|
154
|
-
];
|
|
155
|
-
for (const [key, val] of Object.entries(mwConfig.img)) {
|
|
161
|
+
config.parserFunction[1] = "wikiparser" in globalThis && compareVersion(wikiparse.version, "1.15") && !Object.values(sensitive).includes(true) ? { ...sensitive, "=": "=" } : [...Object.keys(sensitive), "="];
|
|
162
|
+
for (const [key, val] of Object.entries(img)) {
|
|
156
163
|
config.img[key] = val.slice(4);
|
|
157
164
|
}
|
|
158
165
|
return config;
|
package/dist/static.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ export declare const tagModes: {
|
|
|
24
24
|
maplink: string;
|
|
25
25
|
graph: string;
|
|
26
26
|
};
|
|
27
|
-
export declare const getStaticMwConfig: ({ parserFunction: [p0, p1, ...p2], protocol, nsid, variants, redirection, ext, doubleUnderscore: [d0, d1, d2], img, }: Config, modes: Record<string, string>) => MwConfig;
|
|
27
|
+
export declare const getStaticMwConfig: ({ variable, parserFunction: [p0, p1, ...p2], protocol, nsid, variants, redirection, ext, doubleUnderscore: [d0, d1, d2, d3], img, }: Config, modes: Record<string, string>) => MwConfig;
|
package/dist/token.d.ts
CHANGED
|
@@ -56,9 +56,10 @@ export interface MwConfig {
|
|
|
56
56
|
readonly tags: Record<string, true>;
|
|
57
57
|
tagModes: Record<string, string>;
|
|
58
58
|
urlProtocols: string;
|
|
59
|
-
functionSynonyms: [Record<string, string>, Record<string,
|
|
59
|
+
functionSynonyms: [Record<string, string>, Record<string, string>];
|
|
60
60
|
doubleUnderscore: [Record<string, unknown>, Record<string, unknown>];
|
|
61
61
|
nsid: Record<string, number>;
|
|
62
|
+
variableIDs?: string[];
|
|
62
63
|
variants?: string[];
|
|
63
64
|
img?: Record<string, string>;
|
|
64
65
|
redirection?: string[];
|