com-easystep2-datawedge-plugin-intent-capacitor
Version:
Capacitor plugin for Android Intents
87 lines • 3.82 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { WebPlugin } from '@capacitor/core';
export class IntentShimWeb extends WebPlugin {
constructor() {
super();
this.intentListeners = [];
this.debug = false;
this.log('IntentShim Web: Initialized');
}
registerBroadcastReceiver(options) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: registerBroadcastReceiver with filters ${JSON.stringify(options.filterActions)}`);
throw this.unavailable('Not available in web environment');
});
}
unregisterBroadcastReceiver() {
return __awaiter(this, void 0, void 0, function* () {
this.log('IntentShim Web: unregisterBroadcastReceiver');
throw this.unavailable('Not available in web environment');
});
}
sendBroadcast(options) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: sendBroadcast ${options.action}`);
throw this.unavailable('Not available in web environment');
});
}
startActivity(options) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: startActivity ${options.action}`);
// For web, we can at least try to open URLs
if (options.url && options.action === 'android.intent.action.VIEW') {
window.open(options.url, '_blank');
return;
}
throw this.unavailable('Full intent functionality not available in web environment');
});
}
getIntent() {
return __awaiter(this, void 0, void 0, function* () {
this.log('IntentShim Web: getIntent');
throw this.unavailable('Not available in web environment');
});
}
startActivityForResult(options) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: startActivityForResult ${options.action}`);
throw this.unavailable('Not available in web environment');
});
}
sendResult(options) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: sendResult with resultCode ${options.resultCode || 'none'} and extras ${JSON.stringify(options.extras || {})}`);
throw this.unavailable('Not available in web environment');
});
}
onIntent(callback) {
this.log('IntentShim Web: onIntent listener registered');
this.intentListeners.push(callback);
}
packageExists(packageName) {
return __awaiter(this, void 0, void 0, function* () {
this.log(`IntentShim Web: packageExists ${packageName}`);
return { exists: false };
});
}
setDebugMode(options) {
return __awaiter(this, void 0, void 0, function* () {
this.debug = options.enabled;
this.log(`IntentShim Web: Debug mode ${options.enabled ? 'enabled' : 'disabled'}`);
});
}
log(message) {
if (this.debug) {
console.log(message);
}
}
}
//# sourceMappingURL=web.js.map