From: Cheng Zhao Date: Thu, 17 Dec 2015 14:03:16 +0000 (+0800) Subject: Remove sync call in remote module X-Git-Tag: v0.36.1~8^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=353f08e47786dce5801720b419d8ddb8c3249f1d;p=electron.git Remove sync call in remote module --- diff --git a/atom/browser/api/lib/exports/electron.coffee b/atom/browser/api/lib/exports/electron.coffee index 3f7d9b1a..9c61a550 100644 --- a/atom/browser/api/lib/exports/electron.coffee +++ b/atom/browser/api/lib/exports/electron.coffee @@ -1,7 +1,9 @@ +common = require '../../../../common/api/lib/exports/electron' + # Import common modules. -module.exports = require '../../../../common/api/lib/exports/electron' +common.defineProperties exports -Object.defineProperties module.exports, +Object.defineProperties exports, # Browser side modules, please sort with alphabet order. app: enumerable: true diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index e388a0fd..e0256081 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -219,9 +219,6 @@ ipcMain.on 'ATOM_BROWSER_GUEST_WEB_CONTENTS', (event, guestInstanceId) -> catch e event.returnValue = exceptionToMeta e -ipcMain.on 'ATOM_BROWSER_LIST_MODULES', (event) -> - event.returnValue = (name for name of electron) - ipcMain.on 'ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', (event, guestInstanceId, method, args...) -> try guestViewManager = require './guest-view-manager' diff --git a/atom/common/api/lib/exports/electron.coffee b/atom/common/api/lib/exports/electron.coffee index e9814430..7598f9ee 100644 --- a/atom/common/api/lib/exports/electron.coffee +++ b/atom/common/api/lib/exports/electron.coffee @@ -5,23 +5,25 @@ exports.hideInternalModules = -> # Remove the "common/api/lib" and "browser-or-renderer/api/lib". globalPaths.splice 0, 2 -Object.defineProperties exports, - # Common modules, please sort with alphabet order. - clipboard: - # Must be enumerable, otherwise it woulde be invisible to remote module. - enumerable: true - get: -> require '../clipboard' - crashReporter: - enumerable: true - get: -> require '../crash-reporter' - nativeImage: - enumerable: true - get: -> require '../native-image' - shell: - enumerable: true - get: -> require '../shell' - # The internal modules, invisible unless you know their names. - CallbacksRegistry: - get: -> require '../callbacks-registry' - deprecate: - get: -> require '../deprecate' +# Attaches properties to |exports|. +exports.defineProperties = (exports) -> + Object.defineProperties exports, + # Common modules, please sort with alphabet order. + clipboard: + # Must be enumerable, otherwise it woulde be invisible to remote module. + enumerable: true + get: -> require '../clipboard' + crashReporter: + enumerable: true + get: -> require '../crash-reporter' + nativeImage: + enumerable: true + get: -> require '../native-image' + shell: + enumerable: true + get: -> require '../shell' + # The internal modules, invisible unless you know their names. + CallbacksRegistry: + get: -> require '../callbacks-registry' + deprecate: + get: -> require '../deprecate' diff --git a/atom/renderer/api/lib/exports/electron.coffee b/atom/renderer/api/lib/exports/electron.coffee index a224818e..d0b3af3c 100644 --- a/atom/renderer/api/lib/exports/electron.coffee +++ b/atom/renderer/api/lib/exports/electron.coffee @@ -1,7 +1,9 @@ +common = require '../../../../common/api/lib/exports/electron' + # Import common modules. -module.exports = require '../../../../common/api/lib/exports/electron' +common.defineProperties exports -Object.defineProperties module.exports, +Object.defineProperties exports, # Renderer side modules, please sort with alphabet order. desktopCapturer: enumerable: true diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index 48cdd937..28285868 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -126,9 +126,9 @@ ipcRenderer.on 'ATOM_RENDERER_RELEASE_CALLBACK', (event, id) -> callbacksRegistry.remove id # List all built-in modules in browser process. -browserModules = ipcRenderer.sendSync 'ATOM_BROWSER_LIST_MODULES' +browserModules = require '../../../browser/api/lib/exports/electron' # And add a helper receiver for each one. -for name in browserModules +for name of browserModules do (name) -> Object.defineProperty exports, name, get: -> exports.getBuiltin name