coffeescript
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
var CoffeeScript, runScripts, | ||
var CoffeeScript, compile, runScripts, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -10,4 +10,7 @@ | ||
compile = CoffeeScript.compile; | ||
CoffeeScript["eval"] = function(code, options) { | ||
var _ref; | ||
if (options == null) { | ||
@@ -19,3 +22,3 @@ options = {}; | ||
} | ||
return eval(CoffeeScript.compile(code, options)); | ||
return eval(compile(code, options)); | ||
}; | ||
@@ -28,3 +31,3 @@ | ||
options.bare = true; | ||
return Function(CoffeeScript.compile(code, options))(); | ||
return Function(compile(code, options))(); | ||
}; | ||
@@ -36,7 +39,23 @@ | ||
if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null)) { | ||
compile = function(code, options) { | ||
var js, v3SourceMap, _ref; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
options.sourceMap = true; | ||
options.inline = true; | ||
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap; | ||
return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(v3SourceMap)) + "\n//@ sourceURL=coffeescript"; | ||
}; | ||
} | ||
CoffeeScript.load = function(url, callback, options) { | ||
var xhr; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
options.sourceFiles = [url]; | ||
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); | ||
@@ -49,2 +68,3 @@ xhr.open('GET', url, true); | ||
var _ref; | ||
if (xhr.readyState === 4) { | ||
@@ -66,2 +86,3 @@ if ((_ref = xhr.status) === 0 || _ref === 200) { | ||
var coffees, coffeetypes, execute, index, length, s, scripts; | ||
scripts = document.getElementsByTagName('script'); | ||
@@ -71,2 +92,3 @@ coffeetypes = ['text/coffeescript', 'text/literate-coffeescript']; | ||
var _i, _len, _ref, _results; | ||
_results = []; | ||
@@ -85,2 +107,3 @@ for (_i = 0, _len = scripts.length; _i < _len; _i++) { | ||
var mediatype, options, script; | ||
script = coffees[index++]; | ||
@@ -95,2 +118,3 @@ mediatype = script != null ? script.type : void 0; | ||
} else { | ||
options.sourceFiles = ['embedded']; | ||
CoffeeScript.run(script.innerHTML, options); | ||
@@ -97,0 +121,0 @@ return execute(); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -28,2 +28,3 @@ var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; | ||
var _ref; | ||
if (!action) { | ||
@@ -50,3 +51,4 @@ _ref = [description, action], action = _ref[0], description = _ref[1]; | ||
exports.run = function() { | ||
var arg, args, _i, _len, _ref, _results; | ||
var arg, args, e, _i, _len, _ref, _results; | ||
global.__originalDirname = fs.realpathSync('.'); | ||
@@ -64,3 +66,4 @@ process.chdir(cakefileDirectory(__originalDirname)); | ||
options = oparse.parse(args); | ||
} catch (e) { | ||
} catch (_error) { | ||
e = _error; | ||
return fatalError("" + e); | ||
@@ -79,2 +82,3 @@ } | ||
var cakefilePath, desc, name, relative, spaces, task; | ||
relative = path.relative || path.resolve; | ||
@@ -107,2 +111,3 @@ cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile'); | ||
var parent; | ||
if (existsSync(path.join(dir, 'Cakefile'))) { | ||
@@ -109,0 +114,0 @@ return dir; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
var Lexer, compile, ext, fs, helpers, lexer, loadFile, parser, path, sourcemap, vm, _i, _len, _ref, | ||
var Lexer, child_process, compile, ext, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, sourcemap, vm, _i, _len, _ref, | ||
__hasProp = {}.hasOwnProperty; | ||
@@ -8,4 +8,8 @@ | ||
vm = require('vm'); | ||
path = require('path'); | ||
child_process = require('child_process'); | ||
Lexer = require('./lexer').Lexer; | ||
@@ -17,30 +21,11 @@ | ||
vm = require('vm'); | ||
sourcemap = require('./sourcemap'); | ||
loadFile = function(module, filename) { | ||
var raw, stripped; | ||
raw = fs.readFileSync(filename, 'utf8'); | ||
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw; | ||
return module._compile(compile(stripped, { | ||
filename: filename, | ||
literate: helpers.isLiterate(filename) | ||
}), filename); | ||
}; | ||
exports.VERSION = '1.6.2'; | ||
if (require.extensions) { | ||
_ref = ['.coffee', '.litcoffee', '.md', '.coffee.md']; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
ext = _ref[_i]; | ||
require.extensions[ext] = loadFile; | ||
} | ||
} | ||
exports.VERSION = '1.6.1'; | ||
exports.helpers = helpers; | ||
exports.compile = compile = function(code, options) { | ||
var answer, coffeeFile, currentColumn, currentLine, fragment, fragments, header, js, jsFile, merge, newLines, sourceMap, _j, _len1; | ||
var answer, currentColumn, currentLine, fragment, fragments, header, js, merge, newLines, sourceMap, _i, _len; | ||
if (options == null) { | ||
@@ -50,37 +35,25 @@ options = {}; | ||
merge = exports.helpers.merge; | ||
try { | ||
if (options.sourceMap) { | ||
coffeeFile = helpers.baseFileName(options.filename); | ||
jsFile = helpers.baseFileName(options.filename, true) + ".js"; | ||
sourceMap = new sourcemap.SourceMap(); | ||
} | ||
fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options); | ||
currentLine = 0; | ||
if (options.header) { | ||
currentLine += 1; | ||
} | ||
if (options.sourceMap) { | ||
currentLine += 1; | ||
} | ||
currentColumn = 0; | ||
js = ""; | ||
for (_j = 0, _len1 = fragments.length; _j < _len1; _j++) { | ||
fragment = fragments[_j]; | ||
if (sourceMap) { | ||
if (fragment.locationData) { | ||
sourceMap.addMapping([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], { | ||
noReplace: true | ||
}); | ||
} | ||
newLines = helpers.count(fragment.code, "\n"); | ||
currentLine += newLines; | ||
currentColumn = fragment.code.length - (newLines ? fragment.code.lastIndexOf("\n") : 0); | ||
if (options.sourceMap) { | ||
sourceMap = new sourcemap.SourceMap(); | ||
} | ||
fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options); | ||
currentLine = 0; | ||
if (options.header || options.inline) { | ||
currentLine += 1; | ||
} | ||
currentColumn = 0; | ||
js = ""; | ||
for (_i = 0, _len = fragments.length; _i < _len; _i++) { | ||
fragment = fragments[_i]; | ||
if (sourceMap) { | ||
if (fragment.locationData) { | ||
sourceMap.addMapping([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], { | ||
noReplace: true | ||
}); | ||
} | ||
js += fragment.code; | ||
newLines = helpers.count(fragment.code, "\n"); | ||
currentLine += newLines; | ||
currentColumn = fragment.code.length - (newLines ? fragment.code.lastIndexOf("\n") : 0); | ||
} | ||
} catch (err) { | ||
if (options.filename) { | ||
err.message = "In " + options.filename + ", " + err.message; | ||
} | ||
throw err; | ||
js += fragment.code; | ||
} | ||
@@ -97,3 +70,3 @@ if (options.header) { | ||
answer.sourceMap = sourceMap; | ||
answer.v3SourceMap = sourcemap.generateV3SourceMap(sourceMap, coffeeFile, jsFile); | ||
answer.v3SourceMap = sourcemap.generateV3SourceMap(sourceMap, options, code); | ||
} | ||
@@ -119,3 +92,4 @@ return answer; | ||
exports.run = function(code, options) { | ||
var mainModule; | ||
var answer, mainModule, _ref; | ||
if (options == null) { | ||
@@ -125,7 +99,13 @@ options = {}; | ||
mainModule = require.main; | ||
if ((_ref = options.sourceMap) == null) { | ||
options.sourceMap = true; | ||
} | ||
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.'; | ||
mainModule.moduleCache && (mainModule.moduleCache = {}); | ||
mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename))); | ||
mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename || '.'))); | ||
if (!helpers.isCoffee(mainModule.filename) || require.extensions) { | ||
return mainModule._compile(compile(code, options), mainModule.filename); | ||
answer = compile(code, options); | ||
patchStackTrace(); | ||
mainModule._sourceMaps[mainModule.filename] = answer.sourceMap; | ||
return mainModule._compile(answer.js, mainModule.filename); | ||
} else { | ||
@@ -137,3 +117,4 @@ return mainModule._compile(code, mainModule.filename); | ||
exports["eval"] = function(code, options) { | ||
var Module, Script, js, k, o, r, sandbox, v, _j, _len1, _module, _ref1, _ref2, _require; | ||
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _require; | ||
if (options == null) { | ||
@@ -152,6 +133,6 @@ options = {}; | ||
sandbox = Script.createContext(); | ||
_ref1 = options.sandbox; | ||
for (k in _ref1) { | ||
if (!__hasProp.call(_ref1, k)) continue; | ||
v = _ref1[k]; | ||
_ref = options.sandbox; | ||
for (k in _ref) { | ||
if (!__hasProp.call(_ref, k)) continue; | ||
v = _ref[k]; | ||
sandbox[k] = v; | ||
@@ -173,5 +154,5 @@ } | ||
_module.filename = sandbox.__filename; | ||
_ref2 = Object.getOwnPropertyNames(require); | ||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { | ||
r = _ref2[_j]; | ||
_ref1 = Object.getOwnPropertyNames(require); | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
r = _ref1[_i]; | ||
if (r !== 'paths') { | ||
@@ -202,2 +183,42 @@ _require[r] = require[r]; | ||
loadFile = function(module, filename) { | ||
var raw, stripped; | ||
raw = fs.readFileSync(filename, 'utf8'); | ||
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw; | ||
return module._compile(compile(stripped, { | ||
filename: filename, | ||
literate: helpers.isLiterate(filename) | ||
}), filename); | ||
}; | ||
if (require.extensions) { | ||
_ref = ['.coffee', '.litcoffee', '.coffee.md']; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
ext = _ref[_i]; | ||
require.extensions[ext] = loadFile; | ||
} | ||
} | ||
if (child_process) { | ||
fork = child_process.fork; | ||
child_process.fork = function(path, args, options) { | ||
var execPath; | ||
if (args == null) { | ||
args = []; | ||
} | ||
if (options == null) { | ||
options = {}; | ||
} | ||
execPath = helpers.isCoffee(path) ? 'coffee' : null; | ||
if (!Array.isArray(args)) { | ||
args = []; | ||
options = args || {}; | ||
} | ||
options.execPath || (options.execPath = execPath); | ||
return fork(path, args, options); | ||
}; | ||
} | ||
lexer = new Lexer; | ||
@@ -208,2 +229,3 @@ | ||
var tag, token; | ||
token = this.tokens[this.pos++]; | ||
@@ -229,2 +251,104 @@ if (token) { | ||
parser.yy.parseError = function(message, _arg) { | ||
var token; | ||
token = _arg.token; | ||
message = "unexpected " + (token === 1 ? 'end of input' : token); | ||
return helpers.throwSyntaxError(message, parser.lexer.yylloc); | ||
}; | ||
patched = false; | ||
patchStackTrace = function() { | ||
var mainModule; | ||
if (patched) { | ||
return; | ||
} | ||
patched = true; | ||
mainModule = require.main; | ||
mainModule._sourceMaps = {}; | ||
return Error.prepareStackTrace = function(err, stack) { | ||
var frame, frames, getSourceMapping, sourceFiles, _ref1; | ||
sourceFiles = {}; | ||
getSourceMapping = function(filename, line, column) { | ||
var answer, sourceMap; | ||
sourceMap = mainModule._sourceMaps[filename]; | ||
if (sourceMap) { | ||
answer = sourceMap.getSourcePosition([line - 1, column - 1]); | ||
} | ||
if (answer) { | ||
return [answer[0] + 1, answer[1] + 1]; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
frames = (function() { | ||
var _j, _len1, _results; | ||
_results = []; | ||
for (_j = 0, _len1 = stack.length; _j < _len1; _j++) { | ||
frame = stack[_j]; | ||
if (frame.getFunction() === exports.run) { | ||
break; | ||
} | ||
_results.push(" at " + (formatSourcePosition(frame, getSourceMapping))); | ||
} | ||
return _results; | ||
})(); | ||
return "" + err.name + ": " + ((_ref1 = err.message) != null ? _ref1 : '') + "\n" + (frames.join('\n')) + "\n"; | ||
}; | ||
}; | ||
formatSourcePosition = function(frame, getSourceMapping) { | ||
var as, column, fileLocation, fileName, functionName, isConstructor, isMethodCall, line, methodName, source, tp, typeName; | ||
fileName = void 0; | ||
fileLocation = ''; | ||
if (frame.isNative()) { | ||
fileLocation = "native"; | ||
} else { | ||
if (frame.isEval()) { | ||
fileName = frame.getScriptNameOrSourceURL(); | ||
if (!fileName) { | ||
fileLocation = "" + (frame.getEvalOrigin()) + ", "; | ||
} | ||
} else { | ||
fileName = frame.getFileName(); | ||
} | ||
fileName || (fileName = "<anonymous>"); | ||
line = frame.getLineNumber(); | ||
column = frame.getColumnNumber(); | ||
source = getSourceMapping(fileName, line, column); | ||
fileLocation = source ? "" + fileName + ":" + source[0] + ":" + source[1] + ", <js>:" + line + ":" + column : "" + fileName + ":" + line + ":" + column; | ||
} | ||
functionName = frame.getFunctionName(); | ||
isConstructor = frame.isConstructor(); | ||
isMethodCall = !(frame.isToplevel() || isConstructor); | ||
if (isMethodCall) { | ||
methodName = frame.getMethodName(); | ||
typeName = frame.getTypeName(); | ||
if (functionName) { | ||
tp = as = ''; | ||
if (typeName && functionName.indexOf(typeName)) { | ||
tp = "" + typeName + "."; | ||
} | ||
if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) { | ||
as = " [as " + methodName + "]"; | ||
} | ||
return "" + tp + functionName + as + " (" + fileLocation + ")"; | ||
} else { | ||
return "" + typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")"; | ||
} | ||
} else if (isConstructor) { | ||
return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")"; | ||
} else if (functionName) { | ||
return "" + functionName + " (" + fileLocation + ")"; | ||
} else { | ||
return fileLocation; | ||
} | ||
}; | ||
}).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -53,2 +53,3 @@ var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref; | ||
var literals, source, _i, _len, _results; | ||
parseOptions(); | ||
@@ -105,2 +106,3 @@ if (opts.nodejs) { | ||
var file, index, _ref1, _ref2; | ||
if (err && err.code !== 'ENOENT') { | ||
@@ -118,2 +120,3 @@ throw err; | ||
var _i, _len, _results; | ||
_results = []; | ||
@@ -154,5 +157,9 @@ for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
compileScript = function(file, input, base) { | ||
var compiled, o, options, t, task; | ||
var compiled, err, message, o, options, t, task, useColors; | ||
if (base == null) { | ||
base = null; | ||
} | ||
o = opts; | ||
options = compileOptions(file); | ||
options = compileOptions(file, base); | ||
try { | ||
@@ -172,2 +179,5 @@ t = task = { | ||
} else if (o.join && t.file !== o.join) { | ||
if (helpers.isLiterate(file)) { | ||
t.input = helpers.invertLiterate(t.input); | ||
} | ||
sourceCode[sources.indexOf(t.file)] = t.input; | ||
@@ -186,3 +196,3 @@ return compileJoin(); | ||
} else if (o.compile || o.map) { | ||
return writeJs(base, t.file, t.output, t.sourceMap); | ||
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap); | ||
} else if (o.lint) { | ||
@@ -192,3 +202,4 @@ return lint(t.file, t.output); | ||
} | ||
} catch (err) { | ||
} catch (_error) { | ||
err = _error; | ||
CoffeeScript.emit('failure', err, task); | ||
@@ -198,7 +209,10 @@ if (CoffeeScript.listeners('failure').length) { | ||
} | ||
useColors = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; | ||
message = helpers.prettyErrorMessage(err, file || '[stdin]', input, useColors); | ||
if (o.watch) { | ||
return printLine(err.message + '\x07'); | ||
return printLine(message + '\x07'); | ||
} else { | ||
printWarn(message); | ||
return process.exit(1); | ||
} | ||
printWarn(err instanceof Error && err.stack || ("ERROR: " + err)); | ||
return process.exit(1); | ||
} | ||
@@ -209,2 +223,3 @@ }; | ||
var code, stdin; | ||
code = ''; | ||
@@ -239,3 +254,4 @@ stdin = process.openStdin(); | ||
watch = function(source, base) { | ||
var compile, compileTimeout, prevStats, rewatch, watchErr, watcher; | ||
var compile, compileTimeout, e, prevStats, rewatch, watchErr, watcher; | ||
prevStats = null; | ||
@@ -251,3 +267,4 @@ compileTimeout = null; | ||
return compile(); | ||
} catch (e) { | ||
} catch (_error) { | ||
e = _error; | ||
removeSource(source, base, true); | ||
@@ -283,3 +300,4 @@ return compileJoin(); | ||
watcher = fs.watch(source, compile); | ||
} catch (e) { | ||
} catch (_error) { | ||
e = _error; | ||
watchErr(e); | ||
@@ -296,3 +314,4 @@ } | ||
watchDir = function(source, base) { | ||
var readdirTimeout, watcher; | ||
var e, readdirTimeout, watcher; | ||
readdirTimeout = null; | ||
@@ -305,2 +324,3 @@ try { | ||
var file, _i, _len, _results; | ||
if (err) { | ||
@@ -333,3 +353,4 @@ if (err.code !== 'ENOENT') { | ||
}); | ||
} catch (e) { | ||
} catch (_error) { | ||
e = _error; | ||
if (e.code !== 'ENOENT') { | ||
@@ -343,5 +364,7 @@ throw e; | ||
var file, prevSources, toRemove, _i, _len; | ||
prevSources = sources.slice(0); | ||
toRemove = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
@@ -370,2 +393,3 @@ for (_i = 0, _len = sources.length; _i < _len; _i++) { | ||
var index, jsPath; | ||
index = sources.indexOf(source); | ||
@@ -391,6 +415,7 @@ sources.splice(index, 1); | ||
var baseDir, basename, dir, srcDir; | ||
if (extension == null) { | ||
extension = ".js"; | ||
} | ||
basename = helpers.baseFileName(source, true); | ||
basename = helpers.baseFileName(source, true, path.sep); | ||
srcDir = path.dirname(source); | ||
@@ -402,8 +427,8 @@ baseDir = base === '.' ? srcDir : srcDir.substring(base.length); | ||
writeJs = function(base, sourcePath, js, generatedSourceMap) { | ||
var compile, jsDir, jsPath, sourceMapPath; | ||
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) { | ||
var compile, jsDir, sourceMapPath; | ||
if (generatedSourceMap == null) { | ||
generatedSourceMap = null; | ||
} | ||
jsPath = outputPath(sourcePath, base); | ||
sourceMapPath = outputPath(sourcePath, base, ".map"); | ||
@@ -417,3 +442,3 @@ jsDir = path.dirname(jsPath); | ||
if (generatedSourceMap) { | ||
js = "//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath)) + "\n" + js; | ||
js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, path.sep)) + "\n*/\n"; | ||
} | ||
@@ -455,2 +480,3 @@ fs.writeFile(jsPath, js, function(err) { | ||
var conf, jsl, printIt; | ||
printIt = function(buffer) { | ||
@@ -469,4 +495,6 @@ return printLine(file + ':\t' + buffer.toString().trim()); | ||
var strings, tag, token, value; | ||
strings = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
@@ -486,2 +514,3 @@ for (_i = 0, _len = tokens.length; _i < _len; _i++) { | ||
var i, o, source, _i, _len; | ||
optionParser = new optparse.OptionParser(SWITCHES, BANNER); | ||
@@ -499,4 +528,6 @@ o = opts = optionParser.parse(process.argv.slice(2)); | ||
compileOptions = function(filename) { | ||
return { | ||
compileOptions = function(filename, base) { | ||
var answer, cwd, jsDir, jsPath; | ||
answer = { | ||
filename: filename, | ||
@@ -508,2 +539,22 @@ literate: helpers.isLiterate(filename), | ||
}; | ||
if (filename) { | ||
if (base) { | ||
cwd = process.cwd(); | ||
jsPath = outputPath(filename, base); | ||
jsDir = path.dirname(jsPath); | ||
answer = helpers.merge(answer, { | ||
jsPath: jsPath, | ||
sourceRoot: path.relative(jsDir, cwd), | ||
sourceFiles: [path.relative(cwd, filename)], | ||
generatedFile: helpers.baseFileName(jsPath, false, path.sep) | ||
}); | ||
} else { | ||
answer = helpers.merge(answer, { | ||
sourceRoot: "", | ||
sourceFiles: [helpers.baseFileName(filename, false, path.sep)], | ||
generatedFile: helpers.baseFileName(filename, true, path.sep) + ".js" | ||
}); | ||
} | ||
} | ||
return answer; | ||
}; | ||
@@ -513,2 +564,3 @@ | ||
var args, nodeArgs; | ||
nodeArgs = opts.nodejs.split(/\s+/); | ||
@@ -515,0 +567,0 @@ args = process.argv.slice(1); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -11,2 +11,3 @@ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; | ||
var addLocationDataFn, match, patternCount; | ||
patternString = patternString.replace(/\s{2,}/g, ' '); | ||
@@ -598,2 +599,3 @@ patternCount = patternString.split(' ').length; | ||
var _i, _j, _len, _len1, _ref, _results; | ||
_results = []; | ||
@@ -600,0 +602,0 @@ for (_i = 0, _len = alternatives.length; _i < _len; _i++) { |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
var buildLocationData, extend, flatten, _ref; | ||
var buildLocationData, extend, flatten, last, repeat, _ref; | ||
@@ -11,2 +11,3 @@ exports.starts = function(string, literal, start) { | ||
var len; | ||
len = literal.length; | ||
@@ -16,4 +17,19 @@ return literal === string.substr(string.length - len - (back || 0), len); | ||
exports.repeat = repeat = function(str, n) { | ||
var res; | ||
res = ''; | ||
while (n > 0) { | ||
if (n & 1) { | ||
res += str; | ||
} | ||
n >>>= 1; | ||
str += str; | ||
} | ||
return res; | ||
}; | ||
exports.compact = function(array) { | ||
var item, _i, _len, _results; | ||
_results = []; | ||
@@ -31,2 +47,3 @@ for (_i = 0, _len = array.length; _i < _len; _i++) { | ||
var num, pos; | ||
num = pos = 0; | ||
@@ -48,2 +65,3 @@ if (!substr.length) { | ||
var key, val; | ||
for (key in properties) { | ||
@@ -58,2 +76,3 @@ val = properties[key]; | ||
var element, flattened, _i, _len; | ||
flattened = []; | ||
@@ -73,2 +92,3 @@ for (_i = 0, _len = array.length; _i < _len; _i++) { | ||
var val; | ||
val = obj[key]; | ||
@@ -79,3 +99,3 @@ delete obj[key]; | ||
exports.last = function(array, back) { | ||
exports.last = last = function(array, back) { | ||
return array[array.length - (back || 0) - 1]; | ||
@@ -86,2 +106,3 @@ }; | ||
var e, _i, _len; | ||
for (_i = 0, _len = this.length; _i < _len; _i++) { | ||
@@ -96,2 +117,26 @@ e = this[_i]; | ||
exports.invertLiterate = function(code) { | ||
var line, lines, maybe_code; | ||
maybe_code = true; | ||
lines = (function() { | ||
var _i, _len, _ref1, _results; | ||
_ref1 = code.split('\n'); | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
line = _ref1[_i]; | ||
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) { | ||
_results.push(line); | ||
} else if (maybe_code = /^\s*$/.test(line)) { | ||
_results.push(line); | ||
} else { | ||
_results.push('# ' + line); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
return lines.join('\n'); | ||
}; | ||
buildLocationData = function(first, last) { | ||
@@ -121,2 +166,3 @@ if (!last) { | ||
var locationData; | ||
if (("2" in obj) && ("first_line" in obj[2])) { | ||
@@ -134,8 +180,12 @@ locationData = obj[2]; | ||
exports.baseFileName = function(file, stripExt) { | ||
exports.baseFileName = function(file, stripExt, pathSep) { | ||
var parts; | ||
if (stripExt == null) { | ||
stripExt = false; | ||
} | ||
parts = file.split('/'); | ||
if (pathSep == null) { | ||
pathSep = '/'; | ||
} | ||
parts = file.split(pathSep); | ||
file = parts[parts.length - 1]; | ||
@@ -147,3 +197,3 @@ if (!stripExt) { | ||
parts.pop(); | ||
if (parts[parts.length - 1] === 'coffee') { | ||
if (parts[parts.length - 1] === 'coffee' && parts.length > 1) { | ||
parts.pop(); | ||
@@ -162,2 +212,38 @@ } | ||
exports.throwSyntaxError = function(message, location) { | ||
var error, _ref1, _ref2; | ||
if ((_ref1 = location.last_line) == null) { | ||
location.last_line = location.first_line; | ||
} | ||
if ((_ref2 = location.last_column) == null) { | ||
location.last_column = location.first_column; | ||
} | ||
error = new SyntaxError(message); | ||
error.location = location; | ||
throw error; | ||
}; | ||
exports.prettyErrorMessage = function(error, fileName, code, useColors) { | ||
var codeLine, colorize, end, first_column, first_line, last_column, last_line, marker, message, start, _ref1; | ||
if (!error.location) { | ||
return error.stack || ("" + error); | ||
} | ||
_ref1 = error.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; | ||
codeLine = code.split('\n')[first_line]; | ||
start = first_column; | ||
end = first_line === last_line ? last_column + 1 : codeLine.length; | ||
marker = repeat(' ', start) + repeat('^', end - start); | ||
if (useColors) { | ||
colorize = function(str) { | ||
return "\x1B[1;31m" + str + "\x1B[0m"; | ||
}; | ||
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end); | ||
marker = colorize(marker); | ||
} | ||
message = "" + fileName + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + error.message + "\n" + codeLine + "\n" + marker; | ||
return message; | ||
}; | ||
}).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var key, val, _ref; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LITERATE, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, locationDataToString, starts, _ref, _ref1, | ||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, starts, throwSyntaxError, _ref, _ref1, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -8,6 +8,5 @@ | ||
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, locationDataToString = _ref1.locationDataToString; | ||
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError; | ||
exports.Lexer = Lexer = (function() { | ||
function Lexer() {} | ||
@@ -17,2 +16,3 @@ | ||
var consumed, i, tag, _ref2; | ||
if (opts == null) { | ||
@@ -48,3 +48,2 @@ opts = {}; | ||
Lexer.prototype.clean = function(code) { | ||
var line, lines, match; | ||
if (code.charCodeAt(0) === BOM) { | ||
@@ -59,17 +58,3 @@ code = code.slice(1); | ||
if (this.literate) { | ||
lines = (function() { | ||
var _i, _len, _ref2, _results; | ||
_ref2 = code.split('\n'); | ||
_results = []; | ||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { | ||
line = _ref2[_i]; | ||
if (match = LITERATE.exec(line)) { | ||
_results.push(line.slice(match[0].length)); | ||
} else { | ||
_results.push('# ' + line); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
code = lines.join('\n'); | ||
code = invertLiterate(code); | ||
} | ||
@@ -81,2 +66,3 @@ return code; | ||
var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, tag, tagToken, _ref2, _ref3, _ref4; | ||
if (!(match = IDENTIFIER.exec(this.chunk))) { | ||
@@ -164,2 +150,3 @@ return 0; | ||
var binaryLiteral, lexedLength, match, number, octalLiteral; | ||
if (!(match = NUMBER.exec(this.chunk))) { | ||
@@ -191,2 +178,3 @@ return 0; | ||
var match, octalEsc, string; | ||
switch (this.chunk.charAt(0)) { | ||
@@ -224,2 +212,3 @@ case "'": | ||
var doc, heredoc, match, quote; | ||
if (!(match = HEREDOC.exec(this.chunk))) { | ||
@@ -248,2 +237,3 @@ return 0; | ||
var comment, here, match; | ||
if (!(match = this.chunk.match(COMMENT))) { | ||
@@ -264,2 +254,3 @@ return 0; | ||
var match, script; | ||
if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) { | ||
@@ -274,2 +265,3 @@ return 0; | ||
var flags, length, match, prev, regex, _ref2, _ref3; | ||
if (this.chunk.charAt(0) !== '/') { | ||
@@ -302,2 +294,3 @@ return 0; | ||
var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; | ||
heregex = match[0], body = match[1], flags = match[2]; | ||
@@ -356,2 +349,3 @@ if (0 > body.indexOf('#{')) { | ||
var diff, indent, match, noNewlines, size; | ||
if (!(match = MULTI_DENT.exec(this.chunk))) { | ||
@@ -379,3 +373,3 @@ return 0; | ||
diff = size - this.indent + this.outdebt; | ||
this.token('INDENT', diff, 0, indent.length); | ||
this.token('INDENT', diff, indent.length - size, size); | ||
this.indents.push(diff); | ||
@@ -394,2 +388,3 @@ this.ends.push('OUTDENT'); | ||
var dent, len; | ||
while (moveOut > 0) { | ||
@@ -427,2 +422,3 @@ len = this.indents.length - 1; | ||
var match, nline, prev; | ||
if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) { | ||
@@ -461,2 +457,3 @@ return 0; | ||
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5; | ||
if (match = OPERATOR.exec(this.chunk)) { | ||
@@ -528,2 +525,3 @@ value = match[0]; | ||
var attempt, herecomment, indent, match, _ref2; | ||
indent = options.indent, herecomment = options.herecomment; | ||
@@ -548,5 +546,2 @@ if (herecomment) { | ||
} | ||
if (this.literate) { | ||
doc = doc.replace(/\n# \n/g, '\n\n'); | ||
} | ||
if (!herecomment) { | ||
@@ -560,2 +555,3 @@ doc = doc.replace(/^\n/, ''); | ||
var i, stack, tok, tokens; | ||
if (this.tag() !== ')') { | ||
@@ -594,2 +590,3 @@ return this; | ||
var continueCount, i, letter, match, prev, stack, _i, _ref2; | ||
continueCount = 0; | ||
@@ -629,3 +626,4 @@ stack = [end]; | ||
Lexer.prototype.interpolateString = function(str, options) { | ||
var column, expr, heredoc, i, inner, interpolated, len, letter, lexedLength, line, locationToken, nested, offsetInChunk, pi, plusToken, popped, regex, strOffset, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; | ||
var column, expr, heredoc, i, inner, interpolated, len, letter, lexedLength, line, locationToken, nested, offsetInChunk, pi, plusToken, popped, regex, rparen, strOffset, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; | ||
if (options == null) { | ||
@@ -720,3 +718,5 @@ options = {}; | ||
if (interpolated) { | ||
this.token(')', ')', offsetInChunk + lexedLength, 0); | ||
rparen = this.makeToken(')', ')', offsetInChunk + lexedLength, 0); | ||
rparen.stringEnd = true; | ||
this.tokens.push(rparen); | ||
} | ||
@@ -728,2 +728,3 @@ return tokens; | ||
var size, wanted; | ||
if (tag !== (wanted = last(this.ends))) { | ||
@@ -742,2 +743,3 @@ if ('OUTDENT' !== wanted) { | ||
var column, lineCount, lines, string; | ||
if (offset === 0) { | ||
@@ -764,2 +766,3 @@ return [this.chunkLine, this.chunkColumn]; | ||
var lastCharacter, locationData, token, _ref2, _ref3; | ||
if (offsetInChunk == null) { | ||
@@ -774,3 +777,3 @@ offsetInChunk = 0; | ||
lastCharacter = Math.max(0, length - 1); | ||
_ref3 = this.getLineAndColumnFromChunk(offsetInChunk + (length - 1)), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1]; | ||
_ref3 = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1]; | ||
token = [tag, value, locationData]; | ||
@@ -782,2 +785,3 @@ return token; | ||
var token; | ||
token = this.makeToken(tag, value, offsetInChunk, length); | ||
@@ -790,2 +794,3 @@ this.tokens.push(token); | ||
var tok; | ||
return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]); | ||
@@ -796,2 +801,3 @@ }; | ||
var tok; | ||
return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]); | ||
@@ -802,2 +808,3 @@ }; | ||
var _ref2; | ||
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); | ||
@@ -826,3 +833,6 @@ }; | ||
Lexer.prototype.error = function(message) { | ||
throw SyntaxError("" + message + " on line " + (this.chunkLine + 1)); | ||
return throwSyntaxError(message, { | ||
first_line: this.chunkLine, | ||
first_column: this.chunkColumn | ||
}); | ||
}; | ||
@@ -852,2 +862,3 @@ | ||
var _results; | ||
_results = []; | ||
@@ -886,4 +897,2 @@ for (key in COFFEE_ALIAS_MAP) { | ||
LITERATE = /^([ ]{4}|\t)/; | ||
CODE = /^[-=]>/; | ||
@@ -890,0 +899,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -6,3 +6,2 @@ var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments; | ||
exports.OptionParser = OptionParser = (function() { | ||
function OptionParser(rules, banner) { | ||
@@ -15,2 +14,3 @@ this.banner = banner; | ||
var arg, i, isOption, matchedRule, options, originalArgs, pos, rule, seenNonOptionArg, skippingArgument, value, _i, _j, _len, _len1, _ref; | ||
options = { | ||
@@ -64,2 +64,3 @@ "arguments": [] | ||
var letPart, lines, rule, spaces, _i, _len, _ref; | ||
lines = []; | ||
@@ -94,2 +95,3 @@ if (this.banner) { | ||
var tuple, _i, _len, _results; | ||
_results = []; | ||
@@ -108,2 +110,3 @@ for (_i = 0, _len = rules.length; _i < _len; _i++) { | ||
var match; | ||
if (options == null) { | ||
@@ -126,2 +129,3 @@ options = {}; | ||
var arg, l, match, result, _i, _j, _len, _len1, _ref; | ||
args = args.slice(0); | ||
@@ -128,0 +132,0 @@ result = []; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
var CoffeeScript, addMultilineHandler, merge, nodeREPL, replDefaults, vm; | ||
var CoffeeScript, addMultilineHandler, merge, nodeREPL, prettyErrorMessage, replDefaults, vm, _ref; | ||
@@ -11,3 +11,3 @@ vm = require('vm'); | ||
merge = require('./helpers').merge; | ||
_ref = require('./helpers'), merge = _ref.merge, prettyErrorMessage = _ref.prettyErrorMessage; | ||
@@ -17,16 +17,18 @@ replDefaults = { | ||
"eval": function(input, context, filename, cb) { | ||
var js; | ||
var Assign, Block, Literal, Value, ast, err, js, _ref1; | ||
input = input.replace(/\uFF00/g, '\n'); | ||
input = input.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3'); | ||
if (/^(\s*|\(\s*\))$/.test(input)) { | ||
return cb(null); | ||
} | ||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); | ||
_ref1 = require('./nodes'), Block = _ref1.Block, Assign = _ref1.Assign, Value = _ref1.Value, Literal = _ref1.Literal; | ||
try { | ||
js = CoffeeScript.compile("_=(" + input + "\n)", { | ||
filename: filename, | ||
bare: true | ||
ast = CoffeeScript.nodes(input); | ||
ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]); | ||
js = ast.compile({ | ||
bare: true, | ||
locals: Object.keys(context) | ||
}); | ||
return cb(null, vm.runInContext(js, context, filename)); | ||
} catch (err) { | ||
return cb(err); | ||
} catch (_error) { | ||
err = _error; | ||
return cb(prettyErrorMessage(err, filename, input, true)); | ||
} | ||
@@ -38,2 +40,3 @@ } | ||
var inputStream, multiline, nodeLineListener, outputStream, rli; | ||
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream; | ||
@@ -93,6 +96,14 @@ multiline = { | ||
start: function(opts) { | ||
var repl; | ||
var build, major, minor, repl, _ref1; | ||
if (opts == null) { | ||
opts = {}; | ||
} | ||
_ref1 = process.versions.node.split('.').map(function(n) { | ||
return parseInt(n); | ||
}), major = _ref1[0], minor = _ref1[1], build = _ref1[2]; | ||
if (major === 0 && minor < 8) { | ||
console.warn("Node 0.8.0+ required for CoffeeScript REPL"); | ||
process.exit(1); | ||
} | ||
opts = merge(replDefaults, opts); | ||
@@ -99,0 +110,0 @@ repl = nodeREPL.start(opts); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -9,2 +9,3 @@ var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, | ||
var tok; | ||
tok = [tag, value]; | ||
@@ -16,3 +17,2 @@ tok.generated = true; | ||
exports.Rewriter = (function() { | ||
function Rewriter() {} | ||
@@ -35,2 +35,3 @@ | ||
var i, token, tokens; | ||
tokens = this.tokens; | ||
@@ -46,2 +47,3 @@ i = 0; | ||
var levels, token, tokens, _ref, _ref1; | ||
tokens = this.tokens; | ||
@@ -68,2 +70,3 @@ levels = 0; | ||
var i, tag, _i, _len, _ref; | ||
_ref = this.tokens; | ||
@@ -84,2 +87,3 @@ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { | ||
var _ref; | ||
if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) { | ||
@@ -95,4 +99,6 @@ return 1; | ||
var action, condition; | ||
condition = function(token, i) { | ||
var _ref; | ||
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; | ||
@@ -113,4 +119,6 @@ }; | ||
var action, condition; | ||
condition = function(token, i) { | ||
var _ref; | ||
return (_ref = token[0]) === ']' || _ref === 'INDEX_END'; | ||
@@ -131,2 +139,3 @@ }; | ||
var fuzz, i, j, pattern, _i, _ref, _ref1; | ||
i = arguments[0], pattern = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
@@ -157,2 +166,3 @@ fuzz = 0; | ||
var backStack, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
backStack = []; | ||
@@ -173,5 +183,7 @@ while (i >= 0 && (backStack.length || (_ref2 = this.tag(i), __indexOf.call(tags, _ref2) < 0) && ((_ref3 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref3) < 0) || this.tokens[i].generated) && (_ref4 = this.tag(i), __indexOf.call(LINEBREAKS, _ref4) < 0))) { | ||
var stack; | ||
stack = []; | ||
return this.scanTokens(function(token, i, tokens) { | ||
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
tag = token[0]; | ||
@@ -189,2 +201,3 @@ prevTag = (i > 0 ? tokens[i - 1] : [])[0]; | ||
var _ref, _ref1; | ||
return (_ref = stackTop()) != null ? (_ref1 = _ref[2]) != null ? _ref1.ours : void 0 : void 0; | ||
@@ -194,2 +207,3 @@ }; | ||
var _ref; | ||
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '('; | ||
@@ -199,2 +213,3 @@ }; | ||
var _ref; | ||
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '{'; | ||
@@ -204,2 +219,3 @@ }; | ||
var _ref; | ||
return inImplicit && ((_ref = stackTop()) != null ? _ref[0] : void 0) === 'CONTROL'; | ||
@@ -209,2 +225,3 @@ }; | ||
var idx; | ||
idx = j != null ? j : i; | ||
@@ -228,2 +245,3 @@ stack.push([ | ||
var idx; | ||
if (startsLine == null) { | ||
@@ -287,3 +305,3 @@ startsLine = true; | ||
} | ||
if ((__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (__indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || __indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !((_ref = tokens[i + 1]) != null ? _ref.spaced : void 0) && !((_ref1 = tokens[i + 1]) != null ? _ref1.newLine : void 0))) { | ||
if ((__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced && !token.stringEnd || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (__indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || __indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !((_ref = tokens[i + 1]) != null ? _ref.spaced : void 0) && !((_ref1 = tokens[i + 1]) != null ? _ref1.newLine : void 0))) { | ||
if (tag === '?') { | ||
@@ -352,3 +370,4 @@ tag = token[0] = 'FUNC_EXIST'; | ||
return this.scanTokens(function(token, i, tokens) { | ||
var last_column, last_line, _ref, _ref1, _ref2; | ||
var column, line, nextLocation, prevLocation, _ref, _ref1; | ||
if (token[2]) { | ||
@@ -360,11 +379,14 @@ return 1; | ||
} | ||
_ref2 = (_ref = (_ref1 = tokens[i - 1]) != null ? _ref1[2] : void 0) != null ? _ref : { | ||
last_line: 0, | ||
last_column: 0 | ||
}, last_line = _ref2.last_line, last_column = _ref2.last_column; | ||
if (token[0] === '{' && (nextLocation = (_ref = tokens[i + 1]) != null ? _ref[2] : void 0)) { | ||
line = nextLocation.first_line, column = nextLocation.first_column; | ||
} else if (prevLocation = (_ref1 = tokens[i - 1]) != null ? _ref1[2] : void 0) { | ||
line = prevLocation.last_line, column = prevLocation.last_column; | ||
} else { | ||
line = column = 0; | ||
} | ||
token[2] = { | ||
first_line: last_line, | ||
first_column: last_column, | ||
last_line: last_line, | ||
last_column: last_column | ||
first_line: line, | ||
first_column: column, | ||
last_line: line, | ||
last_column: column | ||
}; | ||
@@ -377,5 +399,7 @@ return 1; | ||
var action, condition, indent, outdent, starter; | ||
starter = indent = outdent = null; | ||
condition = function(token, i) { | ||
var _ref; | ||
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN')); | ||
@@ -388,2 +412,3 @@ }; | ||
var tag, _ref, _ref1; | ||
tag = token[0]; | ||
@@ -395,7 +420,7 @@ if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') { | ||
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { | ||
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation(token)))); | ||
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation()))); | ||
return 2; | ||
} | ||
if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) { | ||
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation(token)))); | ||
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation()))); | ||
return 4; | ||
@@ -405,3 +430,3 @@ } | ||
starter = tag; | ||
_ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1]; | ||
_ref1 = this.indentation(true), indent = _ref1[0], outdent = _ref1[1]; | ||
if (starter === 'THEN') { | ||
@@ -423,6 +448,10 @@ indent.fromThen = true; | ||
var action, condition, original; | ||
original = null; | ||
condition = function(token, i) { | ||
var _ref; | ||
return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT'; | ||
var prevTag, tag; | ||
tag = token[0]; | ||
prevTag = this.tokens[i - 1][0]; | ||
return tag === 'TERMINATOR' || (tag === 'INDENT' && __indexOf.call(SINGLE_LINERS, prevTag) < 0); | ||
}; | ||
@@ -444,4 +473,5 @@ action = function(token, i) { | ||
Rewriter.prototype.indentation = function(token, implicit) { | ||
Rewriter.prototype.indentation = function(implicit) { | ||
var indent, outdent; | ||
if (implicit == null) { | ||
@@ -465,2 +495,3 @@ implicit = false; | ||
var _ref; | ||
return (_ref = this.tokens[i]) != null ? _ref[0] : void 0; | ||
@@ -491,3 +522,3 @@ }; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
@@ -494,0 +525,0 @@ IMPLICIT_UNSPACED_CALL = ['+', '-']; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -8,3 +8,2 @@ var Scope, extend, last, _ref; | ||
exports.Scope = Scope = (function() { | ||
Scope.root = null; | ||
@@ -44,2 +43,3 @@ | ||
var _ref1; | ||
if (((_ref1 = this.method) != null ? _ref1.name : void 0) || !this.parent) { | ||
@@ -68,2 +68,3 @@ return this.method; | ||
var _ref1; | ||
return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0)); | ||
@@ -82,2 +83,3 @@ }; | ||
var v, _i, _len, _ref1; | ||
_ref1 = this.variables; | ||
@@ -95,2 +97,3 @@ for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
var index, temp; | ||
if (reserve == null) { | ||
@@ -123,2 +126,3 @@ reserve = true; | ||
var realVars, tempVars, v, _i, _len, _ref1; | ||
realVars = []; | ||
@@ -138,2 +142,3 @@ tempVars = []; | ||
var v, _i, _len, _ref1, _results; | ||
_ref1 = this.variables; | ||
@@ -140,0 +145,0 @@ _results = []; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.1 | ||
// Generated by CoffeeScript 1.6.2 | ||
(function() { | ||
@@ -6,3 +6,2 @@ var BASE64_CHARS, LineMapping, MAX_BASE64_VALUE, VLQ_CONTINUATION_BIT, VLQ_SHIFT, VLQ_VALUE_MASK, decodeBase64Char, encodeBase64Char; | ||
LineMapping = (function() { | ||
function LineMapping(generatedLine) { | ||
@@ -16,2 +15,3 @@ this.generatedLine = generatedLine; | ||
var sourceColumn, sourceLine; | ||
sourceLine = _arg[0], sourceColumn = _arg[1]; | ||
@@ -38,2 +38,3 @@ if (options == null) { | ||
var answer, columnMapping, lastColumnMapping, _i, _len, _ref; | ||
answer = null; | ||
@@ -60,3 +61,2 @@ lastColumnMapping = null; | ||
exports.SourceMap = (function() { | ||
function SourceMap() { | ||
@@ -68,2 +68,3 @@ this.generatedLines = []; | ||
var generatedColumn, generatedLine, lineMapping; | ||
if (options == null) { | ||
@@ -82,2 +83,3 @@ options = {}; | ||
var answer, generatedColumn, generatedLine, lineMapping; | ||
generatedLine = _arg[0], generatedColumn = _arg[1]; | ||
@@ -96,2 +98,3 @@ answer = null; | ||
var columnMapping, generatedLineNumber, lineMapping, _i, _len, _ref, _results; | ||
_ref = this.generatedLines; | ||
@@ -104,2 +107,3 @@ _results = []; | ||
var _j, _len1, _ref1, _results1; | ||
_ref1 = lineMapping.columnMappings; | ||
@@ -124,10 +128,11 @@ _results1 = []; | ||
exports.generateV3SourceMap = function(sourceMap, sourceFile, generatedFile) { | ||
var answer, lastGeneratedColumnWritten, lastSourceColumnWritten, lastSourceLineWritten, mappings, needComma, writingGeneratedLine; | ||
if (sourceFile == null) { | ||
sourceFile = null; | ||
exports.generateV3SourceMap = function(sourceMap, options, code) { | ||
var answer, generatedFile, lastGeneratedColumnWritten, lastSourceColumnWritten, lastSourceLineWritten, mappings, needComma, sourceFiles, sourceRoot, writingGeneratedLine; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (generatedFile == null) { | ||
generatedFile = null; | ||
} | ||
sourceRoot = options.sourceRoot || ""; | ||
sourceFiles = options.sourceFiles || [""]; | ||
generatedFile = options.generatedFile || ""; | ||
writingGeneratedLine = 0; | ||
@@ -162,7 +167,10 @@ lastGeneratedColumnWritten = 0; | ||
file: generatedFile, | ||
sourceRoot: "", | ||
sources: sourceFile ? [sourceFile] : [], | ||
sourceRoot: sourceRoot, | ||
sources: sourceFiles, | ||
names: [], | ||
mappings: mappings | ||
}; | ||
if (options.inline) { | ||
answer.sourcesContent = [code]; | ||
} | ||
return JSON.stringify(answer, null, 2); | ||
@@ -190,2 +198,3 @@ }; | ||
var value; | ||
value = BASE64_CHARS.indexOf(char); | ||
@@ -206,2 +215,3 @@ if (value === -1) { | ||
var answer, nextVlqChunk, signBit, valueToEncode; | ||
signBit = value < 0 ? 1 : 0; | ||
@@ -223,2 +233,3 @@ valueToEncode = (Math.abs(value) << 1) + signBit; | ||
var consumed, continuationShift, done, nextChunkValue, nextVlqChunk, position, signBit, value; | ||
if (offset == null) { | ||
@@ -225,0 +236,0 @@ offset = 0; |
@@ -6,3 +6,3 @@ { | ||
"author": "Jeremy Ashkenas", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"licenses": [{ | ||
@@ -13,3 +13,3 @@ "type": "MIT", | ||
"engines": { | ||
"node": ">=0.4.0" | ||
"node": ">=0.8.0" | ||
}, | ||
@@ -16,0 +16,0 @@ "directories" : { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
355071
7317
12
4