Files
threshold-ui/addons/api/addon/workers/web-worker.js
T
Zhihe Li a9a6518b23 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
2025-09-03 11:41:40 -04:00

32 lines
819 B
JavaScript

/**
* 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();
})();