mirror of
https://github.com/atom/atom.git
synced 2026-02-13 08:04:56 -05:00
Create task shell that bootstraps worker
This commit is contained in:
@@ -1,43 +1,23 @@
|
||||
eval("window = {};")
|
||||
eval("console = {};")
|
||||
console.warn = ->
|
||||
self.postMessage
|
||||
type: 'warn'
|
||||
details: arguments
|
||||
console.log = ->
|
||||
self.postMessage
|
||||
type: 'warn'
|
||||
details: arguments
|
||||
eval("attachEvent = function(){};")
|
||||
module.exports =
|
||||
loadTextmateSnippets: ({path}) ->
|
||||
fs = require 'fs'
|
||||
snippetsDirPath = fs.join(path, 'Snippets')
|
||||
snippets = fs.list(snippetsDirPath).map (snippetPath) ->
|
||||
fs.readPlist(snippetPath)
|
||||
self.postMessage
|
||||
type: 'loadSnippets'
|
||||
snippets: snippets
|
||||
|
||||
self.addEventListener 'message', (event) ->
|
||||
switch event.data.type
|
||||
when 'start'
|
||||
window.resourcePath = event.data.resourcePath
|
||||
importScripts(event.data.requirePath)
|
||||
self.postMessage(type:'started')
|
||||
else
|
||||
self[event.data.type](event.data)
|
||||
|
||||
self.loadTextmateSnippets = ({path}) ->
|
||||
fs = require 'fs'
|
||||
snippetsDirPath = fs.join(path, 'Snippets')
|
||||
snippets = fs.list(snippetsDirPath).map (snippetPath) ->
|
||||
fs.readPlist(snippetPath)
|
||||
self.postMessage
|
||||
type: 'loadSnippets'
|
||||
snippets: snippets
|
||||
|
||||
self.loadAtomSnippets = ({path}) ->
|
||||
fs = require 'fs'
|
||||
snippetsDirPath = fs.join(path, 'snippets')
|
||||
snippets = []
|
||||
for snippetsPath in fs.list(snippetsDirPath)
|
||||
continue if fs.base(snippetsPath).indexOf('.') is 0
|
||||
try
|
||||
snippets.push(fs.readObject(snippetsPath))
|
||||
catch e
|
||||
console.warn "Error reading snippets file '#{snippetsPath}'"
|
||||
self.postMessage
|
||||
type: 'loadSnippets'
|
||||
snippets: snippets
|
||||
loadAtomSnippets: ({path}) ->
|
||||
fs = require 'fs'
|
||||
snippetsDirPath = fs.join(path, 'snippets')
|
||||
snippets = []
|
||||
for snippetsPath in fs.list(snippetsDirPath)
|
||||
continue if fs.base(snippetsPath).indexOf('.') is 0
|
||||
try
|
||||
snippets.push(fs.readObject(snippetsPath))
|
||||
catch e
|
||||
console.warn "Error reading snippets file '#{snippetsPath}'"
|
||||
self.postMessage
|
||||
type: 'loadSnippets'
|
||||
snippets: snippets
|
||||
|
||||
21
src/stdlib/task-shell.coffee
Normal file
21
src/stdlib/task-shell.coffee
Normal file
@@ -0,0 +1,21 @@
|
||||
eval("window = {};")
|
||||
eval("attachEvent = function(){};")
|
||||
eval("console = {};")
|
||||
console.warn = ->
|
||||
self.postMessage
|
||||
type: 'warn'
|
||||
details: arguments
|
||||
console.log = ->
|
||||
self.postMessage
|
||||
type: 'warn'
|
||||
details: arguments
|
||||
|
||||
self.addEventListener 'message', (event) ->
|
||||
switch event.data.type
|
||||
when 'start'
|
||||
window.resourcePath = event.data.resourcePath
|
||||
importScripts(event.data.requirePath)
|
||||
self.task = require(event.data.taskPath)
|
||||
self.postMessage(type:'started')
|
||||
else
|
||||
self.task[event.data.type](event.data)
|
||||
@@ -1,13 +1,12 @@
|
||||
module.exports =
|
||||
class Task
|
||||
|
||||
constructor: (path) ->
|
||||
@path = require.getPath(path)
|
||||
constructor: (@path) ->
|
||||
|
||||
onProgress: (event) ->
|
||||
|
||||
start: ->
|
||||
worker = new Worker(@path)
|
||||
worker = new Worker(require.getPath('task-shell'))
|
||||
worker.onmessage = (event) =>
|
||||
switch event.data.type
|
||||
when 'warn'
|
||||
@@ -24,3 +23,4 @@ class Task
|
||||
type: 'start'
|
||||
resourcePath: window.resourcePath
|
||||
requirePath: require.getPath('require')
|
||||
taskPath: @path
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# Like sands through the hourglass, so are the days of our lives.
|
||||
date = new Date().getTime()
|
||||
require 'atom'
|
||||
require 'window'
|
||||
|
||||
pathToOpen = atom.getWindowState('pathToOpen') ? window.location.params.pathToOpen
|
||||
window.attachRootView(pathToOpen)
|
||||
atom.show()
|
||||
console.log "Load time: #{new Date().getTime() - date}"
|
||||
|
||||
Reference in New Issue
Block a user