@kusto/monaco-kusto 8.1.0 → 8.3.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.
Files changed (32) hide show
  1. package/package.json +16 -16
  2. package/release/dev/Kusto.Language.Bridge.min.js +1 -1
  3. package/release/dev/kusto.javascript.client.min.js +1 -1
  4. package/release/dev/kustoMode.js +21 -21
  5. package/release/dev/kustoWorker.js +23 -21
  6. package/release/dev/{main-3a499de0.js → main-e6ef956d.js} +168 -381
  7. package/release/dev/monaco.contribution.js +6 -9
  8. package/release/dev/{schema-c5e21c0d.js → schema-7d65ed04.js} +4 -4
  9. package/release/esm/commandFormatter.js +37 -0
  10. package/release/esm/commandHighlighter.js +52 -0
  11. package/release/esm/extendedEditor.js +41 -0
  12. package/release/esm/kusto.worker.js +2 -2
  13. package/release/esm/kustoMode.js +139 -1158
  14. package/release/esm/kustoWorker.js +252 -0
  15. package/release/esm/languageFeatures.js +1072 -0
  16. package/release/esm/languageService/kustoLanguageService.js +1923 -0
  17. package/release/esm/languageService/kustoMonarchLanguageDefinition.js +211 -0
  18. package/release/esm/languageService/renderInfo.js +1 -0
  19. package/release/esm/languageService/schema.js +64 -0
  20. package/release/esm/languageService/settings.js +1 -0
  21. package/release/esm/monaco.contribution.js +178 -426
  22. package/release/esm/{schema-76f41b43.js → schema-ee621489.js} +1 -2
  23. package/release/esm/types.js +1 -0
  24. package/release/esm/workerManager.js +102 -0
  25. package/release/min/Kusto.Language.Bridge.min.js +1 -1
  26. package/release/min/kusto.javascript.client.min.js +1 -1
  27. package/release/min/kustoMode.js +2 -2
  28. package/release/min/kustoWorker.js +2 -2
  29. package/release/min/main-04a9f035.js +7 -0
  30. package/release/min/monaco.contribution.js +2 -2
  31. package/release/min/{schema-ac23be64.js → schema-095fdf5a.js} +2 -2
  32. package/release/min/main-33264011.js +0 -7
@@ -1,455 +1,207 @@
1
- /*!-----------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 8.1.0(7000174e976f65eb699b0ee78332810263aba5f0)
4
- * Released under the MIT license
5
- * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
- *-----------------------------------------------------------------------------*/
7
-
8
1
  import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
9
- import { g as getCslTypeNameFromClrType, a as getCallName, b as getExpression, c as getInputParametersAsCslString, d as getEntityDataTypeFromCslType } from './schema-76f41b43.js';
10
- export { s as showSchema } from './schema-76f41b43.js';
11
-
12
- function getCurrentCommandRange(editor, cursorPosition) {
13
- const zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
14
- const lines = editor.getModel().getLinesContent();
15
- let commandOrdinal = 0;
16
- const linesWithCommandOrdinal = [];
17
- for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
18
- let isEmptyLine = lines[lineNumber].trim() === '';
19
- if (isEmptyLine) {
20
- // increase commandCounter - we'll be starting a new command.
21
- linesWithCommandOrdinal.push({
22
- commandOrdinal: commandOrdinal++,
23
- lineNumber
24
- });
25
- } else {
26
- linesWithCommandOrdinal.push({
27
- commandOrdinal: commandOrdinal,
28
- lineNumber
29
- });
30
- }
31
-
32
- // No need to keep scanning if we're past our line and we've seen an empty line.
33
- if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
34
- break;
2
+ import KustoCommandHighlighter from './commandHighlighter';
3
+ import KustoCommandFormatter from './commandFormatter';
4
+ import { extend, getCurrentCommandRange } from './extendedEditor';
5
+ import { getCslTypeNameFromClrType, getCallName, getExpression, getInputParametersAsCslString, getEntityDataTypeFromCslType, } from './languageService/schema';
6
+ export * from './languageService/schema';
7
+ export * from './languageService/renderInfo';
8
+ export * from './languageService/settings';
9
+ export * from './types';
10
+ export { getCurrentCommandRange } from './extendedEditor';
11
+ // --- Kusto configuration and defaults ---------
12
+ var LanguageServiceDefaultsImpl = /** @class */ (function () {
13
+ function LanguageServiceDefaultsImpl(languageSettings) {
14
+ this._onDidChange = new monaco.Emitter();
15
+ this.setLanguageSettings(languageSettings);
16
+ // default to never kill worker when idle.
17
+ // reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
18
+ // the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
19
+ // This stems from the fact that web workers have much more limited memory that the main process.
20
+ // An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
21
+ // setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
22
+ this._workerMaxIdleTime = 0;
35
23
  }
36
- }
37
- const currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
38
- const currentCommandLines = linesWithCommandOrdinal.filter(line => line.commandOrdinal === currentCommandOrdinal);
39
- const currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
40
- const currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
41
-
42
- // End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
43
- // Start-column of 1 and End column of 2 means 1st character is selected.
44
- // Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
45
- const commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
46
- return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
47
- }
48
-
49
- /**
50
- * Extending ICode editor to contain additional kusto-specific methods.
51
- * note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
52
- */
53
- function extend(editor) {
54
- const proto = Object.getPrototypeOf(editor);
55
- proto.getCurrentCommandRange = function (cursorPosition) {
56
- getCurrentCommandRange(this, cursorPosition);
57
- };
58
- }
59
-
60
- /**
61
- * Highlights the command that surround cursor location
62
- */
63
- class KustoCommandHighlighter {
64
- static ID = 'editor.contrib.kustoCommandHighlighter';
65
- static CURRENT_COMMAND_HIGHLIGHT = {
66
- className: 'selectionHighlight'
67
- };
68
- disposables = [];
69
- decorations = [];
70
-
71
- /**
72
- * Register to cursor movement and selection events.
73
- * @param editor monaco editor instance
74
- */
75
- constructor(editor) {
76
- this.editor = editor;
77
- // Note that selection update is triggered not only for selection changes, but also just when no text selection is occurring and cursor just moves around.
78
- // This case is counted as a 0-length selection starting and ending on the cursor position.
79
- this.editor.onDidChangeCursorSelection(changeEvent => {
80
- if (this.editor.getModel().getLanguageId() !== 'kusto') {
81
- return;
82
- }
83
- this.highlightCommandUnderCursor(changeEvent);
24
+ Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
25
+ get: function () {
26
+ return this._onDidChange.event;
27
+ },
28
+ enumerable: false,
29
+ configurable: true
84
30
  });
85
- }
86
- getId() {
87
- return KustoCommandHighlighter.ID;
88
- }
89
- dispose() {
90
- this.disposables.forEach(d => d.dispose());
91
- }
92
- highlightCommandUnderCursor(changeEvent) {
93
- // Looks like the user selected a bunch of text. we don't want to highlight the entire command in this case - since highlighting
94
- // the text is more helpful.
95
- if (!changeEvent.selection.isEmpty()) {
96
- this.decorations = this.editor.deltaDecorations(this.decorations, []);
97
- return;
98
- }
99
- const commandRange = getCurrentCommandRange(this.editor, changeEvent.selection.getStartPosition());
100
- const decorations = [{
101
- range: commandRange,
102
- options: KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT
103
- }];
104
- this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
105
- }
106
- }
107
-
108
- class KustoCommandFormatter {
109
- actionAdded = false;
110
- constructor(editor) {
111
- this.editor = editor;
112
- // selection also represents no selection - for example the event gets triggered when moving cursor from point
113
- // a to point b. in the case start position will equal end position.
114
- editor.onDidChangeCursorSelection(changeEvent => {
115
- if (this.editor.getModel().getLanguageId() !== 'kusto') {
116
- return;
117
- }
118
- // Theoretically you would expect this code to run only once in onDidCreateEditor.
119
- // Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is emitted by
120
- // the super ctor before the child ctor was able to fully run).
121
- // Thus we don't have a key binding provided yet when onDidCreateEditor is run, which is essential to call addAction.
122
- // By adding the action here in onDidChangeCursorSelection we're making sure that the editor has a key binding provider,
123
- // and we just need to make sure that this happens only once.
124
- if (!this.actionAdded) {
125
- editor.addAction({
126
- id: 'editor.action.kusto.formatCurrentCommand',
127
- label: 'Format Command Under Cursor',
128
- keybindings: [monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyF)],
129
- run: ed => {
130
- editor.trigger('KustoCommandFormatter', 'editor.action.formatSelection', null);
131
- },
132
- contextMenuGroupId: '1_modification'
133
- });
134
- this.actionAdded = true;
135
- }
31
+ Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageSettings", {
32
+ get: function () {
33
+ return this._languageSettings;
34
+ },
35
+ enumerable: false,
36
+ configurable: true
136
37
  });
137
- }
138
- }
139
-
140
- // --- Kusto configuration and defaults ---------
141
-
142
- class LanguageServiceDefaultsImpl {
143
- _onDidChange = new monaco.Emitter();
144
-
145
- // in milliseconds. For example - this is 2 minutes 2 * 60 * 1000
146
-
147
- constructor(languageSettings) {
148
- this.setLanguageSettings(languageSettings);
149
- // default to never kill worker when idle.
150
- // reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
151
- // the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
152
- // This stems from the fact that web workers have much more limited memory that the main process.
153
- // An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
154
- // setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
155
- this._workerMaxIdleTime = 0;
156
- }
157
- get onDidChange() {
158
- return this._onDidChange.event;
159
- }
160
- get languageSettings() {
161
- return this._languageSettings;
162
- }
163
- setLanguageSettings(options) {
164
- this._languageSettings = options || Object.create(null);
165
- this._onDidChange.fire(this);
166
- }
167
- setMaximumWorkerIdleTime(value) {
168
- // doesn't fire an event since no
169
- // worker restart is required here
170
- this._workerMaxIdleTime = value;
171
- }
172
- getWorkerMaxIdleTime() {
173
- return this._workerMaxIdleTime;
174
- }
175
- }
176
- const defaultLanguageSettings = {
177
- includeControlCommands: true,
178
- newlineAfterPipe: true,
179
- openSuggestionDialogAfterPreviousSuggestionAccepted: true,
180
- useIntellisenseV2: true,
181
- useSemanticColorization: true,
182
- useTokenColorization: false,
183
- enableHover: true,
184
- formatter: {
185
- indentationSize: 4,
186
- pipeOperatorStyle: 'Smart'
187
- },
188
- syntaxErrorAsMarkDown: {
189
- enableSyntaxErrorAsMarkDown: false
190
- },
191
- enableQueryWarnings: false,
192
- enableQuerySuggestions: false,
193
- disabledDiagnosticCodes: [],
194
- quickFixCodeActions: ['Change to', 'FixAll'],
195
- enableQuickFixes: false
38
+ LanguageServiceDefaultsImpl.prototype.setLanguageSettings = function (options) {
39
+ this._languageSettings = options || Object.create(null);
40
+ this._onDidChange.fire(this);
41
+ };
42
+ LanguageServiceDefaultsImpl.prototype.setMaximumWorkerIdleTime = function (value) {
43
+ // doesn't fire an event since no
44
+ // worker restart is required here
45
+ this._workerMaxIdleTime = value;
46
+ };
47
+ LanguageServiceDefaultsImpl.prototype.getWorkerMaxIdleTime = function () {
48
+ return this._workerMaxIdleTime;
49
+ };
50
+ return LanguageServiceDefaultsImpl;
51
+ }());
52
+ var defaultLanguageSettings = {
53
+ includeControlCommands: true,
54
+ newlineAfterPipe: true,
55
+ openSuggestionDialogAfterPreviousSuggestionAccepted: true,
56
+ useIntellisenseV2: true,
57
+ useSemanticColorization: true,
58
+ useTokenColorization: false,
59
+ enableHover: true,
60
+ formatter: {
61
+ indentationSize: 4,
62
+ pipeOperatorStyle: 'Smart',
63
+ },
64
+ syntaxErrorAsMarkDown: {
65
+ enableSyntaxErrorAsMarkDown: false,
66
+ },
67
+ enableQueryWarnings: false,
68
+ enableQuerySuggestions: false,
69
+ disabledDiagnosticCodes: [],
70
+ quickFixCodeActions: ['Change to', 'FixAll'],
71
+ enableQuickFixes: false,
196
72
  };
197
- function getKustoWorker() {
198
- return new Promise((resolve, reject) => {
199
- withMode(mode => {
200
- mode.getKustoWorker().then(resolve, reject);
73
+ export function getKustoWorker() {
74
+ return new Promise(function (resolve, reject) {
75
+ withMode(function (mode) {
76
+ mode.getKustoWorker().then(resolve, reject);
77
+ });
201
78
  });
202
- });
203
79
  }
204
80
  function withMode(callback) {
205
- import('./kustoMode.js').then(callback);
81
+ import('./kustoMode').then(callback);
206
82
  }
207
- const kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
208
- const themeNames = {
209
- light: 'kusto-light',
210
- dark: 'kusto-dark',
211
- dark2: 'kusto-dark2'
83
+ export var kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
84
+ export var themeNames = {
85
+ light: 'kusto-light',
86
+ dark: 'kusto-dark',
87
+ dark2: 'kusto-dark2',
212
88
  };
213
- monaco.languages.onLanguage('kusto', () => {
214
- withMode(mode => mode.setupMode(kustoDefaults, monaco));
89
+ monaco.languages.onLanguage('kusto', function () {
90
+ withMode(function (mode) { return mode.setupMode(kustoDefaults, monaco); });
215
91
  });
216
92
  monaco.languages.register({
217
- id: 'kusto',
218
- extensions: ['.csl', '.kql']
93
+ id: 'kusto',
94
+ extensions: ['.csl', '.kql'],
219
95
  });
220
96
  monaco.editor.defineTheme(themeNames.light, {
221
- base: 'vs',
222
- inherit: true,
223
- rules: [{
224
- token: 'comment',
225
- foreground: '008000'
226
- },
227
- // CommentToken Green
228
- {
229
- token: 'variable.predefined',
230
- foreground: '800080'
231
- },
232
- // CalculatedColumnToken Purple
233
- {
234
- token: 'function',
235
- foreground: '0000FF'
236
- },
237
- // FunctionNameToken Blue
238
- {
239
- token: 'operator.sql',
240
- foreground: 'CC3700'
241
- },
242
- // _WAS_ OperatorToken OrangeRed, but wasn't accessible.
243
- {
244
- token: 'string',
245
- foreground: 'B22222'
246
- },
247
- // StringLiteralToken Firebrick
248
- {
249
- token: 'operator.scss',
250
- foreground: '0000FF'
251
- },
252
- // SubOperatorToken Blue
253
- {
254
- token: 'variable',
255
- foreground: 'C71585'
256
- },
257
- // TableColumnToken MediumVioletRed
258
- {
259
- token: 'variable.parameter',
260
- foreground: '9932CC'
261
- },
262
- // TableToken DarkOrchid
263
- {
264
- token: '',
265
- foreground: '000000'
266
- },
267
- // UnknownToken, PlainTextToken Black
268
- {
269
- token: 'type',
270
- foreground: '0000FF'
271
- },
272
- // DataTypeToken Blue
273
- {
274
- token: 'tag',
275
- foreground: '0000FF'
276
- },
277
- // ControlCommandToken Blue
278
- {
279
- token: 'annotation',
280
- foreground: '2B91AF'
281
- },
282
- // QueryParametersToken FF2B91AF
283
- {
284
- token: 'keyword',
285
- foreground: '0000FF'
286
- },
287
- // CslCommandToken, PluginToken Blue
288
- {
289
- token: 'number',
290
- foreground: '191970'
291
- },
292
- // LetVariablesToken MidnightBlue
293
- {
294
- token: 'annotation',
295
- foreground: '9400D3'
296
- },
297
- // ClientDirectiveToken DarkViolet
298
- {
299
- token: 'invalid',
300
- background: 'cd3131'
301
- }],
302
- colors: {}
97
+ base: 'vs',
98
+ inherit: true,
99
+ rules: [
100
+ { token: 'comment', foreground: '008000' },
101
+ { token: 'variable.predefined', foreground: '800080' },
102
+ { token: 'function', foreground: '0000FF' },
103
+ { token: 'operator.sql', foreground: 'CC3700' },
104
+ { token: 'string', foreground: 'B22222' },
105
+ { token: 'operator.scss', foreground: '0000FF' },
106
+ { token: 'variable', foreground: 'C71585' },
107
+ { token: 'variable.parameter', foreground: '9932CC' },
108
+ { token: '', foreground: '000000' },
109
+ { token: 'type', foreground: '0000FF' },
110
+ { token: 'tag', foreground: '0000FF' },
111
+ { token: 'annotation', foreground: '2B91AF' },
112
+ { token: 'keyword', foreground: '0000FF' },
113
+ { token: 'number', foreground: '191970' },
114
+ { token: 'annotation', foreground: '9400D3' },
115
+ { token: 'invalid', background: 'cd3131' },
116
+ ],
117
+ colors: {},
303
118
  });
304
119
  monaco.editor.defineTheme(themeNames.dark, {
305
- base: 'vs-dark',
306
- inherit: true,
307
- rules: [{
308
- token: 'comment',
309
- foreground: '608B4E'
310
- },
311
- // CommentToken Green
312
- {
313
- token: 'variable.predefined',
314
- foreground: '4ec9b0'
315
- },
316
- // CalculatedColumnToken Purple
317
- {
318
- token: 'function',
319
- foreground: 'dcdcaa'
320
- },
321
- // FunctionNameToken Blue
322
- {
323
- token: 'operator.sql',
324
- foreground: '9cdcfe'
325
- },
326
- // OperatorToken OrangeRed
327
- {
328
- token: 'string',
329
- foreground: 'ce9178'
330
- },
331
- // StringLiteralToken Firebrick
332
- {
333
- token: 'operator.scss',
334
- foreground: '569cd6'
335
- },
336
- // SubOperatorToken Blue
337
- {
338
- token: 'variable',
339
- foreground: '4ec9b0'
340
- },
341
- // TableColumnToken MediumVioletRed
342
- {
343
- token: 'variable.parameter',
344
- foreground: 'c586c0'
345
- },
346
- // TableToken DarkOrchid
347
- {
348
- token: '',
349
- foreground: 'd4d4d4'
350
- },
351
- // UnknownToken, PlainTextToken Black
352
- {
353
- token: 'type',
354
- foreground: '569cd6'
355
- },
356
- // DataTypeToken Blue
357
- {
358
- token: 'tag',
359
- foreground: '569cd6'
360
- },
361
- // ControlCommandToken Blue
362
- {
363
- token: 'annotation',
364
- foreground: '9cdcfe'
365
- },
366
- // QueryParametersToken FF2B91AF
367
- {
368
- token: 'keyword',
369
- foreground: '569cd6'
370
- },
371
- // CslCommandToken, PluginToken Blue
372
- {
373
- token: 'number',
374
- foreground: 'd7ba7d'
375
- },
376
- // LetVariablesToken MidnightBlue
377
- {
378
- token: 'annotation',
379
- foreground: 'b5cea8'
380
- },
381
- // ClientDirectiveToken DarkViolet
382
- {
383
- token: 'invalid',
384
- background: 'cd3131'
385
- }],
386
- colors: {
120
+ base: 'vs-dark',
121
+ inherit: true,
122
+ rules: [
123
+ { token: 'comment', foreground: '608B4E' },
124
+ { token: 'variable.predefined', foreground: '4ec9b0' },
125
+ { token: 'function', foreground: 'dcdcaa' },
126
+ { token: 'operator.sql', foreground: '9cdcfe' },
127
+ { token: 'string', foreground: 'ce9178' },
128
+ { token: 'operator.scss', foreground: '569cd6' },
129
+ { token: 'variable', foreground: '4ec9b0' },
130
+ { token: 'variable.parameter', foreground: 'c586c0' },
131
+ { token: '', foreground: 'd4d4d4' },
132
+ { token: 'type', foreground: '569cd6' },
133
+ { token: 'tag', foreground: '569cd6' },
134
+ { token: 'annotation', foreground: '9cdcfe' },
135
+ { token: 'keyword', foreground: '569cd6' },
136
+ { token: 'number', foreground: 'd7ba7d' },
137
+ { token: 'annotation', foreground: 'b5cea8' },
138
+ { token: 'invalid', background: 'cd3131' },
139
+ ],
140
+ colors: {
387
141
  // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
388
- }
142
+ },
389
143
  });
390
144
  monaco.editor.defineTheme(themeNames.dark2, {
391
- base: 'vs-dark',
392
- inherit: true,
393
- rules: [],
394
- colors: {
395
- // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
396
- 'editor.background': '#1B1A19',
397
- // gray 200
398
- 'editorSuggestWidget.selectedBackground': '#004E8C'
399
- }
145
+ base: 'vs-dark',
146
+ inherit: true,
147
+ rules: [],
148
+ colors: {
149
+ // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
150
+ 'editor.background': '#1B1A19',
151
+ 'editorSuggestWidget.selectedBackground': '#004E8C',
152
+ },
400
153
  });
401
-
402
154
  // Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
403
155
  // Most other language features are initialized in kustoMode.ts
404
- monaco.editor.onDidCreateEditor(editor => {
405
- if (window.MonacoEnvironment?.globalAPI) {
406
- // hook up extension methods to editor.
407
- extend(editor);
408
- }
409
-
410
- // TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution registrar but it's no exposed in the API.
411
- // https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
412
- new KustoCommandHighlighter(editor);
413
- if (isStandaloneCodeEditor(editor)) {
414
- new KustoCommandFormatter(editor);
415
- }
416
- triggerSuggestDialogWhenCompletionItemSelected(editor);
156
+ monaco.editor.onDidCreateEditor(function (editor) {
157
+ var _a;
158
+ if ((_a = window.MonacoEnvironment) === null || _a === void 0 ? void 0 : _a.globalAPI) {
159
+ // hook up extension methods to editor.
160
+ extend(editor);
161
+ }
162
+ // TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution registrar but it's no exposed in the API.
163
+ // https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
164
+ new KustoCommandHighlighter(editor);
165
+ if (isStandaloneCodeEditor(editor)) {
166
+ new KustoCommandFormatter(editor);
167
+ }
168
+ triggerSuggestDialogWhenCompletionItemSelected(editor);
417
169
  });
418
170
  function triggerSuggestDialogWhenCompletionItemSelected(editor) {
419
- editor.onDidChangeCursorSelection(event => {
420
- // checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
421
- if (kustoDefaults && kustoDefaults.languageSettings && kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
422
- var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
423
- // If the word at the current position is not null - meaning we did not add a space after completion.
424
- // In this case we don't want to activate the eager mode, since it will display the current selected word..
425
- if (!didAcceptSuggestion || editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
426
- return;
427
- }
428
- event.selection;
429
- // OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
430
- // the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
431
- // The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
432
- // the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
433
- // the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
434
- // this is the best we have.
435
- setTimeout(() => editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}), 10);
436
- }
437
- });
171
+ editor.onDidChangeCursorSelection(function (event) {
172
+ // checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
173
+ if (kustoDefaults &&
174
+ kustoDefaults.languageSettings &&
175
+ kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
176
+ var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
177
+ // If the word at the current position is not null - meaning we did not add a space after completion.
178
+ // In this case we don't want to activate the eager mode, since it will display the current selected word..
179
+ if (!didAcceptSuggestion || editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
180
+ return;
181
+ }
182
+ event.selection;
183
+ // OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
184
+ // the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
185
+ // The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
186
+ // the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
187
+ // the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
188
+ // this is the best we have.
189
+ setTimeout(function () { return editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}); }, 10);
190
+ }
191
+ });
438
192
  }
439
193
  function isStandaloneCodeEditor(editor) {
440
- return editor.addAction !== undefined;
194
+ return editor.addAction !== undefined;
441
195
  }
442
- const globalApi = {
443
- getCslTypeNameFromClrType,
444
- getCallName,
445
- getExpression,
446
- getInputParametersAsCslString,
447
- getEntityDataTypeFromCslType,
448
- kustoDefaults,
449
- getKustoWorker,
450
- getCurrentCommandRange,
451
- themeNames
196
+ var globalApi = {
197
+ getCslTypeNameFromClrType: getCslTypeNameFromClrType,
198
+ getCallName: getCallName,
199
+ getExpression: getExpression,
200
+ getInputParametersAsCslString: getInputParametersAsCslString,
201
+ getEntityDataTypeFromCslType: getEntityDataTypeFromCslType,
202
+ kustoDefaults: kustoDefaults,
203
+ getKustoWorker: getKustoWorker,
204
+ getCurrentCommandRange: getCurrentCommandRange,
205
+ themeNames: themeNames,
452
206
  };
453
207
  monaco.languages.kusto = globalApi;
454
-
455
- export { getCallName, getCslTypeNameFromClrType, getCurrentCommandRange, getEntityDataTypeFromCslType, getExpression, getInputParametersAsCslString, getKustoWorker, kustoDefaults, themeNames };
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 8.1.0(7000174e976f65eb699b0ee78332810263aba5f0)
3
+ * monaco-kusto version: 8.3.0(b1e36a8cfc8e35c070743997d6e7770ea8081289)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
@@ -80,6 +80,5 @@ const getInputParameterAsCslString = inputParameter => {
80
80
  * .show schema as json
81
81
  */
82
82
  let showSchema;
83
- (function (_showSchema) {})(showSchema || (showSchema = {}));
84
83
 
85
84
  export { getCallName as a, getExpression as b, getInputParametersAsCslString as c, getEntityDataTypeFromCslType as d, getCslTypeNameFromClrType as g, showSchema as s };
@@ -0,0 +1 @@
1
+ export {};