refactor: use "as const" for constant mappings (#28980)
This commit is contained in:
parent
a699dfdf83
commit
961b74b2ac
4 changed files with 11 additions and 11 deletions
|
@ -2,10 +2,10 @@ import { app, BrowserWindow } from 'electron/main';
|
||||||
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
|
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
|
||||||
const dialogBinding = process._linkedBinding('electron_browser_dialog');
|
const dialogBinding = process._linkedBinding('electron_browser_dialog');
|
||||||
|
|
||||||
const DialogType = {
|
enum DialogType {
|
||||||
OPEN: 'OPEN' as 'OPEN',
|
OPEN = 'OPEN',
|
||||||
SAVE: 'SAVE' as 'SAVE'
|
SAVE = 'SAVE'
|
||||||
};
|
}
|
||||||
|
|
||||||
enum SaveFileDialogProperties {
|
enum SaveFileDialogProperties {
|
||||||
createDirectory = 1 << 0,
|
createDirectory = 1 << 0,
|
||||||
|
@ -72,7 +72,7 @@ const setupSaveDialogProperties = (properties: (keyof typeof SaveFileDialogPrope
|
||||||
return dialogProperties;
|
return dialogProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupDialogProperties = (type: keyof typeof DialogType, properties: string[]): number => {
|
const setupDialogProperties = (type: DialogType, properties: string[]): number => {
|
||||||
if (type === DialogType.OPEN) {
|
if (type === DialogType.OPEN) {
|
||||||
return setupOpenDialogProperties(properties as (keyof typeof OpenFileDialogProperties)[]);
|
return setupOpenDialogProperties(properties as (keyof typeof OpenFileDialogProperties)[]);
|
||||||
} else if (type === DialogType.SAVE) {
|
} else if (type === DialogType.SAVE) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ const PDFPageSizes: Record<string, ElectronInternal.MediaSize> = {
|
||||||
width_microns: 279400,
|
width_microns: 279400,
|
||||||
custom_display_name: 'Tabloid'
|
custom_display_name: 'Tabloid'
|
||||||
}
|
}
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
// The minimum micron size Chromium accepts is that where:
|
// The minimum micron size Chromium accepts is that where:
|
||||||
// Per printing/units.h:
|
// Per printing/units.h:
|
||||||
|
@ -109,7 +109,7 @@ const defaultPrintingSetting = {
|
||||||
printerType: 2,
|
printerType: 2,
|
||||||
title: undefined as string | undefined,
|
title: undefined as string | undefined,
|
||||||
url: undefined as string | undefined
|
url: undefined as string | undefined
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
// JavaScript implementations of WebContents.
|
// JavaScript implementations of WebContents.
|
||||||
const binding = process._linkedBinding('electron_browser_web_contents');
|
const binding = process._linkedBinding('electron_browser_web_contents');
|
||||||
|
@ -191,7 +191,7 @@ WebContents.prototype.executeJavaScriptInIsolatedWorld = async function (worldId
|
||||||
|
|
||||||
let pendingPromise: Promise<any> | undefined;
|
let pendingPromise: Promise<any> | undefined;
|
||||||
WebContents.prototype.printToPDF = async function (options) {
|
WebContents.prototype.printToPDF = async function (options) {
|
||||||
const printSettings = {
|
const printSettings: Record<string, any> = {
|
||||||
...defaultPrintingSetting,
|
...defaultPrintingSetting,
|
||||||
requestID: getNextId()
|
requestID: getNextId()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const webViewEvents: Record<string, string[]> = {
|
export const webViewEvents: Record<string, readonly string[]> = {
|
||||||
'load-commit': ['url', 'isMainFrame'],
|
'load-commit': ['url', 'isMainFrame'],
|
||||||
'did-attach': [],
|
'did-attach': [],
|
||||||
'did-finish-load': [],
|
'did-finish-load': [],
|
||||||
|
@ -33,4 +33,4 @@ export const webViewEvents: Record<string, string[]> = {
|
||||||
'found-in-page': ['result'],
|
'found-in-page': ['result'],
|
||||||
'did-change-theme-color': ['themeColor'],
|
'did-change-theme-color': ['themeColor'],
|
||||||
'update-target-url': ['url']
|
'update-target-url': ['url']
|
||||||
};
|
} as const;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
||||||
|
|
||||||
const DEPRECATED_EVENTS: Record<string, string> = {
|
const DEPRECATED_EVENTS: Record<string, string> = {
|
||||||
'page-title-updated': 'page-title-set'
|
'page-title-updated': 'page-title-set'
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
const dispatchEvent = function (
|
const dispatchEvent = function (
|
||||||
webView: WebViewImpl, eventName: string, eventKey: string, ...args: Array<any>
|
webView: WebViewImpl, eventName: string, eventKey: string, ...args: Array<any>
|
||||||
|
|
Loading…
Reference in a new issue