sqlite-wasm-viewer 1.0.13 → 1.2.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/dist/viewer.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Viewer = void 0;
7
+ var _dbWorkerConnector = require("./dbWorkerConnector");
8
+ var _resizeHandler = require("./utils/resizeHandler");
9
+ var _EditCellView = require("./views/EditCellView/EditCellView");
10
+ var _ExecuteSQLView = require("./views/ExecuteSQLView/ExecuteSQLView");
11
+ var _ExplorerView = require("./views/ExplorerView/ExplorerView");
12
+ var _SqlLogView = require("./views/SqlLogView/SqlLogView");
13
+ var _TableView = require("./views/TableView/TableView");
14
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+ 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, _toPropertyKey(descriptor.key), descriptor); } }
17
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
+ var Viewer = /*#__PURE__*/function () {
21
+ function Viewer(config, onClickClose) {
22
+ _classCallCheck(this, Viewer);
23
+ this.onClickClose = onClickClose;
24
+ this.createElements();
25
+ (0, _dbWorkerConnector.connectToWorker)(config);
26
+ }
27
+ _createClass(Viewer, [{
28
+ key: "createElements",
29
+ value: function createElements() {
30
+ var _this = this;
31
+ this._container = document.createElement('div');
32
+ this._container.id = 'viewer';
33
+ var closeBtn = document.createElement('button');
34
+ closeBtn.id = 'close_btn';
35
+ closeBtn.innerText = 'Close';
36
+ closeBtn.onclick = function () {
37
+ _this.onClickClose();
38
+ };
39
+ this._container.appendChild(closeBtn);
40
+
41
+ // Left Panel
42
+ var leftPanel = document.createElement('div');
43
+ leftPanel.id = 'db_list';
44
+ (0, _ExplorerView.createExplorerView)(leftPanel, this._container);
45
+ this._container.appendChild(leftPanel);
46
+
47
+ // Middle Panel
48
+ var middlePanel = document.createElement('div');
49
+ middlePanel.id = 'middle_panel';
50
+ var listResizeHandlerEl = (0, _resizeHandler.createResizeHandler)(leftPanel, middlePanel, true, this._container);
51
+ this._container.appendChild(listResizeHandlerEl);
52
+ var tableViewEl = document.createElement('div');
53
+ tableViewEl.id = 'table_view';
54
+ middlePanel.appendChild(tableViewEl);
55
+ (0, _TableView.createTableView)(tableViewEl);
56
+ this._container.append(middlePanel);
57
+
58
+ // Right Panel
59
+ var rightPanel = document.createElement('div');
60
+ rightPanel.id = 'right_panel';
61
+ var rightPanelResizeHandlerEl = (0, _resizeHandler.createResizeHandler)(middlePanel, rightPanel, false, this._container);
62
+ this._container.appendChild(rightPanelResizeHandlerEl);
63
+ (0, _EditCellView.createEditCellView)(rightPanel);
64
+ (0, _ExecuteSQLView.createSQLExecutorView)(rightPanel);
65
+ (0, _SqlLogView.createSqlLogView)(rightPanel);
66
+ this._container.append(rightPanel);
67
+ }
68
+ }, {
69
+ key: "element",
70
+ get: function get() {
71
+ return this._container;
72
+ }
73
+ }]);
74
+ return Viewer;
75
+ }();
76
+ exports.Viewer = Viewer;
@@ -4,8 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EditCellView = void 0;
7
- var _viewerState = require("../../viewerState");
7
+ exports.createEditCellView = createEditCellView;
8
+ var Bus = _interopRequireWildcard(require("../../bus"));
9
+ var _QueryRunner = require("../../QueryRunner");
10
+ var _state = require("../../state");
8
11
  require("./styles.css");
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
14
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
15
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
16
  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, _toPropertyKey(descriptor.key), descriptor); } }
@@ -13,17 +18,20 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
13
18
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
19
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
20
  var EditCellView = /*#__PURE__*/function () {
16
- function EditCellView(viewerElem, rootEl) {
21
+ function EditCellView(rootEl) {
17
22
  var _this = this;
18
23
  _classCallCheck(this, EditCellView);
19
- this.viewerElem = viewerElem;
20
24
  this.rootEl = rootEl;
21
25
  this.buildDom();
22
- viewerElem.addEventListener('cellSelected', function (event) {
23
- var cell = event.detail;
24
- _this.currentCell = cell;
25
- _this.textArea.value = cell.value;
26
- _this.textArea.select();
26
+ Bus.listen('cell-selected', function (cell) {
27
+ if (cell) {
28
+ _this.textArea.value = cell.value;
29
+ _this.textArea.select();
30
+ _this.textArea.placeholder = '';
31
+ } else {
32
+ _this.textArea.value = '';
33
+ _this.textArea.placeholder = 'Select cell to edit...';
34
+ }
27
35
  });
28
36
  }
29
37
  _createClass(EditCellView, [{
@@ -36,10 +44,12 @@ var EditCellView = /*#__PURE__*/function () {
36
44
  header.innerText = 'Edit Cell';
37
45
  container.appendChild(header);
38
46
  this.textArea = document.createElement('textarea');
47
+ this.textArea.placeholder = 'Select cell to edit...';
39
48
  this.textArea.id = 'execute_sql_textarea';
40
49
  container.appendChild(this.textArea);
41
50
  var executeBtn = document.createElement('button');
42
51
  executeBtn.innerText = 'Apply';
52
+ executeBtn.classList.add('panelActionBtn');
43
53
  executeBtn.onclick = this.handleApplyEdit.bind(this);
44
54
  container.appendChild(executeBtn);
45
55
  this.rootEl.appendChild(container);
@@ -48,27 +58,30 @@ var EditCellView = /*#__PURE__*/function () {
48
58
  key: "handleApplyEdit",
49
59
  value: function handleApplyEdit() {
50
60
  if (this.textArea.value) {
51
- var _this$queryRunner2, _this$currentCell, _this$currentCell2, _this$currentCell3;
52
- if (!_viewerState.ViewerState.instance.hasChanges) {
53
- var _this$queryRunner;
54
- (_this$queryRunner = this.queryRunner) === null || _this$queryRunner === void 0 ? void 0 : _this$queryRunner.runQuery({
61
+ var _this$currentCell, _this$currentCell2, _this$currentCell3;
62
+ if (!(0, _state.isDirty)()) {
63
+ _QueryRunner.queryRunner.runQuery({
55
64
  sql: 'SAVEPOINT "RESTOREPOINT"',
56
65
  parameters: []
57
66
  });
58
67
  }
59
- (_this$queryRunner2 = this.queryRunner) === null || _this$queryRunner2 === void 0 ? void 0 : _this$queryRunner2.runQuery({
68
+ _QueryRunner.queryRunner.runQuery({
60
69
  sql: "UPDATE ".concat((_this$currentCell = this.currentCell) === null || _this$currentCell === void 0 ? void 0 : _this$currentCell.tableName, " SET \"").concat((_this$currentCell2 = this.currentCell) === null || _this$currentCell2 === void 0 ? void 0 : _this$currentCell2.columnName, "\"=? WHERE \"_rowid_\"='").concat((_this$currentCell3 = this.currentCell) === null || _this$currentCell3 === void 0 ? void 0 : _this$currentCell3.cellRowId, "'"),
61
70
  parameters: [this.textArea.value]
62
71
  });
63
- _viewerState.ViewerState.instance.setHasChanges(true);
72
+ if (this.currentCell) {
73
+ Bus.emit('cell-edited', {
74
+ cell: this.currentCell,
75
+ value: this.textArea.value
76
+ });
77
+ }
78
+ (0, _state.setDirty)(true);
64
79
  }
65
80
  }
66
- }, {
67
- key: "setDb",
68
- value: function setDb(queryRunner) {
69
- this.queryRunner = queryRunner;
70
- }
71
81
  }]);
72
82
  return EditCellView;
73
83
  }();
74
- exports.EditCellView = EditCellView;
84
+ exports.EditCellView = EditCellView;
85
+ function createEditCellView(rootEl) {
86
+ return new EditCellView(rootEl);
87
+ }
@@ -1,23 +1,30 @@
1
1
  #execute_sql_container {
2
2
  display: flex;
3
3
  flex-direction: column;
4
+ height: 100%;
4
5
  }
5
6
 
6
7
  #execute_sql_editor {
7
8
  position: relative;
8
- background-color: white;
9
- height: 300px;
9
+ background-color: #fff;
10
+ height: 100%;
10
11
  }
11
12
 
12
13
  #execute_sql_textarea {
13
14
  resize: none;
14
- height: 300px;
15
- background-color: white;
15
+ height: 100%;
16
+ min-height: 150px;
17
+ background: #f8fafc;
16
18
  overflow: auto;
17
19
  white-space: nowrap;
18
- font-size: 10pt;
19
- font-family: monospace;
20
- line-height: 1.5;
20
+ font-size: 12px;
21
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
22
+ line-height: 1.45;
21
23
  tab-size: 2;
22
- caret-color: black;
24
+ caret-color: #111827;
25
+ color: #0f172a;
26
+ border: 0;
27
+ border-top: 1px solid #e5e7eb;
28
+ border-bottom: 1px solid #e5e7eb;
29
+ border-radius: 0;
23
30
  }
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ExecuteSQLView = void 0;
6
+ exports.createSQLExecutorView = createSQLExecutorView;
7
+ var _QueryRunner = require("../../QueryRunner");
7
8
  require("./styles.css");
8
9
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -31,6 +32,7 @@ var ExecuteSQLView = /*#__PURE__*/function () {
31
32
  container.appendChild(this.textArea);
32
33
  var executeBtn = document.createElement('button');
33
34
  executeBtn.innerText = 'Execute SQL';
35
+ executeBtn.classList.add('panelActionBtn');
34
36
  executeBtn.onclick = this.handleExecuteSql.bind(this);
35
37
  container.appendChild(executeBtn);
36
38
  this.rootEl.appendChild(container);
@@ -39,19 +41,15 @@ var ExecuteSQLView = /*#__PURE__*/function () {
39
41
  key: "handleExecuteSql",
40
42
  value: function handleExecuteSql() {
41
43
  if (this.textArea.value) {
42
- var _this$queryRunner;
43
- (_this$queryRunner = this.queryRunner) === null || _this$queryRunner === void 0 ? void 0 : _this$queryRunner.runQuery({
44
+ _QueryRunner.queryRunner.runQuery({
44
45
  sql: this.textArea.value,
45
46
  parameters: []
46
47
  });
47
48
  }
48
49
  }
49
- }, {
50
- key: "setDb",
51
- value: function setDb(queryRunner) {
52
- this.queryRunner = queryRunner;
53
- }
54
50
  }]);
55
51
  return ExecuteSQLView;
56
52
  }();
57
- exports.ExecuteSQLView = ExecuteSQLView;
53
+ function createSQLExecutorView(rootEl) {
54
+ return new ExecuteSQLView(rootEl);
55
+ }
@@ -1,47 +1,51 @@
1
1
  #execute_sql_container {
2
2
  display: flex;
3
3
  flex-direction: column;
4
+ height: 100%;
4
5
  }
5
6
 
6
7
  #execute_sql_editor {
7
8
  position: relative;
8
- background-color: white;
9
- height: 300px;
9
+ background-color: #fff;
10
+ height: 100%;
10
11
  }
11
12
 
12
13
  #execute_sql_textarea, #execute_sql_highlighting {
13
14
  resize: none;
14
- height: 300px;
15
- background-color: white;
15
+ height: 100%;
16
+ min-height: 150px;
17
+ background: #f8fafc;
16
18
  overflow: auto;
17
19
  white-space: nowrap;
18
- font-size: 10pt;
19
- font-family: monospace;
20
- line-height: 1.5;
20
+ font-size: 12px;
21
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
22
+ line-height: 1.45;
21
23
  tab-size: 2;
22
- caret-color: black;
24
+ caret-color: #111827;
25
+ color: #0f172a;
23
26
  }
24
27
 
25
28
  #execute_sql_highlighting {
26
29
  z-index: 0;
27
30
  margin: 0;
28
- padding: 2px;
31
+ padding: 8px;
32
+ border-top: 1px solid #e5e7eb;
33
+ border-bottom: 1px solid #e5e7eb;
34
+ border-radius: 0;
29
35
  }
30
36
 
31
37
  .highlighting {
32
- color: blue;
38
+ color: #2563eb;
33
39
  }
34
40
 
35
41
  .sql-hl-keyword {
36
- color: purple;
37
- /* font-weight: 600; */
42
+ color: #7c3aed;
38
43
  }
39
44
 
40
45
  .sql-hl-special {
41
- color: black;
46
+ color: #0f172a;
42
47
  }
43
48
 
44
49
  .sql-hl-string {
45
- color: red;
46
- /* font-weight: 600; */
50
+ color: #dc2626;
47
51
  }
@@ -4,8 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ExplorerView = void 0;
7
- var _viewerState = require("../../viewerState");
7
+ exports.createExplorerView = createExplorerView;
8
+ var Bus = _interopRequireWildcard(require("../../bus"));
9
+ var _state = require("../../state");
8
10
  require("./styles.css");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
13
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
15
  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, _toPropertyKey(descriptor.key), descriptor); } }
@@ -16,11 +20,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
16
20
  var EXPANDED_EXPLORER_ITEMS_KEY = 'expanded_explorer_items';
17
21
  var ExplorerView = /*#__PURE__*/function () {
18
22
  function ExplorerView(rootEl, viewEl) {
19
- var _localStorage$getItem;
23
+ var _this = this,
24
+ _localStorage$getItem;
20
25
  _classCallCheck(this, ExplorerView);
21
26
  _defineProperty(this, "expandedItems", {});
22
27
  _defineProperty(this, "selectedItem", null);
23
28
  _defineProperty(this, "showFullItemLabelTimeout", 0);
29
+ Bus.listen('db-found', function (table) {
30
+ _this.addDatabaseItem(table);
31
+ });
24
32
  this.dbs = [];
25
33
  this.scheduleShowFullItemLabel = this.scheduleShowFullItemLabel.bind(this);
26
34
  this.hideFullItemLabel = this.hideFullItemLabel.bind(this);
@@ -52,16 +60,16 @@ var ExplorerView = /*#__PURE__*/function () {
52
60
  }, {
53
61
  key: "buildDom",
54
62
  value: function buildDom() {
55
- var _this = this;
63
+ var _this2 = this;
56
64
  this.containerEl.innerHTML = '';
57
65
  this.dbs.forEach(function (db) {
58
- _this.buildDbGroupDom(db);
66
+ _this2.buildDbGroupDom(db);
59
67
  });
60
68
  }
61
69
  }, {
62
70
  key: "buildDbGroupDom",
63
71
  value: function buildDbGroupDom(db) {
64
- var _this2 = this;
72
+ var _this3 = this;
65
73
  var dbRoot = document.createDocumentFragment();
66
74
  var dbItem = document.createElement('div');
67
75
  this.setupCommonItemDom(dbItem);
@@ -74,7 +82,7 @@ var ExplorerView = /*#__PURE__*/function () {
74
82
  this.buildExpandArrowDom(dbItem, tablesContainer, db, isExpanded);
75
83
  dbRoot.appendChild(dbItem);
76
84
  db.tables.forEach(function (table) {
77
- _this2.buildTableDom(tablesContainer, table, db);
85
+ _this3.buildTableDom(tablesContainer, table, db);
78
86
  });
79
87
  tablesContainer.style.display = isExpanded ? 'block' : 'none';
80
88
  dbRoot.appendChild(tablesContainer);
@@ -83,7 +91,7 @@ var ExplorerView = /*#__PURE__*/function () {
83
91
  }, {
84
92
  key: "buildExpandArrowDom",
85
93
  value: function buildExpandArrowDom(itemElem, tablesContainer, db, isExpanded) {
86
- var _this3 = this;
94
+ var _this4 = this;
87
95
  var expandArrow = document.createElement('div');
88
96
  expandArrow.className = 'expand';
89
97
  expandArrow.innerHTML = '&#9656;';
@@ -92,24 +100,24 @@ var ExplorerView = /*#__PURE__*/function () {
92
100
  expandArrow.classList.add('expanded');
93
101
  }
94
102
  expandArrow.onclick = function () {
95
- _this3.expandedItems[db.filename] = !_this3.expandedItems[db.filename];
96
- tablesContainer.style.display = _this3.expandedItems[db.filename] ? 'block' : 'none';
103
+ _this4.expandedItems[db.filename] = !_this4.expandedItems[db.filename];
104
+ tablesContainer.style.display = _this4.expandedItems[db.filename] ? 'block' : 'none';
97
105
  expandArrow.classList.toggle('expanded');
98
- localStorage.setItem(EXPANDED_EXPLORER_ITEMS_KEY, JSON.stringify(_this3.expandedItems));
106
+ localStorage.setItem(EXPANDED_EXPLORER_ITEMS_KEY, JSON.stringify(_this4.expandedItems));
99
107
  };
100
108
  itemElem.appendChild(expandArrow);
101
109
  }
102
110
  }, {
103
111
  key: "buildTableDom",
104
112
  value: function buildTableDom(tablesContainer, tableName, db) {
105
- var _this4 = this,
113
+ var _this5 = this,
106
114
  _this$selectedItem,
107
115
  _this$selectedItem2;
108
116
  var tableItem = document.createElement('div');
109
117
  this.setupCommonItemDom(tableItem);
110
118
  tableItem.classList.add('table');
111
119
  tableItem.onclick = function () {
112
- _this4.selectTable(tableItem, db);
120
+ _this5.selectTable(tableItem, db);
113
121
  };
114
122
  if (((_this$selectedItem = this.selectedItem) === null || _this$selectedItem === void 0 ? void 0 : _this$selectedItem.tableName) === tableName && ((_this$selectedItem2 = this.selectedItem) === null || _this$selectedItem2 === void 0 ? void 0 : _this$selectedItem2.dbName) === db.filename) {
115
123
  this.selectedItem.tableElem = tableItem;
@@ -132,7 +140,7 @@ var ExplorerView = /*#__PURE__*/function () {
132
140
  tableElem: tableEl
133
141
  };
134
142
  var databasePath = databaseItem.filename;
135
- _viewerState.ViewerState.instance.setSelectedTable({
143
+ (0, _state.selectTable)({
136
144
  tableName: tableName,
137
145
  databasePath: databasePath
138
146
  });
@@ -156,13 +164,13 @@ var ExplorerView = /*#__PURE__*/function () {
156
164
  }, {
157
165
  key: "scheduleShowFullItemLabel",
158
166
  value: function scheduleShowFullItemLabel(event) {
159
- var _this5 = this;
167
+ var _this6 = this;
160
168
  var item = event.target;
161
169
  var label = item.querySelector('.label');
162
170
  if (label && label.offsetWidth < label.scrollWidth) {
163
171
  clearTimeout(this.showFullItemLabelTimeout);
164
172
  this.showFullItemLabelTimeout = window.setTimeout(function () {
165
- _this5.showFullItemLabel(item);
173
+ _this6.showFullItemLabel(item);
166
174
  }, 300);
167
175
  }
168
176
  }
@@ -190,4 +198,12 @@ var ExplorerView = /*#__PURE__*/function () {
190
198
  }]);
191
199
  return ExplorerView;
192
200
  }();
193
- exports.ExplorerView = ExplorerView;
201
+ exports.ExplorerView = ExplorerView;
202
+ var _explorerView;
203
+ function createExplorerView(rootEl, viewEl) {
204
+ if (!_explorerView) {
205
+ _explorerView = new ExplorerView(rootEl, viewEl);
206
+ } else {
207
+ // console.warn('ExplorerView is already created');
208
+ }
209
+ }
@@ -1,19 +1,21 @@
1
1
  #explorer_tree {
2
- padding: 8px;
3
- padding-left: 20px;
2
+ padding: 8px 8px 8px 20px;
4
3
  overflow-y: auto;
5
4
  scrollbar-gutter: stable;
5
+ background: #fff;
6
6
  }
7
7
 
8
8
  #explorer_tree .item {
9
- height: 20px;
9
+ height: 26px;
10
10
  white-space: nowrap;
11
11
  text-overflow: ellipsis;
12
- background-color: darkgray;
12
+ background: transparent;
13
+ border-radius: 6px;
14
+ color: #334155;
13
15
  }
14
16
 
15
17
  #explorer_tree .item > .label {
16
- padding: 2px 4px;
18
+ padding: 4px 8px;
17
19
  overflow: hidden;
18
20
  text-overflow: ellipsis;
19
21
  }
@@ -24,14 +26,15 @@
24
26
 
25
27
  #explorer_tree .expand {
26
28
  position: absolute;
27
- top: 1px;
29
+ top: 3px;
28
30
  left: -20px;
29
31
  width: 20px;
30
32
  height: 20px;
31
33
  display: flex;
32
34
  align-items: center;
33
35
  justify-content: center;
34
- transition: all .1s ease-in;
36
+ color: #64748b;
37
+ transition: all 0.12s ease-in;
35
38
  }
36
39
 
37
40
  #explorer_tree .expanded {
@@ -43,16 +46,25 @@
43
46
  cursor: pointer;
44
47
  }
45
48
 
49
+ #explorer_tree .table:hover,
50
+ #explorer_tree .db:hover {
51
+ background: #f1f5f9;
52
+ }
53
+
46
54
  #explorer_tree .table.selected {
47
- background-color: rgb(128, 128, 128);
55
+ background: #e2e8f0;
56
+ color: #0f172a;
57
+ font-weight: 600;
48
58
  }
49
59
 
50
60
  #viewer #full_label {
51
61
  position: absolute;
52
62
  pointer-events: none;
53
63
  z-index: 99999;
54
- border: 1px solid gray;
55
- background-color: darkgray;
56
- padding: 2px 4px;
57
- border-radius: 2px;
64
+ border: 1px solid #cbd5e1;
65
+ background-color: #fff;
66
+ color: #0f172a;
67
+ padding: 4px 8px;
68
+ border-radius: 6px;
69
+ box-shadow: 0 6px 20px rgba(15, 23, 42, 0.16);
58
70
  }
@@ -3,8 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.initSqlLogView = initSqlLogView;
6
+ exports.createSqlLogView = createSqlLogView;
7
+ var Bus = _interopRequireWildcard(require("../../bus"));
7
8
  require("./styles.css");
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
8
11
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
12
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
13
  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, _toPropertyKey(descriptor.key), descriptor); } }
@@ -12,10 +15,16 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
12
15
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
16
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
17
  var SqlLogView = /*#__PURE__*/function () {
15
- function SqlLogView(rootEl, queryRunner) {
18
+ function SqlLogView(rootEl) {
16
19
  var _this = this;
17
20
  _classCallCheck(this, SqlLogView);
18
- queryRunner.addListener(this.handleQueryRun.bind(this));
21
+ Bus.listen('query-run', function (query) {
22
+ if (query.errorMsg) {
23
+ _this.textArea.value += "Error while running previous query: ".concat(query.errorMsg, "\n");
24
+ } else {
25
+ _this.textArea.value += "".concat(query.sql, "\n");
26
+ }
27
+ });
19
28
  var container = document.createElement('div');
20
29
  container.id = 'sql_log_container';
21
30
  var header = document.createElement('div');
@@ -43,6 +52,6 @@ var SqlLogView = /*#__PURE__*/function () {
43
52
  }]);
44
53
  return SqlLogView;
45
54
  }();
46
- function initSqlLogView(rootEl, queryRunner) {
47
- return new SqlLogView(rootEl, queryRunner);
55
+ function createSqlLogView(rootEl) {
56
+ return new SqlLogView(rootEl);
48
57
  }
@@ -2,9 +2,19 @@
2
2
  flex-grow: 1;
3
3
  display: flex;
4
4
  flex-direction: column;
5
+ height: 100%;
5
6
  }
6
7
 
7
8
  #query_log_text {
8
9
  resize: none;
9
10
  height: 100%;
11
+ min-height: 150px;
12
+ background: #f8fafc;
13
+ color: #1e293b;
14
+ border: 0;
15
+ border-top: 1px solid #e5e7eb;
16
+ border-radius: 0;
17
+ font-size: 12px;
18
+ line-height: 1.45;
19
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
10
20
  }