mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
parent
97a73ca369
commit
48b0f16ed9
84
package-lock.json
generated
84
package-lock.json
generated
@ -5,42 +5,66 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": {
|
"@angular/common": {
|
||||||
"version": "5.2.9",
|
"version": "6.0.0-rc.2",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/common/-/common-5.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/common/-/common-6.0.0-rc.2.tgz",
|
||||||
"integrity": "sha512-g2hPcI0fnT4TV+Fd+1IohjuqBxPvxwyH9IzTn8PkU9X2M+F6cHCUvHxL1sWI2sF8pYcaHzVjq9WClym10X36Lg==",
|
"integrity": "sha512-F0eR3xReT5OUkkojMiGy7+AL1fBMBpTj0GmIFmsYJOOGHru0UorNetmQlYT7GUCxraClHpcDRlnmguoP0GZyGg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "1.8.1"
|
"tslib": "1.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@angular/compiler": {
|
"@angular/compiler": {
|
||||||
"version": "5.2.9",
|
"version": "6.0.0-rc.2",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-5.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-6.0.0-rc.2.tgz",
|
||||||
"integrity": "sha512-mN+ofInk8y/tk2TCJZx8RrGdOKdrfunoCair7tfDy4XoQJE90waGfaYWo07hYU+UYwLhrg19m2Czy6rIDciUJA==",
|
"integrity": "sha512-t/6thZ+AIJd59LK1Co2N0CtvPX/gQMLhgZ3tFpHOWbvyj/BOJ17dgtEnYGSB1spcnKXNAr+N8XECup0zNj/VWg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "1.8.1"
|
"tslib": "1.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@angular/compiler-cli": {
|
"@angular/compiler-cli": {
|
||||||
"version": "5.2.9",
|
"version": "6.0.0-rc.2",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-5.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-6.0.0-rc.2.tgz",
|
||||||
"integrity": "sha512-LAEpL/6PAev3zwTow/43Atzv9AtKLAiLoS285X3EV1f80yQpYAmFRrPUtDlrIZdhZHBBv7CxnyCVpOLU3T8ohw==",
|
"integrity": "sha512-Qcoh75Ru3p9STahonKaegp0r8s/R5MV9DoBgsBGDM9Y/b1+GkpYBQEcsh5iyHJh1OlTmLMrAXh+eqwofI2xyaQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"chokidar": "1.7.0",
|
"chokidar": "1.7.0",
|
||||||
"minimist": "1.2.0",
|
"minimist": "1.2.0",
|
||||||
"reflect-metadata": "0.1.12",
|
"reflect-metadata": "0.1.12",
|
||||||
"tsickle": "0.27.2"
|
"tsickle": "0.27.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@angular/core": {
|
"@angular/core": {
|
||||||
"version": "5.2.9",
|
"version": "6.0.0-rc.2",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/core/-/core-5.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/core/-/core-6.0.0-rc.2.tgz",
|
||||||
"integrity": "sha512-cvHBJGtasrIoARvbLFyHaOsiWKVwMNrrSTZLwrlyHP8oYzkDrE0qKGer6QCqyKt+51hF53cgWEffGzM/u/0wYg==",
|
"integrity": "sha512-cnF0rw2NPV+hxYyJmuwu8C6iTVUnyOuM9WgjGGa2Ti2HBYk1vCT5HTgIB5GkX99fntAhVohcBeRpxHKCedy6SQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "1.8.1"
|
"tslib": "1.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/code-frame": {
|
"@babel/code-frame": {
|
||||||
@ -11322,12 +11346,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rxjs": {
|
"rxjs": {
|
||||||
"version": "5.5.8",
|
"version": "6.0.0-smoosh.2",
|
||||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.8.tgz",
|
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.0.0-smoosh.2.tgz",
|
||||||
"integrity": "sha512-Bz7qou7VAIoGiglJZbzbXa4vpX5BmTTN2Dj/se6+SwADtw4SihqBIiEa7VmTXJ8pynvq0iFr5Gx9VLyye1rIxQ==",
|
"integrity": "sha512-IAickSl7xhGOHhhZp7XhhyIpHUm1QvHMMPQVAusotHiwE8szw4ntHVbouj0CiB5IMe4jep1dzsTNcvj2YUIP+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"symbol-observable": "1.0.1"
|
"tslib": "1.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
@ -12479,12 +12511,6 @@
|
|||||||
"upper-case": "1.1.3"
|
"upper-case": "1.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"symbol-observable": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"symbol-tree": {
|
"symbol-tree": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
||||||
@ -13362,9 +13388,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsickle": {
|
"tsickle": {
|
||||||
"version": "0.27.2",
|
"version": "0.27.5",
|
||||||
"resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.27.5.tgz",
|
||||||
"integrity": "sha512-KW+ZgY0t2cq2Qib1sfdgMiRnk+cr3brUtzZoVWjv+Ot3jNxVorFBUH+6In6hl8Dg7BI2AAFf69NHkwvZNMSFwA==",
|
"integrity": "sha512-NP+CjM1EXza/M8mOXBLH3vkFEJiu1zfEAlC5WdJxHPn8l96QPz5eooP6uAgYtw1CcKfuSyIiheNUdKxtDWCNeg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "1.2.0",
|
"minimist": "1.2.0",
|
||||||
|
10
package.json
10
package.json
@ -22,10 +22,10 @@
|
|||||||
"shipit": "npm run build && npm run readmes && npm run npmpub"
|
"shipit": "npm run build && npm run readmes && npm run npmpub"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/common": "^5.2.9",
|
"@angular/common": "^6.0.0-rc.2",
|
||||||
"@angular/compiler": "^5.2.9",
|
"@angular/compiler": "^6.0.0-rc.2",
|
||||||
"@angular/compiler-cli": "^5.2.9",
|
"@angular/compiler-cli": "^6.0.0-rc.2",
|
||||||
"@angular/core": "^5.2.9",
|
"@angular/core": "^6.0.0-rc.2",
|
||||||
"@types/cordova": "0.0.34",
|
"@types/cordova": "0.0.34",
|
||||||
"@types/fs-extra": "^5.0.1",
|
"@types/fs-extra": "^5.0.1",
|
||||||
"@types/jest": "^22.2.2",
|
"@types/jest": "^22.2.2",
|
||||||
@ -56,7 +56,7 @@
|
|||||||
"minimist": "1.2.0",
|
"minimist": "1.2.0",
|
||||||
"nodemon": "^1.17.3",
|
"nodemon": "^1.17.3",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"rxjs": "^5.5.8",
|
"rxjs": "^6.0.0-rc.1",
|
||||||
"string-replace-webpack-plugin": "^0.1.3",
|
"string-replace-webpack-plugin": "^0.1.3",
|
||||||
"ts-jest": "^22.4.2",
|
"ts-jest": "^22.4.2",
|
||||||
"ts-node": "^4.1.0",
|
"ts-node": "^4.1.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { callCordovaPlugin, wrapInstance, wrapPromise } from './common';
|
import { callCordovaPlugin, wrapInstance, wrapPromise } from './common';
|
||||||
import 'rxjs/add/observable/of';
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
declare const window: any;
|
declare const window: any;
|
||||||
|
|
||||||
@ -33,14 +33,16 @@ class MockCordovaPlugin {
|
|||||||
static ping = jest.fn((arg: string) => 'pong');
|
static ping = jest.fn((arg: string) => 'pong');
|
||||||
ping = jest.fn((arg: string) => 'pong');
|
ping = jest.fn((arg: string) => 'pong');
|
||||||
|
|
||||||
static pingAsync = jest.fn((arg: string, success: Function, error: Function) => success('pong'));
|
static pingAsync = jest.fn(
|
||||||
pingAsync = jest.fn((arg: string, success: Function, error: Function) => success('pong'));
|
(arg: string, success: Function, error: Function) => success('pong')
|
||||||
|
);
|
||||||
|
pingAsync = jest.fn((arg: string, success: Function, error: Function) =>
|
||||||
|
success('pong')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Common decorator functions', () => {
|
describe('Common decorator functions', () => {
|
||||||
|
let plugin: MockPlugin, instancePluginObject: MockInstancePluginObject;
|
||||||
let plugin: MockPlugin,
|
|
||||||
instancePluginObject: MockInstancePluginObject;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
window.mockPlugin = MockCordovaPlugin;
|
window.mockPlugin = MockCordovaPlugin;
|
||||||
@ -73,15 +75,17 @@ describe('Common decorator functions', () => {
|
|||||||
|
|
||||||
test('original method should have received args', () => {
|
test('original method should have received args', () => {
|
||||||
expect(MockCordovaPlugin.pingAsync.mock.calls[0][0]).toBe('pingpong');
|
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][1]).toBe(
|
||||||
expect(typeof MockCordovaPlugin.pingAsync.mock.calls[0][2]).toBe('function');
|
'function'
|
||||||
|
);
|
||||||
|
expect(typeof MockCordovaPlugin.pingAsync.mock.calls[0][2]).toBe(
|
||||||
|
'function'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('wrapObservable', () => {
|
describe('wrapObservable', () => {
|
||||||
test('should return an observable that emits a value', async () => {
|
test('should return an observable that emits a value', async () => {});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test('original method should have been called', () => {});
|
test('original method should have been called', () => {});
|
||||||
|
|
||||||
@ -93,8 +97,7 @@ describe('Common decorator functions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('callInstance', () => {
|
describe('callInstance', () => {
|
||||||
test('should call an instance method', async () => {
|
test('should call an instance method', async () => {});
|
||||||
});
|
|
||||||
|
|
||||||
test('original method should have been called', () => {
|
test('original method should have been called', () => {
|
||||||
// expect(instancePluginObject._pluginInstance.ping.mock.calls.length).toBe(1);
|
// expect(instancePluginObject._pluginInstance.ping.mock.calls.length).toBe(1);
|
||||||
@ -104,5 +107,4 @@ describe('Common decorator functions', () => {
|
|||||||
// expect(instancePluginObject._pluginInstance.ping.mock.calls[0][0]).toBe('pingpong');
|
// expect(instancePluginObject._pluginInstance.ping.mock.calls[0][0]).toBe('pingpong');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import 'rxjs/add/observable/fromEvent';
|
|
||||||
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable, fromEvent } from 'rxjs';
|
||||||
|
|
||||||
import { CordovaOptions } from './interfaces';
|
import { CordovaOptions } from './interfaces';
|
||||||
|
|
||||||
@ -175,7 +173,7 @@ function wrapEventObservable(event: string, element: any): Observable<any> {
|
|||||||
} else {
|
} else {
|
||||||
element = window;
|
element = window;
|
||||||
}
|
}
|
||||||
return Observable.fromEvent(element, event);
|
return fromEvent(element, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +286,7 @@ export function setIndex(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setErrorIndex = () => {
|
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.
|
// 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 behavior.
|
||||||
if (opts.errorIndex > args.length) {
|
if (opts.errorIndex > args.length) {
|
||||||
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
|
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
import { checkAvailability, getPlugin } from './common';
|
import { checkAvailability, getPlugin } from './common';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
|
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
|
||||||
return new Observable(observer => {
|
return new Observable(observer => {
|
||||||
|
|
||||||
const availabilityCheck = checkAvailability(pluginObj, methodName);
|
const availabilityCheck = checkAvailability(pluginObj, methodName);
|
||||||
|
|
||||||
if (availabilityCheck === true) {
|
if (availabilityCheck === true) {
|
||||||
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
|
const pluginInstance = getPlugin(pluginObj.constructor.getPluginRef());
|
||||||
pluginInstance[methodName] = observer.next.bind(observer);
|
pluginInstance[methodName] = observer.next.bind(observer);
|
||||||
return () => pluginInstance[methodName] = () => { };
|
return () => (pluginInstance[methodName] = () => {});
|
||||||
} else {
|
} else {
|
||||||
observer.error(availabilityCheck);
|
observer.error(availabilityCheck);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cordovaFunctionOverride(pluginObj: any, methodName: string, args: IArguments | Array<any> = []) {
|
export function cordovaFunctionOverride(
|
||||||
|
pluginObj: any,
|
||||||
|
methodName: string,
|
||||||
|
args: IArguments | Array<any> = []
|
||||||
|
) {
|
||||||
return overrideFunction(pluginObj, methodName);
|
return overrideFunction(pluginObj, methodName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user