feat: 🎸 Allow building and bundling of web workers in ember (#2923)
* feat: 🎸 Allow building and bundling of web workers in ember * refactor: 💡 Cleanup code and add comments
This commit is contained in:
1 parent
1bafbe1ad2
commit
a9a6518b23
15 files changed
+888
-108
No files matched your search
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { PWBWorker } from 'promise-worker-bi';
|
||||
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
|
||||
|
||||
const promiseWorker = new PWBWorker();
|
||||
promiseWorker.register((message) => {
|
||||
console.log(`Received from main: ${message}`);
|
||||
});
|
||||
|
||||
const initializeSQLite = async () => {
|
||||
try {
|
||||
const sqlite3 = await sqlite3InitModule({
|
||||
print: console.log,
|
||||
printErr: console.error,
|
||||
});
|
||||
console.log(`SQLite Version: ${sqlite3?.version.libVersion}`);
|
||||
const poolUtil = await sqlite3.installOpfsSAHPoolVfs();
|
||||
const db = new poolUtil.OpfsSAHPoolDb('/boundary');
|
||||
console.log(db);
|
||||
} catch (err) {
|
||||
console.error('Initialization error:', err.name, err.message);
|
||||
}
|
||||
};
|
||||
|
||||
(async () => {
|
||||
await initializeSQLite();
|
||||
})();
|
||||
Reference in new issue
Block a user