@gooddata/sdk-ui-metric-component 11.65.0-alpha.8 → 11.65.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/NOTICE +622 -2311
- package/esm/MaqlEditor/maql/formatter.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/formatter.js +1 -1
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.js +1 -1
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/useDecoration.js +1 -1
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/useHover.js +1 -1
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/useValidation.js +1 -1
- package/esm/MaqlEditor/maql/monacoConverter.d.ts +80 -0
- package/esm/MaqlEditor/maql/monacoConverter.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/monacoConverter.js +528 -0
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts +41 -0
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts.map +1 -1
- package/esm/MaqlEditor/monaco/monacoWorkers.js +143 -30
- package/esm/translations/es-ES.json +7 -7
- package/esm/translations/fr-FR.json +30 -30
- package/package.json +23 -21
- package/worker/monaco-editor-worker.js +30 -0
- package/worker/monaco-editor-worker.source.js +1 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { Command, CompletionItemKind, CompletionItemLabelDetails, InsertReplaceEdit, InsertTextFormat, MarkupContent, MarkupKind, Range, } from "vscode-languageserver-types";
|
|
3
|
+
function isProtocolCompletionItem(item) {
|
|
4
|
+
return typeof item === "object" && item !== null && "data" in item;
|
|
5
|
+
}
|
|
6
|
+
function isRangeReplace(value) {
|
|
7
|
+
return value.insert !== undefined;
|
|
8
|
+
}
|
|
9
|
+
function isString(value) {
|
|
10
|
+
return typeof value === "string" || value instanceof String;
|
|
11
|
+
}
|
|
12
|
+
function isNumber(value) {
|
|
13
|
+
return typeof value === "number" || value instanceof Number;
|
|
14
|
+
}
|
|
15
|
+
function isStringArray(value) {
|
|
16
|
+
return Array.isArray(value) && value.every(isString);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts Monaco editor structures to the language server protocol ones.
|
|
20
|
+
*/
|
|
21
|
+
export class MonacoToProtocolConverter {
|
|
22
|
+
_monaco;
|
|
23
|
+
constructor(_monaco) {
|
|
24
|
+
this._monaco = _monaco;
|
|
25
|
+
}
|
|
26
|
+
asPosition(lineNumber, column) {
|
|
27
|
+
const line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1;
|
|
28
|
+
const character = column === undefined || column === null ? undefined : column - 1;
|
|
29
|
+
return { line, character };
|
|
30
|
+
}
|
|
31
|
+
asRange(range) {
|
|
32
|
+
if (range === undefined) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (range === null) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (isRangeReplace(range)) {
|
|
39
|
+
return this.asRange(range.insert);
|
|
40
|
+
}
|
|
41
|
+
const start = this.asPosition(range.startLineNumber, range.startColumn);
|
|
42
|
+
const end = this.asPosition(range.endLineNumber, range.endColumn);
|
|
43
|
+
return { start, end };
|
|
44
|
+
}
|
|
45
|
+
asCompletionItem(item) {
|
|
46
|
+
const result = { label: item.label };
|
|
47
|
+
const protocolItem = isProtocolCompletionItem(item) ? item : undefined;
|
|
48
|
+
if (item.detail) {
|
|
49
|
+
result.detail = item.detail;
|
|
50
|
+
}
|
|
51
|
+
if (item.documentation) {
|
|
52
|
+
if (typeof item.documentation === "string") {
|
|
53
|
+
result.documentation = item.documentation;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
result.documentation = this.asDocumentation(protocolItem?.documentationFormat ?? MarkupKind.Markdown, item.documentation);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (item.filterText) {
|
|
60
|
+
result.filterText = item.filterText;
|
|
61
|
+
}
|
|
62
|
+
this.fillPrimaryInsertText(result, item);
|
|
63
|
+
if (isNumber(item.kind)) {
|
|
64
|
+
result.kind = this.asCompletionItemKind(item.kind, protocolItem?.originalItemKind);
|
|
65
|
+
}
|
|
66
|
+
if (item.sortText) {
|
|
67
|
+
result.sortText = item.sortText;
|
|
68
|
+
}
|
|
69
|
+
if (item.additionalTextEdits) {
|
|
70
|
+
result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
|
|
71
|
+
}
|
|
72
|
+
if (item.commitCharacters) {
|
|
73
|
+
result.commitCharacters = item.commitCharacters.slice();
|
|
74
|
+
}
|
|
75
|
+
if (item.command) {
|
|
76
|
+
result.command = this.asCommand(item.command);
|
|
77
|
+
}
|
|
78
|
+
if (item.preselect === true || item.preselect === false) {
|
|
79
|
+
result.preselect = item.preselect;
|
|
80
|
+
}
|
|
81
|
+
if (protocolItem) {
|
|
82
|
+
if (protocolItem.data !== undefined) {
|
|
83
|
+
result.data = protocolItem.data;
|
|
84
|
+
}
|
|
85
|
+
if (protocolItem.deprecated === true || protocolItem.deprecated === false) {
|
|
86
|
+
result.deprecated = protocolItem.deprecated;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (item.tags) {
|
|
90
|
+
result.tags = item.tags.slice();
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
asFormattingOptions(options) {
|
|
95
|
+
return { tabSize: options.tabSize, insertSpaces: options.insertSpaces };
|
|
96
|
+
}
|
|
97
|
+
asTextEdit(edit) {
|
|
98
|
+
return {
|
|
99
|
+
range: this.asRange(edit.range),
|
|
100
|
+
newText: edit.text || "",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
asTextEdits(items) {
|
|
104
|
+
if (!items) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
return items.map((item) => this.asTextEdit(item));
|
|
108
|
+
}
|
|
109
|
+
asCommand(item) {
|
|
110
|
+
if (item) {
|
|
111
|
+
const args = item.arguments || [];
|
|
112
|
+
return Command.create(item.title, item.id, ...args);
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
asCompletionItemKind(value, original) {
|
|
117
|
+
if (original !== undefined) {
|
|
118
|
+
return original;
|
|
119
|
+
}
|
|
120
|
+
const kinds = this._monaco.languages.CompletionItemKind;
|
|
121
|
+
switch (value) {
|
|
122
|
+
case kinds.Method:
|
|
123
|
+
return CompletionItemKind.Method;
|
|
124
|
+
case kinds.Function:
|
|
125
|
+
return CompletionItemKind.Function;
|
|
126
|
+
case kinds.Constructor:
|
|
127
|
+
return CompletionItemKind.Constructor;
|
|
128
|
+
case kinds.Field:
|
|
129
|
+
return CompletionItemKind.Field;
|
|
130
|
+
case kinds.Variable:
|
|
131
|
+
return CompletionItemKind.Variable;
|
|
132
|
+
case kinds.Class:
|
|
133
|
+
return CompletionItemKind.Class;
|
|
134
|
+
case kinds.Struct:
|
|
135
|
+
return CompletionItemKind.Struct;
|
|
136
|
+
case kinds.Interface:
|
|
137
|
+
return CompletionItemKind.Interface;
|
|
138
|
+
case kinds.Module:
|
|
139
|
+
return CompletionItemKind.Module;
|
|
140
|
+
case kinds.Property:
|
|
141
|
+
return CompletionItemKind.Property;
|
|
142
|
+
case kinds.Event:
|
|
143
|
+
return CompletionItemKind.Event;
|
|
144
|
+
case kinds.Operator:
|
|
145
|
+
return CompletionItemKind.Operator;
|
|
146
|
+
case kinds.Unit:
|
|
147
|
+
return CompletionItemKind.Unit;
|
|
148
|
+
case kinds.Value:
|
|
149
|
+
return CompletionItemKind.Value;
|
|
150
|
+
case kinds.Constant:
|
|
151
|
+
return CompletionItemKind.Constant;
|
|
152
|
+
case kinds.Enum:
|
|
153
|
+
return CompletionItemKind.Enum;
|
|
154
|
+
case kinds.EnumMember:
|
|
155
|
+
return CompletionItemKind.EnumMember;
|
|
156
|
+
case kinds.Keyword:
|
|
157
|
+
return CompletionItemKind.Keyword;
|
|
158
|
+
case kinds.Text:
|
|
159
|
+
return CompletionItemKind.Text;
|
|
160
|
+
case kinds.Color:
|
|
161
|
+
return CompletionItemKind.Color;
|
|
162
|
+
case kinds.File:
|
|
163
|
+
return CompletionItemKind.File;
|
|
164
|
+
case kinds.Reference:
|
|
165
|
+
return CompletionItemKind.Reference;
|
|
166
|
+
case kinds.Customcolor:
|
|
167
|
+
return CompletionItemKind.Color;
|
|
168
|
+
case kinds.Folder:
|
|
169
|
+
return CompletionItemKind.Folder;
|
|
170
|
+
case kinds.TypeParameter:
|
|
171
|
+
return CompletionItemKind.TypeParameter;
|
|
172
|
+
case kinds.Snippet:
|
|
173
|
+
return CompletionItemKind.Snippet;
|
|
174
|
+
default:
|
|
175
|
+
return (value + 1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
asDocumentation(format, documentation) {
|
|
179
|
+
switch (format) {
|
|
180
|
+
case MarkupKind.PlainText:
|
|
181
|
+
return { kind: format, value: documentation };
|
|
182
|
+
case MarkupKind.Markdown:
|
|
183
|
+
return { kind: format, value: documentation.value };
|
|
184
|
+
default:
|
|
185
|
+
return `Unsupported Markup content received. Kind is: ${format}`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
fillPrimaryInsertText(target, source) {
|
|
189
|
+
// insertTextRules is a bit set; the snippet flag is tested with a bitmask, as upstream does.
|
|
190
|
+
const snippetRule = this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
191
|
+
const hasSnippetRule = source.insertTextRules !== undefined && (source.insertTextRules & snippetRule) !== 0;
|
|
192
|
+
const format = source.insertTextRules !== undefined && !hasSnippetRule
|
|
193
|
+
? InsertTextFormat.Snippet
|
|
194
|
+
: InsertTextFormat.PlainText;
|
|
195
|
+
target.insertTextFormat = format;
|
|
196
|
+
const text = source.insertText;
|
|
197
|
+
const range = source.range ? this.asRange(source.range) : undefined;
|
|
198
|
+
if (source.fromEdit && text && range) {
|
|
199
|
+
target.textEdit = { newText: text, range };
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
target.insertText = text;
|
|
203
|
+
}
|
|
204
|
+
target.insertTextMode = source.insertTextMode;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Converts language server protocol structures to the Monaco editor ones.
|
|
209
|
+
*/
|
|
210
|
+
export class ProtocolToMonacoConverter {
|
|
211
|
+
_monaco;
|
|
212
|
+
constructor(_monaco) {
|
|
213
|
+
this._monaco = _monaco;
|
|
214
|
+
}
|
|
215
|
+
asTextEdit(edit) {
|
|
216
|
+
return {
|
|
217
|
+
range: this.asRange(edit.range),
|
|
218
|
+
text: edit.newText,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
asTextEdits(items) {
|
|
222
|
+
if (!items) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
return items.map((item) => this.asTextEdit(item));
|
|
226
|
+
}
|
|
227
|
+
asCommand(command) {
|
|
228
|
+
if (!command) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
id: command.command,
|
|
233
|
+
title: command.title,
|
|
234
|
+
arguments: command.arguments,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
asHover(hover) {
|
|
238
|
+
if (!hover) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
contents: this.asHoverContent(hover.contents),
|
|
243
|
+
range: this.asRange(hover.range),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
asHoverContent(contents) {
|
|
247
|
+
if (Array.isArray(contents)) {
|
|
248
|
+
return contents.map((content) => this.asMarkdownString(content));
|
|
249
|
+
}
|
|
250
|
+
return [this.asMarkdownString(contents)];
|
|
251
|
+
}
|
|
252
|
+
asDocumentation(value) {
|
|
253
|
+
if (isString(value)) {
|
|
254
|
+
return value;
|
|
255
|
+
}
|
|
256
|
+
if (value.kind === MarkupKind.PlainText) {
|
|
257
|
+
return value.value;
|
|
258
|
+
}
|
|
259
|
+
return this.asMarkdownString(value);
|
|
260
|
+
}
|
|
261
|
+
asMarkdownString(content) {
|
|
262
|
+
if (MarkupContent.is(content)) {
|
|
263
|
+
return { value: content.value };
|
|
264
|
+
}
|
|
265
|
+
if (isString(content)) {
|
|
266
|
+
return { value: content };
|
|
267
|
+
}
|
|
268
|
+
const { language, value } = content;
|
|
269
|
+
return { value: "```" + language + "\n" + value + "\n```" };
|
|
270
|
+
}
|
|
271
|
+
asSeverity(severity) {
|
|
272
|
+
if (severity === 1) {
|
|
273
|
+
return this._monaco.MarkerSeverity.Error;
|
|
274
|
+
}
|
|
275
|
+
if (severity === 2) {
|
|
276
|
+
return this._monaco.MarkerSeverity.Warning;
|
|
277
|
+
}
|
|
278
|
+
if (severity === 3) {
|
|
279
|
+
return this._monaco.MarkerSeverity.Info;
|
|
280
|
+
}
|
|
281
|
+
return this._monaco.MarkerSeverity.Hint;
|
|
282
|
+
}
|
|
283
|
+
asDiagnostics(diagnostics) {
|
|
284
|
+
if (!diagnostics) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return diagnostics.map((diagnostic) => this.asDiagnostic(diagnostic));
|
|
288
|
+
}
|
|
289
|
+
asDiagnostic(diagnostic) {
|
|
290
|
+
return {
|
|
291
|
+
code: typeof diagnostic.code === "number" ? diagnostic.code.toString() : diagnostic.code,
|
|
292
|
+
severity: this.asSeverity(diagnostic.severity),
|
|
293
|
+
message: diagnostic.message,
|
|
294
|
+
source: diagnostic.source,
|
|
295
|
+
startLineNumber: diagnostic.range.start.line + 1,
|
|
296
|
+
startColumn: diagnostic.range.start.character + 1,
|
|
297
|
+
endLineNumber: diagnostic.range.end.line + 1,
|
|
298
|
+
endColumn: diagnostic.range.end.character + 1,
|
|
299
|
+
relatedInformation: this.asRelatedInformations(diagnostic.relatedInformation),
|
|
300
|
+
tags: diagnostic.tags,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
asRelatedInformations(relatedInformation) {
|
|
304
|
+
if (!relatedInformation) {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
return relatedInformation.map((item) => this.asRelatedInformation(item));
|
|
308
|
+
}
|
|
309
|
+
asRelatedInformation(relatedInformation) {
|
|
310
|
+
return {
|
|
311
|
+
resource: this._monaco.Uri.parse(relatedInformation.location.uri),
|
|
312
|
+
startLineNumber: relatedInformation.location.range.start.line + 1,
|
|
313
|
+
startColumn: relatedInformation.location.range.start.character + 1,
|
|
314
|
+
endLineNumber: relatedInformation.location.range.end.line + 1,
|
|
315
|
+
endColumn: relatedInformation.location.range.end.character + 1,
|
|
316
|
+
message: relatedInformation.message,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
asCompletionResult(result, defaultMonacoRange) {
|
|
320
|
+
if (!result) {
|
|
321
|
+
return { incomplete: false, suggestions: [] };
|
|
322
|
+
}
|
|
323
|
+
if (Array.isArray(result)) {
|
|
324
|
+
return {
|
|
325
|
+
incomplete: false,
|
|
326
|
+
suggestions: result.map((item) => this.asCompletionItem(item, defaultMonacoRange)),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const defaultRange = this.getCompletionItemDefaultRange(result);
|
|
330
|
+
return {
|
|
331
|
+
incomplete: result.isIncomplete,
|
|
332
|
+
suggestions: result.items.map((item) => this.asCompletionItem(item, defaultMonacoRange, defaultRange, result.itemDefaults)),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
asCompletionItem(item, defaultMonacoRange, defaultRange, itemDefaults) {
|
|
336
|
+
const result = { label: this.asCompletionItemLabel(item) };
|
|
337
|
+
if (item.detail) {
|
|
338
|
+
result.detail = item.detail;
|
|
339
|
+
}
|
|
340
|
+
if (item.documentation) {
|
|
341
|
+
result.documentation = this.asDocumentation(item.documentation);
|
|
342
|
+
result.documentationFormat = isString(item.documentation) ? undefined : item.documentation.kind;
|
|
343
|
+
}
|
|
344
|
+
if (item.filterText) {
|
|
345
|
+
result.filterText = item.filterText;
|
|
346
|
+
}
|
|
347
|
+
const insertText = this.asCompletionInsertText(item, defaultRange, itemDefaults?.insertTextFormat);
|
|
348
|
+
result.insertText = insertText.insertText;
|
|
349
|
+
result.range = insertText.range ?? defaultMonacoRange;
|
|
350
|
+
result.fromEdit = insertText.fromEdit;
|
|
351
|
+
if (insertText.isSnippet) {
|
|
352
|
+
result.insertTextRules = this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
353
|
+
}
|
|
354
|
+
if (isNumber(item.kind)) {
|
|
355
|
+
const [itemKind, original] = this.asCompletionItemKind(item.kind);
|
|
356
|
+
result.kind = itemKind;
|
|
357
|
+
if (original) {
|
|
358
|
+
result.originalItemKind = original;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (item.sortText) {
|
|
362
|
+
result.sortText = item.sortText;
|
|
363
|
+
}
|
|
364
|
+
if (item.additionalTextEdits) {
|
|
365
|
+
result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
|
|
366
|
+
}
|
|
367
|
+
if (isStringArray(item.commitCharacters)) {
|
|
368
|
+
result.commitCharacters = item.commitCharacters.slice();
|
|
369
|
+
}
|
|
370
|
+
if (item.command) {
|
|
371
|
+
result.command = this.asCommand(item.command);
|
|
372
|
+
}
|
|
373
|
+
if (item.deprecated === true || item.deprecated === false) {
|
|
374
|
+
result.deprecated = item.deprecated;
|
|
375
|
+
}
|
|
376
|
+
if (item.preselect === true || item.preselect === false) {
|
|
377
|
+
result.preselect = item.preselect;
|
|
378
|
+
}
|
|
379
|
+
const data = item.data ?? itemDefaults?.data;
|
|
380
|
+
if (data !== undefined) {
|
|
381
|
+
result.data = data;
|
|
382
|
+
}
|
|
383
|
+
const insertTextMode = item.insertTextMode ?? itemDefaults?.insertTextMode;
|
|
384
|
+
if (insertTextMode) {
|
|
385
|
+
result.insertTextMode = insertTextMode;
|
|
386
|
+
}
|
|
387
|
+
if (item.tags) {
|
|
388
|
+
result.tags = item.tags;
|
|
389
|
+
}
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
getCompletionItemDefaultRange(list) {
|
|
393
|
+
const rangeDefaults = list.itemDefaults?.editRange;
|
|
394
|
+
if (Range.is(rangeDefaults)) {
|
|
395
|
+
return this.asRange(rangeDefaults);
|
|
396
|
+
}
|
|
397
|
+
return rangeDefaults === undefined
|
|
398
|
+
? undefined
|
|
399
|
+
: { insert: this.asRange(rangeDefaults.insert), replace: this.asRange(rangeDefaults.replace) };
|
|
400
|
+
}
|
|
401
|
+
asCompletionItemLabel(item) {
|
|
402
|
+
if (CompletionItemLabelDetails.is(item.labelDetails)) {
|
|
403
|
+
return {
|
|
404
|
+
label: item.label,
|
|
405
|
+
detail: item.labelDetails.detail,
|
|
406
|
+
description: item.labelDetails.description,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
return item.label;
|
|
410
|
+
}
|
|
411
|
+
asCompletionItemKind(value) {
|
|
412
|
+
const kinds = this._monaco.languages.CompletionItemKind;
|
|
413
|
+
if (CompletionItemKind.Text <= value && value <= CompletionItemKind.TypeParameter) {
|
|
414
|
+
switch (value) {
|
|
415
|
+
case CompletionItemKind.Text:
|
|
416
|
+
return [kinds.Text, undefined];
|
|
417
|
+
case CompletionItemKind.Method:
|
|
418
|
+
return [kinds.Method, undefined];
|
|
419
|
+
case CompletionItemKind.Function:
|
|
420
|
+
return [kinds.Function, undefined];
|
|
421
|
+
case CompletionItemKind.Constructor:
|
|
422
|
+
return [kinds.Constructor, undefined];
|
|
423
|
+
case CompletionItemKind.Field:
|
|
424
|
+
return [kinds.Field, undefined];
|
|
425
|
+
case CompletionItemKind.Variable:
|
|
426
|
+
return [kinds.Variable, undefined];
|
|
427
|
+
case CompletionItemKind.Class:
|
|
428
|
+
return [kinds.Class, undefined];
|
|
429
|
+
case CompletionItemKind.Interface:
|
|
430
|
+
return [kinds.Interface, undefined];
|
|
431
|
+
case CompletionItemKind.Module:
|
|
432
|
+
return [kinds.Module, undefined];
|
|
433
|
+
case CompletionItemKind.Property:
|
|
434
|
+
return [kinds.Property, undefined];
|
|
435
|
+
case CompletionItemKind.Unit:
|
|
436
|
+
return [kinds.Unit, undefined];
|
|
437
|
+
case CompletionItemKind.Value:
|
|
438
|
+
return [kinds.Value, undefined];
|
|
439
|
+
case CompletionItemKind.Enum:
|
|
440
|
+
return [kinds.Enum, undefined];
|
|
441
|
+
case CompletionItemKind.Keyword:
|
|
442
|
+
return [kinds.Keyword, undefined];
|
|
443
|
+
case CompletionItemKind.Snippet:
|
|
444
|
+
return [kinds.Snippet, undefined];
|
|
445
|
+
case CompletionItemKind.Color:
|
|
446
|
+
return [kinds.Color, undefined];
|
|
447
|
+
case CompletionItemKind.File:
|
|
448
|
+
return [kinds.File, undefined];
|
|
449
|
+
case CompletionItemKind.Reference:
|
|
450
|
+
return [kinds.Reference, undefined];
|
|
451
|
+
case CompletionItemKind.Folder:
|
|
452
|
+
return [kinds.Folder, undefined];
|
|
453
|
+
case CompletionItemKind.EnumMember:
|
|
454
|
+
return [kinds.EnumMember, undefined];
|
|
455
|
+
case CompletionItemKind.Constant:
|
|
456
|
+
return [kinds.Constant, undefined];
|
|
457
|
+
case CompletionItemKind.Struct:
|
|
458
|
+
return [kinds.Struct, undefined];
|
|
459
|
+
case CompletionItemKind.Event:
|
|
460
|
+
return [kinds.Event, undefined];
|
|
461
|
+
case CompletionItemKind.Operator:
|
|
462
|
+
return [kinds.Operator, undefined];
|
|
463
|
+
case CompletionItemKind.TypeParameter:
|
|
464
|
+
return [kinds.TypeParameter, undefined];
|
|
465
|
+
default:
|
|
466
|
+
return [value - 1, undefined];
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return [CompletionItemKind.Text, value];
|
|
470
|
+
}
|
|
471
|
+
asCompletionInsertText(item, defaultRange, defaultInsertTextFormat) {
|
|
472
|
+
const insertTextFormat = item.insertTextFormat ?? defaultInsertTextFormat;
|
|
473
|
+
const isSnippet = insertTextFormat === InsertTextFormat.Snippet;
|
|
474
|
+
if (item.textEdit !== undefined || defaultRange !== undefined) {
|
|
475
|
+
const [range, newText] = item.textEdit === undefined
|
|
476
|
+
? [defaultRange, item.textEditText ?? item.label]
|
|
477
|
+
: this.getCompletionRangeAndText(item.textEdit);
|
|
478
|
+
return { insertText: newText, range, fromEdit: true, isSnippet };
|
|
479
|
+
}
|
|
480
|
+
if (item.insertText) {
|
|
481
|
+
return { isSnippet, insertText: item.insertText, fromEdit: false, range: defaultRange };
|
|
482
|
+
}
|
|
483
|
+
return { insertText: item.label, range: defaultRange, fromEdit: false, isSnippet: false };
|
|
484
|
+
}
|
|
485
|
+
getCompletionRangeAndText(value) {
|
|
486
|
+
if (InsertReplaceEdit.is(value)) {
|
|
487
|
+
return [
|
|
488
|
+
{ insert: this.asRange(value.insert), replace: this.asRange(value.replace) },
|
|
489
|
+
value.newText,
|
|
490
|
+
];
|
|
491
|
+
}
|
|
492
|
+
return [this.asRange(value.range), value.newText];
|
|
493
|
+
}
|
|
494
|
+
asRange(range) {
|
|
495
|
+
if (range === undefined) {
|
|
496
|
+
return undefined;
|
|
497
|
+
}
|
|
498
|
+
if (range === null) {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
const start = this.asPosition(range.start);
|
|
502
|
+
const end = this.asPosition(range.end);
|
|
503
|
+
if (start instanceof this._monaco.Position && end instanceof this._monaco.Position) {
|
|
504
|
+
return new this._monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
startLineNumber: start?.lineNumber,
|
|
508
|
+
startColumn: start?.column,
|
|
509
|
+
endLineNumber: end?.lineNumber,
|
|
510
|
+
endColumn: end?.column,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
asPosition(position) {
|
|
514
|
+
if (position === undefined) {
|
|
515
|
+
return undefined;
|
|
516
|
+
}
|
|
517
|
+
if (position === null) {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
const { line, character } = position;
|
|
521
|
+
const lineNumber = line === undefined ? undefined : line + 1;
|
|
522
|
+
const column = character === undefined ? undefined : character + 1;
|
|
523
|
+
if (lineNumber !== undefined && column !== undefined) {
|
|
524
|
+
return new this._monaco.Position(lineNumber, column);
|
|
525
|
+
}
|
|
526
|
+
return { lineNumber, column };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL of the self-contained editor worker file that this package ships, relative to this module.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The relative path is the same from `src/MaqlEditor/monaco/` and from `esm/MaqlEditor/monaco/`, so
|
|
6
|
+
* it also holds when a dev server serves this package from its sources. webpack and Vite recognise
|
|
7
|
+
* the `new URL("...", import.meta.url)` pattern and emit the file as an asset. A pre-bundled
|
|
8
|
+
* dependency, other bundlers and a Module Federation remote on another origin leave a URL that does
|
|
9
|
+
* not exist or that the page cannot start a worker from. The URL must therefore be checked before
|
|
10
|
+
* the worker starts, see {@link resolveEditorWorkerUrl}.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function getBundledEditorWorkerUrl(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the URL the editor worker starts from: the bundled worker file when the bundler emitted
|
|
17
|
+
* it next to the page, the inline worker otherwise.
|
|
18
|
+
*
|
|
19
|
+
* @param assetUrl - URL of the bundled worker file, defaults to {@link getBundledEditorWorkerUrl}
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveEditorWorkerUrl(assetUrl?: string): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Name of the Trusted Types policy that turns the worker URL into a `TrustedScriptURL`. A page whose
|
|
25
|
+
* content security policy lists the allowed policy names must allow this one.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare const EDITOR_WORKER_TRUSTED_TYPES_POLICY = "gdMetricEditorWorker";
|
|
30
|
+
/**
|
|
31
|
+
* Creates the `MonacoEnvironment.getWorker` that starts the bundled editor worker.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* The worker URL and the Trusted Types policy are created once and shared by all workers, which is why
|
|
35
|
+
* the cache lives in the created function: tests create their own, the runtime uses one. A failed
|
|
36
|
+
* resolution is not cached, so the next worker tries again.
|
|
37
|
+
*
|
|
38
|
+
* @param resolveWorkerUrl - resolves the URL of the worker this package ships
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function createEditorWorkerFactory(resolveWorkerUrl?: () => Promise<string>): (workerId: string, label: string) => Promise<Worker>;
|
|
1
42
|
/**
|
|
2
43
|
* Point Monaco at the bundled `editorWorkerService` worker.
|
|
3
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monacoWorkers.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/monaco/monacoWorkers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monacoWorkers.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/monaco/monacoWorkers.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAiED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,GAAE,MAAoC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAEjB;AAKD;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AA2BzE;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACrC,gBAAgB,GAAE,MAAM,OAAO,CAAC,MAAM,CAA0B,GACjE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAetD;AAID;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CASzC"}
|