Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370309
D8547.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8547.diff
View Options
diff --git a/web/database/db-module.js b/web/database/db-module.js
new file mode 100644
--- /dev/null
+++ b/web/database/db-module.js
@@ -0,0 +1,25 @@
+// @flow
+
+import Module from './_generated/comm-query-executor.js';
+import type { EmscriptenModule } from './types/module.js';
+import { DEFAULT_COMM_QUERY_EXECUTOR_FILENAME } from './utils/constants.js';
+
+function getDatabaseModule(
+ databaseModuleFilename?: ?string,
+ databaseModuleFilePath?: string,
+): EmscriptenModule {
+ const fileName = databaseModuleFilename
+ ? databaseModuleFilename
+ : DEFAULT_COMM_QUERY_EXECUTOR_FILENAME;
+
+ return Module({
+ locateFile: (path: string, prefix?: string) => {
+ if (databaseModuleFilePath) {
+ return `${databaseModuleFilePath}/${fileName}`;
+ }
+ return `${prefix ?? ''}${fileName}`;
+ },
+ });
+}
+
+export { getDatabaseModule };
diff --git a/web/database/utils/constants.js b/web/database/utils/constants.js
--- a/web/database/utils/constants.js
+++ b/web/database/utils/constants.js
@@ -10,6 +10,8 @@
export const DATABASE_WORKER_PATH = '/worker/database';
export const SQLJS_FILE_PATH = '/compiled/webworkers';
+export const DEFAULT_COMM_QUERY_EXECUTOR_FILENAME = 'comm_query_executor.wasm';
+
export const DB_SUPPORTED_OS: $ReadOnlyArray<string> = [
'Windows 10',
'Linux',
diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js
--- a/web/database/worker/db-worker.js
+++ b/web/database/worker/db-worker.js
@@ -19,7 +19,7 @@
type WorkerRequestProxyMessage,
workerWriteRequests,
} from '../../types/worker-types.js';
-import Module from '../_generated/comm-query-executor.js';
+import { getDatabaseModule } from '../db-module.js';
import { migrate, setupSQLiteDB } from '../queries/db-queries.js';
import {
getAllDrafts,
@@ -60,22 +60,13 @@
let persistNeeded: boolean = false;
let persistInProgress: boolean = false;
-const defaultCommQueryExecutorFilename = 'comm_query_executor.wasm';
-
async function initDatabase(
sqljsFilePath: string,
sqljsFilename: ?string,
commQueryExecutorFilename: ?string,
encryptionKeyJWK?: ?SubtleCrypto$JsonWebKey,
) {
- const dbModule = Module({
- locateFile: function () {
- if (commQueryExecutorFilename) {
- return `${sqljsFilePath}/${commQueryExecutorFilename}`;
- }
- return `${sqljsFilePath}/${defaultCommQueryExecutorFilename}`;
- },
- });
+ const dbModule = getDatabaseModule(commQueryExecutorFilename, sqljsFilePath);
try {
const result = dbModule.CommQueryExecutor.testDBOperation();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 1:56 AM (16 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587308
Default Alt Text
D8547.diff (2 KB)
Attached To
Mode
D8547: [web] add function to retrieve WASM module
Attached
Detach File
Event Timeline
Log In to Comment