@bhsd/codemirror-mediawiki 2.24.2 → 2.25.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/hover.d.ts +7 -1
- package/dist/linter.d.mts +46 -0
- package/dist/linter.d.ts +10 -4
- package/dist/linter.mjs +35 -5
- package/dist/main.min.js +16 -16
- package/dist/mw.min.js +20 -20
- package/dist/mwConfig.d.mts +15 -0
- package/dist/mwConfig.mjs +22 -11
- package/dist/statusBar.d.ts +2 -0
- package/dist/token.d.ts +0 -2
- 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 +1 -1
- package/package.json +8 -7
package/dist/hover.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tooltip } from '@codemirror/view';
|
|
1
|
+
import type { Tooltip, TooltipView, EditorView } from '@codemirror/view';
|
|
2
2
|
import type { Text } from '@codemirror/state';
|
|
3
3
|
import type { Position } from 'vscode-languageserver-types';
|
|
4
4
|
/**
|
|
@@ -13,6 +13,12 @@ export declare const indexToPos: (doc: Text, index: number) => Position;
|
|
|
13
13
|
* @param pos 位置
|
|
14
14
|
*/
|
|
15
15
|
export declare const posToIndex: (doc: Text, pos: Position) => number;
|
|
16
|
+
/**
|
|
17
|
+
* 创建 TooltipView
|
|
18
|
+
* @param view EditorView 实例
|
|
19
|
+
* @param innerHTML 提示内容
|
|
20
|
+
*/
|
|
21
|
+
export declare const createTooltipView: (view: EditorView, innerHTML: string) => TooltipView;
|
|
16
22
|
declare const _default: import("@codemirror/state").Extension & {
|
|
17
23
|
active: import("@codemirror/state").StateField<readonly Tooltip[]>;
|
|
18
24
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Diagnostic as DiagnosticBase, Range } from 'vscode-languageserver-types';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
import type { Warning } from 'stylelint';
|
|
4
|
+
import type { Diagnostic } from 'luacheck-browserify';
|
|
5
|
+
export type Option = Record<string, unknown> | null | undefined;
|
|
6
|
+
export type LiveOption = (runtime?: true) => Option;
|
|
7
|
+
declare type getLinter<T> = () => (text: string) => T;
|
|
8
|
+
/**
|
|
9
|
+
* @param opt 初始化选项
|
|
10
|
+
* @param obj 仅用于wikiparse.LanguageService
|
|
11
|
+
* @param config runtime设置
|
|
12
|
+
*/
|
|
13
|
+
declare type getAsyncLinter<T, S = never, R = never> = (opt?: S, obj?: R) => Promise<(text: string, config?: Option) => T>;
|
|
14
|
+
declare interface MixedDiagnostic extends Omit<DiagnosticBase, 'range'> {
|
|
15
|
+
range?: Range;
|
|
16
|
+
from?: number;
|
|
17
|
+
to?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 获取 Wikitext LSP
|
|
21
|
+
* @param opt 选项
|
|
22
|
+
* @param obj 对象
|
|
23
|
+
*/
|
|
24
|
+
export declare const getWikiLinter: getAsyncLinter<Promise<MixedDiagnostic[]>, Option, object>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取 ESLint
|
|
27
|
+
* @param fix 是否修正
|
|
28
|
+
*/
|
|
29
|
+
export declare const getJsLinter: getAsyncLinter<Linter.LintMessage[], boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取 Stylelint
|
|
32
|
+
* @param fix 是否修正
|
|
33
|
+
*/
|
|
34
|
+
export declare const getCssLinter: getAsyncLinter<Promise<Warning[]>, boolean>;
|
|
35
|
+
/** 获取 Luacheck */
|
|
36
|
+
export declare const getLuaLinter: getAsyncLinter<Promise<Diagnostic[]>>;
|
|
37
|
+
declare interface JsonError {
|
|
38
|
+
message: string;
|
|
39
|
+
severity: 'error';
|
|
40
|
+
line: string | undefined;
|
|
41
|
+
column: string | undefined;
|
|
42
|
+
position: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** JSON.parse */
|
|
45
|
+
export declare const getJsonLinter: getLinter<JsonError[]>;
|
|
46
|
+
export {};
|
package/dist/linter.d.ts
CHANGED
|
@@ -22,10 +22,16 @@ declare interface MixedDiagnostic extends Omit<DiagnosticBase, 'range'> {
|
|
|
22
22
|
* @param obj 对象
|
|
23
23
|
*/
|
|
24
24
|
export declare const getWikiLinter: getAsyncLinter<Promise<MixedDiagnostic[]>, Option, object>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* 获取 ESLint
|
|
27
|
+
* @param fix 是否修正
|
|
28
|
+
*/
|
|
29
|
+
export declare const getJsLinter: getAsyncLinter<Linter.LintMessage[], boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取 Stylelint
|
|
32
|
+
* @param fix 是否修正
|
|
33
|
+
*/
|
|
34
|
+
export declare const getCssLinter: getAsyncLinter<Promise<Warning[]>, boolean>;
|
|
29
35
|
/** 获取 Luacheck */
|
|
30
36
|
export declare const getLuaLinter: getAsyncLinter<Promise<Diagnostic[]>>;
|
|
31
37
|
declare interface JsonError {
|
package/dist/linter.mjs
CHANGED
|
@@ -49,7 +49,7 @@ ${sanitizeInlineStyle(childNodes[1].childNodes[0].data).replace(/\n/gu, " ")}
|
|
|
49
49
|
];
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
const getJsLinter = async () => {
|
|
52
|
+
const getJsLinter = async (fix) => {
|
|
53
53
|
var _a;
|
|
54
54
|
await loadScript("npm/eslint-linter-browserify@8.57.0/linter.min.js", "eslint", true);
|
|
55
55
|
const esLinter = new eslint.Linter(), conf = {
|
|
@@ -62,11 +62,41 @@ const getJsLinter = async () => {
|
|
|
62
62
|
conf.rules[name] = 2;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
return (text, opt) =>
|
|
65
|
+
return (text, opt) => {
|
|
66
|
+
const config = { ...conf, ...opt }, warnings = esLinter.verify(text, config);
|
|
67
|
+
if (fix) {
|
|
68
|
+
const { fixed, output } = esLinter.verifyAndFix(text, config);
|
|
69
|
+
if (fixed) {
|
|
70
|
+
warnings.push({
|
|
71
|
+
line: 1,
|
|
72
|
+
column: 1,
|
|
73
|
+
ruleId: null,
|
|
74
|
+
severity: 0,
|
|
75
|
+
message: output
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return warnings;
|
|
80
|
+
};
|
|
66
81
|
};
|
|
67
|
-
const getCssLinter = async () => {
|
|
68
|
-
await loadScript("npm/stylelint-
|
|
69
|
-
return (code, opt) =>
|
|
82
|
+
const getCssLinter = async (fix) => {
|
|
83
|
+
await loadScript("npm/@bhsd/stylelint-browserify", "stylelint");
|
|
84
|
+
return async (code, opt) => {
|
|
85
|
+
const rules = opt == null ? void 0 : opt["rules"], warnings = await styleLint(stylelint, code, rules);
|
|
86
|
+
if (fix) {
|
|
87
|
+
const text = await styleLint(stylelint, code, rules, true);
|
|
88
|
+
if (text !== code) {
|
|
89
|
+
warnings.push({
|
|
90
|
+
line: 1,
|
|
91
|
+
column: 1,
|
|
92
|
+
rule: "fix",
|
|
93
|
+
severity: "custom",
|
|
94
|
+
text
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return warnings;
|
|
99
|
+
};
|
|
70
100
|
};
|
|
71
101
|
const getLuaLinter = async () => {
|
|
72
102
|
await loadScript("npm/luacheck-browserify/dist/index.min.js", "luacheck");
|