Rename to Plugin Compass, add mobile onboarding/signin, implement self-update for desktop, and fix workflow paths
This commit is contained in:
@@ -1,8 +1,62 @@
|
||||
import { Preferences } from '@capacitor/preferences';
|
||||
|
||||
const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com';
|
||||
|
||||
export { Preferences };
|
||||
let PreferencesImpl = null;
|
||||
|
||||
async function getPreferences() {
|
||||
if (PreferencesImpl) return PreferencesImpl;
|
||||
|
||||
try {
|
||||
const module = await import('@capacitor/preferences');
|
||||
PreferencesImpl = module.Preferences;
|
||||
return PreferencesImpl;
|
||||
} catch {
|
||||
// Fallback to localStorage
|
||||
PreferencesImpl = {
|
||||
async get({ key }) {
|
||||
return { value: localStorage.getItem(key) };
|
||||
},
|
||||
async set({ key, value }) {
|
||||
localStorage.setItem(key, value);
|
||||
return;
|
||||
},
|
||||
async remove({ key }) {
|
||||
localStorage.removeItem(key);
|
||||
return;
|
||||
},
|
||||
async keys() {
|
||||
return { keys: Object.keys(localStorage) };
|
||||
},
|
||||
async clear() {
|
||||
localStorage.clear();
|
||||
return;
|
||||
}
|
||||
};
|
||||
return PreferencesImpl;
|
||||
}
|
||||
}
|
||||
|
||||
export const Preferences = {
|
||||
async get(options) {
|
||||
const pref = await getPreferences();
|
||||
return pref.get(options);
|
||||
},
|
||||
async set(options) {
|
||||
const pref = await getPreferences();
|
||||
return pref.set(options);
|
||||
},
|
||||
async remove(options) {
|
||||
const pref = await getPreferences();
|
||||
return pref.remove(options);
|
||||
},
|
||||
async keys() {
|
||||
const pref = await getPreferences();
|
||||
return pref.keys();
|
||||
},
|
||||
async clear() {
|
||||
const pref = await getPreferences();
|
||||
return pref.clear();
|
||||
}
|
||||
};
|
||||
|
||||
export async function syncApp(appId) {
|
||||
if (!appId || appId.trim() === '') {
|
||||
@@ -41,3 +95,9 @@ export async function runOpencodeTask(appId, taskName, args = []) {
|
||||
|
||||
throw new Error('OpenCode execution is not supported on mobile devices. Please use the desktop app for this feature.');
|
||||
}
|
||||
|
||||
window.nativeBridge = {
|
||||
Preferences,
|
||||
syncApp,
|
||||
runOpencodeTask
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user