util and browser-cola are updated
This commit is contained in:
parent
58442e1ad4
commit
661c1f5751
26
bin/cola
26
bin/cola
|
|
@ -21,7 +21,8 @@ mangling you need to use `-c` and `-m`.\
|
||||||
")
|
")
|
||||||
.describe("j", "Work with JavaScript (by default Cola will expect ColaScript).")
|
.describe("j", "Work with JavaScript (by default Cola will expect ColaScript).")
|
||||||
.describe("n", "Enable compilation for node.")
|
.describe("n", "Enable compilation for node.")
|
||||||
.describe("k", "Path to packages.json (packages.json by default).")
|
.describe("P", "Path to packages.json (packages.json by default).")
|
||||||
|
.describe("i", "ignore `main` wrapping.")
|
||||||
.describe("source-map", "Specify an output file where to generate source map.")
|
.describe("source-map", "Specify an output file where to generate source map.")
|
||||||
.describe("source-map-root", "The path to the original source to be included in the source map.")
|
.describe("source-map-root", "The path to the original source to be included in the source map.")
|
||||||
.describe("source-map-url", "The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.")
|
.describe("source-map-url", "The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.")
|
||||||
|
|
@ -29,7 +30,6 @@ mangling you need to use `-c` and `-m`.\
|
||||||
.describe("in-source-map", "Input source map, useful if you're compressing JS that was generated from some other original code.")
|
.describe("in-source-map", "Input source map, useful if you're compressing JS that was generated from some other original code.")
|
||||||
.describe("screw-ie8", "Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks (by default Cola will try to be IE-proof).")
|
.describe("screw-ie8", "Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks (by default Cola will try to be IE-proof).")
|
||||||
.describe("expr", "Parse a single expression, rather than a program (for parsing JSON)")
|
.describe("expr", "Parse a single expression, rather than a program (for parsing JSON)")
|
||||||
.describe("i", "ignore `main` binding.")
|
|
||||||
.describe("p", "Skip prefix for original filenames that appear in source maps. \
|
.describe("p", "Skip prefix for original filenames that appear in source maps. \
|
||||||
For example -p 3 will drop 3 directories from file names and ensure they are relative paths. \
|
For example -p 3 will drop 3 directories from file names and ensure they are relative paths. \
|
||||||
You can also specify -p relative, which will make Cola figure out itself the relative paths between original sources, \
|
You can also specify -p relative, which will make Cola figure out itself the relative paths between original sources, \
|
||||||
|
|
@ -61,6 +61,7 @@ parsed, but the source map will adjust for its presence.")
|
||||||
.describe("acorn", "Use Acorn for parsing.")
|
.describe("acorn", "Use Acorn for parsing.")
|
||||||
.describe("spidermonkey", "Assume input files are SpiderMonkey AST format (as JSON).")
|
.describe("spidermonkey", "Assume input files are SpiderMonkey AST format (as JSON).")
|
||||||
.describe("self", "Build itself (Cola) as a library (implies --wrap=Cola --export-all)")
|
.describe("self", "Build itself (Cola) as a library (implies --wrap=Cola --export-all)")
|
||||||
|
.describe("browser-cola", "Build itself (Cola) for running Cola in browser.")
|
||||||
.describe("wrap", "Embed everything in a big function, making the “exports” and “global” variables available. \
|
.describe("wrap", "Embed everything in a big function, making the “exports” and “global” variables available. \
|
||||||
You need to pass an argument to this option to specify the name that your module will take when included in, say, a browser.")
|
You need to pass an argument to this option to specify the name that your module will take when included in, say, a browser.")
|
||||||
.describe("export-all", "Only used when --wrap, this tells Cola to add code to automatically export all globals.")
|
.describe("export-all", "Only used when --wrap, this tells Cola to add code to automatically export all globals.")
|
||||||
|
|
@ -72,8 +73,8 @@ You need to pass an argument to this option to specify the name that your module
|
||||||
.alias("j", "js")
|
.alias("j", "js")
|
||||||
.alias("j", "javascript")
|
.alias("j", "javascript")
|
||||||
.alias("n", "node")
|
.alias("n", "node")
|
||||||
.alias("k", "packages")
|
.alias("P", "packages")
|
||||||
.alias("i", "ignore-main-binding")
|
.alias("i", "ignore-main-wrapping")
|
||||||
.alias("p", "prefix")
|
.alias("p", "prefix")
|
||||||
.alias("o", "output")
|
.alias("o", "output")
|
||||||
.alias("v", "verbose")
|
.alias("v", "verbose")
|
||||||
|
|
@ -85,7 +86,7 @@ You need to pass an argument to this option to specify the name that your module
|
||||||
.alias("V", "version")
|
.alias("V", "version")
|
||||||
.alias("e", "enclose")
|
.alias("e", "enclose")
|
||||||
|
|
||||||
.string("k")
|
.string("P")
|
||||||
.string("source-map")
|
.string("source-map")
|
||||||
.string("source-map-root")
|
.string("source-map-root")
|
||||||
.string("source-map-url")
|
.string("source-map-url")
|
||||||
|
|
@ -106,6 +107,7 @@ You need to pass an argument to this option to specify the name that your module
|
||||||
.boolean("screw-ie8")
|
.boolean("screw-ie8")
|
||||||
.boolean("export-all")
|
.boolean("export-all")
|
||||||
.boolean("self")
|
.boolean("self")
|
||||||
|
.boolean("browser-cola")
|
||||||
.boolean("v")
|
.boolean("v")
|
||||||
.boolean("stats")
|
.boolean("stats")
|
||||||
.boolean("acorn")
|
.boolean("acorn")
|
||||||
|
|
@ -204,6 +206,16 @@ if (ARGS.self) {
|
||||||
files = Cola.FILES;
|
files = Cola.FILES;
|
||||||
if (!ARGS.wrap) ARGS.wrap = "Cola";
|
if (!ARGS.wrap) ARGS.wrap = "Cola";
|
||||||
ARGS.export_all = true;
|
ARGS.export_all = true;
|
||||||
|
ARGS.j = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ARGS.browser_cola) {
|
||||||
|
if (files.length > 0) {
|
||||||
|
sys.error("WARN: Ignoring input files since --self was passed");
|
||||||
|
}
|
||||||
|
files = Cola.FILES;
|
||||||
|
files.push(path.join(path.dirname(fs.realpathSync(__filename)), "../lib/browser.js"));
|
||||||
|
ARGS.j = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ORIG_MAP = ARGS.in_source_map;
|
var ORIG_MAP = ARGS.in_source_map;
|
||||||
|
|
@ -301,7 +313,7 @@ async.eachLimit(files, 1, function (file, cb) {
|
||||||
if (!ARGS.j) TOPLEVEL = TOPLEVEL.toJavaScript({
|
if (!ARGS.j) TOPLEVEL = TOPLEVEL.toJavaScript({
|
||||||
main_binding: !ARGS.i,
|
main_binding: !ARGS.i,
|
||||||
is_node: ARGS.n,
|
is_node: ARGS.n,
|
||||||
modules: Cola.getPackages(ARGS.k),
|
modules: Cola.getPackages(ARGS.P),
|
||||||
path: path.dirname(file),
|
path: path.dirname(file),
|
||||||
parser: {
|
parser: {
|
||||||
expression : ARGS.expr,
|
expression : ARGS.expr,
|
||||||
|
|
@ -434,7 +446,7 @@ function getOptions(x, constants) {
|
||||||
if (!ARGS.j) ast = ast.toJavaScript({
|
if (!ARGS.j) ast = ast.toJavaScript({
|
||||||
main_binding: !ARGS.i,
|
main_binding: !ARGS.i,
|
||||||
is_node: ARGS.n,
|
is_node: ARGS.n,
|
||||||
modules: Cola.getPackages(ARGS.k),
|
modules: Cola.getPackages(ARGS.P),
|
||||||
parser: {
|
parser: {
|
||||||
expression: true,
|
expression: true,
|
||||||
is_js: ARGS.j
|
is_js: ARGS.j
|
||||||
|
|
|
||||||
11
bower.json
11
bower.json
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "cola-script",
|
"name": "cola-script",
|
||||||
"version": "0.6.0",
|
"version": "0.8.0",
|
||||||
"homepage": "https://github.com/TrigenSoftware/ColaScript",
|
"homepage": "https://github.com/TrigenSoftware/ColaScript",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Onoshko Dan"
|
"Onoshko Dan"
|
||||||
],
|
],
|
||||||
"description": "ColaScript translator / parser / mangler / compressor / beautifier toolkit",
|
"description": "ColaScript translator / parser / mangler / compressor / beautifier toolkit",
|
||||||
"main": "./lib/browser-cola.js",
|
"main": "lib/browser-cola.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"ColaScript",
|
"ColaScript",
|
||||||
"Cola",
|
"Cola",
|
||||||
|
|
@ -22,11 +22,6 @@
|
||||||
"*.md",
|
"*.md",
|
||||||
"colalogo.png",
|
"colalogo.png",
|
||||||
".gitignore",
|
".gitignore",
|
||||||
".travis.yml",
|
".travis.yml"
|
||||||
"bower.json",
|
|
||||||
"demo.cola",
|
|
||||||
"demo.cola.js",
|
|
||||||
"LICENSE",
|
|
||||||
"package.json"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +347,7 @@ Cola.AST_Toplevel = Cola.DEFNODE("Toplevel", "globals language requiredModules",
|
||||||
});
|
});
|
||||||
|
|
||||||
var wrapped_tl = "(function(" + parameters.join(",") + "){ '$ORIG'; })(" + args.join(",") + ")";
|
var wrapped_tl = "(function(" + parameters.join(",") + "){ '$ORIG'; })(" + args.join(",") + ")";
|
||||||
wrapped_tl = Cola.parse(wrapped_tl);
|
wrapped_tl = Cola.parse(wrapped_tl, { is_js : true });
|
||||||
wrapped_tl = wrapped_tl.transform(new Cola.TreeTransformer(function before(node){
|
wrapped_tl = wrapped_tl.transform(new Cola.TreeTransformer(function before(node){
|
||||||
if (node instanceof Cola.AST_Directive && node.value == "$ORIG") {
|
if (node instanceof Cola.AST_Directive && node.value == "$ORIG") {
|
||||||
return Cola.MAP.splice(self.body);
|
return Cola.MAP.splice(self.body);
|
||||||
|
|
@ -360,7 +360,7 @@ Cola.AST_Toplevel = Cola.DEFNODE("Toplevel", "globals language requiredModules",
|
||||||
var to_export = [];
|
var to_export = [];
|
||||||
if (export_all) {
|
if (export_all) {
|
||||||
self.figure_out_scope();
|
self.figure_out_scope();
|
||||||
self.walk(new TreeWalker(function(node){
|
self.walk(new Cola.TreeWalker(function(node){
|
||||||
if (node instanceof Cola.AST_SymbolDeclaration && node.definition().global) {
|
if (node instanceof Cola.AST_SymbolDeclaration && node.definition().global) {
|
||||||
if (!Cola.find_if(function(n){ return n.name == node.name }, to_export))
|
if (!Cola.find_if(function(n){ return n.name == node.name }, to_export))
|
||||||
to_export.push(node);
|
to_export.push(node);
|
||||||
|
|
@ -368,7 +368,7 @@ Cola.AST_Toplevel = Cola.DEFNODE("Toplevel", "globals language requiredModules",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
var wrapped_tl = "(function(exports, global){ global['" + name + "'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";
|
var wrapped_tl = "(function(exports, global){ global['" + name + "'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";
|
||||||
wrapped_tl = Cola.parse(wrapped_tl);
|
wrapped_tl = Cola.parse(wrapped_tl, { is_js : true });
|
||||||
wrapped_tl = wrapped_tl.transform(new Cola.TreeTransformer(function before(node){
|
wrapped_tl = wrapped_tl.transform(new Cola.TreeTransformer(function before(node){
|
||||||
if (node instanceof Cola.AST_SimpleStatement) {
|
if (node instanceof Cola.AST_SimpleStatement) {
|
||||||
node = node.body;
|
node = node.body;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2,13 +2,6 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>ColaScript Playground</title>
|
<title>ColaScript Playground</title>
|
||||||
<script type="text/packages-json">
|
|
||||||
{
|
|
||||||
"underscore" : "/components/jashkenas/underscore/1.7.0/underscore.js",
|
|
||||||
"uid" : "/components/matthewmueller-uid@0.0.2/index.js",
|
|
||||||
"fmt" : "/components/yields-fmt@0.1.0/index.js"
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script src="./utils.js"></script>
|
<script src="./utils.js"></script>
|
||||||
<script src="./ast.js"></script>
|
<script src="./ast.js"></script>
|
||||||
<script src="./parse.js"></script>
|
<script src="./parse.js"></script>
|
||||||
|
|
@ -21,6 +14,7 @@
|
||||||
<script src="./translate.js"></script>
|
<script src="./translate.js"></script>
|
||||||
<script src="./std.js"></script>
|
<script src="./std.js"></script>
|
||||||
<script src="./typecheck.js"></script>
|
<script src="./typecheck.js"></script>
|
||||||
|
<!--script src="./browser-cola.js"></script-->
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
@ -226,7 +220,7 @@ main();</textarea>
|
||||||
<label for="is_node">node</label>
|
<label for="is_node">node</label>
|
||||||
<input type="checkbox" id="compressed" onclick="changeClass()">
|
<input type="checkbox" id="compressed" onclick="changeClass()">
|
||||||
<label for="compressed">compressed</label>
|
<label for="compressed">compressed</label>
|
||||||
<span id="version">v0.6.0</span>
|
<span id="version">v0.8.0</span>
|
||||||
<span id="lenstat"></span>
|
<span id="lenstat"></span>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ Cola.getSource = function(file) {
|
||||||
|
|
||||||
Cola.getPackages = function(path) {
|
Cola.getPackages = function(path) {
|
||||||
if (!path) path = "packages.json";
|
if (!path) path = "packages.json";
|
||||||
return Cola.getSource(path);
|
return JSON.parse(Cola.getSource(path));
|
||||||
};
|
};
|
||||||
|
|
||||||
Cola.dirname = path.dirname;
|
Cola.dirname = path.dirname;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"description": "ColaScript translator / parser / mangler / compressor / beautifier toolkit",
|
"description": "ColaScript translator / parser / mangler / compressor / beautifier toolkit",
|
||||||
"homepage": "https://github.com/TrigenSoftware/ColaScript",
|
"homepage": "https://github.com/TrigenSoftware/ColaScript",
|
||||||
"main": "tools/node.js",
|
"main": "tools/node.js",
|
||||||
"version": "0.6.0",
|
"version": "0.8.0",
|
||||||
"engines": { "node" : ">=0.4.0" },
|
"engines": { "node" : ">=0.4.0" },
|
||||||
"maintainers": [{
|
"maintainers": [{
|
||||||
"name": "Dan Onoshko (dangreen)",
|
"name": "Dan Onoshko (dangreen)",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user