mirror of
https://github.com/atom/atom.git
synced 2026-02-05 20:25:04 -05:00
* Open the dev tools console * Call `atom.beginTracing()` * Do stuff * Call `atom.endTracing()` * Save the file somewhere * Open `about:tracing` in chrome and load the file * Inspect away!
70 lines
2.0 KiB
CoffeeScript
70 lines
2.0 KiB
CoffeeScript
fs = require('fs')
|
|
|
|
atom.configDirPath = fs.absolute("~/.atom")
|
|
atom.configFilePath = fs.join(atom.configDirPath, "atom.coffee")
|
|
|
|
atom.exitWhenDone = window.location.params.exitWhenDone
|
|
|
|
messageIdCounter = 1
|
|
originalSendMessageToBrowserProcess = atom.sendMessageToBrowserProcess
|
|
|
|
atom.pendingBrowserProcessCallbacks = {}
|
|
|
|
atom.sendMessageToBrowserProcess = (name, data=[], callbacks) ->
|
|
messageId = messageIdCounter++
|
|
data.unshift(messageId)
|
|
callbacks = [callbacks] if typeof callbacks is 'function'
|
|
@pendingBrowserProcessCallbacks[messageId] = callbacks
|
|
originalSendMessageToBrowserProcess(name, data)
|
|
|
|
atom.receiveMessageFromBrowserProcess = (name, data) ->
|
|
if name is 'reply'
|
|
[messageId, callbackIndex] = data.shift()
|
|
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data...)
|
|
|
|
atom.open = (args...) ->
|
|
@sendMessageToBrowserProcess('open', args)
|
|
|
|
atom.newWindow = (args...) ->
|
|
@sendMessageToBrowserProcess('newWindow', args)
|
|
|
|
atom.confirm = (message, detailedMessage, buttonLabelsAndCallbacks...) ->
|
|
args = [message, detailedMessage]
|
|
callbacks = []
|
|
while buttonLabelsAndCallbacks.length
|
|
args.push(buttonLabelsAndCallbacks.shift())
|
|
callbacks.push(buttonLabelsAndCallbacks.shift())
|
|
@sendMessageToBrowserProcess('confirm', args, callbacks)
|
|
|
|
atom.showSaveDialog = (callback) ->
|
|
@sendMessageToBrowserProcess('showSaveDialog', [], callback)
|
|
|
|
atom.toggleDevTools = ->
|
|
@sendMessageToBrowserProcess('toggleDevTools')
|
|
|
|
atom.showDevTools = ->
|
|
@sendMessageToBrowserProcess('showDevTools')
|
|
|
|
atom.focus = ->
|
|
@sendMessageToBrowserProcess('focus')
|
|
|
|
atom.exit = (status) ->
|
|
@sendMessageToBrowserProcess('exit', [status])
|
|
|
|
atom.beginTracing = ->
|
|
@sendMessageToBrowserProcess('beginTracing')
|
|
|
|
atom.endTracing = ->
|
|
@sendMessageToBrowserProcess('endTracing')
|
|
|
|
atom.getRootViewStateForPath = (path) ->
|
|
if json = localStorage[path]
|
|
JSON.parse(json)
|
|
|
|
atom.setRootViewStateForPath = (path, state) ->
|
|
return unless path
|
|
if state?
|
|
localStorage[path] = JSON.stringify(state)
|
|
else
|
|
delete localStorage[path]
|