diff --git a/dist/seajs-combo-debug.js b/dist/seajs-combo-debug.js index ab706b5..3a48678 100644 --- a/dist/seajs-combo-debug.js +++ b/dist/seajs-combo-debug.js @@ -11,6 +11,7 @@ var comboHash = data.comboHash = {} var comboSyntax = ["??", ","] var comboMaxLength = 2000 +var comboMaxFiles = 200 var comboExcludes var comboSuffix @@ -27,6 +28,7 @@ function setComboHash(uris) { data.comboSyntax && (comboSyntax = data.comboSyntax) data.comboMaxLength && (comboMaxLength = data.comboMaxLength) data.comboSuffix && (comboSuffix = data.comboSuffix) + data.comboMaxFiles && (comboMaxFiles = data.comboMaxFiles) comboExcludes = data.comboExcludes var needComboUris = [] @@ -232,6 +234,13 @@ function setHash(root, files) { for (var i = 0, len = files.length; i < len; i++) { copy[i] = files[i].replace(/\?.*$/, '') } + // server limit file num + if (files.length > comboMaxFiles) { + setHash(root, copy.splice(0, comboMaxFiles)) + setHash(root, copy) + return + } + var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1]) if(comboSuffix) { comboPath += comboSuffix diff --git a/dist/seajs-combo.js b/dist/seajs-combo.js index b216d15..f3b061d 100644 --- a/dist/seajs-combo.js +++ b/dist/seajs-combo.js @@ -1 +1 @@ -!function(){function a(a){var b=a.length;if(!(2>b)){r.comboSyntax&&(t=r.comboSyntax),r.comboMaxLength&&(u=r.comboMaxLength),r.comboSuffix&&(o=r.comboSuffix),n=r.comboExcludes;for(var d=[],e=0;b>e;e++){var f=a[e];if(!s[f]){var h=p.get(f);h.status1&&g(c(d))}}function b(a){a.requestUri=s[a.uri]||a.uri}function c(a){return e(d(a))}function d(a){for(var b={__KEYS:[]},c=0,d=a.length;d>c;c++)for(var e=a[c].replace("://","__").split("/"),f=b,g=0,h=e.length;h>g;g++){var i=e[g];f[i]||(f[i]={__KEYS:[]},f.__KEYS.push(i)),f=f[i]}return b}function e(a){for(var b=[],c=a.__KEYS,d=0,e=c.length;e>d;d++){for(var g=c[d],h=g,i=a[g],j=i.__KEYS;1===j.length;)h+="/"+j[0],i=i[j[0]],j=i.__KEYS;j.length&&b.push([h.replace("__","://"),f(i)])}return b}function f(a){for(var b=[],c=a.__KEYS,d=0,e=c.length;e>d;d++){var g=c[d],h=f(a[g]),i=h.length;if(i)for(var j=0;i>j;j++)b.push(g+"/"+h[j]);else b.push(g)}return b}function g(a){for(var b=0,c=a.length;c>b;b++)for(var d=a[b],e=d[0]+"/",f=j(d[1]),g=0,i=f.length;i>g;g++)h(e,f[g]);return s}function h(a,b){for(var c=[],d=0,e=b.length;e>d;d++)c[d]=b[d].replace(/\?.*$/,"");var f=a+t[0]+c.join(t[1]);o&&(f+=o);var g=f.length>u;if(b.length>1&&g){var j=i(b,u-(a+t[0]).length);h(a,j[0]),h(a,j[1])}else{if(g)throw new Error("The combo url is too long: "+f);for(var d=0,e=b.length;e>d;d++)s[a+b[d]]=f}}function i(a,b){for(var c=t[1],d=a[0],e=1,f=a.length;f>e;e++)if(d+=c+a[e],d.length>b)return[a.splice(0,e),a]}function j(a){for(var b=[],c={},d=0,e=a.length;e>d;d++){var f=a[d],g=k(f);g&&(c[g]||(c[g]=[])).push(f)}for(var h in c)c.hasOwnProperty(h)&&b.push(c[h]);return b}function k(a){var b=a.lastIndexOf(".");return b>=0?a.substring(b):""}function l(a){return n?n.test?n.test(a):n(a):void 0}function m(a){var b=r.comboSyntax||["??",","],c=b[0],d=b[1];return c&&a.indexOf(c)>0||d&&a.indexOf(d)>0}var n,o,p=seajs.Module,q=p.STATUS.FETCHING,r=seajs.data,s=r.comboHash={},t=["??",","],u=2e3;if(seajs.on("load",a),seajs.on("fetch",b),r.test){var v=seajs.test||(seajs.test={});v.uris2paths=c,v.paths2hash=g}define("seajs/seajs-combo/1.0.1/seajs-combo",[],{})}(); \ No newline at end of file +!function(){function a(a){var b=a.length;if(!(2>b)){r.comboSyntax&&(t=r.comboSyntax),r.comboMaxLength&&(u=r.comboMaxLength),r.comboSuffix&&(o=r.comboSuffix),r.comboMaxFiles&&(v=r.comboMaxFiles),n=r.comboExcludes;for(var d=[],e=0;b>e;e++){var f=a[e];if(!s[f]){var h=p.get(f);h.status1&&g(c(d))}}function b(a){a.requestUri=s[a.uri]||a.uri}function c(a){return e(d(a))}function d(a){for(var b={__KEYS:[]},c=0,d=a.length;d>c;c++)for(var e=a[c].replace("://","__").split("/"),f=b,g=0,h=e.length;h>g;g++){var i=e[g];f[i]||(f[i]={__KEYS:[]},f.__KEYS.push(i)),f=f[i]}return b}function e(a){for(var b=[],c=a.__KEYS,d=0,e=c.length;e>d;d++){for(var g=c[d],h=g,i=a[g],j=i.__KEYS;1===j.length;)h+="/"+j[0],i=i[j[0]],j=i.__KEYS;j.length&&b.push([h.replace("__","://"),f(i)])}return b}function f(a){for(var b=[],c=a.__KEYS,d=0,e=c.length;e>d;d++){var g=c[d],h=f(a[g]),i=h.length;if(i)for(var j=0;i>j;j++)b.push(g+"/"+h[j]);else b.push(g)}return b}function g(a){for(var b=0,c=a.length;c>b;b++)for(var d=a[b],e=d[0]+"/",f=j(d[1]),g=0,i=f.length;i>g;g++)h(e,f[g]);return s}function h(a,b){for(var c=[],d=0,e=b.length;e>d;d++)c[d]=b[d].replace(/\?.*$/,"");if(b.length>v)return h(a,c.splice(0,v)),h(a,c),void 0;var f=a+t[0]+c.join(t[1]);o&&(f+=o);var g=f.length>u;if(b.length>1&&g){var j=i(b,u-(a+t[0]).length);h(a,j[0]),h(a,j[1])}else{if(g)throw new Error("The combo url is too long: "+f);for(var d=0,e=b.length;e>d;d++)s[a+b[d]]=f}}function i(a,b){for(var c=t[1],d=a[0],e=1,f=a.length;f>e;e++)if(d+=c+a[e],d.length>b)return[a.splice(0,e),a]}function j(a){for(var b=[],c={},d=0,e=a.length;e>d;d++){var f=a[d],g=k(f);g&&(c[g]||(c[g]=[])).push(f)}for(var h in c)c.hasOwnProperty(h)&&b.push(c[h]);return b}function k(a){var b=a.lastIndexOf(".");return b>=0?a.substring(b):""}function l(a){return n?n.test?n.test(a):n(a):void 0}function m(a){var b=r.comboSyntax||["??",","],c=b[0],d=b[1];return c&&a.indexOf(c)>0||d&&a.indexOf(d)>0}var n,o,p=seajs.Module,q=p.STATUS.FETCHING,r=seajs.data,s=r.comboHash={},t=["??",","],u=2e3,v=200;if(seajs.on("load",a),seajs.on("fetch",b),r.test){var w=seajs.test||(seajs.test={});w.uris2paths=c,w.paths2hash=g}define("seajs/seajs-combo/1.0.1/seajs-combo",[],{})}(); \ No newline at end of file diff --git a/src/seajs-combo.js b/src/seajs-combo.js index 275e315..3036eea 100644 --- a/src/seajs-combo.js +++ b/src/seajs-combo.js @@ -10,6 +10,7 @@ var comboHash = data.comboHash = {} var comboSyntax = ["??", ","] var comboMaxLength = 2000 +var comboMaxFiles = 200 var comboExcludes var comboSuffix @@ -26,6 +27,7 @@ function setComboHash(uris) { data.comboSyntax && (comboSyntax = data.comboSyntax) data.comboMaxLength && (comboMaxLength = data.comboMaxLength) data.comboSuffix && (comboSuffix = data.comboSuffix) + data.comboMaxFiles && (comboMaxFiles = data.comboMaxFiles) comboExcludes = data.comboExcludes var needComboUris = [] @@ -231,6 +233,13 @@ function setHash(root, files) { for (var i = 0, len = files.length; i < len; i++) { copy[i] = files[i].replace(/\?.*$/, '') } + // server limit file num + if (files.length > comboMaxFiles) { + setHash(root, copy.splice(0, comboMaxFiles)) + setHash(root, copy) + return + } + var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1]) if(comboSuffix) { comboPath += comboSuffix