Merge in v5 code

This commit is contained in:
Ibby Hadeed 2017-12-28 07:28:44 -05:00
parent d43fe72f7b
commit 0f9c21ab42
No known key found for this signature in database
GPG Key ID: 1CA08EB11DAAA786
255 changed files with 11473 additions and 6501 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@ node_modules/
aot/ aot/
scripts/ionic-native-bower scripts/ionic-native-bower
dist/ dist/
src/plugins/**/ngx
*.d.ts
injectable-classes.json

View File

@ -1,3 +1,48 @@
<a name="4.5.0"></a>
# [4.5.0](https://github.com/ionic-team/ionic-native/compare/v4.4.2...v4.5.0) (2017-12-08)
### Bug Fixes
* **alipay:** add 'string' as an alternative type for 'pay()' input parameter; ([#2172](https://github.com/ionic-team/ionic-native/issues/2172)) ([d43fe72](https://github.com/ionic-team/ionic-native/commit/d43fe72))
* **app-rate:** add simpleMode ([#2155](https://github.com/ionic-team/ionic-native/issues/2155)) ([9844274](https://github.com/ionic-team/ionic-native/commit/9844274))
* **app-rate:** change openStoreInApp to inAppReview ([#2097](https://github.com/ionic-team/ionic-native/issues/2097)) ([d95ae68](https://github.com/ionic-team/ionic-native/commit/d95ae68))
* **camera-preview:** add missing `tapToFocus` camera option ([#2046](https://github.com/ionic-team/ionic-native/issues/2046)) ([b9b781d](https://github.com/ionic-team/ionic-native/commit/b9b781d))
* **deeplinks:** add options parameter([#1601](https://github.com/ionic-team/ionic-native/issues/1601)) ([#2141](https://github.com/ionic-team/ionic-native/issues/2141)) ([bb2291c](https://github.com/ionic-team/ionic-native/commit/bb2291c))
* **ftp:** return observable (not promise) for upload and download method ([#2174](https://github.com/ionic-team/ionic-native/issues/2174)) ([5159367](https://github.com/ionic-team/ionic-native/commit/5159367))
* **indexappcontent:** Return observable for onItemPressed ([#2006](https://github.com/ionic-team/ionic-native/issues/2006)) ([9a52110](https://github.com/ionic-team/ionic-native/commit/9a52110))
* **mobile-accessibility:** change signature references to the correct names ([#2139](https://github.com/ionic-team/ionic-native/issues/2139)) ([b2c873c](https://github.com/ionic-team/ionic-native/commit/b2c873c))
* **ms-adal:** add userInfo in the AuthenticationResult ([#2160](https://github.com/ionic-team/ionic-native/issues/2160)) ([c038c63](https://github.com/ionic-team/ionic-native/commit/c038c63))
* **music-controls:** various fixes ([#2094](https://github.com/ionic-team/ionic-native/issues/2094)) ([afca876](https://github.com/ionic-team/ionic-native/commit/afca876))
* **push:** add senderID to AndroidPushOptions ([#2060](https://github.com/ionic-team/ionic-native/issues/2060)) ([4694c42](https://github.com/ionic-team/ionic-native/commit/4694c42))
* **web-intent:** fix false negative of plugin installation ([#2062](https://github.com/ionic-team/ionic-native/issues/2062)) ([ae94c71](https://github.com/ionic-team/ionic-native/commit/ae94c71))
### Features
* **android exoplayer:** add cordova-plugin-exoplayer ([#2180](https://github.com/ionic-team/ionic-native/issues/2180)) ([d06fa48](https://github.com/ionic-team/ionic-native/commit/d06fa48))
* **android-fingerprint:** add getSigningCertificateFingerprint() method ([#2076](https://github.com/ionic-team/ionic-native/issues/2076)) ([bd5bcdc](https://github.com/ionic-team/ionic-native/commit/bd5bcdc))
* **apple-pay:** add cordova-plugin-applepay ([#2081](https://github.com/ionic-team/ionic-native/issues/2081)) ([784f948](https://github.com/ionic-team/ionic-native/commit/784f948))
* **apple-pay:** update for version 3 of the Apple Pay plugin. ([#2177](https://github.com/ionic-team/ionic-native/issues/2177)) ([bf41506](https://github.com/ionic-team/ionic-native/commit/bf41506))
* **ble:** support startStateNotifications & stopStateNotifications ([#2085](https://github.com/ionic-team/ionic-native/issues/2085)) ([2a4bcee](https://github.com/ionic-team/ionic-native/commit/2a4bcee))
* **braintree:** add support for cordova-plugin-braintree to [@ionic-native](https://github.com/ionic-native) ([#2073](https://github.com/ionic-team/ionic-native/issues/2073)) ([091ac7a](https://github.com/ionic-team/ionic-native/commit/091ac7a))
* **call-number:** add isCallSupported method ([#2051](https://github.com/ionic-team/ionic-native/issues/2051)) ([6053296](https://github.com/ionic-team/ionic-native/commit/6053296))
* **dns:** add cordova-plugin-dns plugin ([#2083](https://github.com/ionic-team/ionic-native/issues/2083)) ([212bd63](https://github.com/ionic-team/ionic-native/commit/212bd63))
* **firebase:** add new Firebase phone verification methods ([#2157](https://github.com/ionic-team/ionic-native/issues/2157)) ([86181af](https://github.com/ionic-team/ionic-native/commit/86181af))
* **GooglePlayGamesServices:** add plugin ([#1904](https://github.com/ionic-team/ionic-native/issues/1904)) ([03f5789](https://github.com/ionic-team/ionic-native/commit/03f5789))
* **network-interface:** add plugin support ([#2063](https://github.com/ionic-team/ionic-native/issues/2063)) ([86b2a2c](https://github.com/ionic-team/ionic-native/commit/86b2a2c))
* **nfc:** add interfaces and missing references to UriHelper and TextHelper ([#2104](https://github.com/ionic-team/ionic-native/issues/2104)) ([8b78644](https://github.com/ionic-team/ionic-native/commit/8b78644))
* **nfc:** add support for iOS ([#2050](https://github.com/ionic-team/ionic-native/issues/2050)) ([9f72592](https://github.com/ionic-team/ionic-native/commit/9f72592))
* **push:** add support for version 2.1.0 ([#2064](https://github.com/ionic-team/ionic-native/issues/2064)) ([c1ce5da](https://github.com/ionic-team/ionic-native/commit/c1ce5da))
* **zeroconf:** add reInit() method ([#2144](https://github.com/ionic-team/ionic-native/issues/2144)) ([7255795](https://github.com/ionic-team/ionic-native/commit/7255795))
<a name="4.4.2"></a>
## [4.4.2](https://github.com/ionic-team/ionic-native/compare/v4.4.1...v4.4.2) (2017-11-15)
<a name="4.4.1"></a> <a name="4.4.1"></a>
## [4.4.1](https://github.com/ionic-team/ionic-native/compare/v4.4.0...v4.4.1) (2017-11-13) ## [4.4.1](https://github.com/ionic-team/ionic-native/compare/v4.4.0...v4.4.1) (2017-11-13)

View File

@ -3,7 +3,7 @@ jobs:
build: build:
working_directory: ~/ionic-native/ working_directory: ~/ionic-native/
docker: docker:
- image: node:7 - image: node:8
steps: steps:
- checkout - checkout
- restore_cache: - restore_cache:
@ -33,7 +33,7 @@ jobs:
- run: bash ./scripts/git/config.sh - run: bash ./scripts/git/config.sh
- run: - run:
name: Build Ionic Native name: Build Ionic Native
command: npm run build:core && ./node_modules/.bin/tsc command: npm run build
- run: - run:
name: Generate README files to ensure docs are valid name: Generate README files to ensure docs are valid
command: npm run readmes command: npm run readmes

View File

@ -1,55 +0,0 @@
"use strict";
module.exports = config => {
const conf = {
frameworks: [
'jasmine',
'karma-typescript'
],
plugins: [
'karma-typescript',
'karma-jasmine',
'karma-phantomjs-launcher'
],
preprocessors: {
'src/**/*.ts': ['karma-typescript']
},
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
transforms: [
require("karma-typescript-es6-transform")()
]
},
compilerOptions: {
lib: ['es2015', 'dom'],
paths: {
"@ionic-native/core": ["./src/@ionic-native/core"]
},
baseUrl: '.'
}
},
files: [
{ pattern: 'src/**/*.ts', included: true, watched: true }
],
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.INFO,
autoWatch: true,
browsers: [
'PhantomJS'
],
singleRun: false
};
config.set(conf);
};

5848
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,82 @@
{ {
"name": "ionic-native", "name": "ionic-native",
"version": "4.4.2", "version": "5.0.0-beta.1",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)", "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT", "license": "MIT",
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"build:core": "tsc -p tsconfig.core.json",
"build:esm": "ts-node -P scripts scripts/tasks/build-esm",
"build:es5": "ts-node -P scripts scripts/tasks/build-es5",
"build:ngx": "ts-node -P scripts scripts/tasks/build-ngx",
"build": "npm run build:core && npm run build:esm && npm run build:ngx && npm run build:es5",
"prebuild": "rm -rf dist",
"npmpub": "ts-node -P scripts scripts/tasks/publish",
"lint": "gulp lint",
"readmes": "gulp readmes",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"postchangelog": "git commit -am \"chore(): update changelog\""
},
"devDependencies": { "devDependencies": {
"@angular/compiler": "4.4.4", "@angular/common": "latest",
"@angular/compiler-cli": "4.4.4", "@angular/compiler": "latest",
"@angular/core": "4.4.4", "@angular/compiler-cli": "latest",
"@angular/core": "latest",
"@types/cordova": "0.0.34", "@types/cordova": "0.0.34",
"@types/jasmine": "^2.6.3", "@types/fs-extra": "^4.0.5",
"@types/node": "^8.0.50", "@types/jest": "21.1.5",
"@types/lodash": "4.14.85",
"@types/node": "8.0.47",
"@types/rimraf": "^2.0.2",
"@types/webpack": "^3.8.1",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babelify": "^8.0.0",
"browserify": "^14.5.0",
"canonical-path": "0.0.2", "canonical-path": "0.0.2",
"child-process-promise": "2.2.1",
"conventional-changelog-cli": "1.3.4", "conventional-changelog-cli": "1.3.4",
"cpr": "2.0.0", "cpr": "2.0.0",
"cz-conventional-changelog": "2.0.0", "cz-conventional-changelog": "2.0.0",
"decamelize": "1.2.0", "decamelize": "1.2.0",
"dgeni": "0.4.7", "dgeni": "0.4.7",
"dgeni-packages": "0.16.10", "dgeni-packages": "0.16.10",
"fs-extra": "2.0.0", "fs-extra": "^4.0.3",
"fs-extra-promise": "0.4.1", "fs-extra-promise": "^1.0.1",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-rename": "1.2.2", "gulp-rename": "1.2.2",
"gulp-replace": "0.5.4", "gulp-replace": "0.6.1",
"gulp-tslint": "6.1.2", "gulp-tslint": "8.1.2",
"jasmine-core": "^2.6.1", "jest": "21.2.1",
"karma": "^1.7.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-typescript": "^3.0.1",
"karma-typescript-es6-transform": "^1.0.0",
"lodash": "4.17.4", "lodash": "4.17.4",
"minimist": "1.2.0", "minimist": "1.2.0",
"node-html-encoder": "0.0.2", "nodemon": "1.12.1",
"q": "1.5.0", "rimraf": "^2.6.2",
"queue": "4.2.1",
"rimraf": "2.6.1",
"rxjs": "5.5.2", "rxjs": "5.5.2",
"semver": "5.3.0", "string-replace-webpack-plugin": "^0.1.3",
"tslint": "3.15.1", "ts-jest": "21.1.4",
"tslint-ionic-rules": "0.0.8", "ts-node": "3.3.0",
"typescript": "~2.4.2", "tslint": "5.8.0",
"zone.js": "0.8.18" "tslint-ionic-rules": "0.0.11",
"typescript": "^2.6.2",
"uglifyjs-webpack-plugin": "^1.1.2",
"unminified-webpack-plugin": "^1.4.2",
"webpack": "^3.9.1"
}, },
"scripts": { "jest": {
"start": "npm run test:watch", "transform": {
"lint": "gulp lint", "^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"build": "npm run clean && npm run lint && npm run build:core && npm run build:modules", },
"build:core": "ngc -p scripts/build/tsconfig-core.json", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js?|ts?)$",
"build:modules": "node scripts/build/build.js", "moduleFileExtensions": [
"clean": "rimraf dist .tmp", "ts",
"shipit": "npm run build && gulp readmes && npm run npmpub", "tsx",
"npmpub": "node scripts/build/publish.js", "js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "jsx",
"postchangelog": "git commit -am \"chore(): update changelog\"", "json"
"test": "karma start karma.conf.js --single-run", ]
"test:watch": "karma start karma.conf.js",
"readmes": "gulp readmes"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,159 +0,0 @@
"use strict";
// Node module dependencies
const fs = require('fs-extra-promise').useFs(require('fs-extra')),
queue = require('queue'),
path = require('path'),
exec = require('child_process').exec;
// Constants for the build process. Paths and JSON files templates
const ROOT = path.resolve(path.join(__dirname, '../../')), // root ionic-native directory
PLUGINS_PATH = path.resolve(ROOT, 'src/@ionic-native/plugins'), // path to plugins source files
CORE_PACKAGE_JSON = require(path.resolve(__dirname, 'core-package.json')), // core package.json
PLUGIN_PACKAGE_JSON = require(path.resolve(__dirname, 'plugin-package.json')), // plugin package.json template
PLUGIN_TS_CONFIG = require(path.resolve(__dirname, 'tsconfig-plugin.json')), // plugin tsconfig template
BUILD_TMP = path.resolve(ROOT, '.tmp'), // tmp directory path
BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/@ionic-native'), // dist directory root path
BUILD_CORE_DIST = path.resolve(BUILD_DIST_ROOT, 'core'); // core dist directory path
// dependency versions
const ANGULAR_VERSION = '*',
RXJS_VERSION = '^5.0.1',
MIN_CORE_VERSION = '^4.2.0',
IONIC_NATIVE_VERSION = require(path.resolve(ROOT, 'package.json')).version;
// package dependencies
const CORE_PEER_DEPS = {
'rxjs': RXJS_VERSION
};
const PLUGIN_PEER_DEPS = {
'@ionic-native/core': MIN_CORE_VERSION,
'@angular/core': ANGULAR_VERSION,
'rxjs': RXJS_VERSION
};
// set peer dependencies for all plugins
PLUGIN_PACKAGE_JSON.peerDependencies = PLUGIN_PEER_DEPS;
// Create tmp/dist directories
console.log('Making new TMP directory');
fs.mkdirpSync(BUILD_TMP);
// Prepare and copy the core module's package.json
console.log('Preparing core module package.json');
CORE_PACKAGE_JSON.version = IONIC_NATIVE_VERSION;
CORE_PACKAGE_JSON.peerDependencies = CORE_PEER_DEPS;
fs.writeJsonSync(path.resolve(BUILD_CORE_DIST, 'package.json'), CORE_PACKAGE_JSON);
// Fetch a list of the plugins
const PLUGINS = fs.readdirSync(PLUGINS_PATH);
// Build specific list of plugins to build from arguments, if any
let pluginsToBuild = process.argv.slice(2);
let ignoreErrors = false;
let errors = [];
const index = pluginsToBuild.indexOf('ignore-errors');
if (index > -1) {
ignoreErrors = true;
pluginsToBuild.splice(index, 1);
console.log('Build will continue even if errors were thrown. Errors will be printed when build finishes.');
}
if (!pluginsToBuild.length) {
pluginsToBuild = PLUGINS;
}
// Create a queue to process tasks
const QUEUE = queue({
concurrency: require('os').cpus().length
});
// Function to process a single plugin
const addPluginToQueue = pluginName => {
QUEUE.push((callback) => {
console.log(`Building plugin: ${pluginName}`);
const PLUGIN_BUILD_DIR = path.resolve(BUILD_TMP, 'plugins', pluginName),
PLUGIN_SRC_PATH = path.resolve(PLUGINS_PATH, pluginName, 'index.ts');
let tsConfigPath;
fs.mkdirpAsync(PLUGIN_BUILD_DIR) // create tmp build dir
.then(() => fs.mkdirpAsync(path.resolve(BUILD_DIST_ROOT, pluginName))) // create dist dir
.then(() => {
// Write tsconfig.json
const tsConfig = JSON.parse(JSON.stringify(PLUGIN_TS_CONFIG));
tsConfig.files = [PLUGIN_SRC_PATH];
// tsConfig.compilerOptions.paths['@ionic-native/core'] = [BUILD_CORE_DIST];
tsConfigPath = path.resolve(PLUGIN_BUILD_DIR, 'tsconfig.json');
return fs.writeJsonAsync(tsConfigPath, tsConfig);
})
.then(() => {
// clone package.json
const packageJson = JSON.parse(JSON.stringify(PLUGIN_PACKAGE_JSON));
packageJson.name = `@ionic-native/${pluginName}`;
packageJson.version = IONIC_NATIVE_VERSION;
return fs.writeJsonAsync(path.resolve(BUILD_DIST_ROOT, pluginName, 'package.json'), packageJson);
})
.then(() => {
// compile the plugin
exec(`${ROOT}/node_modules/.bin/ngc -p ${tsConfigPath}`, (err, stdout, stderr) => {
if (err) {
if (!ignoreErrors) {
// oops! something went wrong.
console.log(err);
callback(`\n\nBuilding ${pluginName} failed.`);
return;
} else {
errors.push(err);
}
}
// we're done with this plugin!
callback();
});
})
.catch(callback);
}); // QUEUE.push end
};
pluginsToBuild.forEach(addPluginToQueue);
QUEUE.start((err) => {
if (err) {
console.log('Error building plugins.');
console.log(err);
process.stderr.write(err);
process.exit(1);
} else if (errors.length) {
errors.forEach(e => {
console.log(e.message) && console.log('\n');
process.stderr.write(err);
});
console.log('Build complete with errors');
process.exit(1);
} else {
console.log('Done processing plugins!');
}
});

View File

@ -1,14 +0,0 @@
{
"name": "@ionic-native/core",
"version": "{{VERSION}}",
"description": "Ionic Native - Native plugins for ionic apps",
"module": "index.js",
"typings": "index.d.ts",
"author": "ionic",
"license": "MIT",
"peerDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-native.git"
}
}

123
scripts/build/helpers.ts Normal file
View File

@ -0,0 +1,123 @@
import * as ts from 'typescript';
import * as fs from 'fs-extra';
import * as path from 'path';
import { camelCase, clone } from 'lodash';
export const ROOT = path.resolve(__dirname, '../../');
export const TS_CONFIG = clone(require(path.resolve(ROOT, 'tsconfig.json')));
export const COMPILER_OPTIONS = TS_CONFIG.compilerOptions;
export const PLUGINS_ROOT = path.join(ROOT, 'src/plugins/');
export const PLUGIN_PATHS = fs.readdirSync(PLUGINS_ROOT).map(d => path.join(PLUGINS_ROOT, d, 'index.ts'));
export function getDecorator(node: ts.Node, index: number = 0): ts.Decorator {
if (node.decorators && node.decorators[index])
return node.decorators[index];
}
export function hasDecorator(decoratorName: string, node: ts.Node): boolean {
return node.decorators && node.decorators.length && node.decorators.findIndex(d => getDecoratorName(d) === decoratorName) > -1;
}
export function getDecoratorName(decorator: any) {
return decorator.expression.expression.text;
}
export function getRawDecoratorArgs(decorator: any): any[] {
if (decorator.expression.arguments.length === 0) return [];
return decorator.expression.arguments[0].properties;
}
export function getDecoratorArgs(decorator: any) {
const properties: any[] = getRawDecoratorArgs(decorator);
const args = {};
properties.forEach(prop => {
let val;
switch (prop.initializer.kind) {
case ts.SyntaxKind.StringLiteral:
val = prop.initializer.text;
// args[prop.name.escapedText] = val;
break;
case ts.SyntaxKind.ArrayLiteralExpression:
val = prop.initializer.elements.map(e => e.text);
break;
case ts.SyntaxKind.TrueKeyword:
val = true;
break;
case ts.SyntaxKind.FalseKeyword:
val = false;
break;
case ts.SyntaxKind.NumericLiteral:
val = Number(prop.initializer.text);
break;
default:
console.log(prop.initializer);
throw 'Unexpected property value type << helpers.ts >>';
}
args[prop.name.text] = val;
});
return args;
}
/**
* FROM STENCIL
* Convert a js value into typescript AST
* @param val array, object, string, boolean, or number
* @returns Typescript Object Literal, Array Literal, String Literal, Boolean Literal, Numeric Literal
*/
export function convertValueToLiteral(val: any) {
if (Array.isArray(val)) {
return arrayToArrayLiteral(val);
}
if (typeof val === 'object') {
return objectToObjectLiteral(val);
}
if (typeof val === 'number') {
return ts.createNumericLiteral(String(val));
}
return ts.createLiteral(val);
}
/**
* FROM STENCIL
* Convert a js object into typescript AST
* @param obj key value object
* @returns Typescript Object Literal Expression
*/
function objectToObjectLiteral(obj: { [key: string]: any }): ts.ObjectLiteralExpression {
const newProperties: ts.ObjectLiteralElementLike[] = Object.keys(obj).map((key: string): ts.ObjectLiteralElementLike => {
return ts.createPropertyAssignment(ts.createLiteral(key), convertValueToLiteral(obj[key]) as ts.Expression);
});
return ts.createObjectLiteral(newProperties);
}
/**
* FROM STENCIL
* Convert a js array into typescript AST
* @param list array
* @returns Typescript Array Literal Expression
*/
function arrayToArrayLiteral(list: any[]): ts.ArrayLiteralExpression {
const newList: any[] = list.map(convertValueToLiteral);
return ts.createArrayLiteral(newList);
}
export function getMethodsForDecorator(decoratorName: string) {
switch (decoratorName) {
case 'CordovaProperty': return ['cordovaPropertyGet', 'cordovaPropertySet'];
case 'InstanceProperty': return ['instancePropertyGet', 'instancePropertySet'];
case 'CordovaCheck': return ['checkAvailability'];
case 'InstanceCheck': return ['instanceAvailability'];
}
return [camelCase(decoratorName)];
}

105
scripts/build/ngx.ts Normal file
View File

@ -0,0 +1,105 @@
import * as ts from 'typescript';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as ngc from '@angular/compiler-cli';
import * as rimraf from 'rimraf';
import { generateDeclarations } from './transpile';
import { clone } from 'lodash';
import { EmitFlags } from '@angular/compiler-cli';
import { importsTransformer } from './transformers/imports';
import { pluginClassTransformer } from './transformers/plugin-class';
import { COMPILER_OPTIONS, PLUGIN_PATHS, ROOT } from './helpers';
export function getProgram(rootNames: string[] = createSourceFiles()) {
const options: ngc.CompilerOptions = clone(COMPILER_OPTIONS);
options.basePath = ROOT;
options.moduleResolution = ts.ModuleResolutionKind.NodeJs;
options.module = ts.ModuleKind.ES2015;
options.target = ts.ScriptTarget.ES5;
options.lib = ['dom', 'es2017'];
options.inlineSourceMap = true;
options.inlineSources = true;
delete options.baseUrl;
const host: ngc.CompilerHost = ngc.createCompilerHost({ options });
return ngc.createProgram({
rootNames,
options,
host
});
}
// hacky way to export metadata only for core package
export function transpileNgxCore() {
getProgram([path.resolve(ROOT, 'src/core/index.ts')]).emit({
emitFlags: EmitFlags.Metadata,
emitCallback: ({ program, writeFile, customTransformers, cancellationToken, targetSourceFile }) =>
program.emit(targetSourceFile, writeFile, cancellationToken, true, customTransformers)
});
}
export function transpileNgx() {
getProgram().emit({
emitFlags: EmitFlags.Metadata,
customTransformers: {
beforeTs: [
importsTransformer(true),
pluginClassTransformer(true)
]
}
});
}
export function generateDeclarationFiles() {
generateDeclarations(PLUGIN_PATHS.map(p => p.replace('index.ts', 'ngx/index.ts')));
}
// remove reference to @ionic-native/core decorators
export function modifyMetadata() {
PLUGIN_PATHS.map(p => p.replace('src', 'dist').replace('index.ts', 'ngx/index.metadata.json'))
.forEach(p => {
const content = fs.readJSONSync(p);
let _prop;
for (const prop in content[0].metadata) {
_prop = content[0].metadata[prop];
removeIonicNativeDecorators(_prop);
if (_prop.members) {
for (const memberProp in _prop.members) {
removeIonicNativeDecorators(_prop.members[memberProp][0]);
}
}
}
fs.writeJSONSync(p, content);
});
}
function removeIonicNativeDecorators(node: any) {
if (node.decorators && node.decorators.length) {
node.decorators = node.decorators.filter((d, i) => d.expression.module !== '@ionic-native/core');
}
if (node.decorators && !node.decorators.length) delete node.decorators;
}
function createSourceFiles(): string[] {
return PLUGIN_PATHS.map((indexPath: string) => {
const ngxPath = path.resolve(indexPath.replace('index.ts', ''), 'ngx'),
newPath = path.resolve(ngxPath, 'index.ts');
// delete directory
rimraf.sync(ngxPath);
fs.mkdirpSync(ngxPath);
fs.copyFileSync(indexPath, newPath);
return newPath;
});
}
export function cleanupNgx() {
PLUGIN_PATHS.forEach((indexPath: string) =>
rimraf.sync(indexPath.replace('index.ts', 'ngx'))
);
}

View File

@ -1,14 +0,0 @@
{
"name": "@ionic-native/{{PLUGIN}}",
"version": "{{VERSION}}",
"description": "Ionic Native - Native plugins for ionic apps",
"module": "index.js",
"typings": "index.d.ts",
"author": "ionic",
"license": "MIT",
"peerDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-native.git"
}
}

View File

@ -1,58 +0,0 @@
"use strict";
// Node module dependencies
const fs = require('fs-extra-promise').useFs(require('fs-extra')),
queue = require('queue'),
path = require('path'),
exec = require('child-process-promise').exec;
const ROOT = path.resolve(path.join(__dirname, '../../')),
DIST = path.resolve(ROOT, 'dist', '@ionic-native');
const FLAGS = '--access public'; // add any flags here if you want... (example: --tag alpha)
const PACKAGES = fs.readdirSync(DIST);
const failedPackages = [];
const QUEUE = queue({
concurrency: 10
});
PACKAGES.forEach(packageName => {
QUEUE.push(done => {
console.log(`Publishing @ionic-native/${packageName}`);
const packagePath = path.resolve(DIST, packageName);
exec(`npm publish ${packagePath} ${FLAGS}`)
.then(() => done())
.catch((e) => {
if (e.stderr && e.stderr.indexOf('previously published version') === -1) {
failedPackages.push({
cmd: e.cmd,
stderr: e.stderr
});
}
done();
});
});
});
QUEUE.start((err) => {
if (err) {
console.log('Error publishing ionic-native. ', err);
} else if (failedPackages.length > 0) {
console.log(`${failedPackages.length} packages failed to publish.`);
console.log(failedPackages);
} else {
console.log('Done publishing ionic-native!');
}
});

View File

@ -0,0 +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, '');

View File

@ -0,0 +1,54 @@
import * as ts from 'typescript';
import * as fs from 'fs-extra';
import * as path from 'path';
import { hasDecorator, ROOT } from '../helpers';
export interface InjectableClassEntry {
file: string;
className: string;
dirName: string;
}
const injectableClasses: InjectableClassEntry[] = [];
export const EMIT_PATH = path.resolve(ROOT, 'injectable-classes.json');
/**
* This transformer extracts all the injectable classes
* so we can use all the names later on when we compile
* an es5 bundle.
*
* Every injectable class will end up in the
* window['IonicNative'] object.
*/
export function extractInjectables() {
return (ctx: ts.TransformationContext) => {
return tsSourceFile => {
if (tsSourceFile.fileName.indexOf('src/plugins') > -1) {
ts.visitEachChild(tsSourceFile, node => {
if (node.kind !== ts.SyntaxKind.ClassDeclaration) {
return node;
}
const isInjectable: boolean = hasDecorator('Injectable', node);
if (isInjectable) {
injectableClasses.push({
file: tsSourceFile.path,
className: (node as ts.ClassDeclaration).name.text,
dirName: tsSourceFile.path.split(/[\\\/]+/).reverse()[1]
});
}
}, ctx);
}
return tsSourceFile;
}
};
}
export function emitInjectableClasses() {
fs.writeJSONSync(EMIT_PATH, injectableClasses);
}
export function cleanEmittedData() {
fs.unlinkSync(EMIT_PATH);
}

View File

@ -0,0 +1,51 @@
import * as ts from 'typescript';
import { getMethodsForDecorator } from '../helpers';
function transformImports(file: ts.SourceFile, ctx: ts.TransformationContext, ngcBuild?: boolean) {
// remove angular imports
if (!ngcBuild) {
file.statements = (file.statements as any).filter((s: any) => !(s.kind === ts.SyntaxKind.ImportDeclaration && s.moduleSpecifier.text === '@angular/core'));
}
// find the @ionic-native/core import statement
const importStatement = (file.statements as any).find((s: any) => {
return s.kind === ts.SyntaxKind.ImportDeclaration && s.moduleSpecifier.text === '@ionic-native/core';
});
// we're only interested in files containing @ionic-native/core import statement
if (!importStatement) return file;
let decorators: string[] = [];
const decoratorRegex: RegExp = /@([a-zA-Z]+)\(/g;
let m;
while ((m = decoratorRegex.exec(file.text)) !== null) {
if (m.index === decoratorRegex.lastIndex) {
decoratorRegex.lastIndex++;
}
if (m && m[1] && decorators.indexOf(m[1]) === -1 && m[1] !== 'Plugin') decorators.push(m[1]);
}
if (decorators.length) {
let methods = [];
decorators.forEach(d => methods = getMethodsForDecorator(d).concat(methods));
importStatement.importClause.namedBindings.elements = [
ts.createIdentifier('IonicNativePlugin'),
...methods.map(m => ts.createIdentifier(m))
];
}
return file;
}
export function importsTransformer(ngcBuild?: boolean) {
return (ctx: ts.TransformationContext) => {
return tsSourceFile => {
return transformImports(tsSourceFile, ctx, ngcBuild);
}
};
}

View File

@ -0,0 +1,37 @@
import * as ts from 'typescript';
import { transformMethod } from './methods';
import { transformProperty } from './properties';
export function transformMembers(cls: ts.ClassDeclaration) {
const propertyIndices: number[] = [];
let members = cls.members.map((member: any, index: number) => {
// only process decorated members
if (!member.decorators || !member.decorators.length) return member;
switch (member.kind) {
case ts.SyntaxKind.MethodDeclaration:
return transformMethod(member);
case ts.SyntaxKind.PropertyDeclaration:
propertyIndices.push(index);
return member;
case ts.SyntaxKind.Constructor:
return ts.createConstructor(undefined, undefined, member.parameters, member.body);
default:
return member; // in case anything gets here by accident...
}
});
propertyIndices.forEach((i: number) => {
const [getter, setter] = transformProperty(members, i) as any;
members.push(getter, setter);
});
propertyIndices.reverse().forEach(i => members.splice(i, 1));
return members;
}

View File

@ -0,0 +1,47 @@
import * as ts from 'typescript';
import { convertValueToLiteral, getDecorator, getDecoratorArgs, getDecoratorName, getMethodsForDecorator } from '../helpers';
export function transformMethod(method: ts.MethodDeclaration) {
if (!method) return;
const decorator = getDecorator(method),
decoratorName = getDecoratorName(decorator),
decoratorArgs = getDecoratorArgs(decorator);
try {
return ts.createMethod(undefined, undefined, undefined, method.name, undefined, method.typeParameters, method.parameters, method.type, ts.createBlock([
ts.createReturn(
getMethodBlock(method, decoratorName, decoratorArgs)
)
]));
} catch (e) {
console.log('Error transforming method: ', (method.name as any).text);
console.log(e.message);
}
}
function getMethodBlock(method: ts.MethodDeclaration, decoratorName: string, decoratorArgs: any): ts.Expression {
const decoratorMethod = getMethodsForDecorator(decoratorName)[0];
switch (decoratorName) {
case 'CordovaCheck':
case 'InstanceCheck':
return ts.createImmediatelyInvokedFunctionExpression([ts.createIf(
ts.createBinary(
ts.createCall(ts.createIdentifier(decoratorMethod), undefined, [ts.createThis()]),
ts.SyntaxKind.EqualsEqualsEqualsToken,
ts.createTrue()
),
method.body
)]);
default:
return ts.createCall(ts.createIdentifier(decoratorMethod), undefined, [
ts.createThis(),
ts.createLiteral((method.name as any).text),
convertValueToLiteral(decoratorArgs),
ts.createIdentifier('arguments')
]);
}
}

View File

@ -0,0 +1,64 @@
import * as ts from 'typescript';
import { convertValueToLiteral, getDecorator, getDecoratorArgs, getDecoratorName } from '../helpers';
import { transformMembers } from './members';
function transformClass(cls: any, ngcBuild?: boolean) {
console.time('~ transformClass: ' + cls.name.text);
const pluginStatics = [];
const dec: any = getDecorator(cls);
if (dec) {
const pluginDecoratorArgs = getDecoratorArgs(dec);
// add plugin decorator args as static properties of the plugin's class
for (let prop in pluginDecoratorArgs) {
pluginStatics.push(ts.createProperty(
undefined,
[ts.createToken(ts.SyntaxKind.StaticKeyword)],
ts.createIdentifier(prop),
undefined,
undefined,
convertValueToLiteral(pluginDecoratorArgs[prop])
));
}
}
cls = ts.createClassDeclaration(
ngcBuild && cls.decorators && cls.decorators.length? cls.decorators.filter(d => getDecoratorName(d) === 'Injectable') : undefined, // remove Plugin and Injectable decorators
[ts.createToken(ts.SyntaxKind.ExportKeyword)],
cls.name,
cls.typeParameters,
cls.heritageClauses,
[
...transformMembers(cls),
...pluginStatics
]
);
console.timeEnd('~ transformClass: ' + cls.name.text);
return cls;
}
function transformClasses(file: ts.SourceFile, ctx: ts.TransformationContext, ngcBuild?: boolean) {
// console.log('Transforming file: ' + file.fileName);
return ts.visitEachChild(file, node => {
if (node.kind !== ts.SyntaxKind.ClassDeclaration) {
return node;
}
return transformClass(node, ngcBuild);
}, ctx);
}
export function pluginClassTransformer(ngcBuild?: boolean): ts.TransformerFactory<ts.SourceFile> {
return (ctx: ts.TransformationContext) => {
return tsSourceFile => {
if (tsSourceFile.fileName.indexOf('src/plugins') > -1)
return transformClasses(tsSourceFile, ctx, ngcBuild);
return tsSourceFile;
}
};
}

View File

@ -0,0 +1,53 @@
import * as ts from 'typescript';
import { getDecorator, getDecoratorName } from '../helpers';
export function transformProperty(members: any[], index: number) {
const property = members[index] as ts.PropertyDeclaration,
decorator = getDecorator(property),
decoratorName = getDecoratorName(decorator);
let type: 'cordova' | 'instance';
switch (decoratorName) {
case 'CordovaProperty':
type = 'cordova';
break;
case 'InstanceProperty':
type = 'instance';
break;
default: return property;
}
const getter = ts.createGetAccessor(undefined, undefined, property.name, undefined, property.type, ts.createBlock([
ts.createReturn(
ts.createCall(
ts.createIdentifier(type + 'PropertyGet'),
undefined,
[
ts.createThis(),
ts.createLiteral((property.name as any).text)
]
)
)
]));
const setter = ts.createSetAccessor(undefined, undefined, property.name, [ts.createParameter(undefined, undefined, undefined, 'value', undefined, property.type)], ts.createBlock([
ts.createStatement(
ts.createCall(
ts.createIdentifier(type + 'PropertySet'),
undefined,
[
ts.createThis(),
ts.createLiteral((property.name as any).text),
ts.createIdentifier('value')
]
)
)
]));
return [getter, setter];
}

View File

@ -0,0 +1,51 @@
import * as ts from 'typescript';
import { pluginClassTransformer } from './transformers/plugin-class';
import { importsTransformer } from './transformers/imports';
import { clone } from 'lodash';
import { emitInjectableClasses, extractInjectables } from './transformers/extract-injectables';
import { COMPILER_OPTIONS, PLUGIN_PATHS, TS_CONFIG } from './helpers';
let host: ts.CompilerHost;
export function getCompilerHost() {
if (!host) host = ts.createCompilerHost(TS_CONFIG);
return host;
}
export function getProgram(declaration: boolean = false, pluginPaths: string[] = PLUGIN_PATHS) {
const compilerOptions: ts.CompilerOptions = clone(COMPILER_OPTIONS);
compilerOptions.declaration = declaration;
compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
compilerOptions.target = ts.ScriptTarget.ES5;
compilerOptions.module = ts.ModuleKind.ES2015;
compilerOptions.inlineSourceMap = true;
compilerOptions.inlineSources = true;
compilerOptions.lib = [
'lib.dom.d.ts',
'lib.es5.d.ts',
'lib.es2015.d.ts',
'lib.es2016.d.ts',
'lib.es2017.d.ts'
];
return ts.createProgram(pluginPaths, compilerOptions, getCompilerHost());
}
export function generateDeclarations(sourceFiles?: string[]) {
return getProgram(true, sourceFiles).emit(undefined, getCompilerHost().writeFile, undefined, true);
}
export function transpile() {
const emitResult = getProgram().emit(undefined, getCompilerHost().writeFile, undefined, false, {
before: [
extractInjectables(),
importsTransformer(),
pluginClassTransformer(),
]
});
emitInjectableClasses();
return emitResult;
}

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "es2015",
"moduleResolution": "node",
"outDir": "../../../dist/@ionic-native/",
"paths": {
"@ionic-native/core": ["../../../dist/@ionic-native/core"]
},
"rootDir": "../../../src/@ionic-native/plugins/",
"target": "es5",
"skipLibCheck": true,
"lib": ["es2015", "dom"],
"sourceMap": true,
"inlineSources": true,
"noImplicitAny": true
},
"files": []
}

View File

@ -1,65 +0,0 @@
const exec = require('child-process-promise').exec;
let diff;
exec(`git branch | grep \\* | cut -d ' ' -f2`)
.then(output => {
if (output.stderr) {
return Promise.reject(output.stderr);
}
const branch = output.stdout.trim();
if (branch !== 'master') {
console.log('Merging master branch in ...');
// not on master branch
// let's test the changes that were made
return exec(`git merge origin master`);
}
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
console.log('Checking for differences ...');
return exec(`git diff --name-status origin master`)
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
diff = output.stdout;
diff = diff.replace(/A\s+/g, '');
diff = diff.match(/src\/@ionic-native\/plugins\/([a-zA-Z0-9\-]+)\/index\.ts/g);
if (!diff) process.exit();
console.log(`${ diff.length } plugins were modified. We will now build them to verify they still work.`);
return exec('npm run build:core --silent');
})
.then((output) => {
if (output && output.stderr) {
return Promise.reject(output.stderr);
}
console.log('Built core library successfully ...');
console.log('Building plugins ...');
diff = diff.map(text => text.replace('src/@ionic-native/plugins/', '').replace('/index.ts', ''));
return exec(`npm run build:modules ${diff.join(' ')} --silent`);
})
.then((output) => {
if (output && output.stderr) {
console.log(output.stderr);
process.exit(1);
}
console.log(output.stdout);
process.exit();
})
.catch(e => {
console.log(e.message || e);
process.exit(1);
});

View File

@ -2,5 +2,5 @@
"sitePath": "../ionic-site", "sitePath": "../ionic-site",
"v2DocsDir": "docs/native", "v2DocsDir": "docs/native",
"docsDest": "../ionic-site/content/docs/native", "docsDest": "../ionic-site/content/docs/native",
"pluginDir": "dist/@ionic-native" "pluginDir": "dist/plugins"
} }

View File

@ -50,11 +50,11 @@ module.exports = currentVersion => {
// Don't run unwanted processors since we are not using the normal file reading processor // Don't run unwanted processors since we are not using the normal file reading processor
readFilesProcessor.$enabled = false; readFilesProcessor.$enabled = false;
readFilesProcessor.basePath = path.resolve(__dirname, '../..'); readFilesProcessor.basePath = path.resolve(__dirname, '../../..');
readTypeScriptModules.basePath = path.resolve(__dirname, '../..'); readTypeScriptModules.basePath = path.resolve(__dirname, '../../..');
readTypeScriptModules.sourceFiles = [ readTypeScriptModules.sourceFiles = [
'./src/@ionic-native/plugins/**/*.ts' './src/plugins/**/*.ts'
]; ];
}) })

View File

@ -40,7 +40,6 @@ module.exports = currentVersion => {
computePathsProcessor.pathTemplates = [{ computePathsProcessor.pathTemplates = [{
docTypes: ['class'], docTypes: ['class'],
getOutputPath: doc => doc.originalModule.replace(config.pluginDir + '/', '') getOutputPath: doc => doc.originalModule.replace(config.pluginDir + '/', '')
.replace('/plugins', '')
.replace(/\/index$/, '/README.md') .replace(/\/index$/, '/README.md')
}]; }];
@ -50,10 +49,10 @@ module.exports = currentVersion => {
.config(function(readFilesProcessor, readTypeScriptModules) { .config(function(readFilesProcessor, readTypeScriptModules) {
// Don't run unwanted processors since we are not using the normal file reading processor // Don't run unwanted processors since we are not using the normal file reading processor
readFilesProcessor.$enabled = false; readFilesProcessor.$enabled = false;
readFilesProcessor.basePath = path.resolve(__dirname, '../..'); readFilesProcessor.basePath = path.resolve(__dirname, '../../..');
readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../..')); readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../../..'));
readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts']; readTypeScriptModules.sourceFiles = ['./src/plugins/**/*.ts'];
}) })
// Configure file writing // Configure file writing

View File

@ -1,5 +1,5 @@
"use strict"; "use strict";
const config = require('../config.json'), const config = require('./config.json'),
projectPackage = require('../../package.json'), projectPackage = require('../../package.json'),
path = require('path'), path = require('path'),
fs = require('fs-extra-promise').useFs(require('fs-extra')), fs = require('fs-extra-promise').useFs(require('fs-extra')),
@ -10,7 +10,7 @@ module.exports = gulp => {
try { try {
const ionicPackage = require('./dgeni-config')(projectPackage.version), const ionicPackage = require('./dgeni/dgeni-config')(projectPackage.version),
dgeni = new Dgeni([ionicPackage]); 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'));
@ -27,7 +27,7 @@ module.exports = gulp => {
try { try {
const ionicPackage = require('./dgeni-readmes-config')(projectPackage.version), const ionicPackage = require('./dgeni/dgeni-readmes-config')(projectPackage.version),
dgeni = new Dgeni([ionicPackage]); 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'));

View File

@ -31,7 +31,7 @@ function run {
# git push origin master || : # git push origin master || :
echo "-- Updated docs for $VERSION_NAME succesfully!" echo "-- Updated docs for $VERSION_NAME successfully!"
fi fi
} }

0
scripts/utils.inc.sh → scripts/docs/utils.inc.sh Executable file → Normal file
View File

View File

@ -0,0 +1,76 @@
import * as fs from 'fs-extra';
import * as path from 'path';
import * as webpack from 'webpack';
import * as uglifyJsPlugin from 'uglifyjs-webpack-plugin';
import * as unminifiedPlugin from 'unminified-webpack-plugin';
import { cleanEmittedData, EMIT_PATH, InjectableClassEntry } from '../build/transformers/extract-injectables';
import { ROOT } from '../build/helpers';
const DIST = path.resolve(ROOT, 'dist');
const INDEX_PATH = path.resolve(DIST, 'index.js');
const INJECTABLE_CLASSES = fs.readJSONSync(EMIT_PATH).map((item: InjectableClassEntry) => {
item.file = './' + item.file.split(/[\/\\]+/).slice(-3, -1).join('/');
return item;
});
const webpackConfig: webpack.Configuration = {
entry: INDEX_PATH,
devtool: 'source-map',
target: 'web',
output: {
path: DIST,
filename: 'ionic-native.min.js'
},
resolve: {
modules: ['node_modules'],
extensions: ['.js'],
alias: {
'@ionic-native/core': path.resolve(DIST, 'core/index.js')
}
},
module: {
rules: [{
test: /\.js$/,
use: path.resolve(ROOT, 'scripts/build/remove-tslib-helpers.js')
}]
},
plugins: [
new webpack.ProvidePlugin({
'__extends': ['tslib', '__extends']
}),
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new uglifyJsPlugin({
sourceMap: true
})
]
};
function getPluginImport(entry: InjectableClassEntry) {
return `import { ${ entry.className } } from '${ entry.file }';`;
}
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 += '\n};\n';
fileContent += `require('./core/bootstrap').checkReady();\n`;
fileContent += `require('./core/ng1').initAngular1(window.IonicNative);`;
fs.writeFileSync(INDEX_PATH, fileContent, { encoding: 'utf-8' });
}
function compile() {
webpack(webpackConfig, (err, stats) => {
if (err) console.log(err);
else console.log(stats);
// cleanEmittedData();
});
}
createIndexFile();
compile();

View File

@ -0,0 +1,29 @@
import { generateDeclarations, transpile } from '../build/transpile';
import { EMIT_PATH } from '../build/transformers/extract-injectables';
import { PLUGIN_PATHS } from '../build/helpers';
import * as fs from 'fs-extra';
import * as path from 'path';
generateDeclarations();
transpile();
const outDirs = PLUGIN_PATHS.map(p => p.replace('src', 'dist').replace(/[\\/]index.ts/, ''));
const injectableClasses = fs.readJSONSync(EMIT_PATH);
outDirs.forEach(dir => {
const classes = injectableClasses.filter(entry => entry.dirName === dir.split(/[\\/]+/).pop());
let jsFile: string = fs.readFileSync(path.join(dir, 'index.js'), 'utf-8'),
dtsFile: string = fs.readFileSync(path.join(dir, 'index.d.ts'), 'utf-8');
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(new RegExp(`([\\s\\(])${ entry.className }([\\s\\.;\\(,])`, 'g'), '$1' + entry.className + 'Original$2');
jsFile = jsFile.replace(`export { ${ entry.className }Original }`, `var ${ entry.className } = new ${ entry.className }Original();\nexport { ${ entry.className } }`);
});
fs.writeFileSync(path.join(dir, 'index.js'), jsFile, 'utf-8');
fs.writeFileSync(path.join(dir, 'index.d.ts'), dtsFile, 'utf-8');
});

View File

@ -0,0 +1,7 @@
import { generateDeclarationFiles, transpileNgx, transpileNgxCore, modifyMetadata, cleanupNgx } from '../build/ngx';
transpileNgxCore();
transpileNgx();
generateDeclarationFiles();
modifyMetadata();
cleanupNgx();

75
scripts/tasks/publish.ts Normal file
View File

@ -0,0 +1,75 @@
import * as fs from 'fs-extra';
import * as path from 'path';
import { merge } from 'lodash';
import { exec } from 'child_process';
import { PLUGIN_PATHS, ROOT } from '../build/helpers';
const MAIN_PACKAGE_JSON = require('../../package.json');
const VERSION = MAIN_PACKAGE_JSON.version;
const FLAGS = '--access public --tag beta';
const PACKAGE_JSON_BASE = {
"description": "Ionic Native - Native plugins for ionic apps",
"module": "index.js",
"typings": "index.d.ts",
"author": "ionic",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-native.git"
}
};
const DIST = path.resolve(ROOT, 'dist');
const PACKAGES = [];
const RXJS_VEERSION = '^5.0.1';
const CORE_VERSION = '^5.0.0';
const PLUGIN_PEER_DEPENDENCIES = {
'@ionic-native/core': VERSION, // TODO change this in production
'rxjs': RXJS_VEERSION
};
function getPackageJsonContent(name, peerDependencies = {}) {
return merge(PACKAGE_JSON_BASE, {
name: '@ionic-native/' + name,
peerDependencies,
version: VERSION
});
}
function writePackageJson(data: any, dir: string) {
const filePath = path.resolve(dir, 'package.json');
fs.writeJSONSync(filePath, data);
PACKAGES.push(dir);
}
function prepare() {
// write @ionic-native/core package.json
writePackageJson(
getPackageJsonContent('core', { 'rxjs': RXJS_VEERSION }),
path.resolve(DIST, 'core')
);
// write plugin package.json files
PLUGIN_PATHS.forEach((pluginPath: string) => {
const pluginName = pluginPath.split(/[\/\\]+/).slice(-2)[0];
const packageJsonContents = getPackageJsonContent(pluginName, PLUGIN_PEER_DEPENDENCIES);
const dir = path.resolve(DIST, 'plugins', pluginName);
writePackageJson(packageJsonContents, dir);
});
}
function publish() {
// TODO apply queue system so it doesn't publish everything at once
PACKAGES.forEach((pkg: string) => {
// console.log('Going to run the following command: ', `npm publish ${ pkg } ${ FLAGS }`);
exec(`npm publish ${ pkg } ${ FLAGS }`);
});
}
prepare();
publish();

12
scripts/tsconfig.json Normal file
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"moduleResolution": "node",
"noImplicitAny": false,
"lib": ["es6"]
},
"exclude": [
"node_modules"
]
}

View File

@ -1,277 +0,0 @@
import 'core-js';
import { Plugin, Cordova, CordovaProperty, CordovaCheck, CordovaInstance, InstanceProperty } from './decorators';
import { IonicNativePlugin } from './ionic-native-plugin';
import { ERR_CORDOVA_NOT_AVAILABLE, ERR_PLUGIN_NOT_INSTALLED } from './plugin';
import { Observable } from 'rxjs/Observable';
declare const window: any;
class TestObject {
constructor(public _objectInstance: any) {}
@InstanceProperty
name: string;
@CordovaInstance({ sync: true })
pingSync(): string { return; }
@CordovaInstance()
ping(): Promise<any> { return; }
}
@Plugin({
pluginName: 'TestPlugin',
pluginRef: 'testPlugin',
repo: '',
plugin: 'cordova-plugin-my-plugin',
platforms: ['Android', 'iOS']
})
class TestPlugin extends IonicNativePlugin {
@CordovaProperty
name: string;
@Cordova({ sync: true })
pingSync(): string { return; }
@Cordova()
ping(): Promise<string> { return; }
@CordovaCheck()
customPing(): Promise<string> {
return Promise.resolve('pong');
}
create(): TestObject {
return new TestObject(TestPlugin.getPlugin().create());
}
@Cordova({
destruct: true
})
destructPromise(): Promise<any> { return; }
@Cordova({
destruct: true,
observable: true
})
destructObservable(): Observable<any> { return; }
}
function definePlugin() {
(window as any).testPlugin = {
name: 'John Smith',
ping: (success: Function, error: Function) => success('pong'),
pingSync: () => 'pong',
create: function TestObject() {
this.pingSync = () => 'pong';
this.ping = (success: Function, error: Function) => success('pong');
this.name = 'John Smith';
return this;
},
destructPromise: (success: Function) => success('hello', 'world'),
destructObservable: (success: Function) => success('hello', 'world')
};
}
describe('Regular Decorators', () => {
let plugin: TestPlugin;
beforeEach(() => {
plugin = new TestPlugin();
definePlugin();
});
describe('Plugin', () => {
it('should set pluginName', () => {
expect(TestPlugin.getPluginName()).toEqual('TestPlugin');
});
it('should set pluginRef', () => {
expect(TestPlugin.getPluginRef()).toEqual('testPlugin');
});
it('should return original plugin object', () => {
expect(TestPlugin.getPlugin()).toEqual(window.testPlugin);
});
it('should return supported platforms', () => {
expect(TestPlugin.getSupportedPlatforms()).toEqual(['Android', 'iOS']);
});
});
describe('Cordova', () => {
it('should do a sync function', () => {
expect(plugin.pingSync()).toEqual('pong');
});
it('should do an async function', (done: Function) => {
plugin.ping()
.then(res => {
expect(res).toEqual('pong');
done();
})
.catch(e => {
expect(e).toBeUndefined();
done('Method should have resolved');
});
});
it('should throw plugin_not_installed error', (done: Function) => {
delete window.testPlugin;
window.cordova = true;
expect(<any>plugin.pingSync()).toEqual(ERR_PLUGIN_NOT_INSTALLED);
plugin.ping()
.catch(e => {
expect(e).toEqual(ERR_PLUGIN_NOT_INSTALLED.error);
delete window.cordova;
done();
});
});
it('should throw cordova_not_available error', (done: Function) => {
delete window.testPlugin;
expect(<any>plugin.pingSync()).toEqual(ERR_CORDOVA_NOT_AVAILABLE);
plugin.ping()
.catch(e => {
expect(e).toEqual(ERR_CORDOVA_NOT_AVAILABLE.error);
done();
});
});
});
describe('CordovaProperty', () => {
it('should return property value', () => {
expect(plugin.name).toEqual('John Smith');
});
it('should set property value', () => {
plugin.name = 'value2';
expect(plugin.name).toEqual('value2');
});
});
describe('CordovaCheck', () => {
it('should run the method when plugin exists', (done) => {
plugin.customPing()
.then(res => {
expect(res).toEqual('pong');
done();
});
});
it('shouldnt run the method when plugin doesnt exist', (done) => {
delete window.testPlugin;
window.cordova = true;
plugin.customPing()
.catch(e => {
expect(e).toEqual(ERR_PLUGIN_NOT_INSTALLED.error);
done();
});
});
});
describe('CordovaOptions', () => {
describe('destruct', () => {
it('should destruct values returned by a Promise', (done) => {
plugin.destructPromise()
.then((args: any[]) => {
expect(args).toEqual(['hello', 'world']);
done();
});
});
it('should destruct values returned by an Observable', (done) => {
plugin.destructObservable()
.subscribe((args: any[]) => {
expect(args).toEqual(['hello', 'world']);
done();
});
});
});
});
});
describe('Instance Decorators', () => {
let instance: TestObject,
plugin: TestPlugin;
beforeEach(() => {
definePlugin();
plugin = new TestPlugin();
instance = plugin.create();
});
describe('Instance plugin', () => {
});
describe('CordovaInstance', () => {
it('should call instance async method', (done) => {
instance.ping()
.then(r => {
expect(r).toEqual('pong');
done();
});
});
it('should call instance sync method', () => {
expect(instance.pingSync()).toEqual('pong');
});
it('shouldnt call instance method when _objectInstance is undefined', () => {
delete instance._objectInstance;
instance.ping()
.then(r => {
expect(r).toBeUndefined();
})
.catch(e => {
expect(e).toBeUndefined();
});
});
});
describe('InstanceProperty', () => {
it('should return property value', () => {
expect(instance.name).toEqual('John Smith');
});
it('should set property value', () => {
instance.name = 'John Cena';
expect(instance.name).toEqual('John Cena');
});
});
});

View File

@ -1,313 +0,0 @@
import { instanceAvailability, checkAvailability, wrap, wrapInstance, overrideFunction } from './plugin';
import { getPlugin, getPromise } from './util';
import { Observable } from 'rxjs/Observable';
import 'rxjs/observable/throw';
export interface PluginConfig {
/**
* Plugin name, this should match the class name
*/
pluginName: string;
/**
* Plugin NPM package name
*/
plugin: string;
/**
* Plugin object reference
*/
pluginRef?: string;
/**
* Github repository URL
*/
repo?: string;
/**
* Custom install command
*/
install?: string;
/**
* Available installation variables
*/
installVariables?: string[];
/**
* Supported platforms
*/
platforms?: string[];
[key: string]: any;
}
export interface CordovaOptions {
destruct?: boolean;
/**
* Set to true if the wrapped method is a sync function
*/
sync?: boolean;
/**
* Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method takes.
*/
callbackOrder?: 'reverse';
/**
* Callback style
*/
callbackStyle?: 'node' | 'object';
/**
* Set a custom index for the success callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
successIndex?: number;
/**
* Set a custom index for the error callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
errorIndex?: number;
/**
* Success function property name. This must be set if callbackStyle is set to object.
*/
successName?: string;
/**
* Error function property name. This must be set if callbackStyle is set to object.
*/
errorName?: string;
/**
* Set to true to return an observable
*/
observable?: boolean;
/**
* If observable is set to true, this can be set to a different function name that will cancel the observable.
*/
clearFunction?: string;
/**
* This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
*/
clearWithArgs?: boolean;
/**
* Creates an observable that wraps a global event. Replaces document.addEventListener
*/
eventObservable?: boolean;
/**
* Event name, this must be set if eventObservable is set to true
*/
event?: string;
/**
* Element to attach the event listener to, this is optional, defaults to `window`
*/
element?: any;
/**
* Set to true if the wrapped method returns a promise
*/
otherPromise?: boolean;
/**
* Supported platforms
*/
platforms?: string[];
}
export interface CordovaCheckOptions {
sync?: boolean;
observable?: boolean;
}
/**
* @private
*/
export function InstanceCheck(opts: CordovaCheckOptions = {}) {
return (pluginObj: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
return {
value: function(...args: any[]): any {
if (instanceAvailability(this)) {
return descriptor.value.apply(this, args);
} else {
if (opts.sync) {
return;
} else if (opts.observable) {
return new Observable<any>(() => { });
}
return getPromise(() => { });
}
},
enumerable: true
};
};
}
/**
* Executes function only if plugin is available
* @private
*/
export function CordovaCheck(opts: CordovaCheckOptions = {}) {
return (pluginObj: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
return {
value: function(...args: any[]): any {
const check = checkAvailability(pluginObj);
if (check === true) {
return descriptor.value.apply(this, args);
} else {
if (opts.sync) {
return null;
} else if (opts.observable) {
return Observable.throw(new Error(check && check.error));
}
return Promise.reject(check && check.error);
}
},
enumerable: true
};
};
}
/**
* @private
*
* Class decorator specifying Plugin metadata. Required for all plugins.
*
* @usage
* ```typescript
* @Plugin({
* pluginName: 'MyPlugin',
* plugin: 'cordova-plugin-myplugin',
* pluginRef: 'window.myplugin'
* })
* export class MyPlugin {
*
* // Plugin wrappers, properties, and functions go here ...
*
* }
* ```
*/
export function Plugin(config: PluginConfig): ClassDecorator {
return function(cls: any) {
// Add these fields to the class
for (let prop in config) {
cls[prop] = config[prop];
}
cls['installed'] = function(printWarning?: boolean) {
return !!getPlugin(config.pluginRef);
};
cls['getPlugin'] = function() {
return getPlugin(config.pluginRef);
};
cls['checkInstall'] = function() {
return checkAvailability(cls) === true;
};
cls['getPluginName'] = function() {
return config.pluginName;
};
cls['getPluginRef'] = function() {
return config.pluginRef;
};
cls['getPluginInstallName'] = function() {
return config.plugin;
};
cls['getPluginRepo'] = function() {
return config.repo;
};
cls['getSupportedPlatforms'] = function() {
return config.platforms;
};
return cls;
};
}
/**
* @private
*
* Wrap a stub function in a call to a Cordova plugin, checking if both Cordova
* and the required plugin are installed.
*/
export function Cordova(opts: CordovaOptions = {}) {
return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => {
return {
value: function(...args: any[]) {
return wrap(this, methodName, opts).apply(this, args);
},
enumerable: true
};
};
}
/**
* @private
*
* Wrap an instance method
*/
export function CordovaInstance(opts: CordovaOptions = {}) {
return (target: Object, methodName: string) => {
return {
value: function(...args: any[]) {
return wrapInstance(this, methodName, opts).apply(this, args);
},
enumerable: true
};
};
}
/**
* @private
*
*
* Before calling the original method, ensure Cordova and the plugin are installed.
*/
export function CordovaProperty(target: any, key: string) {
Object.defineProperty(target, key, {
enumerable: true,
get: () => {
if (checkAvailability(target, key) === true) {
return getPlugin(target.constructor.getPluginRef())[key];
} else {
return null;
}
},
set: (value) => {
if (checkAvailability(target, key) === true) {
getPlugin(target.constructor.getPluginRef())[key] = value;
}
}
});
}
/**
* @private
* @param target
* @param key
* @constructor
*/
export function InstanceProperty(target: any, key: string) {
Object.defineProperty(target, key, {
enumerable: true,
get: function() {
return this._objectInstance[key];
},
set: function(value) {
this._objectInstance[key] = value;
}
});
}
/**
* @private
*
* Wrap a stub function in a call to a Cordova plugin, checking if both Cordova
* and the required plugin are installed.
*/
export function CordovaFunctionOverride(opts: any = {}) {
return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => {
return {
value: function(...args: any[]) {
return overrideFunction(this, methodName, opts);
},
enumerable: true
};
};
}

View File

@ -0,0 +1,108 @@
import { callCordovaPlugin, wrapInstance, wrapPromise } from './common';
import 'rxjs/add/observable/of';
declare const window: any;
class MockPlugin {
static getPluginRef(): string {
return 'mockPlugin';
}
static getPluginName(): string {
return 'MockPlugin';
}
static getPluginInstallName(): string {
return '';
}
create(): MockInstancePluginObject {
return new MockInstancePluginObject();
}
}
class MockInstancePluginObject {
_pluginInstance: MockCordovaPlugin;
constructor() {
this._pluginInstance = new MockCordovaPlugin();
}
}
class MockCordovaPlugin {
static ping = jest.fn((arg: string) => 'pong');
ping = jest.fn((arg: string) => 'pong');
static pingAsync = jest.fn((arg: string, success: Function, error: Function) => success('pong'));
pingAsync = jest.fn((arg: string, success: Function, error: Function) => success('pong'));
}
describe('Common decorator functions', () => {
let plugin: MockPlugin,
instancePluginObject: MockInstancePluginObject;
beforeAll(() => {
window.mockPlugin = MockCordovaPlugin;
plugin = new MockPlugin();
instancePluginObject = plugin.create();
});
describe('callCordovaPlugin', () => {
test('should return value from cordova plugin', () => {
expect(callCordovaPlugin(plugin, 'ping', ['pingpong'])).toBe('pong');
});
test('original method should have been called', () => {
expect(MockCordovaPlugin.ping.mock.calls.length).toBe(1);
});
test('original method should have received args', () => {
expect(MockCordovaPlugin.ping.mock.calls[0][0]).toBe('pingpong');
});
});
describe('wrapPromise', () => {
test('should return a promise that resolves with a value', async () => {
expect(await wrapPromise(plugin, 'pingAsync', ['pingpong'])).toBe('pong');
});
test('original method should have been called', () => {
expect(MockCordovaPlugin.pingAsync.mock.calls.length).toBe(1);
});
test('original method should have received args', () => {
expect(MockCordovaPlugin.pingAsync.mock.calls[0][0]).toBe('pingpong');
expect(typeof MockCordovaPlugin.pingAsync.mock.calls[0][1]).toBe('function');
expect(typeof MockCordovaPlugin.pingAsync.mock.calls[0][2]).toBe('function');
});
});
describe('wrapObservable', () => {
test('should return an observable that emits a value', async () => {
});
test('original method should have been called', () => {});
test('original method should have received args', () => {});
});
describe('wrapEventObservable', () => {
test('should return an observable that wraps an event listener', async () => {});
});
describe('callInstance', () => {
test('should call an instance method', async () => {
});
test('original method should have been called', () => {
// expect(instancePluginObject._pluginInstance.ping.mock.calls.length).toBe(1);
});
test('original method should have received args', () => {
// expect(instancePluginObject._pluginInstance.ping.mock.calls[0][0]).toBe('pingpong');
});
});
});

View File

@ -1,139 +1,25 @@
import { getPlugin, getPromise, cordovaWarn, pluginWarn } from './util'; import { CordovaOptions } from './interfaces';
import { checkReady } from './bootstrap';
import { CordovaOptions } from './decorators';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent'; import 'rxjs/add/observable/fromEvent';
checkReady();
// declare const window;
// declare var Promise;
export const ERR_CORDOVA_NOT_AVAILABLE = { error: 'cordova_not_available' }; export const ERR_CORDOVA_NOT_AVAILABLE = { error: 'cordova_not_available' };
export const ERR_PLUGIN_NOT_INSTALLED = { error: 'plugin_not_installed' }; export const ERR_PLUGIN_NOT_INSTALLED = { error: 'plugin_not_installed' };
export function getPromise(callback: Function) {
/** const tryNativePromise = () => {
* Checks if plugin/cordova is available if (Promise) {
* @return {boolean | { error: string } } return new Promise((resolve, reject) => {
* @private callback(resolve, reject);
*/
export function checkAvailability(pluginRef: string, methodName?: string, pluginName?: string): boolean | { error: string };
export function checkAvailability(pluginObj: any, methodName?: string, pluginName?: string): boolean | { error: string };
export function checkAvailability(plugin: any, methodName?: string, pluginName?: string): boolean | { error: string } {
let pluginRef, pluginInstance, pluginPackage;
if (typeof plugin === 'string') {
pluginRef = plugin;
} else {
pluginRef = plugin.constructor.getPluginRef();
pluginName = plugin.constructor.getPluginName();
pluginPackage = plugin.constructor.getPluginInstallName();
}
pluginInstance = getPlugin(pluginRef);
if (!pluginInstance || (!!methodName && typeof pluginInstance[methodName] === 'undefined')) {
if (!window.cordova) {
cordovaWarn(pluginName, methodName);
return ERR_CORDOVA_NOT_AVAILABLE;
}
pluginWarn(pluginName, pluginPackage, methodName);
return ERR_PLUGIN_NOT_INSTALLED;
}
return true;
}
/**
* Checks if _objectInstance exists and has the method/property
* @private
*/
export function instanceAvailability(pluginObj: any, methodName?: string): boolean {
return pluginObj._objectInstance && (!methodName || typeof pluginObj._objectInstance[methodName] !== 'undefined');
}
function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
// ignore resolve and reject in case sync
if (opts.sync) {
return args;
}
// If the plugin method expects myMethod(success, err, options)
if (opts.callbackOrder === 'reverse') {
// Get those arguments in the order [resolve, reject, ...restOfArgs]
args.unshift(reject);
args.unshift(resolve);
} else if (opts.callbackStyle === 'node') {
args.push((err: any, result: any) => {
if (err) {
reject(err);
} else {
resolve(result);
}
}); });
} else if (opts.callbackStyle === 'object' && opts.successName && opts.errorName) {
let obj: any = {};
obj[opts.successName] = resolve;
obj[opts.errorName] = reject;
args.push(obj);
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
const setSuccessIndex = () => {
// If we've specified a success/error index
if (opts.successIndex > args.length) {
args[opts.successIndex] = resolve;
} else { } else {
args.splice(opts.successIndex, 0, resolve); console.error('No Promise support or polyfill found. To enable Ionic Native support, please add the es6-promise polyfill before this script, or run with a library like Angular or on a recent browser.');
} }
}; };
const setErrorIndex = () => { return tryNativePromise();
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour.
if (opts.errorIndex > args.length) {
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
} else {
args.splice(opts.errorIndex, 0, reject); // otherwise just splice it into the array
}
};
if (opts.successIndex > opts.errorIndex) {
setErrorIndex();
setSuccessIndex();
} else {
setSuccessIndex();
setErrorIndex();
}
} else {
// Otherwise, let's tack them on to the end of the argument list
// which is 90% of cases
args.push(resolve);
args.push(reject);
}
return args;
} }
function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts: any = {}, resolve?: Function, reject?: Function) { export function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: CordovaOptions = {}) {
// Try to figure out where the success/error callbacks need to be bound
// to our promise resolve/reject handlers.
args = setIndex(args, opts, resolve, reject);
const availabilityCheck = checkAvailability(pluginObj, methodName);
if (availabilityCheck === true) {
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
return pluginInstance[methodName].apply(pluginInstance, args);
} else {
return availabilityCheck;
}
}
function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any = {}) {
let pluginResult: any, rej: Function; let pluginResult: any, rej: Function;
const p = getPromise((resolve: Function, reject: Function) => { const p = getPromise((resolve: Function, reject: Function) => {
if (opts.destruct) { if (opts.destruct) {
@ -198,7 +84,143 @@ function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: a
}); });
} }
function callInstance(pluginObj: any, methodName: string, args: any[], opts: any = {}, resolve?: Function, reject?: Function) { /**
* Wrap the event with an observable
* @private
* @param event even name
* @param element The element to attach the event listener to
* @returns {Observable}
*/
function wrapEventObservable(event: string, element: any): Observable<any> {
if (element) {
get(window, element);
} else {
element = window;
}
return Observable.fromEvent(element, event);
}
/**
* Checks if plugin/cordova is available
* @return {boolean | { error: string } }
* @private
*/
export function checkAvailability(pluginRef: string, methodName?: string, pluginName?: string): boolean | { error: string };
export function checkAvailability(pluginObj: any, methodName?: string, pluginName?: string): boolean | { error: string };
export function checkAvailability(plugin: any, methodName?: string, pluginName?: string): boolean | { error: string } {
let pluginRef, pluginInstance, pluginPackage;
if (typeof plugin === 'string') {
pluginRef = plugin;
} else {
pluginRef = plugin.constructor.getPluginRef();
pluginName = plugin.constructor.getPluginName();
pluginPackage = plugin.constructor.getPluginInstallName();
}
pluginInstance = getPlugin(pluginRef);
if (!pluginInstance || (!!methodName && typeof pluginInstance[methodName] === 'undefined')) {
if (!window.cordova) {
cordovaWarn(pluginName, methodName);
return ERR_CORDOVA_NOT_AVAILABLE;
}
pluginWarn(pluginName, pluginPackage, methodName);
return ERR_PLUGIN_NOT_INSTALLED;
}
return true;
}
/**
* Checks if _objectInstance exists and has the method/property
* @private
*/
export function instanceAvailability(pluginObj: any, methodName?: string): boolean {
return pluginObj._objectInstance && (!methodName || typeof pluginObj._objectInstance[methodName] !== 'undefined');
}
export function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
// ignore resolve and reject in case sync
if (opts.sync) {
return args;
}
// If the plugin method expects myMethod(success, err, options)
if (opts.callbackOrder === 'reverse') {
// Get those arguments in the order [resolve, reject, ...restOfArgs]
args.unshift(reject);
args.unshift(resolve);
} else if (opts.callbackStyle === 'node') {
args.push((err: any, result: any) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
} else if (opts.callbackStyle === 'object' && opts.successName && opts.errorName) {
let obj: any = {};
obj[opts.successName] = resolve;
obj[opts.errorName] = reject;
args.push(obj);
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
const setSuccessIndex = () => {
// If we've specified a success/error index
if (opts.successIndex > args.length) {
args[opts.successIndex] = resolve;
} else {
args.splice(opts.successIndex, 0, resolve);
}
};
const setErrorIndex = () => {
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour.
if (opts.errorIndex > args.length) {
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
} else {
args.splice(opts.errorIndex, 0, reject); // otherwise just splice it into the array
}
};
if (opts.successIndex > opts.errorIndex) {
setErrorIndex();
setSuccessIndex();
} else {
setSuccessIndex();
setErrorIndex();
}
} else {
// Otherwise, let's tack them on to the end of the argument list
// which is 90% of cases
args.push(resolve);
args.push(reject);
}
return args;
}
export function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts: any = {}, resolve?: Function, reject?: Function) {
// Try to figure out where the success/error callbacks need to be bound
// to our promise resolve/reject handlers.
args = setIndex(args, opts, resolve, reject);
const availabilityCheck = checkAvailability(pluginObj, methodName);
if (availabilityCheck === true) {
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
return pluginInstance[methodName].apply(pluginInstance, args);
} else {
return availabilityCheck;
}
}
export function callInstance(pluginObj: any, methodName: string, args: any[], opts: any = {}, resolve?: Function, reject?: Function) {
args = setIndex(args, opts, resolve, reject); args = setIndex(args, opts, resolve, reject);
@ -208,42 +230,43 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any
} }
/** export function getPlugin(pluginRef: string): any {
* Wrap the event with an observable return get(window, pluginRef);
* @private
* @param event even name
* @param element The element to attach the event listener to
* @returns {Observable}
*/
export function wrapEventObservable(event: string, element: any = window): Observable<any> {
return Observable.fromEvent(element, event);
} }
/** export function get(element: Element | Window, path: string) {
* Certain plugins expect the user to override methods in the plugin. For example, const paths: string[] = path.split('.');
* window.cordova.plugins.backgroundMode.onactivate = function() { ... }. let obj: any = element;
* for (let i: number = 0; i < paths.length; i++) {
* Unfortunately, this is brittle and would be better wrapped as an Observable. overrideFunction if (!obj) { return null; }
* does just this. obj = obj[paths[i]];
* @private
*/
export function overrideFunction(pluginObj: any, methodName: string, args: any[], opts: any = {}): Observable<any> {
return new Observable(observer => {
const availabilityCheck = checkAvailability(pluginObj, methodName);
if (availabilityCheck === true) {
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
pluginInstance[methodName] = observer.next.bind(observer);
return () => pluginInstance[methodName] = () => { };
} else {
observer.error(availabilityCheck);
observer.complete();
} }
return obj;
});
} }
export function pluginWarn(pluginName: string, plugin?: string, method?: string): void {
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
}
if (plugin) {
console.warn('Install the ' + pluginName + ' plugin: \'ionic cordova plugin add ' + plugin + '\'');
}
}
/**
* @private
* @param pluginName
* @param method
*/
export function cordovaWarn(pluginName: string, method?: string): void {
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
}
}
/** /**
* @private * @private
@ -288,7 +311,6 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {})
if (pluginResult && pluginResult.error) { if (pluginResult && pluginResult.error) {
observer.error(pluginResult.error); observer.error(pluginResult.error);
observer.complete();
} }
return () => { return () => {

View File

@ -0,0 +1,23 @@
import { checkAvailability, getPlugin } from './common';
import { Observable } from 'rxjs/Observable';
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
return new Observable(observer => {
const availabilityCheck = checkAvailability(pluginObj, methodName);
if (availabilityCheck === true) {
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
pluginInstance[methodName] = observer.next.bind(observer);
return () => pluginInstance[methodName] = () => { };
} else {
observer.error(availabilityCheck);
observer.complete();
}
});
}
export function cordovaFunctionOverride(pluginObj: any, methodName: string, args: IArguments | Array<any> = []) {
return overrideFunction(pluginObj, methodName);
}

View File

@ -0,0 +1,7 @@
import { CordovaOptions } from './interfaces';
import { wrapInstance } from './common';
export function cordovaInstance(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
args = Array.from(args);
return wrapInstance(pluginObj, methodName, config).apply(this, args);
}

View File

@ -0,0 +1,14 @@
import { checkAvailability, getPlugin } from './common';
export function cordovaPropertyGet(pluginObj: any, key: string) {
if (checkAvailability(pluginObj, key) === true) {
return getPlugin(pluginObj.constructor.getPluginRef())[key];
}
return null;
}
export function cordovaPropertySet(pluginObj: any, key: string, value: any) {
if (checkAvailability(pluginObj, key) === true) {
getPlugin(pluginObj.constructor.getPluginRef())[key] = value;
}
}

View File

@ -0,0 +1,6 @@
import { CordovaOptions } from './interfaces';
import { wrap } from './common';
export function cordova(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
return wrap(pluginObj, methodName, config).apply(this, args);
}

View File

@ -0,0 +1,12 @@
export function instancePropertyGet(pluginObj: any, key: string) {
if (!!pluginObj._objectInstance && !!pluginObj._objectInstance[key]) {
return pluginObj._objectInstance[key];
}
return null;
}
export function instancePropertySet(pluginObj: any, key: string, value: any) {
if (!!pluginObj._objectInstance && !!pluginObj._objectInstance[key]) {
pluginObj._objectInstance[key] = value;
}
}

View File

@ -0,0 +1,105 @@
export interface PluginConfig {
/**
* Plugin name, this should match the class name
*/
pluginName: string;
/**
* Plugin NPM package name
*/
plugin: string;
/**
* Plugin object reference
*/
pluginRef?: string;
/**
* Github repository URL
*/
repo?: string;
/**
* Custom install command
*/
install?: string;
/**
* Available installation variables
*/
installVariables?: string[];
/**
* Supported platforms
*/
platforms?: string[];
[key: string]: any;
}
export interface CordovaOptions {
destruct?: boolean;
/**
* Set to true if the wrapped method is a sync function
*/
sync?: boolean;
/**
* Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method takes.
*/
callbackOrder?: 'reverse';
/**
* Callback style
*/
callbackStyle?: 'node' | 'object';
/**
* Set a custom index for the success callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
successIndex?: number;
/**
* Set a custom index for the error callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
errorIndex?: number;
/**
* Success function property name. This must be set if callbackStyle is set to object.
*/
successName?: string;
/**
* Error function property name. This must be set if callbackStyle is set to object.
*/
errorName?: string;
/**
* Set to true to return an observable
*/
observable?: boolean;
/**
* If observable is set to true, this can be set to a different function name that will cancel the observable.
*/
clearFunction?: string;
/**
* This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
*/
clearWithArgs?: boolean;
/**
* Creates an observable that wraps a global event. Replaces document.addEventListener
*/
eventObservable?: boolean;
/**
* Event name, this must be set if eventObservable is set to true
*/
event?: string;
/**
* Element to attach the event listener to, this is optional, defaults to `window`
*/
element?: any;
/**
* Set to true if the wrapped method returns a promise
*/
otherPromise?: boolean;
/**
* Supported platforms
*/
platforms?: string[];
}
export declare const Plugin: (config: PluginConfig) => ClassDecorator;
export declare const Cordova: (config?: CordovaOptions) => MethodDecorator;
export declare const CordovaProperty: () => PropertyDecorator;
export declare const CordovaInstance: (config?: CordovaOptions) => MethodDecorator;
export declare const InstanceProperty: () => PropertyDecorator;
export declare const CordovaCheck: (config?: CordovaOptions) => MethodDecorator;
export declare const InstanceCheck: (config?: CordovaOptions) => MethodDecorator;
export declare const CordovaFunctionOverride: () => MethodDecorator;

View File

@ -1,4 +1,14 @@
export * from './plugin'; import { checkReady } from './bootstrap';
export * from './decorators';
export * from './util'; export { IonicNativePlugin } from './ionic-native-plugin';
export * from './ionic-native-plugin';
// Decorators
export { checkAvailability, instanceAvailability, wrap, getPromise } from './decorators/common';
export * from './decorators/cordova';
export * from './decorators/cordova-function-override';
export * from './decorators/cordova-instance';
export * from './decorators/cordova-property';
export * from './decorators/instance-property';
export * from './decorators/interfaces';
checkReady();

View File

@ -1,69 +0,0 @@
// This is to verify that new (FileTransfer.getPlugin)() works
import { Plugin, CordovaInstance } from './decorators';
import { checkAvailability } from './plugin';
import { IonicNativePlugin } from './ionic-native-plugin';
class FT {
hello(): string {
return 'world';
}
}
(window as any).FileTransfer = () => new FT();
@Plugin({
plugin: 'cordova-plugin-file-transfer',
pluginRef: 'FileTransfer',
repo: '',
pluginName: 'FileTransfer'
})
export class FileTransfer extends IonicNativePlugin {
create(): FileTransferObject {
let instance: any;
if (checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) {
instance = new (FileTransfer.getPlugin())();
}
return new FileTransferObject(instance);
}
}
export class FileTransferObject {
constructor(public _objectInstance: any) {
console.info('Creating a new FileTransferObject with instance: ', _objectInstance);
}
@CordovaInstance({ sync: true })
hello(): string { return; }
}
describe('Mock FileTransfer Plugin', () => {
let plugin: FileTransfer,
instance: FileTransferObject;
beforeAll(() => {
plugin = new FileTransfer();
instance = plugin.create();
});
it('should create a new FileTransfer plugin instance', () => {
expect(plugin instanceof FileTransfer).toBeTruthy();
});
it('should create new FileTransferObject instance', () => {
expect(instance instanceof FileTransferObject).toBeTruthy();
});
it('FileTransferObject instance should have _objectInstance property', () => {
expect(instance._objectInstance).toBeDefined();
});
it('FileTransferObject.hello should return world', () => {
console.info('instance hello is', instance.hello());
expect(instance.hello()).toEqual('world');
});
});

View File

@ -1,3 +1,6 @@
import { checkAvailability } from './decorators/common';
import { get } from './util';
export class IonicNativePlugin { export class IonicNativePlugin {
static pluginName: string; static pluginName: string;
@ -16,31 +19,31 @@ export class IonicNativePlugin {
* Returns a boolean that indicates whether the plugin is installed * Returns a boolean that indicates whether the plugin is installed
* @return {boolean} * @return {boolean}
*/ */
static installed(): boolean { return false; } static installed(): boolean { return checkAvailability(this.pluginRef) === true; }
/** /**
* Returns the original plugin object * Returns the original plugin object
*/ */
static getPlugin(): any { } static getPlugin(): any { return get(window, this.pluginRef); }
/** /**
* Returns the plugin's name * Returns the plugin's name
*/ */
static getPluginName(): string { return; } static getPluginName(): string { return this.pluginName; }
/** /**
* Returns the plugin's reference * Returns the plugin's reference
*/ */
static getPluginRef(): string { return; } static getPluginRef(): string { return this.pluginRef; }
/** /**
* Returns the plugin's install name * Returns the plugin's install name
*/ */
static getPluginInstallName(): string { return; } static getPluginInstallName(): string { return this.plugin; }
/** /**
* Returns the plugin's supported platforms * Returns the plugin's supported platforms
*/ */
static getSupportedPlatforms(): string[] { return; } static getSupportedPlatforms(): string[] { return this.platforms || []; }
} }

View File

@ -0,0 +1,25 @@
declare const window: any;
/**
* Initialize the ionic.native Angular module if we're running in ng1.
* This iterates through the list of registered plugins and dynamically
* creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovaStatusBar.
*/
export function initAngular1(plugins: any) {
if (window.angular) {
const ngModule = window.angular.module('ionic.native', []);
for (const name in plugins) {
let serviceName = '$cordova' + name;
let cls = plugins[name];
(function(serviceName, cls, name) {
ngModule.service(serviceName, [function() {
const funcs = window.angular.copy(cls);
funcs.__proto__['name'] = name;
return funcs;
}]);
})(serviceName, cls, name);
}
}
}

View File

@ -3,7 +3,7 @@ declare const window: any;
/** /**
* @private * @private
*/ */
export const get = (element: Element | Window, path: string): any => { export function get(element: Element | Window, path: string) {
const paths: string[] = path.split('.'); const paths: string[] = path.split('.');
let obj: any = element; let obj: any = element;
for (let i: number = 0; i < paths.length; i++) { for (let i: number = 0; i < paths.length; i++) {
@ -11,17 +11,17 @@ export const get = (element: Element | Window, path: string): any => {
obj = obj[paths[i]]; obj = obj[paths[i]];
} }
return obj; return obj;
}; }
/** /**
* @private * @private
*/ */
export const getPromise = (callback: Function): Promise<any> => { export function getPromise(callback: Function = () => {}): Promise<any> {
const tryNativePromise = () => { const tryNativePromise = () => {
if (window.Promise) { if (window.Promise) {
return new Promise((resolve, reject) => { return new Promise<any>((resolve, reject) => {
callback(resolve, reject); callback(resolve, reject);
}); });
} else { } else {
@ -30,40 +30,4 @@ export const getPromise = (callback: Function): Promise<any> => {
}; };
return tryNativePromise(); return tryNativePromise();
}; }
/**
* @private
* @param pluginRef
* @returns {null|*}
*/
export const getPlugin = (pluginRef: string): any => {
return get(window, pluginRef);
};
/**
* @private
*/
export const pluginWarn = (pluginName: string, plugin?: string, method?: string): void => {
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
}
if (plugin) {
console.warn('Install the ' + pluginName + ' plugin: \'ionic cordova plugin add ' + plugin + '\'');
}
};
/**
* @private
* @param pluginName
* @param method
*/
export const cordovaWarn = (pluginName: string, method?: string): void => {
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
}
};

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface ActionSheetOptions { export interface ActionSheetOptions {
@ -80,7 +80,7 @@ export interface ActionSheetOptions {
* addDestructiveButtonWithLabel: 'Delete', * addDestructiveButtonWithLabel: 'Delete',
* androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK, * androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK,
* destructiveButtonLast: true * destructiveButtonLast: true
* }; * }
* *
* this.actionSheet.show(options).then((buttonIndex: number) => { * this.actionSheet.show(options).then((buttonIndex: number) => {
* console.log('Button pressed: ' + buttonIndex); * console.log('Button pressed: ' + buttonIndex);
@ -123,7 +123,9 @@ export class ActionSheet extends IonicNativePlugin {
* button pressed (1 based, so 1, 2, 3, etc.) * button pressed (1 based, so 1, 2, 3, etc.)
*/ */
@Cordova() @Cordova()
show(options?: ActionSheetOptions): Promise<any> { return; } show(options?: ActionSheetOptions): Promise<any> {
return;
}
/** /**
@ -131,5 +133,7 @@ export class ActionSheet extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves when the actionsheet is closed * @returns {Promise<any>} Returns a Promise that resolves when the actionsheet is closed
*/ */
@Cordova() @Cordova()
hide(options?: any): Promise<any> { return; } hide(options?: any): Promise<any> {
return;
}
} }

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent'; import 'rxjs/add/observable/fromEvent';
@ -64,6 +64,162 @@ export interface AdMobFreeRewardVideoConfig {
autoShow?: boolean; autoShow?: boolean;
} }
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.banner',
})
export class AdMobFreeBanner {
/**
* Update config.
* @param options
* @return {AdMobFreeBannerConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeBannerConfig): AdMobFreeBannerConfig {
return;
}
/**
* Hide the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
hide(): Promise<any> {
return;
}
/**
* Create banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> {
return;
}
/**
* Remove the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
remove(): Promise<any> {
return;
}
/**
* Show the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> {
return;
}
}
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.interstitial',
})
export class AdMobFreeInterstitial {
/**
* Update config.
* @param options
* @return {AdMobFreeInterstitialConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeInterstitialConfig): AdMobFreeInterstitialConfig {
return;
}
/**
* Check if interstitial is ready
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
isReady(): Promise<any> {
return;
}
/**
* Prepare interstitial
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> {
return;
}
/**
* Show the interstitial
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> {
return;
}
}
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.rewardvideo',
})
export class AdMobFreeRewardVideo {
/**
* Update config.
* @param options
* @return {AdMobFreeRewardVideoConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeRewardVideoConfig): AdMobFreeRewardVideoConfig {
return;
}
/**
* Check if reward video is ready
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
isReady(): Promise<any> {
return;
}
/**
* Prepare reward video
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> {
return;
}
/**
* Show the reward video
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> {
return;
}
}
/** /**
* @name AdMob Free * @name AdMob Free
* @description * @description
@ -84,7 +240,7 @@ export interface AdMobFreeRewardVideoConfig {
* // for the sake of this example we will just use the test config * // for the sake of this example we will just use the test config
* isTesting: true, * isTesting: true,
* autoShow: true * autoShow: true
* }; * }
* this.admobFree.banner.config(bannerConfig); * this.admobFree.banner.config(bannerConfig);
* *
* this.admobFree.banner.prepare() * this.admobFree.banner.prepare()
@ -140,6 +296,21 @@ export class AdMobFree extends IonicNativePlugin {
REWARD_VIDEO_START: 'admob.rewardvideo.events.START', REWARD_VIDEO_START: 'admob.rewardvideo.events.START',
REWARD_VIDEO_REWARD: 'admob.rewardvideo.events.REWARD' REWARD_VIDEO_REWARD: 'admob.rewardvideo.events.REWARD'
}; };
/**
* Returns the AdMobFreeBanner object
* @type {AdMobFreeBanner}
*/
banner: AdMobFreeBanner = new AdMobFreeBanner();
/**
* Returns the AdMobFreeInterstitial object
* @type {AdMobFreeInterstitial}
*/
interstitial: AdMobFreeInterstitial = new AdMobFreeInterstitial();
/**
* Returns the AdMobFreeRewardVideo object
* @type {AdMobFreeRewardVideo}
*/
rewardVideo: AdMobFreeRewardVideo = new AdMobFreeRewardVideo();
/** /**
* Watch an event * Watch an event
@ -150,152 +321,4 @@ export class AdMobFree extends IonicNativePlugin {
return Observable.fromEvent(document, event); return Observable.fromEvent(document, event);
} }
/**
* Returns the AdMobFreeBanner object
* @type {AdMobFreeBanner}
*/
banner: AdMobFreeBanner = new AdMobFreeBanner();
/**
* Returns the AdMobFreeInterstitial object
* @type {AdMobFreeInterstitial}
*/
interstitial: AdMobFreeInterstitial = new AdMobFreeInterstitial();
/**
* Returns the AdMobFreeRewardVideo object
* @type {AdMobFreeRewardVideo}
*/
rewardVideo: AdMobFreeRewardVideo = new AdMobFreeRewardVideo();
}
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.banner',
})
export class AdMobFreeBanner {
/**
* Update config.
* @param options
* @return {AdMobFreeBannerConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeBannerConfig): AdMobFreeBannerConfig { return; }
/**
* Hide the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
hide(): Promise<any> { return; }
/**
* Create banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> { return; }
/**
* Remove the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
remove(): Promise<any> { return; }
/**
* Show the banner.
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> { return; }
}
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.interstitial',
})
export class AdMobFreeInterstitial {
/**
* Update config.
* @param options
* @return {AdMobFreeInterstitialConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeInterstitialConfig): AdMobFreeInterstitialConfig { return; }
/**
* Check if interstitial is ready
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
isReady(): Promise<any> { return; }
/**
* Prepare interstitial
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> { return; }
/**
* Show the interstitial
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> { return; }
}
/**
* @hidden
*/
@Plugin({
pluginName: 'AdMobFree',
plugin: 'cordova-plugin-admob-free',
pluginRef: 'admob.rewardvideo',
})
export class AdMobFreeRewardVideo {
/**
* Update config.
* @param options
* @return {AdMobFreeRewardVideoConfig}
*/
@Cordova({ sync: true })
config(options: AdMobFreeRewardVideoConfig): AdMobFreeRewardVideoConfig { return; }
/**
* Check if reward video is ready
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
isReady(): Promise<any> { return; }
/**
* Prepare reward video
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
prepare(): Promise<any> { return; }
/**
* Show the reward video
* @return {Promise<any>}
*/
@Cordova({ otherPromise: true })
show(): Promise<any> { return; }
} }

View File

@ -1,8 +1,15 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export type AdSize = 'SMART_BANNER' | 'BANNER' | 'MEDIUM_RECTANGLE' | 'FULL_BANNER' | 'LEADERBOARD' | 'SKYSCRAPER' | 'CUSTOM'; export type AdSize =
'SMART_BANNER'
| 'BANNER'
| 'MEDIUM_RECTANGLE'
| 'FULL_BANNER'
| 'LEADERBOARD'
| 'SKYSCRAPER'
| 'CUSTOM';
export interface AdMobOptions { export interface AdMobOptions {
@ -167,7 +174,9 @@ export class AdMobPro extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves when the banner is created * @returns {Promise<any>} Returns a Promise that resolves when the banner is created
*/ */
@Cordova() @Cordova()
createBanner(adIdOrOptions: string | AdMobOptions): Promise<any> { return; } createBanner(adIdOrOptions: string | AdMobOptions): Promise<any> {
return;
}
/** /**
* Destroy the banner, remove it from screen. * Destroy the banner, remove it from screen.
@ -175,7 +184,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
removeBanner(): void { } removeBanner(): void {
}
/** /**
* Show banner at position * Show banner at position
@ -184,7 +194,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
showBanner(position: number): void { } showBanner(position: number): void {
}
/** /**
* Show banner at custom position * Show banner at custom position
@ -194,7 +205,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
showBannerAtXY(x: number, y: number): void { } showBannerAtXY(x: number, y: number): void {
}
/** /**
* Hide the banner, remove it from screen, but can show it later * Hide the banner, remove it from screen, but can show it later
@ -202,7 +214,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
hideBanner(): void { } hideBanner(): void {
}
/** /**
* Prepare interstitial banner * Prepare interstitial banner
@ -210,7 +223,9 @@ export class AdMobPro extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves when interstitial is prepared * @returns {Promise<any>} Returns a Promise that resolves when interstitial is prepared
*/ */
@Cordova() @Cordova()
prepareInterstitial(adIdOrOptions: string | AdMobOptions): Promise<any> { return; } prepareInterstitial(adIdOrOptions: string | AdMobOptions): Promise<any> {
return;
}
/** /**
* Show interstitial ad when it's ready * Show interstitial ad when it's ready
@ -218,7 +233,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
showInterstitial(): void { } showInterstitial(): void {
}
/** /**
* Prepare a reward video ad * Prepare a reward video ad
@ -226,7 +242,9 @@ export class AdMobPro extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves when the ad is prepared * @returns {Promise<any>} Returns a Promise that resolves when the ad is prepared
*/ */
@Cordova() @Cordova()
prepareRewardVideoAd(adIdOrOptions: string | AdMobOptions): Promise<any> { return; } prepareRewardVideoAd(adIdOrOptions: string | AdMobOptions): Promise<any> {
return;
}
/** /**
* Show a reward video ad * Show a reward video ad
@ -234,7 +252,8 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
showRewardVideoAd(): void { } showRewardVideoAd(): void {
}
/** /**
* Sets the values for configuration and targeting * Sets the values for configuration and targeting
@ -242,14 +261,18 @@ export class AdMobPro extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves when the options have been set * @returns {Promise<any>} Returns a Promise that resolves when the options have been set
*/ */
@Cordova() @Cordova()
setOptions(options: AdMobOptions): Promise<any> { return; } setOptions(options: AdMobOptions): Promise<any> {
return;
}
/** /**
* Get user ad settings * Get user ad settings
* @returns {Promise<any>} Returns a promise that resolves with the ad settings * @returns {Promise<any>} Returns a promise that resolves with the ad settings
*/ */
@Cordova() @Cordova()
getAdSettings(): Promise<any> { return; } getAdSettings(): Promise<any> {
return;
}
/** /**
* Triggered when failed to receive Ad * Triggered when failed to receive Ad
@ -258,9 +281,11 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onAdFailLoad', event: 'onAdFailLoad',
element: document element: 'document'
}) })
onAdFailLoad(): Observable<any> { return; } onAdFailLoad(): Observable<any> {
return;
}
/** /**
* Triggered when Ad received * Triggered when Ad received
@ -269,9 +294,11 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onAdLoaded', event: 'onAdLoaded',
element: document element: 'document'
}) })
onAdLoaded(): Observable<any> { return; } onAdLoaded(): Observable<any> {
return;
}
/** /**
* Triggered when Ad will be showed on screen * Triggered when Ad will be showed on screen
@ -280,9 +307,11 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onAdPresent', event: 'onAdPresent',
element: document element: 'document'
}) })
onAdPresent(): Observable<any> { return; } onAdPresent(): Observable<any> {
return;
}
/** /**
* Triggered when user click the Ad, and will jump out of your App * Triggered when user click the Ad, and will jump out of your App
@ -291,9 +320,11 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onAdLeaveApp', event: 'onAdLeaveApp',
element: document element: 'document'
}) })
onAdLeaveApp(): Observable<any> { return; } onAdLeaveApp(): Observable<any> {
return;
}
/** /**
* Triggered when dismiss the Ad and back to your App * Triggered when dismiss the Ad and back to your App
@ -302,8 +333,10 @@ export class AdMobPro extends IonicNativePlugin {
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onAdDismiss', event: 'onAdDismiss',
element: document element: 'document'
}) })
onAdDismiss(): Observable<any> { return; } onAdDismiss(): Observable<any> {
return;
}
} }

View File

@ -1,8 +1,7 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
export interface AlipayOrder { export interface AlipayOrder {
/** /**
* appId assigned by Alipay * appId assigned by Alipay
@ -77,7 +76,7 @@ export interface AlipayOrder {
* // Should get from server side with sign. * // Should get from server side with sign.
* const alipayOrder: AlipayOrder = { * const alipayOrder: AlipayOrder = {
* ... * ...
* }; * }
* *
* *
* this.alipay.pay(alipayOrder) * this.alipay.pay(alipayOrder)
@ -113,5 +112,7 @@ export class Alipay extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves with the success return, or rejects with an error. * @returns {Promise<any>} Returns a Promise that resolves with the success return, or rejects with an error.
*/ */
@Cordova() @Cordova()
pay(order: AlipayOrder | string): Promise<any> { return; } pay(order: AlipayOrder | string): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export type AndroidExoPlayerAspectRatio = 'FILL_SCREEN' | 'FIT_SCREEN'; export type AndroidExoPlayerAspectRatio = 'FILL_SCREEN' | 'FIT_SCREEN';
@ -194,7 +194,9 @@ export class AndroidExoplayer extends IonicNativePlugin {
successIndex: 1, successIndex: 1,
errorIndex: 2 errorIndex: 2
}) })
show(parameters: AndroidExoPlayerParams): Observable<AndroidExoplayerState> { return; } show(parameters: AndroidExoPlayerParams): Observable<AndroidExoplayerState> {
return;
}
/** /**
* Switch stream without disposing of the player. * Switch stream without disposing of the player.
@ -203,21 +205,27 @@ export class AndroidExoplayer extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
setStream(url: string, controller: AndroidExoPlayerControllerConfig): Promise<void> { return; } setStream(url: string, controller: AndroidExoPlayerControllerConfig): Promise<void> {
return;
}
/** /**
* Will pause if playing and play if paused * Will pause if playing and play if paused
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
playPause(): Promise<void> { return; } playPause(): Promise<void> {
return;
}
/** /**
* Stop playing. * Stop playing.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
stop(): Promise<void> { return; } stop(): Promise<void> {
return;
}
/** /**
* Jump to a particular position. * Jump to a particular position.
@ -225,7 +233,9 @@ export class AndroidExoplayer extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
seekTo(milliseconds: number): Promise<void> { return; } seekTo(milliseconds: number): Promise<void> {
return;
}
/** /**
* Jump to a particular time relative to the current position. * Jump to a particular time relative to the current position.
@ -233,28 +243,36 @@ export class AndroidExoplayer extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
seekBy(milliseconds: number): Promise<void> { return; } seekBy(milliseconds: number): Promise<void> {
return;
}
/** /**
* Get the current player state. * Get the current player state.
* @return {Promise<AndroidExoplayerState>} * @return {Promise<AndroidExoplayerState>}
*/ */
@Cordova() @Cordova()
getState(): Promise<AndroidExoplayerState> { return; } getState(): Promise<AndroidExoplayerState> {
return;
}
/** /**
* Show the controller. * Show the controller.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
showController(): Promise<void> { return; } showController(): Promise<void> {
return;
}
/** /**
* Hide the controller. * Hide the controller.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
hideController(): Promise<void> { return; } hideController(): Promise<void> {
return;
}
/** /**
* Update the controller configuration. * Update the controller configuration.
@ -262,12 +280,16 @@ export class AndroidExoplayer extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
setController(controller: AndroidExoPlayerControllerConfig): Promise<void> { return; } setController(controller: AndroidExoPlayerControllerConfig): Promise<void> {
return;
}
/** /**
* Close and dispose of player, call before destroy. * Close and dispose of player, call before destroy.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
close(): Promise<void> { return; } close(): Promise<void> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface AFAAuthOptions { export interface AFAAuthOptions {
@ -177,7 +177,9 @@ export class AndroidFingerprintAuth extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
encrypt(options: AFAAuthOptions): Promise<AFAEncryptResponse> { return; } encrypt(options: AFAAuthOptions): Promise<AFAEncryptResponse> {
return;
}
/** /**
* Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device. * Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
@ -185,19 +187,25 @@ export class AndroidFingerprintAuth extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
decrypt(options: AFAAuthOptions): Promise<AFADecryptOptions> { return; } decrypt(options: AFAAuthOptions): Promise<AFADecryptOptions> {
return;
}
/** /**
* Check if service is available * Check if service is available
* @returns {Promise<any>} Returns a Promise that resolves if fingerprint auth is available on the device * @returns {Promise<any>} Returns a Promise that resolves if fingerprint auth is available on the device
*/ */
@Cordova() @Cordova()
isAvailable(): Promise<{ isAvailable: boolean, isHardwareDetected: boolean, hasEnrolledFingerprints: boolean }> { return; } isAvailable(): Promise<{ isAvailable: boolean, isHardwareDetected: boolean, hasEnrolledFingerprints: boolean }> {
return;
}
/** /**
* Delete the cipher used for encryption and decryption by username * Delete the cipher used for encryption and decryption by username
* @returns {Promise<any>} Returns a Promise that resolves if the cipher was successfully deleted * @returns {Promise<any>} Returns a Promise that resolves if the cipher was successfully deleted
*/ */
@Cordova() @Cordova()
delete(options: { clientId: string; username: string; }): Promise<{ deleted: boolean }> { return; } delete(options: { clientId: string; username: string; }): Promise<{ deleted: boolean }> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
* Bit flag values for setSystemUiVisibility() * Bit flag values for setSystemUiVisibility()
@ -64,63 +64,81 @@ export class AndroidFullScreen extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
isSupported(): Promise<void> { return; } isSupported(): Promise<void> {
return;
}
/** /**
* Is immersive mode supported? * Is immersive mode supported?
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
isImmersiveModeSupported(): Promise<void> { return; } isImmersiveModeSupported(): Promise<void> {
return;
}
/** /**
* The width of the screen in immersive mode. * The width of the screen in immersive mode.
* @return {Promise<number>} * @return {Promise<number>}
*/ */
@Cordova() @Cordova()
immersiveWidth(): Promise<number> { return; } immersiveWidth(): Promise<number> {
return;
}
/** /**
* The height of the screen in immersive mode. * The height of the screen in immersive mode.
* @return {Promise<number>} * @return {Promise<number>}
*/ */
@Cordova() @Cordova()
immersiveHeight(): Promise<number> { return; } immersiveHeight(): Promise<number> {
return;
}
/** /**
* Hide system UI until user interacts. * Hide system UI until user interacts.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
leanMode(): Promise<void> { return; } leanMode(): Promise<void> {
return;
}
/** /**
* Show system UI. * Show system UI.
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
showSystemUI(): Promise<void> { return; } showSystemUI(): Promise<void> {
return;
}
/** /**
* Extend your app underneath the status bar (Android 4.4+ only). * Extend your app underneath the status bar (Android 4.4+ only).
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
showUnderStatusBar(): Promise<void> { return; } showUnderStatusBar(): Promise<void> {
return;
}
/** /**
* Extend your app underneath the system UI (Android 4.4+ only). * Extend your app underneath the system UI (Android 4.4+ only).
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
showUnderSystemUI(): Promise<void> { return; } showUnderSystemUI(): Promise<void> {
return;
}
/** /**
* Hide system UI and keep it hidden (Android 4.4+ only). * Hide system UI and keep it hidden (Android 4.4+ only).
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
immersiveMode(): Promise<void> { return; } immersiveMode(): Promise<void> {
return;
}
/** /**
* Manually set the the system UI to a custom mode. This mirrors the Android method of the same name. (Android 4.4+ only). * Manually set the the system UI to a custom mode. This mirrors the Android method of the same name. (Android 4.4+ only).
@ -129,5 +147,7 @@ export class AndroidFullScreen extends IonicNativePlugin {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
@Cordova() @Cordova()
setSystemUiVisibility(visibility: AndroidSystemUiFlags): Promise<void> { return; } setSystemUiVisibility(visibility: AndroidSystemUiFlags): Promise<void> {
return;
}
} }

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
/** /**
@ -199,7 +199,9 @@ export class AndroidPermissions extends IonicNativePlugin {
* @return {Promise<any>} Returns a promise * @return {Promise<any>} Returns a promise
*/ */
@Cordova() @Cordova()
checkPermission(permission: string): Promise<any> { return; } checkPermission(permission: string): Promise<any> {
return;
}
/** /**
* Request permission * Request permission
@ -207,7 +209,9 @@ export class AndroidPermissions extends IonicNativePlugin {
* @return {Promise<any>} * @return {Promise<any>}
*/ */
@Cordova() @Cordova()
requestPermission(permission: string): Promise<any> { return; } requestPermission(permission: string): Promise<any> {
return;
}
/** /**
* Request permissions * Request permissions
@ -215,7 +219,9 @@ export class AndroidPermissions extends IonicNativePlugin {
* @return {Promise<any>} Returns a promise * @return {Promise<any>} Returns a promise
*/ */
@Cordova() @Cordova()
requestPermissions(permissions: string[]): Promise<any> { return; } requestPermissions(permissions: string[]): Promise<any> {
return;
}
/** /**
* This function still works now, will not support in the future. * This function still works now, will not support in the future.
@ -223,6 +229,8 @@ export class AndroidPermissions extends IonicNativePlugin {
* @return {Promise<any>} Returns a promise * @return {Promise<any>} Returns a promise
*/ */
@Cordova() @Cordova()
hasPermission(permission: string): Promise<any> { return; } hasPermission(permission: string): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
* @name App Availability * @name App Availability
@ -48,6 +48,8 @@ export class AppAvailability extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
check(app: string): Promise<boolean> { return; } check(app: string): Promise<boolean> {
return;
}
} }

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
/** /**
@ -37,6 +37,8 @@ export class AppMinimize extends IonicNativePlugin {
* @return {Promise<any>} * @return {Promise<any>}
*/ */
@Cordova() @Cordova()
minimize(): Promise<any> { return; } minimize(): Promise<any> {
return;
}
} }

View File

@ -1,4 +1,4 @@
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@ -40,7 +40,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
fetch(dict: string, key?: string): Promise<any> { return; } fetch(dict: string, key?: string): Promise<any> {
return;
}
/** /**
* Set a preference value * Set a preference value
@ -67,7 +69,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
remove(dict: string, key?: string): Promise<any> { return; } remove(dict: string, key?: string): Promise<any> {
return;
}
/** /**
* Clear preferences * Clear preferences
@ -77,7 +81,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
clearAll(): Promise<any> { return; } clearAll(): Promise<any> {
return;
}
/** /**
* Show native preferences interface * Show native preferences interface
@ -87,7 +93,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
show(): Promise<any> { return; } show(): Promise<any> {
return;
}
/** /**
* Show native preferences interface * Show native preferences interface
@ -98,7 +106,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
observable: true observable: true
}) })
watch(subscribe: boolean): Observable<any> { return; } watch(subscribe: boolean): Observable<any> {
return;
}
/** /**
* Return named configuration context * Return named configuration context
@ -111,13 +121,17 @@ export class AppPreferences extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
suite(suiteName: string): any { return; } suite(suiteName: string): any {
return;
}
@Cordova({ @Cordova({
platforms: ['iOS'], platforms: ['iOS'],
sync: true sync: true
}) })
iosSuite(suiteName: string): any { return; } iosSuite(suiteName: string): any {
return;
}
/** /**
* Return cloud synchronized configuration context * Return cloud synchronized configuration context
@ -127,7 +141,9 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS', 'Windows', 'Windows Phone 8'] platforms: ['iOS', 'Windows', 'Windows Phone 8']
}) })
cloudSync(): Object { return; } cloudSync(): Object {
return;
}
/** /**
* Return default configuration context * Return default configuration context
@ -137,6 +153,8 @@ export class AppPreferences extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS', 'Windows', 'Windows Phone 8'] platforms: ['iOS', 'Windows', 'Windows Phone 8']
}) })
defaults(): Object { return; } defaults(): Object {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, CordovaProperty, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, CordovaProperty, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface AppRatePreferences { export interface AppRatePreferences {
@ -121,7 +121,7 @@ export interface AppUrls {
* ios: '<app_id>', * ios: '<app_id>',
* android: 'market://details?id=<package_name>', * android: 'market://details?id=<package_name>',
* windows: 'ms-windows-store://review/?ProductId=<store_id>' * windows: 'ms-windows-store://review/?ProductId=<store_id>'
* }; * }
* *
* this.appRate.promptForRating(true); * this.appRate.promptForRating(true);
* *
@ -133,7 +133,7 @@ export interface AppUrls {
* android: 'market://details?id=<package_name>', * android: 'market://details?id=<package_name>',
* windows: 'ms-windows-store://review/?ProductId=<store_id>' * windows: 'ms-windows-store://review/?ProductId=<store_id>'
* } * }
* }; * }
* *
* this.appRate.promptForRating(false); * this.appRate.promptForRating(false);
* ``` * ```
@ -158,7 +158,7 @@ export class AppRate extends IonicNativePlugin {
* Configure various settings for the Rating View. * Configure various settings for the Rating View.
* See table below for options * See table below for options
*/ */
@CordovaProperty @CordovaProperty()
preferences: AppRatePreferences; preferences: AppRatePreferences;
/** /**
@ -166,12 +166,14 @@ export class AppRate extends IonicNativePlugin {
* @param {boolean} immediately Show the rating prompt immediately. * @param {boolean} immediately Show the rating prompt immediately.
*/ */
@Cordova() @Cordova()
promptForRating(immediately: boolean): void { }; promptForRating(immediately: boolean): void {
}
/** /**
* Immediately send the user to the app store rating page * Immediately send the user to the app store rating page
*/ */
@Cordova() @Cordova()
navigateToAppStore(): void { }; navigateToAppStore(): void {
}
} }

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
/** /**
@ -49,5 +49,7 @@ export class AppUpdate extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
checkAppUpdate(updateUrl: string): Promise<any> { return; } checkAppUpdate(updateUrl: string): Promise<any> {
return;
}
} }

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
@ -41,27 +40,35 @@ export class AppVersion extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getAppName(): Promise<any> { return; } getAppName(): Promise<any> {
return;
}
/** /**
* Returns the package name of the app * Returns the package name of the app
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getPackageName(): Promise<any> { return; } getPackageName(): Promise<any> {
return;
}
/** /**
* Returns the build identifier of the app * Returns the build identifier of the app
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getVersionCode(): Promise<any> { return; } getVersionCode(): Promise<any> {
return;
}
/** /**
* Returns the version of the app * Returns the version of the app
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getVersionNumber(): Promise<any> { return; } getVersionNumber(): Promise<any> {
return;
}
} }

View File

@ -1,15 +1,22 @@
import {Injectable} from '@angular/core'; import { Injectable } from '@angular/core';
import {Observable} from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
Plugin,
Cordova,
IonicNativePlugin
} from '@ionic-native/core';
export type IMakePayments = 'This device can make payments and has a supported card' | 'This device cannot make payments.' | 'This device can make payments but has no supported cards'; export type IMakePayments =
'This device can make payments and has a supported card'
| 'This device cannot make payments.'
| 'This device can make payments but has no supported cards';
export type IShippingType = 'shipping' | 'delivery' | 'store' | 'service'; export type IShippingType = 'shipping' | 'delivery' | 'store' | 'service';
export type IBillingRequirement = 'none' | 'all' | 'postcode' | 'name' | 'email' | 'phone'; export type IBillingRequirement = 'none' | 'all' | 'postcode' | 'name' | 'email' | 'phone';
export type ITransactionStatus = 'success' | 'failure' | 'invalid-billing-address' | 'invalid-shipping-address' | 'invalid-shipping-contact' | 'require-pin' | 'incorrect-pin' | 'locked-pin'; export type ITransactionStatus =
'success'
| 'failure'
| 'invalid-billing-address'
| 'invalid-shipping-address'
| 'invalid-shipping-contact'
| 'require-pin'
| 'incorrect-pin'
| 'locked-pin';
export type ICompleteTransaction = 'Payment status applied.'; export type ICompleteTransaction = 'Payment status applied.';
export type IUpdateItemsAndShippingStatus = 'Updated List Info' | 'Did you make a payment request?'; export type IUpdateItemsAndShippingStatus = 'Updated List Info' | 'Did you make a payment request?';
@ -50,12 +57,14 @@ export interface IOrderItem {
label: string; label: string;
amount: number; amount: number;
} }
export interface IShippingMethod { export interface IShippingMethod {
identifier: string; identifier: string;
label: string; label: string;
detail: string; detail: string;
amount: number; amount: number;
} }
export interface IOrderItemsAndShippingMethods { export interface IOrderItemsAndShippingMethods {
items: IOrderItem[]; items: IOrderItem[];
shippingMethods?: IShippingMethod[]; shippingMethods?: IShippingMethod[];
@ -221,7 +230,7 @@ export class ApplePay extends IonicNativePlugin {
* this.paySheetItems.shippingCost = { * this.paySheetItems.shippingCost = {
* label: 'Shipping Cost', * label: 'Shipping Cost',
* amount: shippingMethod[0].amount * amount: shippingMethod[0].amount
* }; * }
* this.applePay.updateItemsAndShippingMethods(this.paySheetItems, shippingMethods); * this.applePay.updateItemsAndShippingMethods(this.paySheetItems, shippingMethods);
* }); * });
*/ */

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@ -46,14 +46,17 @@ export class Appodeal extends IonicNativePlugin {
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
initialize(appKey: string, adType: number): void { }; initialize(appKey: string, adType: number): void {
}
/** /**
* check if SDK has been initialized * check if SDK has been initialized
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
isInitialized(): Promise<any> { return; }; isInitialized(): Promise<any> {
return;
}
/** /**
* show ad of specified type * show ad of specified type
@ -61,7 +64,9 @@ export class Appodeal extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
show(adType: number): Promise<any> { return; }; show(adType: number): Promise<any> {
return;
}
/** /**
* show ad of specified type with placement options * show ad of specified type with placement options
@ -70,24 +75,26 @@ export class Appodeal extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
showWithPlacement( showWithPlacement(adType: number,
adType: number, placement: any): Promise<any> {
placement: any return;
): Promise<any> { return; }; }
/** /**
* hide ad of specified type * hide ad of specified type
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
hide(adType: number): void { }; hide(adType: number): void {
}
/** /**
* confirm use of ads of specified type * confirm use of ads of specified type
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
confirm(adType: number): void { }; confirm(adType: number): void {
}
/** /**
* check if ad of specified type has been loaded * check if ad of specified type has been loaded
@ -95,7 +102,9 @@ export class Appodeal extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
isLoaded(adType: number): Promise<any> { return; }; isLoaded(adType: number): Promise<any> {
return;
}
/** /**
* check if ad of specified * check if ad of specified
@ -103,7 +112,9 @@ export class Appodeal extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
isPrecache(adType: number): Promise<any> { return; }; isPrecache(adType: number): Promise<any> {
return;
}
/** /**
* *
@ -111,75 +122,87 @@ export class Appodeal extends IonicNativePlugin {
* @param autoCache * @param autoCache
*/ */
@Cordova() @Cordova()
setAutoCache(adType: number, autoCache: any): void { }; setAutoCache(adType: number, autoCache: any): void {
}
/** /**
* forcefully cache an ad by type * forcefully cache an ad by type
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
cache(adType: number): void { }; cache(adType: number): void {
}
/** /**
* *
* @param {boolean} set * @param {boolean} set
*/ */
@Cordova() @Cordova()
setOnLoadedTriggerBoth(set: boolean): void { }; setOnLoadedTriggerBoth(set: boolean): void {
}
/** /**
* enable or disable Smart Banners * enable or disable Smart Banners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
setSmartBanners(enabled: boolean): void { }; setSmartBanners(enabled: boolean): void {
}
/** /**
* enable or disable banner backgrounds * enable or disable banner backgrounds
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
setBannerBackground(enabled: boolean): void { }; setBannerBackground(enabled: boolean): void {
}
/** /**
* enable or disable banner animations * enable or disable banner animations
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
setBannerAnimation(enabled: boolean): void { }; setBannerAnimation(enabled: boolean): void {
}
/** /**
* *
* @param value * @param value
*/ */
@Cordova() @Cordova()
set728x90Banners(value: any): void { }; set728x90Banners(value: any): void {
}
/** /**
* enable or disable logging * enable or disable logging
* @param {boolean} logging * @param {boolean} logging
*/ */
@Cordova() @Cordova()
setLogging(logging: boolean): void { }; setLogging(logging: boolean): void {
}
/** /**
* enable or disable testing mode * enable or disable testing mode
* @param {boolean} testing * @param {boolean} testing
*/ */
@Cordova() @Cordova()
setTesting(testing: boolean): void { }; setTesting(testing: boolean): void {
}
/** /**
* reset device ID * reset device ID
*/ */
@Cordova() @Cordova()
resetUUID(): void { }; resetUUID(): void {
}
/** /**
* get version of Appdeal SDK * get version of Appdeal SDK
*/ */
@Cordova() @Cordova()
getVersion(): Promise<any> { return; }; getVersion(): Promise<any> {
return;
}
/** /**
* *
@ -187,7 +210,8 @@ export class Appodeal extends IonicNativePlugin {
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
disableNetwork(network?: string, adType?: number): void { }; disableNetwork(network?: string, adType?: number): void {
}
/** /**
* *
@ -195,54 +219,62 @@ export class Appodeal extends IonicNativePlugin {
* @param {number} adType * @param {number} adType
*/ */
@Cordova() @Cordova()
disableNetworkType(network?: string, adType?: number): void { }; disableNetworkType(network?: string, adType?: number): void {
}
/** /**
* disable Location permissions for Appodeal SDK * disable Location permissions for Appodeal SDK
*/ */
@Cordova() @Cordova()
disableLocationPermissionCheck(): void { }; disableLocationPermissionCheck(): void {
}
/** /**
* disable Storage permissions for Appodeal SDK * disable Storage permissions for Appodeal SDK
*/ */
@Cordova() @Cordova()
disableWriteExternalStoragePermissionCheck(): void { }; disableWriteExternalStoragePermissionCheck(): void {
}
/** /**
* enable event listeners * enable event listeners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
enableInterstitialCallbacks(enabled: boolean): void { }; enableInterstitialCallbacks(enabled: boolean): void {
}
/** /**
* enable event listeners * enable event listeners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
enableSkippableVideoCallbacks(enabled: boolean): void { }; enableSkippableVideoCallbacks(enabled: boolean): void {
}
/** /**
* enable event listeners * enable event listeners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
enableNonSkippableVideoCallbacks(enabled: boolean): void { }; enableNonSkippableVideoCallbacks(enabled: boolean): void {
}
/** /**
* enable event listeners * enable event listeners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
enableBannerCallbacks(enabled: boolean): void { }; enableBannerCallbacks(enabled: boolean): void {
}
/** /**
* enable event listeners * enable event listeners
* @param {boolean} enabled * @param {boolean} enabled
*/ */
@Cordova() @Cordova()
enableRewardedVideoCallbacks(enabled: boolean): void { }; enableRewardedVideoCallbacks(enabled: boolean): void {
}
/** /**
* *
@ -250,7 +282,8 @@ export class Appodeal extends IonicNativePlugin {
* @param {boolean} value * @param {boolean} value
*/ */
@Cordova() @Cordova()
setCustomBooleanRule(name: string, value: boolean): void { }; setCustomBooleanRule(name: string, value: boolean): void {
}
/** /**
* *
@ -258,7 +291,8 @@ export class Appodeal extends IonicNativePlugin {
* @param {number} value * @param {number} value
*/ */
@Cordova() @Cordova()
setCustomIntegerRule(name: string, value: number): void { }; setCustomIntegerRule(name: string, value: number): void {
}
/** /**
* set rule with float value * set rule with float value
@ -266,7 +300,8 @@ export class Appodeal extends IonicNativePlugin {
* @param {number} value * @param {number} value
*/ */
@Cordova() @Cordova()
setCustomDoubleRule(name: string, value: number): void { }; setCustomDoubleRule(name: string, value: number): void {
}
/** /**
* set rule with string value * set rule with string value
@ -274,243 +309,302 @@ export class Appodeal extends IonicNativePlugin {
* @param {string} value * @param {string} value
*/ */
@Cordova() @Cordova()
setCustomStringRule(name: string, value: string): void { }; setCustomStringRule(name: string, value: string): void {
}
/** /**
* set ID preference in Appodeal for current user * set ID preference in Appodeal for current user
* @param id * @param id
*/ */
@Cordova() @Cordova()
setUserId(id: any): void { }; setUserId(id: any): void {
}
/** /**
* set Email preference in Appodeal for current user * set Email preference in Appodeal for current user
* @param email * @param email
*/ */
@Cordova() @Cordova()
setEmail(email: any): void { }; setEmail(email: any): void {
}
/** /**
* set Birthday preference in Appodeal for current user * set Birthday preference in Appodeal for current user
* @param birthday * @param birthday
*/ */
@Cordova() @Cordova()
setBirthday(birthday: any): void { }; setBirthday(birthday: any): void {
}
/** /**
* et Age preference in Appodeal for current user * et Age preference in Appodeal for current user
* @param age * @param age
*/ */
@Cordova() @Cordova()
setAge(age: any): void { }; setAge(age: any): void {
}
/** /**
* set Gender preference in Appodeal for current user * set Gender preference in Appodeal for current user
* @param gender * @param gender
*/ */
@Cordova() @Cordova()
setGender(gender: any): void { }; setGender(gender: any): void {
}
/** /**
* set Occupation preference in Appodeal for current user * set Occupation preference in Appodeal for current user
* @param occupation * @param occupation
*/ */
@Cordova() @Cordova()
setOccupation(occupation: any): void { }; setOccupation(occupation: any): void {
}
/** /**
* set Relation preference in Appodeal for current user * set Relation preference in Appodeal for current user
* @param relation * @param relation
*/ */
@Cordova() @Cordova()
setRelation(relation: any): void { }; setRelation(relation: any): void {
}
/** /**
* set Smoking preference in Appodeal for current user * set Smoking preference in Appodeal for current user
* @param smoking * @param smoking
*/ */
@Cordova() @Cordova()
setSmoking(smoking: any): void { }; setSmoking(smoking: any): void {
}
/** /**
* set Alcohol preference in Appodeal for current user * set Alcohol preference in Appodeal for current user
* @param alcohol * @param alcohol
*/ */
@Cordova() @Cordova()
setAlcohol(alcohol: any): void { }; setAlcohol(alcohol: any): void {
}
/** /**
* set Interests preference in Appodeal for current user * set Interests preference in Appodeal for current user
* @param interests * @param interests
*/ */
@Cordova() @Cordova()
setInterests(interests: any): void { }; setInterests(interests: any): void {
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onInterstitialLoaded', event: 'onInterstitialLoaded',
element: document element: 'document'
}) })
onInterstitialLoaded(): Observable<any> { return; } onInterstitialLoaded(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onInterstitialFailedToLoad', event: 'onInterstitialFailedToLoad',
element: document element: 'document'
}) })
onInterstitialFailedToLoad(): Observable<any> { return; } onInterstitialFailedToLoad(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onInterstitialShown', event: 'onInterstitialShown',
element: document element: 'document'
}) })
onInterstitialShown(): Observable<any> { return; } onInterstitialShown(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onInterstitialClicked', event: 'onInterstitialClicked',
element: document element: 'document'
}) })
onInterstitialClicked(): Observable<any> { return; } onInterstitialClicked(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onInterstitialClosed', event: 'onInterstitialClosed',
element: document element: 'document'
}) })
onInterstitialClosed(): Observable<any> { return; } onInterstitialClosed(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onSkippableVideoLoaded', event: 'onSkippableVideoLoaded',
element: document element: 'document'
}) })
onSkippableVideoLoaded(): Observable<any> { return; } onSkippableVideoLoaded(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onSkippableVideoFailedToLoad', event: 'onSkippableVideoFailedToLoad',
element: document element: 'document'
}) })
onSkippableVideoFailedToLoad(): Observable<any> { return; } onSkippableVideoFailedToLoad(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onSkippableVideoShown', event: 'onSkippableVideoShown',
element: document element: 'document'
}) })
onSkippableVideoShown(): Observable<any> { return; } onSkippableVideoShown(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onSkippableVideoFinished', event: 'onSkippableVideoFinished',
element: document element: 'document'
}) })
onSkippableVideoFinished(): Observable<any> { return; } onSkippableVideoFinished(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onSkippableVideoClosed', event: 'onSkippableVideoClosed',
element: document element: 'document'
}) })
onSkippableVideoClosed(): Observable<any> { return; } onSkippableVideoClosed(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onRewardedVideoLoaded', event: 'onRewardedVideoLoaded',
element: document element: 'document'
}) })
onRewardedVideoLoaded(): Observable<any> { return; } onRewardedVideoLoaded(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onRewardedVideoFailedToLoad', event: 'onRewardedVideoFailedToLoad',
element: document element: 'document'
}) })
onRewardedVideoFailedToLoad(): Observable<any> { return; } onRewardedVideoFailedToLoad(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onRewardedVideoShown', event: 'onRewardedVideoShown',
element: document element: 'document'
}) })
onRewardedVideoShown(): Observable<any> { return; } onRewardedVideoShown(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onRewardedVideoFinished', event: 'onRewardedVideoFinished',
element: document element: 'document'
}) })
onRewardedVideoFinished(): Observable<any> { return; } onRewardedVideoFinished(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onRewardedVideoClosed', event: 'onRewardedVideoClosed',
element: document element: 'document'
}) })
onRewardedVideoClosed(): Observable<any> { return; } onRewardedVideoClosed(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onNonSkippableVideoLoaded', event: 'onNonSkippableVideoLoaded',
element: document element: 'document'
}) })
onNonSkippableVideoLoaded(): Observable<any> { return; } onNonSkippableVideoLoaded(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onNonSkippableVideoFailedToLoad', event: 'onNonSkippableVideoFailedToLoad',
element: document element: 'document'
}) })
onNonSkippableVideoFailedToLoad(): Observable<any> { return; } onNonSkippableVideoFailedToLoad(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onNonSkippableVideoShown', event: 'onNonSkippableVideoShown',
element: document element: 'document'
}) })
onNonSkippableVideoShown(): Observable<any> { return; } onNonSkippableVideoShown(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onNonSkippableVideoFinished', event: 'onNonSkippableVideoFinished',
element: document element: 'document'
}) })
onNonSkippableVideoFinished(): Observable<any> { return; } onNonSkippableVideoFinished(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onNonSkippableVideoClosed', event: 'onNonSkippableVideoClosed',
element: document element: 'document'
}) })
onNonSkippableVideoClosed(): Observable<any> { return; } onNonSkippableVideoClosed(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onBannerClicked', event: 'onBannerClicked',
element: document element: 'document'
}) })
onBannerClicked(): Observable<any> { return; } onBannerClicked(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onBannerFailedToLoad', event: 'onBannerFailedToLoad',
element: document element: 'document'
}) })
onBannerFailedToLoad(): Observable<any> { return; } onBannerFailedToLoad(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onBannerLoaded', event: 'onBannerLoaded',
element: document element: 'document'
}) })
onBannerLoaded(): Observable<any> { return; } onBannerLoaded(): Observable<any> {
return;
}
@Cordova({ @Cordova({
eventObservable: true, eventObservable: true,
event: 'onBannerShown', event: 'onBannerShown',
element: document element: 'document'
}) })
onBannerShown(): Observable<any> { return; } onBannerShown(): Observable<any> {
return;
}
} }

View File

@ -1,4 +1,4 @@
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
/** /**
@ -36,12 +36,14 @@ export class Autostart extends IonicNativePlugin {
* Enable the automatic startup after the boot * Enable the automatic startup after the boot
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
enable(): void { } enable(): void {
}
/** /**
* Disable the automatic startup after the boot * Disable the automatic startup after the boot
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
disable(): void { } disable(): void {
}
} }

View File

@ -1,4 +1,4 @@
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
export interface BackgroundFetchConfig { export interface BackgroundFetchConfig {
@ -27,7 +27,7 @@ export interface BackgroundFetchConfig {
* *
* const config: BackgroundFetchConfig = { * const config: BackgroundFetchConfig = {
* stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true. * stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.
* }; * }
* *
* backgroundFetch.configure(config) * backgroundFetch.configure(config)
* .then(() => { * .then(() => {
@ -72,7 +72,9 @@ export class BackgroundFetch extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
configure(config: BackgroundFetchConfig): Promise<any> { return; } configure(config: BackgroundFetchConfig): Promise<any> {
return;
}
/** /**
* Start the background-fetch API. * Start the background-fetch API.
@ -80,14 +82,18 @@ export class BackgroundFetch extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
start(): Promise<any> { return; } start(): Promise<any> {
return;
}
/** /**
* Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed. * Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed.
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
stop(): Promise<any> { return; } stop(): Promise<any> {
return;
}
/** /**
* You MUST call this method in your fetch callbackFn provided to #configure in order to signal to iOS that your fetch action is complete. iOS provides only 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app. * You MUST call this method in your fetch callbackFn provided to #configure in order to signal to iOS that your fetch action is complete. iOS provides only 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app.
@ -95,13 +101,16 @@ export class BackgroundFetch extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
finish(): void { } finish(): void {
}
/** /**
* Return the status of the background-fetch * Return the status of the background-fetch
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
status(): Promise<any> { return; } status(): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export interface BackgroundGeolocationResponse { export interface BackgroundGeolocationResponse {
@ -276,7 +276,7 @@ export interface BackgroundGeolocationConfig {
* distanceFilter: 30, * distanceFilter: 30,
* debug: true, // enable this hear sounds for background-geolocation life-cycle. * debug: true, // enable this hear sounds for background-geolocation life-cycle.
* stopOnTerminate: false, // enable this to clear background location settings when the app terminates * stopOnTerminate: false, // enable this to clear background location settings when the app terminates
* }; * }
* *
* this.backgroundGeolocation.configure(config) * this.backgroundGeolocation.configure(config)
* .subscribe((location: BackgroundGeolocationResponse) => { * .subscribe((location: BackgroundGeolocationResponse) => {
@ -369,7 +369,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
callbackOrder: 'reverse', callbackOrder: 'reverse',
observable: true observable: true
}) })
configure(options: BackgroundGeolocationConfig): Observable<BackgroundGeolocationResponse> { return; } configure(options: BackgroundGeolocationConfig): Observable<BackgroundGeolocationResponse> {
return;
}
/** /**
* Turn ON the background-geolocation system. * Turn ON the background-geolocation system.
@ -377,14 +379,18 @@ export class BackgroundGeolocation extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
start(): Promise<any> { return; } start(): Promise<any> {
return;
}
/** /**
* Turn OFF background-tracking * Turn OFF background-tracking
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
stop(): Promise<any> { return; } stop(): Promise<any> {
return;
}
/** /**
* Inform the native plugin that you're finished, the background-task may be completed * Inform the native plugin that you're finished, the background-task may be completed
@ -393,7 +399,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'] platforms: ['iOS']
}) })
finish(): Promise<any> { return; } finish(): Promise<any> {
return;
}
/** /**
* Force the plugin to enter "moving" or "stationary" state * Force the plugin to enter "moving" or "stationary" state
@ -403,7 +411,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'] platforms: ['iOS']
}) })
changePace(isMoving: boolean): Promise<any> { return; } changePace(isMoving: boolean): Promise<any> {
return;
}
/** /**
* Setup configuration * Setup configuration
@ -413,7 +423,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
setConfig(options: BackgroundGeolocationConfig): Promise<any> { return; } setConfig(options: BackgroundGeolocationConfig): Promise<any> {
return;
}
/** /**
* Returns current stationaryLocation if available. null if not * Returns current stationaryLocation if available. null if not
@ -422,7 +434,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'] platforms: ['iOS']
}) })
getStationaryLocation(): Promise<BackgroundGeolocationResponse> { return; } getStationaryLocation(): Promise<BackgroundGeolocationResponse> {
return;
}
/** /**
* Add a stationary-region listener. Whenever the devices enters "stationary-mode", * Add a stationary-region listener. Whenever the devices enters "stationary-mode",
@ -432,7 +446,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'] platforms: ['iOS']
}) })
onStationary(): Promise<any> { return; } onStationary(): Promise<any> {
return;
}
/** /**
* Check if location is enabled on the device * Check if location is enabled on the device
@ -441,19 +457,23 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
isLocationEnabled(): Promise<number> { return; } isLocationEnabled(): Promise<number> {
return;
}
/** /**
* Display app settings to change permissions * Display app settings to change permissions
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
showAppSettings(): void { } showAppSettings(): void {
}
/** /**
* Display device location settings * Display device location settings
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
showLocationSettings(): void { } showLocationSettings(): void {
}
/** /**
* Method can be used to detect user changes in location services settings. * Method can be used to detect user changes in location services settings.
@ -464,7 +484,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
watchLocationMode(): Promise<boolean> { return; } watchLocationMode(): Promise<boolean> {
return;
}
/** /**
* Stop watching for location mode changes. * Stop watching for location mode changes.
@ -473,7 +495,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
stopWatchingLocationMode(): Promise<any> { return; } stopWatchingLocationMode(): Promise<any> {
return;
}
/** /**
* Method will return all stored locations. * Method will return all stored locations.
@ -487,14 +511,18 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
getLocations(): Promise<any> { return; } getLocations(): Promise<any> {
return;
}
/** /**
* Method will return locations, which has not been yet posted to server. NOTE: Locations does contain locationId. * Method will return locations, which has not been yet posted to server. NOTE: Locations does contain locationId.
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getValidLocations(): Promise<any> { return; } getValidLocations(): Promise<any> {
return;
}
/** /**
* Delete stored location by given locationId. * Delete stored location by given locationId.
@ -504,7 +532,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
deleteLocation(locationId: number): Promise<any> { return; } deleteLocation(locationId: number): Promise<any> {
return;
}
/** /**
* Delete all stored locations. * Delete all stored locations.
@ -513,7 +543,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
deleteAllLocations(): Promise<any> { return; } deleteAllLocations(): Promise<any> {
return;
}
/** /**
* Normally plugin will handle switching between BACKGROUND and FOREGROUND mode itself. * Normally plugin will handle switching between BACKGROUND and FOREGROUND mode itself.
@ -531,7 +563,9 @@ export class BackgroundGeolocation extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'] platforms: ['iOS']
}) })
switchMode(modeId: number): Promise<any> { return; } switchMode(modeId: number): Promise<any> {
return;
}
/** /**
* Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries. * Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries.
@ -541,6 +575,8 @@ export class BackgroundGeolocation extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
getLogEntries(limit: number): Promise<any> { return; } getLogEntries(limit: number): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
@ -82,14 +82,17 @@ export class BackgroundMode extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
enable(): void { } enable(): void {
}
/** /**
* Disable the background mode. * Disable the background mode.
* Once the background mode has been disabled, the app will be paused when in background. * Once the background mode has been disabled, the app will be paused when in background.
*/ */
@Cordova() @Cordova()
disable(): Promise<any> { return; } disable(): Promise<any> {
return;
}
/** /**
* Checks if background mode is enabled or not. * Checks if background mode is enabled or not.
@ -98,7 +101,9 @@ export class BackgroundMode extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
isEnabled(): boolean { return; } isEnabled(): boolean {
return;
}
/** /**
* Can be used to get the information if the background mode is active. * Can be used to get the information if the background mode is active.
@ -107,7 +112,9 @@ export class BackgroundMode extends IonicNativePlugin {
@Cordova({ @Cordova({
sync: true sync: true
}) })
isActive(): boolean { return; } isActive(): boolean {
return;
}
/** /**
* Override the default title, ticker and text. * Override the default title, ticker and text.
@ -117,7 +124,9 @@ export class BackgroundMode extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
setDefaults(options?: BackgroundModeConfiguration): Promise<any> { return; } setDefaults(options?: BackgroundModeConfiguration): Promise<any> {
return;
}
/** /**
* Modify the displayed information. * Modify the displayed information.
@ -128,7 +137,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
configure(options?: BackgroundModeConfiguration): void {} configure(options?: BackgroundModeConfiguration): void {
}
/** /**
* Listen for events that the plugin fires. Available events are `enable`, `disable`, `activate`, `deactivate` and `failure`. * Listen for events that the plugin fires. Available events are `enable`, `disable`, `activate`, `deactivate` and `failure`.
@ -140,7 +150,9 @@ export class BackgroundMode extends IonicNativePlugin {
clearFunction: 'un', clearFunction: 'un',
clearWithArgs: true clearWithArgs: true
}) })
on(event: string): Observable<any> { return; } on(event: string): Observable<any> {
return;
}
/** /**
* Android allows to programmatically move from foreground to background. * Android allows to programmatically move from foreground to background.
@ -149,7 +161,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
moveToBackground(): void { } moveToBackground(): void {
}
/** /**
* Enable GPS-tracking in background (Android). * Enable GPS-tracking in background (Android).
@ -158,7 +171,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
disableWebViewOptimizations (): void { } disableWebViewOptimizations(): void {
}
/** /**
* Android allows to programmatically move from background to foreground. * Android allows to programmatically move from background to foreground.
@ -167,7 +181,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
moveToForeground(): void { } moveToForeground(): void {
}
/** /**
* Override the back button on Android to go to background instead of closing the app. * Override the back button on Android to go to background instead of closing the app.
@ -176,7 +191,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
overrideBackButton(): void { } overrideBackButton(): void {
}
/** /**
* Exclude the app from the recent task list. Works on Android 5.0+. * Exclude the app from the recent task list. Works on Android 5.0+.
@ -185,7 +201,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
excludeFromTaskList(): void { } excludeFromTaskList(): void {
}
/** /**
* The method works async instead of isActive() or isEnabled(). * The method works async instead of isActive() or isEnabled().
@ -193,7 +210,9 @@ export class BackgroundMode extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android'] platforms: ['Android']
}) })
isScreenOff(): Promise<boolean> { return; } isScreenOff(): Promise<boolean> {
return;
}
/** /**
* Turn screen on * Turn screen on
@ -202,7 +221,8 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
wakeUp(): void { } wakeUp(): void {
}
/** /**
* Turn screen on and show app even locked * Turn screen on and show app even locked
@ -211,6 +231,7 @@ export class BackgroundMode extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
unlock(): void { } unlock(): void {
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
@ -39,13 +39,17 @@ export class Backlight extends IonicNativePlugin {
* @return {Promise<any>} Returns a promise that resolves when the backlight is on * @return {Promise<any>} Returns a promise that resolves when the backlight is on
*/ */
@Cordova() @Cordova()
on(): Promise<any> { return; } on(): Promise<any> {
return;
}
/** /**
* This function turns backlight off * This function turns backlight off
* @return {Promise<any>} Returns a promise that resolves when the backlight is off * @return {Promise<any>} Returns a promise that resolves when the backlight is off
*/ */
@Cordova() @Cordova()
off(): Promise<any> { return; } off(): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
@ -37,7 +37,9 @@ export class Badge extends IonicNativePlugin {
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
@Cordova() @Cordova()
clear(): Promise<boolean> { return; } clear(): Promise<boolean> {
return;
}
/** /**
* Set the badge of the app icon. * Set the badge of the app icon.
@ -45,14 +47,18 @@ export class Badge extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
set(badgeNumber: number): Promise<any> { return; } set(badgeNumber: number): Promise<any> {
return;
}
/** /**
* Get the badge of the app icon. * Get the badge of the app icon.
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
get(): Promise<any> { return; } get(): Promise<any> {
return;
}
/** /**
* Increase the badge number. * Increase the badge number.
@ -60,7 +66,9 @@ export class Badge extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
increase(increaseBy: number): Promise<any> { return; } increase(increaseBy: number): Promise<any> {
return;
}
/** /**
* Decrease the badge number. * Decrease the badge number.
@ -68,20 +76,26 @@ export class Badge extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
decrease(decreaseBy: number): Promise<any> { return; } decrease(decreaseBy: number): Promise<any> {
return;
}
/** /**
* Determine if the app has permission to show badges. * Determine if the app has permission to show badges.
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
hasPermission(): Promise<any> { return; } hasPermission(): Promise<any> {
return;
}
/** /**
* Register permission to set badge notifications * Register permission to set badge notifications
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
registerPermission(): Promise<any> { return; } registerPermission(): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface BarcodeScannerOptions { export interface BarcodeScannerOptions {
@ -117,7 +117,9 @@ export class BarcodeScanner extends IonicNativePlugin {
@Cordova({ @Cordova({
callbackOrder: 'reverse' callbackOrder: 'reverse'
}) })
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> { return; } scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
return;
}
/** /**
* Encodes data into a barcode. * Encodes data into a barcode.
@ -127,6 +129,8 @@ export class BarcodeScanner extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
encode(type: string, data: any): Promise<any> { return; } encode(type: string, data: any): Promise<any> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
* @name Base64 To Gallery * @name Base64 To Gallery

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
* @beta * @beta
@ -40,6 +40,8 @@ export class Base64 extends IonicNativePlugin {
* @return {Promise<string>} Returns a promise that resolves when the file is successfully encoded * @return {Promise<string>} Returns a promise that resolves when the file is successfully encoded
*/ */
@Cordova() @Cordova()
encodeFile(filePath: string): Promise<string> { return; } encodeFile(filePath: string): Promise<string> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export interface BatteryStatusResponse { export interface BatteryStatusResponse {
@ -62,7 +62,9 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterystatus' event: 'batterystatus'
}) })
onChange(): Observable<BatteryStatusResponse> { return; } onChange(): Observable<BatteryStatusResponse> {
return;
}
/** /**
* Watch when the battery level goes low * Watch when the battery level goes low
@ -72,7 +74,9 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterylow' event: 'batterylow'
}) })
onLow(): Observable<BatteryStatusResponse> { return; } onLow(): Observable<BatteryStatusResponse> {
return;
}
/** /**
* Watch when the battery level goes to critial * Watch when the battery level goes to critial
@ -82,6 +86,8 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterycritical' event: 'batterycritical'
}) })
onCritical(): Observable<BatteryStatusResponse> { return; } onCritical(): Observable<BatteryStatusResponse> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
/** /**
@ -194,7 +194,9 @@ export class BLE extends IonicNativePlugin {
@Cordova({ @Cordova({
observable: true observable: true
}) })
scan(services: string[], seconds: number): Observable<any> { return; } scan(services: string[], seconds: number): Observable<any> {
return;
}
/** /**
* Scan and discover BLE peripherals until `stopScan` is called. * Scan and discover BLE peripherals until `stopScan` is called.
@ -217,7 +219,9 @@ export class BLE extends IonicNativePlugin {
clearFunction: 'stopScan', clearFunction: 'stopScan',
clearWithArgs: false clearWithArgs: false
}) })
startScan(services: string[]): Observable<any> { return; } startScan(services: string[]): Observable<any> {
return;
}
/** /**
* Scans for BLE devices. This function operates similarly to the `startScan` function, but allows you to specify extra options (like allowing duplicate device reports). * Scans for BLE devices. This function operates similarly to the `startScan` function, but allows you to specify extra options (like allowing duplicate device reports).
@ -230,7 +234,9 @@ export class BLE extends IonicNativePlugin {
clearFunction: 'stopScan', clearFunction: 'stopScan',
clearWithArgs: false clearWithArgs: false
}) })
startScanWithOptions(services: string[], options: { reportDuplicates?: boolean } | any): Observable<any> { return; } startScanWithOptions(services: string[], options: { reportDuplicates?: boolean } | any): Observable<any> {
return;
}
/** /**
* Stop a scan started by `startScan`. * Stop a scan started by `startScan`.
@ -247,7 +253,9 @@ export class BLE extends IonicNativePlugin {
* @return returns a Promise. * @return returns a Promise.
*/ */
@Cordova() @Cordova()
stopScan(): Promise<any> { return; } stopScan(): Promise<any> {
return;
}
/** /**
* Connect to a peripheral. * Connect to a peripheral.
@ -268,7 +276,9 @@ export class BLE extends IonicNativePlugin {
clearFunction: 'disconnect', clearFunction: 'disconnect',
clearWithArgs: true clearWithArgs: true
}) })
connect(deviceId: string): Observable<any> { return; } connect(deviceId: string): Observable<any> {
return;
}
/** /**
* Disconnect from a peripheral. * Disconnect from a peripheral.
@ -282,7 +292,9 @@ export class BLE extends IonicNativePlugin {
* @return Returns a Promise * @return Returns a Promise
*/ */
@Cordova() @Cordova()
disconnect(deviceId: string): Promise<any> { return; } disconnect(deviceId: string): Promise<any> {
return;
}
/** /**
* Read the value of a characteristic. * Read the value of a characteristic.
@ -293,11 +305,11 @@ export class BLE extends IonicNativePlugin {
* @return Returns a Promise * @return Returns a Promise
*/ */
@Cordova() @Cordova()
read( read(deviceId: string,
deviceId: string,
serviceUUID: string, serviceUUID: string,
characteristicUUID: string characteristicUUID: string): Promise<any> {
): Promise<any> { return; }; return;
}
/** /**
* Write the value of a characteristic. * Write the value of a characteristic.
@ -328,12 +340,12 @@ export class BLE extends IonicNativePlugin {
* @return Returns a Promise * @return Returns a Promise
*/ */
@Cordova() @Cordova()
write( write(deviceId: string,
deviceId: string,
serviceUUID: string, serviceUUID: string,
characteristicUUID: string, characteristicUUID: string,
value: ArrayBuffer value: ArrayBuffer): Promise<any> {
): Promise<any> { return; } return;
}
/** /**
* Write the value of a characteristic without waiting for confirmation from the peripheral. * Write the value of a characteristic without waiting for confirmation from the peripheral.
@ -345,12 +357,12 @@ export class BLE extends IonicNativePlugin {
* @return Returns a Promise * @return Returns a Promise
*/ */
@Cordova() @Cordova()
writeWithoutResponse( writeWithoutResponse(deviceId: string,
deviceId: string,
serviceUUID: string, serviceUUID: string,
characteristicUUID: string, characteristicUUID: string,
value: ArrayBuffer value: ArrayBuffer): Promise<any> {
): Promise<any> { return; } return;
}
/** /**
* Register to be notified when the value of a characteristic changes. * Register to be notified when the value of a characteristic changes.
@ -372,11 +384,11 @@ export class BLE extends IonicNativePlugin {
clearFunction: 'stopNotification', clearFunction: 'stopNotification',
clearWithArgs: true clearWithArgs: true
}) })
startNotification( startNotification(deviceId: string,
deviceId: string,
serviceUUID: string, serviceUUID: string,
characteristicUUID: string characteristicUUID: string): Observable<any> {
): Observable<any> { return; } return;
}
/** /**
* Stop being notified when the value of a characteristic changes. * Stop being notified when the value of a characteristic changes.
@ -387,11 +399,11 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
stopNotification( stopNotification(deviceId: string,
deviceId: string,
serviceUUID: string, serviceUUID: string,
characteristicUUID: string characteristicUUID: string): Promise<any> {
): Promise<any> { return; } return;
}
/** /**
* Report the connection status. * Report the connection status.
@ -407,7 +419,9 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
isConnected(deviceId: string): Promise<any> { return; } isConnected(deviceId: string): Promise<any> {
return;
}
/** /**
* Report if bluetooth is enabled. * Report if bluetooth is enabled.
@ -415,7 +429,9 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<void>} Returns a Promise that resolves if Bluetooth is enabled, and rejects if disabled. * @returns {Promise<void>} Returns a Promise that resolves if Bluetooth is enabled, and rejects if disabled.
*/ */
@Cordova() @Cordova()
isEnabled(): Promise<void> { return; } isEnabled(): Promise<void> {
return;
}
/** /**
* Register to be notified when Bluetooth state changes on the device. * Register to be notified when Bluetooth state changes on the device.
@ -434,7 +450,9 @@ export class BLE extends IonicNativePlugin {
clearFunction: 'stopStateNotifications', clearFunction: 'stopStateNotifications',
clearWithArgs: false clearWithArgs: false
}) })
startStateNotifications(): Observable<any> { return; } startStateNotifications(): Observable<any> {
return;
}
/** /**
* Stop state notifications. * Stop state notifications.
@ -442,7 +460,9 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
stopStateNotifications(): Promise<any> { return; } stopStateNotifications(): Promise<any> {
return;
}
/** /**
* Open System Bluetooth settings (Android only). * Open System Bluetooth settings (Android only).
@ -450,7 +470,9 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
showBluetoothSettings(): Promise<any> { return; } showBluetoothSettings(): Promise<any> {
return;
}
/** /**
* Enable Bluetooth on the device (Android only). * Enable Bluetooth on the device (Android only).
@ -458,7 +480,9 @@ export class BLE extends IonicNativePlugin {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
enable(): Promise<any> { return; } enable(): Promise<any> {
return;
}
/** /**
* Read the RSSI value on the device connection. * Read the RSSI value on the device connection.
@ -468,7 +492,7 @@ export class BLE extends IonicNativePlugin {
*@returns {Promise<any>} *@returns {Promise<any>}
*/ */
@Cordova() @Cordova()
readRSSI( readRSSI(deviceId: string): Promise<any> {
deviceId: string, return;
): Promise<any> { return; } }
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
/** /**
@ -50,7 +50,9 @@ export class BluetoothSerial extends IonicNativePlugin {
observable: true, observable: true,
clearFunction: 'disconnect' clearFunction: 'disconnect'
}) })
connect(macAddress_or_uuid: string): Observable<any> { return; } connect(macAddress_or_uuid: string): Observable<any> {
return;
}
/** /**
* Connect insecurely to a Bluetooth device * Connect insecurely to a Bluetooth device
@ -62,14 +64,18 @@ export class BluetoothSerial extends IonicNativePlugin {
observable: true, observable: true,
clearFunction: 'disconnect' clearFunction: 'disconnect'
}) })
connectInsecure(macAddress: string): Observable<any> { return; } connectInsecure(macAddress: string): Observable<any> {
return;
}
/** /**
* Disconnect from the connected device * Disconnect from the connected device
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
@Cordova() @Cordova()
disconnect(): Promise<any> { return; } disconnect(): Promise<any> {
return;
}
/** /**
* Writes data to the serial port * Writes data to the serial port
@ -79,7 +85,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
write(data: any): Promise<any> { return; } write(data: any): Promise<any> {
return;
}
/** /**
* Gets the number of bytes of data available * Gets the number of bytes of data available
@ -87,7 +95,10 @@ export class BluetoothSerial extends IonicNativePlugin {
*/ */
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) available(): Promise<any> { return; } })
available(): Promise<any> {
return;
}
/** /**
* Reads data from the buffer * Reads data from the buffer
@ -96,7 +107,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
read(): Promise<any> { return; } read(): Promise<any> {
return;
}
/** /**
* Reads data from the buffer until it reaches a delimiter * Reads data from the buffer until it reaches a delimiter
@ -106,7 +119,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
readUntil(delimiter: string): Promise<any> { return; } readUntil(delimiter: string): Promise<any> {
return;
}
/** /**
* Subscribe to be notified when data is received * Subscribe to be notified when data is received
@ -118,7 +133,9 @@ export class BluetoothSerial extends IonicNativePlugin {
observable: true, observable: true,
clearFunction: 'unsubscribe' clearFunction: 'unsubscribe'
}) })
subscribe(delimiter: string): Observable<any> { return; } subscribe(delimiter: string): Observable<any> {
return;
}
/** /**
* Subscribe to be notified when data is received * Subscribe to be notified when data is received
@ -129,7 +146,9 @@ export class BluetoothSerial extends IonicNativePlugin {
observable: true, observable: true,
clearFunction: 'unsubscribeRawData' clearFunction: 'unsubscribeRawData'
}) })
subscribeRawData(): Observable<any> { return; } subscribeRawData(): Observable<any> {
return;
}
/** /**
* Clears data in buffer * Clears data in buffer
@ -138,7 +157,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
clear(): Promise<any> { return; } clear(): Promise<any> {
return;
}
/** /**
* Lists bonded devices * Lists bonded devices
@ -147,7 +168,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
list(): Promise<any> { return; } list(): Promise<any> {
return;
}
/** /**
* Reports if bluetooth is enabled * Reports if bluetooth is enabled
@ -156,7 +179,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
isEnabled(): Promise<any> { return; } isEnabled(): Promise<any> {
return;
}
/** /**
* Reports the connection status * Reports the connection status
@ -165,7 +190,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
isConnected(): Promise<any> { return; } isConnected(): Promise<any> {
return;
}
/** /**
* Reads the RSSI from the connected peripheral * Reads the RSSI from the connected peripheral
@ -174,7 +201,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
readRSSI(): Promise<any> { return; } readRSSI(): Promise<any> {
return;
}
/** /**
* Show the Bluetooth settings on the device * Show the Bluetooth settings on the device
@ -183,7 +212,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
showBluetoothSettings(): Promise<any> { return; } showBluetoothSettings(): Promise<any> {
return;
}
/** /**
* Enable Bluetooth on the device * Enable Bluetooth on the device
@ -192,7 +223,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
enable(): Promise<any> { return; } enable(): Promise<any> {
return;
}
/** /**
* Discover unpaired devices * Discover unpaired devices
@ -201,7 +234,9 @@ export class BluetoothSerial extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'] platforms: ['Android', 'iOS', 'Windows Phone']
}) })
discoverUnpaired(): Promise<any> { return; } discoverUnpaired(): Promise<any> {
return;
}
/** /**
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function. * Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
@ -212,7 +247,9 @@ export class BluetoothSerial extends IonicNativePlugin {
observable: true, observable: true,
clearFunction: 'clearDeviceDiscoveredListener' clearFunction: 'clearDeviceDiscoveredListener'
}) })
setDeviceDiscoveredListener(): Observable<any> { return; } setDeviceDiscoveredListener(): Observable<any> {
return;
}
/** /**
* Sets the human readable device name that is broadcasted to other devices * Sets the human readable device name that is broadcasted to other devices
@ -222,7 +259,8 @@ export class BluetoothSerial extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
setName(newName: string): void { } setName(newName: string): void {
}
/** /**
* Makes the device discoverable by other devices * Makes the device discoverable by other devices
@ -232,6 +270,7 @@ export class BluetoothSerial extends IonicNativePlugin {
platforms: ['Android'], platforms: ['Android'],
sync: true sync: true
}) })
setDiscoverable(discoverableDuration: number): void { } setDiscoverable(discoverableDuration: number): void {
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
* Options for the setupApplePay method. * Options for the setupApplePay method.
@ -116,8 +116,7 @@ export interface PaymentUIResult {
/** /**
* Information about the Apple Pay card used to complete a payment (if Apple Pay was used). * Information about the Apple Pay card used to complete a payment (if Apple Pay was used).
*/ */
applePaycard: { applePaycard: {};
};
/** /**
* Information about 3D Secure card used to complete a payment (if 3D Secure was used). * Information about 3D Secure card used to complete a payment (if 3D Secure was used).
@ -167,12 +166,12 @@ export interface PaymentUIResult {
* merchantId: '<YOUR MERCHANT ID>', * merchantId: '<YOUR MERCHANT ID>',
* currency: 'USD', * currency: 'USD',
* country: 'US' * country: 'US'
* }; * }
* *
* const paymentOptions: PaymentUIOptions = { * const paymentOptions: PaymentUIOptions = {
* amount: '14.99', * amount: '14.99',
* primaryDescription: 'Your product or service (per /item, /month, /week, etc)', * primaryDescription: 'Your product or service (per /item, /month, /week, etc)',
* }; * }
* *
* this.braintree.initialize(BRAINTREE_TOKEN) * this.braintree.initialize(BRAINTREE_TOKEN)
* .then(() => this.braintree.setupApplePay(appleOptions)) * .then(() => this.braintree.setupApplePay(appleOptions))
@ -217,7 +216,9 @@ export class Braintree extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS'], platforms: ['Android', 'iOS'],
}) })
initialize(token: string): Promise<undefined | string> { return; } initialize(token: string): Promise<undefined | string> {
return;
}
/** /**
* Used to configure Apple Pay on iOS. * Used to configure Apple Pay on iOS.
@ -234,7 +235,9 @@ export class Braintree extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['iOS'], platforms: ['iOS'],
}) })
setupApplePay(options: ApplePayOptions): Promise<undefined | string> { return; } setupApplePay(options: ApplePayOptions): Promise<undefined | string> {
return;
}
/** /**
* Shows Braintree's Drop-In Payments UI. * Shows Braintree's Drop-In Payments UI.
@ -246,5 +249,7 @@ export class Braintree extends IonicNativePlugin {
@Cordova({ @Cordova({
platforms: ['Android', 'iOS'], platforms: ['Android', 'iOS'],
}) })
presentDropInPaymentUI(options?: PaymentUIOptions): Promise<PaymentUIResult | string> { return; } presentDropInPaymentUI(options?: PaymentUIOptions): Promise<PaymentUIResult | string> {
return;
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
/** /**
@ -39,7 +39,9 @@ export class Brightness extends IonicNativePlugin {
* @returns {Promise<any>} Returns a Promise that resolves if setting brightness was successful. * @returns {Promise<any>} Returns a Promise that resolves if setting brightness was successful.
*/ */
@Cordova() @Cordova()
setBrightness(value: number): Promise<any> { return; } setBrightness(value: number): Promise<any> {
return;
}
/** /**
* Reads the current brightness of the device display. * Reads the current brightness of the device display.
@ -48,12 +50,15 @@ export class Brightness extends IonicNativePlugin {
* brightness value of the device display (floating number between 0 and 1). * brightness value of the device display (floating number between 0 and 1).
*/ */
@Cordova() @Cordova()
getBrightness(): Promise<any> { return; } getBrightness(): Promise<any> {
return;
}
/** /**
* Keeps the screen on. Prevents the device from setting the screen to sleep. * Keeps the screen on. Prevents the device from setting the screen to sleep.
*/ */
@Cordova() @Cordova()
setKeepScreenOn(value: boolean): void { } setKeepScreenOn(value: boolean): void {
}
} }

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
/** /**
@ -43,7 +43,9 @@ export class Broadcaster extends IonicNativePlugin {
clearFunction: 'removeEventListener', clearFunction: 'removeEventListener',
clearWithArgs: true clearWithArgs: true
}) })
addEventListener(eventName: string): Observable<any> { return; } addEventListener(eventName: string): Observable<any> {
return;
}
/** /**
* This function sends data to the native code * This function sends data to the native code
@ -52,6 +54,8 @@ export class Broadcaster extends IonicNativePlugin {
* @return {Promise<any>} Returns a promise that resolves when an event is successfully fired * @return {Promise<any>} Returns a promise that resolves when an event is successfully fired
*/ */
@Cordova() @Cordova()
fireNativeEvent(eventName: string, eventData: any): Promise<any> { return; } fireNativeEvent(eventName: string, eventData: any): Promise<any> {
return;
}
} }

Some files were not shown because too many files have changed in this diff Show More