Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
javascript and coffee editor working side by side
- requireing worker src inside modes - passing to index attached to mod
- Loading branch information
Showing
32 changed files
with
15,383 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ results | |
npm-debug.log | ||
node_modules | ||
|
||
worker | ||
workersrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var path = require('path') | ||
, uglify = require('uglify-js') | ||
, fs = require('fs') | ||
, workers = require('./workers') | ||
; | ||
|
||
|
||
function minify(code) { | ||
var compressor = uglify.Compressor() | ||
, ast = uglify.parse(code); | ||
|
||
ast.figure_out_scope(); | ||
return ast.transform(compressor).print_to_string(); | ||
} | ||
|
||
module.exports = function () { | ||
// 'php', 'xquery' not supported since they cannot be inlined even when minified before stringify | ||
workers.supported | ||
.forEach(function (worker) { | ||
var filename = worker.toLowerCase() + '.js'; | ||
var file = path.join(__dirname, '..', 'workersrc', filename); | ||
var src = fs.readFileSync(file, 'utf-8'); | ||
|
||
var dst = path.join(__dirname, '..', 'worker', filename); | ||
var stringified = JSON.stringify(minify(src)); | ||
|
||
// need a String object here so we can attach extra props like src | ||
var code = 'module.exports = new String(\'' + 'ace/mode/' + worker + '_worker\');\n' | ||
+ 'module.exports.src = ' + stringified + ';'; | ||
|
||
fs.writeFileSync(dst, code, 'utf-8'); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var blob; | ||
|
||
var workerSrc = mod.src; | ||
try { | ||
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder; | ||
blob = new BlobBuilder(); | ||
blob.append(workerSrc); | ||
blob = blob.getBlob(); | ||
} catch(e) { | ||
blob = new Blob([workerSrc]); | ||
} | ||
var blobUrl = (window.URL || window.webkitURL).createObjectURL(blob); | ||
|
||
this.$worker = new Worker(blobUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
var workers = module.exports = { | ||
coffee : [ 'coffee' ] | ||
, css : [ 'css', 'html', 'luapage', 'markdown', 'rhtml' ] | ||
, javascript : [ 'coldfusion', 'curly', 'django', 'groovy', 'html', 'java', 'javascript', 'luapage', 'markdown', 'rhtml', 'scala', 'svg', 'typescript' ] | ||
, json : [ 'json' ] | ||
, lua : [ 'lua', 'luapage' ] | ||
, php : [ 'php' ] | ||
, xquery : [ 'xquery' ] | ||
}; | ||
|
||
module.exports.supported = Object.keys(workers) | ||
.filter(function (w) { | ||
return w !== 'php' && w !== 'xquery'; | ||
}); | ||
|
||
function getWorkers(lang) { | ||
return Object.keys(workers) | ||
.filter(function (k) { | ||
return ~workers[k].indexOf(lang); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.