提交 9459d2aa 编写于 作者: B Benjamin Pasero

Update to Electron 2.0.x

上级 e47a9c9e
disturl "https://atom.io/download/electron"
target "1.7.12"
target "2.0.2"
runtime "electron"
Package: @@NAME@@
Version: @@VERSION@@
Section: devel
Depends: libnotify4, libnss3, gnupg, apt, libxkbfile1, libgconf-2-4, libsecret-1-0
Depends: libnotify4, libnss3, gnupg, apt, libxkbfile1, libgconf-2-4, libsecret-1-0, libgtk-3-0 (>= 3.10.0)
Priority: optional
Architecture: @@ARCHITECTURE@@
Maintainer: Microsoft Corporation <vscode-linux@microsoft.com>
......@@ -12,3 +12,4 @@ Conflicts: visual-studio-@@NAME@@
Replaces: visual-studio-@@NAME@@
Description: Code editing. Redefined.
Visual Studio Code is a new choice of tool that combines the simplicity of a code editor with what developers need for the core edit-build-debug cycle. See https://code.visualstudio.com/docs/setup/linux for installation instructions and FAQ.
\ No newline at end of file
......@@ -4,7 +4,7 @@
"libpthread.so.0(GLIBC_2.2.5)(64bit)",
"libpthread.so.0(GLIBC_2.3.2)(64bit)",
"libpthread.so.0(GLIBC_2.3.3)(64bit)",
"libgtk-x11-2.0.so.0()(64bit)",
"libgtk-3.so.0()(64bit)",
"libgdk-x11-2.0.so.0()(64bit)",
"libatk-1.0.so.0()(64bit)",
"libgio-2.0.so.0()(64bit)",
......@@ -114,7 +114,7 @@
"libglib-2.0.so.0",
"libgmodule-2.0.so.0",
"libgobject-2.0.so.0",
"libgtk-x11-2.0.so.0",
"libgtk-3.so.0",
"libm.so.6",
"libm.so.6(GLIBC_2.0)",
"libm.so.6(GLIBC_2.1)",
......
......@@ -29,7 +29,7 @@ set ELECTRON_ENABLE_LOGGING=1
set ELECTRON_ENABLE_STACK_DUMPING=1
:: Launch Code
%CODE% --debug=5874 out\cli.js . %*
%CODE% --inspect=5874 out\cli.js . %*
popd
endlocal
......@@ -32,7 +32,7 @@ function code() {
VSCODE_DEV=1 \
ELECTRON_ENABLE_LOGGING=1 \
ELECTRON_ENABLE_STACK_DUMPING=1 \
"$CODE" --debug=5874 "$ROOT/out/cli.js" . "$@"
"$CODE" --inspect=5874 "$ROOT/out/cli.js" . "$@"
}
code "$@"
......@@ -3,6 +3,10 @@
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
ROOT=$(dirname "$(dirname "$(realpath "$0")")")
# On Linux with Electron 2.0.x running out of a VM causes
# a freeze so we only enable this flag on macOS
export ELECTRON_ENABLE_LOGGING=1
else
ROOT=$(dirname "$(dirname "$(readlink -f $0)")")
fi
......@@ -40,7 +44,6 @@ function code() {
export NODE_ENV=development
export VSCODE_DEV=1
export VSCODE_CLI=1
export ELECTRON_ENABLE_LOGGING=1
export ELECTRON_ENABLE_STACK_DUMPING=1
# Launch Code
......
......@@ -4,6 +4,10 @@
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
ROOT=$(dirname $(dirname $(realpath "$0")))
# On Linux with Electron 2.0.x running out of a VM causes
# a freeze so we only enable this flag on macOS
export ELECTRON_ENABLE_LOGGING=1
else
ROOT=$(dirname $(dirname $(readlink -f $0)))
fi
......@@ -25,7 +29,6 @@ test -d node_modules || yarn
node build/lib/electron.js || ./node_modules/.bin/gulp electron
# Unit Tests
export ELECTRON_ENABLE_LOGGING=1
if [[ "$OSTYPE" == "darwin"* ]]; then
cd $ROOT ; ulimit -n 4096 ; \
"$CODE" \
......
......@@ -69,6 +69,12 @@ if (isTempPortable) {
const app = require('electron').app;
// TODO@Ben Electron 2.0.x: prevent localStorage migration from SQLite to LevelDB due to issues
app.commandLine.appendSwitch('disable-mojo-local-storage');
// TODO@Ben Electron 2.0.x: force srgb color profile (for https://github.com/Microsoft/vscode/issues/51791)
app.commandLine.appendSwitch('force-color-profile', 'srgb');
const minimist = require('minimist');
const paths = require('./paths');
......
// Type definitions for Electron 1.7.9
// Type definitions for Electron 2.0.0-beta.2
// Project: http://electron.atom.io/
// Definitions by: The Electron Team <https://github.com/electron/electron>
// Definitions: https://github.com/electron/electron-typescript-definitions
......@@ -58,6 +58,7 @@ declare namespace Electron {
dialog: Dialog;
DownloadItem: typeof DownloadItem;
globalShortcut: GlobalShortcut;
inAppPurchase: InAppPurchase;
IncomingMessage: typeof IncomingMessage;
ipcMain: IpcMain;
Menu: typeof Menu;
......@@ -94,6 +95,7 @@ declare namespace Electron {
const desktopCapturer: DesktopCapturer;
const dialog: Dialog;
const globalShortcut: GlobalShortcut;
const inAppPurchase: InAppPurchase;
const ipcMain: IpcMain;
const ipcRenderer: IpcRenderer;
type nativeImage = NativeImage;
......@@ -157,6 +159,46 @@ declare namespace Electron {
hasVisibleWindows: boolean) => void): this;
removeListener(event: 'activate', listener: (event: Event,
hasVisibleWindows: boolean) => void): this;
/**
* Emitted during Handoff after an activity from this device was successfully
* resumed on another one.
*/
on(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
once(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
addListener(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
removeListener(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
/**
* Emitted before the application starts closing its windows. Calling
* event.preventDefault() will prevent the default behaviour, which is terminating
......@@ -286,6 +328,46 @@ declare namespace Electron {
* Contains app-specific state stored by the activity on another device.
*/
userInfo: any) => void): this;
/**
* Emitted during Handoff when an activity from a different device fails to be
* resumed.
*/
on(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
once(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
addListener(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
removeListener(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
/**
* Emitted when the gpu process crashes or is killed.
*/
......@@ -410,6 +492,49 @@ declare namespace Electron {
url: string,
certificateList: Certificate[],
callback: (certificate?: Certificate) => void) => void): this;
/**
* Emitted when Handoff is about to be resumed on another device. If you need to
* update the state to be transferred, you should call event.preventDefault()
* immediately, construct a new userInfo dictionary and call
* app.updateCurrentActiviy() in a timely manner. Otherwise the operation will fail
* and continue-activity-error will be called.
*/
on(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
once(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
addListener(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
removeListener(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
/**
* Emitted when a new webContents is created.
*/
......@@ -421,6 +546,31 @@ declare namespace Electron {
webContents: WebContents) => void): this;
removeListener(event: 'web-contents-created', listener: (event: Event,
webContents: WebContents) => void): this;
/**
* Emitted during Handoff before an activity from a different device wants to be
* resumed. You should call event.preventDefault() if you want to handle this
* event.
*/
on(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
once(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
addListener(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
removeListener(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
/**
* Emitted when the application has finished basic startup. On Windows and Linux,
* the will-finish-launching event is the same as the ready event; on macOS, this
......@@ -482,7 +632,7 @@ declare namespace Electron {
*/
enableMixedSandbox(): void;
/**
* Exits immediately with exitCode. exitCode defaults to 0. All windows will be
* Exits immediately with exitCode. exitCode defaults to 0. All windows will be
* closed immediately without asking user and the before-quit and will-quit events
* will not be emitted.
*/
......@@ -492,7 +642,6 @@ declare namespace Electron {
* the active app. On Windows, focuses on the application's first window.
*/
focus(): void;
getAppMemoryInfo(): ProcessMetric[];
getAppMetrics(): ProcessMetric[];
getAppPath(): string;
getBadgeCount(): number;
......@@ -501,12 +650,12 @@ declare namespace Electron {
* Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
* and macOS, icons depend on the application associated with file mime type.
*/
getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void;
getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void;
/**
* Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
* and macOS, icons depend on the application associated with file mime type.
*/
getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void;
getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void;
getGPUFeatureStatus(): GPUFeatureStatus;
getJumpListSettings(): JumpListSettings;
/**
......@@ -517,8 +666,7 @@ declare namespace Electron {
getLocale(): string;
/**
* If you provided path and args options to app.setLoginItemSettings then you need
* to pass the same arguments here for openAtLogin to be set correctly. Note: This
* API has no effect on MAS builds.
* to pass the same arguments here for openAtLogin to be set correctly.
*/
getLoginItemSettings(options?: LoginItemSettingsOptions): LoginItemSettings;
/**
......@@ -544,6 +692,10 @@ declare namespace Electron {
* net_error_list.
*/
importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void;
/**
* Invalidates the current Handoff user activity.
*/
invalidateCurrentActivity(type: string): void;
isAccessibilitySupportEnabled(): boolean;
/**
* This method checks if the current executable is the default handler for a
......@@ -555,6 +707,7 @@ declare namespace Electron {
* the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
*/
isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
isInApplicationsFolder(): boolean;
isReady(): boolean;
isUnityRunning(): boolean;
/**
......@@ -578,6 +731,15 @@ declare namespace Electron {
* instance starts:
*/
makeSingleInstance(callback: (argv: string[], workingDirectory: string) => void): boolean;
/**
* No confirmation dialog will be presented by default, if you wish to allow the
* user to confirm the operation you may do so using the dialog API. NOTE: This
* method throws errors if anything other than the user causes the move to fail.
* For instance if the user cancels the authorization dialog this method returns
* false. If we fail to perform the copy then this method will throw an error. The
* message in the error should be informative and tell you exactly what went wrong
*/
moveToApplicationsFolder(): boolean;
/**
* Try to close all windows. The before-quit event will be emitted first. If all
* windows are successfully closed, the will-quit event will be emitted and by
......@@ -615,6 +777,15 @@ declare namespace Electron {
* .plist file. See the Apple docs for more details.
*/
setAboutPanelOptions(options: AboutPanelOptionsOptions): void;
/**
* Manually enables Chrome's accessibility support, allowing to expose
* accessibility switch to users in application settings.
* https://www.chromium.org/developers/design-documents/accessibility for more
* details. Disabled by default. Note: Rendering accessibility tree can
* significantly affect the performance of your app. It should not be enabled by
* default.
*/
setAccessibilitySupportEnabled(enabled: boolean): void;
/**
* Changes the Application User Model ID to id.
*/
......@@ -660,8 +831,7 @@ declare namespace Electron {
/**
* Set the app's login item settings. To work with Electron's autoUpdater on
* Windows, which uses Squirrel, you'll want to set the launch path to Update.exe,
* and pass arguments that specify your application name. For example: Note: This
* API has no effect on MAS builds.
* and pass arguments that specify your application name. For example:
*/
setLoginItemSettings(settings: Settings): void;
/**
......@@ -694,6 +864,18 @@ declare namespace Electron {
* them.
*/
show(): void;
/**
* Start accessing a security scoped resource. With this method electron
* applications that are packaged for the Mac App Store may reach outside their
* sandbox to access files chosen by the user. See Apple's documentation for a
* description of how this system works.
*/
startAccessingSecurityScopedResource(bookmarkData: string): Function;
/**
* Updates the current activity if its type matches type, merging the entries from
* userInfo into its current userInfo dictionary.
*/
updateCurrentActivity(type: string, userInfo: any): void;
commandLine: CommandLine;
dock: Dock;
}
......@@ -763,16 +945,18 @@ declare namespace Electron {
getFeedURL(): string;
/**
* Restarts the app and installs the update after it has been downloaded. It should
* only be called after update-downloaded has been emitted. Note:
* autoUpdater.quitAndInstall() will close all application windows first and only
* emit before-quit event on app after that. This is different from the normal quit
* event sequence.
* only be called after update-downloaded has been emitted. Under the hood calling
* autoUpdater.quitAndInstall() will close all application windows first, and
* automatically call app.quit() after all windows have been closed. Note: If the
* application is quit without calling this API after the update-downloaded event
* has been emitted, the application will still be replaced by the updated one on
* the next run.
*/
quitAndInstall(): void;
/**
* Sets the url and initialize the auto updater.
*/
setFeedURL(url: string, requestHeaders?: any): void;
setFeedURL(options: FeedURLOptions): void;
}
interface BluetoothDevice {
......@@ -789,6 +973,8 @@ declare namespace Electron {
constructor(options?: BrowserViewConstructorOptions);
static fromId(id: number): BrowserView;
static fromWebContents(webContents: WebContents): BrowserView | null;
static getAllViews(): BrowserView[];
setAutoResize(options: AutoResizeOptions): void;
setBackgroundColor(color: string): void;
/**
......@@ -831,7 +1017,11 @@ declare namespace Electron {
* cancel the close. Usually you would want to use the beforeunload handler to
* decide whether the window should be closed, which will also be called when the
* window is reloaded. In Electron, returning any value other than undefined would
* cancel the close. For example:
* cancel the close. For example: Note: There is a subtle difference between the
* behaviors of window.onbeforeunload = handler and
* window.addEventListener('beforeunload', handler). It is recommended to always
* set the event.returnValue explicitly, instead of just returning a value, as the
* former works more consistently within Electron.
*/
on(event: 'close', listener: (event: Event) => void): this;
once(event: 'close', listener: (event: Event) => void): this;
......@@ -1056,6 +1246,7 @@ declare namespace Electron {
* This API cannot be called before the ready event of the app module is emitted.
*/
static addExtension(path: string): void;
static fromBrowserView(browserView: BrowserView): BrowserWindow | null;
static fromId(id: number): BrowserWindow;
static fromWebContents(webContents: WebContents): BrowserWindow;
static getAllWindows(): BrowserWindow[];
......@@ -1080,6 +1271,10 @@ declare namespace Electron {
* ready event of the app module is emitted.
*/
static removeExtension(name: string): void;
/**
* Adds a window as a tab on this window, after the tab for the window instance.
*/
addTabbedWindow(browserWindow: BrowserWindow): void;
/**
* Removes focus from the window.
*/
......@@ -1123,6 +1318,11 @@ declare namespace Electron {
focus(): void;
focusOnWebView(): void;
getBounds(): Rectangle;
/**
* Note: The BrowserView API is currently experimental and may change or be removed
* in future Electron releases.
*/
getBrowserView(): BrowserView | null;
getChildWindows(): BrowserWindow[];
getContentBounds(): Rectangle;
getContentSize(): number[];
......@@ -1133,6 +1333,7 @@ declare namespace Electron {
* (unsigned long) on Linux.
*/
getNativeWindowHandle(): Buffer;
getOpacity(): number;
getParentWindow(): BrowserWindow;
getPosition(): number[];
getRepresentedFilename(): string;
......@@ -1184,12 +1385,18 @@ declare namespace Electron {
*/
isMovable(): boolean;
isResizable(): boolean;
isSimpleFullScreen(): boolean;
isVisible(): boolean;
/**
* Note: This API always returns false on Windows.
*/
isVisibleOnAllWorkspaces(): boolean;
isWindowMessageHooked(message: number): boolean;
/**
* Same as webContents.loadFile, filePath should be a path to an HTML file relative
* to the root of your application. See the webContents docs for more information.
*/
loadFile(filePath: string): void;
/**
* Same as webContents.loadURL(url[, options]). The url can be a remote address
* (e.g. http://) or a path to a local HTML file using the file:// protocol. To
......@@ -1203,11 +1410,21 @@ declare namespace Electron {
* being displayed already.
*/
maximize(): void;
/**
* Merges all windows into one window with multiple tabs when native tabs are
* enabled and there is more than one open window.
*/
mergeAllWindows(): void;
/**
* Minimizes the window. On some platforms the minimized window will be shown in
* the Dock.
*/
minimize(): void;
/**
* Moves the current tab into a new window if native tabs are enabled and there is
* more than one tab in the current window.
*/
moveTabToNewWindow(): void;
/**
* Uses Quick Look to preview a file at a given path.
*/
......@@ -1220,6 +1437,16 @@ declare namespace Electron {
* Restores the window from minimized state to its previous state.
*/
restore(): void;
/**
* Selects the next tab when native tabs are enabled and there are other tabs in
* the window.
*/
selectNextTab(): void;
/**
* Selects the previous tab when native tabs are enabled and there are other tabs
* in the window.
*/
selectPreviousTab(): void;
/**
* Sets whether the window should show always on top of other windows. After
* setting this, the window is still a normal window, not a toolbox window which
......@@ -1261,10 +1488,6 @@ declare namespace Electron {
* Resizes and moves the window to the supplied bounds
*/
setBounds(bounds: Rectangle, animate?: boolean): void;
/**
* Note: The BrowserView API is currently experimental and may change or be removed
* in future Electron releases.
*/
setBrowserView(browserView: BrowserView): void;
/**
* Sets whether the window can be manually closed by user. On Linux does nothing.
......@@ -1290,6 +1513,10 @@ declare namespace Electron {
* bar will become gray when set to true.
*/
setDocumentEdited(edited: boolean): void;
/**
* Disable or enable the window.
*/
setEnabled(enable: boolean): void;
/**
* Changes whether the window can be focused.
*/
......@@ -1316,7 +1543,7 @@ declare namespace Electron {
* window will be passed to the window below this window, but if this window has
* focus, it will still receive keyboard events.
*/
setIgnoreMouseEvents(ignore: boolean): void;
setIgnoreMouseEvents(ignore: boolean, options?: IgnoreMouseEventsOptions): void;
/**
* Enters or leaves the kiosk mode.
*/
......@@ -1353,6 +1580,10 @@ declare namespace Electron {
* Sets whether the window can be moved by user. On Linux does nothing.
*/
setMovable(movable: boolean): void;
/**
* Sets the opacity of the window. On Linux does nothing.
*/
setOpacity(opacity: number): void;
/**
* Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to
* convey some sort of application status or to passively notify the user.
......@@ -1393,6 +1624,11 @@ declare namespace Electron {
* HTML-rendered toolbar. For example:
*/
setSheetOffset(offsetY: number, offsetX?: number): void;
/**
* Enters or leaves simple fullscreen mode. Simple fullscreen mode emulates the
* native fullscreen behavior found in versions of Mac OS X prior to Lion (10.7).
*/
setSimpleFullScreen(flag: boolean): void;
/**
* Resizes the window to width and height.
*/
......@@ -1456,6 +1692,11 @@ declare namespace Electron {
* Shows the window but doesn't focus on it.
*/
showInactive(): void;
/**
* Toggles the visibility of the tab bar if native tabs are enabled and there is
* only one tab in the current window.
*/
toggleTabBar(): void;
/**
* Unhooks all of the window messages.
*/
......@@ -1689,7 +1930,7 @@ declare namespace Electron {
* An object representing the HTTP response message.
*/
response: IncomingMessage) => void): this;
constructor(options: any | string);
constructor(options: 'method' | 'url' | 'session' | 'partition' | 'protocol' | 'host' | 'hostname' | 'port' | 'path' | 'redirect');
/**
* Cancels an ongoing HTTP transaction. If the request has already emitted the
* close event, the abort operation will have no effect. Otherwise an ongoing event
......@@ -1917,7 +2158,7 @@ declare namespace Electron {
*/
on(event: 'changed', listener: (event: Event,
/**
* The cookie that was changed
* The cookie that was changed.
*/
cookie: Cookie,
/**
......@@ -1930,7 +2171,7 @@ declare namespace Electron {
removed: boolean) => void): this;
once(event: 'changed', listener: (event: Event,
/**
* The cookie that was changed
* The cookie that was changed.
*/
cookie: Cookie,
/**
......@@ -1943,7 +2184,7 @@ declare namespace Electron {
removed: boolean) => void): this;
addListener(event: 'changed', listener: (event: Event,
/**
* The cookie that was changed
* The cookie that was changed.
*/
cookie: Cookie,
/**
......@@ -1956,7 +2197,7 @@ declare namespace Electron {
removed: boolean) => void): this;
removeListener(event: 'changed', listener: (event: Event,
/**
* The cookie that was changed
* The cookie that was changed.
*/
cookie: Cookie,
/**
......@@ -1972,8 +2213,8 @@ declare namespace Electron {
*/
flushStore(callback: Function): void;
/**
* Sends a request to get all cookies matching details, callback will be called
* with callback(error, cookies) on complete.
* Sends a request to get all cookies matching filter, callback will be called with
* callback(error, cookies) on complete.
*/
get(filter: Filter, callback: (error: Error, cookies: Cookie[]) => void): void;
/**
......@@ -1994,7 +2235,7 @@ declare namespace Electron {
/**
* The number of average idle cpu wakeups per second since the last call to
* getCPUUsage. First call returns 0.
* getCPUUsage. First call returns 0. Will always return 0 on Windows.
*/
idleWakeupsPerSecond: number;
/**
......@@ -2007,19 +2248,31 @@ declare namespace Electron {
// Docs: http://electron.atom.io/docs/api/structures/crash-report
date: string;
ID: number;
date: Date;
id: string;
}
interface CrashReporter extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/crash-reporter
/**
* Set an extra parameter to be sent with the crash report. The values specified
* here will be sent in addition to any values set via the extra option when start
* was called. This API is only available on macOS, if you need to add/update extra
* parameters on Linux and Windows after your first call to start you can call
* start again with the updated extra options.
*/
addExtraParameter(key: string, value: string): void;
/**
* Returns the date and ID of the last crash report. If no crash reports have been
* sent or the crash reporter has not been started, null is returned.
*/
getLastCrashReport(): CrashReport;
/**
* See all of the current parameters being passed to the crash reporter.
*/
getParameters(): void;
/**
* Returns all uploaded crash reports. Each report contains the date and uploaded
* ID.
......@@ -2030,13 +2283,10 @@ declare namespace Electron {
*/
getUploadToServer(): boolean;
/**
* Set an extra parameter to be sent with the crash report. The values specified
* here will be sent in addition to any values set via the extra option when start
* was called. This API is only available on macOS, if you need to add/update extra
* parameters on Linux and Windows after your first call to start you can call
* start again with the updated extra options.
* Remove a extra parameter from the current set of parameters so that it will not
* be sent with the crash report.
*/
setExtraParameter(key: string, value: string): void;
removeExtraParameter(key: string): void;
/**
* This would normally be controlled by user preferences. This has no effect if
* called before start is called. Note: This API can only be called from the main
......@@ -2057,7 +2307,7 @@ declare namespace Electron {
* well. This will start the process that will monitor and send the crash reports.
* Replace submitURL, productName and crashesDirectory with appropriate values.
* Note: If you need send additional/updated extra parameters after your first call
* start you can call setExtraParameter on macOS or call start again with the
* start you can call addExtraParameter on macOS or call start again with the
* new/updated extra parameters on Linux and Windows. Note: On macOS, Electron uses
* a new crashpad client for crash collection and reporting. If you want to enable
* crash reporting, initializing crashpad from the main process using
......@@ -2225,7 +2475,7 @@ declare namespace Electron {
/**
* Displays a modal dialog that shows an error message. This API can be called
* safely before the ready event the app module emits, it is usually used to report
* errors in early stage of startup. If called before the app readyevent on Linux,
* errors in early stage of startup. If called before the app readyevent on Linux,
* the message will be emitted to stderr, and no GUI dialog will appear.
*/
showErrorBox(title: string, content: string): void;
......@@ -2253,11 +2503,11 @@ declare namespace Electron {
* dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use
* the '*' wildcard (no other wildcard is supported). If a callback is passed, the
* API call will be asynchronous and the result will be passed via
* callback(filenames) Note: On Windows and Linux an open dialog can not be both a
* callback(filenames). Note: On Windows and Linux an open dialog can not be both a
* file selector and a directory selector, so if you set properties to ['openFile',
* 'openDirectory'] on these platforms, a directory selector will be shown.
*/
showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (filePaths: string[]) => void): string[];
showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[];
/**
* The browserWindow argument allows the dialog to attach itself to a parent
* window, making it modal. The filters specifies an array of file types that can
......@@ -2266,27 +2516,27 @@ declare namespace Electron {
* dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use
* the '*' wildcard (no other wildcard is supported). If a callback is passed, the
* API call will be asynchronous and the result will be passed via
* callback(filenames) Note: On Windows and Linux an open dialog can not be both a
* callback(filenames). Note: On Windows and Linux an open dialog can not be both a
* file selector and a directory selector, so if you set properties to ['openFile',
* 'openDirectory'] on these platforms, a directory selector will be shown.
*/
showOpenDialog(options: OpenDialogOptions, callback?: (filePaths: string[]) => void): string[];
showOpenDialog(options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[];
/**
* The browserWindow argument allows the dialog to attach itself to a parent
* window, making it modal. The filters specifies an array of file types that can
* be displayed, see dialog.showOpenDialog for an example. If a callback is passed,
* the API call will be asynchronous and the result will be passed via
* callback(filename)
* callback(filename).
*/
showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (filename: string) => void): string;
showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string;
/**
* The browserWindow argument allows the dialog to attach itself to a parent
* window, making it modal. The filters specifies an array of file types that can
* be displayed, see dialog.showOpenDialog for an example. If a callback is passed,
* the API call will be asynchronous and the result will be passed via
* callback(filename)
* callback(filename).
*/
showSaveDialog(options: SaveDialogOptions, callback?: (filename: string) => void): string;
showSaveDialog(options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string;
}
interface Display {
......@@ -2325,33 +2575,54 @@ declare namespace Electron {
* download that can't be resumed. The state can be one of following:
*/
on(event: 'done', listener: (event: Event,
state: string) => void): this;
/**
* Can be `completed`, `cancelled` or `interrupted`.
*/
state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
once(event: 'done', listener: (event: Event,
state: string) => void): this;
/**
* Can be `completed`, `cancelled` or `interrupted`.
*/
state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
addListener(event: 'done', listener: (event: Event,
state: string) => void): this;
/**
* Can be `completed`, `cancelled` or `interrupted`.
*/
state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
removeListener(event: 'done', listener: (event: Event,
state: string) => void): this;
/**
* Can be `completed`, `cancelled` or `interrupted`.
*/
state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
/**
* Emitted when the download has been updated and is not done. The state can be one
* of following:
*/
on(event: 'updated', listener: (event: Event,
state: string) => void): this;
/**
* Can be `progressing` or `interrupted`.
*/
state: ('progressing' | 'interrupted')) => void): this;
once(event: 'updated', listener: (event: Event,
state: string) => void): this;
/**
* Can be `progressing` or `interrupted`.
*/
state: ('progressing' | 'interrupted')) => void): this;
addListener(event: 'updated', listener: (event: Event,
state: string) => void): this;
/**
* Can be `progressing` or `interrupted`.
*/
state: ('progressing' | 'interrupted')) => void): this;
removeListener(event: 'updated', listener: (event: Event,
state: string) => void): this;
/**
* Can be `progressing` or `interrupted`.
*/
state: ('progressing' | 'interrupted')) => void): this;
/**
* Cancels the download operation.
*/
cancel(): void;
/**
* Resumes Boolean - Whether the download can resume.
*/
canResume(): void;
canResume(): boolean;
getContentDisposition(): string;
getETag(): string;
/**
......@@ -2491,6 +2762,38 @@ declare namespace Electron {
webgl2: string;
}
interface InAppPurchase extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/in-app-purchase
/**
* Emitted when one or more transactions have been updated.
*/
on(event: 'transactions-updated', listener: (event: Event,
/**
* Array of transactions.
*/
transactions: Transaction[]) => void): this;
once(event: 'transactions-updated', listener: (event: Event,
/**
* Array of transactions.
*/
transactions: Transaction[]) => void): this;
addListener(event: 'transactions-updated', listener: (event: Event,
/**
* Array of transactions.
*/
transactions: Transaction[]) => void): this;
removeListener(event: 'transactions-updated', listener: (event: Event,
/**
* Array of transactions.
*/
transactions: Transaction[]) => void): this;
canMakePayments(): boolean;
getReceiptURL(): string;
purchaseProduct(productID: string, quantity?: number, callback?: (isProductValid: boolean) => void): void;
}
class IncomingMessage extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/incoming-message
......@@ -2624,7 +2927,7 @@ declare namespace Electron {
/**
* Removes all listeners, or those of the specified channel.
*/
removeAllListeners(channel?: string): this;
removeAllListeners(channel: string): this;
/**
* Removes the specified listener from the listener array for the specified
* channel.
......@@ -2646,6 +2949,10 @@ declare namespace Electron {
* renderer process, unless you know what you are doing you should never use it.
*/
sendSync(channel: string, ...args: any[]): any;
/**
* Sends a message to a window with windowid via channel.
*/
sendTo(windowId: number, channel: string, ...args: any[]): void;
/**
* Like ipcRenderer.send but the event will be sent to the <webview> element in the
* host page instead of the main process.
......@@ -2760,6 +3067,20 @@ declare namespace Electron {
// Docs: http://electron.atom.io/docs/api/menu
/**
* Emitted when a popup is closed either manually or with menu.closePopup().
*/
on(event: 'menu-will-close', listener: (event: Event) => void): this;
once(event: 'menu-will-close', listener: (event: Event) => void): this;
addListener(event: 'menu-will-close', listener: (event: Event) => void): this;
removeListener(event: 'menu-will-close', listener: (event: Event) => void): this;
/**
* Emitted when menu.popup() is called.
*/
on(event: 'menu-will-show', listener: (event: Event) => void): this;
once(event: 'menu-will-show', listener: (event: Event) => void): this;
addListener(event: 'menu-will-show', listener: (event: Event) => void): this;
removeListener(event: 'menu-will-show', listener: (event: Event) => void): this;
constructor();
/**
* Generally, the template is just an array of options for constructing a MenuItem.
......@@ -2772,7 +3093,7 @@ declare namespace Electron {
* Note: The returned Menu instance doesn't support dynamic addition or removal of
* menu items. Instance properties can still be dynamically modified.
*/
static getApplicationMenu(): Menu;
static getApplicationMenu(): Menu | null;
/**
* Sends the action to the first responder of application. This is used for
* emulating default macOS menu behaviors. Usually you would just use the role
......@@ -2786,7 +3107,7 @@ declare namespace Electron {
* Windows and Linux but has no effect on macOS. Note: This API has to be called
* after the ready event of app module.
*/
static setApplicationMenu(menu: Menu): void;
static setApplicationMenu(menu: Menu | null): void;
/**
* Appends the menuItem to the menu.
*/
......@@ -2795,14 +3116,15 @@ declare namespace Electron {
* Closes the context menu in the browserWindow.
*/
closePopup(browserWindow?: BrowserWindow): void;
getMenuItemById(id: string): MenuItem;
/**
* Inserts the menuItem to the pos position of the menu.
*/
insert(pos: number, menuItem: MenuItem): void;
/**
* Pops up this menu as a context menu in the browserWindow.
* Pops up this menu as a context menu in the BrowserWindow.
*/
popup(browserWindow?: BrowserWindow, options?: PopupOptions): void;
popup(options: PopupOptions): void;
items: MenuItem[];
}
......@@ -2848,6 +3170,13 @@ declare namespace Electron {
* Creates a new NativeImage instance from dataURL.
*/
static createFromDataURL(dataURL: string): NativeImage;
/**
* Creates a new NativeImage instance from the NSImage that maps to the given image
* name. See NSImageName for a list of possible values. The hslShift is applied to
* the image with the following rules This means that [-1, 0, 1] will make the
* image completely white and [-1, 1, 0] will make the image completely black.
*/
static createFromNamedImage(imageName: string, hslShift: number[]): NativeImage;
/**
* Creates a new NativeImage instance from a file located at path. This method
* returns an empty image if the path does not exist, cannot be read, or is not a
......@@ -2911,22 +3240,22 @@ declare namespace Electron {
on(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
* The index of the action that was activated.
*/
index: number) => void): this;
once(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
* The index of the action that was activated.
*/
index: number) => void): this;
addListener(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
* The index of the action that was activated.
*/
index: number) => void): this;
removeListener(event: 'action', listener: (event: Event,
/**
* The index of the action that was activated
* The index of the action that was activated.
*/
index: number) => void): this;
/**
......@@ -2938,7 +3267,7 @@ declare namespace Electron {
removeListener(event: 'click', listener: (event: Event) => void): this;
/**
* Emitted when the notification is closed by manual intervention from the user.
* This event is not guarunteed to be emitted in all cases where the notification
* This event is not guaranteed to be emitted in all cases where the notification
* is closed.
*/
on(event: 'close', listener: (event: Event) => void): this;
......@@ -2951,22 +3280,22 @@ declare namespace Electron {
*/
on(event: 'reply', listener: (event: Event,
/**
* The string the user entered into the inline reply field
* The string the user entered into the inline reply field.
*/
reply: string) => void): this;
once(event: 'reply', listener: (event: Event,
/**
* The string the user entered into the inline reply field
* The string the user entered into the inline reply field.
*/
reply: string) => void): this;
addListener(event: 'reply', listener: (event: Event,
/**
* The string the user entered into the inline reply field
* The string the user entered into the inline reply field.
*/
reply: string) => void): this;
removeListener(event: 'reply', listener: (event: Event,
/**
* The string the user entered into the inline reply field
* The string the user entered into the inline reply field.
*/
reply: string) => void): this;
/**
......@@ -2980,11 +3309,17 @@ declare namespace Electron {
removeListener(event: 'show', listener: (event: Event) => void): this;
constructor(options: NotificationConstructorOptions);
static isSupported(): boolean;
/**
* Dismisses the notification.
*/
close(): void;
/**
* Immediately shows the notification to the user, please note this means unlike
* the HTML5 Notification implementation, simply instantiating a new Notification
* does not immediately show it to the user, you need to call this method before
* the OS will display it.
* the OS will display it. If the notification has been shown before, this method
* will dismiss the previously shown notification and create a new one with
* identical properties.
*/
show(): void;
}
......@@ -3036,6 +3371,16 @@ declare namespace Electron {
once(event: 'resume', listener: Function): this;
addListener(event: 'resume', listener: Function): this;
removeListener(event: 'resume', listener: Function): this;
/**
* Emitted when the system is about to reboot or shut down. If the event handler
* invokes e.preventDefault(), Electron will attempt to delay system shutdown in
* order for the app to exit cleanly. If e.preventDefault() is called, the app
* should exit as soon as possible by calling something like app.quit().
*/
on(event: 'shutdown', listener: Function): this;
once(event: 'shutdown', listener: Function): this;
addListener(event: 'shutdown', listener: Function): this;
removeListener(event: 'shutdown', listener: Function): this;
/**
* Emitted when the system is suspending.
*/
......@@ -3118,6 +3463,11 @@ declare namespace Electron {
* sends a new HTTP request as a response.
*/
interceptHttpProtocol(scheme: string, handler: (request: InterceptHttpProtocolRequest, callback: (redirectRequest: RedirectRequest) => void) => void, completion?: (error: Error) => void): void;
/**
* Same as protocol.registerStreamProtocol, except that it replaces an existing
* protocol handler.
*/
interceptStreamProtocol(scheme: string, handler: (request: InterceptStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void;
/**
* Intercepts scheme protocol and uses handler as the protocol's new handler which
* sends a String as a response.
......@@ -3178,6 +3528,15 @@ declare namespace Electron {
* the ready event of the app module gets emitted.
*/
registerStandardSchemes(schemes: string[], options?: RegisterStandardSchemesOptions): void;
/**
* Registers a protocol of scheme that will send a Readable as a response. The
* usage is similar to the other register{Any}Protocol, except that the callback
* should be called with either a Readable object or an object that has the data,
* statusCode, and headers properties. Example: It is possible to pass any object
* that implements the readable stream API (emits data/end/error events). For
* example, here's how a file could be returned:
*/
registerStreamProtocol(scheme: string, handler: (request: RegisterStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void;
/**
* Registers a protocol of scheme that will send a String as a response. The usage
* is the same with registerFileProtocol, except that the callback should be called
......@@ -3380,7 +3739,7 @@ declare namespace Electron {
* options, you have to ensure the Session with the partition has never been used
* before. There is no way to change the options of an existing Session object.
*/
static fromPartition(partition: string, options: FromPartitionOptions): Session;
static fromPartition(partition: string, options?: FromPartitionOptions): Session;
/**
* A Session object, the default session object of the app.
*/
......@@ -3444,11 +3803,12 @@ declare namespace Electron {
* Writes any unwritten DOMStorage data to disk.
*/
flushStorageData(): void;
getBlobData(identifier: string, callback: (result: Buffer) => void): Blob;
getBlobData(identifier: string, callback: (result: Buffer) => void): void;
/**
* Callback is invoked with the session's current cache size.
*/
getCacheSize(callback: (size: number) => void): void;
getPreloads(): string[];
getUserAgent(): string;
/**
* Resolves the proxy information for url. The callback will be called with
......@@ -3471,9 +3831,14 @@ declare namespace Electron {
/**
* Sets the handler which can be used to respond to permission requests for the
* session. Calling callback(true) will allow the permission and callback(false)
* will reject it.
* will reject it. To clear the handler, call setPermissionRequestHandler(null).
*/
setPermissionRequestHandler(handler: (webContents: WebContents, permission: string, callback: (permissionGranted: boolean) => void, details: PermissionRequestHandlerDetails) => void | null): void;
/**
* Adds scripts that will be executed on ALL web contents that are associated with
* this session just before normal preload scripts run.
*/
setPermissionRequestHandler(handler: (webContents: WebContents, permission: string, callback: (permissionGranted: boolean) => void) => void): void;
setPreloads(preloads: string[]): void;
/**
* Sets the proxy settings. When pacScript and proxyRules are provided together,
* the proxyRules option is ignored and pacScript configuration is applied. The
......@@ -3578,6 +3943,24 @@ declare namespace Electron {
width: number;
}
interface StreamProtocolResponse {
// Docs: http://electron.atom.io/docs/api/structures/stream-protocol-response
/**
* A Node.js readable stream representing the response body
*/
data: ReadableStream;
/**
* An object containing the response headers
*/
headers: Headers;
/**
* The HTTP response code
*/
statusCode: number;
}
interface SystemPreferences extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/system-preferences
......@@ -3633,7 +4016,7 @@ declare namespace Electron {
getAccentColor(): string;
getColor(color: '3d-dark-shadow' | '3d-face' | '3d-highlight' | '3d-light' | '3d-shadow' | 'active-border' | 'active-caption' | 'active-caption-gradient' | 'app-workspace' | 'button-text' | 'caption-text' | 'desktop' | 'disabled-text' | 'highlight' | 'highlight-text' | 'hotlight' | 'inactive-border' | 'inactive-caption' | 'inactive-caption-gradient' | 'inactive-caption-text' | 'info-background' | 'info-text' | 'menu' | 'menu-highlight' | 'menubar' | 'menu-text' | 'scrollbar' | 'window' | 'window-frame' | 'window-text'): string;
/**
* This API uses NSUserDefaults on macOS. Some popular key and types are:
* Some popular key and types are:
*/
getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url' | 'array' | 'dictionary'): any;
/**
......@@ -3655,14 +4038,22 @@ declare namespace Electron {
*/
postNotification(event: string, userInfo: any): void;
/**
* Set the value of key in system preferences. Note that type should match actual
* type of value. An exception is thrown if they don't. This API uses
* NSUserDefaults on macOS. Some popular key and types are:
* Add the specified defaults to your application's NSUserDefaults.
*/
registerDefaults(defaults: any): void;
/**
* Removes the key in NSUserDefaults. This can be used to restore the default or
* global value of a key previously set with setUserDefault.
*/
removeUserDefault(key: string): void;
/**
* Set the value of key in NSUserDefaults. Note that type should match actual type
* of value. An exception is thrown if they don't. Some popular key and types are:
*/
setUserDefault(key: string, type: string, value: string): void;
/**
* Same as subscribeNotification, but uses NSNotificationCenter for local defaults.
* This is necessary for events such as NSUserDefaultsDidChangeNotification
* This is necessary for events such as NSUserDefaultsDidChangeNotification.
*/
subscribeLocalNotification(event: string, callback: (event: string, userInfo: any) => void): void;
/**
......@@ -3830,7 +4221,7 @@ declare namespace Electron {
// Docs: http://electron.atom.io/docs/api/touch-bar
constructor(options: TouchBarConstructorOptions);
escapeItem: any;
escapeItem: (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null);
static TouchBarButton: typeof TouchBarButton;
static TouchBarColorPicker: typeof TouchBarColorPicker;
static TouchBarGroup: typeof TouchBarGroup;
......@@ -3842,6 +4233,23 @@ declare namespace Electron {
static TouchBarSpacer: typeof TouchBarSpacer;
}
interface Transaction {
// Docs: http://electron.atom.io/docs/api/structures/transaction
errorCode: number;
errorMessage: string;
originalTransactionIdentifier: string;
payment: Payment;
transactionDate: string;
transactionIdentifier: string;
/**
* The transaction sate ("purchasing", "purchased", "failed", "restored", or
* "deferred")
*/
transactionState: string;
}
class Tray extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/tray
......@@ -3873,45 +4281,61 @@ declare namespace Electron {
*/
on(event: 'click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
bounds: Rectangle,
/**
* The position of the event.
*/
position: Point) => void): this;
once(event: 'click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
bounds: Rectangle,
/**
* The position of the event.
*/
position: Point) => void): this;
addListener(event: 'click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
bounds: Rectangle,
/**
* The position of the event.
*/
position: Point) => void): this;
removeListener(event: 'click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
bounds: Rectangle,
/**
* The position of the event.
*/
position: Point) => void): this;
/**
* Emitted when the tray icon is double clicked.
*/
on(event: 'double-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
once(event: 'double-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
addListener(event: 'double-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
removeListener(event: 'double-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
/**
......@@ -3970,22 +4394,22 @@ declare namespace Electron {
*/
on(event: 'drop-text', listener: (event: Event,
/**
* the dropped text string
* the dropped text string.
*/
text: string) => void): this;
once(event: 'drop-text', listener: (event: Event,
/**
* the dropped text string
* the dropped text string.
*/
text: string) => void): this;
addListener(event: 'drop-text', listener: (event: Event,
/**
* the dropped text string
* the dropped text string.
*/
text: string) => void): this;
removeListener(event: 'drop-text', listener: (event: Event,
/**
* the dropped text string
* the dropped text string.
*/
text: string) => void): this;
/**
......@@ -3993,22 +4417,22 @@ declare namespace Electron {
*/
on(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
once(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
addListener(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
removeListener(event: 'mouse-enter', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
/**
......@@ -4016,22 +4440,45 @@ declare namespace Electron {
*/
on(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
once(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
addListener(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
removeListener(event: 'mouse-leave', listener: (event: Event,
/**
* The position of the event
* The position of the event.
*/
position: Point) => void): this;
/**
* Emitted when the mouse moves in the tray icon.
*/
on(event: 'mouse-move', listener: (event: Event,
/**
* The position of the event.
*/
position: Point) => void): this;
once(event: 'mouse-move', listener: (event: Event,
/**
* The position of the event.
*/
position: Point) => void): this;
addListener(event: 'mouse-move', listener: (event: Event,
/**
* The position of the event.
*/
position: Point) => void): this;
removeListener(event: 'mouse-move', listener: (event: Event,
/**
* The position of the event.
*/
position: Point) => void): this;
/**
......@@ -4039,22 +4486,22 @@ declare namespace Electron {
*/
on(event: 'right-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
once(event: 'right-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
addListener(event: 'right-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
removeListener(event: 'right-click', listener: (event: Event,
/**
* The bounds of tray icon
* The bounds of tray icon.
*/
bounds: Rectangle) => void): this;
constructor(image: NativeImage | string);
......@@ -4096,7 +4543,8 @@ declare namespace Electron {
*/
setPressedImage(image: NativeImage): void;
/**
* Sets the title displayed aside of the tray icon in the status bar.
* Sets the title displayed aside of the tray icon in the status bar (Support ANSI
* colors).
*/
setTitle(title: string): void;
/**
......@@ -4150,7 +4598,7 @@ declare namespace Electron {
*/
length: number;
/**
* Last Modification time in number of seconds sine the UNIX epoch.
* Last Modification time in number of seconds since the UNIX epoch.
*/
modificationTime: number;
/**
......@@ -4176,7 +4624,7 @@ declare namespace Electron {
*/
length: number;
/**
* Last Modification time in number of seconds sine the UNIX epoch.
* Last Modification time in number of seconds since the UNIX epoch.
*/
modificationTime: number;
/**
......@@ -4217,22 +4665,22 @@ declare namespace Electron {
*/
on(event: 'before-input-event', listener: (event: Event,
/**
* Input properties
* Input properties.
*/
input: Input) => void): this;
once(event: 'before-input-event', listener: (event: Event,
/**
* Input properties
* Input properties.
*/
input: Input) => void): this;
addListener(event: 'before-input-event', listener: (event: Event,
/**
* Input properties
* Input properties.
*/
input: Input) => void): this;
removeListener(event: 'before-input-event', listener: (event: Event,
/**
* Input properties
* Input properties.
*/
input: Input) => void): this;
/**
......@@ -4242,7 +4690,7 @@ declare namespace Electron {
on(event: 'certificate-error', listener: (event: Event,
url: string,
/**
* The error code
* The error code.
*/
error: string,
certificate: Certificate,
......@@ -4250,7 +4698,7 @@ declare namespace Electron {
once(event: 'certificate-error', listener: (event: Event,
url: string,
/**
* The error code
* The error code.
*/
error: string,
certificate: Certificate,
......@@ -4258,7 +4706,7 @@ declare namespace Electron {
addListener(event: 'certificate-error', listener: (event: Event,
url: string,
/**
* The error code
* The error code.
*/
error: string,
certificate: Certificate,
......@@ -4266,11 +4714,31 @@ declare namespace Electron {
removeListener(event: 'certificate-error', listener: (event: Event,
url: string,
/**
* The error code
* The error code.
*/
error: string,
certificate: Certificate,
callback: (isTrusted: boolean) => void) => void): this;
/**
* Emitted when the associated window logs a console message. Will not be emitted
* for windows with offscreen rendering enabled.
*/
on(event: 'console-message', listener: (level: number,
message: string,
line: number,
sourceId: string) => void): this;
once(event: 'console-message', listener: (level: number,
message: string,
line: number,
sourceId: string) => void): this;
addListener(event: 'console-message', listener: (level: number,
message: string,
line: number,
sourceId: string) => void): this;
removeListener(event: 'console-message', listener: (level: number,
message: string,
line: number,
sourceId: string) => void): this;
/**
* Emitted when there is a new context menu that needs to be handled.
*/
......@@ -4300,69 +4768,69 @@ declare namespace Electron {
* nwse-resize, col-resize, row-resize, m-panning, e-panning, n-panning,
* ne-panning, nw-panning, s-panning, se-panning, sw-panning, w-panning, move,
* vertical-text, cell, context-menu, alias, progress, nodrop, copy, none,
* not-allowed, zoom-in, zoom-out, grab, grabbing, custom. If the type parameter is
* custom, the image parameter will hold the custom cursor image in a NativeImage,
* and scale, size and hotspot will hold additional information about the custom
* cursor.
* not-allowed, zoom-in, zoom-out, grab, grabbing or custom. If the type parameter
* is custom, the image parameter will hold the custom cursor image in a
* NativeImage, and scale, size and hotspot will hold additional information about
* the custom cursor.
*/
on(event: 'cursor-changed', listener: (event: Event,
type: string,
image?: NativeImage,
/**
* scaling factor for the custom cursor
* scaling factor for the custom cursor.
*/
scale?: number,
/**
* the size of the `image`
* the size of the `image`.
*/
size?: Size,
/**
* coordinates of the custom cursor's hotspot
* coordinates of the custom cursor's hotspot.
*/
hotspot?: Point) => void): this;
once(event: 'cursor-changed', listener: (event: Event,
type: string,
image?: NativeImage,
/**
* scaling factor for the custom cursor
* scaling factor for the custom cursor.
*/
scale?: number,
/**
* the size of the `image`
* the size of the `image`.
*/
size?: Size,
/**
* coordinates of the custom cursor's hotspot
* coordinates of the custom cursor's hotspot.
*/
hotspot?: Point) => void): this;
addListener(event: 'cursor-changed', listener: (event: Event,
type: string,
image?: NativeImage,
/**
* scaling factor for the custom cursor
* scaling factor for the custom cursor.
*/
scale?: number,
/**
* the size of the `image`
* the size of the `image`.
*/
size?: Size,
/**
* coordinates of the custom cursor's hotspot
* coordinates of the custom cursor's hotspot.
*/
hotspot?: Point) => void): this;
removeListener(event: 'cursor-changed', listener: (event: Event,
type: string,
image?: NativeImage,
/**
* scaling factor for the custom cursor
* scaling factor for the custom cursor.
*/
scale?: number,
/**
* the size of the `image`
* the size of the `image`.
*/
size?: Size,
/**
* coordinates of the custom cursor's hotspot
* coordinates of the custom cursor's hotspot.
*/
hotspot?: Point) => void): this;
/**
......@@ -4400,14 +4868,53 @@ declare namespace Electron {
once(event: 'devtools-reload-page', listener: Function): this;
addListener(event: 'devtools-reload-page', listener: Function): this;
removeListener(event: 'devtools-reload-page', listener: Function): this;
/**
* Emitted when a <webview> has been attached to this web contents.
*/
on(event: 'did-attach-webview', listener: (event: Event,
/**
* The guest web contents that is used by the `<webview>`.
*/
webContents: WebContents) => void): this;
once(event: 'did-attach-webview', listener: (event: Event,
/**
* The guest web contents that is used by the `<webview>`.
*/
webContents: WebContents) => void): this;
addListener(event: 'did-attach-webview', listener: (event: Event,
/**
* The guest web contents that is used by the `<webview>`.
*/
webContents: WebContents) => void): this;
removeListener(event: 'did-attach-webview', listener: (event: Event,
/**
* The guest web contents that is used by the `<webview>`.
*/
webContents: WebContents) => void): this;
/**
* Emitted when a page's theme color changes. This is usually due to encountering a
* meta tag:
*/
on(event: 'did-change-theme-color', listener: Function): this;
once(event: 'did-change-theme-color', listener: Function): this;
addListener(event: 'did-change-theme-color', listener: Function): this;
removeListener(event: 'did-change-theme-color', listener: Function): this;
on(event: 'did-change-theme-color', listener: (event: Event,
/**
* Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
*/
color: string | null) => void): this;
once(event: 'did-change-theme-color', listener: (event: Event,
/**
* Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
*/
color: string | null) => void): this;
addListener(event: 'did-change-theme-color', listener: (event: Event,
/**
* Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
*/
color: string | null) => void): this;
removeListener(event: 'did-change-theme-color', listener: (event: Event,
/**
* Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
*/
color: string | null) => void): this;
/**
* This event is like did-finish-load but emitted when the load failed or was
* cancelled, e.g. window.stop() is invoked. The full list of error codes and their
......@@ -4643,7 +5150,7 @@ declare namespace Electron {
*/
disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
/**
* The options which will be used for creating the new `BrowserWindow`.
* The options which will be used for creating the new .
*/
options: any,
/**
......@@ -4660,7 +5167,7 @@ declare namespace Electron {
*/
disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
/**
* The options which will be used for creating the new `BrowserWindow`.
* The options which will be used for creating the new .
*/
options: any,
/**
......@@ -4677,7 +5184,7 @@ declare namespace Electron {
*/
disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
/**
* The options which will be used for creating the new `BrowserWindow`.
* The options which will be used for creating the new .
*/
options: any,
/**
......@@ -4694,7 +5201,7 @@ declare namespace Electron {
*/
disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
/**
* The options which will be used for creating the new `BrowserWindow`.
* The options which will be used for creating the new .
*/
options: any,
/**
......@@ -4707,22 +5214,22 @@ declare namespace Electron {
*/
on(event: 'page-favicon-updated', listener: (event: Event,
/**
* Array of URLs
* Array of URLs.
*/
favicons: string[]) => void): this;
once(event: 'page-favicon-updated', listener: (event: Event,
/**
* Array of URLs
* Array of URLs.
*/
favicons: string[]) => void): this;
addListener(event: 'page-favicon-updated', listener: (event: Event,
/**
* Array of URLs
* Array of URLs.
*/
favicons: string[]) => void): this;
removeListener(event: 'page-favicon-updated', listener: (event: Event,
/**
* Array of URLs
* Array of URLs.
*/
favicons: string[]) => void): this;
/**
......@@ -4771,8 +5278,8 @@ declare namespace Electron {
/**
* Emitted when bluetooth device needs to be selected on call to
* navigator.bluetooth.requestDevice. To use navigator.bluetooth api webBluetooth
* should be enabled. If event.preventDefault is not called, first available
* device will be selected. callback should be called with deviceId to be selected,
* should be enabled. If event.preventDefault is not called, first available device
* will be selected. callback should be called with deviceId to be selected,
* passing empty string to callback will cancel the request.
*/
on(event: 'select-bluetooth-device', listener: (event: Event,
......@@ -4935,13 +5442,13 @@ declare namespace Electron {
* called with callback(image). The image is an instance of NativeImage that stores
* data of the snapshot. Omitting rect will capture the whole visible page.
*/
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
capturePage(callback: (image: NativeImage) => void): void;
/**
* Captures a snapshot of the page within rect. Upon completion callback will be
* called with callback(image). The image is an instance of NativeImage that stores
* data of the snapshot. Omitting rect will capture the whole visible page.
*/
capturePage(callback: (image: NativeImage) => void): void;
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
/**
* Clears the navigation history.
*/
......@@ -4988,16 +5495,15 @@ declare namespace Electron {
* requestFullScreen can only be invoked by a gesture from the user. Setting
* userGesture to true will remove this limitation. If the result of the executed
* code is a promise the callback result will be the resolved value of the promise.
* We recommend that you use the returned Promise to handle code that results in a
* We recommend that you use the returned Promise to handle code that results in a
* Promise.
*/
executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
/**
* Starts a request to find all matches for the text in the web page and returns an
* Integer representing the request id used for the request. The result of the
* request can be obtained by subscribing to found-in-page event.
* Starts a request to find all matches for the text in the web page. The result of
* the request can be obtained by subscribing to found-in-page event.
*/
findInPage(text: string, options?: FindInPageOptions): void;
findInPage(text: string, options?: FindInPageOptions): number;
/**
* Focuses the web page.
*/
......@@ -5076,6 +5582,12 @@ declare namespace Electron {
isOffscreen(): boolean;
isPainting(): boolean;
isWaitingForResponse(): boolean;
/**
* Loads the given file in the window, filePath should be a path to an HTML file
* relative to the root of your application. For instance an app structure like
* this: Would require code like this
*/
loadFile(filePath: string): void;
/**
* Loads the url in the window. The url must contain the protocol prefix, e.g. the
* http:// or file://. If the load should bypass http cache then use the pragma
......@@ -5083,7 +5595,9 @@ declare namespace Electron {
*/
loadURL(url: string, options?: LoadURLOptions): void;
/**
* Opens the devtools.
* Opens the devtools. When contents is a <webview> tag, the mode would be detach
* by default, explicitly passing an empty mode can force using last used dock
* state.
*/
openDevTools(options?: OpenDevToolsOptions): void;
/**
......@@ -5101,7 +5615,7 @@ declare namespace Electron {
* webContents.print({silent: false, printBackground: false, deviceName: ''}). Use
* page-break-before: always; CSS style to force to print to a new page.
*/
print(options?: PrintOptions): void;
print(options?: PrintOptions, callback?: (success: boolean) => void): void;
/**
* Prints window's web page as PDF with Chromium's preview printing custom
* settings. The callback will be called with callback(error, data) on completion.
......@@ -5160,6 +5674,19 @@ declare namespace Electron {
* Mute the audio on the current web page.
*/
setAudioMuted(muted: boolean): void;
/**
* Uses the devToolsWebContents as the target WebContents to show devtools. The
* devToolsWebContents must not have done any navigation, and it should not be used
* for other purposes after the call. By default Electron manages the devtools by
* creating an internal WebContents with native view, which developers have very
* limited control of. With the setDevToolsWebContents method, developers can use
* any WebContents to show the devtools in it, including BrowserWindow, BrowserView
* and <webview> tag. Note that closing the devtools does not destroy the
* devToolsWebContents, it is caller's responsibility to destroy
* devToolsWebContents. An example of showing devtools in a <webview> tag: An
* example of showing devtools in a BrowserWindow:
*/
setDevToolsWebContents(devToolsWebContents: WebContents): void;
/**
* If offscreen rendering is enabled sets the frame rate to the specified number.
* Only values between 1 and 60 are accepted.
......@@ -5187,7 +5714,7 @@ declare namespace Electron {
setVisualZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
/**
* Setting the WebRTC IP handling policy allows you to control which IPs are
* exposed via WebRTC. See BrowserLeaks for more details.
* exposed via WebRTC. See BrowserLeaks for more details.
*/
setWebRTCIPHandlingPolicy(policy: 'default' | 'default_public_interface_only' | 'default_public_and_private_interfaces' | 'disable_non_proxied_udp'): void;
/**
......@@ -5198,14 +5725,10 @@ declare namespace Electron {
/**
* Changes the zoom level to the specified level. The original size is 0 and each
* increment above or below represents zooming 20% larger or smaller to default
* limits of 300% and 50% of original size, respectively.
* limits of 300% and 50% of original size, respectively. The formula for this is
* scale := 1.2 ^ level.
*/
setZoomLevel(level: number): void;
/**
* Deprecated: Call setVisualZoomLevelLimits instead to set the visual zoom level
* limits. This method will be removed in Electron 2.0.
*/
setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
/**
* Shows pop-up dictionary that searches the selected word on the page.
*/
......@@ -5276,6 +5799,10 @@ declare namespace Electron {
* userGesture to true will remove this limitation.
*/
executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
/**
* Work like executeJavaScript but evaluates scripts in isolated context.
*/
executeJavaScriptInIsolatedWorld(worldId: number, scripts: WebSource[], userGesture?: boolean, callback?: (result: any) => void): void;
/**
* Returns an object describing usage information of Blink's internal memory
* caches. This will generate:
......@@ -5305,6 +5832,18 @@ declare namespace Electron {
* cannot be corrupted by active network attackers.
*/
registerURLSchemeAsSecure(scheme: string): void;
/**
* Set the content security policy of the isolated world.
*/
setIsolatedWorldContentSecurityPolicy(worldId: number, csp: string): void;
/**
* Set the name of the isolated world. Useful in devtools.
*/
setIsolatedWorldHumanReadableName(worldId: number, name: string): void;
/**
* Set the security origin of the isolated world.
*/
setIsolatedWorldSecurityOrigin(worldId: number, securityOrigin: string): void;
/**
* Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
*/
......@@ -5330,22 +5869,28 @@ declare namespace Electron {
* limits of 300% and 50% of original size, respectively.
*/
setZoomLevel(level: number): void;
/**
* Deprecated: Call setVisualZoomLevelLimits instead to set the visual zoom level
* limits. This method will be removed in Electron 2.0.
*/
setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
}
class WebRequest extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/web-request
/**
* The listener will be called with listener(details) when a server initiated
* redirect is about to occur.
*/
onBeforeRedirect(listener: (details: OnBeforeRedirectDetails) => void): void;
/**
* The listener will be called with listener(details) when a server initiated
* redirect is about to occur.
*/
onBeforeRedirect(filter: OnBeforeRedirectFilter, listener: (details: OnBeforeRedirectDetails) => void): void;
/**
* The listener will be called with listener(details, callback) when a request is
* about to occur. The uploadData is an array of UploadData objects. The callback
* has to be called with an response object.
*/
onBeforeRequest(listener: (details: OnBeforeRequestDetails, callback: (response: Response) => void) => void): void;
/**
* The listener will be called with listener(details, callback) when a request is
* about to occur. The uploadData is an array of UploadData objects. The callback
......@@ -5359,10 +5904,25 @@ declare namespace Electron {
* has to be called with an response object.
*/
onBeforeSendHeaders(filter: OnBeforeSendHeadersFilter, listener: Function): void;
/**
* The listener will be called with listener(details, callback) before sending an
* HTTP request, once the request headers are available. This may occur after a TCP
* connection is made to the server, but before any http data is sent. The callback
* has to be called with an response object.
*/
onBeforeSendHeaders(listener: Function): void;
/**
* The listener will be called with listener(details) when a request is completed.
*/
onCompleted(filter: OnCompletedFilter, listener: (details: OnCompletedDetails) => void): void;
/**
* The listener will be called with listener(details) when a request is completed.
*/
onCompleted(listener: (details: OnCompletedDetails) => void): void;
/**
* The listener will be called with listener(details) when an error occurs.
*/
onErrorOccurred(listener: (details: OnErrorOccurredDetails) => void): void;
/**
* The listener will be called with listener(details) when an error occurs.
*/
......@@ -5373,6 +5933,18 @@ declare namespace Electron {
* response object.
*/
onHeadersReceived(filter: OnHeadersReceivedFilter, listener: Function): void;
/**
* The listener will be called with listener(details, callback) when HTTP response
* headers of a request have been received. The callback has to be called with an
* response object.
*/
onHeadersReceived(listener: Function): void;
/**
* The listener will be called with listener(details) when first byte of the
* response body is received. For HTTP requests, this means that the status line
* and response headers are available.
*/
onResponseStarted(listener: (details: OnResponseStartedDetails) => void): void;
/**
* The listener will be called with listener(details) when first byte of the
* response body is received. For HTTP requests, this means that the status line
......@@ -5385,6 +5957,24 @@ declare namespace Electron {
* response are visible by the time this listener is fired.
*/
onSendHeaders(filter: OnSendHeadersFilter, listener: (details: OnSendHeadersDetails) => void): void;
/**
* The listener will be called with listener(details) just before a request is
* going to be sent to the server, modifications of previous onBeforeSendHeaders
* response are visible by the time this listener is fired.
*/
onSendHeaders(listener: (details: OnSendHeadersDetails) => void): void;
}
interface WebSource {
// Docs: http://electron.atom.io/docs/api/structures/web-source
code: string;
/**
* Default is 1.
*/
startLine?: number;
url?: string;
}
interface WebviewTag extends HTMLElement {
......@@ -5575,6 +6165,10 @@ declare namespace Electron {
*/
addEventListener(event: 'devtools-focused', listener: (event: Event) => void, useCapture?: boolean): this;
removeEventListener(event: 'devtools-focused', listener: (event: Event) => void): this;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
canGoBack(): boolean;
canGoForward(): boolean;
canGoToOffset(offset: number): boolean;
......@@ -5613,13 +6207,12 @@ declare namespace Electron {
* context in the page. HTML APIs like requestFullScreen, which require user
* action, can take advantage of this option for automation.
*/
executeJavaScript(code: string, userGesture: boolean, callback?: (result: any) => void): void;
executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void;
/**
* Starts a request to find all matches for the text in the web page and returns an
* Integer representing the request id used for the request. The result of the
* request can be obtained by subscribing to found-in-page event.
* Starts a request to find all matches for the text in the web page. The result of
* the request can be obtained by subscribing to found-in-page event.
*/
findInPage(text: string, options?: FindInPageOptions): void;
findInPage(text: string, options?: FindInPageOptions): number;
getTitle(): string;
getURL(): string;
getUserAgent(): string;
......@@ -6062,6 +6655,10 @@ declare namespace Electron {
* is true.
*/
fullscreenable?: boolean;
/**
* Use pre-Lion fullscreen on macOS. Default is false.
*/
simpleFullscreen?: boolean;
/**
* Whether to show the window in taskbar. Default is false.
*/
......@@ -6115,7 +6712,7 @@ declare namespace Electron {
*/
enableLargerThanScreen?: boolean;
/**
* Window's background color as Hexadecimal value, like #66CD00 or #FFF or
* Window's background color as a hexadecimal value, like #66CD00 or #FFF or
* #80FFFFFF (alpha is supported). Default is #FFF (white).
*/
backgroundColor?: string;
......@@ -6124,6 +6721,11 @@ declare namespace Electron {
* is true.
*/
hasShadow?: boolean;
/**
* Set the initial opacity of the window, between 0.0 (fully transparent) and 1.0
* (fully opaque). This is only implemented on Windows and macOS.
*/
opacity?: number;
/**
* Forces using dark theme for the window, only works on some GTK+3 desktop
* environments. Default is false.
......@@ -6140,9 +6742,9 @@ declare namespace Electron {
/**
* The style of window title bar. Default is default. Possible values are:
*/
titleBarStyle?: ('default' | 'hidden' | 'hidden-inset' | 'hiddenInset' | 'customButtonsOnHover');
titleBarStyle?: ('default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover');
/**
* Shows the title in the tile bar in full screen mode on macOS for all
* Shows the title in the title bar in full screen mode on macOS for all
* titleBarStyle options. Default is false.
*/
fullscreenWindowTitle?: boolean;
......@@ -6196,7 +6798,11 @@ declare namespace Electron {
/**
* Verification result from chromium.
*/
error: string;
verificationResult: string;
/**
* Error code.
*/
errorCode: number;
}
interface ClearStorageDataOptions {
......@@ -6206,7 +6812,7 @@ declare namespace Electron {
origin?: string;
/**
* The types of storages to clear, can contain: appcache, cookies, filesystem,
* indexdb, localstorage, shadercache, websql, serviceworkers
* indexdb, localstorage, shadercache, websql, serviceworkers.
*/
storages?: string[];
/**
......@@ -6253,11 +6859,11 @@ declare namespace Electron {
interface ContextMenuParams {
/**
* x coordinate
* x coordinate.
*/
x: number;
/**
* y coordinate
* y coordinate.
*/
y: number;
/**
......@@ -6317,8 +6923,8 @@ declare namespace Electron {
*/
inputFieldType: string;
/**
* Input source that invoked the context menu. Can be none, mouse, keyboard, touch,
* touchMenu.
* Input source that invoked the context menu. Can be none, mouse, keyboard, touch
* or touchMenu.
*/
menuSourceType: ('none' | 'mouse' | 'keyboard' | 'touch' | 'touchMenu');
/**
......@@ -6355,9 +6961,10 @@ declare namespace Electron {
* properties are sent correctly. Nested objects are not supported and the property
* names and values must be less than 64 characters long.
*/
extra?: any;
extra?: Extra;
/**
* Only used when the crash reporter is used in a forked process (macOS only).
* Directory to store the crashreports temporarily (only used when the crash
* reporter is started via process.crashReporter.start).
*/
crashesDirectory?: string;
}
......@@ -6502,9 +7109,12 @@ declare namespace Electron {
}
interface DisplayBalloonOptions {
/**
* -
*/
icon?: NativeImage | string;
title?: string;
content?: string;
title: string;
content: string;
}
interface Dock {
......@@ -6569,6 +7179,18 @@ declare namespace Electron {
interface Extensions {
}
interface FeedURLOptions {
url: string;
/**
* HTTP request headers.
*/
headers?: Headers;
/**
* Either json or default, see the README for more information.
*/
serverType?: string;
}
interface FileIconOptions {
size: ('small' | 'normal' | 'large');
}
......@@ -6584,7 +7206,7 @@ declare namespace Electron {
*/
name?: string;
/**
* Retrieves cookies whose domains match or are subdomains of domains
* Retrieves cookies whose domains match or are subdomains of domains.
*/
domain?: string;
/**
......@@ -6644,6 +7266,18 @@ declare namespace Electron {
name: string;
}
interface Headers {
}
interface IgnoreMouseEventsOptions {
/**
* If true, forwards mouse move messages to Chromium, enabling mouse related events
* such as mouseleave. Only used when ignore is true. If ignore is false,
* forwarding is always disabled regardless of this value.
*/
forward?: boolean;
}
interface ImportCertificateOptions {
/**
* Path for the pkcs12 file.
......@@ -6657,35 +7291,35 @@ declare namespace Electron {
interface Input {
/**
* Either keyUp or keyDown
* Either keyUp or keyDown.
*/
type: string;
/**
* Equivalent to
* Equivalent to .
*/
key: string;
/**
* Equivalent to
* Equivalent to .
*/
code: string;
/**
* Equivalent to
* Equivalent to .
*/
isAutoRepeat: boolean;
/**
* Equivalent to
* Equivalent to .
*/
shift: boolean;
/**
* Equivalent to
* Equivalent to .
*/
control: boolean;
/**
* Equivalent to
* Equivalent to .
*/
alt: boolean;
/**
* Equivalent to
* Equivalent to .
*/
meta: boolean;
}
......@@ -6711,6 +7345,14 @@ declare namespace Electron {
uploadData: UploadData[];
}
interface InterceptStreamProtocolRequest {
url: string;
headers: Headers;
referrer: string;
method: string;
uploadData: UploadData[];
}
interface InterceptStringProtocolRequest {
url: string;
referrer: string;
......@@ -6767,6 +7409,9 @@ declare namespace Electron {
* Extra headers separated by "\n"
*/
extraHeaders?: string;
/**
* -
*/
postData?: UploadRawData[] | UploadFile[] | UploadFileSystem[] | UploadBlob[];
/**
* Base url (with trailing path separator) for files to be loaded by the data url.
......@@ -6783,25 +7428,25 @@ declare namespace Electron {
*/
openAtLogin: boolean;
/**
* true if the app is set to open as hidden at login. This setting is only
* supported on macOS.
* true if the app is set to open as hidden at login. This setting is not available
* on .
*/
openAsHidden: boolean;
/**
* true if the app was opened at login automatically. This setting is only
* supported on macOS.
* true if the app was opened at login automatically. This setting is not available
* on .
*/
wasOpenedAtLogin: boolean;
/**
* true if the app was opened as a hidden login item. This indicates that the app
* should not open any windows at startup. This setting is only supported on macOS.
* should not open any windows at startup. This setting is not available on .
*/
wasOpenedAsHidden: boolean;
/**
* true if the app was opened as a login item that should restore the state from
* the previous session. This indicates that the app should restore the windows
* that were open the last time the app was closed. This setting is only supported
* on macOS.
* that were open the last time the app was closed. This setting is not available
* on .
*/
restoreState: boolean;
}
......@@ -6827,7 +7472,7 @@ declare namespace Electron {
* Define the action of the menu item, when specified the click property will be
* ignored. See .
*/
role?: MenuItemRole;
role?: string;
/**
* Can be normal, separator, submenu, checkbox or radio.
*/
......@@ -6850,7 +7495,7 @@ declare namespace Electron {
checked?: boolean;
/**
* Should be specified for submenu type menu items. If submenu is specified, the
* type: 'submenu' can be omitted. If the value is not a Menu then it will be
* type: 'submenu' can be omitted. If the value is not a then it will be
* automatically converted to one using Menu.buildFromTemplate.
*/
submenu?: MenuItemConstructorOptions[] | Menu;
......@@ -6940,7 +7585,7 @@ declare namespace Electron {
*/
disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other');
/**
* The options which should be used for creating the new `BrowserWindow`.
* The options which should be used for creating the new .
*/
options: Options;
}
......@@ -6948,7 +7593,7 @@ declare namespace Electron {
interface NotificationConstructorOptions {
/**
* A title for the notification, which will be shown at the top of the notification
* window when it is shown
* window when it is shown.
*/
title: string;
/**
......@@ -6957,17 +7602,17 @@ declare namespace Electron {
subtitle?: string;
/**
* The body text of the notification, which will be displayed below the title or
* subtitle
* subtitle.
*/
body: string;
/**
* Whether or not to emit an OS notification noise when showing the notification
* Whether or not to emit an OS notification noise when showing the notification.
*/
silent?: boolean;
/**
* An icon to use in the notification
* An icon to use in the notification.
*/
icon?: NativeImage;
icon?: string | NativeImage;
/**
* Whether or not to add an inline reply option to the notification.
*/
......@@ -6982,15 +7627,21 @@ declare namespace Electron {
sound?: string;
/**
* Actions to add to the notification. Please read the available actions and
* limitations in the NotificationAction documentation
* limitations in the NotificationAction documentation.
*/
actions?: NotificationAction[];
/**
* A custom title for the close button of an alert. An empty string will cause the
* default localized text to be used.
*/
closeButtonText?: string;
}
interface OnBeforeRedirectDetails {
id: string;
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
redirectURL: string;
......@@ -7015,6 +7666,7 @@ declare namespace Electron {
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
uploadData: UploadData[];
......@@ -7040,6 +7692,7 @@ declare namespace Electron {
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
responseHeaders: ResponseHeaders;
......@@ -7060,6 +7713,7 @@ declare namespace Electron {
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
fromCache: boolean;
......@@ -7089,6 +7743,7 @@ declare namespace Electron {
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
responseHeaders: ResponseHeaders;
......@@ -7112,6 +7767,7 @@ declare namespace Electron {
id: number;
url: string;
method: string;
webContentsId?: number;
resourceType: string;
timestamp: number;
requestHeaders: RequestHeaders;
......@@ -7152,6 +7808,10 @@ declare namespace Electron {
* Message to display above input boxes.
*/
message?: string;
/**
* Create when packaged for the Mac App Store.
*/
securityScopedBookmarks?: boolean;
}
interface OpenExternalOptions {
......@@ -7175,50 +7835,56 @@ declare namespace Electron {
interface Parameters {
/**
* Specify the screen type to emulate (default: desktop)
* Specify the screen type to emulate (default: desktop):
*/
screenPosition: ('desktop' | 'mobile');
/**
* Set the emulated screen size (screenPosition == mobile)
* Set the emulated screen size (screenPosition == mobile).
*/
screenSize: Size;
/**
* Position the view on the screen (screenPosition == mobile) (default: {x: 0, y:
* 0})
* 0}).
*/
viewPosition: Point;
/**
* Set the device scale factor (if zero defaults to original device scale factor)
* (default: 0)
* (default: 0).
*/
deviceScaleFactor: number;
/**
* Set the emulated view size (empty means no override)
*/
viewSize: Size;
/**
* Whether emulated view should be scaled down if necessary to fit into available
* space (default: false)
*/
fitToView: boolean;
/**
* Offset of the emulated view inside available space (not in fit to view mode)
* (default: {x: 0, y: 0})
*/
offset: Point;
/**
* Scale of emulated view inside available space (not in fit to view mode)
* (default: 1)
* (default: 1).
*/
scale: number;
}
interface Payment {
productIdentifier: string;
quantity: number;
}
interface PermissionRequestHandlerDetails {
/**
* The url of the openExternal request.
*/
externalURL: string;
}
interface PluginCrashedEvent extends Event {
name: string;
version: string;
}
interface PopupOptions {
/**
* Default is the focused window.
*/
window?: BrowserWindow;
/**
* Default is the current mouse cursor position. Must be declared if y is declared.
*/
......@@ -7227,16 +7893,15 @@ declare namespace Electron {
* Default is the current mouse cursor position. Must be declared if x is declared.
*/
y?: number;
/**
* Set to true to have this method return immediately called, false to return after
* the menu has been selected or closed. Defaults to false.
*/
async?: boolean;
/**
* The index of the menu item to be positioned under the mouse cursor at the
* specified coordinates. Default is -1.
*/
positioningItem?: number;
/**
* Called when menu is closed.
*/
callback?: () => void;
}
interface PrintOptions {
......@@ -7295,7 +7960,7 @@ declare namespace Electron {
privateBytes: number;
/**
* The amount of memory shared between processes, typically memory consumed by the
* Electron code itself
* Electron code itself.
*/
sharedBytes: number;
}
......@@ -7309,7 +7974,7 @@ declare namespace Electron {
interface Provider {
/**
* Returns Boolean
* Returns Boolean.
*/
spellCheck: (text: string) => void;
}
......@@ -7354,6 +8019,14 @@ declare namespace Electron {
secure?: boolean;
}
interface RegisterStreamProtocolRequest {
url: string;
headers: Headers;
referrer: string;
method: string;
uploadData: UploadData[];
}
interface RegisterStringProtocolRequest {
url: string;
referrer: string;
......@@ -7401,7 +8074,7 @@ declare namespace Electron {
*/
width?: number;
/**
* Defaults to the image's height
* Defaults to the image's height.
*/
height?: number;
/**
......@@ -7472,6 +8145,11 @@ declare namespace Electron {
* Show the tags input box, defaults to true.
*/
showsTagField?: boolean;
/**
* Create a when packaged for the Mac App Store. If this option is enabled and the
* file doesn't already exist a blank file will be created at the chosen path.
*/
securityScopedBookmarks?: boolean;
}
interface Settings {
......@@ -7484,7 +8162,7 @@ declare namespace Electron {
* true to open the app as hidden. Defaults to false. The user can edit this
* setting from the System Preferences so
* app.getLoginItemStatus().wasOpenedAsHidden should be checked when the app is
* opened to know the current value. This setting is only supported on macOS.
* opened to know the current value. This setting is not available on .
*/
openAsHidden?: boolean;
/**
......@@ -7585,7 +8263,7 @@ declare namespace Electron {
/**
* Can be left, right or overlay.
*/
iconPosition: ('left' | 'right' | 'overlay');
iconPosition?: ('left' | 'right' | 'overlay');
/**
* Function to call when the button is clicked.
*/
......@@ -7608,8 +8286,8 @@ declare namespace Electron {
}
interface TouchBarConstructorOptions {
items: (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer)[];
escapeItem?: TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer;
items: Array<TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer>;
escapeItem?: TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null;
}
interface TouchBarGroupConstructorOptions {
......@@ -7652,15 +8330,15 @@ declare namespace Electron {
interface TouchBarScrubberConstructorOptions {
/**
* An array of items to place in this scrubber
* An array of items to place in this scrubber.
*/
items: ScrubberItem[];
/**
* Called when the user taps an item that was not the last tapped item
* Called when the user taps an item that was not the last tapped item.
*/
select: (selectedIndex: number) => void;
/**
* Called when the user taps any item
* Called when the user taps any item.
*/
highlight: (highlightedIndex: number) => void;
/**
......@@ -7704,7 +8382,7 @@ declare namespace Electron {
*/
selectedIndex?: number;
/**
* Called when the user selects a new segment
* Called when the user selects a new segment.
*/
change: (selectedIndex: number, isSelected: boolean) => void;
}
......@@ -7809,9 +8487,6 @@ declare namespace Electron {
finalUpdate: boolean;
}
interface Headers {
}
interface MediaFlags {
/**
* Whether the media element has crashed.
......@@ -7911,6 +8586,15 @@ declare namespace Electron {
* session.
*/
partition?: string;
/**
* When specified, web pages with the same affinity will run in the same renderer
* process. Note that due to reusing the renderer process, certain webPreferences
* options will also be shared between the web pages even when you specified
* different values for them, including but not limited to preload, sandbox and
* nodeIntegration. So it is suggested to use exact same webPreferences for web
* pages with the same affinity.
*/
affinity?: string;
/**
* The default zoom factor of the page, 3.0 represents 300%. Default is 1.0.
*/
......@@ -7994,7 +8678,7 @@ declare namespace Electron {
defaultEncoding?: string;
/**
* Whether to throttle animations and timers when the page becomes background. This
* also affects the [Page Visibility API][#page-visibility]. Defaults to true.
* also affects the . Defaults to true.
*/
backgroundThrottling?: boolean;
/**
......@@ -8031,6 +8715,12 @@ declare namespace Electron {
* alter the <webview>'s initial settings.
*/
webviewTag?: boolean;
/**
* A list of strings that will be appended to process.argv in the renderer process
* of this app. Useful for passing small bits of data down to renderer process
* preload scripts.
*/
additionArguments?: string[];
}
interface DefaultFontFamily {
......@@ -8108,6 +8798,7 @@ declare namespace NodeJS {
// Docs: http://electron.atom.io/docs/api/process
// ### BEGIN VSCODE MODIFICATION ###
// /**
// * Emitted when Electron has loaded its internal initialization script and is
// * beginning to load the web page or the main script. It can be used by the preload
......@@ -8118,6 +8809,8 @@ declare namespace NodeJS {
// once(event: 'loaded', listener: Function): this;
// addListener(event: 'loaded', listener: Function): this;
// removeListener(event: 'loaded', listener: Function): this;
// ### END VSCODE MODIFICATION ###
/**
* Causes the main thread of the current process crash.
*/
......@@ -8160,8 +8853,8 @@ declare namespace NodeJS {
noAsar?: boolean;
/**
* A Boolean that controls whether or not deprecation warnings are printed to
* stderr. Setting this to true will silence deprecation warnings. This property
* is used instead of the --no-deprecation command line flag.
* stderr. Setting this to true will silence deprecation warnings. This property is
* used instead of the --no-deprecation command line flag.
*/
noDeprecation?: boolean;
/**
......@@ -8170,21 +8863,21 @@ declare namespace NodeJS {
resourcesPath?: string;
/**
* A Boolean that controls whether or not deprecation warnings will be thrown as
* exceptions. Setting this to true will throw errors for deprecations. This
* exceptions. Setting this to true will throw errors for deprecations. This
* property is used instead of the --throw-deprecation command line flag.
*/
throwDeprecation?: boolean;
/**
* A Boolean that controls whether or not deprecations printed to stderr include
* their stack trace. Setting this to true will print stack traces for
* their stack trace. Setting this to true will print stack traces for
* deprecations. This property is instead of the --trace-deprecation command line
* flag.
*/
traceDeprecation?: boolean;
/**
* A Boolean that controls whether or not process warnings printed to stderr
* include their stack trace. Setting this to true will print stack traces for
* process warnings (including deprecations). This property is instead of the
* include their stack trace. Setting this to true will print stack traces for
* process warnings (including deprecations). This property is instead of the
* --trace-warnings command line flag.
*/
traceProcessWarnings?: boolean;
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -190,7 +190,7 @@ function showContextMenu(e) {
}));
}
menu.popup(remote.getCurrentWindow());
menu.popup({ window: remote.getCurrentWindow() });
}
export function startup(data: ProcessExplorerData): void {
......
......@@ -193,23 +193,6 @@ export class CodeWindow implements ICodeWindow {
this._win = new BrowserWindow(options);
this._id = this._win.id;
// Bug in Electron (https://github.com/electron/electron/issues/10862). On multi-monitor setups,
// it can happen that the position we set to the window is not the correct one on the display.
// To workaround, we ask the window for its position and set it again if not matching.
// This only applies if the window is not fullscreen or maximized and multiple monitors are used.
if (isWindows && !isFullscreenOrMaximized) {
try {
if (screen.getAllDisplays().length > 1) {
const [x, y] = this._win.getPosition();
if (x !== this.windowState.x || y !== this.windowState.y) {
this._win.setPosition(this.windowState.x, this.windowState.y, false);
}
}
} catch (err) {
this.logService.warn(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
}
}
if (useCustomTitleStyle) {
this._win.setSheetOffset(22); // offset dialogs by the height of the custom title bar if we have any
}
......@@ -987,11 +970,6 @@ export class CodeWindow implements ICodeWindow {
this.touchBarGroups.push(groupTouchBar);
}
// Ugly workaround for native crash on macOS 10.12.1. We are not
// leveraging the API for changing the ESC touch bar item.
// See https://github.com/electron/electron/issues/10442
(<any>this._win)._setEscapeTouchBarItem = () => { };
this._win.setTouchBar(new TouchBar({ items: this.touchBarGroups }));
}
......
......@@ -49,7 +49,7 @@ export class DarwinUpdateService extends AbstractUpdateService {
protected setUpdateFeedUrl(quality: string): boolean {
try {
electron.autoUpdater.setFeedURL(createUpdateURL('darwin', quality));
electron.autoUpdater.setFeedURL({ url: createUpdateURL('darwin', quality) });
} catch (e) {
// application is very likely not signed
this.logService.error('Failed to set update feed URL', e);
......
......@@ -20,13 +20,16 @@ import { IPartService, Parts, Position as SideBarPosition } from 'vs/workbench/s
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ToggleActivityBarVisibilityAction } from 'vs/workbench/browser/actions/toggleActivityBarVisibility';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { ACTIVITY_BAR_BACKGROUND, ACTIVITY_BAR_BORDER, ACTIVITY_BAR_FOREGROUND, ACTIVITY_BAR_BADGE_BACKGROUND, ACTIVITY_BAR_BADGE_FOREGROUND, ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme';
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { CompositeBar } from 'vs/workbench/browser/parts/compositebar/compositeBar';
import { isMacintosh } from 'vs/base/common/platform';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { scheduleAtNextAnimationFrame, Dimension, createCSSRule } from 'vs/base/browser/dom';
import { Color } from 'vs/base/common/color';
import { ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositebar/compositeBarActions';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { Dimension, createCSSRule } from 'vs/base/browser/dom';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
......@@ -66,6 +69,7 @@ export class ActivitybarPart extends Part {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IThemeService themeService: IThemeService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IStorageService private storageService: IStorageService,
@IExtensionService extensionService: IExtensionService
) {
......@@ -167,6 +171,27 @@ export class ActivitybarPart extends Part {
// Top Actionbar with action items for each viewlet action
this.createGlobalActivityActionBar($('.global-activity').appendTo($result).getHTMLElement());
// TODO@Ben: workaround for https://github.com/Microsoft/vscode/issues/45700
// It looks like there are rendering glitches on macOS with Chrome 61 when
// using --webkit-mask with a background color that is different from the image
// The workaround is to promote the element onto its own drawing layer. We do
// this only after the workbench has loaded because otherwise there is ugly flicker.
if (isMacintosh) {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
scheduleAtNextAnimationFrame(() => { // another delay...
scheduleAtNextAnimationFrame(() => { // ...to prevent more flickering on startup
registerThemingParticipant((theme, collector) => {
const activityBarForeground = theme.getColor(ACTIVITY_BAR_FOREGROUND);
if (activityBarForeground && !activityBarForeground.equals(Color.white)) {
// only apply this workaround if the color is different from the image one (white)
collector.addRule('.monaco-workbench .activitybar > .content .monaco-action-bar .action-label { will-change: transform; }');
}
});
});
});
});
}
return $result.getHTMLElement();
}
......
......@@ -16,8 +16,8 @@ import { Queue } from 'vs/base/common/async';
import { stat, writeFile } from 'vs/base/node/pfs';
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { IWorkspaceContextService, Workspace, WorkbenchState, IWorkspaceFolder, toWorkspaceFolders, IWorkspaceFoldersChangeEvent, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { isLinux, isWindows, isMacintosh } from 'vs/base/common/platform';
import { IFileService } from 'vs/platform/files/common/files';
import { isLinux } from 'vs/base/common/platform';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ConfigurationChangeEvent, ConfigurationModel, DefaultConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, keyFromOverrideIdentifier, isConfigurationOverrides, IConfigurationData } from 'vs/platform/configuration/common/configuration';
......@@ -349,7 +349,19 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
const folderPath = URI.file(singleFolderWorkspaceIdentifier);
return stat(folderPath.fsPath)
.then(workspaceStat => {
const ctime = isLinux ? workspaceStat.ino : workspaceStat.birthtime.getTime(); // On Linux, birthtime is ctime, so we cannot use it! We use the ino instead!
let ctime: number;
if (isLinux) {
ctime = workspaceStat.ino; // Linux: birthtime is ctime, so we cannot use it! We use the ino instead!
} else if (isMacintosh) {
ctime = workspaceStat.birthtime.getTime(); // macOS: birthtime is fine to use as is
} else if (isWindows) {
if (typeof workspaceStat.birthtimeMs === 'number') {
ctime = Math.floor(workspaceStat.birthtimeMs); // Windows: fix precision issue in node.js 8.x to get 7.x results (see https://github.com/nodejs/node/issues/19897)
} else {
ctime = workspaceStat.birthtime.getTime();
}
}
const id = createHash('md5').update(folderPath.fsPath).update(ctime ? String(ctime) : '').digest('hex');
const folder = URI.file(folderPath.fsPath);
return new Workspace(id, getBaseLabel(folder), toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime);
......
......@@ -18,6 +18,7 @@ import { unmnemonicLabel } from 'vs/base/common/labels';
import { Event, Emitter } from 'vs/base/common/event';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IContextMenuDelegate, ContextSubMenu, IEvent } from 'vs/base/browser/contextmenu';
import { once } from 'vs/base/common/functional';
export class ContextMenuService implements IContextMenuService {
......@@ -42,7 +43,15 @@ export class ContextMenuService implements IContextMenuService {
}
return TPromise.timeout(0).then(() => { // https://github.com/Microsoft/vscode/issues/3638
const menu = this.createMenu(delegate, actions);
const onHide = once(() => {
if (delegate.onHide) {
delegate.onHide(undefined);
}
this._onDidContextMenu.fire();
});
const menu = this.createMenu(delegate, actions, onHide);
const anchor = delegate.getAnchor();
let x: number, y: number;
......@@ -61,16 +70,18 @@ export class ContextMenuService implements IContextMenuService {
x *= zoom;
y *= zoom;
menu.popup(remote.getCurrentWindow(), { x: Math.floor(x), y: Math.floor(y), positioningItem: delegate.autoSelectFirstItem ? 0 : void 0 });
this._onDidContextMenu.fire();
if (delegate.onHide) {
delegate.onHide(undefined);
}
menu.popup({
window: remote.getCurrentWindow(),
x: Math.floor(x),
y: Math.floor(y),
positioningItem: delegate.autoSelectFirstItem ? 0 : void 0,
callback: () => onHide()
});
});
});
}
private createMenu(delegate: IContextMenuDelegate, entries: (IAction | ContextSubMenu)[]): Electron.Menu {
private createMenu(delegate: IContextMenuDelegate, entries: (IAction | ContextSubMenu)[], onHide: () => void): Electron.Menu {
const menu = new remote.Menu();
const actionRunner = delegate.actionRunner || new ActionRunner();
......@@ -79,7 +90,7 @@ export class ContextMenuService implements IContextMenuService {
menu.append(new remote.MenuItem({ type: 'separator' }));
} else if (e instanceof ContextSubMenu) {
const submenu = new remote.MenuItem({
submenu: this.createMenu(delegate, e.entries),
submenu: this.createMenu(delegate, e.entries, onHide),
label: unmnemonicLabel(e.label)
});
......@@ -91,6 +102,13 @@ export class ContextMenuService implements IContextMenuService {
type: !!e.checked ? 'checkbox' : !!e.radio ? 'radio' : void 0,
enabled: !!e.enabled,
click: (menuItem, win, event) => {
// To preserve pre-electron-2.x behaviour, we first trigger
// the onHide callback and then the action.
// Fixes https://github.com/Microsoft/vscode/issues/45601
onHide();
// Run action which will close the menu
this.runAction(actionRunner, e, delegate, event);
}
};
......
......@@ -193,13 +193,13 @@ export class ExtensionHostProcessWorker {
}, 100);
// Print out extension host output
onDebouncedOutput(data => {
const inspectorUrlIndex = !this._environmentService.isBuilt && data.data && data.data.indexOf('chrome-devtools://');
if (inspectorUrlIndex >= 0) {
console.log(`%c[Extension Host] %cdebugger inspector at ${data.data.substr(inspectorUrlIndex)}`, 'color: blue', 'color: black');
onDebouncedOutput(output => {
const inspectorUrlMatch = !this._environmentService.isBuilt && output.data && output.data.match(/ws:\/\/([^\s]+)/);
if (inspectorUrlMatch) {
console.log(`%c[Extension Host] %cdebugger inspector at chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=${inspectorUrlMatch[1]}`, 'color: blue', 'color: black');
} else {
console.group('Extension Host');
console.log(data.data, ...data.format);
console.log(output.data, ...output.format);
console.groupEnd();
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册