unified storage: safeInvoke fallback a Dexie cuando no hay Tauri
- tauri-db.ts: fallbackInvoke() para hu_drafts y users via Dexie - storage-router.ts: deteccion de entorno Tauri vs browser - storage-adapter.ts: capa unificada (preparada para futuros dominios) - build: en bun dev todo funciona sin Tauri
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* storage-router.ts
|
||||
*
|
||||
* Detecta si estamos en Tauri (Turso disponible) o navegador.
|
||||
* Enruta operaciones al backend adecuado.
|
||||
*
|
||||
* Estrategia:
|
||||
* - Tauri disponible → Turso (Rust) como fuente primaria
|
||||
* - Solo navegador → Dexie (IndexedDB)
|
||||
*
|
||||
* Para el futuro (RUMBO): este router desaparece, todo va a Turso directo.
|
||||
*/
|
||||
|
||||
let _isTauri: boolean | null = null
|
||||
|
||||
export function isTauri(): boolean {
|
||||
if (_isTauri !== null) return _isTauri
|
||||
try {
|
||||
_isTauri = typeof window !== 'undefined' &&
|
||||
(window as any).__TAURI_INTERNALS__ !== undefined
|
||||
} catch {
|
||||
_isTauri = false
|
||||
}
|
||||
return _isTauri
|
||||
}
|
||||
|
||||
export const ADAPTER = {
|
||||
get name(): string {
|
||||
return isTauri() ? 'Turso' : 'Dexie'
|
||||
},
|
||||
get available(): boolean {
|
||||
return true // Siempre disponible (Dexie fallback)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user