mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: update app module property support (#22747)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import { deprecate, Menu } from 'electron'
|
||||
import { Menu } from 'electron'
|
||||
import { EventEmitter } from 'events'
|
||||
|
||||
const bindings = process.electronBinding('app')
|
||||
@@ -17,6 +17,29 @@ let dockMenu: Electron.Menu | null = null
|
||||
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
|
||||
EventEmitter.call(app as any)
|
||||
|
||||
// Properties.
|
||||
|
||||
const nativeASGetter = app.isAccessibilitySupportEnabled
|
||||
const nativeASSetter = app.setAccessibilitySupportEnabled
|
||||
Object.defineProperty(App.prototype, 'accessibilitySupportEnabled', {
|
||||
get: () => nativeASGetter.call(app),
|
||||
set: (enabled) => nativeASSetter.call(app, enabled)
|
||||
})
|
||||
|
||||
const nativeBCGetter = app.getBadgeCount
|
||||
const nativeBCSetter = app.setBadgeCount
|
||||
Object.defineProperty(App.prototype, 'badgeCount', {
|
||||
get: () => nativeBCGetter.call(app),
|
||||
set: (count) => nativeBCSetter.call(app, count)
|
||||
})
|
||||
|
||||
const nativeNGetter = app.getName
|
||||
const nativeNSetter = app.setName
|
||||
Object.defineProperty(App.prototype, 'name', {
|
||||
get: () => nativeNGetter.call(app),
|
||||
set: (name) => nativeNSetter.call(app, name)
|
||||
})
|
||||
|
||||
Object.assign(app, {
|
||||
commandLine: {
|
||||
hasSwitch: (theSwitch: string) => commandLine.hasSwitch(String(theSwitch)),
|
||||
@@ -112,11 +135,6 @@ for (const name of events) {
|
||||
})
|
||||
}
|
||||
|
||||
// Property Deprecations
|
||||
deprecate.fnToProperty(App.prototype, 'accessibilitySupportEnabled', '_isAccessibilitySupportEnabled', '_setAccessibilitySupportEnabled')
|
||||
deprecate.fnToProperty(App.prototype, 'badgeCount', '_getBadgeCount', '_setBadgeCount')
|
||||
deprecate.fnToProperty(App.prototype, 'name', '_getName', '_setName')
|
||||
|
||||
// Wrappers for native classes.
|
||||
const { DownloadItem } = process.electronBinding('download_item')
|
||||
Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype)
|
||||
|
||||
Reference in New Issue
Block a user