Skip to content

Commit

Permalink
- Updated the chrome extension to catch and dispatch errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennenoel committed Apr 4, 2024
1 parent 349ff40 commit 6fedee5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This library supports the following backing mechanism:
* OPFS (Worker)
* OPFS SyncAccessHandles (Worker)

## Chrome Extension
Available when using this library: Magieno SQLite Viewer Chrome Extension. This extension allows you to execute SQL Queries and see the results in a table format.

## Installation using NPM

This library has two important files: `sqlite-client.js` and `sqlite-client-worker.js`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magieno/sqlite-client",
"version": "3.45.1-build3-with-extension-support",
"version": "10.0.0",
"description": "SQLite Client is a wrapper for Sqlite on Wasm that uses the Origin Private File System to persist the sqlite database file.",
"keywords": [
"sqlite",
Expand Down Expand Up @@ -39,7 +39,9 @@
},
"homepage": "https://github.com/magieno/sqlite-client#readme",
"dependencies": {
"@sqlite.org/sqlite-wasm": "^3.45.1-build1"
},
"peerDependencies": {
"@sqlite.org/sqlite-wasm": "^3.41.2-build10"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
Expand Down
10 changes: 7 additions & 3 deletions src/sqlite-client-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ export class SqliteClientExtension {

await client.init();

const response = await client.executeSql(detail.query, [], ReturnValueEnum.ResultRows, RowModeEnum.Object);
SqliteClientExtension.dispatchEvent({"type": "EXECUTE_SQL_QUERY_RESULT", "uniqueId": detail.uniqueId, "filename": detail.filename, "response": response});
return;
try {
const response = await client.executeSql(detail.query, [], ReturnValueEnum.ResultRows, RowModeEnum.Object);
SqliteClientExtension.dispatchEvent({"type": "EXECUTE_SQL_QUERY_RESULT", "uniqueId": detail.uniqueId, "filename": detail.filename, "response": response});
return;
} catch (error) {
SqliteClientExtension.dispatchEvent({"type": "EXECUTE_SQL_QUERY_RESULT", "uniqueId": detail.uniqueId, "error": error.message});
}
}
}
}

0 comments on commit 6fedee5

Please sign in to comment.