sqlite-wasm-viewer 0.1.0 → 1.0.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/838.index.js +2 -0
- package/dist/838.index.js.LICENSE.txt +1 -0
- package/dist/index.js +466 -0
- package/dist/index.js.LICENSE.txt +1 -0
- package/dist/src_DbWorker_ts.index.js +118 -0
- package/{types.d.ts → index.d.ts} +1 -1
- package/package.json +23 -9
- package/src/DbViewerWorker.ts +0 -115
- package/src/DbWorker.ts +0 -8
- package/src/ListVirtualizer.ts +0 -125
- package/src/QueryRunner.ts +0 -36
- package/src/dbScanner.ts +0 -33
- package/src/index.ts +0 -157
- package/src/styles.css +0 -65
- package/src/types.ts +0 -34
- package/src/viewerState.ts +0 -49
- package/src/views/EditCellView/EditCellView.ts +0 -74
- package/src/views/EditCellView/styles.css +0 -23
- package/src/views/ExecuteSQLView/ExecuteSQLView.ts +0 -49
- package/src/views/ExecuteSQLView/styles.css +0 -47
- package/src/views/ExplorerView/ExplorerView.ts +0 -94
- package/src/views/ExplorerView/styles.css +0 -30
- package/src/views/SqlLogView/SqlLogView.ts +0 -37
- package/src/views/SqlLogView/styles.css +0 -10
- package/src/views/TableView/TableView.ts +0 -266
- package/src/views/TableView/styles.css +0 -79
- package/tsconfig.json +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/******/ "use strict";
|
|
11
|
+
/******/ var __webpack_modules__ = ({
|
|
12
|
+
|
|
13
|
+
/***/ "./src/DbViewerWorker.ts":
|
|
14
|
+
/*!*******************************!*\
|
|
15
|
+
!*** ./src/DbViewerWorker.ts ***!
|
|
16
|
+
\*******************************/
|
|
17
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
18
|
+
|
|
19
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DbViewerWorker: () => (/* binding */ DbViewerWorker)\n/* harmony export */ });\n/* harmony import */ var _sqlite_org_sqlite_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @sqlite.org/sqlite-wasm */ \"@sqlite.org/sqlite-wasm\");\n/* harmony import */ var _sqlite_org_sqlite_wasm__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_sqlite_org_sqlite_wasm__WEBPACK_IMPORTED_MODULE_0__);\nfunction _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); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, \"throw\" === methodName && delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method) || \"return\" !== methodName && (context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a '\" + methodName + \"' method\")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _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); }\n// @ts-expect-error Missing types\n\nvar DbViewerWorker = /*#__PURE__*/function () {\n function DbViewerWorker() {\n _classCallCheck(this, DbViewerWorker);\n _defineProperty(this, \"initialized\", false);\n this.initialized = false;\n this.sqliteDb = null;\n }\n _createClass(DbViewerWorker, [{\n key: \"post\",\n value: function post(message) {\n var _this = this;\n if (message.data.type !== 'init' && !this.initialized) {\n throw new Error(\"DbWorker not initialized with 'init' message\");\n }\n if (message.data.type === 'init') {\n if (this.initialized) {\n throw new Error('DbWorker already initialized');\n }\n _sqlite_org_sqlite_wasm__WEBPACK_IMPORTED_MODULE_0___default()().then( /*#__PURE__*/function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sqlite3) {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _this.sqlite = sqlite3;\n _this.sqliteCApi = sqlite3.capi;\n _this.initialized = true;\n _this.sendMessage({\n type: 'onReady'\n });\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }());\n }\n switch (message.data.type) {\n case 'readSchema':\n {\n var path = message.data.path;\n this.sqliteDb = new this.sqlite.oo1.OpfsDb(path, 'c');\n var sql = \"SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name\";\n var result = this.sqliteDb.exec({\n sql: sql,\n returnValue: 'resultRows'\n });\n this.sendMessage({\n type: 'onSchema',\n schema: result,\n dbName: path\n });\n }\n break;\n case 'query':\n {\n var _message$data$query = message.data.query,\n _sql = _message$data$query.sql,\n parameters = _message$data$query.parameters;\n var rawStatement = this.sqliteDb.prepare(_sql);\n var isReader = this.sqliteCApi.sqlite3_column_count(rawStatement) > 1;\n var resultRows = [];\n try {\n if ((parameters === null || parameters === void 0 ? void 0 : parameters.length) > 0) {\n rawStatement.bind(parameters);\n }\n while (rawStatement.step()) {\n // Kysely expects the results to be in the object mode\n var row = rawStatement.get({});\n resultRows.push(row);\n }\n } finally {\n rawStatement.finalize();\n }\n if (isReader) {\n this.sendMessage({\n type: 'onQuery',\n result: {\n resultRows: resultRows,\n tableName: ''\n },\n label: message.data.label\n });\n } else {\n var changes = this.sqliteCApi.sqlite3_changes(this.sqliteDb.pointer);\n var lastInsertRowid = this.sqliteCApi.sqlite3_last_insert_rowid(this.sqliteDb.pointer);\n var updates = {\n changes: changes,\n lastInsertRowid: lastInsertRowid\n };\n this.sendMessage({\n type: 'onQuery',\n result: {\n resultRows: resultRows,\n updates: updates,\n tableName: ''\n }\n });\n }\n }\n break;\n default:\n break;\n }\n }\n }, {\n key: \"sendMessage\",\n value: function sendMessage(message) {\n postMessage(message);\n }\n }]);\n return DbViewerWorker;\n}();\n\n//# sourceURL=webpack://sqlite-wasm-viewer/./src/DbViewerWorker.ts?");
|
|
20
|
+
|
|
21
|
+
/***/ }),
|
|
22
|
+
|
|
23
|
+
/***/ "./src/DbWorker.ts":
|
|
24
|
+
/*!*************************!*\
|
|
25
|
+
!*** ./src/DbWorker.ts ***!
|
|
26
|
+
\*************************/
|
|
27
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
28
|
+
|
|
29
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _DbViewerWorker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DbViewerWorker */ \"./src/DbViewerWorker.ts\");\n\nvar dbWorker = new _DbViewerWorker__WEBPACK_IMPORTED_MODULE_0__.DbViewerWorker();\nonmessage = function onmessage(message) {\n dbWorker.post(message);\n};\n\n//# sourceURL=webpack://sqlite-wasm-viewer/./src/DbWorker.ts?");
|
|
30
|
+
|
|
31
|
+
/***/ }),
|
|
32
|
+
|
|
33
|
+
/***/ "@sqlite.org/sqlite-wasm":
|
|
34
|
+
/*!***************************************************!*\
|
|
35
|
+
!*** external {"root":"@sqlite.org/sqlite-wasm"} ***!
|
|
36
|
+
\***************************************************/
|
|
37
|
+
/***/ ((module) => {
|
|
38
|
+
|
|
39
|
+
module.exports = undefined;
|
|
40
|
+
|
|
41
|
+
/***/ })
|
|
42
|
+
|
|
43
|
+
/******/ });
|
|
44
|
+
/************************************************************************/
|
|
45
|
+
/******/ // The module cache
|
|
46
|
+
/******/ var __webpack_module_cache__ = {};
|
|
47
|
+
/******/
|
|
48
|
+
/******/ // The require function
|
|
49
|
+
/******/ function __webpack_require__(moduleId) {
|
|
50
|
+
/******/ // Check if module is in cache
|
|
51
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
52
|
+
/******/ if (cachedModule !== undefined) {
|
|
53
|
+
/******/ return cachedModule.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/ // Create a new module (and put it into the cache)
|
|
56
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
57
|
+
/******/ // no module.id needed
|
|
58
|
+
/******/ // no module.loaded needed
|
|
59
|
+
/******/ exports: {}
|
|
60
|
+
/******/ };
|
|
61
|
+
/******/
|
|
62
|
+
/******/ // Execute the module function
|
|
63
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
64
|
+
/******/
|
|
65
|
+
/******/ // Return the exports of the module
|
|
66
|
+
/******/ return module.exports;
|
|
67
|
+
/******/ }
|
|
68
|
+
/******/
|
|
69
|
+
/************************************************************************/
|
|
70
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
71
|
+
/******/ (() => {
|
|
72
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
73
|
+
/******/ __webpack_require__.n = (module) => {
|
|
74
|
+
/******/ var getter = module && module.__esModule ?
|
|
75
|
+
/******/ () => (module['default']) :
|
|
76
|
+
/******/ () => (module);
|
|
77
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
78
|
+
/******/ return getter;
|
|
79
|
+
/******/ };
|
|
80
|
+
/******/ })();
|
|
81
|
+
/******/
|
|
82
|
+
/******/ /* webpack/runtime/define property getters */
|
|
83
|
+
/******/ (() => {
|
|
84
|
+
/******/ // define getter functions for harmony exports
|
|
85
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
86
|
+
/******/ for(var key in definition) {
|
|
87
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
88
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
89
|
+
/******/ }
|
|
90
|
+
/******/ }
|
|
91
|
+
/******/ };
|
|
92
|
+
/******/ })();
|
|
93
|
+
/******/
|
|
94
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
95
|
+
/******/ (() => {
|
|
96
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
97
|
+
/******/ })();
|
|
98
|
+
/******/
|
|
99
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
100
|
+
/******/ (() => {
|
|
101
|
+
/******/ // define __esModule on exports
|
|
102
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
103
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
104
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
105
|
+
/******/ }
|
|
106
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
107
|
+
/******/ };
|
|
108
|
+
/******/ })();
|
|
109
|
+
/******/
|
|
110
|
+
/************************************************************************/
|
|
111
|
+
/******/
|
|
112
|
+
/******/ // startup
|
|
113
|
+
/******/ // Load entry module and return exports
|
|
114
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
115
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/DbWorker.ts");
|
|
116
|
+
/******/
|
|
117
|
+
/******/ })()
|
|
118
|
+
;
|
|
@@ -2,6 +2,6 @@ type Config = {
|
|
|
2
2
|
isSqliteDatabase: (fileName: string) => boolean;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
export declare function setConfig(userConfig
|
|
5
|
+
export declare function setConfig(userConfig?: Partial<Config>): void;
|
|
6
6
|
export declare function showViewer(): void;
|
|
7
7
|
export declare function hideViewer(): void;
|
package/package.json
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqlite-wasm-viewer",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A SQLite OPFS viewer that
|
|
5
|
-
"main": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A SQLite OPFS database viewer that enables database inspection and SQL command execution.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
7
|
+
"publish": "webpack --config ./webpack.config.js && yarn npm publish"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"sqlite",
|
|
11
|
+
"opfs",
|
|
12
|
+
"wasm",
|
|
13
|
+
"sql"
|
|
14
|
+
],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Andrey Efimov",
|
|
17
|
+
"email": "mifozski@gmail.com",
|
|
18
|
+
"url": "https://github.com/mifozski"
|
|
11
19
|
},
|
|
12
|
-
"keywords": [],
|
|
13
|
-
"author": "MysticEggs",
|
|
14
20
|
"license": "ISC",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/mifozski/sqlite-wasm-viewer.git"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/",
|
|
27
|
+
"index.d.ts"
|
|
28
|
+
],
|
|
15
29
|
"devDependencies": {
|
|
16
30
|
"@babel/cli": "^7.22.9",
|
|
17
31
|
"@babel/core": "^7.22.9",
|
package/src/DbViewerWorker.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// @ts-expect-error Missing types
|
|
2
|
-
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
|
|
3
|
-
import { DbWorkerInput, DbWorkerOutput } from './types';
|
|
4
|
-
|
|
5
|
-
export class DbViewerWorker {
|
|
6
|
-
private initialized = false;
|
|
7
|
-
|
|
8
|
-
sqlite: any;
|
|
9
|
-
|
|
10
|
-
sqliteCApi: any;
|
|
11
|
-
|
|
12
|
-
sqliteDb: any;
|
|
13
|
-
|
|
14
|
-
constructor() {
|
|
15
|
-
this.initialized = false;
|
|
16
|
-
this.sqliteDb = null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
post(message: MessageEvent<DbWorkerInput>) {
|
|
20
|
-
if (message.data.type !== 'init' && !this.initialized) {
|
|
21
|
-
throw new Error("DbWorker not initialized with 'init' message");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (message.data.type === 'init') {
|
|
25
|
-
if (this.initialized) {
|
|
26
|
-
throw new Error('DbWorker already initialized');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
sqlite3InitModule().then(async (sqlite3: any) => {
|
|
30
|
-
this.sqlite = sqlite3;
|
|
31
|
-
this.sqliteCApi = sqlite3.capi;
|
|
32
|
-
|
|
33
|
-
this.initialized = true;
|
|
34
|
-
this.sendMessage({ type: 'onReady' });
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
switch (message.data.type) {
|
|
39
|
-
case 'readSchema':
|
|
40
|
-
{
|
|
41
|
-
const { path } = message.data;
|
|
42
|
-
|
|
43
|
-
this.sqliteDb = new this.sqlite.oo1.OpfsDb(path, 'c');
|
|
44
|
-
|
|
45
|
-
const sql = `SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name`;
|
|
46
|
-
|
|
47
|
-
const result = this.sqliteDb.exec({
|
|
48
|
-
sql,
|
|
49
|
-
returnValue: 'resultRows',
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
this.sendMessage({
|
|
53
|
-
type: 'onSchema',
|
|
54
|
-
schema: result,
|
|
55
|
-
dbName: path,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'query':
|
|
60
|
-
{
|
|
61
|
-
const { sql, parameters } = message.data.query;
|
|
62
|
-
|
|
63
|
-
const rawStatement = this.sqliteDb.prepare(sql);
|
|
64
|
-
|
|
65
|
-
const isReader =
|
|
66
|
-
this.sqliteCApi.sqlite3_column_count(rawStatement) > 1;
|
|
67
|
-
const resultRows: any[] = [];
|
|
68
|
-
try {
|
|
69
|
-
if (parameters?.length > 0) {
|
|
70
|
-
rawStatement.bind(parameters);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
while (rawStatement.step()) {
|
|
74
|
-
// Kysely expects the results to be in the object mode
|
|
75
|
-
const row = rawStatement.get({});
|
|
76
|
-
resultRows.push(row);
|
|
77
|
-
}
|
|
78
|
-
} finally {
|
|
79
|
-
rawStatement.finalize();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isReader) {
|
|
83
|
-
this.sendMessage({
|
|
84
|
-
type: 'onQuery',
|
|
85
|
-
result: { resultRows, tableName: '' },
|
|
86
|
-
label: message.data.label,
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
const changes = this.sqliteCApi.sqlite3_changes(
|
|
90
|
-
this.sqliteDb.pointer
|
|
91
|
-
);
|
|
92
|
-
const lastInsertRowid =
|
|
93
|
-
this.sqliteCApi.sqlite3_last_insert_rowid(
|
|
94
|
-
this.sqliteDb.pointer
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const updates = { changes, lastInsertRowid };
|
|
98
|
-
|
|
99
|
-
this.sendMessage({
|
|
100
|
-
type: 'onQuery',
|
|
101
|
-
result: { resultRows, updates, tableName: '' },
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
|
|
107
|
-
default:
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
sendMessage(message: DbWorkerOutput) {
|
|
113
|
-
postMessage(message);
|
|
114
|
-
}
|
|
115
|
-
}
|
package/src/DbWorker.ts
DELETED
package/src/ListVirtualizer.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
interface Config {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
totalRows: number;
|
|
5
|
-
itemHeight: number;
|
|
6
|
-
container: HTMLElement;
|
|
7
|
-
contentRoot: HTMLElement;
|
|
8
|
-
generatorFn: (index: number) => HTMLElement | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ListVirtualizer {
|
|
12
|
-
private height: number;
|
|
13
|
-
|
|
14
|
-
private itemHeight: number;
|
|
15
|
-
|
|
16
|
-
private totalRows: number;
|
|
17
|
-
|
|
18
|
-
private container: HTMLElement;
|
|
19
|
-
|
|
20
|
-
private contentRoot: HTMLElement;
|
|
21
|
-
|
|
22
|
-
private lastRepaintY: number;
|
|
23
|
-
|
|
24
|
-
private screenItemsLen: number;
|
|
25
|
-
|
|
26
|
-
private scrollTop: number;
|
|
27
|
-
|
|
28
|
-
private generatorFn: (index: number) => HTMLElement | null;
|
|
29
|
-
|
|
30
|
-
constructor(config: Config) {
|
|
31
|
-
this.height = config.height;
|
|
32
|
-
this.itemHeight = config.itemHeight;
|
|
33
|
-
|
|
34
|
-
this.lastRepaintY = 0;
|
|
35
|
-
|
|
36
|
-
this.scrollTop = 0;
|
|
37
|
-
|
|
38
|
-
this.generatorFn = config.generatorFn;
|
|
39
|
-
this.totalRows = config.totalRows;
|
|
40
|
-
|
|
41
|
-
this.container = config.container;
|
|
42
|
-
this.contentRoot = config.contentRoot;
|
|
43
|
-
|
|
44
|
-
this.renderChunk(0);
|
|
45
|
-
|
|
46
|
-
this.container.addEventListener('scroll', this.handleScroll.bind(this));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
handleScroll(e: MouseEvent) {
|
|
50
|
-
const { scrollTop } = e.target as HTMLElement;
|
|
51
|
-
|
|
52
|
-
this.scrollTop = scrollTop;
|
|
53
|
-
const screenItemsLen = Math.ceil(this.height / this.itemHeight);
|
|
54
|
-
const maxBuffer = this.screenItemsLen * this.itemHeight;
|
|
55
|
-
let first = Math.ceil(scrollTop / this.itemHeight - screenItemsLen);
|
|
56
|
-
first = first < 0 ? 0 : first;
|
|
57
|
-
if (
|
|
58
|
-
!this.lastRepaintY ||
|
|
59
|
-
Math.abs(scrollTop - this.lastRepaintY) > maxBuffer
|
|
60
|
-
) {
|
|
61
|
-
this.renderChunk(first);
|
|
62
|
-
this.lastRepaintY = scrollTop;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
renderChunk(fromPos: number) {
|
|
69
|
-
this.screenItemsLen = Math.ceil(this.height / this.itemHeight);
|
|
70
|
-
|
|
71
|
-
// Cache 4 times the number of items that fit in the container viewport
|
|
72
|
-
const cachedItemsLen = this.screenItemsLen * 3;
|
|
73
|
-
|
|
74
|
-
const fragment = document.createDocumentFragment();
|
|
75
|
-
|
|
76
|
-
let itemCount = fromPos + cachedItemsLen;
|
|
77
|
-
if (itemCount > this.totalRows) {
|
|
78
|
-
itemCount = this.totalRows;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (fromPos > 0) {
|
|
82
|
-
const offsetterRowEl = document.createElement('tr');
|
|
83
|
-
const offsetterEl = document.createElement('td');
|
|
84
|
-
offsetterEl.style.height = `${fromPos * this.itemHeight}px`;
|
|
85
|
-
offsetterRowEl.appendChild(offsetterEl);
|
|
86
|
-
|
|
87
|
-
fragment.appendChild(offsetterRowEl);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for (let i = fromPos; i < itemCount; i++) {
|
|
91
|
-
const item = this.generatorFn(i);
|
|
92
|
-
|
|
93
|
-
if (!item) {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
fragment.appendChild(item);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (itemCount < this.totalRows) {
|
|
101
|
-
const bottomOffsetterRow = document.createElement('tr');
|
|
102
|
-
const offsetterEl = document.createElement('td');
|
|
103
|
-
offsetterEl.style.height = `${
|
|
104
|
-
(this.totalRows - itemCount) * this.itemHeight
|
|
105
|
-
}px`;
|
|
106
|
-
bottomOffsetterRow.appendChild(offsetterEl);
|
|
107
|
-
|
|
108
|
-
fragment.appendChild(bottomOffsetterRow);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.contentRoot.innerHTML = '';
|
|
112
|
-
this.contentRoot.appendChild(fragment);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public setRowCount(rowCount: number) {
|
|
116
|
-
this.totalRows = rowCount;
|
|
117
|
-
|
|
118
|
-
let first = Math.ceil(
|
|
119
|
-
this.scrollTop / this.itemHeight - this.screenItemsLen
|
|
120
|
-
);
|
|
121
|
-
first = first < 0 ? 0 : first;
|
|
122
|
-
|
|
123
|
-
this.renderChunk(first);
|
|
124
|
-
}
|
|
125
|
-
}
|
package/src/QueryRunner.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Database } from './types';
|
|
2
|
-
|
|
3
|
-
export interface Query {
|
|
4
|
-
sql: string;
|
|
5
|
-
parameters: any[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type Listener = (query: Query) => void;
|
|
9
|
-
|
|
10
|
-
export class QueryRunner {
|
|
11
|
-
private listeners: Listener[];
|
|
12
|
-
|
|
13
|
-
constructor(private db: Database) {
|
|
14
|
-
this.listeners = [];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
runQuery(query: Query, label?: string) {
|
|
18
|
-
this.db.post({ type: 'query', query, label });
|
|
19
|
-
|
|
20
|
-
this.listeners.forEach((listener) => {
|
|
21
|
-
listener(query);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
addListener(listener: Listener): () => void {
|
|
26
|
-
if (this.listeners.indexOf(listener) !== -1) {
|
|
27
|
-
throw new Error('Listener is already added');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
this.listeners.push(listener);
|
|
31
|
-
|
|
32
|
-
return () => {
|
|
33
|
-
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/dbScanner.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export async function collectDbFiles(
|
|
2
|
-
isSqliteDatabase: (fileName: string) => boolean
|
|
3
|
-
): Promise<string[]> {
|
|
4
|
-
const root = await navigator.storage.getDirectory();
|
|
5
|
-
|
|
6
|
-
const dbFileHandlers = await getDbFiles(root, isSqliteDatabase);
|
|
7
|
-
|
|
8
|
-
return Promise.all(
|
|
9
|
-
dbFileHandlers.map((dbFile) => {
|
|
10
|
-
return root.resolve(dbFile).then((parts) => parts?.join('/') || '');
|
|
11
|
-
})
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function getDbFiles(
|
|
16
|
-
root: FileSystemDirectoryHandle,
|
|
17
|
-
isSqliteDatabase: (fileName: string) => boolean
|
|
18
|
-
): Promise<FileSystemFileHandle[]> {
|
|
19
|
-
let dbs: FileSystemFileHandle[] = [];
|
|
20
|
-
|
|
21
|
-
for await (const handle of root.values()) {
|
|
22
|
-
const child = handle;
|
|
23
|
-
|
|
24
|
-
if (child.kind === 'directory') {
|
|
25
|
-
const childDbs = await getDbFiles(child, isSqliteDatabase);
|
|
26
|
-
dbs = dbs.concat(dbs, ...childDbs);
|
|
27
|
-
} else if (isSqliteDatabase(child.name)) {
|
|
28
|
-
dbs.push(child);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return dbs;
|
|
33
|
-
}
|