@mongodb-js/compass-shell 3.3.0 → 3.5.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/lib/2.js DELETED
@@ -1,507 +0,0 @@
1
- (window["webpackJsonpCompassShellPlugin"] = window["webpackJsonpCompassShellPlugin"] || []).push([[2],{
2
-
3
- /***/ 473:
4
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
5
-
6
- "use strict";
7
- // ESM COMPAT FLAG
8
- __webpack_require__.r(__webpack_exports__);
9
-
10
- // EXPORTS
11
- __webpack_require__.d(__webpack_exports__, "CompassShell", function() { return /* reexport */ compass_shell_CompassShell; });
12
-
13
- // EXTERNAL MODULE: external "react"
14
- var external_react_ = __webpack_require__(2);
15
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
16
-
17
- // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/prop-types/index.js
18
- var prop_types = __webpack_require__(244);
19
- var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
20
-
21
- // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/react-redux/es/index.js + 26 modules
22
- var es = __webpack_require__(128);
23
-
24
- // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/@mongosh/browser-repl/lib/mongosh-browser-repl.js
25
- var mongosh_browser_repl = __webpack_require__(281);
26
-
27
- // EXTERNAL MODULE: external "@mongodb-js/compass-components"
28
- var compass_components_ = __webpack_require__(242);
29
-
30
- // CONCATENATED MODULE: ./src/components/shell-info-modal/keyboard-shortcuts-table.jsx
31
-
32
-
33
- const rowStyles = Object(compass_components_["css"])({
34
- td: {
35
- padding: 0
36
- }
37
- });
38
- const hotkeys = [{
39
- key: 'Ctrl+`',
40
- description: 'Toggle shell.'
41
- }, {
42
- key: 'Ctrl+A',
43
- description: 'Moves the cursor to the beginning of the line.'
44
- }, {
45
- key: 'Ctrl+B',
46
- description: 'Moves the cursor Backward one character.'
47
- }, {
48
- key: 'Ctrl+C',
49
- description: 'Stop currently running command.'
50
- }, {
51
- key: 'Ctrl+D',
52
- description: 'Deletes the next character.'
53
- }, {
54
- key: 'Ctrl+E',
55
- description: 'Moves the cursor to the end of the line.'
56
- }, {
57
- key: 'Ctrl+F',
58
- description: 'Moves the cursor Forward one character.'
59
- }, {
60
- key: 'Ctrl+H',
61
- description: 'Erases one character, similar to hitting backspace.'
62
- }, {
63
- key: 'Ctrl/Cmd+L',
64
- description: 'Clears the screen, similar to the clear command.'
65
- }, {
66
- key: 'Ctrl+T',
67
- description: 'Swap the last two characters before the cursor.'
68
- }, {
69
- key: 'Ctrl+U',
70
- description: 'Changes the line to Uppercase.'
71
- }, {
72
- key: '\u2191',
73
- description: 'Cycle backwards through command history.'
74
- }, {
75
- key: '\u2193',
76
- description: 'Cycle forwards through command history.'
77
- }];
78
- function KeyboardShortcutsTable() {
79
- return /*#__PURE__*/external_react_default.a.createElement(compass_components_["Table"], {
80
- data: hotkeys,
81
- columns: [/*#__PURE__*/external_react_default.a.createElement(compass_components_["TableHeader"], {
82
- key: 'name',
83
- label: "Key"
84
- }), /*#__PURE__*/external_react_default.a.createElement(compass_components_["TableHeader"], {
85
- key: 'value',
86
- label: "Description"
87
- })]
88
- }, ({
89
- datum
90
- }) => /*#__PURE__*/external_react_default.a.createElement(compass_components_["Row"], {
91
- className: rowStyles,
92
- key: datum.key
93
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Cell"], null, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Body"], {
94
- weight: "medium"
95
- }, datum.key)), /*#__PURE__*/external_react_default.a.createElement(compass_components_["Cell"], null, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Description"], null, datum.description))));
96
- }
97
-
98
- // CONCATENATED MODULE: ./src/components/shell-info-modal/shell-info-modal.jsx
99
-
100
-
101
-
102
-
103
- const mongoshVersion = `v${__webpack_require__(469).version}`;
104
- const shortcutsTableContainerStyles = Object(compass_components_["css"])({
105
- marginTop: compass_components_["spacing"][2],
106
- maxHeight: '50vh',
107
- overflow: 'auto'
108
- });
109
- const shortcutsTitleStyles = Object(compass_components_["css"])({
110
- marginTop: compass_components_["spacing"][4]
111
- });
112
- function ShellInfoModal({
113
- hideInfoModal,
114
- show
115
- }) {
116
- const onClose = Object(external_react_["useCallback"])(() => {
117
- hideInfoModal();
118
- }, [hideInfoModal]);
119
- return /*#__PURE__*/external_react_default.a.createElement(compass_components_["InfoModal"], {
120
- open: show,
121
- title: `mongosh ${mongoshVersion}`,
122
- trackingId: "shell_info_modal",
123
- "data-testid": "shell-info-modal",
124
- onClose: onClose
125
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Banner"], null, "For more information please visit the\xA0", /*#__PURE__*/external_react_default.a.createElement(compass_components_["Link"], {
126
- id: "mongosh-info-link",
127
- href: "https://docs.mongodb.com/compass/beta/embedded-shell/",
128
- target: "_blank"
129
- }, "MongoDB Shell Documentation"), "."), /*#__PURE__*/external_react_default.a.createElement(compass_components_["Subtitle"], {
130
- className: shortcutsTitleStyles
131
- }, "Keyboard Shortcuts"), /*#__PURE__*/external_react_default.a.createElement("div", {
132
- className: shortcutsTableContainerStyles
133
- }, /*#__PURE__*/external_react_default.a.createElement(KeyboardShortcutsTable, null)));
134
- }
135
- ShellInfoModal.propTypes = {
136
- hideInfoModal: prop_types_default.a.func.isRequired,
137
- show: prop_types_default.a.bool.isRequired
138
- };
139
- /* harmony default export */ var shell_info_modal = (ShellInfoModal);
140
- // CONCATENATED MODULE: ./src/components/shell-info-modal/index.js
141
-
142
- /* harmony default export */ var components_shell_info_modal = (shell_info_modal);
143
- // CONCATENATED MODULE: ./src/components/shell-header/shell-header.jsx
144
- 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; }
145
-
146
-
147
-
148
-
149
- const shellHeaderStyles = Object(compass_components_["css"])({
150
- height: compass_components_["spacing"][5],
151
- display: 'flex',
152
- color: compass_components_["palette"].gray.light1
153
- });
154
- const shellHeaderLeftStyles = Object(compass_components_["css"])({
155
- flexGrow: 1,
156
- display: 'flex',
157
- alignItems: 'center'
158
- });
159
- const shellHeaderDefaultColor = compass_components_["palette"].gray.light1;
160
- const shellHeaderFlashColorDark = compass_components_["palette"].gray.base;
161
- const shellHeaderFlashColorLight = compass_components_["palette"].gray.light2;
162
- const shellLoaderFlash = compass_components_["keyframes"]`
163
- 0% { color: ${shellHeaderDefaultColor}; }
164
- 10% { color: ${shellHeaderFlashColorDark}; }
165
- 20% { color: ${shellHeaderFlashColorLight}; }
166
- 30% { color: ${shellHeaderFlashColorDark}; }
167
- 40% { color: ${shellHeaderFlashColorLight}; }
168
- 50% { color: ${shellHeaderFlashColorDark}; }
169
- 60% { color: ${shellHeaderFlashColorLight}; }
170
- 70% { color: ${shellHeaderFlashColorDark}; }
171
- 80% { color: ${shellHeaderFlashColorLight}; }
172
- 100% { color: ${shellHeaderDefaultColor}; }
173
- `;
174
- const shellHeaderToggleStyles = Object(compass_components_["css"])({
175
- background: 'none',
176
- border: 'none',
177
- cursor: 'pointer',
178
- color: shellHeaderDefaultColor,
179
- padding: `0px ${compass_components_["spacing"][2]}px`,
180
- height: '100%',
181
- display: 'flex',
182
- verticalAlign: 'middle',
183
- flexDirection: 'row',
184
- alignItems: 'center',
185
- margin: 'auto 0',
186
- fontWeight: 'bold',
187
- fontSize: compass_components_["spacing"][2] * 1.5,
188
- lineHeight: `${compass_components_["spacing"][5]}px`,
189
- transition: 'all 200ms',
190
- userSelect: 'none',
191
- textTransform: 'uppercase',
192
- animation: `${shellLoaderFlash} 2s linear`,
193
- '&:hover': {
194
- color: compass_components_["palette"].gray.light3
195
- }
196
- });
197
- const shellHeaderRightStyles = Object(compass_components_["css"])({
198
- display: 'flex',
199
- paddingTop: compass_components_["spacing"][1] / 2,
200
- paddingRight: compass_components_["spacing"][2]
201
- });
202
- const infoButtonStyles = Object(compass_components_["css"])({
203
- marginRight: compass_components_["spacing"][2]
204
- });
205
- const operationInProgressStyles = Object(compass_components_["css"])({
206
- color: compass_components_["palette"].green.light2,
207
- marginLeft: compass_components_["spacing"][2]
208
- });
209
- class shell_header_ShellHeader extends external_react_["Component"] {
210
- componentDidMount() {
211
- document.addEventListener('keydown', this.handleKeyboardToggle.bind(this));
212
- }
213
- componentWillUnmount() {
214
- document.removeEventListener('keydown', this.handleKeyboardToggle.bind(this));
215
- }
216
- handleKeyboardToggle({
217
- ctrlKey,
218
- key
219
- }) {
220
- if (ctrlKey && key === '`') {
221
- this.props.onShellToggleClicked();
222
- }
223
- }
224
-
225
- /**
226
- * Render ShellHeader component.
227
- *
228
- * @returns {React.Component} The rendered component.
229
- */
230
- render() {
231
- const {
232
- isExpanded,
233
- isOperationInProgress,
234
- onShellToggleClicked,
235
- showInfoModal
236
- } = this.props;
237
- return /*#__PURE__*/external_react_default.a.createElement("div", {
238
- className: shellHeaderStyles
239
- }, /*#__PURE__*/external_react_default.a.createElement("div", {
240
- className: shellHeaderLeftStyles
241
- }, /*#__PURE__*/external_react_default.a.createElement("button", {
242
- type: "button",
243
- "data-testid": "shell-expand-button",
244
- className: shellHeaderToggleStyles,
245
- "aria-label": isExpanded ? 'Close Shell' : 'Open Shell',
246
- onClick: onShellToggleClicked,
247
- "aria-pressed": isExpanded
248
- }, ">_MONGOSH", !isExpanded && isOperationInProgress && /*#__PURE__*/external_react_default.a.createElement("span", {
249
- className: operationInProgressStyles
250
- }, /*#__PURE__*/external_react_default.a.createElement(mongosh_browser_repl["ShellLoader"], {
251
- size: "12px"
252
- }), "\xA0Command in progress\u2026"))), /*#__PURE__*/external_react_default.a.createElement("div", {
253
- className: shellHeaderRightStyles
254
- }, isExpanded && /*#__PURE__*/external_react_default.a.createElement(compass_components_["IconButton"], {
255
- "data-testid": "shell-info-button",
256
- className: infoButtonStyles,
257
- variant: "dark",
258
- "aria-label": "Shell Info",
259
- "aria-haspopup": "dialog",
260
- onClick: showInfoModal
261
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Icon"], {
262
- glyph: "InfoWithCircle",
263
- size: "small"
264
- })), /*#__PURE__*/external_react_default.a.createElement(compass_components_["IconButton"], {
265
- variant: "dark",
266
- "aria-label": isExpanded ? 'Close Shell' : 'Open Shell',
267
- onClick: onShellToggleClicked,
268
- "aria-pressed": isExpanded
269
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Icon"], {
270
- glyph: isExpanded ? 'ChevronDown' : 'ChevronUp',
271
- size: "small"
272
- }))));
273
- }
274
- }
275
- _defineProperty(shell_header_ShellHeader, "propTypes", {
276
- isExpanded: prop_types_default.a.bool.isRequired,
277
- isOperationInProgress: prop_types_default.a.bool.isRequired,
278
- onShellToggleClicked: prop_types_default.a.func.isRequired,
279
- showInfoModal: prop_types_default.a.func.isRequired
280
- });
281
- /* harmony default export */ var shell_header = (shell_header_ShellHeader);
282
- // CONCATENATED MODULE: ./src/components/shell-header/index.js
283
-
284
- /* harmony default export */ var components_shell_header = (shell_header);
285
-
286
- // CONCATENATED MODULE: ./src/components/compass-shell/compass-shell.jsx
287
- function compass_shell_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; }
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
- const compassShellStyles = Object(compass_components_["css"])({
296
- backgroundColor: compass_components_["palette"].gray.dark3,
297
- display: 'flex',
298
- flexBasis: 'auto',
299
- position: 'relative',
300
- flexDirection: 'column'
301
- });
302
- const compassShellContainerStyles = Object(compass_components_["css"])({
303
- flexGrow: 1,
304
- display: 'none',
305
- overflow: 'auto',
306
- borderTop: `1px solid ${compass_components_["palette"].gray.dark2}`,
307
- '*::-webkit-scrollbar-thumb': {
308
- background: Object(compass_components_["rgba"])(compass_components_["palette"].gray.light1, 0.5)
309
- }
310
- });
311
- const compassShellContainerVisibleStyles = Object(compass_components_["css"])({
312
- display: 'flex'
313
- });
314
- const defaultShellHeightOpened = 240;
315
- const shellHeightClosed = 32;
316
- const shellMinHeightOpened = 100;
317
- function getMaxShellHeight() {
318
- return Math.max(defaultShellHeightOpened, window.innerHeight - 100);
319
- }
320
-
321
- // Apply bounds to the shell height when resizing to ensure it's always
322
- // visible and usable to the user.
323
- function boundShellHeight(attemptedHeight) {
324
- const maxHeight = getMaxShellHeight();
325
- return Math.min(maxHeight, Math.max(shellMinHeightOpened, attemptedHeight));
326
- }
327
- class compass_shell_CompassShell extends external_react_["Component"] {
328
- constructor(props) {
329
- super(props);
330
- compass_shell_defineProperty(this, "onShellOutputChanged", output => {
331
- this.shellOutput = output;
332
- });
333
- compass_shell_defineProperty(this, "onOperationStarted", () => {
334
- this.setState({
335
- isOperationInProgress: true
336
- });
337
- });
338
- compass_shell_defineProperty(this, "onOperationEnd", () => {
339
- this.setState({
340
- isOperationInProgress: false
341
- });
342
- });
343
- compass_shell_defineProperty(this, "terminateRuntime", () => {
344
- if (this.props.runtime) {
345
- this.props.runtime.terminate();
346
- }
347
- });
348
- compass_shell_defineProperty(this, "saveHistory", async history => {
349
- if (!this.props.historyStorage) {
350
- return;
351
- }
352
- try {
353
- await this.props.historyStorage.save(history);
354
- } catch (error) {
355
- // eslint-disable-next-line no-console
356
- console.error(error);
357
- }
358
- });
359
- compass_shell_defineProperty(this, "loadHistory", async () => {
360
- if (!this.props.historyStorage) {
361
- return;
362
- }
363
- try {
364
- const history = await this.props.historyStorage.load();
365
- this.setState({
366
- initialHistory: history
367
- });
368
- } catch (error) {
369
- // eslint-disable-next-line no-console
370
- console.error(error);
371
- this.setState({
372
- initialHistory: []
373
- });
374
- }
375
- });
376
- this.shellRef = /*#__PURE__*/external_react_default.a.createRef();
377
- this.shellOutput = this.props.shellOutput || [];
378
- this.state = {
379
- height: shellHeightClosed,
380
- prevHeight: defaultShellHeightOpened,
381
- initialHistory: this.props.historyStorage ? null : [],
382
- isOperationInProgress: false,
383
- showInfoModal: false
384
- };
385
- }
386
- componentDidMount() {
387
- this.loadHistory();
388
- window.addEventListener('beforeunload', this.terminateRuntime);
389
- }
390
- componentDidUpdate(prevProps, prevState) {
391
- const {
392
- height
393
- } = this.state;
394
- if (prevState.height < shellMinHeightOpened && height > shellMinHeightOpened) {
395
- this.props.emitShellPluginOpened();
396
- }
397
- }
398
- componentWillUnmount() {
399
- window.removeEventListener('beforeunload', this.terminateRuntime);
400
- }
401
- updateHeight(height) {
402
- this.setState(height > shellMinHeightOpened ? {
403
- height,
404
- // Store the previous height to use when toggling open/close
405
- // when we resize while the shell is expanded.
406
- prevHeight: height
407
- } : {
408
- height
409
- });
410
- }
411
- hideInfoModal() {
412
- this.setState({
413
- showInfoModal: false
414
- });
415
- }
416
- focusEditor() {
417
- var _window$getSelection;
418
- if (this.shellRef.current && ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) !== 'Range') {
419
- this.shellRef.current.focusEditor();
420
- }
421
- }
422
-
423
- /**
424
- * Render CompassShell component.
425
- *
426
- * @returns {React.Component} The rendered component.
427
- */
428
- render() {
429
- const {
430
- height,
431
- prevHeight,
432
- isOperationInProgress,
433
- showInfoModal
434
- } = this.state;
435
- if (!this.props.runtime || !this.state.initialHistory) {
436
- return /*#__PURE__*/external_react_default.a.createElement("div", null);
437
- }
438
- const isExpanded = height > shellMinHeightOpened;
439
- const renderedHeight = isExpanded ? boundShellHeight(height) : shellHeightClosed;
440
- return /*#__PURE__*/external_react_default.a.createElement(external_react_["Fragment"], null, /*#__PURE__*/external_react_default.a.createElement(components_shell_info_modal, {
441
- show: showInfoModal,
442
- hideInfoModal: this.hideInfoModal.bind(this)
443
- }), /*#__PURE__*/external_react_default.a.createElement("div", {
444
- "data-testid": "shell-section",
445
- className: compassShellStyles,
446
- style: {
447
- height: renderedHeight
448
- },
449
- id: "content",
450
- onClick: this.focusEditor.bind(this)
451
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["ResizeHandle"], {
452
- direction: compass_components_["ResizeDirection"].TOP,
453
- onChange: newHeight => this.updateHeight(newHeight),
454
- value: height,
455
- minValue: shellHeightClosed,
456
- maxValue: getMaxShellHeight(),
457
- title: "MongoDB Shell"
458
- }), /*#__PURE__*/external_react_default.a.createElement(components_shell_header, {
459
- isExpanded: isExpanded,
460
- onShellToggleClicked: () => isExpanded ? this.updateHeight(shellHeightClosed) : this.updateHeight(prevHeight),
461
- isOperationInProgress: isOperationInProgress,
462
- showInfoModal: () => this.setState({
463
- showInfoModal: true
464
- })
465
- }), /*#__PURE__*/external_react_default.a.createElement("div", {
466
- "data-testid": "shell-content",
467
- className: Object(compass_components_["cx"])(compassShellContainerStyles, {
468
- [compassShellContainerVisibleStyles]: isExpanded
469
- })
470
- }, /*#__PURE__*/external_react_default.a.createElement(mongosh_browser_repl["Shell"], {
471
- ref: this.shellRef,
472
- runtime: this.props.runtime,
473
- initialHistory: this.state.initialHistory,
474
- initialOutput: this.shellOutput,
475
- onHistoryChanged: this.saveHistory,
476
- onOutputChanged: this.onShellOutputChanged,
477
- onOperationStarted: this.onOperationStarted,
478
- onOperationEnd: this.onOperationEnd
479
- }))));
480
- }
481
- }
482
- compass_shell_defineProperty(compass_shell_CompassShell, "propTypes", {
483
- emitShellPluginOpened: prop_types_default.a.func,
484
- runtime: prop_types_default.a.object,
485
- shellOutput: prop_types_default.a.array,
486
- historyStorage: prop_types_default.a.object
487
- });
488
- compass_shell_defineProperty(compass_shell_CompassShell, "defaultProps", {
489
- emitShellPluginOpened: () => {},
490
- runtime: null
491
- });
492
- /* harmony default export */ var compass_shell = (Object(es["b" /* connect */])(state => ({
493
- emitShellPluginOpened: () => {
494
- if (state.appRegistry && state.appRegistry.globalAppRegistry) {
495
- state.appRegistry.globalAppRegistry.emit('compass:compass-shell:opened');
496
- }
497
- },
498
- runtime: state.runtime ? state.runtime.runtime : null
499
- }))(compass_shell_CompassShell));
500
- // CONCATENATED MODULE: ./src/components/compass-shell/index.js
501
-
502
- /* harmony default export */ var components_compass_shell = __webpack_exports__["default"] = (compass_shell);
503
-
504
-
505
- /***/ })
506
-
507
- }]);
package/lib/index.html DELETED
@@ -1,9 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Webpack App</title>
6
- </head>
7
- <body>
8
- <script type="text/javascript" src="./index.js"></script></body>
9
- </html>