@coderline/alphatab-monaco 1.8.2 → 1.8.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.
- package/dist/alphaTab.monaco.mjs +14 -14
- package/dist/alphatex.mjs +21 -22
- package/dist/lsp.mjs +174 -221
- package/dist/lspMonacoMappings.mjs +237 -344
- package/dist/textmate.mjs +80 -86
- package/dist/types.mjs +11 -12
- package/dist/types2.mjs +17 -0
- package/dist/worker.mjs +4609 -5116
- package/package.json +10 -13
package/dist/alphaTab.monaco.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export { addTextMateGrammarSupport, registerGrammar }
|
|
2
|
+
* alphaTab Monaco v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
*
|
|
10
|
+
* @preserve
|
|
11
|
+
* @license
|
|
12
|
+
*/
|
|
13
|
+
import { addTextMateGrammarSupport, registerGrammar } from "./textmate.mjs";
|
|
14
|
+
import { registerAlphaTexGrammar } from "./alphatex.mjs";
|
|
15
|
+
export { addTextMateGrammarSupport, registerAlphaTexGrammar, registerGrammar };
|
package/dist/alphatex.mjs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { languageConfiguration, textMateGrammar } from
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
* alphaTab Monaco v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
*
|
|
10
|
+
* @preserve
|
|
11
|
+
* @license
|
|
12
|
+
*/
|
|
13
|
+
import { registerGrammar } from "./textmate.mjs";
|
|
14
|
+
import { languageConfiguration, textMateGrammar } from "@coderline/alphatab-language-server";
|
|
15
|
+
//#region src/alphatex.ts
|
|
17
16
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
* Registers alphaTex as language in the provided grammar support context.
|
|
18
|
+
* @param grammarSupport The context for handling grammar support in Monaco.
|
|
19
|
+
*/
|
|
21
20
|
async function registerAlphaTexGrammar(grammarSupport) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return registerGrammar(grammarSupport, "alphatex", async () => {
|
|
22
|
+
return JSON.stringify(textMateGrammar);
|
|
23
|
+
}, async () => languageConfiguration);
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
//#endregion
|
|
27
26
|
export { registerAlphaTexGrammar };
|
package/dist/lsp.mjs
CHANGED
|
@@ -1,234 +1,187 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
* alphaTab Monaco v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
*
|
|
10
|
+
* @preserve
|
|
11
|
+
* @license
|
|
12
|
+
*/
|
|
13
|
+
import { lspToMonacoCompletionItem, lspToMonacoHover, lspToMonacoMarker, lspToMonacoSignatureHelp, monacoToLspCompletionItem, monacoToLspCompletionTriggerKind, monacoToLspContentChange, monacoToLspSignatureHelp, monacoToLspSignatureHelpTriggerKind } from "./lspMonacoMappings.mjs";
|
|
14
|
+
import * as monaco from "monaco-editor";
|
|
15
|
+
import { CompletionRequest, CompletionResolveRequest, DidChangeTextDocumentNotification, DidOpenTextDocumentNotification, DocumentDiagnosticRequest, HoverRequest, InitializeRequest, PositionEncodingKind, SignatureHelpRequest } from "vscode-languageserver-protocol";
|
|
16
|
+
import { BrowserMessageReader, BrowserMessageWriter, createProtocolConnection } from "vscode-languageserver-protocol/browser";
|
|
17
|
+
//#region src/lsp.ts
|
|
19
18
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
* Enables a basic Language Server integration for the given editor covering:
|
|
20
|
+
* * A single document backend (no workspace integration with file open,close, rename etc.)
|
|
21
|
+
* * Diagnostics Provider (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics)
|
|
22
|
+
* * Completions (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion)
|
|
23
|
+
* * Hover (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover)
|
|
24
|
+
* * Signature Help (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp)
|
|
25
|
+
*
|
|
26
|
+
* This feature set is mainly aligned with the capabilities of the alphaTab language server.
|
|
27
|
+
*
|
|
28
|
+
* @param editor The editor to integrate with.
|
|
29
|
+
* @param languageServerWorker The web worker with a language server listening for messages.
|
|
30
|
+
*/
|
|
32
31
|
async function basicEditorLspIntegration(editor, languageServerWorker, info) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await connection.sendNotification(DidOpenTextDocumentNotification.type, {
|
|
96
|
-
textDocument: {
|
|
97
|
-
languageId: info.languageId,
|
|
98
|
-
text: model.getValue(),
|
|
99
|
-
uri: documentUri,
|
|
100
|
-
version: model.getVersionId()
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
setupDocumentHandlingAndDiagnostics(editor, documentUri, connection);
|
|
104
|
-
setupCompletion(documentUri, info.languageId, connection, initResponse);
|
|
105
|
-
setupHover(documentUri, info.languageId, connection, initResponse);
|
|
106
|
-
setupSignatureHelp(documentUri, info.languageId, connection, initResponse);
|
|
32
|
+
const connection = createProtocolConnection(new BrowserMessageReader(languageServerWorker), new BrowserMessageWriter(languageServerWorker), info.logger);
|
|
33
|
+
connection.onError((data) => {
|
|
34
|
+
info.logger?.error(`Error on protocol connection: ${data}`);
|
|
35
|
+
});
|
|
36
|
+
connection.onClose(() => {
|
|
37
|
+
info.logger?.log(`Language Server connection closed`);
|
|
38
|
+
});
|
|
39
|
+
const initRequest = {
|
|
40
|
+
processId: null,
|
|
41
|
+
clientInfo: info.clientInfo,
|
|
42
|
+
rootUri: null,
|
|
43
|
+
capabilities: {
|
|
44
|
+
general: {
|
|
45
|
+
staleRequestSupport: {
|
|
46
|
+
cancel: true,
|
|
47
|
+
retryOnContentModified: []
|
|
48
|
+
},
|
|
49
|
+
regularExpressions: {
|
|
50
|
+
engine: "ECMAScript",
|
|
51
|
+
version: "ES2020"
|
|
52
|
+
},
|
|
53
|
+
markdown: {
|
|
54
|
+
parser: "marked",
|
|
55
|
+
version: "1.1.0"
|
|
56
|
+
},
|
|
57
|
+
positionEncodings: [PositionEncodingKind.UTF16]
|
|
58
|
+
},
|
|
59
|
+
textDocument: {
|
|
60
|
+
completion: { completionItem: {
|
|
61
|
+
snippetSupport: true,
|
|
62
|
+
documentationFormat: ["markdown", "plaintext"],
|
|
63
|
+
insertReplaceSupport: true,
|
|
64
|
+
labelDetailsSupport: true
|
|
65
|
+
} },
|
|
66
|
+
hover: { contentFormat: ["markdown", "plaintext"] },
|
|
67
|
+
signatureHelp: { signatureInformation: {
|
|
68
|
+
documentationFormat: ["markdown", "plaintext"],
|
|
69
|
+
parameterInformation: { labelOffsetSupport: true },
|
|
70
|
+
activeParameterSupport: true
|
|
71
|
+
} },
|
|
72
|
+
diagnostic: {}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
info.logger?.log(`Begin listen on connection`);
|
|
77
|
+
connection.listen();
|
|
78
|
+
info.logger?.log(`Listening now on connection`);
|
|
79
|
+
info.logger?.log(`Begin Language Server initialization`);
|
|
80
|
+
const initResponse = await connection.sendRequest(InitializeRequest.type, initRequest);
|
|
81
|
+
info.logger?.log(`Finished Language Server initialization`);
|
|
82
|
+
const documentUri = "monaco://standalone.document";
|
|
83
|
+
const model = editor.getModel();
|
|
84
|
+
await connection.sendNotification(DidOpenTextDocumentNotification.type, { textDocument: {
|
|
85
|
+
languageId: info.languageId,
|
|
86
|
+
text: model.getValue(),
|
|
87
|
+
uri: documentUri,
|
|
88
|
+
version: model.getVersionId()
|
|
89
|
+
} });
|
|
90
|
+
setupDocumentHandlingAndDiagnostics(editor, documentUri, connection);
|
|
91
|
+
setupCompletion(documentUri, info.languageId, connection, initResponse);
|
|
92
|
+
setupHover(documentUri, info.languageId, connection, initResponse);
|
|
93
|
+
setupSignatureHelp(documentUri, info.languageId, connection, initResponse);
|
|
107
94
|
}
|
|
108
95
|
function setupDocumentHandlingAndDiagnostics(editor, documentUri, connection) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
version: e.versionId
|
|
127
|
-
},
|
|
128
|
-
contentChanges: e.changes.map(monacoToLspContentChange)
|
|
129
|
-
});
|
|
130
|
-
await updateDiagnostics();
|
|
131
|
-
});
|
|
96
|
+
async function updateDiagnostics() {
|
|
97
|
+
const params = { textDocument: { uri: documentUri } };
|
|
98
|
+
const result = await connection.sendRequest(DocumentDiagnosticRequest.type, params);
|
|
99
|
+
if (result.kind === "unchanged") return;
|
|
100
|
+
monaco.editor.setModelMarkers(editor.getModel(), "lsp", result.items.map(lspToMonacoMarker));
|
|
101
|
+
}
|
|
102
|
+
updateDiagnostics();
|
|
103
|
+
editor.onDidChangeModelContent(async (e) => {
|
|
104
|
+
await connection.sendNotification(DidChangeTextDocumentNotification.type, {
|
|
105
|
+
textDocument: {
|
|
106
|
+
uri: documentUri,
|
|
107
|
+
version: e.versionId
|
|
108
|
+
},
|
|
109
|
+
contentChanges: e.changes.map(monacoToLspContentChange)
|
|
110
|
+
});
|
|
111
|
+
await updateDiagnostics();
|
|
112
|
+
});
|
|
132
113
|
}
|
|
133
114
|
function setupHover(documentUri, languageId, connection, initResponse) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const response = await connection.sendRequest(HoverRequest.type, params, token);
|
|
150
|
-
if (response === null) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
return lspToMonacoHover(response);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
115
|
+
if (!initResponse.capabilities.hoverProvider) return;
|
|
116
|
+
monaco.languages.registerHoverProvider(languageId, { async provideHover(_, position, token) {
|
|
117
|
+
const params = {
|
|
118
|
+
position: {
|
|
119
|
+
line: position.lineNumber - 1,
|
|
120
|
+
character: position.column - 1
|
|
121
|
+
},
|
|
122
|
+
textDocument: { uri: documentUri }
|
|
123
|
+
};
|
|
124
|
+
const response = await connection.sendRequest(HoverRequest.type, params, token);
|
|
125
|
+
if (response === null) return null;
|
|
126
|
+
return lspToMonacoHover(response);
|
|
127
|
+
} });
|
|
156
128
|
}
|
|
157
129
|
function setupSignatureHelp(documentUri, languageId, connection, initResponse) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const response = await connection.sendRequest(SignatureHelpRequest.type, params, token);
|
|
182
|
-
if (response === null) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
return lspToMonacoSignatureHelp(response);
|
|
186
|
-
},
|
|
187
|
-
signatureHelpRetriggerCharacters: initResponse.capabilities.signatureHelpProvider.retriggerCharacters,
|
|
188
|
-
signatureHelpTriggerCharacters: initResponse.capabilities.signatureHelpProvider.triggerCharacters
|
|
189
|
-
});
|
|
130
|
+
if (!initResponse.capabilities.signatureHelpProvider) return;
|
|
131
|
+
monaco.languages.registerSignatureHelpProvider(languageId, {
|
|
132
|
+
async provideSignatureHelp(_, position, token, context) {
|
|
133
|
+
const params = {
|
|
134
|
+
position: {
|
|
135
|
+
character: position.column - 1,
|
|
136
|
+
line: position.lineNumber - 1
|
|
137
|
+
},
|
|
138
|
+
textDocument: { uri: documentUri },
|
|
139
|
+
context: {
|
|
140
|
+
isRetrigger: context.isRetrigger,
|
|
141
|
+
triggerKind: monacoToLspSignatureHelpTriggerKind(context.triggerKind),
|
|
142
|
+
activeSignatureHelp: context.activeSignatureHelp ? monacoToLspSignatureHelp(context.activeSignatureHelp) : void 0,
|
|
143
|
+
triggerCharacter: context.triggerCharacter
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const response = await connection.sendRequest(SignatureHelpRequest.type, params, token);
|
|
147
|
+
if (response === null) return null;
|
|
148
|
+
return lspToMonacoSignatureHelp(response);
|
|
149
|
+
},
|
|
150
|
+
signatureHelpRetriggerCharacters: initResponse.capabilities.signatureHelpProvider.retriggerCharacters,
|
|
151
|
+
signatureHelpTriggerCharacters: initResponse.capabilities.signatureHelpProvider.triggerCharacters
|
|
152
|
+
});
|
|
190
153
|
}
|
|
191
154
|
function setupCompletion(documentUri, languageId, connection, initResponse) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
: {
|
|
223
|
-
suggestions: response.items.map(r => lspToMonacoCompletionItem(r, range)),
|
|
224
|
-
incomplete: response.isIncomplete
|
|
225
|
-
};
|
|
226
|
-
},
|
|
227
|
-
async resolveCompletionItem(item, token) {
|
|
228
|
-
const response = await connection.sendRequest(CompletionResolveRequest.type, monacoToLspCompletionItem(item), token);
|
|
229
|
-
return lspToMonacoCompletionItem(response, item.range);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
155
|
+
if (!initResponse.capabilities.completionProvider) return;
|
|
156
|
+
monaco.languages.registerCompletionItemProvider(languageId, {
|
|
157
|
+
triggerCharacters: initResponse.capabilities.completionProvider.triggerCharacters,
|
|
158
|
+
async provideCompletionItems(_, position, context, token) {
|
|
159
|
+
const params = {
|
|
160
|
+
position: {
|
|
161
|
+
line: position.lineNumber - 1,
|
|
162
|
+
character: position.column - 1
|
|
163
|
+
},
|
|
164
|
+
textDocument: { uri: documentUri },
|
|
165
|
+
context: {
|
|
166
|
+
triggerKind: monacoToLspCompletionTriggerKind(context.triggerKind),
|
|
167
|
+
triggerCharacter: context.triggerCharacter
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const response = await connection.sendRequest(CompletionRequest.type, params, token);
|
|
171
|
+
if (response === null) return null;
|
|
172
|
+
const range = new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column);
|
|
173
|
+
return Array.isArray(response) ? {
|
|
174
|
+
suggestions: response.map((r) => lspToMonacoCompletionItem(r, range)),
|
|
175
|
+
incomplete: false
|
|
176
|
+
} : {
|
|
177
|
+
suggestions: response.items.map((r) => lspToMonacoCompletionItem(r, range)),
|
|
178
|
+
incomplete: response.isIncomplete
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
async resolveCompletionItem(item, token) {
|
|
182
|
+
return lspToMonacoCompletionItem(await connection.sendRequest(CompletionResolveRequest.type, monacoToLspCompletionItem(item), token), item.range);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
232
185
|
}
|
|
233
|
-
|
|
186
|
+
//#endregion
|
|
234
187
|
export { basicEditorLspIntegration };
|