From 79414aa3e14ca5a95f2217c6cbd5c218fc5c179e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Mon, 10 Jun 2019 10:31:42 -0700 Subject: [PATCH] Bumped electron version Summary: We in React VR were need newer Chrome DevTools version to make our plugin work properly. Chromium version with required fixes were shipped in electron 5.0.0. This diff bumps electron version and explicitly allows node integration (accessing require, process and other node related functions from window object in index.html), because it was disabled by default in 5.0.0. Reviewed By: jknoxville Differential Revision: D15693539 fbshipit-source-id: 4f71a07b2afaa489aec46940c924f4ad30ad0413 --- flow-typed/electron-menu.js | 30 +- ...{electron-v4.0.5.js => electron-v5.0.2.js} | 443 +++++++++++++----- package.json | 6 +- src/MenuBar.js | 4 +- .../__snapshots__/App.electron.js.snap | 2 +- src/chrome/UserAccount.js | 2 +- src/ui/components/Button.js | 2 +- src/ui/components/ContextMenu.js | 2 +- src/ui/components/ContextMenuProvider.js | 2 +- .../data-inspector/DataInspector.js | 6 +- .../components/elements-inspector/elements.js | 2 +- src/ui/components/searchable/FilterToken.js | 2 +- src/ui/components/table/ManagedTable.js | 2 +- src/ui/components/table/TableHead.js | 2 +- static/index.js | 1 + yarn.lock | 43 +- 16 files changed, 382 insertions(+), 169 deletions(-) rename flow-typed/npm/{electron-v4.0.5.js => electron-v5.0.2.js} (91%) diff --git a/flow-typed/electron-menu.js b/flow-typed/electron-menu.js index 7992488ec..73775d1f3 100644 --- a/flow-typed/electron-menu.js +++ b/flow-typed/electron-menu.js @@ -5,9 +5,6 @@ * @format */ -type Electron$BrowserWindow = any; -type Electron$NativeImage = any; - type Electron$MenuRoles = | 'undo' | 'redo' @@ -38,7 +35,7 @@ type Electron$MenuType = | 'checkbox' | 'radio'; -type Electron$MenuItemOptions = { +type MenuItemConstructorOptions = {| click?: ( menuItem: Electron$MenuItem, browserWindow: Object, @@ -53,33 +50,14 @@ type Electron$MenuItemOptions = { enabled?: boolean, visible?: boolean, checked?: boolean, - submenu?: Electron$Menu | Array, + submenu?: Array, id?: string, position?: string, -}; +|}; declare class Electron$MenuItem { - constructor(options: Electron$MenuItemOptions): Electron$MenuItem; + constructor(options: MenuItemConstructorOptions): Electron$MenuItem; enabled: boolean; visible: boolean; checked: boolean; } - -declare class Electron$Menu { - static setApplicationMenu: (menu: Electron$Menu) => void; - static getApplicationMenu: () => ?Electron$Menu; - static sendActionToFirstResponder: (action: string) => void; - static buildFromTemplate: ( - templates: Array, - ) => Electron$Menu; - popup: ( - browserWindow: Object, - x?: number, - y?: number, - positioningItem?: number, - ) => void; - popup: (x?: number, y?: number, positioningItem?: number) => void; - append: (menuItem: Electron$MenuItem) => void; - insert: (pos: number, menuItem: Electron$MenuItem) => void; - items: Array; -} diff --git a/flow-typed/npm/electron-v4.0.5.js b/flow-typed/npm/electron-v5.0.2.js similarity index 91% rename from flow-typed/npm/electron-v4.0.5.js rename to flow-typed/npm/electron-v5.0.2.js index c65bd1acd..ec16ad033 100644 --- a/flow-typed/npm/electron-v4.0.5.js +++ b/flow-typed/npm/electron-v5.0.2.js @@ -5,33 +5,44 @@ * @format * @flow * - * This is an autogenerated libdef for: electron-v4.0.5 renderer process + * This is an autogenerated libdef for: electron-v5.0.2 renderer process */ declare module 'electron' { declare module.exports: { clipboard: { - readText: (type?: ?string) => string, - writeText: (text: string, type?: ?string) => void, - readHTML: (type?: ?string) => string, - writeHTML: (markup: string, type?: ?string) => void, - readImage: (type?: ?string) => NativeImage, - writeImage: (image: NativeImage, type?: ?string) => void, - readRTF: (type?: ?string) => string, - writeRTF: (text: string, type?: ?string) => void, + readText: (type?: ?'selection' | 'clipboard') => string, + writeText: (text: string, type?: ?'selection' | 'clipboard') => void, + readHTML: (type?: ?'selection' | 'clipboard') => string, + writeHTML: (markup: string, type?: ?'selection' | 'clipboard') => void, + readImage: (type?: ?'selection' | 'clipboard') => NativeImage, + writeImage: ( + image: NativeImage, + type?: ?'selection' | 'clipboard', + ) => void, + readRTF: (type?: ?'selection' | 'clipboard') => string, + writeRTF: (text: string, type?: ?'selection' | 'clipboard') => void, readBookmark: () => { title: string, url: string, }, - writeBookmark: (title: string, url: string, type?: ?string) => void, + writeBookmark: ( + title: string, + url: string, + type?: ?'selection' | 'clipboard', + ) => void, readFindText: () => string, writeFindText: (text: string) => void, - clear: (type?: ?string) => void, - availableFormats: (type?: ?string) => Array, - has: (format: string, type?: ?string) => boolean, + clear: (type?: ?'selection' | 'clipboard') => void, + availableFormats: (type?: ?'selection' | 'clipboard') => Array, + has: (format: string, type?: ?'selection' | 'clipboard') => boolean, read: (format: string) => string, readBuffer: (format: string) => Buffer, - writeBuffer: (format: string, buffer: Buffer, type?: ?string) => void, + writeBuffer: ( + format: string, + buffer: Buffer, + type?: ?'selection' | 'clipboard', + ) => void, write: ( data: { text?: ?string, @@ -40,7 +51,7 @@ declare module 'electron' { rtf?: ?string, bookmark?: ?string, }, - type?: ?string, + type?: ?'selection' | 'clipboard', ) => void, }, crashReporter: { @@ -66,9 +77,15 @@ declare module 'electron' { options: { types: Array, thumbnailSize?: ?Size, + fetchWindowIcons?: ?boolean, }, callback: Function, ) => void, + getSources: (options: { + types: Array, + thumbnailSize?: ?Size, + fetchWindowIcons?: ?boolean, + }) => Promise, }, ipcRenderer: { on: (channel: string, listener: Function) => void, @@ -134,9 +151,11 @@ declare module 'electron' { on: (eventName: 'loaded', callback: () => void) => void, once: (eventName: 'loaded', callback: () => void) => void, defaultApp?: ?boolean, + isMainFrame?: ?boolean, mas?: ?boolean, noAsar?: ?boolean, noDeprecation?: ?boolean, + enablePromiseAPIs?: ?boolean, resourcesPath?: ?string, sandboxed?: ?boolean, throwDeprecation?: ?boolean, @@ -178,11 +197,18 @@ declare module 'electron' { }, callback: Function, ) => void, + getFileIcon: ( + path: string, + options?: ?{ + size: 'small' | 'normal' | 'large', + }, + ) => Promise, setPath: (name: string, path: string) => void, getVersion: () => string, getName: () => string, setName: (name: string) => void, getLocale: () => string, + getLocaleCountryCode: () => string, addRecentDocument: (path: string) => void, clearRecentDocuments: () => void, setAsDefaultProtocolClient: ( @@ -262,14 +288,15 @@ declare module 'electron' { applicationName?: ?string, applicationVersion?: ?string, copyright?: ?string, - credits?: ?string, version?: ?string, + credits?: ?string, + website?: ?string, + iconPath?: ?string, }) => void, startAccessingSecurityScopedResource: ( bookmarkData: string, ) => Function, enableSandbox: () => void, - enableMixedSandbox: () => void, isInApplicationsFolder: () => boolean, moveToApplicationsFolder: () => boolean, on: (( @@ -403,6 +430,10 @@ declare module 'electron' { workingDirectory: string, ) => void, ) => void) & + (( + eventName: 'desktop-capturer-get-sources', + callback: (event: Event, webContents: WebContents) => void, + ) => void) & (( eventName: 'remote-require', callback: ( @@ -574,6 +605,10 @@ declare module 'electron' { workingDirectory: string, ) => void, ) => void) & + (( + eventName: 'desktop-capturer-get-sources', + callback: (event: Event, webContents: WebContents) => void, + ) => void) & (( eventName: 'remote-require', callback: ( @@ -618,6 +653,8 @@ declare module 'electron' { commandLine: { appendSwitch?: ?Function, appendArgument?: ?Function, + hasSwitch?: ?Function, + getSwitchValue?: ?Function, }, dock: { bounce?: ?Function, @@ -673,27 +710,38 @@ declare module 'electron' { ((eventName: 'before-quit-for-update', callback: () => void) => void), }, clipboard: { - readText: (type?: ?string) => string, - writeText: (text: string, type?: ?string) => void, - readHTML: (type?: ?string) => string, - writeHTML: (markup: string, type?: ?string) => void, - readImage: (type?: ?string) => NativeImage, - writeImage: (image: NativeImage, type?: ?string) => void, - readRTF: (type?: ?string) => string, - writeRTF: (text: string, type?: ?string) => void, + readText: (type?: ?'selection' | 'clipboard') => string, + writeText: (text: string, type?: ?'selection' | 'clipboard') => void, + readHTML: (type?: ?'selection' | 'clipboard') => string, + writeHTML: (markup: string, type?: ?'selection' | 'clipboard') => void, + readImage: (type?: ?'selection' | 'clipboard') => NativeImage, + writeImage: ( + image: NativeImage, + type?: ?'selection' | 'clipboard', + ) => void, + readRTF: (type?: ?'selection' | 'clipboard') => string, + writeRTF: (text: string, type?: ?'selection' | 'clipboard') => void, readBookmark: () => { title: string, url: string, }, - writeBookmark: (title: string, url: string, type?: ?string) => void, + writeBookmark: ( + title: string, + url: string, + type?: ?'selection' | 'clipboard', + ) => void, readFindText: () => string, writeFindText: (text: string) => void, - clear: (type?: ?string) => void, - availableFormats: (type?: ?string) => Array, - has: (format: string, type?: ?string) => boolean, + clear: (type?: ?'selection' | 'clipboard') => void, + availableFormats: (type?: ?'selection' | 'clipboard') => Array, + has: (format: string, type?: ?'selection' | 'clipboard') => boolean, read: (format: string) => string, readBuffer: (format: string) => Buffer, - writeBuffer: (format: string, buffer: Buffer, type?: ?string) => void, + writeBuffer: ( + format: string, + buffer: Buffer, + type?: ?'selection' | 'clipboard', + ) => void, write: ( data: { text?: ?string, @@ -702,28 +750,21 @@ declare module 'electron' { rtf?: ?string, bookmark?: ?string, }, - type?: ?string, + type?: ?'selection' | 'clipboard', ) => void, }, contentTracing: { getCategories: (callback: Function) => void, + getCategories: () => Promise, startRecording: ( options: TraceCategoriesAndOptions | TraceConfig, callback: Function, ) => void, + startRecording: ( + options: TraceCategoriesAndOptions | TraceConfig, + ) => Promise, stopRecording: (resultFilePath: string, callback: Function) => void, - startMonitoring: ( - options: { - categoryFilter: string, - traceOptions: string, - }, - callback: Function, - ) => void, - stopMonitoring: (callback: Function) => void, - captureMonitoringSnapshot: ( - resultFilePath: string, - callback: Function, - ) => void, + stopRecording: (resultFilePath: string) => Promise, getTraceBufferUsage: (callback: Function) => void, }, crashReporter: { @@ -766,7 +807,7 @@ declare module 'electron' { securityScopedBookmarks?: ?boolean, }, callback?: ?Function, - ) => Array) & + ) => Array | typeof undefined) & (( options: { title?: ?string, @@ -787,7 +828,7 @@ declare module 'electron' { securityScopedBookmarks?: ?boolean, }, callback?: ?Function, - ) => Array), + ) => Array | typeof undefined), showSaveDialog: (( browserWindow?: ?BrowserWindow, options: { @@ -801,7 +842,7 @@ declare module 'electron' { securityScopedBookmarks?: ?boolean, }, callback?: ?Function, - ) => string) & + ) => string | typeof undefined) & (( options: { title?: ?string, @@ -814,7 +855,7 @@ declare module 'electron' { securityScopedBookmarks?: ?boolean, }, callback?: ?Function, - ) => string), + ) => string | typeof undefined), showMessageBox: (( browserWindow?: ?BrowserWindow, options: { @@ -868,7 +909,8 @@ declare module 'electron' { ) => void), }, globalShortcut: { - register: (accelerator: Accelerator, callback: Function) => void, + register: (accelerator: Accelerator, callback: Function) => boolean, + registerAll: (accelerators: Array, callback: Function) => void, isRegistered: (accelerator: Accelerator) => boolean, unregister: (accelerator: Accelerator) => void, unregisterAll: () => void, @@ -981,9 +1023,11 @@ declare module 'electron' { on: (eventName: 'loaded', callback: () => void) => void, once: (eventName: 'loaded', callback: () => void) => void, defaultApp?: ?boolean, + isMainFrame?: ?boolean, mas?: ?boolean, noAsar?: ?boolean, noDeprecation?: ?boolean, + enablePromiseAPIs?: ?boolean, resourcesPath?: ?string, sandboxed?: ?boolean, throwDeprecation?: ?boolean, @@ -997,13 +1041,9 @@ declare module 'electron' { }, }, protocol: { - registerStandardSchemes: ( - schemes: Array, - options?: ?{ - secure?: ?boolean, - }, + registerSchemesAsPrivileged: ( + customSchemes: Array, ) => void, - registerServiceWorkerSchemes: (schemes: Array) => void, registerFileProtocol: ( scheme: string, handler: Function, @@ -1031,6 +1071,7 @@ declare module 'electron' { ) => void, unregisterProtocol: (scheme: string, completion?: ?Function) => void, isProtocolHandled: (scheme: string, callback: Function) => void, + isProtocolHandled: (scheme: string) => Promise, interceptFileProtocol: ( scheme: string, handler: Function, @@ -1119,14 +1160,20 @@ declare module 'electron' { shell: { showItemInFolder: (fullPath: string) => boolean, openItem: (fullPath: string) => boolean, + openExternalSync: ( + url: string, + options?: ?{ + activate?: ?boolean, + workingDirectory?: ?string, + }, + ) => boolean, openExternal: ( url: string, options?: ?{ activate?: ?boolean, workingDirectory?: ?string, }, - callback?: ?Function, - ) => boolean, + ) => Promise, moveItemToTrash: (fullPath: string) => boolean, beep: () => void, writeShortcutLink: ( @@ -1139,7 +1186,11 @@ declare module 'electron' { systemPreferences: { isDarkMode: () => boolean, isSwipeTrackingFromScrollEventsEnabled: () => boolean, - postNotification: (event: string, userInfo: {}) => void, + postNotification: ( + event: string, + userInfo: {}, + deliverImmediately?: ?boolean, + ) => void, postLocalNotification: (event: string, userInfo: {}) => void, postWorkspaceNotification: (event: string, userInfo: {}) => void, subscribeNotification: (event: string, callback: Function) => number, @@ -1173,6 +1224,7 @@ declare module 'electron' { getAccentColor: () => string, getColor: ( color: + | '3d-dark-shadow' | '3d-dark-shadow' | '3d-face' | '3d-highlight' @@ -1202,9 +1254,56 @@ declare module 'electron' { | 'scrollbar' | 'window' | 'window-frame' - | 'window-text', + | 'window-text' + | 'alternate-selected-control-text' + | 'alternate-selected-control-text' + | 'control-background' + | 'control' + | 'control-text' + | 'disabled-control-text' + | 'find-highlight' + | 'grid' + | 'header-text' + | 'highlight' + | 'keyboard-focus-indicator' + | 'label' + | 'link' + | 'placeholder-text' + | 'quaternary-label' + | 'scrubber-textured-background' + | 'secondary-label' + | 'selected-content-background' + | 'selected-control' + | 'selected-control-text' + | 'selected-menu-item' + | 'selected-text-background' + | 'selected-text' + | 'separator' + | 'shadow' + | 'tertiary-label' + | 'text-background' + | 'text' + | 'under-page-background' + | 'unemphasized-selected-content-background' + | 'unemphasized-selected-text-background' + | 'unemphasized-selected-text' + | 'window-background' + | 'window-frame-text', ) => string, + getSystemColor: ( + color: + | 'blue' + | 'brown' + | 'gray' + | 'green' + | 'orange' + | 'pink' + | 'purple' + | 'red' + | 'yellow', + ) => void, isInvertedColorScheme: () => boolean, + isHighContrastColorScheme: () => boolean, getEffectiveAppearance: () => 'dark' | 'light' | 'unknown', getAppLevelAppearance: () => 'dark' | 'light' | 'unknown', setAppLevelAppearance: (appearance: string | null) => void, @@ -1225,6 +1324,10 @@ declare module 'electron' { eventName: 'inverted-color-scheme-changed', callback: (event: Event, invertedColorScheme: boolean) => void, ) => void) & + (( + eventName: 'high-contrast-color-scheme-changed', + callback: (event: Event, highContrastColorScheme: boolean) => void, + ) => void) & (( eventName: 'appearance-changed', callback: (newAppearance: 'dark' | 'light') => void, @@ -1241,6 +1344,10 @@ declare module 'electron' { eventName: 'inverted-color-scheme-changed', callback: (event: Event, invertedColorScheme: boolean) => void, ) => void) & + (( + eventName: 'high-contrast-color-scheme-changed', + callback: (event: Event, highContrastColorScheme: boolean) => void, + ) => void) & (( eventName: 'appearance-changed', callback: (newAppearance: 'dark' | 'light') => void, @@ -1320,14 +1427,20 @@ declare module 'electron' { shell: { showItemInFolder: (fullPath: string) => boolean, openItem: (fullPath: string) => boolean, + openExternalSync: ( + url: string, + options?: ?{ + activate?: ?boolean, + workingDirectory?: ?string, + }, + ) => boolean, openExternal: ( url: string, options?: ?{ activate?: ?boolean, workingDirectory?: ?string, }, - callback?: ?Function, - ) => boolean, + ) => Promise, moveItemToTrash: (fullPath: string) => boolean, beep: () => void, writeShortcutLink: ( @@ -1352,22 +1465,10 @@ declare module 'electron' { ) => void, setSpellCheckProvider: ( language: string, - autoCorrectWord: boolean, provider: { spellCheck: Function, }, ) => void, - registerURLSchemeAsBypassingCSP: (scheme: string) => void, - registerURLSchemeAsPrivileged: ( - scheme: string, - options?: ?{ - secure?: ?boolean, - bypassCSP?: ?boolean, - allowServiceWorkers?: ?boolean, - supportFetchAPI?: ?boolean, - corsEnabled?: ?boolean, - }, - ) => void, insertText: (text: string) => void, executeJavaScript: ( code: string, @@ -1392,6 +1493,14 @@ declare module 'electron' { worldId: number, securityOrigin: string, ) => void, + setIsolatedWorldInfo: ( + worldId: number, + info: { + securityOrigin?: ?string, + csp?: ?string, + name?: ?string, + }, + ) => void, getResourceUsage: () => { images: MemoryUsageDetails, scripts: MemoryUsageDetails, @@ -1457,11 +1566,23 @@ declare module 'electron' { date: Date, id: string, }; + declare type CustomScheme = { + scheme: string, + privileges?: ?{ + standard?: ?boolean, + secure?: ?boolean, + bypassCSP?: ?boolean, + allowServiceWorkers?: ?boolean, + supportFetchAPI?: ?boolean, + corsEnabled?: ?boolean, + }, + }; declare type DesktopCapturerSource = { id: string, name: string, thumbnail: NativeImage, display_id: string, + appIcon: NativeImage, }; declare type Display = { id: number, @@ -1774,13 +1895,14 @@ declare module 'electron' { callback: Function, ) => void; capturePage: ((rect?: ?Rectangle, callback: Function) => void) & - ((callback: Function) => void); + ((callback: Function) => void) & + ((rect?: ?Rectangle) => void); send: (channel: string, ...args: Array) => void; sendInputEvent: (event: {}) => void; setZoomFactor: (factor: number) => void; setZoomLevel: (level: number) => void; - getZoomFactor: (callback: Function) => void; - getZoomLevel: (callback: Function) => void; + getZoomFactor: () => number; + getZoomLevel: () => number; setVisualZoomLevelLimits: ( minimumLevel: number, maximumLevel: number, @@ -1868,7 +1990,6 @@ declare module 'electron' { callback: (channel: string, args: Array) => void, ) => void) & ((eventName: 'crashed', callback: () => void) => void) & - ((eventName: 'gpu-crashed', callback: () => void) => void) & (( eventName: 'plugin-crashed', callback: (name: string, version: string) => void, @@ -1964,7 +2085,6 @@ declare module 'electron' { callback: (channel: string, args: Array) => void, ) => void) & ((eventName: 'crashed', callback: () => void) => void) & - ((eventName: 'gpu-crashed', callback: () => void) => void) & (( eventName: 'plugin-crashed', callback: (name: string, version: string) => void, @@ -2069,6 +2189,7 @@ declare module 'electron' { devTools?: ?boolean, nodeIntegration?: ?boolean, nodeIntegrationInWorker?: ?boolean, + nodeIntegrationInSubFrames?: ?boolean, preload?: ?string, sandbox?: ?boolean, enableRemoteModule?: ?boolean, @@ -2109,6 +2230,10 @@ declare module 'electron' { safeDialogs?: ?boolean, safeDialogsMessage?: ?string, navigateOnDragDrop?: ?boolean, + autoplayPolicy?: + | ?'no-user-gesture-required' + | 'user-gesture-required' + | 'document-user-activation-required', }, }, ): BrowserWindow; @@ -2212,7 +2337,8 @@ declare module 'electron' { focusOnWebView: () => void; blurWebView: () => void; capturePage: ((rect?: ?Rectangle, callback: Function) => void) & - ((callback: Function) => void); + ((callback: Function) => void) & + ((rect?: ?Rectangle) => void); loadURL: ( url: string, options?: ?{ @@ -2225,7 +2351,7 @@ declare module 'electron' { | Array, baseURLForDataURL?: ?string, }, - ) => void; + ) => Promise; loadFile: ( filePath: string, options?: ?{ @@ -2233,9 +2359,10 @@ declare module 'electron' { search?: ?string, hash?: ?string, }, - ) => void; + ) => Promise; reload: () => void; setMenu: (menu: Menu | null) => void; + removeMenu: () => void; setProgressBar: ( progress: number, options?: ?{ @@ -2306,11 +2433,14 @@ declare module 'electron' { setTouchBar: (touchBar: TouchBar) => void; setBrowserView: (browserView: BrowserView) => void; getBrowserView: () => BrowserView | null; + addBrowserView: (browserView: BrowserView) => void; + removeBrowserView: (browserView: BrowserView) => void; + getBrowserViews: () => void; webContents: WebContents; id: number; on: (( eventName: 'page-title-updated', - callback: (event: Event, title: string) => void, + callback: (event: Event, title: string, explicitSet: boolean) => void, ) => void) & ((eventName: 'close', callback: (event: Event) => void) => void) & ((eventName: 'closed', callback: () => void) => void) & @@ -2361,7 +2491,7 @@ declare module 'electron' { ((eventName: 'new-window-for-tab', callback: () => void) => void); once: (( eventName: 'page-title-updated', - callback: (event: Event, title: string) => void, + callback: (event: Event, title: string, explicitSet: boolean) => void, ) => void) & ((eventName: 'close', callback: (event: Event) => void) => void) & ((eventName: 'closed', callback: () => void) => void) & @@ -2512,6 +2642,14 @@ declare module 'electron' { ) => void); } declare class Cookies { + get: (filter: { + url?: ?string, + name?: ?string, + domain?: ?string, + path?: ?string, + secure?: ?boolean, + session?: ?boolean, + }) => Promise; get: ( filter: { url?: ?string, @@ -2523,6 +2661,16 @@ declare module 'electron' { }, callback: Function, ) => void; + set: (details: { + url: string, + name?: ?string, + value?: ?string, + domain?: ?string, + path?: ?string, + secure?: ?boolean, + httpOnly?: ?boolean, + expirationDate?: ?number, + }) => Promise; set: ( details: { url: string, @@ -2536,7 +2684,9 @@ declare module 'electron' { }, callback: Function, ) => void; + remove: (url: string, name: string) => Promise; remove: (url: string, name: string, callback: Function) => void; + flushStore: () => Promise; flushStore: (callback: Function) => void; on: ( eventName: 'changed', @@ -2576,6 +2726,7 @@ declare module 'electron' { commandParams?: ?{}, callback?: ?Function, ) => void; + sendCommand: (method: string, commandParams?: ?{}) => Promise; on: (( eventName: 'detach', callback: (event: Event, reason: string) => void, @@ -2596,6 +2747,8 @@ declare module 'electron' { declare class DownloadItem { setSavePath: (path: string) => void; getSavePath: () => string; + setSaveDialogOptions: (options: SaveDialogOptions) => void; + getSaveDialogOptions: () => SaveDialogOptions; pause: () => void; isPaused: () => boolean; resume: () => void; @@ -2658,7 +2811,7 @@ declare module 'electron' { static getApplicationMenu: () => Menu | null; static sendActionToFirstResponder: (action: string) => void; static buildFromTemplate: ( - template: Array, + template: Array | Array, ) => Menu; popup: ( options?: ?{ @@ -2694,7 +2847,38 @@ declare module 'electron' { declare class MenuItem { constructor(options: { click?: ?Function, - role?: ?string, + role?: + | ?'undo' + | 'redo' + | 'cut' + | 'copy' + | 'paste' + | 'pasteandmatchstyle' + | 'delete' + | 'selectall' + | 'reload' + | 'forcereload' + | 'toggledevtools' + | 'resetzoom' + | 'zoomin' + | 'zoomout' + | 'togglefullscreen' + | 'window' + | 'minimize' + | 'close' + | 'help' + | 'about' + | 'services' + | 'hide' + | 'hideothers' + | 'unhide' + | 'quit' + | 'startspeaking' + | 'stopspeaking' + | 'close' + | 'minimize' + | 'zoom' + | 'front', type?: ?'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio', label?: ?string, sublabel?: ?string, @@ -3021,7 +3205,7 @@ declare module 'electron' { | Array, baseURLForDataURL?: ?string, }, - ) => void; + ) => Promise; loadFile: ( filePath: string, options?: ?{ @@ -3029,7 +3213,7 @@ declare module 'electron' { search?: ?string, hash?: ?string, }, - ) => void; + ) => Promise; downloadURL: (url: string) => void; getURL: () => string; getTitle: () => string; @@ -3064,9 +3248,9 @@ declare module 'electron' { isAudioMuted: () => boolean; isCurrentlyAudible: () => boolean; setZoomFactor: (factor: number) => void; - getZoomFactor: (callback: Function) => void; + getZoomFactor: () => number; setZoomLevel: (level: number) => void; - getZoomLevel: (callback: Function) => void; + getZoomLevel: () => number; setVisualZoomLevelLimits: ( minimumLevel: number, maximumLevel: number, @@ -3103,6 +3287,7 @@ declare module 'electron' { ) => void; capturePage: ((rect?: ?Rectangle, callback: Function) => void) & ((callback: Function) => void); + capturePage: (rect?: ?Rectangle) => void; hasServiceWorker: (callback: Function) => void; unregisterServiceWorker: (callback: Function) => void; getPrinters: () => Array; @@ -3131,6 +3316,7 @@ declare module 'electron' { openDevTools: ( options?: ?{ mode: 'right' | 'bottom' | 'undocked' | 'detach', + activate?: ?boolean, }, ) => void; closeDevTools: () => void; @@ -3140,6 +3326,11 @@ declare module 'electron' { inspectElement: (x: number, y: number) => void; inspectServiceWorker: () => void; send: (channel: string, ...args: Array) => void; + sendToFrame: ( + frameId: number, + channel: string, + ...args: Array + ) => void; enableDeviceEmulation: (parameters: { screenPosition: 'desktop' | 'mobile', screenSize: Size, @@ -3235,6 +3426,10 @@ declare module 'electron' { ((eventName: 'did-start-loading', callback: () => void) => void) & ((eventName: 'did-stop-loading', callback: () => void) => void) & ((eventName: 'dom-ready', callback: (event: Event) => void) => void) & + (( + eventName: 'page-title-updated', + callback: (event: Event, title: string, explicitSet: boolean) => void, + ) => void) & (( eventName: 'page-favicon-updated', callback: (event: Event, favicons: Array) => void, @@ -3521,6 +3716,22 @@ declare module 'electron' { sourceId: string, ) => void, ) => void) & + (( + eventName: 'preload-error', + callback: (event: Event, preloadPath: string, error: Error) => void, + ) => void) & + (( + eventName: 'ipc-message', + callback: (event: Event, channel: string, ...args: Array) => void, + ) => void) & + (( + eventName: 'ipc-message-sync', + callback: (event: Event, channel: string, ...args: Array) => void, + ) => void) & + (( + eventName: 'desktop-capturer-get-sources', + callback: (event: Event) => void, + ) => void) & (( eventName: 'remote-require', callback: (event: Event, moduleName: string) => void, @@ -3570,6 +3781,10 @@ declare module 'electron' { ((eventName: 'did-start-loading', callback: () => void) => void) & ((eventName: 'did-stop-loading', callback: () => void) => void) & ((eventName: 'dom-ready', callback: (event: Event) => void) => void) & + (( + eventName: 'page-title-updated', + callback: (event: Event, title: string, explicitSet: boolean) => void, + ) => void) & (( eventName: 'page-favicon-updated', callback: (event: Event, favicons: Array) => void, @@ -3856,6 +4071,22 @@ declare module 'electron' { sourceId: string, ) => void, ) => void) & + (( + eventName: 'preload-error', + callback: (event: Event, preloadPath: string, error: Error) => void, + ) => void) & + (( + eventName: 'ipc-message', + callback: (event: Event, channel: string, ...args: Array) => void, + ) => void) & + (( + eventName: 'ipc-message-sync', + callback: (event: Event, channel: string, ...args: Array) => void, + ) => void) & + (( + eventName: 'desktop-capturer-get-sources', + callback: (event: Event) => void, + ) => void) & (( eventName: 'remote-require', callback: (event: Event, moduleName: string) => void, @@ -3886,58 +4117,58 @@ declare module 'electron' { filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onBeforeSendHeaders: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onSendHeaders: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onHeadersReceived: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onResponseStarted: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onBeforeRedirect: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onCompleted: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); onErrorOccurred: (( filter?: ?{ urls: Array, }, - listener: Function, + listener: Function | null, ) => void) & - ((listener: Function) => void); + ((listener: Function | null) => void); } declare class TouchBarButton { constructor(options: { @@ -4039,10 +4270,12 @@ declare module 'electron' { size?: ?'small' | 'large' | 'flexible', }): TouchBarSpacer; } + + declare type URL = any; declare type Accelerator = any; declare type WebFrame = any; declare type ReadableStream = any; - declare type MenuItemConstructorOptions = any; + declare type SaveDialogOptions = any; declare type Protocol = any; declare type NetLog = any; declare type TouchBarItem = any; diff --git a/package.json b/package.json index 2390a136e..0b8439621 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ ] }, "resolutions": { - "@jest-runner/electron/electron": "4.0.8" + "@jest-runner/electron/electron": "5.0.2" }, "jest": { "transform": { @@ -50,9 +50,9 @@ } }, "devDependencies": { - "@jest-runner/electron": "^1.1.1", + "@jest-runner/electron": "^2.0.1", "babel-eslint": "^10.0.1", - "electron": "^4.0.8", + "electron": "^5.0.2", "electron-builder": "^20.38.5", "eslint": "^5.12.1", "eslint-config-fbjs": "^2.0.1", diff --git a/src/MenuBar.js b/src/MenuBar.js index 9db2eecd3..3f25e6997 100644 --- a/src/MenuBar.js +++ b/src/MenuBar.js @@ -127,7 +127,7 @@ export function setupMenuBar( } function appendMenuItem( - template: Array, + template: Array, actionHandler: (action: string) => void, item: ?KeyboardAction, ) { @@ -185,7 +185,7 @@ function getTemplate( app: Object, shell: Object, store: Store, -): Array { +): Array { const exportSubmenu = [ { label: 'File...', diff --git a/src/__tests__/__snapshots__/App.electron.js.snap b/src/__tests__/__snapshots__/App.electron.js.snap index 956cee736..109a42506 100644 --- a/src/__tests__/__snapshots__/App.electron.js.snap +++ b/src/__tests__/__snapshots__/App.electron.js.snap @@ -62,7 +62,7 @@ exports[`Empty app state matches snapshot 1`] = ` className="css-1swhxtd" onClick={[Function]} > - 4.0.8-dev + 5.0.2-dev
{ }; showDetails = () => { - const menuTemplate = [ + const menuTemplate: Array = [ { label: 'Sign Out', click: this.props.logout, diff --git a/src/ui/components/Button.js b/src/ui/components/Button.js index c98182ffc..38901ee43 100644 --- a/src/ui/components/Button.js +++ b/src/ui/components/Button.js @@ -190,7 +190,7 @@ type Props = { /** * Dropdown menu template shown on click. */ - dropdown?: Array, + dropdown?: Array, /** * Name of the icon dispalyed next to the text */ diff --git a/src/ui/components/ContextMenu.js b/src/ui/components/ContextMenu.js index 1aae92bbd..88dceb743 100644 --- a/src/ui/components/ContextMenu.js +++ b/src/ui/components/ContextMenu.js @@ -9,7 +9,7 @@ import * as React from 'react'; import FlexColumn from './FlexColumn.js'; import PropTypes from 'prop-types'; -export type MenuTemplate = Array; +export type MenuTemplate = Array; type Props = { /** List of items in the context menu. Used for static menus. */ diff --git a/src/ui/components/ContextMenuProvider.js b/src/ui/components/ContextMenuProvider.js index ccf3f188d..1f8c5e7f2 100644 --- a/src/ui/components/ContextMenuProvider.js +++ b/src/ui/components/ContextMenuProvider.js @@ -11,7 +11,7 @@ import electron from 'electron'; const PropTypes = require('prop-types'); -type MenuTemplate = Array; +type MenuTemplate = Array; const Container = styled('div')({ display: 'contents', diff --git a/src/ui/components/data-inspector/DataInspector.js b/src/ui/components/data-inspector/DataInspector.js index 36abc455e..a810bd66c 100644 --- a/src/ui/components/data-inspector/DataInspector.js +++ b/src/ui/components/data-inspector/DataInspector.js @@ -178,17 +178,17 @@ const defaultValueExtractor: DataValueExtractor = (value: any) => { const rootContextMenuCache: WeakMap< Object, - Array, + Array, > = new WeakMap(); -function getRootContextMenu(data: Object): Array { +function getRootContextMenu(data: Object): Array { const cached = rootContextMenuCache.get(data); if (cached != null) { return cached; } const stringValue = JSON.stringify(data, null, 2); - const menu: Array = [ + const menu: Array = [ { label: 'Copy entire tree', click: () => clipboard.writeText(stringValue), diff --git a/src/ui/components/elements-inspector/elements.js b/src/ui/components/elements-inspector/elements.js index d59d957c1..54035deb8 100644 --- a/src/ui/components/elements-inspector/elements.js +++ b/src/ui/components/elements-inspector/elements.js @@ -221,7 +221,7 @@ class ElementsRow extends PureComponent { interaction: (name: string, data: any) => void; - getContextMenu = (): Array => { + getContextMenu = (): Array => { const {props} = this; const items = [ { diff --git a/src/ui/components/searchable/FilterToken.js b/src/ui/components/searchable/FilterToken.js index 2abbee5e8..be5f8502a 100644 --- a/src/ui/components/searchable/FilterToken.js +++ b/src/ui/components/searchable/FilterToken.js @@ -105,7 +105,7 @@ export default class FilterToken extends PureComponent { }; showDetails = () => { - const menuTemplate = []; + const menuTemplate: Array = []; if (this.props.filter.type === 'enum') { menuTemplate.push( diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index 5c4b8692a..996bb4821 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -469,7 +469,7 @@ class ManagedTable extends React.Component< clipboard.writeText(cellText); }; - buildContextMenuItems: () => Array = () => { + buildContextMenuItems: () => Array = () => { const {highlightedRows} = this.state; if (highlightedRows.size === 0) { return []; diff --git a/src/ui/components/table/TableHead.js b/src/ui/components/table/TableHead.js index 4c95aa18c..b20961099 100644 --- a/src/ui/components/table/TableHead.js +++ b/src/ui/components/table/TableHead.js @@ -25,7 +25,7 @@ import FlexRow from '../FlexRow.js'; const invariant = require('invariant'); -type MenuTemplate = Array; +type MenuTemplate = Array; const TableHeaderArrow = styled('span')({ float: 'right', diff --git a/static/index.js b/static/index.js index 6b5e387ef..c5ba89350 100644 --- a/static/index.js +++ b/static/index.js @@ -251,6 +251,7 @@ function tryCreateWindow() { webSecurity: false, scrollBounce: true, experimentalFeatures: true, + nodeIntegration: true, }, }); win.once('ready-to-show', () => win.show()); diff --git a/yarn.lock b/yarn.lock index c58782cff..e5bc1091f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -900,38 +900,39 @@ version "0.8.1" resolved "https://registry.yarnpkg.com/@emotion/utils/-/utils-0.8.1.tgz#f3a81587ad8d0ef33cdad6f3b4310774fcc1053e" -"@jest-runner/core@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@jest-runner/core/-/core-1.0.2.tgz#0e21d082c4b3489c8e632a4a722168826fae40b0" - integrity sha512-LR4XiSFawSWO9qyx4/J7D09XTy0PKDvSf3maXXXkxlPavcjUOnsmL5ReI86LJ4YyxJCFSKpQj3eriZSGqrjcng== +"@jest-runner/core@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@jest-runner/core/-/core-2.0.0.tgz#444d0351d0872c0981ee4e87252ccb408cf27543" + integrity sha512-EEc+W5t1hj0uNga8aoEkrBhLnrXS7JBxTabkTz+29VrUxBjCfgKSas+lLaqS+bnqIknRHoKrhZ3N6PIXungDdw== dependencies: jest-message-util "^24.0.0" node-ipc "^9.1.1" -"@jest-runner/electron@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@jest-runner/electron/-/electron-1.1.1.tgz#01b7b15435306da0aee235763bae584d532dea86" - integrity sha512-+yfDVoOzuuhubSG9oRENrv0muPuqQvVz8bIqb/tW/omSwi5WGZY5zENFr27043nnTx7cNxTWu/6soAHZM/ELIg== +"@jest-runner/electron@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@jest-runner/electron/-/electron-2.0.1.tgz#083003afccfe066ceefe37007081951c4ea60509" + integrity sha512-py1YWlRnvMTJXjdJQP2uWD4/MWDVyl7UkXTQ3LnAjamlS2ct+9R4tUBME3ZG3caW2jjNn7zsjYoqCb+nSNhd+A== dependencies: - "@jest-runner/core" "^1.0.2" - "@jest-runner/rpc" "^1.1.0" - electron "^2.0.8" + "@jest-runner/core" "^2.0.0" + "@jest-runner/rpc" "^2.0.0" jest-haste-map "^24.0.0" jest-mock "^24.0.0" jest-runner "^24.0.0" jest-runtime "^24.0.0" jest-util "^24.0.0" + throat "^4.1.0" -"@jest-runner/rpc@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@jest-runner/rpc/-/rpc-1.1.0.tgz#fa998ec51779d9cf17ebc49800fd68faa08a3b90" - integrity sha512-u7ZCQ1MpTPPCy12xQXm9K1LNZbUHWsttm7JPLuH+SP5JgU+5+WykCOBIKJ33giITHNj8tib/DGxiXWWkVo7VYw== +"@jest-runner/rpc@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@jest-runner/rpc/-/rpc-2.0.0.tgz#aebbd8a1fae96b37acfb28da8ce9b1ab9a90dfc0" + integrity sha512-EP1ljCKb0Z3hWlDgFv5MW0PTogs5MOh8EFb5lsS/UP72R6fM4cYlE3GT3xYaGjZS8vawCgSqF475TRK8noDAFA== dependencies: - "@jest-runner/core" "^1.0.2" + "@jest-runner/core" "^2.0.0" glob "^7.1.3" jscodeshift "^0.6.3" node-ipc "^9.1.1" prettier "^1.14.2" + uuid "^3.3.2" yargs "^12.0.1" "@jest/console@^24.7.1": @@ -2740,10 +2741,10 @@ electron-to-chromium@^1.3.122: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.124.tgz#861fc0148748a11b3e5ccebdf8b795ff513fa11f" integrity sha512-glecGr/kFdfeXUHOHAWvGcXrxNU+1wSO/t5B23tT1dtlvYB26GY8aHzZSWD7HqhqC800Lr+w/hQul6C5AF542w== -electron@4.0.8, electron@^2.0.8, electron@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/electron/-/electron-4.0.8.tgz#b7998b16543d2094f081757a0c5afdb8875ea510" - integrity sha512-FOBJIHkuv8wc15N+ZyqwDzPavYVu5CHMBEf14jHDWv7QW2vkEIpJjVK+PIT31kfZfvjsIP0j2wvA/FBsiqB7pw== +electron@5.0.2, electron@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/electron/-/electron-5.0.2.tgz#0f6b38ae7e344b94f433d9171e50568f56962fc7" + integrity sha512-bUHKQhyuOen/q8iHTkrnzqB9CAwBDI+vHbeu21kpq2bqAD+t25yfrmUEcYHaPL4fZOAhk6nnRqskF6/Xd+aZxg== dependencies: "@types/node" "^10.12.18" electron-download "^4.1.0" @@ -7632,7 +7633,7 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -throat@^4.0.0: +throat@^4.0.0, throat@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" integrity sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=