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