muspe-cli
Version:
MusPE Advanced Framework v2.1.3 - Mobile User-friendly Simple Progressive Engine with Enhanced CLI Tools, Specialized E-Commerce Templates, Material Design 3, Progressive Enhancement, Mobile Optimizations, Performance Analysis, and Enterprise-Grade Develo
58 lines (48 loc) • 1.35 kB
JavaScript
// MusPE Cordova Service - Simple integration service
class CordovaService {
constructor() {
this.isReady = false;
this.init();
}
async init() {
if (typeof window !== 'undefined' && window.MusPECordova) {
await this.waitForDeviceReady();
}
}
waitForDeviceReady() {
return new Promise((resolve) => {
if (window.MusPECordova) {
window.MusPECordova.ready(() => {
this.isReady = true;
resolve();
});
} else {
resolve();
}
});
}
isCordova() {
return window.MusPECordova ? window.MusPECordova.isCordova() : false;
}
getDeviceInfo() {
return window.MusPECordova ? window.MusPECordova.getDeviceInfo() : null;
}
getNetworkInfo() {
return window.MusPECordova ? window.MusPECordova.getNetworkInfo() : { isOnline: navigator.onLine };
}
}
// Create singleton instance
const cordovaService = new CordovaService();
// Export for module usage
if (typeof module !== 'undefined' && module.exports) {
module.exports = { CordovaService, cordovaService };
}
// Auto-register service globally
if (typeof window !== 'undefined') {
window.CordovaService = CordovaService;
window.cordovaService = cordovaService;
// Register with MusPE if available
if (window.MusPE) {
MusPE.registerService('cordova', cordovaService);
}
}