zone-patch-cordova.umd.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. /**
  3. * @license Angular v<unknown>
  4. * (c) 2010-2025 Google LLC. https://angular.io/
  5. * License: MIT
  6. */
  7. (function (factory) {
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. factory();
  10. })((function () {
  11. 'use strict';
  12. function patchCordova(Zone) {
  13. Zone.__load_patch('cordova', function (global, Zone, api) {
  14. if (global.cordova) {
  15. var SUCCESS_SOURCE_1 = 'cordova.exec.success';
  16. var ERROR_SOURCE_1 = 'cordova.exec.error';
  17. var FUNCTION_1 = 'function';
  18. var nativeExec_1 = api.patchMethod(global.cordova, 'exec', function () { return function (self, args) {
  19. if (args.length > 0 && typeof args[0] === FUNCTION_1) {
  20. args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE_1);
  21. }
  22. if (args.length > 1 && typeof args[1] === FUNCTION_1) {
  23. args[1] = Zone.current.wrap(args[1], ERROR_SOURCE_1);
  24. }
  25. return nativeExec_1.apply(self, args);
  26. }; });
  27. }
  28. });
  29. Zone.__load_patch('cordova.FileReader', function (global, Zone) {
  30. if (global.cordova && typeof global['FileReader'] !== 'undefined') {
  31. document.addEventListener('deviceReady', function () {
  32. var FileReader = global['FileReader'];
  33. ['abort', 'error', 'load', 'loadstart', 'loadend', 'progress'].forEach(function (prop) {
  34. var eventNameSymbol = Zone.__symbol__('ON_PROPERTY' + prop);
  35. Object.defineProperty(FileReader.prototype, eventNameSymbol, {
  36. configurable: true,
  37. get: function () {
  38. return this._realReader && this._realReader[eventNameSymbol];
  39. },
  40. });
  41. });
  42. });
  43. }
  44. });
  45. }
  46. patchCordova(Zone);
  47. }));