wikiparser-node 1.16.0 → 1.16.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/bundle/bundle.es7.js +15 -15
- package/bundle/bundle.lsp.js +32 -29
- package/bundle/bundle.min.js +15 -15
- package/config/default.json +0 -2
- package/config/zhwiki.json +0 -2
- package/data/.schema.json +56 -0
- package/data/signatures.json +2673 -0
- package/dist/base.d.mts +49 -9
- package/dist/base.d.ts +49 -9
- package/dist/index.d.ts +1 -1
- package/dist/lib/lsp.d.ts +31 -12
- package/dist/lib/lsp.js +241 -62
- package/dist/src/transclude.js +3 -2
- package/extensions/dist/base.js +22 -4
- package/extensions/dist/lsp.js +14 -0
- package/extensions/es7/base.js +22 -4
- package/extensions/typings.d.ts +1 -5
- package/package.json +3 -2
package/dist/base.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem,
|
|
1
|
+
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem as CompletionItemBase, CompletionItemKind, FoldingRange, DocumentLink, Location, WorkspaceEdit, Diagnostic, Hover, DocumentSymbol, CodeAction, SignatureHelp } from 'vscode-languageserver-types';
|
|
2
2
|
export interface Config {
|
|
3
3
|
ext: string[];
|
|
4
4
|
readonly html: [string[], string[], string[]];
|
|
@@ -96,7 +96,26 @@ interface Token extends AstNode {
|
|
|
96
96
|
/** 保存为JSON */
|
|
97
97
|
json(): AST;
|
|
98
98
|
}
|
|
99
|
+
interface SignatureParameter {
|
|
100
|
+
label: string;
|
|
101
|
+
const?: boolean;
|
|
102
|
+
rest?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface SignatureInfo {
|
|
105
|
+
aliases: string[];
|
|
106
|
+
description: string;
|
|
107
|
+
signatures?: SignatureParameter[][];
|
|
108
|
+
}
|
|
109
|
+
export interface SignatureData {
|
|
110
|
+
behaviorSwitches: SignatureInfo[];
|
|
111
|
+
parserFunctions: SignatureInfo[];
|
|
112
|
+
}
|
|
113
|
+
export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
|
|
114
|
+
kind: keyof typeof CompletionItemKind;
|
|
115
|
+
};
|
|
99
116
|
export interface LanguageService {
|
|
117
|
+
/** 销毁实例 */
|
|
118
|
+
destroy(): void;
|
|
100
119
|
/**
|
|
101
120
|
* 提供颜色指示
|
|
102
121
|
* @param rgba 颜色解析函数
|
|
@@ -106,10 +125,9 @@ export interface LanguageService {
|
|
|
106
125
|
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
107
126
|
/**
|
|
108
127
|
* 颜色选择器
|
|
109
|
-
* @
|
|
128
|
+
* @param color 颜色信息
|
|
110
129
|
*/
|
|
111
|
-
provideColorPresentations(
|
|
112
|
-
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
130
|
+
provideColorPresentations(color: ColorInformation): ColorPresentation[];
|
|
113
131
|
/**
|
|
114
132
|
* 提供自动补全
|
|
115
133
|
* @param text 源代码
|
|
@@ -117,15 +135,15 @@ export interface LanguageService {
|
|
|
117
135
|
*/
|
|
118
136
|
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
119
137
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
138
|
+
* 提供语法检查
|
|
139
|
+
* @param wikitext 源代码
|
|
122
140
|
*/
|
|
123
|
-
|
|
141
|
+
provideDiagnostics(wikitext: string): Promise<Diagnostic[]>;
|
|
124
142
|
/**
|
|
125
|
-
*
|
|
143
|
+
* 提供折叠范围
|
|
126
144
|
* @param text 源代码
|
|
127
145
|
*/
|
|
128
|
-
|
|
146
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
129
147
|
/**
|
|
130
148
|
* 提供链接
|
|
131
149
|
* @param text 源代码
|
|
@@ -156,6 +174,28 @@ export interface LanguageService {
|
|
|
156
174
|
* @param newName 新名称
|
|
157
175
|
*/
|
|
158
176
|
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
177
|
+
/**
|
|
178
|
+
* 提供悬停信息
|
|
179
|
+
* @param text 源代码
|
|
180
|
+
* @param position 位置
|
|
181
|
+
*/
|
|
182
|
+
provideHover(text: string, position: Position): Promise<Hover | undefined>;
|
|
183
|
+
/**
|
|
184
|
+
* 提供魔术字帮助
|
|
185
|
+
* @param text 源代码
|
|
186
|
+
* @param position 位置
|
|
187
|
+
*/
|
|
188
|
+
provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
|
|
189
|
+
/**
|
|
190
|
+
* 提供快速修复建议
|
|
191
|
+
* @param diagnostics 语法诊断信息
|
|
192
|
+
*/
|
|
193
|
+
provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
|
|
194
|
+
/**
|
|
195
|
+
* 提供章节
|
|
196
|
+
* @param text 源代码
|
|
197
|
+
*/
|
|
198
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
159
199
|
}
|
|
160
200
|
export interface Parser {
|
|
161
201
|
config: Config | string;
|
package/dist/base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem,
|
|
1
|
+
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem as CompletionItemBase, CompletionItemKind, FoldingRange, DocumentLink, Location, WorkspaceEdit, Diagnostic, Hover, DocumentSymbol, CodeAction, SignatureHelp } from 'vscode-languageserver-types';
|
|
2
2
|
export interface Config {
|
|
3
3
|
ext: string[];
|
|
4
4
|
readonly html: [string[], string[], string[]];
|
|
@@ -96,7 +96,26 @@ interface Token extends AstNode {
|
|
|
96
96
|
/** 保存为JSON */
|
|
97
97
|
json(): AST;
|
|
98
98
|
}
|
|
99
|
+
interface SignatureParameter {
|
|
100
|
+
label: string;
|
|
101
|
+
const?: boolean;
|
|
102
|
+
rest?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface SignatureInfo {
|
|
105
|
+
aliases: string[];
|
|
106
|
+
description: string;
|
|
107
|
+
signatures?: SignatureParameter[][];
|
|
108
|
+
}
|
|
109
|
+
export interface SignatureData {
|
|
110
|
+
behaviorSwitches: SignatureInfo[];
|
|
111
|
+
parserFunctions: SignatureInfo[];
|
|
112
|
+
}
|
|
113
|
+
export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
|
|
114
|
+
kind: keyof typeof CompletionItemKind;
|
|
115
|
+
};
|
|
99
116
|
export interface LanguageService {
|
|
117
|
+
/** 销毁实例 */
|
|
118
|
+
destroy(): void;
|
|
100
119
|
/**
|
|
101
120
|
* 提供颜色指示
|
|
102
121
|
* @param rgba 颜色解析函数
|
|
@@ -106,10 +125,9 @@ export interface LanguageService {
|
|
|
106
125
|
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
107
126
|
/**
|
|
108
127
|
* 颜色选择器
|
|
109
|
-
* @
|
|
128
|
+
* @param color 颜色信息
|
|
110
129
|
*/
|
|
111
|
-
provideColorPresentations(
|
|
112
|
-
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
130
|
+
provideColorPresentations(color: ColorInformation): ColorPresentation[];
|
|
113
131
|
/**
|
|
114
132
|
* 提供自动补全
|
|
115
133
|
* @param text 源代码
|
|
@@ -117,15 +135,15 @@ export interface LanguageService {
|
|
|
117
135
|
*/
|
|
118
136
|
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
119
137
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
138
|
+
* 提供语法检查
|
|
139
|
+
* @param wikitext 源代码
|
|
122
140
|
*/
|
|
123
|
-
|
|
141
|
+
provideDiagnostics(wikitext: string): Promise<Diagnostic[]>;
|
|
124
142
|
/**
|
|
125
|
-
*
|
|
143
|
+
* 提供折叠范围
|
|
126
144
|
* @param text 源代码
|
|
127
145
|
*/
|
|
128
|
-
|
|
146
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
129
147
|
/**
|
|
130
148
|
* 提供链接
|
|
131
149
|
* @param text 源代码
|
|
@@ -156,6 +174,28 @@ export interface LanguageService {
|
|
|
156
174
|
* @param newName 新名称
|
|
157
175
|
*/
|
|
158
176
|
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
177
|
+
/**
|
|
178
|
+
* 提供悬停信息
|
|
179
|
+
* @param text 源代码
|
|
180
|
+
* @param position 位置
|
|
181
|
+
*/
|
|
182
|
+
provideHover(text: string, position: Position): Promise<Hover | undefined>;
|
|
183
|
+
/**
|
|
184
|
+
* 提供魔术字帮助
|
|
185
|
+
* @param text 源代码
|
|
186
|
+
* @param position 位置
|
|
187
|
+
*/
|
|
188
|
+
provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
|
|
189
|
+
/**
|
|
190
|
+
* 提供快速修复建议
|
|
191
|
+
* @param diagnostics 语法诊断信息
|
|
192
|
+
*/
|
|
193
|
+
provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
|
|
194
|
+
/**
|
|
195
|
+
* 提供章节
|
|
196
|
+
* @param text 源代码
|
|
197
|
+
*/
|
|
198
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
159
199
|
}
|
|
160
200
|
export interface Parser {
|
|
161
201
|
config: Config | string;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,6 @@ declare const Parser: Parser;
|
|
|
34
34
|
// @ts-expect-error mixed export styles
|
|
35
35
|
export = Parser;
|
|
36
36
|
export default Parser;
|
|
37
|
-
export type { Config, LintError, TokenTypes, AST, };
|
|
37
|
+
export type { Config, LintError, TokenTypes, LanguageService, AST, };
|
|
38
38
|
export type * from './internal';
|
|
39
39
|
declare global { type Acceptable = unknown; }
|
package/dist/lib/lsp.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import Parser from '../index';
|
|
2
|
+
import type { Range, Position, ColorInformation, ColorPresentation, FoldingRange, DocumentSymbol, DocumentLink, Location, WorkspaceEdit, Diagnostic, Hover, CodeAction, SignatureHelp } from 'vscode-languageserver-types';
|
|
3
|
+
import type { LanguageService as LanguageServiceBase, CompletionItem, SignatureData } from '../base';
|
|
4
|
+
export declare const tasks: WeakMap<object, Parser.LanguageService>;
|
|
4
5
|
/** VSCode-style language service */
|
|
5
6
|
export declare class LanguageService implements LanguageServiceBase {
|
|
6
7
|
#private;
|
|
7
8
|
/** @param uri 任务标识 */
|
|
8
9
|
constructor(uri: object);
|
|
10
|
+
/** @implements */
|
|
11
|
+
destroy(): void;
|
|
9
12
|
/**
|
|
10
13
|
* 提供颜色指示
|
|
11
14
|
* @param rgba 颜色解析函数
|
|
@@ -13,10 +16,7 @@ export declare class LanguageService implements LanguageServiceBase {
|
|
|
13
16
|
* @param hsl 是否允许HSL颜色
|
|
14
17
|
*/
|
|
15
18
|
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
16
|
-
/**
|
|
17
|
-
* 颜色选择器
|
|
18
|
-
* @ignore
|
|
19
|
-
*/
|
|
19
|
+
/** @implements */
|
|
20
20
|
provideColorPresentations(// eslint-disable-line @typescript-eslint/class-methods-use-this
|
|
21
21
|
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
22
22
|
/**
|
|
@@ -26,15 +26,15 @@ export declare class LanguageService implements LanguageServiceBase {
|
|
|
26
26
|
*/
|
|
27
27
|
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
29
|
+
* 提供语法诊断
|
|
30
|
+
* @param wikitext 源代码
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
provideDiagnostics(wikitext: string): Promise<Diagnostic[]>;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 提供折叠范围
|
|
35
35
|
* @param text 源代码
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
38
38
|
/**
|
|
39
39
|
* 提供链接
|
|
40
40
|
* @param text 源代码
|
|
@@ -65,4 +65,23 @@ export declare class LanguageService implements LanguageServiceBase {
|
|
|
65
65
|
* @param newName 新名称
|
|
66
66
|
*/
|
|
67
67
|
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
68
|
+
/**
|
|
69
|
+
* 提供悬停信息
|
|
70
|
+
* @param text 源代码
|
|
71
|
+
* @param position 位置
|
|
72
|
+
*/
|
|
73
|
+
provideHover(text: string, position: Position): Promise<Hover | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* 提供魔术字帮助
|
|
76
|
+
* @param text 源代码
|
|
77
|
+
* @param position 位置
|
|
78
|
+
*/
|
|
79
|
+
provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
|
|
80
|
+
/** @implements */
|
|
81
|
+
provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
|
|
82
|
+
/**
|
|
83
|
+
* 提供章节
|
|
84
|
+
* @param text 源代码
|
|
85
|
+
*/
|
|
86
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
68
87
|
}
|