@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-input.js","sourceRoot":"","sources":["../../src/components/shell-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,uEAA2D;AAE3D,qCAAkC;AAClC,kEAAyC;AACzC,2DAAsD;AAItD,MAAM,UAAU,GAAG,IAAA,wBAAG,EAAC;IACrB,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,MAAM;CAClB,CAAC,CAAC;AAkBH,MAAa,UAAW,SAAQ,iBAA2C;IAUzE,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QAVN,UAAK,GAAoB;YAChC,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,KAAK;SAChB,CAAC;QAEM,WAAM,GAAsB,IAAI,CAAC;QACjC,6BAAwB,GAAa,EAAE,CAAC;Q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B,CAAC,CAAC;SACL;QAED,MAAM,MAAM,GAAG,CACb,8BAAC,eAAM,IACL,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,oBAAoB,EAAE,IAAI,CAAC,WAAW,EACtC,qBAAqB,EAAE,IAAI,CAAC,WAAW,EACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EACzC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;;gBACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBAErB,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,YAAY,mDAAG,MAAM,CAAC,CAAC;YACpC,CAAC,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC9B,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,EACnD,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAC7B,CACH,CAAC;QAEF,OAAO,CACL,8BAAC,6BAAY,IAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,IAC9C,MAAM,CACM,CAChB,CAAC;IACJ,CAAC;CACF;AAhID,gCAgIC"}
@@ -0,0 +1,11 @@
1
+ import { Component } from 'react';
2
+ interface ShellLoaderProps {
3
+ size?: string;
4
+ }
5
+ export default class ShellLoader extends Component<ShellLoaderProps> {
6
+ static defaultProps: {
7
+ size: string;
8
+ };
9
+ render(): JSX.Element;
10
+ }
11
+ export {};
@@ -0,0 +1,42 @@
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
+ const react_1 = __importStar(require("react"));
27
+ const compass_components_1 = require("@mongodb-js/compass-components");
28
+ const shellLoader = (0, compass_components_1.css)({
29
+ '& div': { borderTopColor: compass_components_1.palette.green.light2 }
30
+ });
31
+ class ShellLoader extends react_1.Component {
32
+ render() {
33
+ const { size } = this.props;
34
+ return react_1.default.createElement("div", { className: shellLoader },
35
+ react_1.default.createElement(compass_components_1.SpinLoader, { size: size }));
36
+ }
37
+ }
38
+ exports.default = ShellLoader;
39
+ ShellLoader.defaultProps = {
40
+ size: '12px'
41
+ };
42
+ //# sourceMappingURL=shell-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-loader.js","sourceRoot":"","sources":["../../src/components/shell-loader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,uEAA0E;AAG1E,MAAM,WAAW,GAAG,IAAA,wBAAG,EAAC;IACtB,OAAO,EAAE,EAAE,cAAc,EAAE,4BAAO,CAAC,KAAK,CAAC,MAAM,EAAE;CAClD,CAAC,CAAC;AAMH,MAAqB,WAAY,SAAQ,iBAA2B;IAKlE,MAAM;QACJ,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,OAAO,uCAAK,SAAS,EAAE,WAAW;YAAE,8BAAC,+BAAU,IAAC,IAAI,EAAE,IAAI,GAAI,CAAM,CAAC;IACvE,CAAC;;AARH,8BASC;AARQ,wBAAY,GAAG;IACpB,IAAI,EAAE,MAAM;CACb,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ declare type ShellOutputEntryValue = any;
4
+ export interface ShellOutputEntry {
5
+ format: 'input' | 'output' | 'error';
6
+ type?: string | null;
7
+ value: ShellOutputEntryValue;
8
+ }
9
+ interface ShellOutputLineProps {
10
+ entry: ShellOutputEntry;
11
+ }
12
+ export declare class ShellOutputLine extends Component<ShellOutputLineProps> {
13
+ static propTypes: {
14
+ entry: PropTypes.Validator<object>;
15
+ };
16
+ private renderValue;
17
+ private isError;
18
+ private isPreformattedResult;
19
+ private isPrimitiveOrFunction;
20
+ private getIconGlyph;
21
+ render(): JSX.Element;
22
+ }
23
+ export {};
@@ -0,0 +1,135 @@
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.ShellOutputLine = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const prop_types_1 = __importDefault(require("prop-types"));
32
+ const compass_components_1 = require("@mongodb-js/compass-components");
33
+ const line_with_icon_1 = require("./utils/line-with-icon");
34
+ const help_output_1 = require("./types/help-output");
35
+ const show_banner_result_output_1 = require("./types/show-banner-result-output");
36
+ const show_dbs_output_1 = require("./types/show-dbs-output");
37
+ const show_collections_output_1 = require("./types/show-collections-output");
38
+ const cursor_output_1 = require("./types/cursor-output");
39
+ const cursor_iteration_result_output_1 = require("./types/cursor-iteration-result-output");
40
+ const object_output_1 = require("./types/object-output");
41
+ const stats_result_output_1 = require("./types/stats-result-output");
42
+ const simple_type_output_1 = require("./types/simple-type-output");
43
+ const error_output_1 = require("./types/error-output");
44
+ const show_profile_output_1 = require("./types/show-profile-output");
45
+ const shellOutputLine = (0, compass_components_1.css)({
46
+ padding: '0 8px'
47
+ });
48
+ const shellOutputLineError = (0, compass_components_1.css)({
49
+ backgroundColor: compass_components_1.palette.red.light2,
50
+ color: compass_components_1.palette.red.dark3,
51
+ });
52
+ const shellOutputLineIcon = (0, compass_components_1.css)({
53
+ color: compass_components_1.palette.gray.dark1
54
+ });
55
+ const shellOutputLineIconError = (0, compass_components_1.css)({
56
+ color: 'inherit'
57
+ });
58
+ class ShellOutputLine extends react_1.Component {
59
+ renderValue() {
60
+ const { type, value, format } = this.props.entry;
61
+ if (format === 'input' ||
62
+ this.isPreformattedResult(value, type)) {
63
+ return react_1.default.createElement("pre", null, value);
64
+ }
65
+ if (typeof value === 'string' && type !== null) {
66
+ return react_1.default.createElement(simple_type_output_1.SimpleTypeOutput, { value: value, raw: true });
67
+ }
68
+ if (this.isPrimitiveOrFunction(value)) {
69
+ return react_1.default.createElement(simple_type_output_1.SimpleTypeOutput, { value: value });
70
+ }
71
+ if (type === 'Help') {
72
+ return react_1.default.createElement(help_output_1.HelpOutput, { value: value });
73
+ }
74
+ if (type === 'ShowDatabasesResult') {
75
+ return react_1.default.createElement(show_dbs_output_1.ShowDbsOutput, { value: value });
76
+ }
77
+ if (type === 'StatsResult') {
78
+ return react_1.default.createElement(stats_result_output_1.StatsResultOutput, { value: value });
79
+ }
80
+ if (type === 'ListCommandsResult') {
81
+ return react_1.default.createElement(simple_type_output_1.SimpleTypeOutput, { value: value });
82
+ }
83
+ if (type === 'ShowCollectionsResult') {
84
+ return react_1.default.createElement(show_collections_output_1.ShowCollectionsOutput, { value: value });
85
+ }
86
+ if (type === 'ShowBannerResult') {
87
+ return react_1.default.createElement(show_banner_result_output_1.ShowBannerResultOutput, { value: value });
88
+ }
89
+ if (type === 'Cursor' || type === 'AggregationCursor') {
90
+ return react_1.default.createElement(cursor_output_1.CursorOutput, { value: value });
91
+ }
92
+ if (type === 'CursorIterationResult') {
93
+ return react_1.default.createElement(cursor_iteration_result_output_1.CursorIterationResultOutput, { value: value });
94
+ }
95
+ if (type === 'ShowProfileResult') {
96
+ return react_1.default.createElement(show_profile_output_1.ShowProfileOutput, { value: value });
97
+ }
98
+ if (this.isError(value)) {
99
+ return react_1.default.createElement(error_output_1.ErrorOutput, { value: value });
100
+ }
101
+ return react_1.default.createElement(object_output_1.ObjectOutput, { value: value });
102
+ }
103
+ isError(value) {
104
+ return typeof value.message === 'string' && typeof value.stack === 'string';
105
+ }
106
+ isPreformattedResult(value, type) {
107
+ return typeof value === 'string' &&
108
+ type === 'Database' ||
109
+ type === 'Collection';
110
+ }
111
+ isPrimitiveOrFunction(value) {
112
+ return value !== Object(value) ||
113
+ typeof value === 'function';
114
+ }
115
+ getIconGlyph() {
116
+ const { format } = this.props.entry;
117
+ if (format === 'input') {
118
+ return 'ChevronRight';
119
+ }
120
+ if (format === 'error') {
121
+ return 'XWithCircle';
122
+ }
123
+ return 'ChevronLeft';
124
+ }
125
+ render() {
126
+ const { format } = this.props.entry;
127
+ const icon = (react_1.default.createElement(compass_components_1.Icon, { size: 12, glyph: this.getIconGlyph(), className: (0, compass_components_1.cx)(format === 'error' ? shellOutputLineIconError : shellOutputLineIcon) }));
128
+ return (react_1.default.createElement(line_with_icon_1.LineWithIcon, { className: (0, compass_components_1.cx)(shellOutputLine, format === 'error' && shellOutputLineError), icon: icon }, this.renderValue()));
129
+ }
130
+ }
131
+ exports.ShellOutputLine = ShellOutputLine;
132
+ ShellOutputLine.propTypes = {
133
+ entry: prop_types_1.default.object.isRequired
134
+ };
135
+ //# sourceMappingURL=shell-output-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-output-line.js","sourceRoot":"","sources":["../../src/components/shell-output-line.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAyC;AACzC,4DAAmC;AACnC,uEAAwE;AACxE,2DAAsD;AACtD,qDAAiD;AACjD,iFAA2E;AAC3E,6DAAwD;AACxD,6EAAwE;AACxE,yDAAqD;AACrD,2FAAqF;AACrF,yDAAqD;AACrD,qEAAgE;AAChE,mEAA8D;AAC9D,uDAAmD;AACnD,qEAAgE;AAEhE,MAAM,eAAe,GAAG,IAAA,wBAAG,EAAC;IAC1B,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,IAAA,wBAAG,EAAC;IAC/B,eAAe,EAAE,4BAAO,CAAC,GAAG,CAAC,MAAM;IACnC,KAAK,EAAE,4BAAO,CAAC,GAAG,CAAC,KAAK;CACzB,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,IAAA,wBAAG,EAAC;IAC9B,KAAK,EAAE,4BAAO,CAAC,IAAI,CAAC,KAAK;CAC1B,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,IAAA,wBAAG,EAAC;IACnC,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC;AAgBH,MAAa,eAAgB,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EpC,MAAM,IAAI,GAAG,CACX,8BAAC,yBAAI,IACH,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,EAC1B,SAAS,EAAE,IAAA,uBAAE,EACX,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CACpE,GACD,CACH,CAAC;QAEF,OAAO,CACL,8BAAC,6BAAY,IACX,SAAS,EAAE,IAAA,uBAAE,EACX,eAAe,EACf,MAAM,KAAK,OAAO,IAAI,oBAAoB,CAC3C,EACD,IAAI,EAAE,IAAI,IAET,IAAI,CAAC,WAAW,EAAE,CACN,CAChB,CAAC;IACJ,CAAC;;AAvHH,0CAwHC;AAvHQ,yBAAS,GAAG;IACjB,KAAK,EAAE,oBAAS,CAAC,MAAM,CAAC,UAAU;CACnC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import type { ShellOutputEntry } from './shell-output-line';
4
+ export type { ShellOutputEntry } from './shell-output-line';
5
+ interface ShellOutputProps {
6
+ output: readonly ShellOutputEntry[];
7
+ }
8
+ export declare class ShellOutput extends Component<ShellOutputProps> {
9
+ static propTypes: {
10
+ output: PropTypes.Validator<any[]>;
11
+ };
12
+ renderLine: (entry: ShellOutputEntry, index: number) => JSX.Element;
13
+ render(): JSX.Element[];
14
+ }
@@ -0,0 +1,48 @@
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.ShellOutput = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const prop_types_1 = __importDefault(require("prop-types"));
32
+ const shell_output_line_1 = require("./shell-output-line");
33
+ class ShellOutput extends react_1.Component {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.renderLine = (entry, index) => {
37
+ return react_1.default.createElement(shell_output_line_1.ShellOutputLine, { key: `shell-output-entry-${index}`, entry: entry });
38
+ };
39
+ }
40
+ render() {
41
+ return this.props.output.filter(entry => entry.value !== undefined).map(this.renderLine);
42
+ }
43
+ }
44
+ exports.ShellOutput = ShellOutput;
45
+ ShellOutput.propTypes = {
46
+ output: prop_types_1.default.arrayOf(prop_types_1.default.any).isRequired
47
+ };
48
+ //# sourceMappingURL=shell-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-output.js","sourceRoot":"","sources":["../../src/components/shell-output.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,4DAAmC;AACnC,2DAAsD;AAStD,MAAa,WAAY,SAAQ,iBAA2B;IAA5D;;QAKE,eAAU,GAAG,CAAC,KAAuB,EAAE,KAAa,EAAe,EAAE;YACnE,OAAO,8BAAC,mCAAe,IAAC,GAAG,EAAE,sBAAsB,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;QAC/E,CAAC,CAAC;IAKJ,CAAC;IAHC,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3F,CAAC;;AAXH,kCAYC;AAXQ,qBAAS,GAAG;IACjB,MAAM,EAAE,oBAAS,CAAC,OAAO,CAAC,oBAAS,CAAC,GAAG,CAAC,CAAC,UAAU;CACpD,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { Component } from 'react';
2
+ import type { Runtime } from '@mongosh/browser-runtime-core';
3
+ import type { WorkerRuntime } from '@mongosh/node-runtime-worker-thread';
4
+ import { ShellOutputEntry } from './shell-output';
5
+ interface ShellProps {
6
+ runtime: Runtime | WorkerRuntime;
7
+ onOutputChanged: (output: readonly ShellOutputEntry[]) => void;
8
+ onHistoryChanged: (history: readonly string[]) => void;
9
+ redactInfo?: boolean;
10
+ maxOutputLength: number;
11
+ maxHistoryLength: number;
12
+ onOperationStarted: () => void;
13
+ onOperationEnd: () => void;
14
+ initialOutput: readonly ShellOutputEntry[];
15
+ initialHistory: readonly string[];
16
+ }
17
+ interface ShellState {
18
+ operationInProgress: boolean;
19
+ output: readonly ShellOutputEntry[];
20
+ history: readonly string[];
21
+ passwordPrompt: string;
22
+ shellPrompt: string;
23
+ }
24
+ export declare class Shell extends Component<ShellProps, ShellState> {
25
+ static defaultProps: {
26
+ onHistoryChanged: () => void;
27
+ onOperationStarted: () => void;
28
+ onOperationEnd: () => void;
29
+ onOutputChanged: () => void;
30
+ maxOutputLength: number;
31
+ maxHistoryLength: number;
32
+ initialOutput: never[];
33
+ initialHistory: never[];
34
+ };
35
+ private shellInputElement;
36
+ private editor?;
37
+ private onFinishPasswordPrompt;
38
+ private onCancelPasswordPrompt;
39
+ readonly state: ShellState;
40
+ componentDidMount(): void;
41
+ componentDidUpdate(): void;
42
+ private evaluate;
43
+ private updateShellPrompt;
44
+ private addEntryToHistory;
45
+ private addEntriesToOutput;
46
+ onClearCommand: () => void;
47
+ onPrint: (result: {
48
+ type: string | null;
49
+ printable: any;
50
+ }[]) => void;
51
+ onPrompt: (question: string, type: 'password' | 'yesno') => Promise<string>;
52
+ private onInput;
53
+ private appendEmptyInput;
54
+ private scrollToBottom;
55
+ private onShellClicked;
56
+ private focusEditor;
57
+ private onSigInt;
58
+ renderInput(): JSX.Element;
59
+ render(): JSX.Element;
60
+ }
61
+ export {};
@@ -0,0 +1,283 @@
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.Shell = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const compass_components_1 = require("@mongodb-js/compass-components");
29
+ const history_1 = require("@mongosh/history");
30
+ const password_prompt_1 = require("./password-prompt");
31
+ const shell_input_1 = require("./shell-input");
32
+ const shell_output_1 = require("./shell-output");
33
+ const shellContainer = (0, compass_components_1.css)({
34
+ fontSize: '13px',
35
+ lineHeight: '24px',
36
+ fontFamily: compass_components_1.fontFamilies.code,
37
+ backgroundColor: compass_components_1.palette.gray.dark3,
38
+ color: compass_components_1.palette.gray.light3,
39
+ padding: '4px 0',
40
+ width: '100%',
41
+ height: '100%',
42
+ overflowY: 'scroll',
43
+ overflowX: 'hidden',
44
+ '& a, & a:link, & a:visited, & a:hover, & a:active': {
45
+ fontWeight: 'bold',
46
+ color: 'inherit',
47
+ backgroundColor: 'transparent',
48
+ textDecoration: 'underline',
49
+ cursor: 'pointer'
50
+ },
51
+ '& pre, & code': {
52
+ background: 'transparent',
53
+ border: '0px transparent',
54
+ padding: 0,
55
+ margin: 0,
56
+ fontSize: 'inherit',
57
+ borderRadius: 0,
58
+ color: 'inherit'
59
+ }
60
+ });
61
+ const noop = () => { };
62
+ class Shell extends react_1.Component {
63
+ constructor() {
64
+ super(...arguments);
65
+ this.shellInputElement = null;
66
+ this.onFinishPasswordPrompt = noop;
67
+ this.onCancelPasswordPrompt = noop;
68
+ this.state = {
69
+ operationInProgress: false,
70
+ output: this.props.initialOutput.slice(-this.props.maxOutputLength),
71
+ history: this.props.initialHistory.slice(0, this.props.maxHistoryLength),
72
+ passwordPrompt: '',
73
+ shellPrompt: '>'
74
+ };
75
+ this.evaluate = async (code) => {
76
+ let outputLine;
77
+ try {
78
+ this.props.onOperationStarted();
79
+ this.props.runtime.setEvaluationListener(this);
80
+ const result = await this.props.runtime.evaluate(code);
81
+ outputLine = {
82
+ format: 'output',
83
+ type: result.type,
84
+ value: result.printable
85
+ };
86
+ }
87
+ catch (error) {
88
+ outputLine = {
89
+ format: 'error',
90
+ value: error
91
+ };
92
+ }
93
+ finally {
94
+ await this.updateShellPrompt();
95
+ this.props.onOperationEnd();
96
+ }
97
+ return outputLine;
98
+ };
99
+ this.onClearCommand = () => {
100
+ const output = [];
101
+ Object.freeze(output);
102
+ this.setState({ output });
103
+ this.props.onOutputChanged(output);
104
+ };
105
+ this.onPrint = (result) => {
106
+ const output = this.addEntriesToOutput(result.map((entry) => ({
107
+ format: 'output',
108
+ type: entry.type,
109
+ value: entry.printable
110
+ })));
111
+ this.setState({ output });
112
+ this.props.onOutputChanged(output);
113
+ };
114
+ this.onPrompt = (question, type) => {
115
+ if (type !== 'password') {
116
+ return Promise.reject(new Error('yes/no prompts not implemented yet'));
117
+ }
118
+ const reset = () => {
119
+ this.onFinishPasswordPrompt = noop;
120
+ this.onCancelPasswordPrompt = noop;
121
+ this.setState({ passwordPrompt: '' });
122
+ setTimeout(this.focusEditor, 1);
123
+ };
124
+ const ret = new Promise((resolve, reject) => {
125
+ this.onFinishPasswordPrompt = (result) => {
126
+ reset();
127
+ resolve(result);
128
+ };
129
+ this.onCancelPasswordPrompt = () => {
130
+ reset();
131
+ reject(new Error('Canceled by user'));
132
+ };
133
+ });
134
+ this.setState({ passwordPrompt: question });
135
+ return ret;
136
+ };
137
+ this.onInput = async (code) => {
138
+ if (!code || code.trim() === '') {
139
+ this.appendEmptyInput();
140
+ return;
141
+ }
142
+ const inputLine = {
143
+ format: 'input',
144
+ value: code
145
+ };
146
+ let output = this.addEntriesToOutput([inputLine]);
147
+ this.setState({
148
+ operationInProgress: true,
149
+ output
150
+ });
151
+ this.props.onOutputChanged(output);
152
+ const outputLine = await this.evaluate(code);
153
+ output = this.addEntriesToOutput([outputLine]);
154
+ const history = this.addEntryToHistory(code);
155
+ this.setState({
156
+ operationInProgress: false,
157
+ output,
158
+ history
159
+ });
160
+ this.props.onOutputChanged(output);
161
+ this.props.onHistoryChanged(history);
162
+ };
163
+ this.onShellClicked = (event) => {
164
+ if (event.currentTarget === event.target) {
165
+ this.focusEditor();
166
+ }
167
+ };
168
+ this.focusEditor = () => {
169
+ if (this.editor) {
170
+ this.editor.focus();
171
+ }
172
+ };
173
+ this.onSigInt = () => {
174
+ if (this.state.operationInProgress &&
175
+ this.props.runtime.interrupt) {
176
+ return this.props.runtime.interrupt();
177
+ }
178
+ return Promise.resolve(false);
179
+ };
180
+ }
181
+ componentDidMount() {
182
+ this.scrollToBottom();
183
+ this.updateShellPrompt();
184
+ }
185
+ componentDidUpdate() {
186
+ this.scrollToBottom();
187
+ }
188
+ async updateShellPrompt() {
189
+ var _a;
190
+ let shellPrompt = '>';
191
+ let hasCustomPrompt = false;
192
+ try {
193
+ this.props.runtime.setEvaluationListener(this);
194
+ const promptResult = await this.props.runtime.evaluate(`
195
+ (() => {
196
+ switch (typeof prompt) {
197
+ case 'function':
198
+ return prompt();
199
+ case 'string':
200
+ return prompt;
201
+ }
202
+ })()`);
203
+ if (promptResult.type === null && typeof promptResult.printable === 'string') {
204
+ shellPrompt = promptResult.printable;
205
+ hasCustomPrompt = true;
206
+ }
207
+ }
208
+ catch (_b) {
209
+ }
210
+ if (!hasCustomPrompt) {
211
+ try {
212
+ shellPrompt = (_a = (await this.props.runtime.getShellPrompt())) !== null && _a !== void 0 ? _a : '>';
213
+ }
214
+ catch (_c) {
215
+ }
216
+ }
217
+ this.setState({ shellPrompt });
218
+ }
219
+ addEntryToHistory(code) {
220
+ const history = [
221
+ code,
222
+ ...this.state.history
223
+ ];
224
+ (0, history_1.changeHistory)(history, this.props.redactInfo ? 'redact-sensitive-data' : 'keep-sensitive-data');
225
+ history.splice(this.props.maxHistoryLength);
226
+ Object.freeze(history);
227
+ return history;
228
+ }
229
+ addEntriesToOutput(entries) {
230
+ const output = [
231
+ ...this.state.output,
232
+ ...entries
233
+ ];
234
+ output.splice(0, output.length - this.props.maxOutputLength);
235
+ Object.freeze(output);
236
+ return output;
237
+ }
238
+ appendEmptyInput() {
239
+ const inputLine = {
240
+ format: 'input',
241
+ value: ' '
242
+ };
243
+ const output = this.addEntriesToOutput([
244
+ inputLine
245
+ ]);
246
+ this.setState({ output });
247
+ }
248
+ scrollToBottom() {
249
+ if (!this.shellInputElement) {
250
+ return;
251
+ }
252
+ this.shellInputElement.scrollIntoView();
253
+ }
254
+ renderInput() {
255
+ if (this.state.passwordPrompt) {
256
+ return (react_1.default.createElement(password_prompt_1.PasswordPrompt, { onFinish: this.onFinishPasswordPrompt, onCancel: this.onCancelPasswordPrompt, prompt: this.state.passwordPrompt }));
257
+ }
258
+ return (react_1.default.createElement(shell_input_1.ShellInput, { prompt: this.state.shellPrompt, autocompleter: this.props.runtime, history: this.state.history, onClearCommand: this.onClearCommand, onInput: this.onInput, operationInProgress: this.state.operationInProgress, onEditorLoad: (editor) => {
259
+ this.editor = editor;
260
+ }, onSigInt: this.onSigInt }));
261
+ }
262
+ render() {
263
+ return (react_1.default.createElement(compass_components_1.ThemeProvider, { theme: { theme: compass_components_1.Theme.Dark, enabled: true } },
264
+ react_1.default.createElement("div", { "data-testid": "shell", className: shellContainer, onClick: this.onShellClicked },
265
+ react_1.default.createElement("div", null,
266
+ react_1.default.createElement(shell_output_1.ShellOutput, { output: this.state.output })),
267
+ react_1.default.createElement("div", { ref: (el) => {
268
+ this.shellInputElement = el;
269
+ } }, this.renderInput()))));
270
+ }
271
+ }
272
+ exports.Shell = Shell;
273
+ Shell.defaultProps = {
274
+ onHistoryChanged: noop,
275
+ onOperationStarted: noop,
276
+ onOperationEnd: noop,
277
+ onOutputChanged: noop,
278
+ maxOutputLength: 1000,
279
+ maxHistoryLength: 1000,
280
+ initialOutput: [],
281
+ initialHistory: [],
282
+ };
283
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/components/shell.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AAEzC,uEAAkG;AAElG,8CAAiD;AAEjD,uDAAmD;AACnD,+CAA2C;AAC3C,iDAA+D;AAE/D,MAAM,cAAc,GAAG,IAAA,wBAAG,EAAC;IACzB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,iCAAY,CAAC,IAAI;IAC7B,eAAe,EAAE,4BAAO,CAAC,IAAI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