@coderline/alphatab-monaco 1.8.1 → 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.
@@ -1,15 +1,15 @@
1
1
  /*!
2
- * alphaTab Monaco v1.8.1 (, build 30)
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
-
14
- export { registerAlphaTexGrammar } from './alphatex.mjs';
15
- export { addTextMateGrammarSupport, registerGrammar } from './textmate.mjs';
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
- * alphaTab Monaco v1.8.1 (, build 30)
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
-
14
- import { languageConfiguration, textMateGrammar } from '@coderline/alphatab-language-server';
15
- import { registerGrammar } from './textmate.mjs';
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
- * Registers alphaTex as language in the provided grammar support context.
19
- * @param grammarSupport The context for handling grammar support in Monaco.
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
- return registerGrammar(grammarSupport, 'alphatex', async () => {
23
- return JSON.stringify(textMateGrammar);
24
- }, async () => languageConfiguration);
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
- * alphaTab Monaco v1.8.1 (, build 30)
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
-
14
- import { monacoToLspContentChange, monacoToLspCompletionItem, lspToMonacoCompletionItem, monacoToLspCompletionTriggerKind, lspToMonacoHover, monacoToLspSignatureHelp, monacoToLspSignatureHelpTriggerKind, lspToMonacoSignatureHelp, lspToMonacoMarker } from './lspMonacoMappings.mjs';
15
- import * as monaco from 'monaco-editor';
16
- import { PositionEncodingKind, InitializeRequest, DidOpenTextDocumentNotification, DidChangeTextDocumentNotification, CompletionResolveRequest, CompletionRequest, HoverRequest, SignatureHelpRequest, DocumentDiagnosticRequest } from 'vscode-languageserver-protocol';
17
- import { BrowserMessageReader, BrowserMessageWriter, createProtocolConnection } from 'vscode-languageserver-protocol/browser';
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
- * Enables a basic Language Server integration for the given editor covering:
21
- * * A single document backend (no workspace integration with file open,close, rename etc.)
22
- * * Diagnostics Provider (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics)
23
- * * Completions (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion)
24
- * * Hover (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_hover)
25
- * * Signature Help (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp)
26
- *
27
- * This feature set is mainly aligned with the capabilities of the alphaTab language server.
28
- *
29
- * @param editor The editor to integrate with.
30
- * @param languageServerWorker The web worker with a language server listening for messages.
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
- const reader = new BrowserMessageReader(languageServerWorker);
34
- const writer = new BrowserMessageWriter(languageServerWorker);
35
- const connection = createProtocolConnection(reader, writer, info.logger);
36
- connection.onError(data => {
37
- info.logger?.error(`Error on protocol connection: ${data}`);
38
- });
39
- connection.onClose(() => {
40
- info.logger?.log(`Language Server connection closed`);
41
- });
42
- const initRequest = {
43
- processId: null,
44
- clientInfo: info.clientInfo,
45
- rootUri: null,
46
- capabilities: {
47
- general: {
48
- staleRequestSupport: {
49
- cancel: true,
50
- retryOnContentModified: []
51
- },
52
- regularExpressions: {
53
- engine: 'ECMAScript',
54
- version: 'ES2020'
55
- },
56
- markdown: {
57
- parser: 'marked',
58
- version: '1.1.0'
59
- },
60
- positionEncodings: [PositionEncodingKind.UTF16]
61
- },
62
- textDocument: {
63
- completion: {
64
- completionItem: {
65
- snippetSupport: true,
66
- documentationFormat: ['markdown', 'plaintext'],
67
- insertReplaceSupport: true,
68
- labelDetailsSupport: true
69
- }
70
- },
71
- hover: {
72
- contentFormat: ['markdown', 'plaintext']
73
- },
74
- signatureHelp: {
75
- signatureInformation: {
76
- documentationFormat: ['markdown', 'plaintext'],
77
- parameterInformation: {
78
- labelOffsetSupport: true
79
- },
80
- activeParameterSupport: true
81
- }
82
- },
83
- diagnostic: {}
84
- }
85
- }
86
- };
87
- info.logger?.log(`Begin listen on connection`);
88
- connection.listen();
89
- info.logger?.log(`Listening now on connection`);
90
- info.logger?.log(`Begin Language Server initialization`);
91
- const initResponse = await connection.sendRequest(InitializeRequest.type, initRequest);
92
- info.logger?.log(`Finished Language Server initialization`);
93
- const documentUri = 'monaco://standalone.document';
94
- const model = editor.getModel();
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
- async function updateDiagnostics() {
110
- const params = {
111
- textDocument: {
112
- uri: documentUri
113
- }
114
- };
115
- const result = await connection.sendRequest(DocumentDiagnosticRequest.type, params);
116
- if (result.kind === 'unchanged') {
117
- return;
118
- }
119
- monaco.editor.setModelMarkers(editor.getModel(), 'lsp', result.items.map(lspToMonacoMarker));
120
- }
121
- updateDiagnostics();
122
- editor.onDidChangeModelContent(async (e) => {
123
- await connection.sendNotification(DidChangeTextDocumentNotification.type, {
124
- textDocument: {
125
- uri: documentUri,
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
- if (!initResponse.capabilities.hoverProvider) {
135
- return;
136
- }
137
- // TODO: registration is global, this will break with multiple editors
138
- monaco.languages.registerHoverProvider(languageId, {
139
- async provideHover(_, position, token) {
140
- const params = {
141
- position: {
142
- line: position.lineNumber - 1,
143
- character: position.column - 1
144
- },
145
- textDocument: {
146
- uri: documentUri
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
- if (!initResponse.capabilities.signatureHelpProvider) {
159
- return;
160
- }
161
- // TODO: registration is global, this will break with multiple editors
162
- monaco.languages.registerSignatureHelpProvider(languageId, {
163
- async provideSignatureHelp(_, position, token, context) {
164
- const params = {
165
- position: {
166
- character: position.column - 1,
167
- line: position.lineNumber - 1
168
- },
169
- textDocument: {
170
- uri: documentUri
171
- },
172
- context: {
173
- isRetrigger: context.isRetrigger,
174
- triggerKind: monacoToLspSignatureHelpTriggerKind(context.triggerKind),
175
- activeSignatureHelp: context.activeSignatureHelp
176
- ? monacoToLspSignatureHelp(context.activeSignatureHelp)
177
- : undefined,
178
- triggerCharacter: context.triggerCharacter
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
- if (!initResponse.capabilities.completionProvider) {
193
- return;
194
- }
195
- // TODO: registration is global, this will break with multiple editors
196
- monaco.languages.registerCompletionItemProvider(languageId, {
197
- triggerCharacters: initResponse.capabilities.completionProvider.triggerCharacters,
198
- async provideCompletionItems(_, position, context, token) {
199
- const params = {
200
- position: {
201
- line: position.lineNumber - 1,
202
- character: position.column - 1
203
- },
204
- textDocument: {
205
- uri: documentUri
206
- },
207
- context: {
208
- triggerKind: monacoToLspCompletionTriggerKind(context.triggerKind),
209
- triggerCharacter: context.triggerCharacter
210
- }
211
- };
212
- const response = await connection.sendRequest(CompletionRequest.type, params, token);
213
- if (response === null) {
214
- return null;
215
- }
216
- const range = new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column);
217
- return Array.isArray(response)
218
- ? {
219
- suggestions: response.map(r => lspToMonacoCompletionItem(r, range)),
220
- incomplete: false
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 };