zone-patch-electron.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  10. typeof define === 'function' && define.amd ? define(factory) :
  11. (factory());
  12. }(this, (function () { 'use strict';
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. Zone.__load_patch('electron', function (global, Zone, api) {
  21. function patchArguments(target, name, source) {
  22. return api.patchMethod(target, name, function (delegate) { return function (self, args) {
  23. return delegate && delegate.apply(self, api.bindArguments(args, source));
  24. }; });
  25. }
  26. var _a = require('electron'), desktopCapturer = _a.desktopCapturer, shell = _a.shell, CallbacksRegistry = _a.CallbacksRegistry;
  27. // patch api in renderer process directly
  28. // desktopCapturer
  29. if (desktopCapturer) {
  30. patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources');
  31. }
  32. // shell
  33. if (shell) {
  34. patchArguments(shell, 'openExternal', 'electron.shell.openExternal');
  35. }
  36. // patch api in main process through CallbackRegistry
  37. if (!CallbacksRegistry) {
  38. return;
  39. }
  40. patchArguments(CallbacksRegistry.prototype, 'add', 'CallbackRegistry.add');
  41. });
  42. })));