Compare commits

...

3 Commits

Author SHA1 Message Date
35af57732e Fixed registerAdapter error 2021-03-02 18:19:18 -08:00
fa986fcdc9 Fixed webpack configuration issue and updated webpack 2021-03-02 17:56:45 -08:00
494cd97442 New webpack build 2021-03-02 15:07:30 -08:00
6 changed files with 769 additions and 3361 deletions

View File

@ -1,102 +1,70 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/pawsqlite.mjs");
/******/ })
/************************************************************************/
/******/ ({
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/adapter_wrapper.mjs":
/*!*********************************!*\
!*** ./src/adapter_wrapper.mjs ***!
\*********************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "wrapAdapter": () => (/* binding */ wrapAdapter)
/* harmony export */ });
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
function wrapAdapter(adapter) {
const wrapped = {};
["name", "open", "close", "delete", "sql"].forEach((prop) => {
if (!(prop in adapter)) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError(`Invalid adapter: missing property: ${ prop }`);
}
if (
prop === "name" && !(
typeof adapter[prop] === "string" ||
adapter[prop] instanceof String
) ||
prop !== "name" && (
typeof adapter[prop] !== "function"
)
) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError("Invalid adapter: invalid type for property: " +
prop);
}
if (typeof adapter[prop] === "function") {
wrapped[prop] = async (...args) => {
try {
return await adapter[prop](...args);
} catch (err) {
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError.from(err);
}
};
} else {
wrapped[prop] = adapter[prop];
}
});
return wrapped;
}
/***/ }),
/***/ "./src/database.mjs":
/*!**************************!*\
!*** ./src/database.mjs ***!
\**************************/
/*! exports provided: Database */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Database": () => (/* binding */ Database)
/* harmony export */ });
/* harmony import */ var _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction_manager.mjs */ "./src/transaction_manager.mjs");
@ -108,7 +76,7 @@ class Database {
this.version = null;
this.path = null;
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__["TransactionManager"](dbName, this.adapter);
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__.TransactionManager(dbName, this.adapter);
}
async open() {
@ -169,13 +137,13 @@ class Database {
/*!*********************!*\
!*** ./src/log.mjs ***!
\*********************/
/*! exports provided: log, enableDebug */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "log", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enableDebug", function() { return enableDebug; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "log": () => (/* binding */ log),
/* harmony export */ "enableDebug": () => (/* binding */ enableDebug)
/* harmony export */ });
let DEBUG = false;
function log(...args) {
@ -196,107 +164,16 @@ function enableDebug(active) {
/***/ }),
/***/ "./src/pawsqlite.mjs":
/*!***************************!*\
!*** ./src/pawsqlite.mjs ***!
\***************************/
/*! exports provided: default */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
const adapters = [];
/* harmony default export */ __webpack_exports__["default"] = ({
open: async function(dbName, options = {}) {
const adapter = getAdapter(options.adapter);
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__["Database"](dbName, adapter);
await db.open();
return db;
},
delete: function(dbName, options = {}) {
const adapter = getAdapter(options.adapter);
return adapter.delete(dbName);
},
registerAdapter: function(adapter) {
adapters.push(wrapAdapter(adapter));
},
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_2__["enableDebug"],
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]
});
function wrapAdapter() {
const wrapped = {};
["name", "open", "close", "delete", "sql"].forEach((prop) => {
if (!(prop in adapter)) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Invalid adapter: missing property: ${ prop }`);
}
if (
prop === "name" && !(
typeof adapter[prop] === "string" ||
adapter[prop] instanceof String
) ||
prop !== "name" && (
typeof adapter[prop] !== "function"
)
) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Invalid adapter: invalid type for property: " +
prop);
}
if (typeof adapter[prop] === "function") {
wrapped[prop] = async (...args) => {
try {
return await adapter[prop](...args);
} catch (err) {
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"].from(err);
}
};
} else {
wrapped[prop] = adapter[prop];
}
});
return wrapped;
}
function getAdapter(adapterName) {
const adapter = adapters.find((a) => a.name === adapterName);
if (!adapter) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Unknown Adapter: ${adapterName}`);
}
return adapter;
}
/***/ }),
/***/ "./src/pawsqlite_error.mjs":
/*!*********************************!*\
!*** ./src/pawsqlite_error.mjs ***!
\*********************************/
/*! exports provided: PawSQLiteError */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PawSQLiteError", function() { return PawSQLiteError; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "PawSQLiteError": () => (/* binding */ PawSQLiteError)
/* harmony export */ });
class PawSQLiteError extends Error {
static from(err) {
const p_err = new PawSQLiteError(err.toString());
@ -316,12 +193,12 @@ class PawSQLiteError extends Error {
/*!************************!*\
!*** ./src/result.mjs ***!
\************************/
/*! exports provided: Result */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Result", function() { return Result; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Result": () => (/* binding */ Result)
/* harmony export */ });
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
@ -349,12 +226,12 @@ class Result extends Array {
/*!*****************************!*\
!*** ./src/transaction.mjs ***!
\*****************************/
/*! exports provided: Transaction */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Transaction", function() { return Transaction; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Transaction": () => (/* binding */ Transaction)
/* harmony export */ });
/* harmony import */ var _result_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./result.mjs */ "./src/result.mjs");
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
@ -377,7 +254,7 @@ class Transaction {
async sql(sql, ...args) {
if (this._finalized) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
}
if (!this._ready) {
@ -405,7 +282,7 @@ class Transaction {
.filter(Array.isArray)
.map((a) => a.length);
if (parts.length !== subParamLengths.length + 1) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Unable to build query: sub-" +
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Unable to build query: sub-" +
"paramters do not match sub-paramters in query");
}
@ -451,14 +328,14 @@ class Transaction {
const match = reg.exec(sql);
if (match) {
const statement = match[1].toUpperCase();
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Manually managing transactions is " +
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Manually managing transactions is " +
"forbidden. Found: \"" + statement + "\" statement.");
}
const result = await this.adapter.sql(this.dbName,
...this.buildQuery(sql, ...args));
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
}
async _begin() {
@ -467,7 +344,7 @@ class Transaction {
async _complete(sql) {
if (this._finalized) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
}
this._finalized = true;
@ -492,7 +369,7 @@ class Transaction {
throw error;
}
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
}
}
@ -502,12 +379,12 @@ class Transaction {
/*!*************************************!*\
!*** ./src/transaction_manager.mjs ***!
\*************************************/
/*! exports provided: TransactionManager */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return TransactionManager; });
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "TransactionManager": () => (/* binding */ TransactionManager)
/* harmony export */ });
/* harmony import */ var _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction.mjs */ "./src/transaction.mjs");
@ -520,7 +397,7 @@ class TransactionManager {
}
transaction() {
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__["Transaction"](this.dbName, this.adapter,
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__.Transaction(this.dbName, this.adapter,
this.enqueue.bind(this));
}
@ -567,5 +444,125 @@ class TransactionManager {
/***/ })
/******/ })["default"];
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
/*!***************************!*\
!*** ./src/pawsqlite.mjs ***!
\***************************/
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
/* harmony import */ var _adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./adapter_wrapper.mjs */ "./src/adapter_wrapper.mjs");
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
const adapters = [];
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
open: async function(dbName, options = {}) {
const adapter = getAdapter(options.adapter);
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__.Database(dbName, adapter);
await db.open();
return db;
},
delete: function(dbName, options = {}) {
const adapter = getAdapter(options.adapter);
return adapter.delete(dbName);
},
registerAdapter: function(adapter) {
const wrapped = (0,_adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapAdapter)(adapter);
if (getAdapter(wrapped.name)) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
`Already exists`);
}
adapters.push(wrapped);
},
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_3__.enableDebug,
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError
});
function getAdapter(adapterName, silent=false) {
const adapter = adapters.find((a) => a.name === adapterName);
if (!(silent || adapter)) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`Unknown Adapter: ${adapterName}`);
}
return adapter;
}
})();
module.exports = __webpack_exports__.default;
/******/ })()
;
//# sourceMappingURL=pawsqlite.js.map

File diff suppressed because one or more lines are too long

3704
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
"author": "Ben Ashton",
"license": "MIT",
"devDependencies": {
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack": "5.x",
"webpack-cli": "4.x"
}
}

View File

@ -23,7 +23,7 @@ export default {
registerAdapter: function(adapter) {
const wrapped = wrapAdapter(adapter);
if (getAdapter(wrapped.name)) {
if (getAdapter(wrapped.name, true)) {
throw new PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
`Already exists`);
}

View File

@ -9,7 +9,6 @@ var config = {
output: {
path: __dirname + '/lib',
filename: outputFile,
library: libraryName,
libraryExport: 'default',
libraryTarget: 'commonjs2',
}