Add capacitor

This commit is contained in:
nicwands
2026-04-06 11:35:26 -04:00
parent 1fc972a3f0
commit 2a9e0ef9be
65 changed files with 1732 additions and 52 deletions

View File

@@ -0,0 +1,20 @@
import { Preferences } from '@capacitor/preferences'
const CONFIG_KEY = 'app_config'
export function createCapacitorStorage() {
return {
async load() {
const { value } = await Preferences.get({ key: CONFIG_KEY })
return value ? JSON.parse(value) : null
},
async save(data) {
await Preferences.set({
key: CONFIG_KEY,
value: JSON.stringify(data),
})
},
}
}
export default createCapacitorStorage

View File

@@ -42,6 +42,9 @@ const initConfigManager = async (runtime, pluginManager) => {
storage = createNodeStorage(filesystemPlugin)
} else if (runtime === 'web') {
storage = createWebStorage()
} else if (runtime === 'capacitor') {
const { createCapacitorStorage } = await import('./CapacitorStorage.js')
storage = createCapacitorStorage()
}
return createConfigManager(storage, pluginManager)