XObject = imports.XObject.XObject;
File = imports.File.File;
-TextStream = imports.TextStream.TextStream;
+TextStream = imports.JSDOC.TextStream.TextStream ;
TokenReader = imports.TokenReader.TokenReader;
ScopeParser = imports.ScopeParser.ScopeParser;
TokenStream = imports.TokenStream.TokenStream;
Collapse = imports.Collapse.Collapse;
GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
/**
* @namespace JSDOC
* @class Packer
files : [ "/location/of/file1.js", "/location/of/file2.js", ... ],
target : "/tmp/output.js",
debugTarget : "/tmp/output.debug.js", // merged file without compression.
+ debugTranslateTarget : "/tmp/output.translate.js", // merged with translation
+ // and no compression
translateJSON: "/tmp/translate.json",
throw "No Files";
}
+ var link = false;
if (cfg.autoBuild) {
+
+ function dateString(d){
+ function pad(n){return n<10 ? '0'+n : n}
+ return d.getFullYear() +
+ pad(d.getMonth()+1)+
+ pad(d.getDate())+'_'+
+ pad(d.getHours())+
+ pad(d.getMinutes())+
+ pad(d.getSeconds());
+ }
+
+
+
var version = 0;
this.files.forEach(function(f) {
version = Math.max(File.mtime(f), version);
});
+ var version = dateString(new Date(version));
+
var dirname = GLib.path_get_dirname(this.files[0]);
- var outname = GLib.path_get_basename(dirname);
+ var outname = this.module ? this.module : GLib.path_get_basename(dirname);
this.target = dirname + '/compiled/' + outname + '-' + version + '.js';
- if (File.exists(this.target)) {
- print("Target file already exists");
+ if (File.exists(this.target)) {
+ print("Target file already exists: " + this.target);
Seed.quit();
}
this.prefix = dirname +'/';
this.translateJSON = dirname + '/compiled/_translation_.js';
}
-
-
+
+ print(this.translateJSON);
this.timer = new Date() * 1;
this.packAll();
+
+
}
Packer.prototype = {
/**
- * @prop srcfiles {String} file containing a list of files/or classes to use.
+ * @cfg {String} srcfiles file containing a list of files/or classes to use.
*/
srcfile : false,
/**
- * @prop files {Array} list of files to compress (must be full path)
+ * @cfg {Array} files list of files to compress (must be full path)
*/
files : false,
/**
* and enables translation toolkit.
*/
autoBuild : false,
+ /**
+ * @cfg {String} module used with autoBuild to force a file name
+ */
+ module: false,
/**
- * @prop debugTarget {String} target to write files debug version to (uncompacted)- must be full path.
+ * @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
*/
debugTarget : '', // merged file without compression.
/**
- * @prop tmpDir {String} (optional) where to put the temporary files.
+ * @cfg {String} debugTranslateTarget target to write files debug version
+ * to (uncompacted) but with translation- must be full path.
+ */
+
+ debugTranslateTarget
+
+ /**
+ * @cfg {String} tmpDir (optional) where to put the temporary files.
* if you set this, then files will not be cleaned up
*/
tmpDir : '/tmp',
translateJSON : '', // json based list of strings in all files.
/**
- * @prop cleanup {Boolean} (optional) clean up temp files after done -
+ * @cfg {Boolean} cleanup (optional) clean up temp files after done -
* Defaults to false if you set tmpDir, otherwise true.
*/
cleanup : true,
+ /**
+ * @cfg {Boolean} keepWhite (optional) do not remove white space in output.
+ * usefull for debugging compressed files.
+ */
+
+ keepWhite: true,
/**
- * @prop prefix {String} (optional) prefix of directory to be stripped of when
+ * @cfg {String} prefix (optional) prefix of directory to be stripped of when
* Calculating md5 of filename
*/
prefix : '',
continue;
}
+ // debug Target
+
if (this.debugTarget) {
File.append(this.debugTarget, File.read(file));
}
print("compare : " + mt + "=>" + ot);
if (mt >= ot) {
continue;
- /*
- // then the min'files time is > than original..
- var str = File.read(minfile);
- print("using MIN FILE "+ minfile);
- if (str.length) {
- File.append(outpath, str + "\n");
- }
- continue;
- */
}
}
}
}
+ print("Output file: " + this.target);
+ if (this.debugTarget) print("Output debug file: " + this.debugTarget);
keepWhite : true,
keepComments : true,
sepIdents : true,
- collapseWhite : false
+ collapseWhite : false,
+ filename : fn
});
this.timerPrint("START" + fn);
print(sp.warnings.join("\n"));
- //var out = CompressWhite(new TokenStream(toks), this, true); // do not kill whitespace..
- var out = CompressWhite(new TokenStream(toks), this, false);
+ var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
+
+
this.timerPrint("Compressed");
return out;