(Zone: ZoneType)
| 9 | import {ZoneType} from '../zone-impl'; |
| 10 | |
| 11 | export function patchCordova(Zone: ZoneType): void { |
| 12 | Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => { |
| 13 | if (global.cordova) { |
| 14 | const SUCCESS_SOURCE = 'cordova.exec.success'; |
| 15 | const ERROR_SOURCE = 'cordova.exec.error'; |
| 16 | const FUNCTION = 'function'; |
| 17 | const nativeExec: Function | null = api.patchMethod( |
| 18 | global.cordova, |
| 19 | 'exec', |
| 20 | () => |
| 21 | function (self: any, args: any[]) { |
| 22 | if (args.length > 0 && typeof args[0] === FUNCTION) { |
| 23 | args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE); |
| 24 | } |
| 25 | if (args.length > 1 && typeof args[1] === FUNCTION) { |
| 26 | args[1] = Zone.current.wrap(args[1], ERROR_SOURCE); |
| 27 | } |
| 28 | return nativeExec!.apply(self, args); |
| 29 | }, |
| 30 | ); |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | Zone.__load_patch('cordova.FileReader', (global: any, Zone: ZoneType) => { |
| 35 | if (global.cordova && typeof global['FileReader'] !== 'undefined') { |
| 36 | document.addEventListener('deviceReady', () => { |
| 37 | const FileReader = global['FileReader']; |
| 38 | ['abort', 'error', 'load', 'loadstart', 'loadend', 'progress'].forEach((prop) => { |
| 39 | const eventNameSymbol = Zone.__symbol__('ON_PROPERTY' + prop); |
| 40 | Object.defineProperty(FileReader.prototype, eventNameSymbol, { |
| 41 | configurable: true, |
| 42 | get: function () { |
| 43 | return this._realReader && this._realReader[eventNameSymbol]; |
| 44 | }, |
| 45 | }); |
| 46 | }); |
| 47 | }); |
| 48 | } |
| 49 | }); |
| 50 | } |
no test coverage detected