Rename to Plugin Compass, add mobile onboarding/signin, implement self-update for desktop, and fix workflow paths

This commit is contained in:
southseact-3d
2026-02-16 12:05:30 +00:00
parent 63698e1d19
commit d6e2af3a29
11 changed files with 945 additions and 138 deletions

View File

@@ -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
};