@deephaven/console 0.5.2-matplotlib.2 → 0.6.1-demo.8

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 +26 -56
@@ -1,41 +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
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
-
9
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
10
-
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
-
13
- 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; }
14
-
15
1
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
2
 
17
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
4
 
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
-
21
- 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); } }
22
-
23
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
24
-
25
- 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); }
26
-
27
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
28
-
29
- 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); }; }
30
-
31
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
32
-
33
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
34
-
35
- 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; } }
36
-
37
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
-
39
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; }
40
6
 
41
7
  import React, { Component } from 'react';
@@ -44,50 +10,68 @@ import { ContextActions, ContextActionUtils, ItemList, SearchInput, GLOBAL_SHORT
44
10
  import { vsFileCode, vsFiles, vsNewFile, vsPlay, vsTerminal } from '@deephaven/icons';
45
11
  import { Pending } from '@deephaven/utils';
46
12
  import Log from '@deephaven/log';
47
- import CommandHistoryItem from './CommandHistoryItem';
48
- import CommandHistoryActions from './CommandHistoryActions';
49
- import ConsoleConstants from '../common/ConsoleConstants';
13
+ import CommandHistoryItem from "./CommandHistoryItem.js";
14
+ import CommandHistoryActions from "./CommandHistoryActions.js";
15
+ import ConsoleConstants from "../common/ConsoleConstants.js";
50
16
  import "./CommandHistory.css";
51
- import StoragePropTypes from '../StoragePropTypes';
52
- import CommandHistoryViewportUpdater from './CommandHistoryViewportUpdater';
53
- import SHORTCUTS from '../ConsoleShortcuts';
17
+ import StoragePropTypes from "../StoragePropTypes.js";
18
+ import CommandHistoryViewportUpdater from "./CommandHistoryViewportUpdater.js";
19
+ import SHORTCUTS from "../ConsoleShortcuts.js";
54
20
  var log = Log.module('CommandHistory');
55
21
 
56
- var CommandHistory = /*#__PURE__*/function (_Component) {
57
- _inherits(CommandHistory, _Component);
58
-
59
- var _super = _createSuper(CommandHistory);
60
-
61
- function CommandHistory(props) {
62
- var _this;
63
-
64
- _classCallCheck(this, CommandHistory);
65
-
66
- _this = _super.call(this, props);
67
- _this.copySelectedCommands = _this.copySelectedCommands.bind(_assertThisInitialized(_this));
68
- _this.createNotebook = _this.createNotebook.bind(_assertThisInitialized(_this));
69
- _this.sendToConsole = _this.sendToConsole.bind(_assertThisInitialized(_this));
70
- _this.renderItem = _this.renderItem.bind(_assertThisInitialized(_this));
71
- _this.runInConsole = _this.runInConsole.bind(_assertThisInitialized(_this));
72
- _this.sendToNotebook = _this.sendToNotebook.bind(_assertThisInitialized(_this));
73
- _this.handleSelect = _this.handleSelect.bind(_assertThisInitialized(_this));
74
- _this.handleSelectionChange = _this.handleSelectionChange.bind(_assertThisInitialized(_this));
75
- _this.handleSearchChange = _this.handleSearchChange.bind(_assertThisInitialized(_this));
76
- _this.handleViewportChange = _this.handleViewportChange.bind(_assertThisInitialized(_this));
77
- _this.handleViewportUpdate = _this.handleViewportUpdate.bind(_assertThisInitialized(_this));
78
- _this.itemActions = [{
22
+ class CommandHistory extends Component {
23
+ static getCommandsFromViewport(items, offset, sortedRanges) {
24
+ var commands = [];
25
+
26
+ for (var i = 0; i < sortedRanges.length; i += 1) {
27
+ var range = sortedRanges[i];
28
+
29
+ for (var j = range[0]; j <= range[1]; j += 1) {
30
+ if (j >= offset && j < offset + items.length) {
31
+ var {
32
+ name
33
+ } = items[j - offset];
34
+ commands.push(name);
35
+ }
36
+ }
37
+ }
38
+
39
+ return commands;
40
+ }
41
+
42
+ static getCommandsFromSnapshot(table, sortedRanges) {
43
+ return _asyncToGenerator(function* () {
44
+ var items = yield table.getSnapshot(sortedRanges);
45
+ return [...items.values()].map(item => item.name);
46
+ })();
47
+ }
48
+
49
+ constructor(props) {
50
+ super(props);
51
+ this.copySelectedCommands = this.copySelectedCommands.bind(this);
52
+ this.createNotebook = this.createNotebook.bind(this);
53
+ this.sendToConsole = this.sendToConsole.bind(this);
54
+ this.renderItem = this.renderItem.bind(this);
55
+ this.runInConsole = this.runInConsole.bind(this);
56
+ this.sendToNotebook = this.sendToNotebook.bind(this);
57
+ this.handleSelect = this.handleSelect.bind(this);
58
+ this.handleSelectionChange = this.handleSelectionChange.bind(this);
59
+ this.handleSearchChange = this.handleSearchChange.bind(this);
60
+ this.handleViewportChange = this.handleViewportChange.bind(this);
61
+ this.handleViewportUpdate = this.handleViewportUpdate.bind(this);
62
+ this.itemActions = [{
79
63
  title: 'Copy Selection',
80
64
  description: 'Copy selected commands to clipboard',
81
65
  icon: vsFiles,
82
66
  shortcut: GLOBAL_SHORTCUTS.COPY,
83
- action: _this.copySelectedCommands,
67
+ action: this.copySelectedCommands,
84
68
  group: ContextActions.groups.edit
85
69
  }, {
86
70
  title: 'Send to Console',
87
71
  description: 'Open selected commands in the console',
88
72
  icon: vsTerminal,
89
73
  shortcut: SHORTCUTS.COMMAND_HISTORY.SEND_TO_CONSOLE,
90
- action: _this.sendToConsole,
74
+ action: this.sendToConsole,
91
75
  group: CommandHistory.menuGroups.send,
92
76
  order: 10
93
77
  }, {
@@ -95,7 +79,7 @@ var CommandHistory = /*#__PURE__*/function (_Component) {
95
79
  description: 'Run selected commands in the console',
96
80
  icon: vsPlay,
97
81
  shortcut: SHORTCUTS.COMMAND_HISTORY.RUN,
98
- action: _this.runInConsole,
82
+ action: this.runInConsole,
99
83
  group: CommandHistory.menuGroups.send,
100
84
  order: 10
101
85
  }, {
@@ -103,36 +87,38 @@ var CommandHistory = /*#__PURE__*/function (_Component) {
103
87
  description: 'Open selected commands in a notebook',
104
88
  icon: vsFileCode,
105
89
  shortcut: SHORTCUTS.COMMAND_HISTORY.SEND_TO_NOTEBOOK,
106
- action: _this.sendToNotebook,
90
+ action: this.sendToNotebook,
107
91
  group: CommandHistory.menuGroups.send,
108
92
  order: 20
109
93
  }, {
110
94
  title: 'Send to New Notebook',
111
95
  description: 'Open selected commands in a new notebook',
112
96
  icon: vsNewFile,
113
- action: _this.createNotebook,
97
+ action: this.createNotebook,
114
98
  group: CommandHistory.menuGroups.send,
115
99
  order: 30
116
100
  }];
117
- _this.historyActions = [{
101
+ this.historyActions = [{
118
102
  title: 'Send to Console',
119
103
  icon: vsTerminal,
120
104
  selectionRequired: true,
121
105
  description: 'Open selected commands in the console',
122
- action: _this.sendToConsole
106
+ action: this.sendToConsole
123
107
  }, {
124
108
  title: 'Send to Notebook',
125
109
  icon: vsFileCode,
126
110
  selectionRequired: true,
127
111
  description: 'Open selected commands in a notebook',
128
- action: _this.sendToNotebook
112
+ action: this.sendToNotebook
129
113
  }];
130
- _this.pending = new Pending();
131
- _this.searchInputRef = /*#__PURE__*/React.createRef();
132
- var table = props.table;
133
- _this.state = {
114
+ this.pending = new Pending();
115
+ this.searchInputRef = /*#__PURE__*/React.createRef();
116
+ var {
117
+ table
118
+ } = props;
119
+ this.state = {
134
120
  actions: [],
135
- historyActions: _this.historyActions,
121
+ historyActions: this.historyActions,
136
122
  top: 0,
137
123
  bottom: 0,
138
124
  itemCount: table.size,
@@ -141,335 +127,260 @@ var CommandHistory = /*#__PURE__*/function (_Component) {
141
127
  selectedRanges: [],
142
128
  searchText: ''
143
129
  };
144
- return _this;
145
130
  }
146
131
 
147
- _createClass(CommandHistory, [{
148
- key: "componentWillUnmount",
149
- value: function componentWillUnmount() {
150
- this.pending.cancel();
151
- }
152
- /**
153
- * Retrieves the selected commands as an array.
154
- * If they're not within the current viewport, will fetch them from the table
155
- * @returns {Promise<string[]>} Array of selected commands
156
- */
157
-
158
- }, {
159
- key: "getSelectedCommands",
160
- value: function () {
161
- var _getSelectedCommands = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
162
- var _this$state, items, offset, selectedRanges, ranges, table;
163
-
164
- return regeneratorRuntime.wrap(function _callee$(_context) {
165
- while (1) {
166
- switch (_context.prev = _context.next) {
167
- case 0:
168
- _this$state = this.state, items = _this$state.items, offset = _this$state.offset, selectedRanges = _this$state.selectedRanges;
169
- ranges = selectedRanges.slice().sort(function (a, b) {
170
- return a[0] - b[0];
171
- });
172
-
173
- if (!(ranges.length === 0)) {
174
- _context.next = 4;
175
- break;
176
- }
177
-
178
- return _context.abrupt("return", []);
179
-
180
- case 4:
181
- if (!(ranges[0][0] >= offset && ranges[ranges.length - 1][1] < offset + items.length)) {
182
- _context.next = 6;
183
- break;
184
- }
185
-
186
- return _context.abrupt("return", CommandHistory.getCommandsFromViewport(items, offset, ranges));
187
-
188
- case 6:
189
- table = this.props.table;
190
- return _context.abrupt("return", this.pending.add(CommandHistory.getCommandsFromSnapshot(table, ranges)));
191
-
192
- case 8:
193
- case "end":
194
- return _context.stop();
195
- }
196
- }
197
- }, _callee, this);
198
- }));
199
-
200
- function getSelectedCommands() {
201
- return _getSelectedCommands.apply(this, arguments);
132
+ componentWillUnmount() {
133
+ this.pending.cancel();
134
+ }
135
+ /**
136
+ * Retrieves the selected commands as an array.
137
+ * If they're not within the current viewport, will fetch them from the table
138
+ * @returns {Promise<string[]>} Array of selected commands
139
+ */
140
+
141
+
142
+ getSelectedCommands() {
143
+ var _this = this;
144
+
145
+ return _asyncToGenerator(function* () {
146
+ var {
147
+ items,
148
+ offset,
149
+ selectedRanges
150
+ } = _this.state;
151
+ var ranges = selectedRanges.slice().sort((a, b) => a[0] - b[0]);
152
+
153
+ if (ranges.length === 0) {
154
+ return [];
202
155
  }
203
156
 
204
- return getSelectedCommands;
205
- }()
206
- /**
207
- * Retrieves the text of all the currently selected commands, joined by a new line char
208
- * @returns {Promise<string>} The commands joined by \n char
209
- */
210
-
211
- }, {
212
- key: "getSelectedCommandText",
213
- value: function getSelectedCommandText() {
214
- return this.getSelectedCommands().then(function (commands) {
215
- return commands.join('\n');
216
- });
217
- }
218
- }, {
219
- key: "updateActions",
220
- value: function updateActions() {
221
- var _this2 = this;
222
-
223
- this.setState(function (state) {
224
- var selectedRanges = state.selectedRanges;
225
- var selectedRowCount = selectedRanges.reduce(function (count, range) {
226
- return count + range[1] - range[0] + 1;
227
- }, 0);
228
-
229
- if (selectedRowCount > 0 && selectedRowCount < CommandHistory.MAX_SELECTION_COUNT) {
230
- log.debug('Updating actions', _this2.itemActions);
231
- return {
232
- actions: _this2.itemActions
233
- };
234
- }
157
+ if (ranges[0][0] >= offset && ranges[ranges.length - 1][1] < offset + items.length) {
158
+ // All ranges are in the current viewport, just copy the data we've already got
159
+ return CommandHistory.getCommandsFromViewport(items, offset, ranges);
160
+ }
235
161
 
236
- log.debug('Disabling actions', selectedRowCount);
162
+ var {
163
+ table
164
+ } = _this.props;
165
+ return _this.pending.add(CommandHistory.getCommandsFromSnapshot(table, ranges));
166
+ })();
167
+ }
168
+ /**
169
+ * Retrieves the text of all the currently selected commands, joined by a new line char
170
+ * @returns {Promise<string>} The commands joined by \n char
171
+ */
172
+
173
+
174
+ getSelectedCommandText() {
175
+ return this.getSelectedCommands().then(commands => commands.join('\n'));
176
+ }
177
+
178
+ updateActions() {
179
+ this.setState(state => {
180
+ var {
181
+ selectedRanges
182
+ } = state;
183
+ var selectedRowCount = selectedRanges.reduce((count, range) => count + range[1] - range[0] + 1, 0);
184
+
185
+ if (selectedRowCount > 0 && selectedRowCount < CommandHistory.MAX_SELECTION_COUNT) {
186
+ log.debug('Updating actions', this.itemActions);
237
187
  return {
238
- actions: []
188
+ actions: this.itemActions
239
189
  };
240
- });
241
- }
242
- }, {
243
- key: "copySelectedCommands",
244
- value: function copySelectedCommands() {
245
- this.getSelectedCommandText().then(ContextActionUtils.copyToClipboard)["catch"](log.error);
246
- }
247
- }, {
248
- key: "createNotebook",
249
- value: function createNotebook() {
250
- var _this3 = this;
251
-
252
- this.getSelectedCommandText().then(function (commandText) {
253
- var _this3$props = _this3.props,
254
- language = _this3$props.language,
255
- sendToNotebook = _this3$props.sendToNotebook;
256
- sendToNotebook({
257
- value: commandText,
258
- language: language
259
- }, true);
260
- })["catch"](log.error);
261
- }
262
- }, {
263
- key: "sendToNotebook",
264
- value: function sendToNotebook() {
265
- var _this4 = this;
266
-
267
- this.getSelectedCommandText().then(function (commandText) {
268
- var _this4$props = _this4.props,
269
- language = _this4$props.language,
270
- sendToNotebook = _this4$props.sendToNotebook;
271
- sendToNotebook({
272
- value: commandText,
273
- language: language
274
- });
275
- })["catch"](log.error);
276
- }
277
- }, {
278
- key: "sendToConsole",
279
- value: function sendToConsole() {
280
- var sendToConsole = this.props.sendToConsole;
281
- this.getSelectedCommandText().then(sendToConsole)["catch"](log.error);
282
- }
283
- }, {
284
- key: "runInConsole",
285
- value: function runInConsole() {
286
- var _this5 = this;
287
-
288
- this.getSelectedCommandText().then(function (commandText) {
289
- var sendToConsole = _this5.props.sendToConsole;
290
- sendToConsole(commandText, true, true);
291
- })["catch"](log.error);
292
- }
293
- }, {
294
- key: "handleSelect",
295
- value: function handleSelect(index) {
296
- var sendToConsole = this.props.sendToConsole;
297
- var _this$state2 = this.state,
298
- items = _this$state2.items,
299
- offset = _this$state2.offset;
300
-
301
- if (index < offset || index >= offset + items.length) {
302
- log.error('Invalid index!', index);
303
- return;
304
190
  }
305
191
 
306
- var name = items[index - offset].name;
307
- sendToConsole(name);
308
- }
309
- }, {
310
- key: "handleSelectionChange",
311
- value: function handleSelectionChange(selectedRanges) {
312
- this.setState({
313
- selectedRanges: selectedRanges
314
- });
315
- this.updateActions();
316
- }
317
- }, {
318
- key: "handleViewportChange",
319
- value: function handleViewportChange(top, bottom) {
320
- this.setState({
321
- top: top,
322
- bottom: bottom
323
- });
324
- }
325
- }, {
326
- key: "handleSearchChange",
327
- value: function handleSearchChange(e) {
328
- this.setState({
329
- searchText: e.target.value
330
- });
331
- }
332
- }, {
333
- key: "handleViewportUpdate",
334
- value: function handleViewportUpdate(_ref) {
335
- var items = _ref.items,
336
- offset = _ref.offset;
337
- var table = this.props.table;
338
- var itemCount = table.size;
339
- this.setState({
340
- items: items,
341
- itemCount: itemCount,
342
- offset: offset
343
- });
344
- }
345
- }, {
346
- key: "renderItem",
347
- value: function renderItem(_ref2) {
348
- var item = _ref2.item,
349
- itemIndex = _ref2.itemIndex,
350
- isSelected = _ref2.isSelected;
351
- var language = this.props.language;
352
- return /*#__PURE__*/React.createElement(CommandHistoryItem, {
353
- itemIndex: itemIndex,
354
- isSelected: isSelected,
355
- item: item,
356
- language: language
192
+ log.debug('Disabling actions', selectedRowCount);
193
+ return {
194
+ actions: []
195
+ };
196
+ });
197
+ }
198
+
199
+ copySelectedCommands() {
200
+ this.getSelectedCommandText().then(ContextActionUtils.copyToClipboard).catch(log.error);
201
+ }
202
+
203
+ createNotebook() {
204
+ this.getSelectedCommandText().then(commandText => {
205
+ var {
206
+ language,
207
+ sendToNotebook
208
+ } = this.props;
209
+ sendToNotebook({
210
+ value: commandText,
211
+ language
212
+ }, true);
213
+ }).catch(log.error);
214
+ }
215
+
216
+ sendToNotebook() {
217
+ this.getSelectedCommandText().then(commandText => {
218
+ var {
219
+ language,
220
+ sendToNotebook
221
+ } = this.props;
222
+ sendToNotebook({
223
+ value: commandText,
224
+ language
357
225
  });
226
+ }).catch(log.error);
227
+ }
228
+
229
+ sendToConsole() {
230
+ var {
231
+ sendToConsole
232
+ } = this.props;
233
+ this.getSelectedCommandText().then(sendToConsole).catch(log.error);
234
+ }
235
+
236
+ runInConsole() {
237
+ this.getSelectedCommandText().then(commandText => {
238
+ var {
239
+ sendToConsole
240
+ } = this.props;
241
+ sendToConsole(commandText, true, true);
242
+ }).catch(log.error);
243
+ }
244
+
245
+ handleSelect(index) {
246
+ var {
247
+ sendToConsole
248
+ } = this.props;
249
+ var {
250
+ items,
251
+ offset
252
+ } = this.state;
253
+
254
+ if (index < offset || index >= offset + items.length) {
255
+ log.error('Invalid index!', index);
256
+ return;
358
257
  }
359
- }, {
360
- key: "focus",
361
- value: function focus() {
362
- if (this.searchInputRef.current) {
363
- this.searchInputRef.current.focus();
364
- }
365
- }
366
- }, {
367
- key: "render",
368
- value: function render() {
369
- var _this$props = this.props,
370
- language = _this$props.language,
371
- table = _this$props.table;
372
- var _this$state3 = this.state,
373
- actions = _this$state3.actions,
374
- historyActions = _this$state3.historyActions,
375
- searchText = _this$state3.searchText,
376
- top = _this$state3.top,
377
- bottom = _this$state3.bottom,
378
- items = _this$state3.items,
379
- itemCount = _this$state3.itemCount,
380
- offset = _this$state3.offset,
381
- selectedRanges = _this$state3.selectedRanges;
382
- var languageDisplayString = ConsoleConstants.LANGUAGE_MAP.get(language);
383
- return /*#__PURE__*/React.createElement("div", {
384
- className: "command-history"
385
- }, /*#__PURE__*/React.createElement("div", {
386
- className: "command-history-search-bar"
387
- }, /*#__PURE__*/React.createElement(SearchInput, {
388
- ref: this.searchInputRef,
389
- value: searchText,
390
- placeholder: "".concat(languageDisplayString, " Command History"),
391
- onChange: this.handleSearchChange
392
- }), /*#__PURE__*/React.createElement(CommandHistoryActions, {
393
- actions: historyActions,
394
- hasSelection: selectedRanges.length > 0
395
- })), /*#__PURE__*/React.createElement("div", {
396
- className: "command-history-list"
397
- }, /*#__PURE__*/React.createElement(ItemList, {
398
- itemCount: itemCount,
399
- items: items,
400
- offset: offset,
401
- onSelect: this.handleSelect,
402
- onSelectionChange: this.handleSelectionChange,
403
- onViewportChange: this.handleViewportChange,
404
- renderItem: this.renderItem,
405
- rowHeight: CommandHistory.ITEM_HEIGHT,
406
- isDoubleClickSelect: true,
407
- isMultiSelect: true,
408
- isStickyBottom: true
409
- }), /*#__PURE__*/React.createElement(CommandHistoryViewportUpdater, {
410
- table: table,
411
- top: top,
412
- bottom: bottom,
413
- search: searchText,
414
- onUpdate: this.handleViewportUpdate
415
- }), /*#__PURE__*/React.createElement(ContextActions, {
416
- actions: actions
417
- })));
418
- }
419
- }], [{
420
- key: "getCommandsFromViewport",
421
- value: function getCommandsFromViewport(items, offset, sortedRanges) {
422
- var commands = [];
423
-
424
- for (var i = 0; i < sortedRanges.length; i += 1) {
425
- var range = sortedRanges[i];
426
-
427
- for (var j = range[0]; j <= range[1]; j += 1) {
428
- if (j >= offset && j < offset + items.length) {
429
- var name = items[j - offset].name;
430
- commands.push(name);
431
- }
432
- }
433
- }
434
258
 
435
- return commands;
259
+ var {
260
+ name
261
+ } = items[index - offset];
262
+ sendToConsole(name);
263
+ }
264
+
265
+ handleSelectionChange(selectedRanges) {
266
+ this.setState({
267
+ selectedRanges
268
+ });
269
+ this.updateActions();
270
+ }
271
+
272
+ handleViewportChange(top, bottom) {
273
+ this.setState({
274
+ top,
275
+ bottom
276
+ });
277
+ }
278
+
279
+ handleSearchChange(e) {
280
+ // clear selected range, as old selection could be filtered from list
281
+ this.setState({
282
+ searchText: e.target.value,
283
+ selectedRanges: []
284
+ });
285
+ }
286
+
287
+ handleViewportUpdate(_ref) {
288
+ var {
289
+ items,
290
+ offset
291
+ } = _ref;
292
+ var {
293
+ table
294
+ } = this.props;
295
+ var itemCount = table.size;
296
+ this.setState({
297
+ items,
298
+ itemCount,
299
+ offset
300
+ });
301
+ }
302
+
303
+ renderItem(_ref2) {
304
+ var {
305
+ item,
306
+ itemIndex,
307
+ isSelected
308
+ } = _ref2;
309
+ var {
310
+ language,
311
+ commandHistoryStorage
312
+ } = this.props;
313
+ return /*#__PURE__*/React.createElement(CommandHistoryItem, {
314
+ itemIndex: itemIndex,
315
+ isSelected: isSelected,
316
+ item: item,
317
+ language: language,
318
+ commandHistoryStorage: commandHistoryStorage
319
+ });
320
+ }
321
+
322
+ focus() {
323
+ if (this.searchInputRef.current) {
324
+ this.searchInputRef.current.focus();
436
325
  }
437
- }, {
438
- key: "getCommandsFromSnapshot",
439
- value: function () {
440
- var _getCommandsFromSnapshot = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(table, sortedRanges) {
441
- var items;
442
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
443
- while (1) {
444
- switch (_context2.prev = _context2.next) {
445
- case 0:
446
- _context2.next = 2;
447
- return table.getSnapshot(sortedRanges);
448
-
449
- case 2:
450
- items = _context2.sent;
451
- return _context2.abrupt("return", _toConsumableArray(items.values()).map(function (item) {
452
- return item.name;
453
- }));
454
-
455
- case 4:
456
- case "end":
457
- return _context2.stop();
458
- }
459
- }
460
- }, _callee2);
461
- }));
462
-
463
- function getCommandsFromSnapshot(_x, _x2) {
464
- return _getCommandsFromSnapshot.apply(this, arguments);
465
- }
326
+ }
466
327
 
467
- return getCommandsFromSnapshot;
468
- }()
469
- }]);
328
+ render() {
329
+ var {
330
+ language,
331
+ table
332
+ } = this.props;
333
+ var {
334
+ actions,
335
+ historyActions,
336
+ searchText,
337
+ top,
338
+ bottom,
339
+ items,
340
+ itemCount,
341
+ offset,
342
+ selectedRanges
343
+ } = this.state;
344
+ var languageDisplayString = ConsoleConstants.LANGUAGE_MAP.get(language);
345
+ return /*#__PURE__*/React.createElement("div", {
346
+ className: "command-history"
347
+ }, /*#__PURE__*/React.createElement("div", {
348
+ className: "command-history-search-bar"
349
+ }, /*#__PURE__*/React.createElement(SearchInput, {
350
+ ref: this.searchInputRef,
351
+ value: searchText,
352
+ placeholder: "".concat(languageDisplayString, " Command History"),
353
+ onChange: this.handleSearchChange
354
+ }), /*#__PURE__*/React.createElement(CommandHistoryActions, {
355
+ actions: historyActions,
356
+ hasSelection: selectedRanges.length > 0
357
+ })), /*#__PURE__*/React.createElement("div", {
358
+ className: "command-history-list"
359
+ }, /*#__PURE__*/React.createElement(ItemList, {
360
+ itemCount: itemCount,
361
+ items: items,
362
+ offset: offset,
363
+ selectedRanges: selectedRanges,
364
+ onSelect: this.handleSelect,
365
+ onSelectionChange: this.handleSelectionChange,
366
+ onViewportChange: this.handleViewportChange,
367
+ renderItem: this.renderItem,
368
+ rowHeight: CommandHistory.ITEM_HEIGHT,
369
+ isDoubleClickSelect: true,
370
+ isMultiSelect: true,
371
+ isStickyBottom: true
372
+ }), /*#__PURE__*/React.createElement(CommandHistoryViewportUpdater, {
373
+ table: table,
374
+ top: top,
375
+ bottom: bottom,
376
+ search: searchText,
377
+ onUpdate: this.handleViewportUpdate
378
+ }), /*#__PURE__*/React.createElement(ContextActions, {
379
+ actions: actions
380
+ })));
381
+ }
470
382
 
471
- return CommandHistory;
472
- }(Component);
383
+ }
473
384
 
474
385
  _defineProperty(CommandHistory, "ITEM_HEIGHT", 29);
475
386
 
@@ -483,7 +394,8 @@ CommandHistory.propTypes = {
483
394
  language: PropTypes.string.isRequired,
484
395
  sendToConsole: PropTypes.func.isRequired,
485
396
  sendToNotebook: PropTypes.func.isRequired,
486
- table: StoragePropTypes.CommandHistoryTable.isRequired
397
+ table: StoragePropTypes.CommandHistoryTable.isRequired,
398
+ commandHistoryStorage: StoragePropTypes.CommandHistoryStorage.isRequired
487
399
  };
488
400
  export default CommandHistory;
489
401
  //# sourceMappingURL=CommandHistory.js.map