New webpack build

This commit is contained in:
Ben Ashton 2021-03-02 15:07:30 -08:00
parent 5517a0ba1d
commit 494cd97442
2 changed files with 71 additions and 46 deletions

View File

@ -87,6 +87,59 @@ module.exports =
/************************************************************************/ /************************************************************************/
/******/ ({ /******/ ({
/***/ "./src/adapter_wrapper.mjs":
/*!*********************************!*\
!*** ./src/adapter_wrapper.mjs ***!
\*********************************/
/*! exports provided: wrapAdapter */
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wrapAdapter", function() { return wrapAdapter; });
/* 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":
/*!**************************!*\ /*!**************************!*\
!*** ./src/database.mjs ***! !*** ./src/database.mjs ***!
@ -206,8 +259,10 @@ function enableDebug(active) {
"use strict"; "use strict";
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs"); /* 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 _adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./adapter_wrapper.mjs */ "./src/adapter_wrapper.mjs");
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log.mjs */ "./src/log.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");
@ -230,56 +285,26 @@ const adapters = [];
return adapter.delete(dbName); return adapter.delete(dbName);
}, },
registerAdapter: function(adapter) { registerAdapter: function(adapter) {
adapters.push(wrapAdapter(adapter)); const wrapped = Object(_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_2__["enableDebug"], debug: _log_mjs__WEBPACK_IMPORTED_MODULE_3__["enableDebug"],
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"] Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__["PawSQLiteError"]
}); });
function wrapAdapter() {
const wrapped = {};
["name", "open", "close", "delete", "sql"].forEach((prop) => { function getAdapter(adapterName, silent=false) {
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); const adapter = adapters.find((a) => a.name === adapterName);
if (!adapter) { if (!(silent || adapter)) {
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Unknown Adapter: ${adapterName}`); throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__["PawSQLiteError"](`Unknown Adapter: ${adapterName}`);
} }
return adapter; return adapter;

File diff suppressed because one or more lines are too long