From b589d7f5e50ec3dd66bd4da35b3865d43903fd44 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 07:54:16 -0700 Subject: [PATCH 01/19] - In progress --- e2e/public_html/opfs-error.worker.html | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 e2e/public_html/opfs-error.worker.html diff --git a/e2e/public_html/opfs-error.worker.html b/e2e/public_html/opfs-error.worker.html new file mode 100644 index 0000000..1d8c56e --- /dev/null +++ b/e2e/public_html/opfs-error.worker.html @@ -0,0 +1,70 @@ + + + + + @magieno/sqlite-client Memory (Worker) Error + + + + +
+
+
+ + + +

OPFS

+ +

Worker

+ +
+ +

Data Stored:

+ + + + + + + + + + + + +
First NameLast NameEmail
+
+
+
+ + + + + + + + \ No newline at end of file From ecf2840a2bda94101972faf6089a8b2745917152 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 07:55:27 -0700 Subject: [PATCH 02/19] - Addex exports. --- src/enums/enums.ts | 4 ++++ src/messages/messages.ts | 4 ++++ src/types/types.ts | 1 + 3 files changed, 9 insertions(+) create mode 100644 src/enums/enums.ts create mode 100644 src/messages/messages.ts create mode 100644 src/types/types.ts diff --git a/src/enums/enums.ts b/src/enums/enums.ts new file mode 100644 index 0000000..878a7da --- /dev/null +++ b/src/enums/enums.ts @@ -0,0 +1,4 @@ +export * from "./return-value.enum"; +export * from "./row-mode.enum"; +export * from "./sqlite-client-type.enum"; +export * from "./sqlite-message-type.enum"; \ No newline at end of file diff --git a/src/messages/messages.ts b/src/messages/messages.ts new file mode 100644 index 0000000..75dd284 --- /dev/null +++ b/src/messages/messages.ts @@ -0,0 +1,4 @@ +export * from "./create-database.message"; +export * from "./create-database-result.message"; +export * from "./execute-sql.message"; +export * from "./execute-sql-result.message"; \ No newline at end of file diff --git a/src/types/types.ts b/src/types/types.ts new file mode 100644 index 0000000..75bcb5d --- /dev/null +++ b/src/types/types.ts @@ -0,0 +1 @@ +export * from "./sqlite-client.options"; \ No newline at end of file From fbee4e6f7d638fbce40ee5f52513259e204dad48 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 07:56:24 -0700 Subject: [PATCH 03/19] - Added exports. --- src/adapters/adapters.ts | 2 ++ src/interfaces/interfaces.ts | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 src/adapters/adapters.ts create mode 100644 src/interfaces/interfaces.ts diff --git a/src/adapters/adapters.ts b/src/adapters/adapters.ts new file mode 100644 index 0000000..cf65098 --- /dev/null +++ b/src/adapters/adapters.ts @@ -0,0 +1,2 @@ +export * from "./in-main-thread.sqlite-adapter"; +export * from "./in-worker.sqlite-adapter"; \ No newline at end of file diff --git a/src/interfaces/interfaces.ts b/src/interfaces/interfaces.ts new file mode 100644 index 0000000..8b82d8e --- /dev/null +++ b/src/interfaces/interfaces.ts @@ -0,0 +1,6 @@ +export * from "./memory-main-thread-sqlite-options.interface"; +export * from "./memory-worker-sqlite-options.interface"; +export * from "./opfs-sah-worker-sqlite-options.interface"; +export * from "./opfs-worker-sqlite-options.interface"; +export * from "./sqlite-adapter.interface"; +export * from "./sqlite-message.interface"; \ No newline at end of file From 134adf4f0158a082e47e59566cadd34f63885b2b Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 07:57:18 -0700 Subject: [PATCH 04/19] - exports. --- src/proxies/proxies.ts | 1 + src/sqlite-client.ts | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 src/proxies/proxies.ts diff --git a/src/proxies/proxies.ts b/src/proxies/proxies.ts new file mode 100644 index 0000000..663f2db --- /dev/null +++ b/src/proxies/proxies.ts @@ -0,0 +1 @@ +export * from "./sqlite-client-worker.proxy"; \ No newline at end of file diff --git a/src/sqlite-client.ts b/src/sqlite-client.ts index 1193ecb..b49f3e9 100644 --- a/src/sqlite-client.ts +++ b/src/sqlite-client.ts @@ -6,6 +6,13 @@ import {ReturnValueEnum} from "./enums/return-value.enum"; import {RowModeEnum} from "./enums/row-mode.enum"; import {InWorkerSqliteAdapter} from "./adapters/in-worker.sqlite-adapter"; +export * from "./adapters/adapters"; +export * from "./enums/enums"; +export * from "./interfaces/interfaces"; +export * from "./messages/messages"; +export * from "./proxies/proxies"; +export * from "./types/types"; + export class SqliteClient { public readonly adapter: SqliteAdapterInterface; From aeaec3bc713d28ebae37c713e06a3fb0a5d461c4 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 07:59:30 -0700 Subject: [PATCH 05/19] - Added test. --- e2e/public_html/opfs-error.worker.html | 23 +++--------------- .../main-thread-and-worker-error.spec.js | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 e2e/specs/main-thread-and-worker-error.spec.js diff --git a/e2e/public_html/opfs-error.worker.html b/e2e/public_html/opfs-error.worker.html index 1d8c56e..151cee9 100644 --- a/e2e/public_html/opfs-error.worker.html +++ b/e2e/public_html/opfs-error.worker.html @@ -25,21 +25,6 @@

OPFS

Worker

- -

Data Stored:

- - - - - - - - - - - - -
First NameLast NameEmail
@@ -54,13 +39,11 @@

Data Stored:

try { sqliteClient.executeSql("INVALID SQL"); } catch (e) { - document.getElementById("alert-container").innerHTML = "
\n" + - "

Success!

\n" + - "

The data has been loaded successfully.

\n" + + document.getElementById("alert-container").innerHTML = "
\n" + + "

Error!

\n" + + "

There was an error executing the SQL Query

\n" + "
"; } - - From affc002c0672c223b3aa706c45ebb194f7ee5f57 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 2 Apr 2024 08:59:19 -0700 Subject: [PATCH 09/19] - Fixed the issue. --- e2e/public_html/opfs-error.worker.html | 2 +- package-lock.json | 16 ++++++++-------- package.json | 2 +- src/sqlite-client.ts | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/e2e/public_html/opfs-error.worker.html b/e2e/public_html/opfs-error.worker.html index 4b3e544..f4b7e96 100644 --- a/e2e/public_html/opfs-error.worker.html +++ b/e2e/public_html/opfs-error.worker.html @@ -43,7 +43,7 @@

Worker

document.getElementById("alert-container").innerHTML = "
\n" + "

Error!

\n" + "

There was an error executing the SQL Query:

\n" + - "
" + JSON.stringify(e) + "
" + + "
" + e.message + "
" + "
"; } diff --git a/package-lock.json b/package-lock.json index ca5b5a2..30ca3a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-ignore": "^1.0.10", "rollup-plugin-typescript2": "^0.34.1", - "typescript": "^5.0.4" + "typescript": "^5.4.3" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -706,16 +706,16 @@ "dev": true }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", + "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/universalify": { @@ -1242,9 +1242,9 @@ "dev": true }, "typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", + "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index ca73ca5..531e927 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-ignore": "^1.0.10", "rollup-plugin-typescript2": "^0.34.1", - "typescript": "^5.0.4" + "typescript": "^5.4.3" }, "files": [ "dist" diff --git a/src/sqlite-client.ts b/src/sqlite-client.ts index 1508c5f..b49f3e9 100644 --- a/src/sqlite-client.ts +++ b/src/sqlite-client.ts @@ -40,7 +40,6 @@ export class SqliteClient { throw new Error("You need to call `init` before calling `executeSql`."); } - const response = this.adapter.executeSql(sqlStatement, bindParameters, returnValue, rowMode); - + return this.adapter.executeSql(sqlStatement, bindParameters, returnValue, rowMode); } } From 349ff40083f8442fbf4f3031f672576155ccff2a Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Wed, 3 Apr 2024 08:24:44 -0700 Subject: [PATCH 10/19] - Added extension support. --- package.json | 2 +- .../opfs-worker-sqlite-options.interface.ts | 3 + src/sqlite-client-extension.ts | 64 +++++++++++++++++++ src/sqlite-client.ts | 11 +++- 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/sqlite-client-extension.ts diff --git a/package.json b/package.json index 531e927..7d1424a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@magieno/sqlite-client", - "version": "3.45.1-build1", + "version": "3.45.1-build3-with-extension-support", "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", diff --git a/src/interfaces/opfs-worker-sqlite-options.interface.ts b/src/interfaces/opfs-worker-sqlite-options.interface.ts index 6588a11..0bb6ee2 100644 --- a/src/interfaces/opfs-worker-sqlite-options.interface.ts +++ b/src/interfaces/opfs-worker-sqlite-options.interface.ts @@ -8,4 +8,7 @@ export interface OpfsWorkerSqliteOptionsInterface { flags: string; sqliteWorkerPath: string; + + // Default: false; + emitEventsToMagienoSqliteChromeExtension?: boolean; } \ No newline at end of file diff --git a/src/sqlite-client-extension.ts b/src/sqlite-client-extension.ts new file mode 100644 index 0000000..af7e62c --- /dev/null +++ b/src/sqlite-client-extension.ts @@ -0,0 +1,64 @@ +import {SqliteClientTypeEnum} from "./enums/sqlite-client-type.enum"; +import {ReturnValueEnum, RowModeEnum, SqliteClient} from "./sqlite-client"; + +export class SqliteClientExtension { + public static workerPath: string; + + error: string; + + static dispatchEvent(event: {type: string, uniqueId: string, [x: string]: any}) { + window.dispatchEvent(new CustomEvent("MAGIENO_SQLITE_CLIENT_TO_EXTENSION", { + detail: event, + })); + } + + public static registerWorkerPath(sqliteWorkerPath) { + SqliteClientExtension.workerPath = sqliteWorkerPath; + + // Cache the worker path in CacheStorage, so that the extension can use it when the app is in other pages. + caches.open("magieno").then(cache => { + cache.put("sqlite-worker", new Response(sqliteWorkerPath)); + }); + } + + /** + * This method registers and enables event listeners that will be used by the Magieno SQLite Editor Chrome Extension. + * @param workerPath + */ + static register(workerPath: string) { + SqliteClientExtension.registerWorkerPath(workerPath); + + // Setup the listeners + window.addEventListener('MAGIENO_SQLITE_CLIENT_FROM_EXTENSION', async (event: CustomEvent) => { + await SqliteClientExtension.receiveEvent(event); + }); + } + + static async receiveEvent(event: CustomEvent) { + const detail = event.detail; + + switch (detail.type) { + case "INIT": + if(SqliteClientExtension.workerPath === undefined) { + SqliteClientExtension.dispatchEvent({"type": "INIT_RESULT", "uniqueId": detail.uniqueId, "error": "Cannot find the SqliteWorkerPath. For security reasons, you must manually register it in your page: `SqliteClientExtension.registerWorkerPath('/path/to/sqlite-worker.mjs')`"}); + return; + } + + SqliteClientExtension.dispatchEvent({"type": "INIT_RESULT", "uniqueId": detail.uniqueId}); + return; + case "EXECUTE_SQL_QUERY": + const client = new SqliteClient({ + type: SqliteClientTypeEnum.OpfsWorker, + filename: detail.filename, + flags: "c", + sqliteWorkerPath: SqliteClientExtension.workerPath, + }) + + 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; + } + } +} \ No newline at end of file diff --git a/src/sqlite-client.ts b/src/sqlite-client.ts index b49f3e9..801c943 100644 --- a/src/sqlite-client.ts +++ b/src/sqlite-client.ts @@ -5,6 +5,7 @@ import {InMainThreadSqliteAdapter} from "./adapters/in-main-thread.sqlite-adapte import {ReturnValueEnum} from "./enums/return-value.enum"; import {RowModeEnum} from "./enums/row-mode.enum"; import {InWorkerSqliteAdapter} from "./adapters/in-worker.sqlite-adapter"; +import {SqliteClientExtension} from "./sqlite-client-extension"; export * from "./adapters/adapters"; export * from "./enums/enums"; @@ -12,6 +13,7 @@ export * from "./interfaces/interfaces"; export * from "./messages/messages"; export * from "./proxies/proxies"; export * from "./types/types"; +export * from "./sqlite-client-extension"; export class SqliteClient { public readonly adapter: SqliteAdapterInterface; @@ -21,10 +23,15 @@ export class SqliteClient { case SqliteClientTypeEnum.MemoryMainThread: this.adapter = new InMainThreadSqliteAdapter(this.options); break; - case SqliteClientTypeEnum.MemoryWorker: case SqliteClientTypeEnum.OpfsWorker: + if(this.options.emitEventsToMagienoSqliteChromeExtension === true) { // Only available to OpfsWorker for now. + // Register the worker path so the extension can use it to interact with your SQLite databases. + SqliteClientExtension.register(this.options.sqliteWorkerPath); + } + case SqliteClientTypeEnum.MemoryWorker: case SqliteClientTypeEnum.OpfsSahWorker: this.adapter = new InWorkerSqliteAdapter(this.options); + break; default: throw new Error(`Unknown sqlite client type for options: '${this.options}.`); @@ -42,4 +49,4 @@ export class SqliteClient { return this.adapter.executeSql(sqlStatement, bindParameters, returnValue, rowMode); } -} +} \ No newline at end of file From 6fedee5882e6e0871bc2d22dcbce671d77955750 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Wed, 3 Apr 2024 19:45:22 -0700 Subject: [PATCH 11/19] - Updated the chrome extension to catch and dispatch errors. --- README.md | 3 +++ package-lock.json | 4 ++-- package.json | 6 ++++-- src/sqlite-client-extension.ts | 10 +++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f5f7047..b34d413 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/package-lock.json b/package-lock.json index 30ca3a1..cf1b054 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@magieno/sqlite-client", - "version": "3.45.1-build1", + "version": "3.45.1-build3-with-extension-support", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@magieno/sqlite-client", - "version": "3.45.1-build1", + "version": "3.45.1-build3-with-extension-support", "license": "ISC", "dependencies": { "@sqlite.org/sqlite-wasm": "^3.45.1-build1" diff --git a/package.json b/package.json index 7d1424a..3d91d80 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/sqlite-client-extension.ts b/src/sqlite-client-extension.ts index af7e62c..5707d20 100644 --- a/src/sqlite-client-extension.ts +++ b/src/sqlite-client-extension.ts @@ -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}); + } } } } \ No newline at end of file From 59e5844fc596adfaf8364752d4ad7937e4da9837 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 19:52:18 -0700 Subject: [PATCH 12/19] - ran npm install. --- package-lock.json | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf1b054..291e20d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,13 @@ { "name": "@magieno/sqlite-client", - "version": "3.45.1-build3-with-extension-support", + "version": "10.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@magieno/sqlite-client", - "version": "3.45.1-build3-with-extension-support", + "version": "10.0.0", "license": "ISC", - "dependencies": { - "@sqlite.org/sqlite-wasm": "^3.45.1-build1" - }, "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-json": "^6.0.0", @@ -20,6 +17,9 @@ "rollup-plugin-ignore": "^1.0.10", "rollup-plugin-typescript2": "^0.34.1", "typescript": "^5.4.3" + }, + "peerDependencies": { + "@sqlite.org/sqlite-wasm": "^3.41.2-build10" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -121,9 +121,10 @@ } }, "node_modules/@sqlite.org/sqlite-wasm": { - "version": "3.45.1-build1", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.1-build1.tgz", - "integrity": "sha512-1EgshFNhVeBtZ9KtQPm3PzzJ2CtpmXAq2DAPywy7WZ3gOK6p5n8TY+M+mBMpQCF5cLqrdNFb3Kp9uNie9rUAHw==", + "version": "3.41.2", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", + "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", + "peer": true, "bin": { "sqlite-wasm": "bin/index.js" } @@ -796,9 +797,10 @@ } }, "@sqlite.org/sqlite-wasm": { - "version": "3.45.1-build1", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.1-build1.tgz", - "integrity": "sha512-1EgshFNhVeBtZ9KtQPm3PzzJ2CtpmXAq2DAPywy7WZ3gOK6p5n8TY+M+mBMpQCF5cLqrdNFb3Kp9uNie9rUAHw==" + "version": "3.41.2", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", + "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", + "peer": true }, "@types/estree": { "version": "1.0.1", From 882c9cc54319497110d51c59ffed3e5e9a92d6cf Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 19:57:46 -0700 Subject: [PATCH 13/19] - Fixed the failing test. --- e2e/specs/main-thread-and-worker-error.spec.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e/specs/main-thread-and-worker-error.spec.js b/e2e/specs/main-thread-and-worker-error.spec.js index 6220c07..2095020 100644 --- a/e2e/specs/main-thread-and-worker-error.spec.js +++ b/e2e/specs/main-thread-and-worker-error.spec.js @@ -1,8 +1,5 @@ const htmlFilesToLoad = [ - // "memory.main-thread.html", - // "memory.worker.html", "opfs-error.worker.html", - //"opfs-sah.worker.html", ] htmlFilesToLoad.forEach((htmlFile) => { @@ -12,13 +9,15 @@ htmlFilesToLoad.forEach((htmlFile) => { headless: true, }); - await page.waitForSelector('#success'); + await page.waitForSelector('#error'); }); it('should have the error alert', async () => { - const alert = await page.$('#error'); + const errorFound = await page.evaluate(() => { + return document.querySelector("#error") !== null; + }) - expect(alert).toBeDefined(); + expect(errorFound).toBeTruthy(); }); }); }) From f2ef017c8f4f340e1ce39a66177e9040eb7051ab Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 19:59:59 -0700 Subject: [PATCH 14/19] - Update --- e2e/specs/main-thread-and-worker-error.spec.js | 2 +- e2e/specs/main-thread-and-worker.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/specs/main-thread-and-worker-error.spec.js b/e2e/specs/main-thread-and-worker-error.spec.js index 2095020..562857e 100644 --- a/e2e/specs/main-thread-and-worker-error.spec.js +++ b/e2e/specs/main-thread-and-worker-error.spec.js @@ -4,7 +4,7 @@ const htmlFilesToLoad = [ htmlFilesToLoad.forEach((htmlFile) => { describe(htmlFile, () => { - beforeAll(async () => { + beforeEach(async () => { await page.goto(`http://127.0.0.1:9000/${htmlFile}`, { headless: true, }); diff --git a/e2e/specs/main-thread-and-worker.spec.js b/e2e/specs/main-thread-and-worker.spec.js index ccf6e0d..0efcb30 100644 --- a/e2e/specs/main-thread-and-worker.spec.js +++ b/e2e/specs/main-thread-and-worker.spec.js @@ -7,7 +7,7 @@ const htmlFilesToLoad = [ htmlFilesToLoad.forEach((htmlFile) => { describe(htmlFile, () => { - beforeAll(async () => { + beforeEach(async () => { await page.goto(`http://127.0.0.1:9000/${htmlFile}`, { headless: true, }); From b4aaf8d5329bb2571a2c7ad7bbbcd93acd20ac4c Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 20:04:16 -0700 Subject: [PATCH 15/19] - update. --- e2e/specs/main-thread-and-worker-error.spec.js | 2 +- e2e/specs/main-thread-and-worker.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/specs/main-thread-and-worker-error.spec.js b/e2e/specs/main-thread-and-worker-error.spec.js index 562857e..2095020 100644 --- a/e2e/specs/main-thread-and-worker-error.spec.js +++ b/e2e/specs/main-thread-and-worker-error.spec.js @@ -4,7 +4,7 @@ const htmlFilesToLoad = [ htmlFilesToLoad.forEach((htmlFile) => { describe(htmlFile, () => { - beforeEach(async () => { + beforeAll(async () => { await page.goto(`http://127.0.0.1:9000/${htmlFile}`, { headless: true, }); diff --git a/e2e/specs/main-thread-and-worker.spec.js b/e2e/specs/main-thread-and-worker.spec.js index 0efcb30..ccf6e0d 100644 --- a/e2e/specs/main-thread-and-worker.spec.js +++ b/e2e/specs/main-thread-and-worker.spec.js @@ -7,7 +7,7 @@ const htmlFilesToLoad = [ htmlFilesToLoad.forEach((htmlFile) => { describe(htmlFile, () => { - beforeEach(async () => { + beforeAll(async () => { await page.goto(`http://127.0.0.1:9000/${htmlFile}`, { headless: true, }); From 68c05d7714294c49c9b00885f55534463310caa6 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 20:10:20 -0700 Subject: [PATCH 16/19] - Added npm dependencies for tests --- e2e/package-lock.json | 16 ++++++++++++++++ e2e/package.json | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index 0314054..ddf8724 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "devDependencies": { "@pristine-ts/http": "^0.0.316", + "@sqlite.org/sqlite-wasm": "^3.45.2-build1", "@types/jest": "^29.5.12", "jest": "^29.7.0", "jest-puppeteer": "^10.0.1", @@ -1365,6 +1366,15 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@sqlite.org/sqlite-wasm": { + "version": "3.45.2-build1", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", + "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", + "dev": true, + "bin": { + "sqlite-wasm": "bin/index.js" + } + }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -6757,6 +6767,12 @@ "@sinonjs/commons": "^3.0.0" } }, + "@sqlite.org/sqlite-wasm": { + "version": "3.45.2-build1", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", + "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", + "dev": true + }, "@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", diff --git a/e2e/package.json b/e2e/package.json index 3d46abc..0780d8f 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -5,7 +5,7 @@ "main": "rollup.config.e2e.js", "type": "module", "scripts": { - "build": "tsc -p tsconfig.json && mkdir -p public_html/dist && cp -r ../dist/bundle/sqlite-client-worker.js public_html/dist/sqlite-client-worker.mjs && cp -r ../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/* public_html/dist/ && rollup -c rollup.config.e2e.js --compact", + "build": "tsc -p tsconfig.json && mkdir -p public_html/dist && cp -r ../dist/bundle/sqlite-client-worker.js public_html/dist/sqlite-client-worker.mjs && cp -r node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/* public_html/dist/ && rollup -c rollup.config.e2e.js --compact", "start:server": "pristine file-server:start --directory=./public_html --header=cross-origin-opener-policy:same-origin --header=cross-origin-embedder-policy:require-corp", "test": "pristine file-server:start --directory=./public_html --header=cross-origin-opener-policy:same-origin --header=cross-origin-embedder-policy:require-corp & jest --runInBand --detectOpenHandles --forceExit --verbose --silent=false --coverage" }, @@ -17,6 +17,7 @@ "jest": "^29.7.0", "jest-puppeteer": "^10.0.1", "ts-jest": "^29.1.2", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "@sqlite.org/sqlite-wasm": "^3.45.2-build1" } } From b47fbb348312636b6f4a6b8cb6e12c0b53a7b461 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 20:21:03 -0700 Subject: [PATCH 17/19] - Added private for protection. --- e2e/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/package.json b/e2e/package.json index 0780d8f..54cbc35 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -4,6 +4,7 @@ "description": "E2E testing ==========", "main": "rollup.config.e2e.js", "type": "module", + "private": true, "scripts": { "build": "tsc -p tsconfig.json && mkdir -p public_html/dist && cp -r ../dist/bundle/sqlite-client-worker.js public_html/dist/sqlite-client-worker.mjs && cp -r node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/* public_html/dist/ && rollup -c rollup.config.e2e.js --compact", "start:server": "pristine file-server:start --directory=./public_html --header=cross-origin-opener-policy:same-origin --header=cross-origin-embedder-policy:require-corp", From 018aaa3686fd205e06244532c621f6e164431712 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 20:21:29 -0700 Subject: [PATCH 18/19] - Update. --- e2e/package-lock.json | 14 +++++++------- e2e/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index ddf8724..db2adff 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "devDependencies": { "@pristine-ts/http": "^0.0.316", - "@sqlite.org/sqlite-wasm": "^3.45.2-build1", + "@sqlite.org/sqlite-wasm": "^3.41.2-build10", "@types/jest": "^29.5.12", "jest": "^29.7.0", "jest-puppeteer": "^10.0.1", @@ -1367,9 +1367,9 @@ } }, "node_modules/@sqlite.org/sqlite-wasm": { - "version": "3.45.2-build1", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", - "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", + "version": "3.41.2", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", + "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", "dev": true, "bin": { "sqlite-wasm": "bin/index.js" @@ -6768,9 +6768,9 @@ } }, "@sqlite.org/sqlite-wasm": { - "version": "3.45.2-build1", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", - "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", + "version": "3.41.2", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", + "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", "dev": true }, "@tootallnate/quickjs-emscripten": { diff --git a/e2e/package.json b/e2e/package.json index 54cbc35..0fe08f5 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -19,6 +19,6 @@ "jest-puppeteer": "^10.0.1", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", - "@sqlite.org/sqlite-wasm": "^3.45.2-build1" + "@sqlite.org/sqlite-wasm": "^3.41.2-build10" } } From 043270e6be973a27b6fd9725dfbac29b7aae134e Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Tue, 9 Apr 2024 20:30:47 -0700 Subject: [PATCH 19/19] - Last version works. --- e2e/package-lock.json | 14 +++++++------- e2e/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index db2adff..ddf8724 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "devDependencies": { "@pristine-ts/http": "^0.0.316", - "@sqlite.org/sqlite-wasm": "^3.41.2-build10", + "@sqlite.org/sqlite-wasm": "^3.45.2-build1", "@types/jest": "^29.5.12", "jest": "^29.7.0", "jest-puppeteer": "^10.0.1", @@ -1367,9 +1367,9 @@ } }, "node_modules/@sqlite.org/sqlite-wasm": { - "version": "3.41.2", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", - "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", + "version": "3.45.2-build1", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", + "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", "dev": true, "bin": { "sqlite-wasm": "bin/index.js" @@ -6768,9 +6768,9 @@ } }, "@sqlite.org/sqlite-wasm": { - "version": "3.41.2", - "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.41.2.tgz", - "integrity": "sha512-elKOYvLMzDDvKH28TF++iGPfqmsBBZG8iSCNo8lBSboSLCe+PBn3zwPO5NJRg9vojjMXVoRiifmBZ0IBdVBKjg==", + "version": "3.45.2-build1", + "resolved": "https://registry.npmjs.org/@sqlite.org/sqlite-wasm/-/sqlite-wasm-3.45.2-build1.tgz", + "integrity": "sha512-TeQf8rNFQna8pg95IshtpXkhdMq1iNAXllCoNrhEn18660Hbal9yxKAYv+ZfC1kjfdEXMK6V0XanfX5OT5FyMw==", "dev": true }, "@tootallnate/quickjs-emscripten": { diff --git a/e2e/package.json b/e2e/package.json index 0fe08f5..54cbc35 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -19,6 +19,6 @@ "jest-puppeteer": "^10.0.1", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", - "@sqlite.org/sqlite-wasm": "^3.41.2-build10" + "@sqlite.org/sqlite-wasm": "^3.45.2-build1" } }