refactor: convert more files to typescript (#16820)

This commit is contained in:
Samuel Attard 2019-02-12 06:22:33 -08:00 committed by John Kleinschmidt
parent cfbdc40814
commit 01c442de64
16 changed files with 169 additions and 90 deletions

View file

@ -0,0 +1,29 @@
import { app, session } from 'electron'
// Global protocol APIs.
const protocol = process.atomBinding('protocol')
// Fallback protocol APIs of default session.
Object.setPrototypeOf(protocol, new Proxy({}, {
get (target, property) {
if (!app.isReady()) return
const protocol = session.defaultSession!.protocol
if (!Object.getPrototypeOf(protocol).hasOwnProperty(property)) return
// Returning a native function directly would throw error.
return (...args: any[]) => (protocol[property as keyof Electron.Protocol] as Function)(...args)
},
ownKeys () {
if (!app.isReady()) return []
return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession!.protocol))
},
getOwnPropertyDescriptor (target) {
return { configurable: true, enumerable: true }
}
}))
export default protocol