@deephaven/console 0.5.2-matplotlib.2 → 0.6.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 (114) hide show
  1. package/dist/Console.d.ts +3 -0
  2. package/dist/Console.d.ts.map +1 -1
  3. package/dist/Console.js +807 -871
  4. package/dist/Console.js.map +1 -1
  5. package/dist/ConsoleInput.d.ts +1 -38
  6. package/dist/ConsoleInput.d.ts.map +1 -1
  7. package/dist/ConsoleInput.js +331 -436
  8. package/dist/ConsoleInput.js.map +1 -1
  9. package/dist/ConsoleMenu.js +159 -215
  10. package/dist/ConsoleMenu.js.map +1 -1
  11. package/dist/ConsolePropTypes.js +1 -1
  12. package/dist/ConsolePropTypes.js.map +1 -1
  13. package/dist/ConsoleShortcuts.js +2 -2
  14. package/dist/ConsoleShortcuts.js.map +1 -1
  15. package/dist/ConsoleStatusBar.js +85 -125
  16. package/dist/ConsoleStatusBar.js.map +1 -1
  17. package/dist/StoragePropTypes.js +2 -2
  18. package/dist/StoragePropTypes.js.map +1 -1
  19. package/dist/command-history/CommandHistory.css +5 -2
  20. package/dist/command-history/CommandHistory.css.map +1 -1
  21. package/dist/command-history/CommandHistory.d.ts +5 -0
  22. package/dist/command-history/CommandHistory.d.ts.map +1 -1
  23. package/dist/command-history/CommandHistory.js +303 -391
  24. package/dist/command-history/CommandHistory.js.map +1 -1
  25. package/dist/command-history/CommandHistoryActions.css +4 -0
  26. package/dist/command-history/CommandHistoryActions.css.map +1 -1
  27. package/dist/command-history/CommandHistoryActions.d.ts.map +1 -1
  28. package/dist/command-history/CommandHistoryActions.js +40 -79
  29. package/dist/command-history/CommandHistoryActions.js.map +1 -1
  30. package/dist/command-history/CommandHistoryItem.css +1 -1
  31. package/dist/command-history/CommandHistoryItem.d.ts +5 -0
  32. package/dist/command-history/CommandHistoryItem.d.ts.map +1 -1
  33. package/dist/command-history/CommandHistoryItem.js +15 -9
  34. package/dist/command-history/CommandHistoryItem.js.map +1 -1
  35. package/dist/command-history/CommandHistoryItemTooltip.d.ts +1 -40
  36. package/dist/command-history/CommandHistoryItemTooltip.d.ts.map +1 -1
  37. package/dist/command-history/CommandHistoryItemTooltip.js +139 -189
  38. package/dist/command-history/CommandHistoryItemTooltip.js.map +1 -1
  39. package/dist/command-history/CommandHistoryViewportUpdater.js +30 -35
  40. package/dist/command-history/CommandHistoryViewportUpdater.js.map +1 -1
  41. package/dist/command-history/index.js +5 -5
  42. package/dist/command-history/index.js.map +1 -1
  43. package/dist/common/Code.js +34 -70
  44. package/dist/common/Code.js.map +1 -1
  45. package/dist/common/ConsoleConstants.js +3 -24
  46. package/dist/common/ConsoleConstants.js.map +1 -1
  47. package/dist/common/ConsoleUtils.d.ts +1 -3
  48. package/dist/common/ConsoleUtils.d.ts.map +1 -1
  49. package/dist/common/ConsoleUtils.js +60 -94
  50. package/dist/common/ConsoleUtils.js.map +1 -1
  51. package/dist/common/ObjectIcon.js +4 -2
  52. package/dist/common/ObjectIcon.js.map +1 -1
  53. package/dist/common/index.d.js +1 -34
  54. package/dist/common/index.d.js.map +1 -1
  55. package/dist/common/index.js +4 -4
  56. package/dist/common/index.js.map +1 -1
  57. package/dist/console-history/ConsoleHistory.js +27 -63
  58. package/dist/console-history/ConsoleHistory.js.map +1 -1
  59. package/dist/console-history/ConsoleHistoryItem.js +116 -154
  60. package/dist/console-history/ConsoleHistoryItem.js.map +1 -1
  61. package/dist/console-history/ConsoleHistoryItemResult.js +4 -2
  62. package/dist/console-history/ConsoleHistoryItemResult.js.map +1 -1
  63. package/dist/console-history/ConsoleHistoryResultErrorMessage.js +94 -132
  64. package/dist/console-history/ConsoleHistoryResultErrorMessage.js.map +1 -1
  65. package/dist/console-history/ConsoleHistoryResultInProgress.js +42 -76
  66. package/dist/console-history/ConsoleHistoryResultInProgress.js.map +1 -1
  67. package/dist/console-history/index.js +5 -5
  68. package/dist/console-history/index.js.map +1 -1
  69. package/dist/csv/CsvFormats.js +14 -28
  70. package/dist/csv/CsvFormats.js.map +1 -1
  71. package/dist/csv/CsvInputBar.css +25 -23
  72. package/dist/csv/CsvInputBar.css.map +1 -1
  73. package/dist/csv/CsvInputBar.d.ts +2 -45
  74. package/dist/csv/CsvInputBar.d.ts.map +1 -1
  75. package/dist/csv/CsvInputBar.js +298 -372
  76. package/dist/csv/CsvInputBar.js.map +1 -1
  77. package/dist/csv/CsvOverlay.js +197 -243
  78. package/dist/csv/CsvOverlay.js.map +1 -1
  79. package/dist/csv/CsvParser.js +186 -209
  80. package/dist/csv/CsvParser.js.map +1 -1
  81. package/dist/csv/CsvTypeParser.js +185 -210
  82. package/dist/csv/CsvTypeParser.js.map +1 -1
  83. package/dist/csv/NewTableColumnTypes.js +1 -5
  84. package/dist/csv/NewTableColumnTypes.js.map +1 -1
  85. package/dist/index.js +14 -14
  86. package/dist/index.js.map +1 -1
  87. package/dist/log/LogLevelMenuItem.js +24 -58
  88. package/dist/log/LogLevelMenuItem.js.map +1 -1
  89. package/dist/log/LogView.js +429 -484
  90. package/dist/log/LogView.js.map +1 -1
  91. package/dist/monaco/MonacoCompletionProvider.js +92 -124
  92. package/dist/monaco/MonacoCompletionProvider.js.map +1 -1
  93. package/dist/monaco/MonacoUtils.js +315 -331
  94. package/dist/monaco/MonacoUtils.js.map +1 -1
  95. package/dist/monaco/index.js +2 -2
  96. package/dist/monaco/index.js.map +1 -1
  97. package/dist/monaco/lang/db.js +3 -3
  98. package/dist/monaco/lang/db.js.map +1 -1
  99. package/dist/monaco/lang/groovy.js +3 -3
  100. package/dist/monaco/lang/groovy.js.map +1 -1
  101. package/dist/monaco/lang/log.js +3 -3
  102. package/dist/monaco/lang/log.js.map +1 -1
  103. package/dist/monaco/lang/python.js +3 -3
  104. package/dist/monaco/lang/python.js.map +1 -1
  105. package/dist/monaco/lang/scala.js +5 -5
  106. package/dist/monaco/lang/scala.js.map +1 -1
  107. package/dist/notebook/Editor.js +101 -141
  108. package/dist/notebook/Editor.js.map +1 -1
  109. package/dist/notebook/ScriptEditor.js +261 -301
  110. package/dist/notebook/ScriptEditor.js.map +1 -1
  111. package/dist/notebook/ScriptEditorUtils.js +26 -42
  112. package/dist/notebook/ScriptEditorUtils.js.map +1 -1
  113. package/dist/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +17 -22
@@ -1,29 +1,7 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
2
 
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
4
 
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- 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, descriptor.key, descriptor); } }
10
-
11
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12
-
13
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
-
15
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
-
17
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
-
19
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20
-
21
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
-
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
-
25
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
-
27
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
6
 
29
7
  import React, { PureComponent } from 'react';
@@ -32,548 +10,515 @@ import { DropdownMenu, Tooltip } from '@deephaven/components';
32
10
  import { vsGear, dhTrashUndo } from '@deephaven/icons';
33
11
  import { PropTypes as APIPropTypes } from '@deephaven/jsapi-shim';
34
12
  import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
35
- import ConsoleUtils from '../common/ConsoleUtils';
36
- import LogLevel from './LogLevel';
13
+ import ConsoleUtils from "../common/ConsoleUtils.js";
14
+ import LogLevel from "./LogLevel.js";
37
15
  import "./LogView.css";
38
- import LogLevelMenuItem from './LogLevelMenuItem';
16
+ import LogLevelMenuItem from "./LogLevelMenuItem.js";
39
17
  /**
40
18
  * Log view contents. Uses a monaco editor to display/search the contents of the log.
41
19
  */
42
20
 
43
- var LogView = /*#__PURE__*/function (_PureComponent) {
44
- _inherits(LogView, _PureComponent);
45
-
46
- var _super = _createSuper(LogView);
47
-
48
- function LogView(props) {
49
- var _this;
50
-
51
- _classCallCheck(this, LogView);
52
-
53
- _this = _super.call(this, props);
54
- _this.handleClearClick = _this.handleClearClick.bind(_assertThisInitialized(_this));
55
- _this.handleFlushTimeout = _this.handleFlushTimeout.bind(_assertThisInitialized(_this));
56
- _this.handleLogMessage = _this.handleLogMessage.bind(_assertThisInitialized(_this));
57
- _this.handleMenuItemClick = _this.handleMenuItemClick.bind(_assertThisInitialized(_this));
58
- _this.handleResetClick = _this.handleResetClick.bind(_assertThisInitialized(_this));
59
- _this.handleResize = _this.handleResize.bind(_assertThisInitialized(_this));
60
- _this.handleToggleAllClick = _this.handleToggleAllClick.bind(_assertThisInitialized(_this));
61
- _this.cancelListener = null;
62
- _this.editor = null;
63
- _this.editorContainer = null;
64
- _this.logLevelMenuItems = {};
65
- _this.flushTimer = null;
66
- _this.bufferedMessages = [];
67
- _this.messages = [];
68
- _this.state = {
21
+ class LogView extends PureComponent {
22
+ /** ms to buffer log messages before processing them */
23
+
24
+ /** Maximum number of messages to store in the log */
25
+ static getLogText(logItem) {
26
+ var date = new Date(logItem.micros / 1000);
27
+ var timestamp = ConsoleUtils.formatTimestamp(date);
28
+ return "".concat(timestamp, " ").concat(logItem.logLevel, " ").concat(logItem.message);
29
+ }
30
+
31
+ constructor(props) {
32
+ super(props);
33
+ this.handleClearClick = this.handleClearClick.bind(this);
34
+ this.handleFlushTimeout = this.handleFlushTimeout.bind(this);
35
+ this.handleLogMessage = this.handleLogMessage.bind(this);
36
+ this.handleMenuItemClick = this.handleMenuItemClick.bind(this);
37
+ this.handleResetClick = this.handleResetClick.bind(this);
38
+ this.handleResize = this.handleResize.bind(this);
39
+ this.handleToggleAllClick = this.handleToggleAllClick.bind(this);
40
+ this.cancelListener = null;
41
+ this.editor = null;
42
+ this.editorContainer = null;
43
+ this.logLevelMenuItems = {};
44
+ this.flushTimer = null;
45
+ this.bufferedMessages = [];
46
+ this.messages = [];
47
+ this.state = {
69
48
  shownLogLevels: {}
70
49
  };
71
- return _this;
72
50
  }
73
51
 
74
- _createClass(LogView, [{
75
- key: "componentDidMount",
76
- value: function componentDidMount() {
77
- this.resetLogLevels();
78
- this.initMonaco();
79
- this.startListening();
80
- window.addEventListener('resize', this.handleResize);
81
- }
82
- }, {
83
- key: "componentDidUpdate",
84
- value: function componentDidUpdate(prevProps, prevState) {
85
- this.updateDimensions();
86
- var shownLogLevels = this.state.shownLogLevels;
87
-
88
- if (prevState.shownLogLevels !== shownLogLevels) {
89
- this.refreshLogText();
90
- }
91
-
92
- var session = this.props.session;
52
+ componentDidMount() {
53
+ this.resetLogLevels();
54
+ this.initMonaco();
55
+ this.startListening();
56
+ window.addEventListener('resize', this.handleResize);
57
+ }
93
58
 
94
- if (prevProps.session !== session) {
95
- this.stopListening();
96
- this.startListening(); // clear logs when starting a new console
59
+ componentDidUpdate(prevProps, prevState) {
60
+ this.updateDimensions();
61
+ var {
62
+ shownLogLevels
63
+ } = this.state;
97
64
 
98
- this.clearLogs();
99
- }
65
+ if (prevState.shownLogLevels !== shownLogLevels) {
66
+ this.refreshLogText();
100
67
  }
101
- }, {
102
- key: "componentWillUnmount",
103
- value: function componentWillUnmount() {
104
- this.stopFlushTimer();
68
+
69
+ var {
70
+ session
71
+ } = this.props;
72
+
73
+ if (prevProps.session !== session) {
105
74
  this.stopListening();
106
- this.destroyMonaco();
107
- window.removeEventListener('resize', this.handleResize);
108
- }
109
- }, {
110
- key: "getMenuActions",
111
- value: function getMenuActions(shownLogLevels) {
112
- var _this2 = this;
75
+ this.startListening(); // clear logs when starting a new console
113
76
 
114
- var actions = [];
115
- actions.push({
116
- menuElement: /*#__PURE__*/React.createElement("div", {
117
- className: "log-level-menu-title"
118
- }, "Display Log Levels"),
119
- group: 1,
120
- order: 10
121
- });
77
+ this.clearLogs();
78
+ }
79
+ }
122
80
 
123
- var _loop = function _loop(i) {
124
- var logLevel = LogView.AllLogLevels[i];
125
- var on = shownLogLevels[logLevel] != null ? shownLogLevels[logLevel] : false;
126
- actions.push({
127
- title: logLevel,
128
- group: 1,
129
- order: i + 100,
130
- menuElement: /*#__PURE__*/React.createElement(LogLevelMenuItem, {
131
- logLevel: logLevel,
132
- on: on,
133
- onClick: _this2.handleMenuItemClick,
134
- ref: function ref(element) {
135
- _this2.logLevelMenuItems[logLevel] = element;
136
- }
137
- })
138
- });
139
- };
140
-
141
- for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
142
- _loop(i);
143
- }
81
+ componentWillUnmount() {
82
+ this.stopFlushTimer();
83
+ this.stopListening();
84
+ this.destroyMonaco();
85
+ window.removeEventListener('resize', this.handleResize);
86
+ }
144
87
 
88
+ getMenuActions(shownLogLevels) {
89
+ var _this = this;
90
+
91
+ var actions = [];
92
+ actions.push({
93
+ menuElement: /*#__PURE__*/React.createElement("div", {
94
+ className: "log-level-menu-title"
95
+ }, "Display Log Levels"),
96
+ group: 1,
97
+ order: 10
98
+ });
99
+
100
+ var _loop = function _loop(i) {
101
+ var logLevel = LogView.AllLogLevels[i];
102
+ var on = shownLogLevels[logLevel] != null ? shownLogLevels[logLevel] : false;
145
103
  actions.push({
104
+ title: logLevel,
146
105
  group: 1,
147
- order: 1000,
148
- menuElement: /*#__PURE__*/React.createElement("div", {
149
- className: "log-level-menu-controls"
150
- }, /*#__PURE__*/React.createElement("button", {
151
- type: "button",
152
- className: "btn btn-link log-level-toggle-all",
153
- onClick: this.handleToggleAllClick
154
- }, "Toggle All"), /*#__PURE__*/React.createElement("button", {
155
- type: "button",
156
- className: "btn btn-link",
157
- onClick: this.handleResetClick
158
- }, "Reset"))
106
+ order: i + 100,
107
+ menuElement: /*#__PURE__*/React.createElement(LogLevelMenuItem, {
108
+ logLevel: logLevel,
109
+ on: on,
110
+ onClick: _this.handleMenuItemClick,
111
+ ref: element => {
112
+ _this.logLevelMenuItems[logLevel] = element;
113
+ }
114
+ })
159
115
  });
160
- return actions;
161
- }
162
- }, {
163
- key: "resetLogLevels",
164
- value: function resetLogLevels() {
165
- var shownLogLevels = {};
166
-
167
- for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
168
- var logLevel = LogView.AllLogLevels[i];
169
- var isEnabled = LogView.DefaultLogLevels.indexOf(logLevel) >= 0;
170
- shownLogLevels[logLevel] = isEnabled;
171
- }
116
+ };
172
117
 
173
- this.setState({
174
- shownLogLevels: shownLogLevels
175
- });
118
+ for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
119
+ _loop(i);
176
120
  }
177
- }, {
178
- key: "startListening",
179
- value: function startListening() {
180
- var session = this.props.session;
181
- this.cancelListener = session.onLogMessage(this.handleLogMessage);
182
- }
183
- }, {
184
- key: "stopListening",
185
- value: function stopListening() {
186
- if (this.cancelListener != null) {
187
- this.cancelListener();
188
- this.cancelListener = null;
189
- }
190
- }
191
- }, {
192
- key: "initMonaco",
193
- value: function initMonaco() {
194
- var _this3 = this;
195
-
196
- this.editor = monaco.editor.create(this.editorContainer, {
197
- copyWithSyntaxHighlighting: 'false',
198
- fixedOverflowWidgets: true,
199
- folding: false,
200
- fontFamily: 'Fira Mono',
201
- glyphMargin: false,
202
- language: 'log',
203
- lineDecorationsWidth: 0,
204
- lineNumbers: '',
205
- lineNumbersMinChars: 0,
206
- minimap: {
207
- enabled: false
208
- },
209
- readOnly: true,
210
- renderLineHighlight: 'none',
211
- scrollBeyondLastLine: false,
212
- value: '',
213
- wordWrap: 'on'
214
- }); // When find widget is open, escape key closes it.
215
- // Instead, capture it and do nothing. Same for shift-escape.
216
-
217
- this.editor.addCommand(monaco.KeyCode.Escape, function () {});
218
- this.editor.addCommand( // eslint-disable-next-line no-bitwise
219
- monaco.KeyMod.Shift | monaco.KeyCode.Escape, function () {}); // Restore regular escape to clear selection, when editorText has focus.
220
-
221
- this.editor.addCommand(monaco.KeyCode.Escape, function () {
222
- _this3.editor.setPosition(_this3.editor.getPosition());
223
- }, 'findWidgetVisible && editorTextFocus');
224
- this.editor.addCommand( // eslint-disable-next-line no-bitwise
225
- monaco.KeyMod.Shift | monaco.KeyCode.Escape, function () {
226
- _this3.editor.setPosition(_this3.editor.getPosition());
227
- }, 'findWidgetVisible && editorTextFocus');
121
+
122
+ actions.push({
123
+ group: 1,
124
+ order: 1000,
125
+ menuElement: /*#__PURE__*/React.createElement("div", {
126
+ className: "log-level-menu-controls"
127
+ }, /*#__PURE__*/React.createElement("button", {
128
+ type: "button",
129
+ className: "btn btn-link log-level-toggle-all",
130
+ onClick: this.handleToggleAllClick
131
+ }, "Toggle All"), /*#__PURE__*/React.createElement("button", {
132
+ type: "button",
133
+ className: "btn btn-link",
134
+ onClick: this.handleResetClick
135
+ }, "Reset"))
136
+ });
137
+ return actions;
138
+ }
139
+
140
+ resetLogLevels() {
141
+ var shownLogLevels = {};
142
+
143
+ for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
144
+ var logLevel = LogView.AllLogLevels[i];
145
+ var isEnabled = LogView.DefaultLogLevels.indexOf(logLevel) >= 0;
146
+ shownLogLevels[logLevel] = isEnabled;
228
147
  }
229
- }, {
230
- key: "destroyMonaco",
231
- value: function destroyMonaco() {
232
- if (this.editor) {
233
- this.editor.dispose();
234
- this.editor = null;
235
- }
148
+
149
+ this.setState({
150
+ shownLogLevels
151
+ });
152
+ }
153
+
154
+ startListening() {
155
+ var {
156
+ session
157
+ } = this.props;
158
+ this.cancelListener = session.onLogMessage(this.handleLogMessage);
159
+ }
160
+
161
+ stopListening() {
162
+ if (this.cancelListener != null) {
163
+ this.cancelListener();
164
+ this.cancelListener = null;
236
165
  }
237
- }, {
238
- key: "triggerFindWidget",
239
- value: function triggerFindWidget() {
240
- // The actions.find action can no longer be triggered when the editor is not in focus, with monaco 0.22.x.
241
- // As a workaround, just focus the editor before triggering the action
242
- // https://github.com/microsoft/monaco-editor/issues/2355
243
- this.editor.focus();
244
- this.editor.trigger('keyboard', 'actions.find');
166
+ }
167
+
168
+ initMonaco() {
169
+ this.editor = monaco.editor.create(this.editorContainer, {
170
+ copyWithSyntaxHighlighting: 'false',
171
+ fixedOverflowWidgets: true,
172
+ folding: false,
173
+ fontFamily: 'Fira Mono',
174
+ glyphMargin: false,
175
+ language: 'log',
176
+ lineDecorationsWidth: 0,
177
+ lineNumbers: '',
178
+ lineNumbersMinChars: 0,
179
+ minimap: {
180
+ enabled: false
181
+ },
182
+ readOnly: true,
183
+ renderLineHighlight: 'none',
184
+ scrollBeyondLastLine: false,
185
+ value: '',
186
+ wordWrap: 'on'
187
+ }); // When find widget is open, escape key closes it.
188
+ // Instead, capture it and do nothing. Same for shift-escape.
189
+
190
+ this.editor.addCommand(monaco.KeyCode.Escape, () => {});
191
+ this.editor.addCommand( // eslint-disable-next-line no-bitwise
192
+ monaco.KeyMod.Shift | monaco.KeyCode.Escape, () => {}); // Restore regular escape to clear selection, when editorText has focus.
193
+
194
+ this.editor.addCommand(monaco.KeyCode.Escape, () => {
195
+ this.editor.setPosition(this.editor.getPosition());
196
+ }, 'findWidgetVisible && editorTextFocus');
197
+ this.editor.addCommand( // eslint-disable-next-line no-bitwise
198
+ monaco.KeyMod.Shift | monaco.KeyCode.Escape, () => {
199
+ this.editor.setPosition(this.editor.getPosition());
200
+ }, 'findWidgetVisible && editorTextFocus');
201
+ }
202
+
203
+ destroyMonaco() {
204
+ if (this.editor) {
205
+ this.editor.dispose();
206
+ this.editor = null;
245
207
  }
246
- }, {
247
- key: "toggleAll",
248
- value: function toggleAll() {
249
- var shownLogLevels = this.state.shownLogLevels;
250
- var isAllEnabled = true;
251
-
252
- for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
253
- var logLevel = LogView.AllLogLevels[i];
254
-
255
- if (!shownLogLevels[logLevel]) {
256
- isAllEnabled = false;
257
- break;
258
- }
259
- }
208
+ }
260
209
 
261
- if (isAllEnabled) {
262
- this.setState({
263
- shownLogLevels: {}
264
- });
265
- } else {
266
- var updatedLogLevels = {};
210
+ triggerFindWidget() {
211
+ // The actions.find action can no longer be triggered when the editor is not in focus, with monaco 0.22.x.
212
+ // As a workaround, just focus the editor before triggering the action
213
+ // https://github.com/microsoft/monaco-editor/issues/2355
214
+ this.editor.focus();
215
+ this.editor.trigger('keyboard', 'actions.find');
216
+ }
267
217
 
268
- for (var _i = 0; _i < LogView.AllLogLevels.length; _i += 1) {
269
- var _logLevel = LogView.AllLogLevels[_i];
270
- updatedLogLevels[_logLevel] = true;
271
- }
218
+ toggleAll() {
219
+ var {
220
+ shownLogLevels
221
+ } = this.state;
222
+ var isAllEnabled = true;
272
223
 
273
- this.setState({
274
- shownLogLevels: updatedLogLevels
275
- });
224
+ for (var i = 0; i < LogView.AllLogLevels.length; i += 1) {
225
+ var logLevel = LogView.AllLogLevels[i];
226
+
227
+ if (!shownLogLevels[logLevel]) {
228
+ isAllEnabled = false;
229
+ break;
276
230
  }
277
231
  }
278
- }, {
279
- key: "toggleLogLevel",
280
- value: function toggleLogLevel(logLevel) {
281
- var shownLogLevels = this.state.shownLogLevels;
282
- var isEnabled = shownLogLevels[logLevel];
232
+
233
+ if (isAllEnabled) {
234
+ this.setState({
235
+ shownLogLevels: {}
236
+ });
237
+ } else {
283
238
  var updatedLogLevels = {};
284
- updatedLogLevels[logLevel] = !isEnabled;
285
- this.updateLogLevels(updatedLogLevels);
286
- }
287
- }, {
288
- key: "updateLogLevels",
289
- value: function updateLogLevels(updatedLogLevels) {
290
- var shownLogLevels = this.state.shownLogLevels;
291
- shownLogLevels = _objectSpread(_objectSpread({}, shownLogLevels), updatedLogLevels);
239
+
240
+ for (var _i = 0; _i < LogView.AllLogLevels.length; _i += 1) {
241
+ var _logLevel = LogView.AllLogLevels[_i];
242
+ updatedLogLevels[_logLevel] = true;
243
+ }
244
+
292
245
  this.setState({
293
- shownLogLevels: shownLogLevels
246
+ shownLogLevels: updatedLogLevels
294
247
  });
295
248
  }
296
- }, {
297
- key: "appendLogText",
298
- value: function appendLogText(text) {
299
- if (!this.editor) {
300
- return;
301
- }
249
+ }
302
250
 
303
- var model = this.editor.getModel();
304
- var line = model.getLineCount();
305
- var column = model.getLineLength(line);
306
- var isBottomVisible = this.isBottomVisible();
307
- var edits = [];
308
-
309
- if (column > 0) {
310
- edits.push({
311
- range: {
312
- startLineNumber: line,
313
- startColumn: column + 1,
314
- endLineNumber: line,
315
- endColumn: column + 1
316
- },
317
- text: '\n',
318
- forceMoveMarkers: true
319
- });
320
- line += 1;
321
- column = 0;
322
- }
251
+ toggleLogLevel(logLevel) {
252
+ var {
253
+ shownLogLevels
254
+ } = this.state;
255
+ var isEnabled = shownLogLevels[logLevel];
256
+ var updatedLogLevels = {};
257
+ updatedLogLevels[logLevel] = !isEnabled;
258
+ this.updateLogLevels(updatedLogLevels);
259
+ }
260
+
261
+ updateLogLevels(updatedLogLevels) {
262
+ var {
263
+ shownLogLevels
264
+ } = this.state;
265
+ shownLogLevels = _objectSpread(_objectSpread({}, shownLogLevels), updatedLogLevels);
266
+ this.setState({
267
+ shownLogLevels
268
+ });
269
+ }
270
+
271
+ appendLogText(text) {
272
+ if (!this.editor) {
273
+ return;
274
+ }
275
+
276
+ var model = this.editor.getModel();
277
+ var line = model.getLineCount();
278
+ var column = model.getLineLength(line);
279
+ var isBottomVisible = this.isBottomVisible();
280
+ var edits = [];
323
281
 
282
+ if (column > 0) {
324
283
  edits.push({
325
284
  range: {
326
285
  startLineNumber: line,
327
- startColumn: column,
286
+ startColumn: column + 1,
328
287
  endLineNumber: line,
329
- endColumn: column
288
+ endColumn: column + 1
330
289
  },
331
- text: text,
290
+ text: '\n',
332
291
  forceMoveMarkers: true
333
292
  });
334
- model.applyEdits(edits);
335
-
336
- if (isBottomVisible) {
337
- this.editor.revealLine(model.getLineCount(), 1);
338
- }
293
+ line += 1;
294
+ column = 0;
339
295
  }
340
- /**
341
- * Refresh the contents of the log component with the updated filter text
342
- */
343
-
344
- }, {
345
- key: "refreshLogText",
346
- value: function refreshLogText() {
347
- if (!this.editor) {
348
- return;
349
- }
350
296
 
351
- this.truncateLogIfNecessary();
352
- var shownLogLevels = this.state.shownLogLevels;
353
- var isBottomVisible = this.isBottomVisible();
354
- var text = '';
297
+ edits.push({
298
+ range: {
299
+ startLineNumber: line,
300
+ startColumn: column,
301
+ endLineNumber: line,
302
+ endColumn: column
303
+ },
304
+ text,
305
+ forceMoveMarkers: true
306
+ });
307
+ model.applyEdits(edits);
355
308
 
356
- for (var i = 0; i < this.messages.length; i += 1) {
357
- var message = this.messages[i];
309
+ if (isBottomVisible) {
310
+ this.editor.revealLine(model.getLineCount(), 1);
311
+ }
312
+ }
313
+ /**
314
+ * Refresh the contents of the log component with the updated filter text
315
+ */
358
316
 
359
- if (shownLogLevels[message.logLevel]) {
360
- var logText = LogView.getLogText(message);
361
317
 
362
- if (logText.length > 0) {
363
- text += logText;
318
+ refreshLogText() {
319
+ if (!this.editor) {
320
+ return;
321
+ }
364
322
 
365
- if (logText.charAt(logText.length - 1) !== '\n') {
366
- text += '\n';
367
- }
368
- }
369
- }
370
- }
323
+ this.truncateLogIfNecessary();
324
+ var {
325
+ shownLogLevels
326
+ } = this.state;
327
+ var isBottomVisible = this.isBottomVisible();
328
+ var text = '';
371
329
 
372
- text = text.trimRight();
373
- this.editor.setValue(text);
330
+ for (var i = 0; i < this.messages.length; i += 1) {
331
+ var message = this.messages[i];
374
332
 
375
- if (isBottomVisible) {
376
- var line = this.editor.getModel().getLineCount();
377
- this.editor.revealLine(line, 1);
378
- }
333
+ if (shownLogLevels[message.logLevel]) {
334
+ var logText = LogView.getLogText(message);
379
335
 
380
- this.stopFlushTimer();
381
- this.bufferedMessages = [];
382
- }
383
- }, {
384
- key: "truncateLogIfNecessary",
385
- value: function truncateLogIfNecessary() {
386
- if (this.messages.length > LogView.maxLogSize) {
387
- this.messages = this.messages.splice(this.messages.length - LogView.truncateSize);
336
+ if (logText.length > 0) {
337
+ text += logText;
338
+
339
+ if (logText.charAt(logText.length - 1) !== '\n') {
340
+ text += '\n';
341
+ }
342
+ }
388
343
  }
389
344
  }
390
- }, {
391
- key: "scrollToBottom",
392
- value: function scrollToBottom() {
393
- if (!this.editor) {
394
- return;
395
- }
396
345
 
346
+ text = text.trimRight();
347
+ this.editor.setValue(text);
348
+
349
+ if (isBottomVisible) {
397
350
  var line = this.editor.getModel().getLineCount();
398
351
  this.editor.revealLine(line, 1);
399
352
  }
400
- }, {
401
- key: "isBottomVisible",
402
- value: function isBottomVisible() {
403
- if (!this.editor) {
404
- return true;
405
- }
406
353
 
407
- var model = this.editor.getModel();
408
- var line = model.getLineCount();
409
- return this.isLineVisible(line);
354
+ this.stopFlushTimer();
355
+ this.bufferedMessages = [];
356
+ }
357
+
358
+ truncateLogIfNecessary() {
359
+ if (this.messages.length > LogView.maxLogSize) {
360
+ this.messages = this.messages.splice(this.messages.length - LogView.truncateSize);
410
361
  }
411
- }, {
412
- key: "isLineVisible",
413
- value: function isLineVisible(line) {
414
- var visibleRanges = this.editor.getVisibleRanges();
362
+ }
415
363
 
416
- if (visibleRanges == null || visibleRanges.length === 0) {
417
- return false;
418
- }
364
+ scrollToBottom() {
365
+ if (!this.editor) {
366
+ return;
367
+ }
419
368
 
420
- for (var i = 0; i < visibleRanges.length; i += 1) {
421
- var range = visibleRanges[i];
369
+ var line = this.editor.getModel().getLineCount();
370
+ this.editor.revealLine(line, 1);
371
+ }
422
372
 
423
- if (range.startLineNumber <= line && line <= range.endLineNumber) {
424
- return true;
425
- }
426
- }
373
+ isBottomVisible() {
374
+ if (!this.editor) {
375
+ return true;
376
+ }
377
+
378
+ var model = this.editor.getModel();
379
+ var line = model.getLineCount();
380
+ return this.isLineVisible(line);
381
+ }
427
382
 
383
+ isLineVisible(line) {
384
+ var visibleRanges = this.editor.getVisibleRanges();
385
+
386
+ if (visibleRanges == null || visibleRanges.length === 0) {
428
387
  return false;
429
388
  }
430
- /** Checks if the given log message is visible with the current filters */
431
389
 
432
- }, {
433
- key: "isLogItemVisible",
434
- value: function isLogItemVisible(message) {
435
- var shownLogLevels = this.state.shownLogLevels;
436
- return shownLogLevels[message.logLevel];
390
+ for (var i = 0; i < visibleRanges.length; i += 1) {
391
+ var range = visibleRanges[i];
392
+
393
+ if (range.startLineNumber <= line && line <= range.endLineNumber) {
394
+ return true;
395
+ }
437
396
  }
438
- }, {
439
- key: "flush",
440
- value: function flush() {
441
- var text = '';
442
397
 
443
- for (var i = 0; i < this.bufferedMessages.length; i += 1) {
444
- var message = this.bufferedMessages[i];
445
- var logText = LogView.getLogText(message);
446
- text += logText;
398
+ return false;
399
+ }
400
+ /** Checks if the given log message is visible with the current filters */
447
401
 
448
- if (logText.charAt(logText.length - 1) !== '\n') {
449
- text += '\n';
450
- }
451
- }
452
402
 
453
- this.bufferedMessages = [];
454
- this.appendLogText(text);
455
- }
456
- }, {
457
- key: "queue",
458
- value: function queue(message) {
459
- this.bufferedMessages.push(message);
403
+ isLogItemVisible(message) {
404
+ var {
405
+ shownLogLevels
406
+ } = this.state;
407
+ return shownLogLevels[message.logLevel];
408
+ }
460
409
 
461
- if (this.bufferedMessages.length === 1) {
462
- this.flushTimer = setTimeout(this.handleFlushTimeout, LogView.bufferTimeout);
463
- }
464
- }
465
- }, {
466
- key: "stopFlushTimer",
467
- value: function stopFlushTimer() {
468
- if (this.flushTimer) {
469
- clearTimeout(this.flushTimer);
470
- this.flushTimer = null;
410
+ flush() {
411
+ var text = '';
412
+
413
+ for (var i = 0; i < this.bufferedMessages.length; i += 1) {
414
+ var message = this.bufferedMessages[i];
415
+ var logText = LogView.getLogText(message);
416
+ text += logText;
417
+
418
+ if (logText.charAt(logText.length - 1) !== '\n') {
419
+ text += '\n';
471
420
  }
472
421
  }
473
- }, {
474
- key: "updateDimensions",
475
- value: function updateDimensions() {
476
- if (this.editor) {
477
- this.editor.layout();
478
- }
422
+
423
+ this.bufferedMessages = [];
424
+ this.appendLogText(text);
425
+ }
426
+
427
+ queue(message) {
428
+ this.bufferedMessages.push(message);
429
+
430
+ if (this.bufferedMessages.length === 1) {
431
+ this.flushTimer = setTimeout(this.handleFlushTimeout, LogView.bufferTimeout);
479
432
  }
480
- }, {
481
- key: "handleClearClick",
482
- value: function handleClearClick() {
483
- this.clearLogs();
433
+ }
434
+
435
+ stopFlushTimer() {
436
+ if (this.flushTimer) {
437
+ clearTimeout(this.flushTimer);
438
+ this.flushTimer = null;
484
439
  }
485
- }, {
486
- key: "clearLogs",
487
- value: function clearLogs() {
488
- this.messages = [];
489
- this.refreshLogText();
440
+ }
441
+
442
+ updateDimensions() {
443
+ if (this.editor) {
444
+ this.editor.layout();
490
445
  }
491
- }, {
492
- key: "handleFlushTimeout",
493
- value: function handleFlushTimeout() {
494
- this.stopFlushTimer();
495
- this.flush();
446
+ }
447
+
448
+ handleClearClick() {
449
+ this.clearLogs();
450
+ }
451
+
452
+ clearLogs() {
453
+ this.messages = [];
454
+ this.refreshLogText();
455
+ }
456
+
457
+ handleFlushTimeout() {
458
+ this.stopFlushTimer();
459
+ this.flush();
460
+ }
461
+
462
+ handleLogMessage(message) {
463
+ this.messages.push(message);
464
+
465
+ if (this.editor && this.isLogItemVisible(message)) {
466
+ this.queue(message);
496
467
  }
497
- }, {
498
- key: "handleLogMessage",
499
- value: function handleLogMessage(message) {
500
- this.messages.push(message);
468
+ }
501
469
 
502
- if (this.editor && this.isLogItemVisible(message)) {
503
- this.queue(message);
470
+ handleMenuItemClick(logLevel) {
471
+ this.toggleLogLevel(logLevel);
472
+ }
473
+
474
+ handleResetClick() {
475
+ this.resetLogLevels();
476
+ }
477
+
478
+ handleResize() {
479
+ this.updateDimensions();
480
+ }
481
+
482
+ handleToggleAllClick() {
483
+ this.toggleAll();
484
+ }
485
+
486
+ render() {
487
+ var popperOptions = {
488
+ placement: 'bottom-end'
489
+ };
490
+ var {
491
+ shownLogLevels
492
+ } = this.state;
493
+ var actions = this.getMenuActions(shownLogLevels);
494
+ return /*#__PURE__*/React.createElement("div", {
495
+ className: "log-pane h-100 w-100"
496
+ }, /*#__PURE__*/React.createElement("div", {
497
+ className: "log-pane-menu"
498
+ }, /*#__PURE__*/React.createElement("button", {
499
+ type: "button",
500
+ className: "btn btn-link btn-link-icon btn-clear-logs",
501
+ onClick: this.handleClearClick
502
+ }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
503
+ icon: dhTrashUndo
504
+ }), /*#__PURE__*/React.createElement(Tooltip, null, "Clear log")), /*#__PURE__*/React.createElement("button", {
505
+ type: "button",
506
+ className: "btn btn-link btn-link-icon btn-overflow"
507
+ }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
508
+ icon: vsGear
509
+ }), /*#__PURE__*/React.createElement(Tooltip, null, "Log Settings"), /*#__PURE__*/React.createElement(DropdownMenu, {
510
+ actions: actions,
511
+ popperClassName: "log-level-menu-popper",
512
+ popperOptions: popperOptions
513
+ }))), /*#__PURE__*/React.createElement("div", {
514
+ className: "log-pane-editor h-100 w-100",
515
+ ref: editorContainer => {
516
+ this.editorContainer = editorContainer;
504
517
  }
505
- }
506
- }, {
507
- key: "handleMenuItemClick",
508
- value: function handleMenuItemClick(logLevel) {
509
- this.toggleLogLevel(logLevel);
510
- }
511
- }, {
512
- key: "handleResetClick",
513
- value: function handleResetClick() {
514
- this.resetLogLevels();
515
- }
516
- }, {
517
- key: "handleResize",
518
- value: function handleResize() {
519
- this.updateDimensions();
520
- }
521
- }, {
522
- key: "handleToggleAllClick",
523
- value: function handleToggleAllClick() {
524
- this.toggleAll();
525
- }
526
- }, {
527
- key: "render",
528
- value: function render() {
529
- var _this4 = this;
530
-
531
- var popperOptions = {
532
- placement: 'bottom-end'
533
- };
534
- var shownLogLevels = this.state.shownLogLevels;
535
- var actions = this.getMenuActions(shownLogLevels);
536
- return /*#__PURE__*/React.createElement("div", {
537
- className: "log-pane h-100 w-100"
538
- }, /*#__PURE__*/React.createElement("div", {
539
- className: "log-pane-menu"
540
- }, /*#__PURE__*/React.createElement("button", {
541
- type: "button",
542
- className: "btn btn-link btn-link-icon btn-clear-logs",
543
- onClick: this.handleClearClick
544
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
545
- icon: dhTrashUndo
546
- }), /*#__PURE__*/React.createElement(Tooltip, null, "Clear log")), /*#__PURE__*/React.createElement("button", {
547
- type: "button",
548
- className: "btn btn-link btn-link-icon btn-overflow"
549
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
550
- icon: vsGear
551
- }), /*#__PURE__*/React.createElement(Tooltip, null, "Log Settings"), /*#__PURE__*/React.createElement(DropdownMenu, {
552
- actions: actions,
553
- popperClassName: "log-level-menu-popper",
554
- popperOptions: popperOptions
555
- }))), /*#__PURE__*/React.createElement("div", {
556
- className: "log-pane-editor h-100 w-100",
557
- ref: function ref(editorContainer) {
558
- _this4.editorContainer = editorContainer;
559
- }
560
- }));
561
- }
562
- }], [{
563
- key: "getLogText",
564
- value:
565
- /** ms to buffer log messages before processing them */
566
-
567
- /** Maximum number of messages to store in the log */
568
- function getLogText(logItem) {
569
- var date = new Date(logItem.micros / 1000);
570
- var timestamp = ConsoleUtils.formatTimestamp(date);
571
- return "".concat(timestamp, " ").concat(logItem.logLevel, " ").concat(logItem.message);
572
- }
573
- }]);
518
+ }));
519
+ }
574
520
 
575
- return LogView;
576
- }(PureComponent);
521
+ }
577
522
 
578
523
  _defineProperty(LogView, "DefaultLogLevels", [LogLevel.STDOUT, LogLevel.ERROR, LogLevel.FATAL, LogLevel.STDERR, LogLevel.WARN]);
579
524