You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.5 KiB

'use strict';
/**
* @license Angular
* (c) 2010-2025 Google LLC. https://angular.dev/
* License: MIT
*/
// packages/zone.js/lib/extra/cordova.js
function patchCordova(Zone2) {
Zone2.__load_patch("cordova", (global, Zone3, api) => {
if (global.cordova) {
const SUCCESS_SOURCE = "cordova.exec.success";
const ERROR_SOURCE = "cordova.exec.error";
const FUNCTION = "function";
const nativeExec = api.patchMethod(global.cordova, "exec", () => function(self, args) {
if (args.length > 0 && typeof args[0] === FUNCTION) {
args[0] = Zone3.current.wrap(args[0], SUCCESS_SOURCE);
}
if (args.length > 1 && typeof args[1] === FUNCTION) {
args[1] = Zone3.current.wrap(args[1], ERROR_SOURCE);
}
return nativeExec.apply(self, args);
});
}
});
Zone2.__load_patch("cordova.FileReader", (global, Zone3) => {
if (global.cordova && typeof global["FileReader"] !== "undefined") {
document.addEventListener("deviceReady", () => {
const FileReader = global["FileReader"];
["abort", "error", "load", "loadstart", "loadend", "progress"].forEach((prop) => {
const eventNameSymbol = Zone3.__symbol__("ON_PROPERTY" + prop);
Object.defineProperty(FileReader.prototype, eventNameSymbol, {
configurable: true,
get: function() {
return this._realReader && this._realReader[eventNameSymbol];
}
});
});
});
}
});
}
// packages/zone.js/lib/extra/rollup-cordova.js
patchCordova(Zone);