refactor(compute): standardize compute mode detection for backend initialization
Update backend creation logic to consistently determine compute mode using a local variable, ensuring correct handling when the mode is undefined. This improves clarity and robustness in backend selection.
This commit is contained in:
parent
29b7cfafb9
commit
91d9fe47a5
1 changed files with 5 additions and 2 deletions
|
|
@ -7,8 +7,11 @@ declare const __OPENREADER_COMPUTE_MODE__: 'local' | 'worker' | 'none';
|
|||
let backendPromise: Promise<ComputeBackend> | null = null;
|
||||
|
||||
async function createBackend(): Promise<ComputeBackend> {
|
||||
if (__OPENREADER_COMPUTE_MODE__ === 'worker') return new WorkerComputeBackend();
|
||||
if (__OPENREADER_COMPUTE_MODE__ === 'local') {
|
||||
const bundledMode =
|
||||
typeof __OPENREADER_COMPUTE_MODE__ === 'undefined' ? 'none' : __OPENREADER_COMPUTE_MODE__;
|
||||
|
||||
if (bundledMode === 'worker') return new WorkerComputeBackend();
|
||||
if (bundledMode === 'local') {
|
||||
const { LocalComputeBackend } = await import('@/lib/server/compute/local');
|
||||
return new LocalComputeBackend();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue