chore: tsify more of lib (#23721)

* chore: tsify more of lib

* Update lib/browser/api/session.ts

Co-authored-by: Jeremy Apthorp <jeremya@chromium.org>

Co-authored-by: Jeremy Apthorp <jeremya@chromium.org>
This commit is contained in:
Samuel Attard 2020-05-22 12:46:22 -07:00 committed by GitHub
parent 762f7bcca2
commit 9bc5e98238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 66 additions and 94 deletions

View file

@ -1,11 +1,10 @@
'use strict';
import { EventEmitter } from 'events';
const { EventEmitter } = require('events');
const { BrowserView } = process.electronBinding('browser_view');
Object.setPrototypeOf(BrowserView.prototype, EventEmitter.prototype);
BrowserView.fromWebContents = (webContents) => {
BrowserView.fromWebContents = (webContents: Electron.WebContents) => {
for (const view of BrowserView.getAllViews()) {
if (view.webContents.equal(webContents)) return view;
}
@ -13,4 +12,4 @@ BrowserView.fromWebContents = (webContents) => {
return null;
};
module.exports = BrowserView;
export default BrowserView;

View file

@ -1,2 +0,0 @@
'use strict';
module.exports = process.electronBinding('content_tracing');

View file

@ -0,0 +1 @@
export default process.electronBinding('content_tracing');

View file

@ -1,3 +0,0 @@
'use strict';
module.exports = process.electronBinding('global_shortcut').globalShortcut;

View file

@ -0,0 +1 @@
export default process.electronBinding('global_shortcut').globalShortcut;

View file

@ -1,22 +1,24 @@
'use strict';
import { EventEmitter } from 'events';
const { deprecate } = require('electron');
let _inAppPurchase;
if (process.platform === 'darwin') {
const { EventEmitter } = require('events');
const { inAppPurchase, InAppPurchase } = process.electronBinding('in_app_purchase');
// inAppPurchase is an EventEmitter.
Object.setPrototypeOf(InAppPurchase.prototype, EventEmitter.prototype);
EventEmitter.call(inAppPurchase);
module.exports = inAppPurchase;
_inAppPurchase = inAppPurchase;
} else {
module.exports = {
purchaseProduct: (productID, quantity, callback) => {
_inAppPurchase = new EventEmitter();
Object.assign(_inAppPurchase, {
purchaseProduct: () => {
throw new Error('The inAppPurchase module can only be used on macOS');
},
canMakePayments: () => false,
getReceiptURL: () => ''
};
});
}
export default _inAppPurchase;

View file

@ -1,7 +0,0 @@
'use strict';
const { Notification, isSupported } = process.electronBinding('notification');
Notification.isSupported = isSupported;
module.exports = Notification;

View file

@ -0,0 +1,5 @@
const { Notification: ElectronNotification, isSupported } = process.electronBinding('notification');
ElectronNotification.isSupported = isSupported;
export default ElectronNotification;

View file

@ -1,3 +0,0 @@
'use strict';
module.exports = process.electronBinding('power_save_blocker').powerSaveBlocker;

View file

@ -0,0 +1 @@
export default process.electronBinding('power_save_blocker').powerSaveBlocker;

View file

@ -1,17 +0,0 @@
'use strict';
const { EventEmitter } = require('events');
const { app, deprecate } = require('electron');
const { fromPartition } = process.electronBinding('session');
// Public API.
Object.defineProperties(exports, {
defaultSession: {
enumerable: true,
get () { return fromPartition(''); }
},
fromPartition: {
enumerable: true,
value: fromPartition
}
});

View file

@ -0,0 +1,8 @@
const { fromPartition } = process.electronBinding('session');
export default {
fromPartition,
get defaultSession () {
return fromPartition('');
}
};

View file

@ -1,5 +1,3 @@
'use strict';
const { Tray } = process.electronBinding('tray');
module.exports = Tray;
export default Tray;

View file

@ -1,5 +1,3 @@
'use strict';
const { View } = process.electronBinding('view');
module.exports = View;
export default View;

View file

@ -1,8 +1,7 @@
const electron = require('electron');
import { View } from 'electron';
const { View } = electron;
const { ImageView } = process.electronBinding('image_view');
Object.setPrototypeOf(ImageView.prototype, View.prototype);
module.exports = ImageView;
export default ImageView;

View file

@ -1,10 +1,7 @@
'use strict';
import { View } from 'electron';
const electron = require('electron');
const { View } = electron;
const { WebContentsView } = process.electronBinding('web_contents_view');
Object.setPrototypeOf(WebContentsView.prototype, View.prototype);
module.exports = WebContentsView;
export default WebContentsView;