diff --git a/docs/api/structures/event.md b/docs/api/structures/event.md deleted file mode 100644 index 415d269feec..00000000000 --- a/docs/api/structures/event.md +++ /dev/null @@ -1,3 +0,0 @@ -# Event Object extends `GlobalEvent` - -* `preventDefault` VoidFunction diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 695f588552b..2f8b6cb6711 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -831,7 +831,7 @@ Emitted when the preload script `preloadPath` throws an unhandled exception `err Returns: -* `event` Event +* `event` [IpcMainEvent](structures/ipc-main-event.md) * `channel` string * `...args` any[] @@ -843,7 +843,7 @@ See also [`webContents.ipc`](#contentsipc-readonly), which provides an [`IpcMain Returns: -* `event` Event +* `event` [IpcMainEvent](structures/ipc-main-event.md) * `channel` string * `...args` any[] diff --git a/filenames.auto.gni b/filenames.auto.gni index 274e7270a1a..99b2a743754 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -79,7 +79,6 @@ auto_filenames = { "docs/api/structures/custom-scheme.md", "docs/api/structures/desktop-capturer-source.md", "docs/api/structures/display.md", - "docs/api/structures/event.md", "docs/api/structures/extension-info.md", "docs/api/structures/extension.md", "docs/api/structures/file-filter.md", diff --git a/filenames.gni b/filenames.gni index 19dd6b9d548..f3dc677334f 100644 --- a/filenames.gni +++ b/filenames.gni @@ -267,7 +267,6 @@ filenames = { "shell/browser/api/electron_api_dialog.cc", "shell/browser/api/electron_api_download_item.cc", "shell/browser/api/electron_api_download_item.h", - "shell/browser/api/electron_api_event.cc", "shell/browser/api/electron_api_event_emitter.cc", "shell/browser/api/electron_api_event_emitter.h", "shell/browser/api/electron_api_global_shortcut.cc", @@ -320,8 +319,6 @@ filenames = { "shell/browser/api/electron_api_web_request.cc", "shell/browser/api/electron_api_web_request.h", "shell/browser/api/electron_api_web_view_manager.cc", - "shell/browser/api/event.cc", - "shell/browser/api/event.h", "shell/browser/api/frame_subscriber.cc", "shell/browser/api/frame_subscriber.h", "shell/browser/api/gpu_info_enumerator.cc", @@ -382,7 +379,6 @@ filenames = { "shell/browser/electron_web_contents_utility_handler_impl.h", "shell/browser/electron_web_ui_controller_factory.cc", "shell/browser/electron_web_ui_controller_factory.h", - "shell/browser/event_emitter_mixin.cc", "shell/browser/event_emitter_mixin.h", "shell/browser/extended_web_contents_observer.h", "shell/browser/feature_list.cc", @@ -606,10 +602,13 @@ filenames = { "shell/common/gin_helper/dictionary.h", "shell/common/gin_helper/error_thrower.cc", "shell/common/gin_helper/error_thrower.h", - "shell/common/gin_helper/event_emitter.cc", + "shell/common/gin_helper/event.cc", + "shell/common/gin_helper/event.h", "shell/common/gin_helper/event_emitter.h", "shell/common/gin_helper/event_emitter_caller.cc", "shell/common/gin_helper/event_emitter_caller.h", + "shell/common/gin_helper/event_emitter_template.cc", + "shell/common/gin_helper/event_emitter_template.h", "shell/common/gin_helper/function_template.cc", "shell/common/gin_helper/function_template.h", "shell/common/gin_helper/function_template_extensions.h", diff --git a/lib/browser/api/browser-window.ts b/lib/browser/api/browser-window.ts index 605c65e2ff2..8d18fddd8e0 100644 --- a/lib/browser/api/browser-window.ts +++ b/lib/browser/api/browser-window.ts @@ -1,4 +1,4 @@ -import { BaseWindow, WebContents, Event, BrowserView, TouchBar } from 'electron/main'; +import { BaseWindow, WebContents, BrowserView, TouchBar } from 'electron/main'; import type { BrowserWindow as BWT } from 'electron/main'; import * as deprecate from '@electron/internal/common/deprecate'; const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT }; @@ -22,10 +22,10 @@ BrowserWindow.prototype._init = function (this: BWT) { }; // Redirect focus/blur event to app instance too. - this.on('blur', (event: Event) => { + this.on('blur', (event: Electron.Event) => { app.emit('browser-window-blur', event, this); }); - this.on('focus', (event: Event) => { + this.on('focus', (event: Electron.Event) => { app.emit('browser-window-focus', event, this); }); @@ -68,8 +68,7 @@ BrowserWindow.prototype._init = function (this: BWT) { }); // Notify the creation of the window. - const event = process._linkedBinding('electron_browser_event').createEmpty(); - app.emit('browser-window-created', event, this); + app.emit('browser-window-created', { preventDefault () {} }, this); Object.defineProperty(this, 'devToolsWebContents', { enumerable: true, diff --git a/lib/browser/api/menu-item.ts b/lib/browser/api/menu-item.ts index 425ce0306dd..ae1c2ea5a2a 100644 --- a/lib/browser/api/menu-item.ts +++ b/lib/browser/api/menu-item.ts @@ -1,5 +1,5 @@ import * as roles from '@electron/internal/browser/api/menu-item-roles'; -import { Menu, Event, BrowserWindow, WebContents } from 'electron/main'; +import { Menu, BrowserWindow, WebContents, KeyboardEvent } from 'electron/main'; let nextCommandId = 0; @@ -53,7 +53,7 @@ const MenuItem = function (this: any, options: any) { }); const click = options.click; - this.click = (event: Event, focusedWindow: BrowserWindow, focusedWebContents: WebContents) => { + this.click = (event: KeyboardEvent, focusedWindow: BrowserWindow, focusedWebContents: WebContents) => { // Manually flip the checked flags when clicked. if (!roles.shouldOverrideCheckStatus(this.role) && (this.type === 'checkbox' || this.type === 'radio')) { diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 19a574e8091..15039d57be0 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -524,7 +524,8 @@ const addReplyToEvent = (event: Electron.IpcMainEvent) => { }; }; -const addSenderFrameToEvent = (event: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent) => { +const addSenderToEvent = (event: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent, sender: Electron.WebContents) => { + event.sender = sender; const { processId, frameId } = event; Object.defineProperty(event, 'senderFrame', { get: () => webFrameMain.fromId(processId, frameId) @@ -533,7 +534,7 @@ const addSenderFrameToEvent = (event: Electron.IpcMainEvent | Electron.IpcMainIn const addReturnValueToEvent = (event: Electron.IpcMainEvent) => { Object.defineProperty(event, 'returnValue', { - set: (value) => event.sendReply(value), + set: (value) => event._replyChannel.sendReply(value), get: () => {} }); }; @@ -574,7 +575,7 @@ WebContents.prototype._init = function () { // Dispatch IPC messages to the ipc module. this.on('-ipc-message' as any, function (this: Electron.WebContents, event: Electron.IpcMainEvent, internal: boolean, channel: string, args: any[]) { - addSenderFrameToEvent(event); + addSenderToEvent(event, this); if (internal) { ipcMainInternal.emit(channel, event, ...args); } else { @@ -587,25 +588,30 @@ WebContents.prototype._init = function () { } }); - this.on('-ipc-invoke' as any, function (event: Electron.IpcMainInvokeEvent, internal: boolean, channel: string, args: any[]) { - addSenderFrameToEvent(event); - event._reply = (result: any) => event.sendReply({ result }); - event._throw = (error: Error) => { + this.on('-ipc-invoke' as any, async function (this: Electron.WebContents, event: Electron.IpcMainInvokeEvent, internal: boolean, channel: string, args: any[]) { + addSenderToEvent(event, this); + const replyWithResult = (result: any) => event._replyChannel.sendReply({ result }); + const replyWithError = (error: Error) => { console.error(`Error occurred in handler for '${channel}':`, error); - event.sendReply({ error: error.toString() }); + event._replyChannel.sendReply({ error: error.toString() }); }; const maybeWebFrame = getWebFrameForEvent(event); const targets: (ElectronInternal.IpcMainInternal| undefined)[] = internal ? [ipcMainInternal] : [maybeWebFrame?.ipc, ipc, ipcMain]; const target = targets.find(target => target && (target as any)._invokeHandlers.has(channel)); if (target) { - (target as any)._invokeHandlers.get(channel)(event, ...args); + const handler = (target as any)._invokeHandlers.get(channel); + try { + replyWithResult(await Promise.resolve(handler(event, ...args))); + } catch (err) { + replyWithError(err as Error); + } } else { - event._throw(`No handler registered for '${channel}'`); + replyWithError(new Error(`No handler registered for '${channel}'`)); } }); this.on('-ipc-message-sync' as any, function (this: Electron.WebContents, event: Electron.IpcMainEvent, internal: boolean, channel: string, args: any[]) { - addSenderFrameToEvent(event); + addSenderToEvent(event, this); addReturnValueToEvent(event); if (internal) { ipcMainInternal.emit(channel, event, ...args); @@ -622,8 +628,8 @@ WebContents.prototype._init = function () { } }); - this.on('-ipc-ports' as any, function (event: Electron.IpcMainEvent, internal: boolean, channel: string, message: any, ports: any[]) { - addSenderFrameToEvent(event); + this.on('-ipc-ports' as any, function (this: Electron.WebContents, event: Electron.IpcMainEvent, internal: boolean, channel: string, message: any, ports: any[]) { + addSenderToEvent(event, this); event.ports = ports.map(p => new MessagePortMain(p)); const maybeWebFrame = getWebFrameForEvent(event); maybeWebFrame && maybeWebFrame.ipc.emit(channel, event, message); @@ -651,7 +657,7 @@ WebContents.prototype._init = function () { if (this.getType() !== 'remote') { // Make new windows requested by links behave like "window.open". - this.on('-new-window' as any, (event: ElectronInternal.Event, url: string, frameName: string, disposition: Electron.HandlerDetails['disposition'], + this.on('-new-window' as any, (event: Electron.Event, url: string, frameName: string, disposition: Electron.HandlerDetails['disposition'], rawFeatures: string, referrer: Electron.Referrer, postData: PostData) => { const postBody = postData ? { data: postData, @@ -677,7 +683,7 @@ WebContents.prototype._init = function () { const options = result.browserWindowConstructorOptions; if (!event.defaultPrevented) { openGuestWindow({ - embedder: event.sender, + embedder: this, disposition, referrer, postData, @@ -690,7 +696,7 @@ WebContents.prototype._init = function () { let windowOpenOverriddenOptions: BrowserWindowConstructorOptions | null = null; let windowOpenOutlivesOpenerOption: boolean = false; - this.on('-will-add-new-contents' as any, (event: ElectronInternal.Event, url: string, frameName: string, rawFeatures: string, disposition: Electron.HandlerDetails['disposition'], referrer: Electron.Referrer, postData: PostData) => { + this.on('-will-add-new-contents' as any, (event: Electron.Event, url: string, frameName: string, rawFeatures: string, disposition: Electron.HandlerDetails['disposition'], referrer: Electron.Referrer, postData: PostData) => { const postBody = postData ? { data: postData, ...parseContentTypeFormat(postData) @@ -725,7 +731,7 @@ WebContents.prototype._init = function () { } : undefined; const { webPreferences: parsedWebPreferences } = parseFeatures(rawFeatures); const webPreferences = makeWebPreferences({ - embedder: event.sender, + embedder: this, insecureParsedWebPreferences: parsedWebPreferences, secureOverrideWebPreferences }); @@ -738,7 +744,7 @@ WebContents.prototype._init = function () { }); // Create a new browser window for "window.open" - this.on('-add-new-contents' as any, (event: ElectronInternal.Event, webContents: Electron.WebContents, disposition: string, + this.on('-add-new-contents' as any, (event: Electron.Event, webContents: Electron.WebContents, disposition: string, _userGesture: boolean, _left: number, _top: number, _width: number, _height: number, url: string, frameName: string, referrer: Electron.Referrer, rawFeatures: string, postData: PostData) => { const overriddenOptions = windowOpenOverriddenOptions || undefined; @@ -754,7 +760,7 @@ WebContents.prototype._init = function () { } openGuestWindow({ - embedder: event.sender, + embedder: this, guest: webContents, overrideBrowserWindowOptions: overriddenOptions, disposition, @@ -791,8 +797,7 @@ WebContents.prototype._init = function () { } }); - const event = process._linkedBinding('electron_browser_event').createEmpty(); - app.emit('web-contents-created', event, this); + app.emit('web-contents-created', { sender: this, preventDefault () {}, get defaultPrevented () { return false; } }, this); // Properties diff --git a/lib/browser/guest-view-manager.ts b/lib/browser/guest-view-manager.ts index 47d619a1256..322b82aaec4 100644 --- a/lib/browser/guest-view-manager.ts +++ b/lib/browser/guest-view-manager.ts @@ -14,7 +14,6 @@ interface GuestInstance { } const webViewManager = process._linkedBinding('electron_browser_web_view_manager'); -const eventBinding = process._linkedBinding('electron_browser_event'); const netBinding = process._linkedBinding('electron_browser_net'); const supportedWebViewEvents = Object.keys(webViewEvents); @@ -82,7 +81,13 @@ function makeLoadURLOptions (params: Record) { // Create a new guest instance. const createGuest = function (embedder: Electron.WebContents, embedderFrameId: number, elementInstanceId: number, params: Record) { const webPreferences = makeWebPreferences(embedder, params); - const event = eventBinding.createWithSender(embedder); + const event = { + sender: embedder, + preventDefault () { + this.defaultPrevented = true; + }, + defaultPrevented: false + }; const { instanceId } = params; diff --git a/lib/browser/ipc-main-impl.ts b/lib/browser/ipc-main-impl.ts index 0349cc00c0b..9528af3513d 100644 --- a/lib/browser/ipc-main-impl.ts +++ b/lib/browser/ipc-main-impl.ts @@ -18,13 +18,7 @@ export class IpcMainImpl extends EventEmitter { if (typeof fn !== 'function') { throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`); } - this._invokeHandlers.set(method, async (e, ...args) => { - try { - e._reply(await Promise.resolve(fn(e, ...args))); - } catch (err) { - e._throw(err as Error); - } - }); + this._invokeHandlers.set(method, fn); } handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => { diff --git a/package.json b/package.json index b8743558162..1be5fc16494 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "@azure/storage-blob": "^12.9.0", "@dsanders11/vscode-markdown-languageservice": "^0.3.0-alpha.4", "@electron/asar": "^3.2.1", - "@electron/docs-parser": "^1.0.0", + "@electron/docs-parser": "^1.1.0", "@electron/fiddle-core": "^1.0.4", "@electron/github-app-auth": "^1.5.0", - "@electron/typescript-definitions": "^8.10.0", + "@electron/typescript-definitions": "^8.14.0", "@octokit/rest": "^19.0.7", "@primer/octicons": "^10.0.0", "@types/basic-auth": "^1.1.3", diff --git a/shell/browser/api/electron_api_event.cc b/shell/browser/api/electron_api_event.cc deleted file mode 100644 index 097434e884a..00000000000 --- a/shell/browser/api/electron_api_event.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2018 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/browser/api/event.h" -#include "shell/common/gin_helper/dictionary.h" -#include "shell/common/gin_helper/event_emitter.h" -#include "shell/common/node_includes.h" - -namespace { - -v8::Local CreateWithSender(v8::Isolate* isolate, - v8::Local sender) { - return gin_helper::internal::CreateCustomEvent(isolate, sender); -} - -void Initialize(v8::Local exports, - v8::Local unused, - v8::Local context, - void* priv) { - gin_helper::Dictionary dict(context->GetIsolate(), exports); - dict.SetMethod("createWithSender", &CreateWithSender); - dict.SetMethod("createEmpty", &gin_helper::Event::Create); -} - -} // namespace - -NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_event, Initialize) diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index a96d57fb9fe..8cef04382ee 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1178,8 +1178,7 @@ gin::Handle Session::CreateFrom( // to use partition strings, instead of using the Session object directly. handle->Pin(isolate); - App::Get()->EmitCustomEvent("session-created", - handle.ToV8().As()); + App::Get()->EmitWithoutEvent("session-created", handle); return handle; } diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index 1a59c27787b..f673df6d4da 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -97,19 +97,19 @@ void Tray::OnClicked(const gfx::Rect& bounds, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("click", CreateEventFromFlags(modifiers), bounds, location); + EmitWithoutEvent("click", CreateEventFromFlags(modifiers), bounds, location); } void Tray::OnDoubleClicked(const gfx::Rect& bounds, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("double-click", CreateEventFromFlags(modifiers), bounds); + EmitWithoutEvent("double-click", CreateEventFromFlags(modifiers), bounds); } void Tray::OnRightClicked(const gfx::Rect& bounds, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("right-click", CreateEventFromFlags(modifiers), bounds); + EmitWithoutEvent("right-click", CreateEventFromFlags(modifiers), bounds); } void Tray::OnBalloonShow() { @@ -139,31 +139,31 @@ void Tray::OnDropText(const std::string& text) { void Tray::OnMouseEntered(const gfx::Point& location, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("mouse-enter", CreateEventFromFlags(modifiers), location); + EmitWithoutEvent("mouse-enter", CreateEventFromFlags(modifiers), location); } void Tray::OnMouseExited(const gfx::Point& location, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("mouse-leave", CreateEventFromFlags(modifiers), location); + EmitWithoutEvent("mouse-leave", CreateEventFromFlags(modifiers), location); } void Tray::OnMouseMoved(const gfx::Point& location, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("mouse-move", CreateEventFromFlags(modifiers), location); + EmitWithoutEvent("mouse-move", CreateEventFromFlags(modifiers), location); } void Tray::OnMouseUp(const gfx::Point& location, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("mouse-up", CreateEventFromFlags(modifiers), location); + EmitWithoutEvent("mouse-up", CreateEventFromFlags(modifiers), location); } void Tray::OnMouseDown(const gfx::Point& location, int modifiers) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - EmitCustomEvent("mouse-down", CreateEventFromFlags(modifiers), location); + EmitWithoutEvent("mouse-down", CreateEventFromFlags(modifiers), location); } void Tray::OnDragEntered() { diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc index bcd24ce0c3f..78b1a133cbd 100644 --- a/shell/browser/api/electron_api_utility_process.cc +++ b/shell/browser/api/electron_api_utility_process.cc @@ -203,13 +203,13 @@ void UtilityProcessWrapper::OnServiceProcessLaunched( pid_ = process.Pid(); GetAllUtilityProcessWrappers().AddWithID(this, pid_); if (stdout_read_fd_ != -1) { - EmitWithoutCustomEvent("stdout", stdout_read_fd_); + EmitWithoutEvent("stdout", stdout_read_fd_); } if (stderr_read_fd_ != -1) { - EmitWithoutCustomEvent("stderr", stderr_read_fd_); + EmitWithoutEvent("stderr", stderr_read_fd_); } // Emit 'spawn' event - EmitWithoutCustomEvent("spawn"); + EmitWithoutEvent("spawn"); } void UtilityProcessWrapper::OnServiceProcessDisconnected( @@ -219,7 +219,7 @@ void UtilityProcessWrapper::OnServiceProcessDisconnected( GetAllUtilityProcessWrappers().Remove(pid_); CloseConnectorPort(); // Emit 'exit' event - EmitWithoutCustomEvent("exit", error_code); + EmitWithoutEvent("exit", error_code); Unpin(); } @@ -238,7 +238,7 @@ void UtilityProcessWrapper::Shutdown(int exit_code) { node_service_remote_.reset(); CloseConnectorPort(); // Emit 'exit' event - EmitWithoutCustomEvent("exit", exit_code); + EmitWithoutEvent("exit", exit_code); Unpin(); } @@ -311,7 +311,7 @@ bool UtilityProcessWrapper::Accept(mojo::Message* mojo_message) { v8::HandleScope handle_scope(isolate); v8::Local message_value = electron::DeserializeV8Value(isolate, message); - EmitWithoutCustomEvent("message", message_value); + EmitWithoutEvent("message", message_value); return true; } diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index da897f06f62..3f3ea285cf3 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1812,6 +1812,81 @@ void WebContents::OnFirstNonEmptyLayout( } } +// This object wraps the InvokeCallback so that if it gets GC'd by V8, we can +// still call the callback and send an error. Not doing so causes a Mojo DCHECK, +// since Mojo requires callbacks to be called before they are destroyed. +class ReplyChannel : public gin::Wrappable { + public: + using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback; + static gin::Handle Create(v8::Isolate* isolate, + InvokeCallback callback) { + return gin::CreateHandle(isolate, new ReplyChannel(std::move(callback))); + } + + // gin::Wrappable + static gin::WrapperInfo kWrapperInfo; + gin::ObjectTemplateBuilder GetObjectTemplateBuilder( + v8::Isolate* isolate) override { + return gin::Wrappable::GetObjectTemplateBuilder(isolate) + .SetMethod("sendReply", &ReplyChannel::SendReply); + } + const char* GetTypeName() override { return "ReplyChannel"; } + + private: + explicit ReplyChannel(InvokeCallback callback) + : callback_(std::move(callback)) {} + ~ReplyChannel() override { + if (callback_) { + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + // If there's no current context, it means we're shutting down, so we + // don't need to send an event. + if (!isolate->GetCurrentContext().IsEmpty()) { + v8::HandleScope scope(isolate); + auto message = gin::DataObjectBuilder(isolate) + .Set("error", "reply was never sent") + .Build(); + SendReply(isolate, message); + } + } + } + + bool SendReply(v8::Isolate* isolate, v8::Local arg) { + if (!callback_) + return false; + blink::CloneableMessage message; + if (!gin::ConvertFromV8(isolate, arg, &message)) { + return false; + } + + std::move(callback_).Run(std::move(message)); + return true; + } + + InvokeCallback callback_; +}; + +gin::WrapperInfo ReplyChannel::kWrapperInfo = {gin::kEmbedderNativeGin}; + +gin::Handle WebContents::MakeEventWithSender( + v8::Isolate* isolate, + content::RenderFrameHost* frame, + electron::mojom::ElectronApiIPC::InvokeCallback callback) { + v8::Local wrapper; + if (!GetWrapper(isolate).ToLocal(&wrapper)) + return gin::Handle(); + gin::Handle event = + gin_helper::internal::Event::New(isolate); + gin_helper::Dictionary dict(isolate, event.ToV8().As()); + if (callback) + dict.Set("_replyChannel", + ReplyChannel::Create(isolate, std::move(callback))); + if (frame) { + dict.Set("frameId", frame->GetRoutingID()); + dict.Set("processId", frame->GetProcess()->GetID()); + } + return event; +} + void WebContents::ReceivePostMessage( const std::string& channel, blink::TransferableMessage message, diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index df8901a4526..a14bd8b0962 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -352,20 +352,26 @@ class WebContents : public ExclusiveAccessContext, // this.emit(name, new Event(sender, message), args...); template bool EmitWithSender(base::StringPiece name, - content::RenderFrameHost* sender, + content::RenderFrameHost* frame, electron::mojom::ElectronApiIPC::InvokeCallback callback, Args&&... args) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); - v8::Local wrapper; - if (!GetWrapper(isolate).ToLocal(&wrapper)) + + gin::Handle event = + MakeEventWithSender(isolate, frame, std::move(callback)); + if (event.IsEmpty()) return false; - v8::Local event = gin_helper::internal::CreateNativeEvent( - isolate, wrapper, sender, std::move(callback)); - return EmitCustomEvent(name, event, std::forward(args)...); + EmitWithoutEvent(name, event, std::forward(args)...); + return event->GetDefaultPrevented(); } + gin::Handle MakeEventWithSender( + v8::Isolate* isolate, + content::RenderFrameHost* frame, + electron::mojom::ElectronApiIPC::InvokeCallback callback); + WebContents* embedder() { return embedder_; } #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) diff --git a/shell/browser/api/event.cc b/shell/browser/api/event.cc deleted file mode 100644 index f1b845b5c04..00000000000 --- a/shell/browser/api/event.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/browser/api/event.h" - -#include - -#include "gin/data_object_builder.h" -#include "gin/object_template_builder.h" -#include "shell/browser/javascript_environment.h" -#include "shell/common/gin_converters/blink_converter.h" -#include "shell/common/gin_converters/std_converter.h" - -namespace gin_helper { - -gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin}; - -Event::Event() = default; - -Event::~Event() { - if (callback_) { - v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); - // If there's no current context, it means we're shutting down, so we don't - // need to send an event. - if (!isolate->GetCurrentContext().IsEmpty()) { - v8::HandleScope scope(isolate); - auto message = gin::DataObjectBuilder(isolate) - .Set("error", "reply was never sent") - .Build(); - SendReply(isolate, message); - } - } -} - -void Event::SetCallback(InvokeCallback callback) { - DCHECK(!callback_); - callback_ = std::move(callback); -} - -void Event::PreventDefault(v8::Isolate* isolate) { - v8::Local self = GetWrapper(isolate).ToLocalChecked(); - self->Set(isolate->GetCurrentContext(), - gin::StringToV8(isolate, "defaultPrevented"), v8::True(isolate)) - .Check(); -} - -bool Event::SendReply(v8::Isolate* isolate, v8::Local result) { - if (!callback_) - return false; - - blink::CloneableMessage message; - if (!gin::ConvertFromV8(isolate, result, &message)) { - return false; - } - - std::move(callback_).Run(std::move(message)); - return true; -} - -gin::ObjectTemplateBuilder Event::GetObjectTemplateBuilder( - v8::Isolate* isolate) { - return gin::Wrappable::GetObjectTemplateBuilder(isolate) - .SetMethod("preventDefault", &Event::PreventDefault) - .SetMethod("sendReply", &Event::SendReply); -} - -const char* Event::GetTypeName() { - return "Event"; -} - -// static -gin::Handle Event::Create(v8::Isolate* isolate) { - return gin::CreateHandle(isolate, new Event()); -} - -} // namespace gin_helper diff --git a/shell/browser/api/event.h b/shell/browser/api/event.h deleted file mode 100644 index 763d684c721..00000000000 --- a/shell/browser/api/event.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ELECTRON_SHELL_BROWSER_API_EVENT_H_ -#define ELECTRON_SHELL_BROWSER_API_EVENT_H_ - -#include "electron/shell/common/api/api.mojom.h" -#include "gin/handle.h" -#include "gin/wrappable.h" - -namespace gin_helper { - -class Event : public gin::Wrappable { - public: - using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback; - - static gin::WrapperInfo kWrapperInfo; - - static gin::Handle Create(v8::Isolate* isolate); - - // Pass the callback to be invoked. - void SetCallback(InvokeCallback callback); - - // event.PreventDefault(). - void PreventDefault(v8::Isolate* isolate); - - // event.sendReply(value), used for replying to synchronous messages and - // `invoke` calls. - bool SendReply(v8::Isolate* isolate, v8::Local result); - - // disable copy - Event(const Event&) = delete; - Event& operator=(const Event&) = delete; - - protected: - Event(); - ~Event() override; - - // gin::Wrappable: - gin::ObjectTemplateBuilder GetObjectTemplateBuilder( - v8::Isolate* isolate) override; - const char* GetTypeName() override; - - private: - // Replier for the synchronous messages. - InvokeCallback callback_; -}; - -} // namespace gin_helper - -#endif // ELECTRON_SHELL_BROWSER_API_EVENT_H_ diff --git a/shell/browser/event_emitter_mixin.h b/shell/browser/event_emitter_mixin.h index 54d6f55c126..3719d3bed1d 100644 --- a/shell/browser/event_emitter_mixin.h +++ b/shell/browser/event_emitter_mixin.h @@ -7,16 +7,14 @@ #include +#include "gin/handle.h" #include "gin/object_template_builder.h" #include "shell/browser/javascript_environment.h" +#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event_emitter.h" namespace gin_helper { -namespace internal { -v8::Local GetEventEmitterTemplate(v8::Isolate* isolate); -} // namespace internal - template class EventEmitterMixin { public: @@ -33,14 +31,15 @@ class EventEmitterMixin { v8::Local wrapper; if (!static_cast(this)->GetWrapper(isolate).ToLocal(&wrapper)) return false; - v8::Local event = internal::CreateCustomEvent(isolate, wrapper); - return EmitWithEvent(isolate, wrapper, name, event, - std::forward(args)...); + gin::Handle event = internal::Event::New(isolate); + gin_helper::EmitEvent(isolate, wrapper, name, event, + std::forward(args)...); + return event->GetDefaultPrevented(); } // this.emit(name, args...); template - void EmitWithoutCustomEvent(base::StringPiece name, Args&&... args) { + void EmitWithoutEvent(base::StringPiece name, Args&&... args) { v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); v8::Local wrapper; @@ -49,20 +48,6 @@ class EventEmitterMixin { gin_helper::EmitEvent(isolate, wrapper, name, std::forward(args)...); } - // this.emit(name, event, args...); - template - bool EmitCustomEvent(base::StringPiece name, - v8::Local custom_event, - Args&&... args) { - v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); - v8::HandleScope scope(isolate); - v8::Local wrapper; - if (!static_cast(this)->GetWrapper(isolate).ToLocal(&wrapper)) - return false; - return EmitWithEvent(isolate, wrapper, name, custom_event, - std::forward(args)...); - } - protected: EventEmitterMixin() = default; @@ -82,25 +67,6 @@ class EventEmitterMixin { static_cast(this)->GetTypeName(), constructor->InstanceTemplate()); } - - private: - // this.emit(name, event, args...); - template - static bool EmitWithEvent(v8::Isolate* isolate, - v8::Local wrapper, - base::StringPiece name, - v8::Local event, - Args&&... args) { - auto context = isolate->GetCurrentContext(); - gin_helper::EmitEvent(isolate, wrapper, name, event, - std::forward(args)...); - v8::Local defaultPrevented; - if (event->Get(context, gin::StringToV8(isolate, "defaultPrevented")) - .ToLocal(&defaultPrevented)) { - return defaultPrevented->BooleanValue(isolate); - } - return false; - } }; } // namespace gin_helper diff --git a/shell/common/gin_helper/constructible.h b/shell/common/gin_helper/constructible.h index f2ac51c4c22..8d396bdf641 100644 --- a/shell/common/gin_helper/constructible.h +++ b/shell/common/gin_helper/constructible.h @@ -7,7 +7,7 @@ #include "gin/per_isolate_data.h" #include "gin/wrappable.h" -#include "shell/browser/event_emitter_mixin.h" +#include "shell/common/gin_helper/event_emitter_template.h" #include "shell/common/gin_helper/function_template_extensions.h" namespace gin_helper { diff --git a/shell/common/gin_helper/event.cc b/shell/common/gin_helper/event.cc new file mode 100644 index 00000000000..347ee9ba978 --- /dev/null +++ b/shell/common/gin_helper/event.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2023 Salesforce, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/common/gin_helper/event.h" +#include "gin/dictionary.h" +#include "gin/object_template_builder.h" + +namespace gin_helper::internal { + +// static +gin::Handle Event::New(v8::Isolate* isolate) { + return gin::CreateHandle(isolate, new Event()); +} +// static +v8::Local Event::FillObjectTemplate( + v8::Isolate* isolate, + v8::Local templ) { + return gin::ObjectTemplateBuilder(isolate, "Event", templ) + .SetMethod("preventDefault", &Event::PreventDefault) + .SetProperty("defaultPrevented", &Event::GetDefaultPrevented) + .Build(); +} + +Event::Event() = default; + +Event::~Event() = default; + +gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin}; + +} // namespace gin_helper::internal diff --git a/shell/common/gin_helper/event.h b/shell/common/gin_helper/event.h new file mode 100644 index 00000000000..ce4880c8f5e --- /dev/null +++ b/shell/common/gin_helper/event.h @@ -0,0 +1,48 @@ +// Copyright (c) 2023 Salesforce, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_ +#define ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_ + +#include "gin/handle.h" +#include "gin/wrappable.h" +#include "shell/common/gin_helper/constructible.h" + +namespace v8 { +class Isolate; +template +class Local; +class Object; +class ObjectTemplate; +} // namespace v8 + +namespace gin_helper::internal { + +class Event : public gin::Wrappable, + public gin_helper::Constructible { + public: + // gin_helper::Constructible + static gin::Handle New(v8::Isolate* isolate); + static v8::Local FillObjectTemplate( + v8::Isolate* isolate, + v8::Local prototype); + + // gin::Wrappable + static gin::WrapperInfo kWrapperInfo; + + ~Event() override; + + void PreventDefault() { default_prevented_ = true; } + + bool GetDefaultPrevented() { return default_prevented_; } + + private: + Event(); + + bool default_prevented_ = false; +}; + +} // namespace gin_helper::internal + +#endif // ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_ diff --git a/shell/common/gin_helper/event_emitter.cc b/shell/common/gin_helper/event_emitter.cc deleted file mode 100644 index 5ebb9c93539..00000000000 --- a/shell/common/gin_helper/event_emitter.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2019 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/common/gin_helper/event_emitter.h" - -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" -#include "shell/browser/api/event.h" -#include "shell/common/gin_helper/dictionary.h" -#include "shell/common/gin_helper/object_template_builder.h" - -namespace gin_helper::internal { - -namespace { - -v8::Persistent event_template; - -void PreventDefault(gin_helper::Arguments* args) { - Dictionary self; - if (args->GetHolder(&self)) - self.Set("defaultPrevented", true); -} - -} // namespace - -v8::Local CreateCustomEvent(v8::Isolate* isolate, - v8::Local sender, - v8::Local custom_event) { - if (event_template.IsEmpty()) { - event_template.Reset( - isolate, - ObjectTemplateBuilder(isolate, v8::ObjectTemplate::New(isolate)) - .SetMethod("preventDefault", &PreventDefault) - .Build()); - } - - v8::Local context = isolate->GetCurrentContext(); - CHECK(!context.IsEmpty()); - v8::Local event = - v8::Local::New(isolate, event_template) - ->NewInstance(context) - .ToLocalChecked(); - if (!sender.IsEmpty()) - Dictionary(isolate, event).Set("sender", sender); - if (!custom_event.IsEmpty()) - event->SetPrototype(context, custom_event).IsJust(); - return event; -} - -v8::Local CreateNativeEvent( - v8::Isolate* isolate, - v8::Local sender, - content::RenderFrameHost* frame, - electron::mojom::ElectronApiIPC::MessageSyncCallback callback) { - v8::Local event; - if (frame && callback) { - gin::Handle native_event = Event::Create(isolate); - native_event->SetCallback(std::move(callback)); - event = native_event.ToV8().As(); - } else { - // No need to create native event if we do not need to send reply. - event = CreateCustomEvent(isolate); - } - - Dictionary dict(isolate, event); - dict.Set("sender", sender); - // Should always set frameId even when callback is null. - if (frame) { - dict.Set("frameId", frame->GetRoutingID()); - dict.Set("processId", frame->GetProcess()->GetID()); - } - return event; -} - -} // namespace gin_helper::internal diff --git a/shell/common/gin_helper/event_emitter.h b/shell/common/gin_helper/event_emitter.h index c600e896af9..0ee3c49cf9e 100644 --- a/shell/common/gin_helper/event_emitter.h +++ b/shell/common/gin_helper/event_emitter.h @@ -10,6 +10,8 @@ #include "content/public/browser/browser_thread.h" #include "electron/shell/common/api/api.mojom.h" +#include "gin/handle.h" +#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/wrappable.h" @@ -19,20 +21,6 @@ class RenderFrameHost; namespace gin_helper { -namespace internal { - -v8::Local CreateCustomEvent( - v8::Isolate* isolate, - v8::Local sender = v8::Local(), - v8::Local custom_event = v8::Local()); -v8::Local CreateNativeEvent( - v8::Isolate* isolate, - v8::Local sender, - content::RenderFrameHost* frame, - electron::mojom::ElectronApiIPC::MessageSyncCallback callback); - -} // namespace internal - // Provide helperers to emit event in JavaScript. template class EventEmitter : public gin_helper::Wrappable { @@ -48,16 +36,6 @@ class EventEmitter : public gin_helper::Wrappable { return Base::GetWrapper(isolate); } - // this.emit(name, event, args...); - template - bool EmitCustomEvent(base::StringPiece name, - v8::Local event, - Args&&... args) { - return EmitWithEvent( - name, internal::CreateCustomEvent(isolate(), GetWrapper(), event), - std::forward(args)...); - } - // this.emit(name, new Event(), args...); template bool Emit(base::StringPiece name, Args&&... args) { @@ -65,8 +43,8 @@ class EventEmitter : public gin_helper::Wrappable { v8::Local wrapper = GetWrapper(); if (wrapper.IsEmpty()) return false; - v8::Local event = - internal::CreateCustomEvent(isolate(), wrapper); + gin::Handle event = + internal::Event::New(isolate()); return EmitWithEvent(name, event, std::forward(args)...); } @@ -81,20 +59,14 @@ class EventEmitter : public gin_helper::Wrappable { // this.emit(name, event, args...); template bool EmitWithEvent(base::StringPiece name, - v8::Local event, + gin::Handle event, Args&&... args) { // It's possible that |this| will be deleted by EmitEvent, so save anything // we need from |this| before calling EmitEvent. auto* isolate = this->isolate(); - auto context = isolate->GetCurrentContext(); gin_helper::EmitEvent(isolate, GetWrapper(), name, event, std::forward(args)...); - v8::Local defaultPrevented; - if (event->Get(context, gin::StringToV8(isolate, "defaultPrevented")) - .ToLocal(&defaultPrevented)) { - return defaultPrevented->BooleanValue(isolate); - } - return false; + return event->GetDefaultPrevented(); } }; diff --git a/shell/browser/event_emitter_mixin.cc b/shell/common/gin_helper/event_emitter_template.cc similarity index 83% rename from shell/browser/event_emitter_mixin.cc rename to shell/common/gin_helper/event_emitter_template.cc index 43e052a7715..bf5f7a08d62 100644 --- a/shell/browser/event_emitter_mixin.cc +++ b/shell/common/gin_helper/event_emitter_template.cc @@ -1,11 +1,14 @@ -// Copyright (c) 2019 Slack Technologies, Inc. +// Copyright (c) 2023 Salesforce, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "shell/browser/event_emitter_mixin.h" +#include "shell/common/gin_helper/event_emitter_template.h" -#include "gin/public/wrapper_info.h" +#include "gin/converter.h" +#include "gin/per_isolate_data.h" #include "shell/browser/api/electron_api_event_emitter.h" +#include "v8/include/v8-function.h" +#include "v8/include/v8-template.h" namespace gin_helper::internal { diff --git a/shell/common/gin_helper/event_emitter_template.h b/shell/common/gin_helper/event_emitter_template.h new file mode 100644 index 00000000000..efa677cd3c2 --- /dev/null +++ b/shell/common/gin_helper/event_emitter_template.h @@ -0,0 +1,19 @@ +// Copyright (c) 2023 Salesforce, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_EMITTER_TEMPLATE_H_ +#define ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_EMITTER_TEMPLATE_H_ + +namespace v8 { +class Isolate; +template +class Local; +class FunctionTemplate; +} // namespace v8 + +namespace gin_helper::internal { +v8::Local GetEventEmitterTemplate(v8::Isolate* isolate); +} + +#endif // ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_EMITTER_TEMPLATE_H_ diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 5784628eba3..922840dc0de 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -31,6 +31,7 @@ #include "shell/common/electron_command_line.h" #include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_helper/dictionary.h" +#include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event_emitter_caller.h" #include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/microtasks_scope.h" @@ -50,7 +51,6 @@ V(electron_browser_content_tracing) \ V(electron_browser_crash_reporter) \ V(electron_browser_dialog) \ - V(electron_browser_event) \ V(electron_browser_event_emitter) \ V(electron_browser_global_shortcut) \ V(electron_browser_in_app_purchase) \ @@ -463,6 +463,9 @@ void NodeBindings::Initialize() { SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX); #endif + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + gin_helper::internal::Event::GetConstructor(isolate->GetCurrentContext()); + g_is_initialized = true; } diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 656c83f4ff0..8521c288db5 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -1619,7 +1619,7 @@ describe('webContents module', () => { await w.webContents.loadURL('about:blank'); const promise: Promise<[string, string]> = new Promise(resolve => { w.webContents.once('ipc-message-sync', (event, channel, arg) => { - event.returnValue = 'foobar' as any; + event.returnValue = 'foobar'; resolve([channel, arg]); }); }); diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 964977314f6..5378150c5d4 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -1,4 +1,5 @@ // tslint:disable:ordered-imports curly no-console no-angle-bracket-type-assertion object-literal-sort-keys only-arrow-functions +/* eslint-disable */ import { app, @@ -23,7 +24,6 @@ import { session, systemPreferences, webContents, - Event, TouchBar } from 'electron' @@ -328,7 +328,7 @@ app.whenReady().then(() => { }) app.on('accessibility-support-changed', (_, enabled) => console.log('accessibility: ' + enabled)) -ipcMain.on('online-status-changed', (event: any, status: any) => { +ipcMain.on('online-status-changed', (event, status: any) => { console.log(status) }) diff --git a/typings/internal-ambient.d.ts b/typings/internal-ambient.d.ts index 580fec7688b..1a6df928d8e 100644 --- a/typings/internal-ambient.d.ts +++ b/typings/internal-ambient.d.ts @@ -197,10 +197,6 @@ declare namespace NodeJS { _linkedBinding(name: 'electron_browser_desktop_capturer'): { createDesktopCapturer(): ElectronInternal.DesktopCapturer; }; - _linkedBinding(name: 'electron_browser_event'): { - createWithSender(sender: Electron.WebContents): Electron.Event; - createEmpty(): Electron.Event; - }; _linkedBinding(name: 'electron_browser_event_emitter'): { setEventEmitterPrototype(prototype: Object): void; }; diff --git a/typings/internal-electron.d.ts b/typings/internal-electron.d.ts index df753fd471d..38f412666f3 100644 --- a/typings/internal-electron.d.ts +++ b/typings/internal-electron.d.ts @@ -110,7 +110,7 @@ declare namespace Electron { _shouldRegisterAcceleratorForCommandId(id: string): boolean; _getSharingItemForCommandId(id: string): SharingItem | null; _callMenuWillShow(): void; - _executeCommand(event: any, id: number): void; + _executeCommand(event: KeyboardEvent, id: number): void; _menuWillShow(): void; commandsMap: Record; groupsMap: Record; @@ -138,14 +138,16 @@ declare namespace Electron { acceleratorWorksWhenHidden?: boolean; } - interface IpcMainEvent { + interface ReplyChannel { sendReply(value: any): void; } + interface IpcMainEvent { + _replyChannel: ReplyChannel; + } + interface IpcMainInvokeEvent { - sendReply(value: any): void; - _reply(value: any): void; - _throw(error: Error | string): void; + _replyChannel: ReplyChannel; } class View {} @@ -222,10 +224,6 @@ declare namespace ElectronInternal { once(channel: string, listener: (event: IpcMainInternalEvent, ...args: any[]) => void): this; } - interface Event extends Electron.Event { - sender: WebContents; - } - interface LoadURLOptions extends Electron.LoadURLOptions { reloadIgnoringCache?: boolean; } diff --git a/yarn.lock b/yarn.lock index 5e419113b9d..8387ed7c148 100644 --- a/yarn.lock +++ b/yarn.lock @@ -134,10 +134,10 @@ optionalDependencies: "@types/glob" "^7.1.1" -"@electron/docs-parser@^1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-1.0.1.tgz#f9856d00ec1663a0fb6301f55bc674f44c7dc543" - integrity sha512-jqUHwo3MWUhWusHtTVpSHTZqWSVuc1sPUfavI5Zwdx64q7qd4phqOPGoxScWS3JthKt7Wydvo/eReIUNDJ0gRg== +"@electron/docs-parser@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-1.1.0.tgz#ba095def41746bde56bee731feaf22272bf0b765" + integrity sha512-qrjIKJk8t4/xAYldDVNQgcF8zdAAuG260bzPxdh/xI3p/yddm61bftoct+Tx2crnWFnOfOkr6nGERsDknNiT8A== dependencies: "@types/markdown-it" "^12.0.0" chai "^4.2.0" @@ -187,10 +187,10 @@ "@octokit/auth-app" "^3.6.1" "@octokit/rest" "^18.12.0" -"@electron/typescript-definitions@^8.10.0": - version "8.10.0" - resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.10.0.tgz#e9cf2b329ec4b0b76947ef751725383a6cf8994d" - integrity sha512-FVc2y0GUfxFZDoma0scYiMxkoalle19Fq332fNFGWoCJ9rCj5OUvriewSjPtGBsRuHv2xaMS5MhBuy2/pRuFuQ== +"@electron/typescript-definitions@^8.14.0": + version "8.14.0" + resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.14.0.tgz#a88f74e915317ba943b57ffe499b319d04f01ee3" + integrity sha512-J3b4is6L0NB4+r+7s1Hl1YlzaveKnQt1gswadRyMRwb4gFU3VAe2oBMJLOhFRJMs/9PK/Xp+y9QwyC92Tyqe6A== dependencies: "@types/node" "^11.13.7" chalk "^2.4.2"