@kusto/monaco-kusto 6.1.2 → 7.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.
package/README.md CHANGED
@@ -23,21 +23,27 @@ Kusto language plugin for the Monaco Editor. It provides the following features
23
23
 
24
24
  ### AMD module system:
25
25
 
26
- Example at ![https://github.com/Azure/monaco-kusto/tree/master/samples/amd]()
27
-
28
- 1. Run `npm run copyMonacoFilesAMD <path>` or `yarn copyMonacoFilesAMD <path>` where <path> is where you want the monaco and kusto amd modules to be. These files will need to be served as-in.
29
- 2. Using a amd module loader, import `vs/language/kusto/monaco.contribution`
30
- 1. The monaco editors included loader can be made available via a global require `require` by adding the script tag: `<script src="<path>/vs/loader.js"></script>`
31
- 3. You should now be able to create monaco editors with `language: 'kusto'`. The kusto worker can be reached via the monaco global: `monaco.languages.kusto.getKustoWorker()`
26
+ Example at [/samples/amd](https://github.com/Azure/monaco-kusto/tree/master/samples/amd)
27
+
28
+ 1. Run `npm run copyMonacoFilesAMD <path>` or `yarn copyMonacoFilesAMD <path>`
29
+ where <path> is where you want the monaco and kusto amd modules to be. These
30
+ files will need to be served as-in.
31
+ 2. Using a amd module loader, import `vs/language/kusto/monaco.contribution` 1. The monaco editors included loader can be made available via a global
32
+ require `require` by adding the script tag: `<script src="<path>/vs/loader.js"></script>`
33
+ 3. You should now be able to create monaco editors with `language: 'kusto'`. The
34
+ kusto worker can be reached via the monaco global:
35
+ `monaco.languages.kusto.getKustoWorker()`
36
+ 4. If using typeScript, add "@kusto/monaco-kusto/globalApi" to compilerOptions.types in tsconfig.json`
32
37
 
33
38
  ### ESM
34
39
 
35
- Parcel example at ![https://github.com/Azure/monaco-kusto/tree/master/samples/parcel]()
40
+ Parcel example at [/samples/parcel](https://github.com/Azure/monaco-kusto/tree/master/samples/parcel)
36
41
 
37
42
  1. Configure your bundler so `@kusto/monaco-kusto/release/esm/kusto.worker` has it's own entry point
38
- 2. Configure monaco with that entry point and to use `globalAPI` using the `MonacoEnvironment`. This global needs to be set _before_ the monaco editor source is parsed so it will create a global api for this package to use.
39
- 1. And example of steps 1 & 2 can be seen here: [./samples/parcel/index.html](). This was added to the html file to prevent parcel from including the monaco javascript above it
40
- 3. You should now be able to create monaco editors with `language: 'kusto'`. The kusto worker can be reached via the monaco global: `monaco.languages.kusto.getKustoWorker()`
43
+ 2. Configure the global `MonacoEnvironment` with either `getWorkerUrl` or `getWorker`
44
+ 3. You should now be able to create monaco editors with `language: 'kusto'`. The
45
+ kusto worker can be reached via the monaco global:
46
+ `monaco.languages.kusto.getKustoWorker()`
41
47
 
42
48
  ### Setting a schema
43
49
 
@@ -45,9 +51,10 @@ There are 2 APIs to set a Kusto schema:
45
51
 
46
52
  1. `setSchema` - the passed schema is of type `ClusterType` (defined in `schema.ts`).
47
53
  The database in ROOT.database will be the one in context.
48
- 2. `setSchemaFromShowSchema` - a method to set a schema from the result of the Kusto query `.show schema as json`.
49
- The result is a list of databases (see interface `Result` in `schema.ts`), so when this method is used,
50
- it also requires a cluster URI and the name of the database in context.
54
+ 2. `setSchemaFromShowSchema` - a method to set a schema from the result of the
55
+ Kusto query `.show schema as json`. The result is a list of databases (see
56
+ interface `Result` in `schema.ts`), so when this method is used, it also
57
+ requires a cluster URI and the name of the database in context.
51
58
 
52
59
  ## Contributing
53
60
 
@@ -65,6 +72,25 @@ There are 2 APIs to set a Kusto schema:
65
72
 
66
73
  ## Changelog
67
74
 
75
+ ### 7.0.0
76
+
77
+ - BREAKING CHANGE: Bumped monaco-editor peer dependency to ~0.37.0
78
+ - This version of monaco-editor no longer requires a patch to work with Parcel. Details here: https://github.com/microsoft/monaco-editor/issues/2966
79
+ - fix: "monaco is not defined" errors when consuming esm files
80
+ - Moved types from global interface (`monaco.languages.kusto.*`) to esm index
81
+ file `import { SomeType } from '@kusto/monaco-kusto`. With this, esm
82
+ consumer no longer need to include
83
+ `@kusto/monaco-kusto/release/monaco.d.ts`.
84
+ - ESM output no longer requires `MonacoEnvironment.globalApi` to be `true`
85
+ - Moved `@kusto/monaco-kusto/release/monaco.d.ts` content to
86
+ `@kusto/monaco-kusto/globalApi.d.ts`. Original file now references this new
87
+ one, and will be removed in a future release.
88
+
89
+ ### 6.2.0
90
+
91
+ - Esm output not longer requires `self.MonacoEnvironment` to be true
92
+ - `@kusto/monaco-kusto` no exports the same api as `monaco.languages.kusto`
93
+
68
94
  ### 6.0.0
69
95
 
70
96
  - Improved quality of AMD build artifacts
package/globalApi.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ // Augments monaco global types with Kusto api. Should be imported if you're using amd modules, or if you've set `MonacoEnvironment.globalApi` to true.
2
+
3
+ /// <reference types="monaco-editor/monaco" />
4
+
5
+ declare namespace monaco.editor {
6
+ export interface ICodeEditor {
7
+ getCurrentCommandRange(cursorPosition: monaco.Position): monaco.Range;
8
+ }
9
+ }
10
+
11
+ declare namespace monaco.languages {
12
+ export const kusto: typeof import('@kusto/monaco-kusto');
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kusto/monaco-kusto",
3
- "version": "6.1.2",
3
+ "version": "7.0.0",
4
4
  "description": "CSL, KQL plugin for the Monaco Editor",
5
5
  "author": {
6
6
  "name": "Microsoft"
@@ -28,7 +28,8 @@
28
28
  "files": [
29
29
  "release",
30
30
  "README.md",
31
- "copyMonacoFilesAMD"
31
+ "copyMonacoFilesAMD",
32
+ "globalApi.d.ts"
32
33
  ],
33
34
  "bin": {
34
35
  "copyMonacoFilesAMD": "./copyMonacoFilesAMD.js"
@@ -53,13 +54,13 @@
53
54
  "concurrently": "^7.6.0",
54
55
  "http-server": "^0.12.3",
55
56
  "live-server": "^1.2.1",
56
- "monaco-editor": "~0.35.0",
57
+ "monaco-editor": "~0.37.0",
57
58
  "monaco-languages": "2.11.1",
58
59
  "rimraf": "^4.1.2",
59
60
  "rollup": "^3.17.3",
60
61
  "terser": "^5.16.2",
61
62
  "ts-node": "^10.9.1",
62
- "typescript": "^4.0.0",
63
+ "typescript": "^5.0.4",
63
64
  "vscode-languageserver-textdocument": "1.0.4"
64
65
  },
65
66
  "dependencies": {
@@ -70,6 +71,6 @@
70
71
  "xregexp": "^5.1.1"
71
72
  },
72
73
  "peerDependencies": {
73
- "monaco-editor": "~0.35.0"
74
+ "monaco-editor": "~0.37.0"
74
75
  }
75
76
  }
@@ -1,11 +1,30 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 6.1.2(4c9ec21ad04b49f9f8e8a8f7fe773fe9a8b47334)
3
+ * monaco-kusto version: 7.0.0(f23f8fe8dd705f8413d0d094c76eb0af2131aace)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
7
7
 
8
- define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function (exports, main) { 'use strict';
8
+ define('vs/language/kusto/kustoMode', ['exports', 'vs/editor/editor.main', './main-5ef10bd7'], (function (exports, monaco, main) { 'use strict';
9
+
10
+ function _interopNamespaceDefault(e) {
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
9
28
 
10
29
  var _excluded = ["onDidProvideCompletionItems"];
11
30
  function _typeof$7(obj) { "@babel/helpers - typeof"; return _typeof$7 = "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$7(obj); }
@@ -697,12 +716,9 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
697
716
  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; }
698
717
  function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return _typeof$1(key) === "symbol" ? key : String(key); }
699
718
  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); }
700
- var Uri = monaco.Uri;
701
- monaco.Position;
702
- var Range = monaco.Range;
703
- monaco.Thenable;
704
- monaco.CancellationToken;
705
- monaco.IDisposable; // --- diagnostics ---
719
+
720
+ // --- diagnostics ---
721
+
706
722
  var DiagnosticsAdapter = /*#__PURE__*/function () {
707
723
  function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
708
724
  var _this = this;
@@ -787,7 +803,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
787
803
  }
788
804
  };
789
805
  if (this.defaults.languageSettings.enableQuickFixes) {
790
- this._disposables.push(monaco.languages.registerCodeActionProvider(this._languageId, {
806
+ this._disposables.push(monaco__namespace.languages.registerCodeActionProvider(this._languageId, {
791
807
  provideCodeActions: function () {
792
808
  var _provideCodeActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(model, range, context, _token) {
793
809
  var startOffset, endOffset, showQuickFix, actions;
@@ -1029,16 +1045,16 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1029
1045
  overviewRuler: {
1030
1046
  // The color indication on the right ruler
1031
1047
  color: 'rgb(255, 18, 18, 0.7)',
1032
- position: monaco.editor.OverviewRulerLane.Right
1048
+ position: monaco__namespace.editor.OverviewRulerLane.Right
1033
1049
  },
1034
1050
  minimap: {
1035
1051
  color: 'rgb(255, 18, 18, 0.7)',
1036
- position: monaco.editor.MinimapPosition.Inline
1052
+ position: monaco__namespace.editor.MinimapPosition.Inline
1037
1053
  }
1038
1054
  }
1039
1055
  };
1040
1056
  });
1041
- var oldMarkers = monaco.editor.getModelMarkers({
1057
+ var oldMarkers = monaco__namespace.editor.getModelMarkers({
1042
1058
  owner: languageId,
1043
1059
  resource: resource
1044
1060
  });
@@ -1071,15 +1087,15 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1071
1087
  function toSeverity(lsSeverity) {
1072
1088
  switch (lsSeverity) {
1073
1089
  case main.DiagnosticSeverity.Error:
1074
- return monaco.MarkerSeverity.Error;
1090
+ return monaco__namespace.MarkerSeverity.Error;
1075
1091
  case main.DiagnosticSeverity.Warning:
1076
- return monaco.MarkerSeverity.Warning;
1092
+ return monaco__namespace.MarkerSeverity.Warning;
1077
1093
  case main.DiagnosticSeverity.Information:
1078
- return monaco.MarkerSeverity.Info;
1094
+ return monaco__namespace.MarkerSeverity.Info;
1079
1095
  case main.DiagnosticSeverity.Hint:
1080
- return monaco.MarkerSeverity.Hint;
1096
+ return monaco__namespace.MarkerSeverity.Hint;
1081
1097
  default:
1082
- return monaco.MarkerSeverity.Info;
1098
+ return monaco__namespace.MarkerSeverity.Info;
1083
1099
  }
1084
1100
  }
1085
1101
  function toDiagnostics(resource, diag) {
@@ -1288,7 +1304,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1288
1304
 
1289
1305
  /**
1290
1306
  * Return true if the range doesn't intersect any of the line ranges.
1291
- * @param range Range
1307
+ * @param range monaco.Range
1292
1308
  * @param impactedLineRanges an array of line ranges
1293
1309
  */
1294
1310
  }, {
@@ -1411,13 +1427,13 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1411
1427
  function toDecoration(model, classification) {
1412
1428
  var start = model.getPositionAt(classification.start);
1413
1429
  var end = model.getPositionAt(classification.start + classification.length);
1414
- var range = new Range(start.lineNumber, start.column, end.lineNumber, end.column);
1430
+ var range = new monaco__namespace.Range(start.lineNumber, start.column, end.lineNumber, end.column);
1415
1431
  var inlineClassName = ClassificationKindNames[classification.kind];
1416
1432
  return {
1417
1433
  range: range,
1418
1434
  options: {
1419
1435
  inlineClassName: inlineClassName,
1420
- stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
1436
+ stickiness: monaco__namespace.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
1421
1437
  }
1422
1438
  };
1423
1439
  }
@@ -1445,10 +1461,10 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1445
1461
  if (!range) {
1446
1462
  return void 0;
1447
1463
  }
1448
- return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
1464
+ return new monaco__namespace.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
1449
1465
  }
1450
1466
  function toCompletionItemKind(kind) {
1451
- var mItemKind = monaco.languages.CompletionItemKind;
1467
+ var mItemKind = monaco__namespace.languages.CompletionItemKind;
1452
1468
  switch (kind) {
1453
1469
  case main.CompletionItemKind.Text:
1454
1470
  return mItemKind.Text;
@@ -1511,7 +1527,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1511
1527
  var linkWithoutPostfix = prop.toString().replace('.md', '');
1512
1528
  // Sometimes we get the link as a full URL. For example in the main doc link of the item
1513
1529
  var fullURL = linkWithoutPostfix.startsWith('https') ? linkWithoutPostfix : "".concat(DOCS_BASE_URL, "/").concat(linkWithoutPostfix);
1514
- return monaco.Uri.parse(fullURL);
1530
+ return monaco__namespace.Uri.parse(fullURL);
1515
1531
  }
1516
1532
  });
1517
1533
  return {
@@ -1535,7 +1551,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1535
1551
  key: "provideCompletionItems",
1536
1552
  value: function provideCompletionItems(model, position, context, token) {
1537
1553
  var wordInfo = model.getWordUntilPosition(position);
1538
- var wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
1554
+ var wordRange = new monaco__namespace.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
1539
1555
  var resource = model.uri;
1540
1556
  var onDidProvideCompletionItems = this.languageSettings.onDidProvideCompletionItems;
1541
1557
  return this._worker(resource).then(function (worker) {
@@ -1553,17 +1569,19 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1553
1569
  insertText: entry.insertText,
1554
1570
  sortText: entry.sortText,
1555
1571
  filterText: entry.filterText,
1572
+ // TODO: Is this cast safe?
1556
1573
  documentation: formatDocLink((_entry$documentation = entry.documentation) === null || _entry$documentation === void 0 ? void 0 : _entry$documentation.value),
1557
1574
  detail: entry.detail,
1558
1575
  range: wordRange,
1559
1576
  kind: toCompletionItemKind(entry.kind)
1560
1577
  };
1561
1578
  if (entry.textEdit) {
1579
+ // TODO: Where is the "range" property coming from?
1562
1580
  item.range = toRange(entry.textEdit.range);
1563
1581
  item.insertText = entry.textEdit.newText;
1564
1582
  }
1565
1583
  if (entry.insertTextFormat === main.InsertTextFormat.Snippet) {
1566
- item.insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
1584
+ item.insertTextRules = monaco__namespace.languages.CompletionItemInsertTextRule.InsertAsSnippet;
1567
1585
  }
1568
1586
  return item;
1569
1587
  });
@@ -1613,7 +1631,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1613
1631
 
1614
1632
  function toLocation(location) {
1615
1633
  return {
1616
- uri: Uri.parse(location.uri),
1634
+ uri: monaco__namespace.Uri.parse(location.uri),
1617
1635
  range: toRange(location.range)
1618
1636
  };
1619
1637
  }
@@ -1671,7 +1689,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1671
1689
  }
1672
1690
  var resourceEdits = [];
1673
1691
  for (var _uri2 in edit.changes) {
1674
- var _uri = Uri.parse(_uri2);
1692
+ var _uri = monaco__namespace.Uri.parse(_uri2);
1675
1693
  var _iterator = _createForOfIteratorHelper(edit.changes[_uri2]),
1676
1694
  _step;
1677
1695
  try {
@@ -1783,7 +1801,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1783
1801
  return {
1784
1802
  start: range.startLine + 1,
1785
1803
  end: range.endLine + 1,
1786
- kind: monaco.languages.FoldingRangeKind.Region
1804
+ kind: monaco__namespace.languages.FoldingRangeKind.Region
1787
1805
  };
1788
1806
  }
1789
1807
 
@@ -1826,8 +1844,6 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1826
1844
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1827
1845
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1828
1846
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1829
- monaco.Uri;
1830
- monaco.IDisposable;
1831
1847
  var kustoWorker;
1832
1848
  var resolveWorker;
1833
1849
  var workerPromise = new Promise(function (resolve, reject) {
@@ -1839,7 +1855,7 @@ define('vs/language/kusto/kustoMode', ['exports', './main-1f7cc4fa'], (function
1839
1855
  * @param defaults
1840
1856
  */
1841
1857
  function setupMode(defaults, monacoInstance) {
1842
- var onSchemaChange = new monaco.Emitter();
1858
+ var onSchemaChange = new monaco__namespace.Emitter();
1843
1859
  // TODO: when should we dispose of these? seems like monaco-css and monaco-typescript don't dispose of these.
1844
1860
  var disposables = [];
1845
1861
  var monarchTokensProvider;
@@ -1,11 +1,11 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 6.1.2(4c9ec21ad04b49f9f8e8a8f7fe773fe9a8b47334)
3
+ * monaco-kusto version: 7.0.0(f23f8fe8dd705f8413d0d094c76eb0af2131aace)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
7
7
 
8
- define('vs/language/kusto/kustoWorker', ['exports', './main-1f7cc4fa'], (function (exports, main) { 'use strict';
8
+ define('vs/language/kusto/kustoWorker', ['exports', './main-5ef10bd7'], (function (exports, main) { 'use strict';
9
9
 
10
10
  function _slicedToArray$2(arr, i) { return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$2(); }
11
11
  function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -1,11 +1,11 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 6.1.2(4c9ec21ad04b49f9f8e8a8f7fe773fe9a8b47334)
3
+ * monaco-kusto version: 7.0.0(f23f8fe8dd705f8413d0d094c76eb0af2131aace)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
7
7
 
8
- define('vs/language/kusto/main-1f7cc4fa', ['exports'], (function (exports) { 'use strict';
8
+ define('vs/language/kusto/main-5ef10bd7', ['exports'], (function (exports) { 'use strict';
9
9
 
10
10
  /* --------------------------------------------------------------------------------------------
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.