mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
refactor(lib): run prettier
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
CordovaInstance,
|
||||
InstanceCheck,
|
||||
IonicNativePlugin,
|
||||
Plugin
|
||||
} from '@ionic-native/core';
|
||||
import { CordovaInstance, InstanceCheck, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
|
||||
declare const cordova: Cordova & { InAppBrowser: any };
|
||||
@@ -123,7 +118,14 @@ export interface InAppBrowserOptions {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type InAppBrowserEventType = 'loadstart' | 'loadstop' | 'loaderror' | 'exit' | 'beforeload' | 'message' | 'customscheme';
|
||||
export type InAppBrowserEventType =
|
||||
| 'loadstart'
|
||||
| 'loadstop'
|
||||
| 'loaderror'
|
||||
| 'exit'
|
||||
| 'beforeload'
|
||||
| 'message'
|
||||
| 'customscheme';
|
||||
|
||||
export interface InAppBrowserEvent extends Event {
|
||||
/** the event name */
|
||||
@@ -155,17 +157,11 @@ export class InAppBrowserObject {
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
*/
|
||||
constructor(
|
||||
url: string,
|
||||
target?: string,
|
||||
options?: string | InAppBrowserOptions
|
||||
) {
|
||||
constructor(url: string, target?: string, options?: string | InAppBrowserOptions) {
|
||||
try {
|
||||
if (options && typeof options !== 'string') {
|
||||
options = Object.keys(options)
|
||||
.map(
|
||||
(key: string) => `${key}=${(options as InAppBrowserOptions)[key]}`
|
||||
)
|
||||
.map((key: string) => `${key}=${(options as InAppBrowserOptions)[key]}`)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
@@ -234,19 +230,10 @@ export class InAppBrowserObject {
|
||||
*/
|
||||
@InstanceCheck()
|
||||
on(event: InAppBrowserEventType): Observable<InAppBrowserEvent> {
|
||||
return new Observable<InAppBrowserEvent>(
|
||||
(observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
return () =>
|
||||
this._objectInstance.removeEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
}
|
||||
);
|
||||
return new Observable<InAppBrowserEvent>((observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(event, observer.next.bind(observer));
|
||||
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,19 +243,10 @@ export class InAppBrowserObject {
|
||||
*/
|
||||
@InstanceCheck()
|
||||
on(event: string): Observable<InAppBrowserEvent> {
|
||||
return new Observable<InAppBrowserEvent>(
|
||||
(observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
return () =>
|
||||
this._objectInstance.removeEventListener(
|
||||
event,
|
||||
observer.next.bind(observer)
|
||||
);
|
||||
}
|
||||
);
|
||||
return new Observable<InAppBrowserEvent>((observer: Observer<InAppBrowserEvent>) => {
|
||||
this._objectInstance.addEventListener(event, observer.next.bind(observer));
|
||||
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +286,7 @@ export class InAppBrowserObject {
|
||||
plugin: 'cordova-plugin-inappbrowser',
|
||||
pluginRef: 'cordova.InAppBrowser',
|
||||
repo: 'https://github.com/apache/cordova-plugin-inappbrowser',
|
||||
platforms: ['AmazonFire OS', 'Android', 'Browser', 'iOS', 'macOS', 'Windows']
|
||||
platforms: ['AmazonFire OS', 'Android', 'Browser', 'iOS', 'macOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class InAppBrowser extends IonicNativePlugin {
|
||||
@@ -321,11 +299,7 @@ export class InAppBrowser extends IonicNativePlugin {
|
||||
* name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
* @returns {InAppBrowserObject}
|
||||
*/
|
||||
create(
|
||||
url: string,
|
||||
target?: string,
|
||||
options?: string | InAppBrowserOptions
|
||||
): InAppBrowserObject {
|
||||
create(url: string, target?: string, options?: string | InAppBrowserOptions): InAppBrowserObject {
|
||||
return new InAppBrowserObject(url, target, options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user