+47
-31
@@ -12,2 +12,10 @@ var request = require('request'); | ||
| return "(总进度:"+(++this.val)+"/"+this.len+")" | ||
| }, | ||
| isOver:function(){ | ||
| if(this.val>=this.len){ | ||
| console.log('构建任务全部完毕!'.green); | ||
| console.log('提示: sealoader -v 可检测sealoader最新版本'.yellow); | ||
| errorFuc.show(); | ||
| process.exit(); | ||
| } | ||
| } | ||
@@ -20,7 +28,7 @@ }; | ||
| var seaOutPut=getToPath("sea").outPut; | ||
| if(!checkFile(seaOutPut)){ | ||
| downloadOnly("sea.js","开始下载基础模块sea.js","基础模块sea.js下载成功"); | ||
| if(!cacheFuc.isCache(null,seaOutPut)){ | ||
| downloadOnline("sea.js","开始下载基础模块sea.js","基础模块sea.js下载成功"); | ||
| } | ||
| if(otherAg["-online"]){ | ||
| downloadOnly(jsPath,"开始下载线上资源"+jsPath,"线上资源"+jsPath+"下载成功"); | ||
| downloadOnline(jsPath,"开始下载线上资源"+jsPath,"线上资源"+jsPath+"下载成功"); | ||
| }else{ | ||
@@ -45,3 +53,3 @@ if(jsPath.indexOf(".js")!=-1){ | ||
| } | ||
| var downloadDeps=function(superJs) { | ||
| var downloadDeps=function(superJs,isOnlineJs) { | ||
| var depsList=new function(){ | ||
@@ -58,2 +66,3 @@ var list=[],length=0; | ||
| level=level||0; | ||
| if(array==list&&isOnlineJs)array=array[0].deps; | ||
| for(var i=0,l=array.length;i<l;i++){ | ||
@@ -75,3 +84,3 @@ var a=array[i]; | ||
| afterDownLoad=function (error) { | ||
| var isOver=depsList.reduce()==0; | ||
| var isOver=(depsList.reduce()==0); | ||
| if(error)errorFuc.main(superJs,error); | ||
@@ -84,8 +93,22 @@ if(isOver){ | ||
| } | ||
| if(pro.val>=pro.len){ | ||
| console.log('构建任务全部完毕!'.green); | ||
| console.log('提示: sealoader -v 可检测sealoader最新版本'.yellow); | ||
| errorFuc.show(); | ||
| process.exit(); | ||
| pro.isOver(); | ||
| } | ||
| }, | ||
| downloadAll=function(fileName,depsListLevel){ | ||
| var level=[]; | ||
| depsList.pushLevel(depsListLevel,fileName,level); | ||
| download(fileName,function(error,jsPath){ | ||
| if(error){ | ||
| afterDownLoad(error); | ||
| }else{ | ||
| main(jsPath,level,afterDownLoad); | ||
| } | ||
| }); | ||
| var otherDeps=config.otherDeps[path.basename(fileName,".js")]; | ||
| if(otherDeps){ | ||
| if(typeof otherDeps=="string")otherDeps=[otherDeps]; | ||
| otherDeps.forEach(function(m){ | ||
| depsList.pushLevel(level,m,null); | ||
| download(m,afterDownLoad); | ||
| }); | ||
| } | ||
@@ -101,19 +124,3 @@ }, | ||
| tmp=false; | ||
| var level=[]; | ||
| depsList.pushLevel(depsListLevel,fileName,level); | ||
| download(fileName,function(error,jsPath){ | ||
| if(error){ | ||
| afterDownLoad(error); | ||
| }else{ | ||
| main(jsPath,level,afterDownLoad); | ||
| } | ||
| }); | ||
| var otherDeps=config.otherDeps[fileName]; | ||
| if(otherDeps){ | ||
| if(typeof otherDeps=="string")otherDeps=[otherDeps]; | ||
| otherDeps.forEach(function(m){ | ||
| depsList.pushLevel(level,m,null); | ||
| download(m,afterDownLoad); | ||
| }); | ||
| } | ||
| downloadAll(fileName,depsListLevel); | ||
| } | ||
@@ -126,3 +133,3 @@ }) | ||
| console.log(("开始获取"+superJs+"的依赖...").yellow); | ||
| main(superJs); | ||
| isOnlineJs?downloadAll(superJs):main(superJs); | ||
| }, | ||
@@ -226,10 +233,18 @@ errorFuc=new function(){ | ||
| } | ||
| function downloadOnly(fileName,t1,t2){ | ||
| function downloadOnline(fileName,t1,t2){ | ||
| pro.len++; | ||
| console.log(t1.yellow); | ||
| download(fileName,function(error){ | ||
| download(fileName,function(error,output){ | ||
| if(error){ | ||
| errorFuc.main(fileName,error,true); | ||
| }else{ | ||
| console.log((t2+pro.getNow()).green); | ||
| var superJs=path.basename(output), | ||
| ext=path.extname(superJs); | ||
| if(superJs!="sea.js"&&ext==".js"){ | ||
| console.log(t2.green); | ||
| downloadDeps(superJs,true); | ||
| }else{ | ||
| console.log((t2+pro.getNow()).green); | ||
| pro.isOver(); | ||
| } | ||
| } | ||
@@ -245,2 +260,3 @@ }) | ||
| this.isCache=function (url,output) { | ||
| url=url||config.onlinePath+"/"+output.replace(/\\/g,"/"); | ||
| return (otherAg["-nocache"]!==false || cachedList.indexOf(url)!=-1) && checkFile(output); | ||
@@ -247,0 +263,0 @@ } |
+1
-1
| { | ||
| "name": "sealoader", | ||
| "version": "2.0.5", | ||
| "version": "2.0.6", | ||
| "description": "seajs前端开发解决方案", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
+8
-1
@@ -191,2 +191,3 @@ # sealoader 插件加载器—seajs前端开发解决方案 | ||
| "seajs-upload":"seajs-upload-loading.gif", | ||
| "seajs-uploadImgs":"seajs-uploadImgs-loading.gif", | ||
| "seajs-topTip":"seajs-topTip.css", | ||
@@ -215,2 +216,8 @@ "seajs-gritter":"jquery.gritter.css", | ||
| 2.0.4(2016.04.08): | ||
| 优化缓存机制,极大地提升模块加载速度 | ||
| 优化缓存机制,极大地提升模块加载速度 | ||
| 2.0.6(2016.04.14) | ||
| 完善进度提示 | ||
| 修复依赖完整js名(含后缀)导致otherDeps不加载 | ||
| 修复加载线上模块不加载其依赖的bug(-online) | ||
| 更新readMe中的附录 |
24807
3.2%314
5.37%221
3.27%