mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 08:43:01 +08:00
refactor(): run prettier
This commit is contained in:
parent
3896aca5aa
commit
99a0e0282d
@ -135,8 +135,8 @@ import { Camera } from '@awesome-cordova-plugins/camera';
|
||||
|
||||
document.addEventListener('deviceready', () => {
|
||||
Camera.getPicture()
|
||||
.then(data => console.log('Took a picture!', data))
|
||||
.catch(e => console.log('Error occurred while taking a picture', e));
|
||||
.then((data) => console.log('Took a picture!', data))
|
||||
.catch((e) => console.log('Error occurred while taking a picture', e));
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -5,12 +5,4 @@ module.exports = {
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
trailingComma: 'es5',
|
||||
bracketSpacing: true,
|
||||
jsxBracketSameLine: false,
|
||||
arrowParens: 'avoid',
|
||||
rangeStart: 0,
|
||||
rangeEnd: Infinity,
|
||||
requirePragma: false,
|
||||
insertPragma: false,
|
||||
proseWrap: 'preserve',
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ export const ROOT = resolve(__dirname, '../../');
|
||||
export const TS_CONFIG = clone(require(resolve(ROOT, 'tsconfig.json')));
|
||||
export const COMPILER_OPTIONS = TS_CONFIG.compilerOptions;
|
||||
export const PLUGINS_ROOT = join(ROOT, 'src/@awesome-cordova-plugins/plugins/');
|
||||
export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map(d => join(PLUGINS_ROOT, d, 'index.ts'));
|
||||
export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map((d) => join(PLUGINS_ROOT, d, 'index.ts'));
|
||||
|
||||
export function getDecorator(node: Node, index = 0): Decorator {
|
||||
if (node.decorators && node.decorators[index]) {
|
||||
@ -31,7 +31,7 @@ export function hasDecorator(decoratorName: string, node: Node): boolean {
|
||||
return (
|
||||
node.decorators &&
|
||||
node.decorators.length &&
|
||||
node.decorators.findIndex(d => getDecoratorName(d) === decoratorName) > -1
|
||||
node.decorators.findIndex((d) => getDecoratorName(d) === decoratorName) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ export function getDecoratorArgs(decorator: any) {
|
||||
const properties: any[] = getRawDecoratorArgs(decorator);
|
||||
const args = {};
|
||||
|
||||
properties.forEach(prop => {
|
||||
properties.forEach((prop) => {
|
||||
let val: number | boolean;
|
||||
|
||||
switch (prop.initializer.kind) {
|
||||
|
@ -53,14 +53,14 @@ export function transpileNgx() {
|
||||
}
|
||||
|
||||
export function generateDeclarationFiles() {
|
||||
generateDeclarations(PLUGIN_PATHS.map(p => p.replace('index.ts', 'ngx/index.ts')));
|
||||
generateDeclarations(PLUGIN_PATHS.map((p) => p.replace('index.ts', 'ngx/index.ts')));
|
||||
}
|
||||
|
||||
export function generateLegacyBundles() {
|
||||
[
|
||||
resolve(ROOT, 'dist/@awesome-cordova-plugins/core/index.js'),
|
||||
...PLUGIN_PATHS.map(p => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.js')),
|
||||
].forEach(p =>
|
||||
...PLUGIN_PATHS.map((p) => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.js')),
|
||||
].forEach((p) =>
|
||||
rollup({
|
||||
input: p,
|
||||
onwarn(warning, warn) {
|
||||
@ -68,7 +68,7 @@ export function generateLegacyBundles() {
|
||||
warn(warning);
|
||||
},
|
||||
external: ['@angular/core', '@awesome-cordova-plugins/core', 'rxjs', 'tslib'],
|
||||
}).then(bundle =>
|
||||
}).then((bundle) =>
|
||||
bundle.write({
|
||||
file: join(dirname(p), 'bundle.js'),
|
||||
format: 'cjs',
|
||||
@ -79,9 +79,9 @@ export function generateLegacyBundles() {
|
||||
|
||||
// remove reference to @awesome-cordova-plugins/core decorators
|
||||
export function modifyMetadata() {
|
||||
PLUGIN_PATHS.map(p =>
|
||||
PLUGIN_PATHS.map((p) =>
|
||||
p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace('index.ts', 'ngx/index.metadata.json')
|
||||
).forEach(p => {
|
||||
).forEach((p) => {
|
||||
const content = readJSONSync(p);
|
||||
let _prop: { members: { [x: string]: any[] } };
|
||||
for (const prop in content[0].metadata) {
|
||||
|
@ -1,2 +1,2 @@
|
||||
// removes the __extends method that is added automatically by typescript
|
||||
module.exports = source => source.replace(/var\s__extends\s=\s\(this\s&&[\sa-z\._\(\)\|{}=:\[\]&,;?]+}\)\(\);/i, '');
|
||||
module.exports = (source) => source.replace(/var\s__extends\s=\s\(this\s&&[\sa-z\._\(\)\|{}=:\[\]&,;?]+}\)\(\);/i, '');
|
||||
|
@ -23,11 +23,11 @@ export const EMIT_PATH = resolve(ROOT, 'injectable-classes.json');
|
||||
*/
|
||||
export function extractInjectables() {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
visitEachChild(
|
||||
tsSourceFile,
|
||||
node => {
|
||||
(node) => {
|
||||
if (node.kind !== SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
|
@ -39,22 +39,22 @@ function transformImports(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
if (decorators.length) {
|
||||
let methods = [];
|
||||
|
||||
decorators.forEach(d => (methods = getMethodsForDecorator(d).concat(methods)));
|
||||
decorators.forEach((d) => (methods = getMethodsForDecorator(d).concat(methods)));
|
||||
|
||||
const methodElements = methods.map(m => factory.createIdentifier(m));
|
||||
const methodNames = methodElements.map(el => el.escapedText);
|
||||
const methodElements = methods.map((m) => factory.createIdentifier(m));
|
||||
const methodNames = methodElements.map((el) => el.escapedText);
|
||||
|
||||
importStatement.importClause.namedBindings.elements = [
|
||||
factory.createIdentifier('AwesomeCordovaNativePlugin'),
|
||||
...methodElements,
|
||||
...importStatement.importClause.namedBindings.elements.filter(
|
||||
el => keep.indexOf(el.name.text) !== -1 && methodNames.indexOf(el.name.text) === -1
|
||||
(el) => keep.indexOf(el.name.text) !== -1 && methodNames.indexOf(el.name.text) === -1
|
||||
),
|
||||
];
|
||||
|
||||
if (ngcBuild) {
|
||||
importStatement.importClause.namedBindings.elements = importStatement.importClause.namedBindings.elements.map(
|
||||
binding => {
|
||||
(binding) => {
|
||||
if (binding.escapedText) {
|
||||
binding.name = {
|
||||
text: binding.escapedText,
|
||||
@ -71,7 +71,7 @@ function transformImports(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
|
||||
export function importsTransformer(ngcBuild?: boolean) {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
return transformImports(tsSourceFile, ctx, ngcBuild);
|
||||
};
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ export function transformMembers(cls: ClassDeclaration) {
|
||||
members.push(getter, setter);
|
||||
});
|
||||
|
||||
propertyIndices.reverse().forEach(i => members.splice(i, 1));
|
||||
propertyIndices.reverse().forEach((i) => members.splice(i, 1));
|
||||
|
||||
return members;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ function transformClass(cls: any, ngcBuild?: boolean) {
|
||||
|
||||
cls = factory.createClassDeclaration(
|
||||
ngcBuild && cls.decorators && cls.decorators.length
|
||||
? cls.decorators.filter(d => getDecoratorName(d) === 'Injectable')
|
||||
? cls.decorators.filter((d) => getDecoratorName(d) === 'Injectable')
|
||||
: undefined, // remove Plugin and Injectable decorators
|
||||
[factory.createToken(SyntaxKind.ExportKeyword)],
|
||||
cls.name,
|
||||
@ -55,10 +55,10 @@ function transformClasses(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
Logger.silly('Transforming file: ' + file.fileName);
|
||||
return visitEachChild(
|
||||
file,
|
||||
node => {
|
||||
(node) => {
|
||||
if (
|
||||
node.kind !== SyntaxKind.ClassDeclaration ||
|
||||
(node.modifiers && node.modifiers.find(v => v.kind === SyntaxKind.DeclareKeyword))
|
||||
(node.modifiers && node.modifiers.find((v) => v.kind === SyntaxKind.DeclareKeyword))
|
||||
) {
|
||||
return node;
|
||||
}
|
||||
@ -70,7 +70,7 @@ function transformClasses(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
|
||||
export function pluginClassTransformer(ngcBuild?: boolean): TransformerFactory<SourceFile> {
|
||||
return (ctx: TransformationContext) => {
|
||||
return tsSourceFile => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
return transformClasses(tsSourceFile, ctx, ngcBuild);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ async function run(pluginsDir: string) {
|
||||
|
||||
async function generateTypedoc(root: string, outputPath = typedocTmp, outputDocsPath = typedocDocsTmp) {
|
||||
const pluginDirs = await readdir(root);
|
||||
const paths = pluginDirs.map(dir => resolve(root, dir, 'index.ts'));
|
||||
const paths = pluginDirs.map((dir) => resolve(root, dir, 'index.ts'));
|
||||
typedoc.bootstrap({
|
||||
/*
|
||||
mode: 'modules',
|
||||
@ -96,7 +96,7 @@ function processPlugin(pluginModule): Plugin {
|
||||
*/
|
||||
const getPluginDecorator = (child: any) => {
|
||||
if (isPlugin(child)) {
|
||||
const decorator = child.decorators.find(d => d.name === 'Plugin');
|
||||
const decorator = child.decorators.find((d) => d.name === 'Plugin');
|
||||
|
||||
console.log('Found decorator', decorator.arguments, child);
|
||||
return runInNewContext(`(${decorator.arguments.config})`);
|
||||
@ -105,7 +105,7 @@ const getPluginDecorator = (child: any) => {
|
||||
|
||||
const getTag = (child: any, tagName: string): string => {
|
||||
if (hasTags(child)) {
|
||||
const tag = child.comment.tags.find(t => t.tag === tagName);
|
||||
const tag = child.comment.tags.find((t) => t.tag === tagName);
|
||||
if (tag) {
|
||||
return tag.text;
|
||||
}
|
||||
@ -120,7 +120,7 @@ const isPlugin = (child: any): boolean =>
|
||||
isClass(child) &&
|
||||
hasTags(child) &&
|
||||
Array.isArray(child.decorators) &&
|
||||
child.decorators.some(d => d.name === 'Plugin');
|
||||
child.decorators.some((d) => d.name === 'Plugin');
|
||||
|
||||
const hasPlugin = (child: any): boolean => child.children.some(isPlugin);
|
||||
|
||||
|
@ -7,7 +7,7 @@ const Package = require('dgeni').Package,
|
||||
path = require('path'),
|
||||
config = require('../config.json');
|
||||
|
||||
module.exports = currentVersion => {
|
||||
module.exports = (currentVersion) => {
|
||||
return (
|
||||
new Package('ionic-native-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
|
||||
|
||||
@ -40,7 +40,7 @@ module.exports = currentVersion => {
|
||||
computePathsProcessor.pathTemplates = [
|
||||
{
|
||||
docTypes: ['class'],
|
||||
getOutputPath: doc => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md',
|
||||
getOutputPath: (doc) => 'content/' + config.v2DocsDir + '/' + doc.name + '/index.md',
|
||||
},
|
||||
];
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ const Package = require('dgeni').Package,
|
||||
path = require('path'),
|
||||
config = require('../config.json');
|
||||
|
||||
module.exports = currentVersion => {
|
||||
module.exports = (currentVersion) => {
|
||||
return (
|
||||
new Package('ionic-native-readmes', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
|
||||
|
||||
@ -38,7 +38,7 @@ module.exports = currentVersion => {
|
||||
computePathsProcessor.pathTemplates = [
|
||||
{
|
||||
docTypes: ['class'],
|
||||
getOutputPath: doc =>
|
||||
getOutputPath: (doc) =>
|
||||
doc.originalModule.replace(config.pluginDir + '/', '').replace(/\/index$/, '/README.md'),
|
||||
},
|
||||
];
|
||||
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
name: 'capital',
|
||||
process: str => (str ? str.charAt(0).toUpperCase() + str.substring(1) : ''),
|
||||
process: (str) => (str ? str.charAt(0).toUpperCase() + str.substring(1) : ''),
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
name: 'dashify',
|
||||
process: str => (str ? str.replace(/\s/g, '-') : ''),
|
||||
process: (str) => (str ? str.replace(/\s/g, '-') : ''),
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
name: 'dump',
|
||||
process: obj => console.log(obj),
|
||||
process: (obj) => console.log(obj),
|
||||
};
|
||||
|
@ -4,6 +4,6 @@ module.exports = function removePrivateApi() {
|
||||
name: 'remove-private-api',
|
||||
description: 'Prevent the private apis from being rendered',
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => docs.filter(doc => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden'))),
|
||||
$process: (docs) => docs.filter((doc) => !doc.private && (!doc.tags || !doc.tags.tagsByName.get('hidden'))),
|
||||
};
|
||||
};
|
||||
|
@ -5,9 +5,9 @@ module.exports = function jekyll(renderDocsProcessor) {
|
||||
description: 'Create jekyll includes',
|
||||
$runAfter: ['paths-computed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => {
|
||||
$process: (docs) => {
|
||||
// pretty up and sort the docs object for menu generation
|
||||
docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
|
||||
docs = docs.filter((doc) => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
|
||||
|
||||
docs.push({
|
||||
docType: 'class',
|
||||
@ -22,7 +22,7 @@ module.exports = function jekyll(renderDocsProcessor) {
|
||||
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
||||
});
|
||||
|
||||
docs.forEach(doc => {
|
||||
docs.forEach((doc) => {
|
||||
if (!doc.outputPath) {
|
||||
return;
|
||||
}
|
||||
@ -39,7 +39,7 @@ module.exports = function jekyll(renderDocsProcessor) {
|
||||
|
||||
const betaDocs = [];
|
||||
|
||||
docs = docs.filter(doc => {
|
||||
docs = docs.filter((doc) => {
|
||||
if (doc.beta === true) {
|
||||
betaDocs.push(doc);
|
||||
return false;
|
||||
|
@ -3,8 +3,8 @@ module.exports = function markProperties() {
|
||||
return {
|
||||
name: 'mark-properties',
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs =>
|
||||
docs.map(doc => {
|
||||
$process: (docs) =>
|
||||
docs.map((doc) => {
|
||||
for (let i in doc.members) {
|
||||
if (doc.members.hasOwnProperty(i) && typeof doc.members[i].parameters === 'undefined') {
|
||||
doc.members[i].isProperty = true;
|
||||
|
@ -4,13 +4,13 @@ module.exports = function npmId(renderDocsProcessor) {
|
||||
name: 'npm-id',
|
||||
$runAfter: ['paths-computed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => {
|
||||
$process: (docs) => {
|
||||
// pretty up and sort the docs object for menu generation
|
||||
docs = docs.filter(function (doc) {
|
||||
return (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page';
|
||||
});
|
||||
|
||||
docs.forEach(doc => {
|
||||
docs.forEach((doc) => {
|
||||
doc.npmId = doc.id.match(/plugins\/(.*)\/index/)[1];
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
module.exports = function parseOptional() {
|
||||
return {
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => {
|
||||
docs.forEach(doc => {
|
||||
$process: (docs) => {
|
||||
docs.forEach((doc) => {
|
||||
if (doc.members && doc.members.length) {
|
||||
for (let i in doc.members) {
|
||||
if (doc.members[i].params && doc.members[i].params.length) {
|
||||
|
@ -5,11 +5,11 @@ module.exports = function readmes(renderDocsProcessor) {
|
||||
description: 'Create jekyll includes',
|
||||
$runAfter: ['paths-computed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => {
|
||||
$process: (docs) => {
|
||||
// pretty up and sort the docs object for menu generation
|
||||
docs = docs.filter(doc => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
|
||||
docs = docs.filter((doc) => (!!doc.name && !!doc.outputPath) || doc.docType === 'index-page');
|
||||
|
||||
docs.forEach(doc => {
|
||||
docs.forEach((doc) => {
|
||||
doc.outputPath = doc.outputPath.replace('src/@awesome-cordova-plugins/', '');
|
||||
});
|
||||
|
||||
|
@ -5,14 +5,14 @@ module.exports = function removePrivateMembers() {
|
||||
description: 'Remove member docs with @private tags',
|
||||
$runAfter: ['tags-parsed'],
|
||||
$runBefore: ['rendering-docs'],
|
||||
$process: docs => {
|
||||
docs.forEach(doc => {
|
||||
$process: (docs) => {
|
||||
docs.forEach((doc) => {
|
||||
if (doc.members) {
|
||||
doc.members = doc.members.filter(member => !member.tags.tagsByName.get('hidden'));
|
||||
doc.members = doc.members.filter((member) => !member.tags.tagsByName.get('hidden'));
|
||||
}
|
||||
|
||||
if (doc.statics) {
|
||||
doc.statics = doc.statics.filter(staticMethod => !staticMethod.tags.tagsByName.get('hidden'));
|
||||
doc.statics = doc.statics.filter((staticMethod) => !staticMethod.tags.tagsByName.get('hidden'));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5,13 +5,13 @@ const config = require('./config.json'),
|
||||
fs = require('fs-extra'),
|
||||
Dgeni = require('dgeni');
|
||||
|
||||
module.exports = gulp => {
|
||||
module.exports = (gulp) => {
|
||||
gulp.task('docs', () => {
|
||||
try {
|
||||
const ionicPackage = require('./dgeni/dgeni-config')(projectPackage.version),
|
||||
dgeni = new Dgeni([ionicPackage]);
|
||||
|
||||
return dgeni.generate().then(docs => console.log(docs.length + ' docs generated'));
|
||||
return dgeni.generate().then((docs) => console.log(docs.length + ' docs generated'));
|
||||
} catch (err) {
|
||||
console.log(err.stack);
|
||||
}
|
||||
@ -26,7 +26,7 @@ module.exports = gulp => {
|
||||
try {
|
||||
const ionicPackage = require('./dgeni/dgeni-readmes-config')(projectPackage.version),
|
||||
dgeni = new Dgeni([ionicPackage]);
|
||||
return dgeni.generate().then(docs => console.log(docs.length + ' README files generated'));
|
||||
return dgeni.generate().then((docs) => console.log(docs.length + ' README files generated'));
|
||||
} catch (err) {
|
||||
console.log(err.stack);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ function createIndexFile() {
|
||||
let fileContent = '';
|
||||
fileContent += INJECTABLE_CLASSES.map(getPluginImport).join('\n');
|
||||
fileContent += `\nwindow.IonicNative = {\n`;
|
||||
fileContent += INJECTABLE_CLASSES.map(e => e.className).join(',\n');
|
||||
fileContent += INJECTABLE_CLASSES.map((e) => e.className).join(',\n');
|
||||
fileContent += '\n};\n';
|
||||
fileContent += `require('./@awesome-cordova-plugins/core/bootstrap').checkReady();\n`;
|
||||
fileContent += `require('./@awesome-cordova-plugins/core/ng1').initAngular1(window.IonicNative);`;
|
||||
|
@ -8,16 +8,16 @@ import { generateDeclarations, transpile } from '../build/transpile';
|
||||
generateDeclarations();
|
||||
transpile();
|
||||
|
||||
const outDirs = PLUGIN_PATHS.map(p => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace(/[\\/]index.ts/, ''));
|
||||
const outDirs = PLUGIN_PATHS.map((p) => p.replace(join(ROOT, 'src'), join(ROOT, 'dist')).replace(/[\\/]index.ts/, ''));
|
||||
const injectableClasses = readJSONSync(EMIT_PATH);
|
||||
|
||||
outDirs.forEach(dir => {
|
||||
const classes = injectableClasses.filter(entry => entry.dirName === dir.split(/[\\/]+/).pop());
|
||||
outDirs.forEach((dir) => {
|
||||
const classes = injectableClasses.filter((entry) => entry.dirName === dir.split(/[\\/]+/).pop());
|
||||
|
||||
let jsFile: string = readFileSync(join(dir, 'index.js'), 'utf-8'),
|
||||
dtsFile: string = readFileSync(join(dir, 'index.d.ts'), 'utf-8');
|
||||
|
||||
classes.forEach(entry => {
|
||||
classes.forEach((entry) => {
|
||||
dtsFile = dtsFile.replace(`class ${entry.className} `, 'class ' + entry.className + 'Original ');
|
||||
dtsFile += `\nexport declare const ${entry.className}: ${entry.className}Original;`;
|
||||
jsFile = jsFile.replace(
|
||||
|
@ -80,7 +80,7 @@ function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts:
|
||||
}
|
||||
|
||||
function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: any = {}) {
|
||||
return new Observable(observer => {
|
||||
return new Observable((observer) => {
|
||||
let pluginResult;
|
||||
|
||||
if (opts.destruct) {
|
||||
@ -384,7 +384,7 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {})
|
||||
if (opts.sync) {
|
||||
return callInstance(pluginObj, methodName, args, opts);
|
||||
} else if (opts.observable) {
|
||||
return new Observable(observer => {
|
||||
return new Observable((observer) => {
|
||||
let pluginResult;
|
||||
|
||||
if (opts.destruct) {
|
||||
|
@ -162,7 +162,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
@CordovaCheck()
|
||||
hasAccount(): Promise<any> {
|
||||
return getPromise<boolean>(resolve => {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
EmailComposer.getPlugin().hasAccount((result: boolean) => {
|
||||
if (result) {
|
||||
resolve(true);
|
||||
@ -182,7 +182,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin {
|
||||
|
||||
@CordovaCheck()
|
||||
hasClient(app?: string): Promise<any> {
|
||||
return getPromise<boolean>(resolve => {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
if (app) {
|
||||
EmailComposer.getPlugin().hasClient(app, (result: boolean) => {
|
||||
if (result) {
|
||||
@ -207,7 +207,7 @@ export class EmailComposer extends AwesomeCordovaNativePlugin {
|
||||
@CordovaCheck()
|
||||
@Cordova({ platforms: ['Android'] })
|
||||
getClients(): Promise<string[]> {
|
||||
return getPromise<string[]>(resolve => {
|
||||
return getPromise<string[]>((resolve) => {
|
||||
EmailComposer.getPlugin().getClients((apps: any) => {
|
||||
if (Object.prototype.toString.call(apps) === '[object String]') {
|
||||
apps = [apps];
|
||||
@ -225,8 +225,8 @@ export class EmailComposer extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
@CordovaCheck()
|
||||
isAvailable(app?: string): Promise<any> {
|
||||
return getPromise<boolean>(resolve => {
|
||||
Promise.all([this.hasAccount, this.hasClient(app)]).then(results => {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
Promise.all([this.hasAccount, this.hasClient(app)]).then((results) => {
|
||||
return resolve(results.length === 2 && results[0] && results[1]);
|
||||
});
|
||||
});
|
||||
|
@ -819,7 +819,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
options.exclusive = true;
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path).then(fse => {
|
||||
return this.resolveDirectoryUrl(path).then((fse) => {
|
||||
return this.getDirectory(fse, dirName, options);
|
||||
});
|
||||
}
|
||||
@ -840,10 +840,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getDirectory(fse, dirName, { create: false });
|
||||
})
|
||||
.then(de => {
|
||||
.then((de) => {
|
||||
return this.remove(de);
|
||||
});
|
||||
}
|
||||
@ -869,11 +869,11 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getDirectory(fse, dirName, { create: false });
|
||||
})
|
||||
.then(srcde => {
|
||||
return this.resolveDirectoryUrl(newPath).then(destenation => {
|
||||
.then((srcde) => {
|
||||
return this.resolveDirectoryUrl(newPath).then((destenation) => {
|
||||
return this.move(srcde, destenation, newDirName);
|
||||
});
|
||||
});
|
||||
@ -897,11 +897,11 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getDirectory(fse, dirName, { create: false });
|
||||
})
|
||||
.then(srcde => {
|
||||
return this.resolveDirectoryUrl(newPath).then(deste => {
|
||||
.then((srcde) => {
|
||||
return this.resolveDirectoryUrl(newPath).then((deste) => {
|
||||
return this.copy(srcde, deste, newDirName);
|
||||
});
|
||||
});
|
||||
@ -923,13 +923,13 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getDirectory(fse, dirName, {
|
||||
create: false,
|
||||
exclusive: false,
|
||||
});
|
||||
})
|
||||
.then(de => {
|
||||
.then((de) => {
|
||||
const reader = de.createReader();
|
||||
return this.readEntries(reader);
|
||||
});
|
||||
@ -951,10 +951,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getDirectory(fse, dirName, { create: false });
|
||||
})
|
||||
.then(de => {
|
||||
.then((de) => {
|
||||
return this.rimraf(de);
|
||||
});
|
||||
}
|
||||
@ -974,7 +974,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
return Promise.reject<any>(err);
|
||||
}
|
||||
|
||||
return this.resolveLocalFilesystemUrl(path + file).then(fse => {
|
||||
return this.resolveLocalFilesystemUrl(path + file).then((fse) => {
|
||||
if (fse.isFile) {
|
||||
return true;
|
||||
} else {
|
||||
@ -1011,7 +1011,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
options.exclusive = true;
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path).then(fse => {
|
||||
return this.resolveDirectoryUrl(path).then((fse) => {
|
||||
return this.getFile(fse, fileName, options);
|
||||
});
|
||||
}
|
||||
@ -1032,10 +1032,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getFile(fse, fileName, { create: false });
|
||||
})
|
||||
.then(fe => {
|
||||
.then((fe) => {
|
||||
return this.remove(fe);
|
||||
});
|
||||
}
|
||||
@ -1086,7 +1086,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
private writeFileEntry(fe: FileEntry, text: string | Blob | ArrayBuffer, options: IWriteOptions) {
|
||||
return this.createWriter(fe)
|
||||
.then(writer => {
|
||||
.then((writer) => {
|
||||
if (options.append) {
|
||||
writer.seek(writer.length);
|
||||
}
|
||||
@ -1183,11 +1183,11 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getFile(fse, fileName, { create: false });
|
||||
})
|
||||
.then(srcfe => {
|
||||
return this.resolveDirectoryUrl(newPath).then(deste => {
|
||||
.then((srcfe) => {
|
||||
return this.resolveDirectoryUrl(newPath).then((deste) => {
|
||||
return this.move(srcfe, deste, newFileName);
|
||||
});
|
||||
});
|
||||
@ -1213,11 +1213,11 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return this.resolveDirectoryUrl(path)
|
||||
.then(fse => {
|
||||
.then((fse) => {
|
||||
return this.getFile(fse, fileName, { create: false });
|
||||
})
|
||||
.then(srcfe => {
|
||||
return this.resolveDirectoryUrl(newPath).then(deste => {
|
||||
.then((srcfe) => {
|
||||
return this.resolveDirectoryUrl(newPath).then((deste) => {
|
||||
return this.copy(srcfe, deste, newFileName);
|
||||
});
|
||||
});
|
||||
@ -1246,7 +1246,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
(entry: Entry) => {
|
||||
resolve(entry);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1265,7 +1265,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
@CordovaCheck()
|
||||
resolveDirectoryUrl(directoryUrl: string): Promise<DirectoryEntry> {
|
||||
return this.resolveLocalFilesystemUrl(directoryUrl).then(de => {
|
||||
return this.resolveLocalFilesystemUrl(directoryUrl).then((de) => {
|
||||
if (de.isDirectory) {
|
||||
return de as DirectoryEntry;
|
||||
} else {
|
||||
@ -1290,10 +1290,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
directoryEntry.getDirectory(
|
||||
directoryName,
|
||||
flags,
|
||||
de => {
|
||||
(de) => {
|
||||
resolve(de);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1316,7 +1316,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise<FileEntry> {
|
||||
return new Promise<FileEntry>((resolve, reject) => {
|
||||
try {
|
||||
directoryEntry.getFile(fileName, flags, resolve, err => {
|
||||
directoryEntry.getFile(fileName, flags, resolve, (err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
});
|
||||
@ -1356,10 +1356,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
};
|
||||
|
||||
fileEntry.file(
|
||||
file => {
|
||||
(file) => {
|
||||
reader[`readAs${readAs}`].call(reader, file);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
reject(error);
|
||||
}
|
||||
);
|
||||
@ -1376,7 +1376,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
() => {
|
||||
resolve({ success: true, fileRemoved: fe });
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1392,10 +1392,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
srce.moveTo(
|
||||
destdir,
|
||||
newName,
|
||||
deste => {
|
||||
(deste) => {
|
||||
resolve(deste);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1411,10 +1411,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
srce.copyTo(
|
||||
destdir,
|
||||
newName,
|
||||
deste => {
|
||||
(deste) => {
|
||||
resolve(deste);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1428,10 +1428,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
private readEntries(dr: DirectoryReader): Promise<Entry[]> {
|
||||
return new Promise<Entry[]>((resolve, reject) => {
|
||||
dr.readEntries(
|
||||
entries => {
|
||||
(entries) => {
|
||||
resolve(entries);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1448,7 +1448,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
() => {
|
||||
resolve({ success: true, fileRemoved: de });
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1462,10 +1462,10 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
private createWriter(fe: FileEntry): Promise<FileWriter> {
|
||||
return new Promise<FileWriter>((resolve, reject) => {
|
||||
fe.createWriter(
|
||||
writer => {
|
||||
(writer) => {
|
||||
resolve(writer);
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.fillErrorMessage(err);
|
||||
reject(err);
|
||||
}
|
||||
@ -1482,7 +1482,7 @@ export class File extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
writer.onwriteend = evt => {
|
||||
writer.onwriteend = (evt) => {
|
||||
if (writer.error) {
|
||||
reject(writer.error);
|
||||
} else {
|
||||
|
@ -165,8 +165,8 @@ export class HyperTrack {
|
||||
getDeviceId(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.getDeviceId(
|
||||
deviceId => resolve(deviceId),
|
||||
err => reject(err)
|
||||
(deviceId) => resolve(deviceId),
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -175,8 +175,8 @@ export class HyperTrack {
|
||||
isRunning(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.isRunning(
|
||||
isRunning => resolve(isRunning),
|
||||
err => reject(err)
|
||||
(isRunning) => resolve(isRunning),
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -187,7 +187,7 @@ export class HyperTrack {
|
||||
this.cordovaInstanceHandle.setDeviceName(
|
||||
name,
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -201,7 +201,7 @@ export class HyperTrack {
|
||||
this.cordovaInstanceHandle.setDeviceMetadata(
|
||||
metadata,
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -213,7 +213,7 @@ export class HyperTrack {
|
||||
title,
|
||||
message,
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -225,7 +225,7 @@ export class HyperTrack {
|
||||
geotagData,
|
||||
expectedLocation,
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -235,7 +235,7 @@ export class HyperTrack {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.requestPermissionsIfNecessary(
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -245,7 +245,7 @@ export class HyperTrack {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.allowMockLocations(
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -258,7 +258,7 @@ export class HyperTrack {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.syncDeviceSettings(
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -268,7 +268,7 @@ export class HyperTrack {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.start(
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -278,7 +278,7 @@ export class HyperTrack {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.cordovaInstanceHandle.stop(
|
||||
() => resolve(),
|
||||
err => reject(err)
|
||||
(err) => reject(err)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ export class SmartlookEventTrackingModes {
|
||||
private eventTrackingModes: string[];
|
||||
|
||||
constructor(eventTrackingModes: SmartlookEventTrackingMode[]) {
|
||||
this.eventTrackingModes = eventTrackingModes.map(eventTrackingMode =>
|
||||
this.eventTrackingModes = eventTrackingModes.map((eventTrackingMode) =>
|
||||
eventTrackingMode.getEventTrackingModeString()
|
||||
);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ export class WebSocketServer extends AwesomeCordovaNativePlugin {
|
||||
}
|
||||
|
||||
private onFunctionToObservable<T>(fnName: string) {
|
||||
return new Observable<T>(observer => {
|
||||
return new Observable<T>((observer) => {
|
||||
const id = window.cordova.plugins.wsserver[fnName](observer.next.bind(observer), observer.error.bind(observer));
|
||||
|
||||
return () => window.cordova.plugins.wsserver.removeCallback(id);
|
||||
|
Loading…
Reference in New Issue
Block a user