@mongosh/browser-repl 1.6.0 → 1.6.1

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 (97) hide show
  1. package/.depcheckrc +8 -2
  2. package/config/webpack.config.base.js +46 -61
  3. package/config/webpack.config.test.js +1 -17
  4. package/config/webpack.config.watch.js +27 -0
  5. package/lib/components/ace-autocompleter-adapter.d.ts +15 -0
  6. package/lib/components/ace-autocompleter-adapter.js +26 -0
  7. package/lib/components/ace-autocompleter-adapter.js.map +1 -0
  8. package/lib/components/editor.d.ts +41 -0
  9. package/lib/components/editor.js +140 -0
  10. package/lib/components/editor.js.map +1 -0
  11. package/lib/components/password-prompt.d.ts +12 -0
  12. package/lib/components/password-prompt.js +67 -0
  13. package/lib/components/password-prompt.js.map +1 -0
  14. package/lib/components/shell-input.d.ts +33 -0
  15. package/lib/components/shell-input.js +127 -0
  16. package/lib/components/shell-input.js.map +1 -0
  17. package/lib/components/shell-loader.d.ts +11 -0
  18. package/lib/components/shell-loader.js +42 -0
  19. package/lib/components/shell-loader.js.map +1 -0
  20. package/lib/components/shell-output-line.d.ts +23 -0
  21. package/lib/components/shell-output-line.js +135 -0
  22. package/lib/components/shell-output-line.js.map +1 -0
  23. package/lib/components/shell-output.d.ts +14 -0
  24. package/lib/components/shell-output.js +48 -0
  25. package/lib/components/shell-output.js.map +1 -0
  26. package/lib/components/shell.d.ts +61 -0
  27. package/lib/components/shell.js +283 -0
  28. package/lib/components/shell.js.map +1 -0
  29. package/lib/components/types/cursor-iteration-result-output.d.ts +19 -0
  30. package/lib/components/types/cursor-iteration-result-output.js +57 -0
  31. package/lib/components/types/cursor-iteration-result-output.js.map +1 -0
  32. package/lib/components/types/cursor-output.d.ts +16 -0
  33. package/lib/components/types/cursor-output.js +45 -0
  34. package/lib/components/types/cursor-output.js.map +1 -0
  35. package/lib/components/types/error-output.d.ts +18 -0
  36. package/lib/components/types/error-output.js +92 -0
  37. package/lib/components/types/error-output.js.map +1 -0
  38. package/lib/components/types/help-output.d.ts +25 -0
  39. package/lib/components/types/help-output.js +102 -0
  40. package/lib/components/types/help-output.js.map +1 -0
  41. package/lib/components/types/object-output.d.ts +12 -0
  42. package/lib/components/types/object-output.js +43 -0
  43. package/lib/components/types/object-output.js.map +1 -0
  44. package/lib/components/types/show-banner-result-output.d.ts +15 -0
  45. package/lib/components/types/show-banner-result-output.js +45 -0
  46. package/lib/components/types/show-banner-result-output.js.map +1 -0
  47. package/lib/components/types/show-collections-output.d.ts +17 -0
  48. package/lib/components/types/show-collections-output.js +81 -0
  49. package/lib/components/types/show-collections-output.js.map +1 -0
  50. package/lib/components/types/show-dbs-output.d.ts +17 -0
  51. package/lib/components/types/show-dbs-output.js +54 -0
  52. package/lib/components/types/show-dbs-output.js.map +1 -0
  53. package/lib/components/types/show-profile-output.d.ts +16 -0
  54. package/lib/components/types/show-profile-output.js +67 -0
  55. package/lib/components/types/show-profile-output.js.map +1 -0
  56. package/lib/components/types/simple-type-output.d.ts +14 -0
  57. package/lib/components/types/simple-type-output.js +45 -0
  58. package/lib/components/types/simple-type-output.js.map +1 -0
  59. package/lib/components/types/stats-result-output.d.ts +12 -0
  60. package/lib/components/types/stats-result-output.js +51 -0
  61. package/lib/components/types/stats-result-output.js.map +1 -0
  62. package/lib/components/utils/expandable.d.ts +12 -0
  63. package/lib/components/utils/expandable.js +53 -0
  64. package/lib/components/utils/expandable.js.map +1 -0
  65. package/lib/components/utils/inspect.d.ts +1 -0
  66. package/lib/components/utils/inspect.js +75 -0
  67. package/lib/components/utils/inspect.js.map +1 -0
  68. package/lib/components/utils/line-with-icon.d.ts +14 -0
  69. package/lib/components/utils/line-with-icon.js +59 -0
  70. package/lib/components/utils/line-with-icon.js.map +1 -0
  71. package/lib/components/utils/syntax-highlight.d.ts +12 -0
  72. package/lib/components/utils/syntax-highlight.js +53 -0
  73. package/lib/components/utils/syntax-highlight.js.map +1 -0
  74. package/lib/iframe-runtime/iframe-interpreter-environment.d.ts +7 -0
  75. package/lib/iframe-runtime/iframe-interpreter-environment.js +17 -0
  76. package/lib/iframe-runtime/iframe-interpreter-environment.js.map +1 -0
  77. package/lib/iframe-runtime/iframe-runtime.d.ts +17 -0
  78. package/lib/iframe-runtime/iframe-runtime.js +68 -0
  79. package/lib/iframe-runtime/iframe-runtime.js.map +1 -0
  80. package/lib/iframe-runtime/index.d.ts +1 -0
  81. package/lib/iframe-runtime/index.js +18 -0
  82. package/lib/iframe-runtime/index.js.map +1 -0
  83. package/lib/index.d.ts +2 -0
  84. package/lib/index.js +8 -0
  85. package/lib/index.js.map +1 -0
  86. package/lib/sandbox.d.ts +1 -0
  87. package/lib/sandbox.js +212 -0
  88. package/lib/sandbox.js.map +1 -0
  89. package/package.json +49 -52
  90. package/.babelrc +0 -11
  91. package/.storybook/main.js +0 -4
  92. package/.storybook/webpack.config.js +0 -12
  93. package/config/plain-url.js +0 -1
  94. package/config/webpack.config.prod.js +0 -21
  95. package/config/webpack.config.stats.js +0 -9
  96. package/lib/mongosh-browser-repl.js +0 -1991
  97. package/lib/mongosh-browser-repl.js.map +0 -1
package/.depcheckrc CHANGED
@@ -1,2 +1,8 @@
1
- ignores: ['css-loader', 'file-loader', 'less', 'less-loader', 'style-loader', 'ts-loader', 'webpack-cli']
2
- skip-missing: true
1
+ ignores: [
2
+ # used by webpack
3
+ 'webpack-cli',
4
+ # resolved as `<depname>/` so depcheck doesn't see it being used
5
+ 'buffer',
6
+ 'util'
7
+ ]
8
+ skip-missing: true
@@ -1,76 +1,61 @@
1
- const path = require('path');
1
+ const webpack = require('webpack');
2
2
 
3
3
  module.exports = {
4
+ target: 'web',
4
5
  stats: 'errors-only',
5
6
  resolve: {
6
7
  extensions: ['.tsx', '.ts', '.jsx', '.js', '.less'],
7
- alias: {
8
- // imports in service-provider-core that can break the browser build
9
- 'whatwg-url': path.resolve(__dirname, 'plain-url.js'),
8
+ fallback: {
9
+ // node specific and don't require a polyfill
10
+ zlib: false,
11
+ v8: false,
12
+ fs: false,
13
+ crypto: false,
14
+ // node specific and require a polyfill
15
+ // path polyfill is required for following packages:
16
+ // async-rewriter2, @mongodb-js/compass-components, mongodb-log-writer, shell-api
17
+ path: require.resolve('path-browserify'),
18
+ // stream polyfill is required for following packages:
19
+ // mongodb-log-writer, @leafygreen-ui/emotion
20
+ stream: require.resolve('stream-browserify'),
21
+ // buffer polyfill is required for following packages:
22
+ // @leafygreen-ui/emotion
23
+ buffer: require.resolve('buffer/'),
24
+ // util polyfill is required by browser-repl itself
25
+ util: require.resolve('util/'),
26
+ // compass specific
27
+ electron: false,
28
+ '@electron/remote': false,
29
+ 'hadron-ipc': false,
30
+ 'compass-preferences-model': false
10
31
  }
11
32
  },
12
33
  module: {
13
34
  rules: [
14
35
  {
15
- test: /\.js(x?)$/,
16
- exclude: /node_modules/,
36
+ test: /\.(js|jsx|ts|tsx)$/,
37
+ include: [/src/, /node_modules/],
17
38
  use: {
18
- loader: 'babel-loader'
19
- }
20
- },
21
- {
22
- test: /\.ts(x?)$/,
23
- exclude: /node_modules/,
24
- use: {
25
- loader: 'ts-loader'
26
- }
27
- },
28
- {
29
- test: /\.css$/,
30
- use: [
31
- { loader: 'style-loader' },
32
- { loader: 'css-loader' }
33
- ]
34
- },
35
- // For styles that have to be global (see https://github.com/css-modules/css-modules/pull/65)
36
- {
37
- test: /\.less$/,
38
- include: [/\.global/, /bootstrap/],
39
- use: [
40
- {
41
- loader: 'style-loader',
42
- },
43
- {
44
- loader: 'css-loader',
45
- options: {
46
- modules: false
47
- }
48
- },
49
- {
50
- loader: 'less-loader',
51
- }
52
- ]
53
- },
54
- // For CSS-Modules locally scoped styles
55
- {
56
- test: /\.less$/,
57
- exclude: [/\.global/, /bootstrap/, /node_modules/],
58
- use: [
59
- { loader: 'style-loader' },
60
- {
61
- loader: 'css-loader',
62
- options: {
63
- modules: {
64
- localIdentName: 'mongosh-[name]-[local]__[hash:base64:5]'
65
- },
66
- importLoaders: 1,
67
- }
68
- },
69
- {
70
- loader: 'less-loader'
39
+ loader: require.resolve('babel-loader'),
40
+ options: {
41
+ presets: [
42
+ require.resolve('@babel/preset-react'),
43
+ require.resolve('@babel/preset-typescript')
44
+ ],
45
+ plugins: [
46
+ require.resolve('@babel/plugin-proposal-class-properties')
47
+ ],
48
+ sourceType: 'unambiguous',
49
+ compact: false
71
50
  }
72
- ]
51
+ }
73
52
  }
74
53
  ]
75
- }
54
+ },
55
+ plugins: [
56
+ new webpack.ProvidePlugin({
57
+ process: 'process',
58
+ Buffer: ['buffer', 'Buffer']
59
+ })
60
+ ]
76
61
  };
@@ -4,21 +4,5 @@ process.env.NODE_ENV = 'test';
4
4
 
5
5
  module.exports = {
6
6
  ...webpackConfigBase,
7
- mode: 'development',
8
- devtool: 'eval-source-map',
9
- node: {
10
- global: true,
11
- crypto: 'empty',
12
- module: false,
13
- clearImmediate: false,
14
- setImmediate: false
15
- },
16
- externals: {
17
- 'fs': 'none',
18
- 'jsdom': 'window',
19
- 'cheerio': 'window',
20
- 'react/lib/ExecutionEnvironment': 'true',
21
- 'react/addons': 'true',
22
- 'react/lib/ReactContext': 'window'
23
- }
7
+ mode: 'development'
24
8
  };
@@ -0,0 +1,27 @@
1
+ const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
3
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
4
+ const webpackConfigBase = require('./webpack.config.base');
5
+
6
+ webpackConfigBase.module.rules[0].use.options.plugins = [
7
+ ...webpackConfigBase.module.rules[0].use.options.plugins,
8
+ require.resolve('react-refresh/babel')
9
+ ];
10
+
11
+ module.exports = {
12
+ ...webpackConfigBase,
13
+ mode: 'development',
14
+ devServer: {
15
+ static: false,
16
+ host: 'localhost',
17
+ hot: true
18
+ },
19
+ entry: {
20
+ sandbox: path.resolve(__dirname, '..', 'src', 'sandbox.tsx')
21
+ },
22
+ plugins: [
23
+ ...(webpackConfigBase.plugins ?? []),
24
+ new HtmlWebpackPlugin(),
25
+ new ReactRefreshWebpackPlugin()
26
+ ]
27
+ };
@@ -0,0 +1,15 @@
1
+ import { Autocompleter, Completion } from '@mongosh/browser-runtime-core';
2
+ interface AceCompletion {
3
+ caption: string;
4
+ value: string;
5
+ }
6
+ export declare class AceAutocompleterAdapter {
7
+ private adaptee;
8
+ constructor(adaptee: Autocompleter);
9
+ getCompletions: (_editor: any, session: any, position: {
10
+ row: number;
11
+ column: number;
12
+ }, prefix: string, done: (err: Error | null, completions?: AceCompletion[] | undefined) => any) => void;
13
+ adaptCompletion: (prefix: string, line: string, completion: Completion) => AceCompletion;
14
+ }
15
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AceAutocompleterAdapter = void 0;
4
+ class AceAutocompleterAdapter {
5
+ constructor(adaptee) {
6
+ this.getCompletions = (_editor, session, position, prefix, done) => {
7
+ const line = session.getLine(position.row)
8
+ .substring(0, position.column);
9
+ this.adaptee.getCompletions(line)
10
+ .then((completions) => {
11
+ done(null, completions.map(this.adaptCompletion.bind(this, prefix, line)));
12
+ })
13
+ .catch(done);
14
+ };
15
+ this.adaptCompletion = (prefix, line, completion) => {
16
+ const value = prefix + completion.completion.substring(line.length);
17
+ return {
18
+ caption: value,
19
+ value: value
20
+ };
21
+ };
22
+ this.adaptee = adaptee;
23
+ }
24
+ }
25
+ exports.AceAutocompleterAdapter = AceAutocompleterAdapter;
26
+ //# sourceMappingURL=ace-autocompleter-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ace-autocompleter-adapter.js","sourceRoot":"","sources":["../../src/components/ace-autocompleter-adapter.ts"],"names":[],"mappings":";;;AAaA,MAAa,uBAAuB;IAGlC,YAAY,OAAsB;QAIlC,mBAAc,GAAG,CACf,OAAY,EACZ,OAAY,EACZ,QAAyC,EACzC,MAAc,EACd,IAA+D,EAAQ,EAAE;YAGzE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;iBACvC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAGjC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC;iBAC9B,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;gBACpB,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CACxB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAC9C,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC;QAEF,oBAAe,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,UAAsB,EAAiB,EAAE;YAGxF,MAAM,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK;aACb,CAAC;QACJ,CAAC,CAAC;QAhCA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CAgCF;AArCD,0DAqCC"}
@@ -0,0 +1,41 @@
1
+ import { Component } from 'react';
2
+ import { AceEditor as IAceEditor } from '@mongodb-js/compass-editor';
3
+ import { Autocompleter } from '@mongosh/browser-runtime-core';
4
+ interface EditorProps {
5
+ autocompleter?: Autocompleter;
6
+ moveCursorToTheEndOfInput: boolean;
7
+ onEnter(): void | Promise<void>;
8
+ onArrowUpOnFirstLine(): void | Promise<void>;
9
+ onArrowDownOnLastLine(): void | Promise<void>;
10
+ onChange(value: string): void | Promise<void>;
11
+ onClearCommand(): void | Promise<void>;
12
+ onSigInt(): Promise<boolean>;
13
+ operationInProgress: boolean;
14
+ value: string;
15
+ onEditorLoad?: (editor: IAceEditor) => void;
16
+ }
17
+ export declare class Editor extends Component<EditorProps> {
18
+ static defaultProps: {
19
+ onEnter: () => void;
20
+ onArrowUpOnFirstLine: () => void;
21
+ onArrowDownOnLastLine: () => void;
22
+ onChange: () => void;
23
+ onClearCommand: () => void;
24
+ onSigInt: () => void;
25
+ operationInProgress: boolean;
26
+ value: string;
27
+ moveCursorToTheEndOfInput: boolean;
28
+ };
29
+ private editor;
30
+ private visibleCursorDisplayStyle;
31
+ private onEditorLoad;
32
+ private autocompleter;
33
+ private editorId;
34
+ constructor(props: EditorProps);
35
+ componentDidUpdate(prevProps: EditorProps): void;
36
+ componentWillUnmount(): void;
37
+ private hideCursor;
38
+ private showCursor;
39
+ render(): JSX.Element;
40
+ }
41
+ export {};
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Editor = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const compass_components_1 = require("@mongodb-js/compass-components");
29
+ const compass_editor_1 = require("@mongodb-js/compass-editor");
30
+ const ace_autocompleter_adapter_1 = require("./ace-autocompleter-adapter");
31
+ const noop = () => { };
32
+ const editor = (0, compass_components_1.css)({
33
+ lineHeight: '24px !important',
34
+ marginLeft: '-4px',
35
+ });
36
+ class Editor extends react_1.Component {
37
+ constructor(props) {
38
+ super(props);
39
+ this.visibleCursorDisplayStyle = '';
40
+ this.onEditorLoad = (editor) => {
41
+ var _a, _b;
42
+ this.editor = editor;
43
+ this.visibleCursorDisplayStyle = this.editor.renderer.$cursorLayer.element.style.display;
44
+ editor.commands.on('afterExec', (e) => {
45
+ if (this.autocompleter &&
46
+ e.command.name === 'insertstring' &&
47
+ /^[\w.]$/.test(e.args)) {
48
+ this.editor.execCommand('startAutocomplete');
49
+ }
50
+ });
51
+ (_b = (_a = this.props).onEditorLoad) === null || _b === void 0 ? void 0 : _b.call(_a, editor);
52
+ };
53
+ this.autocompleter = null;
54
+ this.editorId = Date.now();
55
+ if (this.props.autocompleter) {
56
+ this.autocompleter = new ace_autocompleter_adapter_1.AceAutocompleterAdapter(this.props.autocompleter);
57
+ }
58
+ }
59
+ componentDidUpdate(prevProps) {
60
+ if (prevProps.operationInProgress !== this.props.operationInProgress) {
61
+ if (this.props.operationInProgress) {
62
+ this.hideCursor();
63
+ }
64
+ else {
65
+ this.showCursor();
66
+ }
67
+ }
68
+ }
69
+ componentWillUnmount() {
70
+ this.autocompleter = null;
71
+ }
72
+ hideCursor() {
73
+ this.editor.renderer.$cursorLayer.element.style.display = 'none';
74
+ }
75
+ showCursor() {
76
+ this.editor.renderer.$cursorLayer.element.style.display = this.visibleCursorDisplayStyle;
77
+ }
78
+ render() {
79
+ return (react_1.default.createElement(compass_editor_1.InlineEditor, { options: {
80
+ readOnly: !!this.props.operationInProgress
81
+ }, className: editor, name: `mongosh-ace-${this.editorId}`, onLoad: this.onEditorLoad, text: this.props.value, onChangeText: this.props.onChange, completer: this.autocompleter, commands: [
82
+ {
83
+ name: 'return',
84
+ bindKey: { win: 'Return', mac: 'Return' },
85
+ exec: () => {
86
+ this.props.onEnter();
87
+ }
88
+ },
89
+ {
90
+ name: 'arrowUpOnFirstLine',
91
+ bindKey: { win: 'Up', mac: 'Up' },
92
+ exec: () => {
93
+ const selectionRange = this.editor.getSelectionRange();
94
+ if (!selectionRange.isEmpty() || selectionRange.start.row !== 0) {
95
+ return this.editor.selection.moveCursorUp();
96
+ }
97
+ this.props.onArrowUpOnFirstLine();
98
+ }
99
+ },
100
+ {
101
+ name: 'arrowDownOnLastLine',
102
+ bindKey: { win: 'Down', mac: 'Down' },
103
+ exec: () => {
104
+ const selectionRange = this.editor.getSelectionRange();
105
+ const lastRowIndex = this.editor.session.getLength() - 1;
106
+ if (!selectionRange.isEmpty() || selectionRange.start.row !== lastRowIndex) {
107
+ return this.editor.selection.moveCursorDown();
108
+ }
109
+ this.props.onArrowDownOnLastLine();
110
+ }
111
+ },
112
+ {
113
+ name: 'clearShell',
114
+ bindKey: { win: 'Ctrl-L', mac: 'Command-L' },
115
+ exec: this.props.onClearCommand
116
+ },
117
+ {
118
+ name: 'SIGINT',
119
+ bindKey: { win: 'Ctrl-C', mac: 'Ctrl-C' },
120
+ exec: this.props.onSigInt,
121
+ readOnly: true,
122
+ }
123
+ ], maxLines: Infinity, editorProps: {
124
+ $blockScrolling: Infinity
125
+ } }));
126
+ }
127
+ }
128
+ exports.Editor = Editor;
129
+ Editor.defaultProps = {
130
+ onEnter: noop,
131
+ onArrowUpOnFirstLine: noop,
132
+ onArrowDownOnLastLine: noop,
133
+ onChange: noop,
134
+ onClearCommand: noop,
135
+ onSigInt: noop,
136
+ operationInProgress: false,
137
+ value: '',
138
+ moveCursorToTheEndOfInput: false
139
+ };
140
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../src/components/editor.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,uEAAqD;AACrD,+DAAmF;AAEnF,2EAAsE;AAEtE,MAAM,IAAI,GAAG,GAAS,EAAE,G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,EAClB,WAAW,EAAE;gBACX,eAAe,EAAE,QAAQ;aAC1B,GACD,CAAC,CAAC;IACN,CAAC;;AA1IH,wBA2IC;AA1IQ,mBAAY,GAAG;IACpB,OAAO,EAAE,IAAI;IACb,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,IAAI;IACd,mBAAmB,EAAE,KAAK;IAC1B,KAAK,EAAE,EAAE;IACT,yBAAyB,EAAE,KAAK;CACjC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import React, { Component } from 'react';
2
+ interface PasswordPromptProps {
3
+ onFinish: (result: string) => void;
4
+ onCancel: () => void;
5
+ prompt: string;
6
+ }
7
+ export declare class PasswordPrompt extends Component<PasswordPromptProps> {
8
+ constructor(props: PasswordPromptProps);
9
+ onKeyDown: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
10
+ render(): JSX.Element;
11
+ }
12
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PasswordPrompt = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const compass_components_1 = require("@mongodb-js/compass-components");
29
+ const passwordPrompt = (0, compass_components_1.css)({
30
+ paddingLeft: 23,
31
+ '& input': {
32
+ fontSize: '13px',
33
+ lineHeight: '24px',
34
+ fontFamily: compass_components_1.fontFamilies.code,
35
+ backgroundColor: compass_components_1.palette.gray.dark3,
36
+ color: compass_components_1.palette.gray.light3,
37
+ padding: '0 3px',
38
+ border: `1px solid ${compass_components_1.palette.gray.light3}`,
39
+ borderRadius: 3
40
+ }
41
+ });
42
+ class PasswordPrompt extends react_1.Component {
43
+ constructor(props) {
44
+ super(props);
45
+ this.onKeyDown = (ev) => {
46
+ switch (ev.key) {
47
+ case 'Enter':
48
+ this.props.onFinish(ev.target.value);
49
+ break;
50
+ case 'Esc':
51
+ case 'Escape':
52
+ this.props.onCancel();
53
+ break;
54
+ default:
55
+ break;
56
+ }
57
+ };
58
+ }
59
+ render() {
60
+ return (react_1.default.createElement("label", { className: passwordPrompt },
61
+ this.props.prompt,
62
+ ":\u00A0",
63
+ react_1.default.createElement("input", { type: "password", onKeyDown: this.onKeyDown, autoFocus: true })));
64
+ }
65
+ }
66
+ exports.PasswordPrompt = PasswordPrompt;
67
+ //# sourceMappingURL=password-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-prompt.js","sourceRoot":"","sources":["../../src/components/password-prompt.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,uEAA4E;AAE5E,MAAM,cAAc,GAAG,IAAA,wBAAG,EAAC;IACzB,WAAW,EAAE,EAAE;IACf,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,iCAAY,CAAC,IAAI;QAC7B,eAAe,EAAE,4BAAO,CAAC,IAAI,CAAC,KAAK;QACnC,KAAK,EAAE,4BAAO,CAAC,IAAI,CAAC,MAAM;QAC1B,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,aAAa,4BAAO,CAAC,IAAI,CAAC,MAAM,EAAE;QAC1C,YAAY,EAAE,CAAC;KAChB;CACF,CAAC,CAAC;AAQH,MAAa,cAAe,SAAQ,iBAA8B;IAChE,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAGf,cAAS,GAAG,CAAC,EAAyC,EAAQ,EAAE;YAC9D,QAAQ,EAAE,CAAC,GAAG,EAAE;gBACd,KAAK,OAAO;oBACV,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAE,EAAE,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAC;oBAC3D,MAAM;gBACR,KAAK,KAAK,CAAC;gBACX,KAAK,QAAQ;oBACX,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACtB,MAAM;gBACR;oBACE,MAAM;aACT;QACH,CAAC,CAAC;IAdF,CAAC;IAgBD,MAAM;QACJ,OAAO,CACL,yCAAO,SAAS,EAAE,cAAc;YAC7B,IAAI,CAAC,KAAK,CAAC,MAAM;;YAClB,yCAAO,IAAI,EAAC,UAAU,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,SAAG,CACxD,CACT,CAAC;IACJ,CAAC;CACF;AA3BD,wCA2BC"}
@@ -0,0 +1,33 @@
1
+ import { Component } from 'react';
2
+ import { Autocompleter } from '@mongosh/browser-runtime-core';
3
+ import type { AceEditor as IAceEditor } from '@mongodb-js/compass-editor';
4
+ interface ShellInputProps {
5
+ autocompleter?: Autocompleter;
6
+ history?: readonly string[];
7
+ onClearCommand?(): void | Promise<void>;
8
+ onInput?(code: string): void | Promise<void>;
9
+ operationInProgress?: boolean;
10
+ prompt?: string;
11
+ onEditorLoad?: (editor: IAceEditor) => void;
12
+ onSigInt?(): Promise<boolean>;
13
+ }
14
+ interface ShellInputState {
15
+ currentValue: string;
16
+ readOnly: boolean;
17
+ }
18
+ export declare class ShellInput extends Component<ShellInputProps, ShellInputState> {
19
+ readonly state: ShellInputState;
20
+ private editor;
21
+ private historyNavigationEntries;
22
+ private historyNavigationIndex;
23
+ constructor(props: ShellInputProps);
24
+ componentDidUpdate(prevProps: ShellInputProps): void;
25
+ private initializeHistoryNavigation;
26
+ private onChange;
27
+ private syncCurrentValueWithHistoryNavigation;
28
+ private historyBack;
29
+ private historyNext;
30
+ private onEnter;
31
+ render(): JSX.Element;
32
+ }
33
+ export {};
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ShellInput = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const compass_components_1 = require("@mongodb-js/compass-components");
32
+ const editor_1 = require("./editor");
33
+ const shell_loader_1 = __importDefault(require("./shell-loader"));
34
+ const line_with_icon_1 = require("./utils/line-with-icon");
35
+ const shellInput = (0, compass_components_1.css)({
36
+ padding: '0 8px',
37
+ minHeight: '24px',
38
+ });
39
+ class ShellInput extends react_1.Component {
40
+ constructor(props) {
41
+ super(props);
42
+ this.state = {
43
+ currentValue: '',
44
+ readOnly: false
45
+ };
46
+ this.editor = null;
47
+ this.historyNavigationEntries = [];
48
+ this.historyNavigationIndex = 0;
49
+ this.onChange = (value) => {
50
+ this.setState({ currentValue: value });
51
+ };
52
+ this.historyBack = () => {
53
+ if (this.historyNavigationIndex >= this.historyNavigationEntries.length - 1) {
54
+ return;
55
+ }
56
+ this.historyNavigationIndex++;
57
+ this.syncCurrentValueWithHistoryNavigation();
58
+ };
59
+ this.historyNext = () => {
60
+ if (this.historyNavigationIndex <= 0) {
61
+ return;
62
+ }
63
+ this.historyNavigationIndex--;
64
+ this.syncCurrentValueWithHistoryNavigation();
65
+ };
66
+ this.onEnter = async () => {
67
+ if (this.props.onInput) {
68
+ await this.props.onInput(this.state.currentValue);
69
+ }
70
+ this.setState({ currentValue: '' });
71
+ };
72
+ this.initializeHistoryNavigation();
73
+ }
74
+ componentDidUpdate(prevProps) {
75
+ if (prevProps.history !== this.props.history) {
76
+ this.initializeHistoryNavigation();
77
+ }
78
+ if (this.historyNavigationIndex === 0) {
79
+ this.historyNavigationEntries[0] = this.state.currentValue;
80
+ }
81
+ }
82
+ initializeHistoryNavigation() {
83
+ this.historyNavigationEntries = [
84
+ this.state.currentValue,
85
+ ...(this.props.history || [])
86
+ ];
87
+ this.historyNavigationIndex = 0;
88
+ }
89
+ syncCurrentValueWithHistoryNavigation() {
90
+ const value = this.historyNavigationEntries[this.historyNavigationIndex];
91
+ if (value === undefined) {
92
+ return;
93
+ }
94
+ this.setState({ currentValue: value }, () => {
95
+ var _a;
96
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.navigateFileEnd();
97
+ });
98
+ }
99
+ render() {
100
+ let prompt;
101
+ if (this.props.operationInProgress) {
102
+ prompt = (react_1.default.createElement(shell_loader_1.default, null));
103
+ }
104
+ else if (this.props.prompt) {
105
+ const trimmed = this.props.prompt.trim();
106
+ if (trimmed.endsWith('>')) {
107
+ prompt = (react_1.default.createElement(react_1.default.Fragment, null,
108
+ react_1.default.createElement("span", null, trimmed.replace(/>$/g, '')),
109
+ react_1.default.createElement(compass_components_1.Icon, { size: 12, glyph: 'ChevronRight' })));
110
+ }
111
+ else {
112
+ prompt = (react_1.default.createElement("span", null, trimmed));
113
+ }
114
+ }
115
+ else {
116
+ prompt = (react_1.default.createElement(compass_components_1.Icon, { size: 12, glyph: 'ChevronRight' }));
117
+ }
118
+ const editor = (react_1.default.createElement(editor_1.Editor, { autocompleter: this.props.autocompleter, onArrowUpOnFirstLine: this.historyBack, onArrowDownOnLastLine: this.historyNext, onChange: this.onChange, onEnter: this.onEnter, onClearCommand: this.props.onClearCommand, onEditorLoad: (editor) => {
119
+ var _a, _b;
120
+ this.editor = editor;
121
+ (_b = (_a = this.props).onEditorLoad) === null || _b === void 0 ? void 0 : _b.call(_a, editor);
122
+ }, value: this.state.currentValue, operationInProgress: this.props.operationInProgress, onSigInt: this.props.onSigInt }));
123
+ return (react_1.default.createElement(line_with_icon_1.LineWithIcon, { className: shellInput, icon: prompt }, editor));
124
+ }
125
+ }
126
+ exports.ShellInput = ShellInput;
127
+ //# sourceMappingURL=shell-input.js.map