📄 esc.wsf
字号:
prototype.crunch=$0r;
prototype.flush=function(){this.buffer='';this.report=new $0c()};
prototype.getSubstitute=$0g;
prototype.loadMaps=$0d;
prototype.out=$0b;
prototype.load=$0e;
prototype.save=$0f;
prototype.getReport=$0s;
prototype.$1u=new RegExp("[$_]");
prototype.$1v=new RegExp("[^$\\w]","g");
prototype.$1w=new RegExp("^[\\x00\\.\"']");
prototype.$1x=new RegExp("\\s+$");
prototype.$1y=new RegExp("^\\s*\\W");
prototype.$1z=new RegExp("^[-\\\\+\"~'!]");
prototype.$1A=new RegExp("("+$0z+")|("+$0B+")","g");
prototype.$1B=new RegExp("("+$0C+")","g");
prototype.$1C=new RegExp("("+$0z+")|(\\r?\\n\\s+)|(\\x20{2,})","g");
prototype.$1D=new RegExp("("+$0z+")|(\\w+)?\\s+("+$0A+")","g");
prototype.$1E=new RegExp("("+$0z+")|("+$0A+")[ \\t]+","g");
prototype.$1F=new RegExp("("+$0z+")|function[\\n\\s]+([$\\w]+)","g");
prototype.$1G=new RegExp("("+$0z+")|("+$0B+")|(\\W[\\n\\s]*?[$\\w]+)\\b","gm");
prototype.$1H=new RegExp("("+$0z+")|(\\x00)|\\.[\\n\\s]*?([$_][$\\w]{3,})","g");
prototype.$1I=new RegExp("("+$0z+")|(\\S)\\s*[\\r\\n]+\\s*(\\S)","g");
prototype.$1J=new RegExp("[$\\w][$\\w]");
prototype.$1K=new RegExp("("+$0D+")","g");
}
}
function $0b($0E,$0F){
if(!this.silent){
var $0G=String((!$0F?'ESC> ':'')+($0E||''));
WScript.Echo($0G);
}
}
function $0c(){
this.scripts=[];
this.rawSize=
this.crunchedSize=
this.elapsedTime=0;
}
function $0d(){
if(this.$1L)
return;
var $0H,$0I,$0J,$0K,$0L;
for(var i=0;i<arguments.length;i++){
$0H=arguments[i].replace(/\W.+$/,'');
try{
$0J=getResource(arguments[i]).split(/\r?\n/g)||[];
for(var j=0;j<$0J.length;j++)
if($0J[j].length&&!$0y.$1y.test($0J[j]))
Soya_Saltstorm_ESC.prototype[$0H][$0J[j].replace($0y.$1x,'')]=1;
if(this.verbose)
this.out('Parsed map "'+$0H+'", '+$0J.length+' entries.')
}
catch($0M){
if($0M)
$0J=null;
}
if($0J)
continue;
else $0I=this.fso.BuildPath(this.resourcePath,arguments[i]);
if(/^common|core/.test(arguments[i])&&!this.fso.FileExists($0I)){
this.out('Couldn\'t $0N $0O:'+
this.fso.GetAbsolutePathName($0I));
return WScript.Quit(99);
}
else if(typeof this[$0H]!='object'){
this.out('Unrecognized mapname : '+$0H);
return WScript.Quit(99);
}
else if(this.fso.FileExists($0I)){
$0J=this.fso.OpenTextFile($0I);
$0L=0;
while(!$0J.AtEndOfStream){
$0K=$0J.ReadLine();
if($0K.length&&!$0y.$1y.test($0K))
Soya_Saltstorm_ESC.prototype[$0H][$0K.replace($0y.$1x,'')]=++$0L;
}
$0J.Close();
Soya_Saltstorm_ESC.prototype[$0H].length=$0L;
if(this.verbose)
this.out('Loaded map "'+$0H+'", '+$0L+' entries. ['+$0I+']');
}
}
this.$1L=1;
}
function $0e(){
var i,$0P,$0Q,$0R,$0S=[];
for(i=0;i<arguments.length;i++){
if(arguments[i]&&this.fso.FolderExists(arguments[i])){
$0R=new Enumerator(this.fso.GetFolder(arguments[i]).SubFolders);
for(;!$0R.atEnd();$0R.moveNext())
arguments[arguments.length++]=$0R.item().Path;
$0R=new Enumerator(this.fso.GetFolder(arguments[i]).Files);
for(;!$0R.atEnd();$0R.moveNext())
if($0R.item().Size&&this.fileFilter.test($0R.item().Path))
$0S.push($0R.item().Path);
}
else if(arguments[i])
$0S.push(arguments[i]);
}
for(i=0;i<$0S.length;i++){
if(!this.fso.FileExists($0S[i])){
this.out('Couldn\'t $0N $0T:"' + this.fso.GetAbsolutePathName(aLoadQueue[i]) + '"');
return WScript.Quit(99);
}
else if(this.verbose)
this.out('Loading script :"'+this.fso.GetAbsolutePathName($0S[i])+'"');
$0Q=this.fso.GetFile($0S[i]);
this.buffer+=(this.report.scripts.length?'\r\n':'');
this.buffer+=this.$1t($0Q.Path,true);
this.report.scripts.push(
$0Q.Path+' ('+($0Q.Size/1024).toFixed(2)+' kb)');
}
return $0S.length;
}
function $0f($0U,$0V){
var $0W;
if(!$0U){
this.out('Need an output filename!');
return WScript.Quit(99);
}
else if(this.fso.FolderExists($0U)){
this.out('Need an output filename, "'+
this.fso.GetAbsolutePathName($0U)+'" is a folder.');
return WScript.Quit(99);
}
this.outFile=this.fso.GetAbsolutePathName($0U);
this.outMode=$0V?'Writing':'Appending';
$0W=this.fso.OpenTextFile(this.outFile,($0V?2:8),true);
$0W.WriteLine(this.buffer);
$0W.Close();
}
function $0g($0X){
if(!this.$1s[$0X]){
var k=1;
while(k<5){
this.$1r[k]++;
if(this.$1r[k]&&!(this.$1r[k]%62)){
k++;
if(this.$1r.length==k)
this.$1r[k]=-1;
}
else break;
}
this.$1s[$0X]='$';
for(k=this.$1r.length-1;k>0;k--)
this.$1s[$0X]+=this.$1r[0].charAt(this.$1r[k]%62);
if(this.verbose)
this.out('Substituting ['+this.$1s[$0X]+'] -> ['+$0X+']');
}
return this.$1s[$0X];
}
function $0h($0Y,$0Z,$10){
if(typeof $10!='undefined')
return '';
else return $0Y;
}
function $0i($0Y,$11){
if(typeof $11!='undefined'&&/^\s+/.test($11))
return '\r\n';
else return $0Y;
}
function $0j($0Y,$12,$13){
if(typeof $12!='undefined')
return $0Y;
else if($13&&$13.length>2&&
($0y.mangle[$13]||$0y.$1u.test($13.charAt(0))))
$13=$0y.getSubstitute($13);
else Soya_Saltstorm_ESC.prototype.bless[$13]=1;
return String('function \x00'+$13);
}
function $0k($0Y,$12,$14,$15){
if(typeof $12=='undefined'&&typeof $14=='undefined'&&typeof $15=='string'){
$15=$15.replace(/\s+/g,'');
if(!$0y.$1w.test($15)&&isNaN(parseInt($15.substr(1),10))){
$15=$15.replace($0y.$1v,'');
if($15.length>2&&!$0y.core[$15]&&!$0y.common[$15]&&
!$0y.bless[$15]&&($0y.mangle[$15]||!$0y.mangle.length))
return $0Y.replace($15,$0y.getSubstitute($15));
}
}
return $0Y;
}
function $0l($0Y,$12,$16,$P){
if(typeof $P=='string')
return(!$0y.core[$P]&&!$0y.common[$P]&&!$0y.bless[$P])?
String('.'+$0y.getSubstitute($P)):$0Y;
else if(typeof $12!='undefined')
return $0Y;
else return '';
}
function $0m($0Y,$12,$17,$18,$19){
if(typeof $12!='undefined')
return $0Y;
else if(typeof $17!='undefined')
return '\r\n';
else if(typeof $18!='undefined')
return ' ';
else return '';
}
function $0n($0Y,$12,$1a,$1b){
if(typeof $12=='undefined'){
if(!$0y.$1z.test($1b)||!$1a||!$0y.core[$1a])
return($1a||'')+$1b;
else return $0Y;
}
else return $12;
}
function $0o($0Y,$12,$1b){
if(typeof $12!='undefined')
return $0Y;
else return $1b;
}
function $0p($0Y,$1c,$1d){
return('};'+$1d);
}
function $0q($0Y,$12,$1e,$1f){
if(typeof $1e=='undefined')
return $0Y;
var $1g=($0y.$1J.test($1e+$1f))?' ':'';
return $1e+$1g+$1f;
}
function $0r($1h,$0t,$1i){
var $B=(typeof $1h=='string')?$1h:this.buffer;
this.loadMaps('core.map','common.map','bless.map','mangle.map');
if(!this.buffer.length&&!$1h)
return String();
else if(typeof $0t=='number')
this.crunchLevel=$0t;
var $1j=(new Date()).getTime()-1;
var $1k=$B.length;
this.report.rawSize+=$B.length;
if(this.crunchLevel>=1){
$B=$B.replace(this.$1A,$0h)
.replace(this.$1B,$0i)
.replace(/\s*\r?\n/g,'\r\n');
if(this.verbose)
this.out('Removing comments, empty lines and trailing whitespace, saved '+
($1k-$B.length)+' bytes.');
$1k=$B.length;
}
if(this.crunchLevel>=2){
$B=$B.replace(this.$1C,$0m);
if(this.verbose)
this.out('Removing tabs and spaces, saved '+
($1k-$B.length)+' bytes.');
$1k=$B.length;
$B=$B.replace(this.$1D,$0n);
if(this.verbose)
this.out('Removing spaces left to operators, saved '+
($1k-$B.length)+' bytes.');
$1k=$B.length;
$B=$B.replace(this.$1E,$0o);
if(this.verbose)
this.out('Removing spaces right to operators, saved '+
($1k-$B.length)+' bytes.');
$1k=$B.length;
}
if(this.substitute||$1i||this.crunchLevel>=4){
$B=$B.replace(this.$1F,$0j);
$B=$B.replace(this.$1G,$0k);
$B=$B.replace(this.$1H,$0l);
if(this.verbose)
this.out('Substitution summary, saved '+
($1k-$B.length)+' bytes.');
$1k=$B.length;
}
if(this.crunchLevel>=3){
$B=$B.replace(this.$1I,$0q);
$B=$B.replace(this.$1K,$0p);
$B+='\r\n';
if(this.verbose){
this.out('Removing newlines, saved '+
($1k-$B.length)+' bytes.');
this.out('',1);
}
}
if(typeof $1h=='string'){
this.report.crunchedSize+=$B.length;
this.buffer+=$B;
}
else{
this.buffer=$B;
this.report.crunchedSize=$B.length;
}
this.report.elapsedTime+=(new Date()).getTime()-$1j;
return this.buffer;
}
function $0s($1l){
var $1m=($1l||'\r\n'),
$1n=this.label?String($1m+this.label+$1m):'';
if(!this.report.elapsedTime){
$1n+='Nothing to report, yet...';
return(!$1o)?this.out($1n,1):$1n;
}
var $1p=Boolean(this.substitute||this.crunchLevel>=4),
$1q=this.report.rawSize-this.report.crunchedSize;
if(this.report.scripts.length){
$1n+="-----------------------------------------------------------------------------"+$1m;
$1n+=" Crunching script(s):\r\n\t * "+this.report.scripts.join("\r\n\t * ")+$1m;
$1n+="-----------------------------------------------------------------------------"+$1m;
$1n+=" "+(this.outMode||"Put")+" to : "+(this.outFile||"[buffer]")+" ("+
(this.report.crunchedSize/1024).toFixed(2)+" kb)"+$1m;
}
$1n+="-----------------------------------------------------------------------------"+$1m;
$1n+=" Processtime :\t"+(this.report.elapsedTime/1000).toFixed(3)+" secs"+$1m;
$1n+=" Crunch-level :\t"+this.crunchLevel+$1m;
$1n+=" Subst. engine :\t"+($1p?'On':'Off')+$1m;
if($1p)
$1n+=" Substitutions :\t"+(this.$1r[1]-9)+$1m;
$1n+=" Original size :\t"+(this.report.rawSize/1024).toFixed(2)+" kb"+$1m;
$1n+=" Crunched size :\t"+(this.report.crunchedSize/1024).toFixed(2)+" kb"+$1m;
$1n+=" Saving ratio :\t"+($1q/1024).toFixed(2)+" kb"+$1m;
$1n+=" -'' ''- (%) :\t"+(($1q/this.report.rawSize)*100).toFixed(2)+" %"+$1m;
$1n+="-----------------------------------------------------------------------------"+$1m;
return $1n;
}
if(typeof(Soya)=='object')Soya.registerBean('Soya.Saltstorm.ESC',false,1);
/*** </POD> ***/
]]>
</script>
<script language="JScript">
<![CDATA[
/*
Command flow control script for ESC.wsf
Edited : 2005-02-06
*/
var oShell = WScript.CreateObject('WScript.Shell');
if(!oShell)
WScript.Quit(64);
// Do we have Jscript 5.5+ ?
else if(oShell && parseFloat(ScriptEngineMajorVersion() + '.' + ScriptEngineMinorVersion()) < 5.5)
oShell.Popup(getResource('jscript'), 64, WScript.ScriptName, 16), WScript.Quit(4);
// Is ESC executed under cscript ?
// if not let user select switching to cscript automagically.
else if(oShell && WScript.FullName.toLowerCase().indexOf('cscript') < 0){
if(oShell.Popup(getResource('wscript'), 64, WScript.ScriptName, 52) == 6)
oShell.Run('%comspec% /Q /K cscript //NoLogo ' + WScript.ScriptName + ' -a', 9);
WScript.Quit(3);
}
// get the cmdline arguments formatted in a nice manner.
var oArgs = Soya.WSH.getArguments();
// should we run in verbose-mode ?;
var bVerbose = Boolean(!oArgs.s && !oArgs.silent && (oArgs.v || oArgs.verbose));
// create an instance of the ESC object.
var esc = new Soya.Saltstorm.ESC(oArgs.l || oArgs.level, bVerbose);
esc.label = 'ESC (ECMAScript Cruncher) ' + esc.version +
'\r\nCopyright (C) 2001-2005 Thomas Loo <tloo@saltstorm.net>';
esc.resourcePath = esc.fso.GetParentFolderName(WScript.ScriptFullName || '.');
var sOutput = String(oArgs.oa || oArgs.ow || '');
if(oArgs.a || oArgs.about){
WScript.Echo(getResource('about'));
WScript.Quit(1);
}
else if(oArgs.c || oArgs.copyright){
WScript.Echo('\n' + esc.label + getResource('copyright'));
WScript.Quit(1);
}
else if(oArgs.e || oArgs.example){
WScript.Echo('\n' + esc.label + getResource('example'));
WScript.Quit(1);
}
// if there are options missing, print out the help table and quit.
else if((oArgs.h || oArgs.help) || !sOutput.length || !oArgs[0]){
WScript.Echo('\n' + esc.label + getResource('usage'));
WScript.Quit((oArgs.h || oArgs.help) ? 1 : 2);
}
// Wake up the variable substitution engine if option set (-$);
esc.substitute = Boolean(oArgs.$);
// load input files;
for(var i = 0; i < oArgs.length; i++)
esc.load(oArgs[i]);
// crunch baby, crunch!;
if(sOutput.toUpperCase() == 'STDOUT'){
esc.silent = true;
WScript.StdOut.Write(esc.crunch());
}
else if(sOutput.length){
esc.crunch();
esc.save(sOutput, Boolean(oArgs.ow));
// write report to stdout if not silence'd.
if(!oArgs.s && !oArgs.silent)
WScript.StdOut.Write(esc.getReport());
}
// Shutting down nicely..
WScript.Quit(0);
]]>
</script>
</job>
</package>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -