Make "screen" module a browser module
This commit is contained in:
parent
551c39e241
commit
809c995c0b
5 changed files with 15 additions and 18 deletions
6
atom.gyp
6
atom.gyp
|
@ -25,6 +25,7 @@
|
||||||
'atom/browser/api/lib/menu-item.coffee',
|
'atom/browser/api/lib/menu-item.coffee',
|
||||||
'atom/browser/api/lib/power-monitor.coffee',
|
'atom/browser/api/lib/power-monitor.coffee',
|
||||||
'atom/browser/api/lib/protocol.coffee',
|
'atom/browser/api/lib/protocol.coffee',
|
||||||
|
'atom/browser/api/lib/screen.coffee',
|
||||||
'atom/browser/api/lib/tray.coffee',
|
'atom/browser/api/lib/tray.coffee',
|
||||||
'atom/browser/api/lib/web-contents.coffee',
|
'atom/browser/api/lib/web-contents.coffee',
|
||||||
'atom/browser/lib/chrome-extension.coffee',
|
'atom/browser/lib/chrome-extension.coffee',
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
'atom/common/api/lib/crash-reporter.coffee',
|
'atom/common/api/lib/crash-reporter.coffee',
|
||||||
'atom/common/api/lib/id-weak-map.coffee',
|
'atom/common/api/lib/id-weak-map.coffee',
|
||||||
'atom/common/api/lib/original-fs.coffee',
|
'atom/common/api/lib/original-fs.coffee',
|
||||||
'atom/common/api/lib/screen.coffee',
|
|
||||||
'atom/common/api/lib/shell.coffee',
|
'atom/common/api/lib/shell.coffee',
|
||||||
'atom/common/lib/init.coffee',
|
'atom/common/lib/init.coffee',
|
||||||
'atom/common/lib/asar.coffee',
|
'atom/common/lib/asar.coffee',
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
'atom/renderer/lib/web-view/web-view-constants.coffee',
|
'atom/renderer/lib/web-view/web-view-constants.coffee',
|
||||||
'atom/renderer/api/lib/ipc.coffee',
|
'atom/renderer/api/lib/ipc.coffee',
|
||||||
'atom/renderer/api/lib/remote.coffee',
|
'atom/renderer/api/lib/remote.coffee',
|
||||||
|
'atom/renderer/api/lib/screen.coffee',
|
||||||
'atom/renderer/api/lib/web-frame.coffee',
|
'atom/renderer/api/lib/web-frame.coffee',
|
||||||
],
|
],
|
||||||
'lib_sources': [
|
'lib_sources': [
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
'atom/browser/api/atom_api_power_monitor.h',
|
'atom/browser/api/atom_api_power_monitor.h',
|
||||||
'atom/browser/api/atom_api_protocol.cc',
|
'atom/browser/api/atom_api_protocol.cc',
|
||||||
'atom/browser/api/atom_api_protocol.h',
|
'atom/browser/api/atom_api_protocol.h',
|
||||||
|
'atom/browser/api/atom_api_screen.cc',
|
||||||
'atom/browser/api/atom_api_tray.cc',
|
'atom/browser/api/atom_api_tray.cc',
|
||||||
'atom/browser/api/atom_api_tray.h',
|
'atom/browser/api/atom_api_tray.h',
|
||||||
'atom/browser/api/atom_api_web_contents.cc',
|
'atom/browser/api/atom_api_web_contents.cc',
|
||||||
|
@ -199,8 +201,6 @@
|
||||||
'atom/common/api/atom_api_crash_reporter.cc',
|
'atom/common/api/atom_api_crash_reporter.cc',
|
||||||
'atom/common/api/atom_api_id_weak_map.cc',
|
'atom/common/api/atom_api_id_weak_map.cc',
|
||||||
'atom/common/api/atom_api_id_weak_map.h',
|
'atom/common/api/atom_api_id_weak_map.h',
|
||||||
'atom/common/api/atom_api_screen.cc',
|
|
||||||
'atom/common/api/atom_api_screen.h',
|
|
||||||
'atom/common/api/atom_api_shell.cc',
|
'atom/common/api/atom_api_shell.cc',
|
||||||
'atom/common/api/atom_api_v8_util.cc',
|
'atom/common/api/atom_api_v8_util.cc',
|
||||||
'atom/common/api/atom_bindings.cc',
|
'atom/common/api/atom_bindings.cc',
|
||||||
|
|
11
atom/browser/api/lib/screen.coffee
Normal file
11
atom/browser/api/lib/screen.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
binding = process.atomBinding 'screen'
|
||||||
|
|
||||||
|
checkAppIsReady = ->
|
||||||
|
unless process.type is 'renderer' or require('app').isReady()
|
||||||
|
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
|
||||||
|
|
||||||
|
for name, _ of binding
|
||||||
|
do (name) ->
|
||||||
|
module.exports[name] = (args...) ->
|
||||||
|
checkAppIsReady()
|
||||||
|
binding[name](args...)
|
|
@ -1,15 +0,0 @@
|
||||||
binding = process.atomBinding 'screen'
|
|
||||||
|
|
||||||
checkAppIsReady = ->
|
|
||||||
unless process.type is 'renderer' or require('app').isReady()
|
|
||||||
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
|
|
||||||
|
|
||||||
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
|
||||||
# On Linux and Windows we could not access screen in renderer process.
|
|
||||||
module.exports = require('remote').require 'screen'
|
|
||||||
else
|
|
||||||
for name, _ of binding
|
|
||||||
do (name) ->
|
|
||||||
module.exports[name] = (args...) ->
|
|
||||||
checkAppIsReady()
|
|
||||||
binding[name](args...)
|
|
1
atom/renderer/api/lib/screen.coffee
Normal file
1
atom/renderer/api/lib/screen.coffee
Normal file
|
@ -0,0 +1 @@
|
||||||
|
module.exports = require('remote').require('screen')
|
Loading…
Reference in a new issue