diff --git a/dist/recent/inject.js b/dist/recent/inject.js index 5dea702..1b0bffe 100644 --- a/dist/recent/inject.js +++ b/dist/recent/inject.js @@ -4175,21 +4175,26 @@ var TreeNode = Fiber.extend(function() { }); }; - // is this module already available? If so, don't redownload. This happens often when - // there was an inline define() on the page - if (this.env.executor.getModule(nodeData.resolvedId)) { - return function(a, b, cb) { - cb(''); - }; - } + // for non-AMD modules, if the module is already resolved, return an empty string + // which will cause the communicator to exit early and apply content rules if required + // for AMD modules, we re-fetch every time due to the nature of dynamic modules + if (nodeData.resolvedId.indexOf('!') === -1) { + // is this module already available? If so, don't redownload. This happens often when + // there was an inline define() on the page + if (this.env.executor.getModule(nodeData.resolvedId)) { + return function(a, b, cb) { + cb(''); + }; + } - else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) { - return function(a, b, cb) { - cb(''); - }; + else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) { + return function(a, b, cb) { + cb(''); + }; + } } - else if (fetchRules.length > 0) { + if (fetchRules.length > 0) { return function(name, path, cb) { var i = 0, len = fetchRules.length; diff --git a/dist/recent/inject.min.js b/dist/recent/inject.min.js index ee459e4..4d5cb3f 100644 --- a/dist/recent/inject.min.js +++ b/dist/recent/inject.min.js @@ -1,2 +1,2 @@ (function(context,undefined){function init(e){var t=InjectContext.createContext();context.require=t.require,context.define=t.define,context.Inject=t.Inject,context.Inject.version=e}function proxy(e,t){if(!t)throw Error("proxying requires a scope");if(!e)throw Error("proxying requires a function");return function(){return e.apply(t,arguments)}}function each(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n])}function guid(){return"INJECT_xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=0|16*Math.random(),n="x"==e?t:8|3&t;return n.toString(16)})}function addListener(e,t,n){window.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)}function getDomainName(e){return e.match(reURI)[3]}function sendMessage(e,t,n,r){r||(r={}),r=JSON.stringify(r),e.postMessage([n,r].join(":"),t)}function allComponents(){return{Analyzer:Analyzer,Communicator:Communicator,Executor:Executor,RequireContext:RequireContext,RulesEngine:RulesEngine,TreeNode:TreeNode,TreeRunner:TreeRunner,cache:HAS_LOCAL_STORAGE&&lscache?lscache:null}}function amdPluginBreakout(e){e.rulesEngine.addFetchRule(/^.+?\!.+$/,function(t,n,r,i,o){var s=o.moduleId,u=o.parentId,a=o.parentUrl,c=s.split("!"),l=r.module(c[0],u);r.url(l,a);var h=c[1],d=e.requireContext.createRequire(u,a),f=function(){return d.apply(d,arguments)},g=function(e){f[e]=function(){return d[e].apply(d,arguments)}};for(var p in d)HAS_OWN_PROPERTY.call(d,p)&&g(p);var m=function(e){return r.module(e,u)};d([l],function(n){var r=n.normalize?n.normalize(h,m):m(h),i=function(e){"string"==typeof e&&(e=['module.exports = decodeURIComponent("',encodeURIComponent(e),'");'].join("")),t(null,e)};i.fromText=function(t,n){n||(n=t,t=null);var r=e.executor.createModule(t);e.executor.runModule(r,n)},n.load(r,f,i,{})})})}var InjectContext,commonJSHeader=["","__REACHABLE_PATH__.fn = function() {"," with (window) {"," __REACHABLE_PATH__.innerFn = function() {"," // id: __MODULE_ID__ uri: __MODULE_URI__"," var module = __REACHABLE_PATH__.module,"," require = __REACHABLE_PATH__.require,"," define = __REACHABLE_PATH__.define,"," exports = module.exports;"," try{module.undefined_function();}catch(e){module.__error_line = e;}"].join("\n"),commonJSFooter=[""," __REACHABLE_PATH__.module = module;"," };",' __REACHABLE_PATH__.defineExecutingModuleAs("__MODULE_ID__", "__MODULE_URI__");'," try {"," __REACHABLE_PATH__.innerFn.call(__REACHABLE_PATH__.module);"," }"," catch (__EXCEPTION__) {"," __REACHABLE_PATH__.module.__error = __EXCEPTION__;"," }"," __REACHABLE_PATH__.undefineExecutingModule();"," }","};",""].join("\n"),IS_IE=eval("/*@cc_on!@*/false"),IS_GK=!1;(function(){var e=navigator.userAgent.toLowerCase();-1!==e.indexOf("gecko")&&(IS_GK=!0)})();var FILE_STORAGE_TOKEN="INJECT",LSCACHE_SCHEMA_VERSION=1,LSCACHE_SCHEMA_VERSION_STRING="!version",LSCACHE_APP_KEY_STRING="!appCacheKey",FILE_SUFFIX_REGEX=/.*?\.(js|txt)(\?.*)?$/,BASIC_FILE_SUFFIX=".js",HOST_PREFIX_REGEX=/^https?:\/\//,HOST_SUFFIX_REGEX=/^(.*?)(\/.*|$)/,RESPONSE_SLICER_REGEX=/^(.+?)[\s]+([\w\W]+?)[\s]+([\w\W]+)$/m,FUNCTION_REGEX=/^[\s\(]*function[^\(]*\(([^)]*)\)/,FUNCTION_NEWLINES_REGEX=/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,FUNCTION_BODY_REGEX=/[\w\W]*?\{([\w\W]*)\}/m,WHITESPACE_REGEX=/\s+/g,REQUIRE_REGEX=RegExp("(?:^|[\\s;,=\\?:\\}\\)\\(])require[\\s]*\\(['\"]([^'\"]+?)['\"]\\)","gim"),DEFINE_REGEX=RegExp("(?:^|[\\s;,\\?\\}\\)\\(])define[\\s]*\\([\\w\\W]*?\\[([\\w\\W]*?)\\]","gim"),DEFINE_TERM_REGEX=RegExp("['\"]([\\w\\W]*?)['\"]","gim"),IS_AMD_REGEX=/(?:^|[\s]+)define[\s]*\(/g,BUILTINS={require:!0,exports:!0,module:!0},BUILTINS_REPLACE_REGEX=/[\s]|"|'|(require)|(exports)|(module)/g,GREEDY_REQUIRE_REXEX=/require.*/,JS_COMMENTS_REGEX=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,RELATIVE_PATH_REGEX=/^(\.{1,2}\/).+/,ABSOLUTE_PATH_REGEX=/^([A-Za-z]+:)?\/\//,PROTOCOL_REGEX=/:\/\//,PROTOCOL_STRING="://",PROTOCOL_EXPANDED_REGEX=/__INJECT_PROTOCOL_COLON_SLASH_SLASH__/,PROTOCOL_EXPANDED_STRING="__INJECT_PROTOCOL_COLON_SLASH_SLASH__",HAS_OWN_PROPERTY=Object.prototype.hasOwnProperty,HAS_LOCAL_STORAGE=function(){try{return localStorage.setItem("injectLStest","ok"),localStorage.removeItem("injectLStest"),!0}catch(e){return!1}}(),LEADING_SLASHES_REGEX=/^\/+/g,userConfig={moduleRoot:null,fileExpires:0,useSuffix:!0,xd:{relayFile:null},debug:{sourceMap:!1,logging:!1}},context=this,userModules={},isHostMethod=function(e,t){var n=typeof e[t];return"function"===n||!("object"!==n||!e[t])||"unknown"===n},debugLog=function(){};(function(){var e="undefined"!=typeof console&&console.log&&"function"==typeof console.log,t=function(e,t){userConfig.debug&&userConfig.debug.logging&&console.log("## "+e+" ##"+"\n"+t)};e&&(debugLog=t)})();var normalizeStack;(function(){var e=null;normalizeStack=function(n){return e||(e=t.mode(n)),t[e](n)};var t={mode:function(e){if(e.arguments&&e.stack)return"chrome";if(e.stack&&e.sourceURL)return"safari";if(e.stack&&e.number)return"ie";if(e.stack&&e.fileName)return"firefox";if(e.message&&e["opera#sourceloc"])return e.stacktrace?e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?"opera9":"opera10a":"opera9";if(e.message&&e.stack&&e.stacktrace)return 0>e.stacktrace.indexOf("called from line")?"opera10b":"opera11";if(e.stack&&!e.fileName){var t=/:[\d]+:[\d]+\)?(\n|$)/;return t.test(e.stack)?"chrome":"phantom"}return"other"},chrome:function(e){return(e.stack+"\n").replace(/^\s+(at eval )?at\s+/gm,"").replace(/^([^\(]+?)([\n$])/gm,"{anonymous}() ($1)$2").replace(/^Object.\s*\(([^\)]+)\)/gm,"{anonymous}() ($1)").replace(/^(.+) \((.+)\)$/gm,"$1@$2").split("\n").slice(1,-1)},phantom:function(e){return(e.stack+"\n").replace(/^\s+(at eval )?at\s+/gm,"").replace(/^([^\(]+?)([\n$])/gm,"{anonymous}() ($1)$2").replace(/^Object.\s*\(([^\)]+)\)/gm,"{anonymous}() ($1)").replace(/^(.+) \((.+)\)$/gm,"$1@$2").replace(/(.+):([0-9]+)(\)?)/g,"$1:$2:0$3").split("\n").slice(1,-1)},safari:function(e){return e.stack.replace(/\[native code\]\n/m,"").replace(/^(?=\w+Error\:).*$\n/m,"").replace(/^@/gm,"{anonymous}()@").split("\n")},ie:function(e){return e.stack.replace(/^\s*at\s+(.*)$/gm,"$1").replace(/^Anonymous function\s+/gm,"{anonymous}() ").replace(/^(.+)\s+\((.+)\)$/gm,"$1@$2").split("\n").slice(1)},firefox:function(e){return e.stack.replace(/(?:\n@:0)?\s+$/m,"").replace(/^(?:\((\S*)\))?@/gm,"{anonymous}($1)@").split("\n")},opera11:function(e){for(var t="{anonymous}",n=/^.*line (\d+), column (\d+)(?: in (.+))? in (\S+):$/,r=e.stacktrace.split("\n"),i=[],o=0,s=r.length;s>o;o+=2){var u=n.exec(r[o]);if(u){var a=u[4]+":"+u[1]+":"+u[2],c=u[3]||"global code";c=c.replace(//,"$1").replace(//,t),i.push(c+"@"+a+" -- "+r[o+1].replace(/^\s+/,""))}}return i},opera10b:function(e){for(var t=/^(.*)@(.+):(\d+)$/,n=e.stacktrace.split("\n"),r=[],i=0,o=n.length;o>i;i++){var s=t.exec(n[i]);if(s){var u=s[1]?s[1]+"()":"global code";r.push(u+"@"+s[2]+":"+s[3])}}return r},opera10a:function(e){for(var t="{anonymous}",n=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split("\n"),i=[],o=0,s=r.length;s>o;o+=2){var u=n.exec(r[o]);if(u){var a=u[3]||t;i.push(a+"()@"+u[2]+":"+u[1]+" -- "+r[o+1].replace(/^\s+/,""))}}return i},opera9:function(e){for(var t="{anonymous}",n=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),i=[],o=2,s=r.length;s>o;o+=2){var u=n.exec(r[o]);u&&i.push(t+"()@"+u[2]+":"+u[1]+" -- "+r[o+1].replace(/^\s+/,""))}return i},other:function(e){for(var t,n,r="{anonymous}",i=/function\s*([\w\-$]+)?\s*\(/i,o=[],s=10;e&&e.arguments&&s>o.length;)t=i.test(""+e)?RegExp.$1||r:r,n=Array.prototype.slice.call(e.arguments||[]),o[o.length]=t+"("+this.stringifyArguments(n)+")",e=e.caller;return o}}})();var addListener,removeListener;(function(e){e.addEventListener?(addListener=function(e,t,n,r){e.addEventListener(t,n,r||!1)},removeListener=function(e,t,n,r){e.removeEventListener(t,n,r||!1)}):(addListener=function(e,t,n){e.attachEvent("on"+t,n)},removeListener=function(e,t,n){e.detachEvent("on"+t,n)})})(window);var reURI=/^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/,getXHR=function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=!1,n=0;e.length>n;n++){try{e[n](),t=e[n]}catch(r){continue}break}return t}(),module={exports:{}};(function(e){function t(e,t){var n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}function Fiber(){}var n=!1,r=Array.prototype,i=e.Fiber;Fiber.extend=function(e){function r(){n||(this.init.apply(this,arguments),this.init=void 0)}var i,o=this.prototype,s=e(o);return n=!0,i=r.prototype=new this,n=!1,i.init=function(){"function"==typeof o.init&&o.init.apply(this,arguments)},t(s,i),i.constructor=r,r.__base__=o,r.extend=Fiber.extend,r},Fiber.proxy=function(e,t){var n,r,i={};1===arguments.length&&(t=e,e=t.constructor.__base__),r=function(n){return function(){return e[n].apply(t,arguments)}};for(n in e)e.hasOwnProperty(n)&&"function"==typeof e[n]&&(i[n]=r(n));return i},Fiber.decorate=function(e){var n,i=e.constructor.__base__,o=r.slice.call(arguments,1),s=o.length;for(n=0;s>n;n++)t(o[n].call(e,i),e)},Fiber.mixin=function(e){var n,i=e.__base__,o=r.slice.call(arguments,1),s=o.length;for(n=0;s>n;n++)t(o[n](i),e.prototype)},Fiber.noConflict=function(){return e.Fiber=i,Fiber},module!==undefined?"function"==typeof module.setExports?module.setExports(Fiber):module.exports&&(module.exports=Fiber):e.Fiber=Fiber})(this);var Fiber=module.exports;module=undefined;var Flow=function(){var e,t=[],n=setTimeout(function(){n=null,e._next()},0);return e={destroy:function(){n&&clearTimeout(n)},par:function(n,r){return!r&&t[t.length-1]instanceof Array||t.push([]),t[t.length-1].push(n),e},seq:function(t){return e.par(t,!0)},_next:function(n,r){for(var i=[],o=[],s=t.shift()||[],u=s.length,a=1==u,c=0;s.length>c;c++)(function(t,s){t(function(t,n){i[s]=t,o[s]=n,0==--u&&e._next(a?i[0]:i,a?o[0]:o)},n,r)})(s[c],c)}}},lscache=function(){function e(){if(void 0!==i)return i;try{n("__lscachetest__","__lscachetest__"),r("__lscachetest__"),i=!0}catch(e){i=!1}return i}function t(){return void 0===o&&(o=null!=window.JSON),o}function n(e,t){localStorage.removeItem(s+a+e),localStorage.setItem(s+a+e,t)}function r(e){localStorage.removeItem(s+a+e)}var i,o,s="lscache-",u=Math.floor(144e9),a="";return{set:function(i,o,c){if(e()){if("string"!=typeof o){if(!t())return;try{o=JSON.stringify(o)}catch(l){return}}try{n(i,o)}catch(h){if("QUOTA_EXCEEDED_ERR"!==h.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==h.name)return;for(var d,f=[],g=0;localStorage.length>g;g++)if(d=localStorage.key(g),0===d.indexOf(s+a)&&0>d.indexOf("-cacheexpiration")){d=d.substr((s+a).length);var p=localStorage.getItem(s+a+(d+"-cacheexpiration")),p=p?parseInt(p,10):u;f.push({key:d,size:(localStorage.getItem(s+a+d)||"").length,expiration:p})}for(f.sort(function(e,t){return t.expiration-e.expiration}),g=(o||"").length;f.length&&g>0;)d=f.pop(),r(d.key),r(d.key+"-cacheexpiration"),g-=d.size;try{n(i,o)}catch(m){return}}c?n(i+"-cacheexpiration",(Math.floor((new Date).getTime()/6e4)+c).toString(10)):r(i+"-cacheexpiration")}},get:function(n){if(!e())return null;var i=n+"-cacheexpiration",o=localStorage.getItem(s+a+i);if(o&&(o=parseInt(o,10),Math.floor((new Date).getTime()/6e4)>=o))return r(n),r(i),null;if(n=localStorage.getItem(s+a+n),!n||!t())return n;try{return JSON.parse(n)}catch(u){return n}},remove:function(t){return e()?(r(t),r(t+"-cacheexpiration"),undefined):null},supported:function(){return e()},flush:function(){if(e())for(var t=localStorage.length-1;t>=0;--t){var n=localStorage.key(t);0===n.indexOf(s+a)&&localStorage.removeItem(n)}},setBucket:function(e){a=e},resetBucket:function(){a=""}}}();(function(){var e;HAS_LOCAL_STORAGE&&lscache&&(lscache.setBucket(FILE_STORAGE_TOKEN),e=lscache.get(LSCACHE_SCHEMA_VERSION_STRING),e&&e>0&&LSCACHE_SCHEMA_VERSION>e&&(lscache.flush(),lscache.set(LSCACHE_SCHEMA_VERSION_STRING,LSCACHE_SCHEMA_VERSION)))})();var Analyzer=Fiber.extend(function(){return{init:function(){},stripBuiltins:function(e){var t=[],n=e.length,r=0;for(r;n>r;r++)BUILTINS[e[r]]||t.push(e[r]);return t},extractRequires:function(e){var t,n,r,i=[],o={require:1,module:1,exports:1};if(!e)return[];for(e=e.replace(JS_COMMENTS_REGEX,"");t=REQUIRE_REGEX.exec(e);)r=t[1],o[r]||(o[r]=1,i.push(r));for(;t=DEFINE_REGEX.exec(e);)for(;n=DEFINE_TERM_REGEX.exec(t[1]);)r=n[1],o[r]||(o[r]=1,i.push(r));return i}}}),Communicator=Fiber.extend(function(){return{init:function(e){this.env=e,this.clearCaches(),this.alreadyListening=!1,this.socket=null,this.socketInProgress=!1,this.socketQueue=[],this.socketQueueCache={},this.downloadCompleteQueue={}},clearCaches:function(){self.downloadCompleteQueue={}},noop:function(e,t,n){n("")},get:function(e,t,n){if(this.downloadCompleteQueue[t]||(this.downloadCompleteQueue[t]=[]),debugLog("Communicator ("+t+")","requesting"),!this.env.config.relayFile){var r=this.readFromCache(t);if(r)return debugLog("Communicator ("+t+")","retireved from cache. length: "+r.length),n(r),undefined}return debugLog("Communicator ("+t+")","queued"),this.downloadCompleteQueue[t].length?(this.downloadCompleteQueue[t].push(n),debugLog("Communicator ("+t+")","request already in progress"),undefined):(this.downloadCompleteQueue[t].push(n),this.env.config.relayFile&&getDomainName(t)!==getDomainName(location.href)?(this.sendViaIframe(t),undefined):(this.sendViaXHR(t),undefined))},addSocketQueue:function(e){this.socketQueueCache[e]||(this.socketQueueCache[e]=1,this.socketQueue.push(e))},beginListening:function(){var e=this;this.alreadyListening||(this.alreadyListening=!0,addListener(window,"message",function(t){var n,r,i;if(e.env.config.relayFile&&getDomainName(t.origin)===getDomainName(e.env.config.relayFile))switch(n=t.data.split(/:/),r=n.shift()){case"ready":e.socketInProgress=!1,function(){var t=e.socketQueue;e.socketQueue=[],e.socketQueueCache={};for(var n=0,r=t.length;r>n;n++)sendMessage(e.socket.contentWindow,e.env.config.relayFile,"fetch",{url:t[n]})}();break;case"fetchFail":case"fetchOk":i=JSON.parse(n.join(":")),e.resolveCompletedFile(i.url,i.status,i.responseText)}}))},readFromCache:function(e){return this.env.config.expires>0?this.env.lscache.get(e):null},resolveCompletedFile:function(e,t,n){t=1*t,debugLog("Communicator ("+e+")","status "+t+". Length: "+(n?n.length:"NaN")),200===t&&!this.env.config.relayFile&&this.env.config.expires>0&&this.env.lscache.set(e,n,this.env.config.expires),200!==t&&(n="throw new Error('Error "+t+": Unable to retrieve "+e+"');"),each(this.downloadCompleteQueue[e],function(e){e(n)}),this.downloadCompleteQueue[e]=[]},sendViaIframe:function(e){this.beginListening();var t=this;if(this.socket&&!this.socketInProgress)sendMessage(this.socket.contentWindow,this.env.config.relayFile,"fetch",{url:e});else{if(this.socket&&this.socketInProgress)return this.addSocketQueue(e),undefined;this.socketInProgress=!0,this.addSocketQueue(e);var n=this.env.config.relayFile;this.socket=document.createElement("iframe"),n+=0>n.indexOf("?")?"?":"&",n+="injectReturn="+encodeURIComponent(location.href),this.socket.src=n,this.socket.style.visibility="hidden",this.socket.style.border=0,this.socket.style.width="1px",this.socket.style.height="1px",this.socket.style.left="-5000px",this.socket.style.top="-5000px",this.socket.style.opacity="0",window.setTimeout(function(){document.body.firsChild?document.body.insertBefore(t.socket,document.body.firstChild):document.body.appendChild(t.socket)})}},sendViaXHR:function(e){var t=this,n=getXHR();n.open("GET",e),n.onreadystatechange=function(){4===n.readyState&&t.resolveCompletedFile(e,n.status,n.responseText)},n.send(null)}}}),Executor=Fiber.extend(function(){function hasOwnProperty(e,t){return{}.prototype.hasOwnProperty.call(e,t)}function createGlobalObject(e,t){return window[e]={defineExecutingModuleAs:function(){t.defineExecutingModuleAs.apply(t,arguments)},undefineExecutingModule:function(){t.undefineExecutingModule.apply(t,arguments)}},window[e]}function removeGlobalObject(e){delete window[e]}function executeJavaScriptModule(globalObject,env,code,functionId){var meta=globalObject,module=meta.module,failed=!1,sourceString=IS_IE?"":"//@ sourceURL="+module.uri,result,err;code=[code,sourceString].join("\n");try{eval(code)}catch(ex){ex.message="Parse error in "+module.id+" ("+module.uri+") please check for an uncaught error "+ex.message;var scr=document.createElement("script");return scr.src=module.uri,scr.type="text/javascript",docHead.appendChild(scr),{__error:ex}}if(env.config.sourceUrls){var toExec=code.replace(/([\w\W]+?)=([\w\W]*\})[\w\W]*?$/,"$1 = ($2)();");toExec=[toExec,sourceString].join("\n"),eval(toExec),module.__error&&(module.__error.message="Runtime error in "+module.id+"("+module.uri+") "+module.__error.message)}else globalObject.fn(),module.__error&&(module.__error.message="Runtime error in "+module.id+"("+module.uri+") "+module.__error.message)}var functionCount=0,docHead=!1;try{docHead=document.getElementsByTagName("head")[0]}catch(e){docHead=!1}return{init:function(e){this.env=e,this.clearCaches()},clearCaches:function(){this.cache={},this.errors={},this.anonymousAMDStack=[]},defineExecutingModuleAs:function(e,t){return this.anonymousAMDStack.push({id:e,path:t})},undefineExecutingModule:function(){return this.anonymousAMDStack.pop()},getCurrentExecutingAMD:function(){return this.anonymousAMDStack[this.anonymousAMDStack.length-1]},getFromCache:function(e){var t,n,r,i,o,s,u,a,c,l=this.env.rulesEngine.getOriginalName(e);if(HAS_OWN_PROPERTY.call(this.errors,e)&&this.errors[e]?t=this.errors[e]:l&&HAS_OWN_PROPERTY.call(this.errors,l)&&this.errors[l]&&(t=this.errors[l]),this.cache[e]?r=this.cache[e]:l&&this.cache[l]&&(this.cache[e]=this.cache[l],r=this.cache[l]),t)throw n="module "+e+" failed to load successfully",n+=t?": "+t.message:"",r&&r.__error_line&&(i=normalizeStack(t),o=normalizeStack(r.__error_line),s=i[0].split(/:/),u=o[0].split(/:/),a=s[s.length-2]-u[u.length-2],a-=1,c=s[s.length-1],n=n+" @ Line: "+a+" Column: "+c+" "),t.message=n,t;return r||null},createModule:function(e,t,n){var r;return!/\!/.test(e)&&this.cache[e]?(this.cache[t]=this.cache[e],this.cache[e].qualifiedIds[t]=1,this.cache[e]):(r={},r.id=e||null,r.qualifiedIds={},r.uri=n||null,r.exports={},r.exec=!1,r.setExports=function(e){var t;for(t in r.exports)if(Object.hasOwnProperty.call(r.exports,t))return debugLog("cannot setExports when exports have already been set. setExports skipped"),undefined;switch(typeof e){case"object":for(t in e)r.exports[t]=e[t];break;case"function":r.exports=e;break;default:r.exports=e}},/\!/.test(e)||(this.cache[e]=r,this.cache[e].qualifiedIds[t]=1),this.cache[t]=r,this.cache[t].qualifiedIds[e]=1,r)},getModule:function(e,t){return this.getFromCache(e)||t},runModule:function(e,t){function n(t){return t.replace(/__MODULE_ID__/g,e.id).replace(/__MODULE_URI__/g,e.uri).replace(/__FUNCTION_ID__/g,r).replace(/__REACHABLE_PATH__/g,i)}debugLog("Executor","executing "+e.uri);var r="exec"+functionCount++,i=this.env.instance+"_"+r,o=createGlobalObject(i,this),s=[];for(var u in e.qualifiedIds)e.qualifiedIds.hasOwnProperty(u)&&s.push(u);o.module=e,o.require=this.env.requireContext.createRequire(e.id,e.uri,s),o.define=this.env.requireContext.createInlineDefine(e,o.require);var a=n(commonJSHeader),c=n(commonJSFooter),l=[a,";",t,c].join("\n");executeJavaScriptModule(o,this.env,l,r),e.__error&&(debugLog("Executor","broken",e.id,e.uri,e.exports),this.errors[e.id]=e.__error),removeGlobalObject(i),debugLog("Executor","executed",e.id,e.uri,e.exports)}}}),InjectContext=Fiber.extend(function(){var e;return{init:function(t){this._={},this.env={config:{moduleRoot:null,suffixes:!0,sourceUrls:!1,relayFile:null,expires:0},instance:guid()},e||(e=allComponents()),this.env.analyzer=new e.Analyzer(this.env),this.env.communicator=new e.Communicator(this.env),this.env.executor=new e.Executor(this.env),this.env.requireContext=new e.RequireContext(this.env),this.env.rulesEngine=new e.RulesEngine(this.env),this.env.TreeNode=e.TreeNode,this.env.TreeRunner=e.TreeRunner,t?this.setModuleRoot(t):(this.require=this.env.requireContext.createRequire(),this.define=this.env.requireContext.createDefine())},setModuleRoot:function(t){return this.env.config.moduleRoot=t,this.env.requireContext=new e.RequireContext(this.env),this.require=this.env.requireContext.createRequire(t),this.define=this.env.requireContext.createDefine(t),this},setCrossDomain:function(e){return this.env.config.relayFile="string"==typeof e?e:e.relayFile,this},disableSuffixes:function(){return this.env.config.suffixes=!1,this},enableSuffixes:function(){return this.env.config.suffixes=!0,this},setExpires:function(e){return this.env.config.expires=e||0,this},setCacheKey:function(t){var n;return e.cache?(n=e.cache.get(LSCACHE_APP_KEY_STRING),(!t&&n||null!==n&&n!==t||null===n&&t)&&(e.cache.flush(),e.cache.set(LSCACHE_APP_KEY_STRING,t)),this):!1},reset:function(e){return this.env.executor.clearCaches(),e&&this.env.communicator.clearCaches(),this},disableAMD:function(){return this.define.amd=!1,this.define},enableAMD:function(){return this.define.amd={},this.define},enableAMDPlugins:function(){return this.env.config.amdPlugins=!0,amdPluginBreakout(this.env),this},addModuleRule:function(){return this.env.rulesEngine.addModuleRule.apply(this.env.rulesEngine,arguments),this},addFileRule:function(){return this.env.rulesEngine.addFileRule.apply(this.env.rulesEngine,arguments),this},addContentRule:function(){return this.env.rulesEngine.addContentRule.apply(this.env.rulesEngine,arguments),this},addFetchRule:function(){return this.env.rulesEngine.addFetchRule.apply(this.env.rulesEngine,arguments),this},addPackage:function(){return this.env.rulesEngine.addPackage.apply(this.env.rulesEngine,arguments),this},enableSourceUrls:function(){return this.env.config.sourceUrls=!0,this},disableSourceUrls:function(){return this.env.config.sourceUrls=!1,this},createContext:function(){return InjectContext.createContext.apply(InjectContext,arguments)}}});InjectContext.createContext=function(e){var t=new InjectContext(e);return{require:t.require,define:t.define,Inject:t}};var RequireContext=Fiber.extend(function(){return{init:function(e,t,n,r){this.env=e,this.id=t||null,this.path=n||null,this.qualifiedIds=r||[]},log:function(e){debugLog("RequireContext for "+this.path,e)},getPath:function(){if(!this.env.config.moduleRoot)throw Error("moduleRoot must be defined. Please use Inject.setModuleRoot()");return this.path||this.env.config.moduleRoot},getId:function(){return this.id||""},require:function(e,t){var n,r,i,o,s,u,a=[],c={};if("string"==typeof e){if(this.log("CommonJS require(string) of "+e),/^[\d]+$/.test(e))throw Error("require() must be a string containing a-z, slash(/), dash(-), and dots(.)");for(r=this.env.rulesEngine.resolveModule(e,this.getId()),i=this.env.requireContext.qualifiedId(r,this.id),a=[r,i],c[r]=1,c[i]=1,s=0,u=this.qualifiedIds.length;u>s;s++)o=this.env.requireContext.qualifiedId(r,this.qualifiedIds[s]),c[o]||(a.push(o),c[o]=1);for(s=0,u=a.length;!n&&u>s;s++)n=this.env.executor.getModule(a[s]);if(!n)throw Error("module "+e+" is not available");if(n.__error)throw n.__error;return n.exports}this.log("AMD require(Array) of "+e.join(", "));var l=[];this.ensure(e,proxy(function(n){for(var r=0,i=e.length;i>r;r++)switch(e[r]){case"require":l.push(n);break;case"module":case"exports":throw Error("require(array, callback) doesn't create a module. You cannot use module/exports here");default:l.push(n(e[r]))}t.apply(context,l)},this))},ensure:function(e,t){if("[object Array]"!==Object.prototype.toString.call(e))throw Error("require.ensure() must take an Array as the first argument");this.log("CommonJS require.ensure(array) of "+e.join(", ")),e=this.env.analyzer.stripBuiltins(e);var require=proxy(this.require,this);this.process(e,function(){"function"==typeof t&&t(require)})},run:function(e){this.log("AMD require.run(string) of "+e),this.ensure([e])},define:function(){var e,t,n=Array.prototype.slice.call(arguments,0),r=null,i=["require","exports","module"],o=!1,s={},u={"string array object":["id","dependencies","factory"],"string object":["id","factory"],"array object":["dependencies","factory"],object:["factory"]},a=[];for(t=0,len=n.length;len>t;t++)"[object Array]"===Object.prototype.toString.apply(n[t])?a.push("array"):"object"==typeof n[t]||"function"==typeof n[t]?a.push("object"):a.push(typeof n[t]);if(a=a.join(" "),!u[a])throw Error("You did not use an AMD compliant interface. Please check your define() calls");for(a=u[a],t=0,len=a.length;len>t;t++)switch(e=n[t],a[t]){case"id":r=e;break;case"dependencies":i=e,o=!0;break;case"factory":s=e}if(!r){if(currentExecutingAMD=this.env.executor.getCurrentExecutingAMD(),!currentExecutingAMD)throw Error("Anonymous AMD module used, but it was not included as a dependency. This is most often caused by an anonymous define() from a script tag.");r=currentExecutingAMD.id,this.log("AMD identified anonymous module as "+r)}this.process(r,i,function(e){if(e.data.resolvedId){for(var t,n=[],r=o?i:["require","exports","module"],require=this.env.requireContext.createRequire(e.data.resolvedId,e.data.resolvedUrl),u=this.env.executor.createModule(e.data.resolvedId,this.env.requireContext.qualifiedId(e),e.data.resolvedUrl),a=0,c=r.length;c>a;a++)switch(r[a]){case"require":n.push(require);break;case"module":n.push(u);break;case"exports":n.push(u.exports);break;default:n.push(require(r[a]))}"function"==typeof s?(t=s.apply(u,n),t&&(u.exports=t)):"object"==typeof s&&(u.exports=s),u.amd=!0,u.exec=!0}})},process:function(e){var t,n,r;"string"!=typeof e?(t=this.id,n=arguments[0],r=arguments[1]):(t=arguments[0],n=arguments[1],r=arguments[2]);var o,s,u=new this.env.TreeNode,a=n.length,c=[],l=this,h=function(){(0===a||0===--a)&&(s=new l.env.TreeRunner(l.env,u),s.execute(function(){r.call(l,u)}))};if(u.data.originalId=t,u.data.resolvedId=t,u.data.resolvedUrl=this.env.rulesEngine.resolveFile(t,this.path),n.length)for(i=0,len=n.length;len>i;i++)BUILTINS[n[i]]?h():(o=new this.env.TreeNode,o.data.originalId=n[i],u.addChild(o),this.env.executor.getModule(n[i])?h():this.env.executor.getModule(this.env.requireContext.qualifiedId(this.env.rulesEngine.resolveModule(o.data.originalId,u.data.resolvedId),o))?h():(s=new this.env.TreeRunner(this.env,o),c.push(s),s.download(h)));else h()},createRequire:function(e,t,n){var r=new RequireContext(this.env,e,t,n),require=proxy(r.require,r),i=this;return require.ensure=proxy(r.ensure,r),require.run=proxy(r.run,r),require.toUrl=function(t){var n=i.env.rulesEngine.resolveModule(t,e),r=i.env.rulesEngine.resolveFile(n,"",!0);return r},require},createDefine:function(e,t,n){var r=new RequireContext(this.env,e,t),define=proxy(r.define,r);return define.amd=n?!1:{},define},qualifiedId:function(e,t){var n=[];return"string"==typeof e?t?[e,t].join("(from)"):e:(e.parents(function(e){e.data.resolvedId&&n.push(e.data.resolvedId)}),n.join("(from)"))},createInlineDefine:function(e,require){var define=function(){function t(e){return"[object Array]"===Object.prototype.toString.call(e)}for(var n,r=[],i=["require","exports","module"],o={},s=0,u=arguments.length;u>s;s++)if(t(arguments[s])){i=arguments[s];break}o=arguments[arguments.length-1];for(var a=0,c=i.length;c>a;a++)switch(i[a]){case"require":r.push(require);break;case"module":r.push(e);break;case"exports":r.push(e.exports);break;default:r.push(require(i[a]))}"function"==typeof o?(n=o.apply(e,r),n&&(e.exports=n)):"object"==typeof o&&(e.exports=o),e.amd=!0,e.exec=!0};return define.amd={},define}}}),RulesEngine=Fiber.extend(function(){var e=function(e){return e=e.split("/"),e.pop(),e=e.join("/")};return{init:function(e){this.env=e,this.clearRules()},clearRules:function(){this.moduleRules=[],this.fileRules=[],this.contentRules=[],this.fetchRules=[],this.aliasRules={},this.revAliasRules={},this.dirty={moduleRules:!0,fileRules:!0,contentRules:!0,fetchRules:!0,aliasRules:!0,revAliasRules:!0},this.caches={moduleRules:{},fileRules:{},contentRules:{},fetchRules:{},aliasRules:{},revAliasRules:{}},this.addRuleCounter=0,this.addRulePointcuts={}},add:function(e,t,n,r){this.dirty[e]=!0,r=r||{};var i=r.weight||this[e].length,o=r.last||!1;this[e].push({matches:t,fn:"function"==typeof n?n:function(){return n},weight:i,last:o,all:r})},clearCache:function(e){this.caches[e]={}},sort:function(e){this.dirty[e]&&(this.clearCache(e),this[e].sort(function(e,t){return t.weight-e.weight}),this.dirty[e]=!1)},getDeprecatedPointcuts:function(e){return this.addRulePointcuts[e]||[]},addRule:function(e,t,n){n||(n=t,t=null),n||(n={}),"string"==typeof n&&(n={path:n}),n.weight||(n.weight=this.addRuleCounter++),n.path?this.addFileRule(e,n.path,{weight:n.weight,last:n.last,useSuffix:n.useSuffix,afterFetch:n.pointcuts&&n.pointcuts.afterFetch?n.pointcuts.afterFetch:null}):n.pointcuts&&n.pointcuts.afterFetch&&this.addContentRule(e,n.pointcuts.afterFetch,{weight:n.weight})},addModuleRule:function(e,t,n){return this.add("moduleRules",e,t,n)},addFileRule:function(e,t,n){return this.add("fileRules",e,t,n)},addContentRule:function(e,t,n){return this.add("contentRules",e,t,n)},addFetchRule:function(e,t,n){return this.add("fetchRules",e,t,n)},addPackage:function(e,t){if(this.dirty.aliasRules=!0,this.revAliasRules[e])throw Error("An alias can only map back to 1 origin");this.aliasRules[e]||(this.aliasRules[e]=[]),this.aliasRules[e].push(t),this.revAliasRules[t]=e},resolveModule:function(t,n){t=t||"",n=n||"",this.sort("moduleRules");var r,i,o=t,s=0,u=this.moduleRules,a=u.length,c=!1;for(s;a>s&&(r=u[s].matches,i=u[s].fn,c=!1,"string"==typeof r?r===t&&(c=!0):"function"==typeof r.test&&(c=r.test(t)),!c||(o=i(o),!r.last));s++);return o=o.replace(LEADING_SLASHES_REGEX,""),0!==o.indexOf(".")&&(n=null),n&&(n=e(n)),o=this.getRelative(o,n),o=o.replace(LEADING_SLASHES_REGEX,""),this.caches.moduleRules[t]=o,o},resolveFile:function(e,t,n){e=e||"",t=t||"",this.sort("fileRules");var r,i,o=e,s=0,u=this.fileRules,a=u.length,c=!1,l=this.env,h=[];for(s;a>s&&(r=u[s].matches,i=u[s].fn,c=!1,"string"==typeof r?r===e&&(c=!0):"function"==typeof r.test&&(c=r.test(e)),!c||(o=i(o),u[s].all&&u[s].all.afterFetch&&h.push(u[s].all.afterFetch),!u[s].last));s++);return l.config.moduleRoot||"undefined"==typeof console||"function"!=typeof console.log||console.log("Without moduleRoot defined, Inject will default to the URL of the current page. This may cause unexpected behavior"),o?(t&&!l.config.baseDir?(t=t.replace(PROTOCOL_REGEX,PROTOCOL_EXPANDED_STRING).split("/"),t[t.length-1]&&1!==t.length&&t.pop(),t=t.join("/").replace(PROTOCOL_EXPANDED_REGEX,PROTOCOL_STRING)):t=t?l.config.baseDir(t):l.config.moduleRoot?l.config.moduleRoot:location.pathname,ABSOLUTE_PATH_REGEX.test(o)?(this.caches.fileRules[e]=o,o):(t=t.replace(PROTOCOL_REGEX,PROTOCOL_EXPANDED_STRING),o=o.replace(PROTOCOL_REGEX,PROTOCOL_EXPANDED_STRING),o=/\?/.test(t)?t+o:this.getRelative(o,t),o=o.replace(PROTOCOL_EXPANDED_REGEX,PROTOCOL_STRING),n||!l.config.suffixes||FILE_SUFFIX_REGEX.test(o)||(o+=BASIC_FILE_SUFFIX),this.addRulePointcuts[o]=h,this.caches.fileRules[e]=o,o)):(this.addRulePointcuts[o]=h,this.caches.fileRules[e]=o,o)},getAliases:function(e){return this.aliasRules[e]||[]},getOriginalName:function(e){return this.revAliasRules[e]||null},getFetchRules:function(e){this.sort("fetchRules");var t,n,r=0,i=this.fetchRules,o=i.length,s=!1,u=[];for(r;o>r;r++)t=i[r].matches,n=i[r].fn,s=!1,"string"==typeof t?t===e&&(s=!0):"function"==typeof t.test&&(s=t.test(e)),s&&u.push(n);return this.caches.contentRules[e]=u,u},getContentRules:function(e){this.sort("contentRules");var t,n,r=0,i=this.contentRules,o=i.length,s=!1,u=[],a=!1,c=this.addRulePointcuts[e]||[];for(r;o>r;r++)t=i[r].matches,n=i[r].fn,s=!1,"string"==typeof t?t===e&&(s=!0):"function"==typeof t.test&&(s=t.test(e)),s&&u.push(n);return each(c,function(e){a=!1,each(u,function(t){t===e&&(a=!0)}),a||u.push(e)}),this.caches.contentRules[e]=u,u -},getRelative:function(e,t){var n,r,i,o,s,u=[];if(t=t||"",ABSOLUTE_PATH_REGEX.test(e))return e;if(0===e.indexOf("/")&&(t=""),n=[],t.length)for(i=0,o=t.split("/"),s=o.length;s>i;i++)n.push(o[i]);for(i=0,o=e.split("/"),s=o.length;s>i;i++)n.push(o[i]);for(i=0,s=n.length;s>i;i++)if(r=n[i],!("."===r||""===r&&i>0))if(".."===r){if(0===u.length)throw Error("could not traverse higher than highest path: "+e+", "+t);u.pop()}else u.push(r);return u=u.join("/")}}}),TreeNode=Fiber.extend(function(){return{init:function(){this.data={},this.children=[],this.left=null,this.right=null,this.parent=null},addChild:function(e){var t;return this.children.length>0&&(t=this.children[this.children.length-1],e.setLeft(t),t.setRight(e)),this.children.push(e),e.setParent(this)},getChildren:function(){return this.children},setLeft:function(e){return this.left=e,this.left},getLeft:function(){return this.left},setRight:function(e){return this.right=e,this.right},getRight:function(){return this.right},setParent:function(e){return this.parent=e,this.parent},getParent:function(){return this.parent},parents:function(e){for(var t=[],n=this;n;)e&&e(n),t.push(n),n=n.getParent();return t},postOrder:function(e){for(var t=this,n=null,r=[];t;)if(t.getChildren().length>0&&"up"!==n)n="down",t=t.getChildren()[0];else if(r.push(t),e&&e(t),t.getRight())n="right",t=t.getRight();else{if(!t.getParent())return r;n="up",t=t.getParent()}}}}),TreeRunner=Fiber.extend(function(){var e=function(){function e(){var e=i;for(i=[],u=!1,fn=e.shift();fn;)fn(),fn=e.shift()}function t(e){i.push(e),u||(u=!0,n())}var n,r,i=[],o=!!window.postMessage,s="inject-nexttick",u=!1;return o?(n=function(){window.postMessage(s,"*")},r=function(t){t.source==window&&t.data===s&&(t.stopPropagation?t.stopPropagation():t.returnValue=!1,e())},t.listener=addListener(window,"message",r,!0)):(n=function(){window.setTimeout(function(){r()},0)},r=e),t.removeListener=function(){removeListener(window,"message",r,!0)},t}();return{init:function(e,t){this.env=e,this.root=t},download:function(e){var t,n=this.root,r=this,i=n.data,o=n.getParent();i.resolvedId=o?this.env.rulesEngine.resolveModule(i.originalId,o.data.resolvedId):this.env.rulesEngine.resolveModule(i.originalId,""),i.resolvedUrl=this.env.rulesEngine.resolveFile(i.resolvedId),t=this.buildCommunicator(n),t(i.originalId,i.resolvedUrl,function(t){var s=r.env.rulesEngine.getContentRules(i.resolvedUrl),u=new Flow,a=0,c=s.length;for(addContent=function(e){u.seq(function(t,n,r){try{e(function(e){t(null,e)},r)}catch(i){t(i,r)}})},u.seq(function(e){e(null,t)}),a;c>a;a++)addContent(s[a]);u.seq(function(t,s,u){var a,c=!1,l={},h=o;for("string"==typeof u?i.file=u:i.exports=u,l[i.originalId]=!0;h&&!c;)l[h.data.originalId]?c=!0:(l[h.data.originalId]=!0,h=h.getParent());i.circular=c,i.exports?(a=r.env.executor.createModule(i.resolvedId,r.env.requireContext.qualifiedId(n),i.resolvedUrl),a.exec=!0,a.exports=u,e()):i.circular?e():r.downloadDependencies(n,proxy(e,r))})})},execute:function(e){var t=this.root.postOrder(),n=this,r=t.length,i=0,o=function(e){var t,r=e.data;r.resolvedId&&(t=n.env.executor.createModule(r.resolvedId,n.env.requireContext.qualifiedId(e),r.resolvedUrl),r.module=t,t.exec||r.circular||(r.exports?(t.exports=r.exports,t.exec=!0):"string"==typeof r.file&&(n.env.executor.runModule(t,r.file),t.exec=!0,t.amd||(r.exports=t.exports))))};for(i;r>i;i++)o(t[i]);e()},buildCommunicator:function(e){var t=e.data,n=this,r=e.getParent()?e.getParent().data:null,i=this.env.rulesEngine.getFetchRules(t.resolvedId),o=new Flow,s={module:function(){return n.env.rulesEngine.resolveModule.apply(n.env.rulesEngine,arguments)},url:function(){return n.env.rulesEngine.resolveFile.apply(n.env.rulesEngine,arguments)}},u={get:function(){return n.env.communicator.get.apply(n.env.communicator,arguments)}},a=function(e){o.seq(function(n,i,o){function a(e,t){n(null,t)}function c(e){n(e,o)}try{e(a,o,s,u,{moduleId:t.originalId,parentId:r?r.originalId:"",parentUrl:r?r.resolvedUrl:""})}catch(l){c(l)}})};return this.env.executor.getModule(t.resolvedId)?function(e,t,n){n("")}:this.env.executor.getModule(this.env.requireContext.qualifiedId(e))?function(e,t,n){n("")}:i.length>0?function(e,t,n){var r=0,s=i.length;for(o.seq(function(e){e(null,"")}),r;s>r;r++)a(i[r]);o.seq(function(e,t,r){n(r)})}:proxy(this.env.communicator.get,this.env.communicator)},downloadDependencies:function(t,n){var r,i,o=this.env.analyzer.extractRequires(t.data.file),s=o.length,u=0,a=s,c=function(){s--,0===s&&n()},l=function(t){e(function(){t.download(c)})};if(!o.length)return n();for(u;a>u;u++)r=new TreeNode,r.data.originalId=o[u],t.addChild(r),this.env.executor.getModule(o[u])&&this.env.executor.getModule(o[u]).exec?c():(i=new this.env.TreeRunner(this.env,r),l(i))}}});init("0.7.0-rc3")})(this); \ No newline at end of file +},getRelative:function(e,t){var n,r,i,o,s,u=[];if(t=t||"",ABSOLUTE_PATH_REGEX.test(e))return e;if(0===e.indexOf("/")&&(t=""),n=[],t.length)for(i=0,o=t.split("/"),s=o.length;s>i;i++)n.push(o[i]);for(i=0,o=e.split("/"),s=o.length;s>i;i++)n.push(o[i]);for(i=0,s=n.length;s>i;i++)if(r=n[i],!("."===r||""===r&&i>0))if(".."===r){if(0===u.length)throw Error("could not traverse higher than highest path: "+e+", "+t);u.pop()}else u.push(r);return u=u.join("/")}}}),TreeNode=Fiber.extend(function(){return{init:function(){this.data={},this.children=[],this.left=null,this.right=null,this.parent=null},addChild:function(e){var t;return this.children.length>0&&(t=this.children[this.children.length-1],e.setLeft(t),t.setRight(e)),this.children.push(e),e.setParent(this)},getChildren:function(){return this.children},setLeft:function(e){return this.left=e,this.left},getLeft:function(){return this.left},setRight:function(e){return this.right=e,this.right},getRight:function(){return this.right},setParent:function(e){return this.parent=e,this.parent},getParent:function(){return this.parent},parents:function(e){for(var t=[],n=this;n;)e&&e(n),t.push(n),n=n.getParent();return t},postOrder:function(e){for(var t=this,n=null,r=[];t;)if(t.getChildren().length>0&&"up"!==n)n="down",t=t.getChildren()[0];else if(r.push(t),e&&e(t),t.getRight())n="right",t=t.getRight();else{if(!t.getParent())return r;n="up",t=t.getParent()}}}}),TreeRunner=Fiber.extend(function(){var e=function(){function e(){var e=i;for(i=[],u=!1,fn=e.shift();fn;)fn(),fn=e.shift()}function t(e){i.push(e),u||(u=!0,n())}var n,r,i=[],o=!!window.postMessage,s="inject-nexttick",u=!1;return o?(n=function(){window.postMessage(s,"*")},r=function(t){t.source==window&&t.data===s&&(t.stopPropagation?t.stopPropagation():t.returnValue=!1,e())},t.listener=addListener(window,"message",r,!0)):(n=function(){window.setTimeout(function(){r()},0)},r=e),t.removeListener=function(){removeListener(window,"message",r,!0)},t}();return{init:function(e,t){this.env=e,this.root=t},download:function(e){var t,n=this.root,r=this,i=n.data,o=n.getParent();i.resolvedId=o?this.env.rulesEngine.resolveModule(i.originalId,o.data.resolvedId):this.env.rulesEngine.resolveModule(i.originalId,""),i.resolvedUrl=this.env.rulesEngine.resolveFile(i.resolvedId),t=this.buildCommunicator(n),t(i.originalId,i.resolvedUrl,function(t){var s=r.env.rulesEngine.getContentRules(i.resolvedUrl),u=new Flow,a=0,c=s.length;for(addContent=function(e){u.seq(function(t,n,r){try{e(function(e){t(null,e)},r)}catch(i){t(i,r)}})},u.seq(function(e){e(null,t)}),a;c>a;a++)addContent(s[a]);u.seq(function(t,s,u){var a,c=!1,l={},h=o;for("string"==typeof u?i.file=u:i.exports=u,l[i.originalId]=!0;h&&!c;)l[h.data.originalId]?c=!0:(l[h.data.originalId]=!0,h=h.getParent());i.circular=c,i.exports?(a=r.env.executor.createModule(i.resolvedId,r.env.requireContext.qualifiedId(n),i.resolvedUrl),a.exec=!0,a.exports=u,e()):i.circular?e():r.downloadDependencies(n,proxy(e,r))})})},execute:function(e){var t=this.root.postOrder(),n=this,r=t.length,i=0,o=function(e){var t,r=e.data;r.resolvedId&&(t=n.env.executor.createModule(r.resolvedId,n.env.requireContext.qualifiedId(e),r.resolvedUrl),r.module=t,t.exec||r.circular||(r.exports?(t.exports=r.exports,t.exec=!0):"string"==typeof r.file&&(n.env.executor.runModule(t,r.file),t.exec=!0,t.amd||(r.exports=t.exports))))};for(i;r>i;i++)o(t[i]);e()},buildCommunicator:function(e){var t=e.data,n=this,r=e.getParent()?e.getParent().data:null,i=this.env.rulesEngine.getFetchRules(t.resolvedId),o=new Flow,s={module:function(){return n.env.rulesEngine.resolveModule.apply(n.env.rulesEngine,arguments)},url:function(){return n.env.rulesEngine.resolveFile.apply(n.env.rulesEngine,arguments)}},u={get:function(){return n.env.communicator.get.apply(n.env.communicator,arguments)}},a=function(e){o.seq(function(n,i,o){function a(e,t){n(null,t)}function c(e){n(e,o)}try{e(a,o,s,u,{moduleId:t.originalId,parentId:r?r.originalId:"",parentUrl:r?r.resolvedUrl:""})}catch(l){c(l)}})};if(-1===t.resolvedId.indexOf("!")){if(this.env.executor.getModule(t.resolvedId))return function(e,t,n){n("")};if(this.env.executor.getModule(this.env.requireContext.qualifiedId(e)))return function(e,t,n){n("")}}return i.length>0?function(e,t,n){var r=0,s=i.length;for(o.seq(function(e){e(null,"")}),r;s>r;r++)a(i[r]);o.seq(function(e,t,r){n(r)})}:proxy(this.env.communicator.get,this.env.communicator)},downloadDependencies:function(t,n){var r,i,o=this.env.analyzer.extractRequires(t.data.file),s=o.length,u=0,a=s,c=function(){s--,0===s&&n()},l=function(t){e(function(){t.download(c)})};if(!o.length)return n();for(u;a>u;u++)r=new TreeNode,r.data.originalId=o[u],t.addChild(r),this.env.executor.getModule(o[u])&&this.env.executor.getModule(o[u]).exec?c():(i=new this.env.TreeRunner(this.env,r),l(i))}}});init("0.7.0-rc3")})(this); \ No newline at end of file diff --git a/src/treerunner.js b/src/treerunner.js index 99398a0..c191d16 100644 --- a/src/treerunner.js +++ b/src/treerunner.js @@ -300,21 +300,26 @@ var TreeRunner = Fiber.extend(function() { }); }; - // is this module already available? If so, don't redownload. This happens often when - // there was an inline define() on the page - if (this.env.executor.getModule(nodeData.resolvedId)) { - return function(a, b, cb) { - cb(''); - }; - } + // for non-AMD modules, if the module is already resolved, return an empty string + // which will cause the communicator to exit early and apply content rules if required + // for AMD modules, we re-fetch every time due to the nature of dynamic modules + if (nodeData.resolvedId.indexOf('!') === -1) { + // is this module already available? If so, don't redownload. This happens often when + // there was an inline define() on the page + if (this.env.executor.getModule(nodeData.resolvedId)) { + return function(a, b, cb) { + cb(''); + }; + } - else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) { - return function(a, b, cb) { - cb(''); - }; + else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) { + return function(a, b, cb) { + cb(''); + }; + } } - else if (fetchRules.length > 0) { + if (fetchRules.length > 0) { return function(name, path, cb) { var i = 0, len = fetchRules.length;