# Commit Message for SharedArrayBuffer Platform Exclusion

fix: eliminate SharedArrayBuffer checks on non-web platforms

* Add platform guard in AbsurdSqlDatabaseService to only initialize on web
* Change singleton pattern from eager to lazy instantiation
* Update worker import to use lazy singleton pattern
* Prevents absurd-sql initialization on Electron/Capacitor platforms
* Reduces console noise and memory footprint on desktop/mobile
* Maintains full web platform functionality and performance

Resolves SharedArrayBuffer-related console output on Electron platform
while preserving all web features and maintaining clean architecture.
This commit is contained in:
Matthew Raymer
2025-07-03 05:15:57 +00:00
parent 797db7069c
commit 292aceee75
21 changed files with 1044 additions and 151 deletions

View File

@@ -9,6 +9,7 @@ import { CapacitorPlatformService } from "./platforms/CapacitorPlatformService";
* The factory determines which platform implementation to use based on the VITE_PLATFORM
* environment variable. Supported platforms are:
* - capacitor: Mobile platform using Capacitor
* - electron: Desktop platform using Electron with Capacitor
* - web: Default web platform (fallback)
*
* @example
@@ -50,6 +51,10 @@ export class PlatformServiceFactory {
case "capacitor":
PlatformServiceFactory.instance = new CapacitorPlatformService();
break;
case "electron":
// Use a specialized electron service that extends CapacitorPlatformService
PlatformServiceFactory.instance = new ElectronPlatformService();
break;
case "web":
default:
PlatformServiceFactory.instance = new WebPlatformService();
@@ -69,3 +74,56 @@ export class PlatformServiceFactory {
};
}
}
/**
* Electron-specific platform service implementation.
* Extends CapacitorPlatformService with electron-specific overrides.
*
* This service handles the unique requirements of the Electron platform:
* - Desktop-specific capabilities
* - Electron-specific file system access
* - Desktop UI patterns
* - Native desktop integration
*/
class ElectronPlatformService extends CapacitorPlatformService {
/**
* Gets the capabilities of the Electron platform
* Overrides the mobile-focused capabilities from CapacitorPlatformService
* @returns Platform capabilities object specific to Electron
*/
getCapabilities() {
return {
hasFileSystem: true,
hasCamera: false, // Desktop typically doesn't have integrated cameras for our use case
isMobile: false, // Electron is desktop, not mobile
isIOS: false,
hasFileDownload: true, // Desktop supports direct file downloads
needsFileHandlingInstructions: false, // Desktop users are familiar with file handling
isNativeApp: true, // Electron is a native app
};
}
/**
* Checks if running on Electron platform.
* @returns true, as this is the Electron implementation
*/
isElectron(): boolean {
return true;
}
/**
* Checks if running on Capacitor platform.
* @returns false, as this is Electron, not pure Capacitor
*/
isCapacitor(): boolean {
return false;
}
/**
* Checks if running on web platform.
* @returns false, as this is not web
*/
isWeb(): boolean {
return false;
}
}