lfr-amd-loader
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,1 +0,1 @@ | ||
(function(){function e(e,t){x[C]=e,x[C+1]=t,C+=2,2===C&&P()}function t(e){return"function"==typeof e}function n(){return function(){process.nextTick(s)}}function o(){var e=0,t=new O(s),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function i(){var e=new MessageChannel;return e.port1.onmessage=s,function(){e.port2.postMessage(0)}}function r(){return function(){setTimeout(s,1)}}function s(){for(var e=0;C>e;e+=2)x[e](x[e+1]),x[e]=void 0,x[e+1]=void 0;C=0}function u(){}function a(e,t,n,o){try{e.call(t,n,o)}catch(i){return i}}function l(t,n,o){e(function(e){var t=!1,i=a(o,n,function(o){t||(t=!0,n!==o?f(e,o):h(e,o))},function(n){t||(t=!0,p(e,n))});!t&&i&&(t=!0,p(e,i))},t)}function c(e,t){1===t.a?h(e,t.b):2===e.a?p(e,t.b):g(t,void 0,function(t){f(e,t)},function(t){p(e,t)})}function f(e,n){if(e===n)p(e,new TypeError("You cannot resolve a promise with itself"));else if("function"==typeof n||"object"==typeof n&&null!==n)if(n.constructor===e.constructor)c(e,n);else{var o;try{o=n.then}catch(i){A.error=i,o=A}o===A?p(e,A.error):void 0===o?h(e,n):t(o)?l(e,n,o):h(e,n)}else h(e,n)}function d(e){e.f&&e.f(e.b),m(e)}function h(t,n){void 0===t.a&&(t.b=n,t.a=1,0!==t.e.length&&e(m,t))}function p(t,n){void 0===t.a&&(t.a=2,t.b=n,e(d,t))}function g(t,n,o,i){var r=t.e,s=r.length;t.f=null,r[s]=n,r[s+1]=o,r[s+2]=i,0===s&&t.a&&e(m,t)}function m(e){var t=e.e,n=e.a;if(0!==t.length){for(var o,i,r=e.b,s=0;s<t.length;s+=3)o=t[s],i=t[s+n],o?_(n,o,i,r):i(r);e.e.length=0}}function v(){this.error=null}function _(e,n,o,i){var r,s,u,a,l=t(o);if(l){try{r=o(i)}catch(c){k.error=c,r=k}if(r===k?(a=!0,s=r.error,r=null):u=!0,n===r)return void p(n,new TypeError("A promises callback cannot return that same promise."))}else r=i,u=!0;void 0===n.a&&(l&&u?f(n,r):a?p(n,s):1===e?h(n,r):2===e&&p(n,r))}function y(e,t){try{t(function(t){f(e,t)},function(t){p(e,t)})}catch(n){p(e,n)}}function b(e,t,n,o){this.n=e,this.c=new e(u,o),this.i=n,this.o(t)?(this.m=t,this.d=this.length=t.length,this.l(),0===this.length?h(this.c,this.b):(this.length=this.length||0,this.k(),0===this.d&&h(this.c,this.b))):p(this.c,this.p())}function M(e){if(q++,this.b=this.a=void 0,this.e=[],u!==e){if(!t(e))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof M))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");y(this,e)}}var P,w=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},C=0,j="undefined"!=typeof window?window:{},O=j.MutationObserver||j.WebKitMutationObserver,j="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,x=Array(1e3);P="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?n():O?o():j?i():r();var A=new v,k=new v;b.prototype.o=function(e){return w(e)},b.prototype.p=function(){return Error("Array Methods must be provided an Array")},b.prototype.l=function(){this.b=Array(this.length)},b.prototype.k=function(){for(var e=this.length,t=this.c,n=this.m,o=0;void 0===t.a&&e>o;o++)this.j(n[o],o)},b.prototype.j=function(e,t){var n=this.n;"object"==typeof e&&null!==e?e.constructor===n&&void 0!==e.a?(e.f=null,this.g(e.a,t,e.b)):this.q(n.resolve(e),t):(this.d--,this.b[t]=this.h(e))},b.prototype.g=function(e,t,n){var o=this.c;void 0===o.a&&(this.d--,this.i&&2===e?p(o,n):this.b[t]=this.h(n)),0===this.d&&h(o,this.b)},b.prototype.h=function(e){return e},b.prototype.q=function(e,t){var n=this;g(e,void 0,function(e){n.g(1,t,e)},function(e){n.g(2,t,e)})};var q=0;M.all=function(e,t){return new b(this,e,!0,t).c},M.race=function(e,t){function n(e){f(i,e)}function o(e){p(i,e)}var i=new this(u,t);if(!w(e))return p(i,new TypeError("You must pass an array to race.")),i;for(var r=e.length,s=0;void 0===i.a&&r>s;s++)g(this.resolve(e[s]),void 0,n,o);return i},M.resolve=function(e,t){if(e&&"object"==typeof e&&e.constructor===this)return e;var n=new this(u,t);return f(n,e),n},M.reject=function(e,t){var n=new this(u,t);return p(n,e),n},M.prototype={constructor:M,then:function(t,n){var o=this.a;if(1===o&&!t||2===o&&!n)return this;var i=new this.constructor(u),r=this.b;if(o){var s=arguments[o-1];e(function(){_(o,i,s,r)})}else g(this,i,t,n);return i},"catch":function(e){return this.then(null,e)}};var R={Promise:M,polyfill:function(){var e;e="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self,"Promise"in e&&"resolve"in e.Promise&&"reject"in e.Promise&&"all"in e.Promise&&"race"in e.Promise&&function(){var n;return new e.Promise(function(e){n=e}),t(n)}()||(e.Promise=M)}};"function"==typeof define&&define.amd?define(function(){return R}):"undefined"!=typeof module&&module.exports?module.exports=R:"undefined"!=typeof this&&(this.ES6Promise=R)}).call(this),function(){var global={};global.__CONFIG__=window.__CONFIG__,function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.EventEmitter=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){this._events={}}return t.prototype={constructor:t,on:function(e,t){var n=this._events[e]=this._events[e]||[];n.push(t)},off:function(e,t){var n=this._events[e];if(n){var o=n.indexOf(t);o>-1?n.splice(o,1):console.warn("Off: callback was not removed: "+t.toString())}else console.warn("Off: there are no listeners for event: "+e)},emit:function(e,t){var n=this._events[e];if(n){n=n.slice(0);for(var o=0;o<n.length;o++){var i=n[o];i.call(i,t)}}else console.warn("No listeners for event: "+e)}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.ConfigParser=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._config={},this._modules={},this._conditionalModules={},this._parseConfig(e)}var n=Object.prototype.hasOwnProperty;return t.prototype={constructor:t,addModule:function(e){var t=this._modules[e.name];if(t)for(var o in e)n.call(e,o)&&(t[o]=e[o]);else this._modules[e.name]=e;return this._registerConditionalModule(e),this._modules[e.name]},getConfig:function(){return this._config},getConditionalModules:function(){return this._conditionalModules},getModules:function(){return this._modules},mapModule:function(e){var t;t=Array.isArray(e)?e:[e];for(var o=0;o<t.length;o++){var i=t[o];for(var r in this._config.maps)if(n.call(this._config.maps,r)&&(i===r||0===i.indexOf(r+"/"))){i=this._config.maps[r]+i.substring(r.length),t[o]=i;break}}return Array.isArray(e)?t:t[0]},_parseConfig:function(e){for(var t in e)n.call(e,t)&&("modules"===t?this._parseModules(e[t]):this._config[t]=e[t]);return this._config},_parseModules:function(e){for(var t in e)if(n.call(e,t)){var o=e[t];o.name=t,this.addModule(o)}return this._modules},_registerConditionalModule:function(e){if(e.condition){var t=this._conditionalModules[e.condition.trigger];t||(this._conditionalModules[e.condition.trigger]=t=[]),t.push(e.name)}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.DependencyBuilder=n}("undefined"!=typeof global?global:this,function(global){"use strict";function DependencyBuilder(e){this._configParser=e,this._pathResolver=new global.PathResolver,this._result=[]}var hasOwnProperty=Object.prototype.hasOwnProperty;return DependencyBuilder.prototype={constructor:DependencyBuilder,resolveDependencies:function(e){this._queue=e.slice(0);var t;try{this._resolveDependencies(),t=this._result.reverse().slice(0)}finally{this._cleanup()}return t},_cleanup:function(){var e=this._configParser.getModules();for(var t in e)if(hasOwnProperty.call(e,t)){var n=e[t];n.conditionalMark=!1,n.mark=!1,n.tmpMark=!1}this._queue.length=0,this._result.length=0},_processConditionalModules:function(e){var t=this._configParser.getConditionalModules()[e.name];if(t&&!e.conditionalMark){for(var n=this._configParser.getModules(),o=0;o<t.length;o++){var i=n[t[o]];-1===this._queue.indexOf(i.name)&&this._testConditionalModule(i.condition.test)&&this._queue.push(i.name)}e.conditionalMark=!0}},_resolveDependencies:function(){for(var e=this._configParser.getModules(),t=0;t<this._queue.length;t++){var n=e[this._queue[t]];n||(n=this._configParser.addModule({name:this._queue[t],dependencies:[]})),n.mark||this._visit(n)}},_testConditionalModule:function(testFunction){return"function"==typeof testFunction?testFunction():eval("false || "+testFunction)()},_visit:function(e){if(e.tmpMark)throw new Error("Error processing module: "+e.name+". The provided configuration is not Directed Acyclic Graph.");if(this._processConditionalModules(e),!e.mark){e.tmpMark=!0;for(var t=this._configParser.getModules(),n=0;n<e.dependencies.length;n++){var o=e.dependencies[n];if("exports"!==o&&"module"!==o){o=this._pathResolver.resolvePath(e.name,o);var i=this._configParser.mapModule(o),r=t[i];r||(r=this._configParser.addModule({name:i,dependencies:[]})),this._visit(r)}}e.mark=!0,e.tmpMark=!1,this._result.unshift(e.name)}},_queue:[]},DependencyBuilder}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.URLBuilder=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._configParser=e}var n=/^https?:\/\/|\/\/|www\./;return t.prototype={constructor:t,build:function(e){var t=[],o=[],i=[],r=this._configParser.getConfig(),s=r.basePath,u=this._configParser.getModules();"/"!==s.charAt(s.length-1)&&(s+="/");for(var a=0;a<e.length;a++){var l=u[e[a]];if(l.fullPath)i.push(l.fullPath);else{var c=this._getModulePath(l),f=0===c.indexOf("/");n.test(c)?i.push(c):r.combine?f?t.push(c):o.push(c):i.push(r.url+(f?"":s)+c)}l.requested=!0}return o.length&&(i.push(r.url+s+o.join("&"+s)),o.length=0),t.length&&(i.push(r.url+t.join("&")),t.length=0),i},_getModulePath:function(e){var t=e.path||e.name,o=this._configParser.getConfig().paths;for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t===i||0===t.indexOf(i+"/"))&&(t=o[i]+t.substring(i.length));return n.test(t)||t.indexOf(".js")===t.length-3||(t+=".js"),t}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.PathResolver=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){}return t.prototype={constructor:t,resolvePath:function(e,t){if("exports"===t||"module"===t||0!==t.indexOf(".")&&0!==t.indexOf(".."))return t;var n=e.split("/");n.splice(-1,1);for(var o=t.split("/"),i=o.splice(-1,1),r=0;r<o.length;r++){var s=o[r];if("."!==s)if(".."===s){if(!n.length){n=n.concat(o.slice(r));break}n.splice(-1,1)}else n.push(s)}return n.push(i),n.join("/")}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.Loader=new n,e.require=e.Loader.require.bind(e.Loader),e.define=e.Loader.define.bind(e.Loader)}("undefined"!=typeof global?global:this,function(e){"use strict";function t(n){t.superclass.constructor.apply(this,arguments),this._config=n||e.__CONFIG__,this._modulesMap={}}t.prototype=Object.create(e.EventEmitter.prototype),t.prototype.constructor=t,t.superclass=e.EventEmitter.prototype;var n={define:function(e,t,n,o){var i=o||{},r=this._getConfigParser(),s=this._getPathResolver();t=t.map(function(t){return s.resolvePath(e,t)}),i.name=e,i.dependencies=t,i.pendingImplementation=n,r.addModule(i),this._modulesMap[i.name]||(this._modulesMap[i.name]=!0),this.emit("moduleRegister",e)},getConditionalModules:function(){return this._getConfigParser().getConditionalModules()},getModules:function(){return this._getConfigParser().getModules()},require:function(){var e,t,n,o,i=this,r=Array.isArray?Array.isArray(arguments[0]):"[object Array]"===Object.prototype.toString.call(arguments[0]);if(r)n=arguments[0],o="function"==typeof arguments[1]?arguments[1]:null,e="function"==typeof arguments[2]?arguments[2]:null;else for(n=[],t=0;t<arguments.length;++t)if("string"==typeof arguments[t])n[t]=arguments[t];else if("function"==typeof arguments[t]){o=arguments[t],e="function"==typeof arguments[++t]?arguments[t]:null;break}n=this._getConfigParser().mapModule(n),i._resolveDependencies(n).then(function(e){return i._loadModules(e)}).then(function(e){if(o){var t=i._getModuleImplementations(n);o.apply(o,t)}},function(t){e&&e.call(e,t)})},_createModulePromise:function(e){var t=this;return new Promise(function(n,o){var i=function(o){o===e&&(t.off("moduleRegister",i),t._modulesMap[e]=!0,n(e))};t.on("moduleRegister",i)})},_getConfigParser:function(){return this._configParser||(this._configParser=new e.ConfigParser(this._config)),this._configParser},_getDependencyBuilder:function(){return this._dependencyBuilder||(this._dependencyBuilder=new e.DependencyBuilder(this._getConfigParser())),this._dependencyBuilder},_getMissingDepenencies:function(e){for(var t=this._getConfigParser().getModules(),n=Object.create(null),o=0;o<e.length;o++)for(var i=t[e[o]],r=0;r<i.dependencies.length;r++){var s=i.dependencies[r];"exports"===s||"module"===s||s.pendingImplementation||(n[s]=1)}return Object.keys(n)},_getModuleImplementations:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];t.push(i?i.implementation:void 0)}return t},_getPathResolver:function(){return this._pathResolver||(this._pathResolver=new e.PathResolver),this._pathResolver},_getURLBuilder:function(){return this._urlBuilder||(this._urlBuilder=new e.URLBuilder(this._getConfigParser())),this._urlBuilder},_filterNotRequestedModules:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];"exports"===i||"module"===i||i&&i.requested||t.push(e[o])}return t},_loadModules:function(e){var t=this;return new Promise(function(n,o){var i=t._filterNotRequestedModules(e);if(i.length){for(var r=t._getURLBuilder().build(i),s=[],u=0;u<r.length;u++)s.push(t._loadScript(r[u]));Promise.all(s).then(function(n){return t._waitForModules(e)}).then(function(e){n(e)})["catch"](function(e){o(e)})}else t._waitForModules(e).then(function(e){n(e)})["catch"](function(e){o(e)})})},_loadScript:function(e){return new Promise(function(t,n){var o=document.createElement("script");o.src=e,o.onload=o.onreadystatechange=function(){this.readyState&&"complete"!==this.readyState&&"load"!==this.readyState||(o.onload=o.onreadystatechange=null,t(o))},o.onerror=function(){document.body.removeChild(o),n(o)},document.body.appendChild(o)})},_resolveDependencies:function(e){var t=this;return new Promise(function(n,o){try{var i=t._getDependencyBuilder().resolveDependencies(e);n(i)}catch(r){o(r)}})},_setModuleImplementation:function(e){for(var t=this._getConfigParser().getModules(),n=0;n<e.length;n++){var o=e[n];if(!o.implementation){for(var i,r=[],s=this._getConfigParser(),u=0;u<o.dependencies.length;u++){var a=o.dependencies[u];if("exports"===a)i={},r.push(i);else if("module"===a)i={exports:{}},r.push(i);else{var l=t[s.mapModule(a)],c=l.implementation;r.push(c)}}var f=o.pendingImplementation.apply(o.pendingImplementation,r);f?o.implementation=f:i&&(o.implementation=i.exports||i)}}},_waitForModule:function(e){var t=this,n=t._modulesMap[e];return n||(n=t._createModulePromise(e),t._modulesMap[e]=n),n},_waitForModules:function(e){var t=this;return new Promise(function(n,o){for(var i=[],r=0;r<e.length;r++)i.push(t._waitForModule(e[r]));Promise.all(i).then(function(i){var r=t._getConfigParser().getModules(),s=function(){for(var o=[],i=0;i<e.length;i++)o.push(r[e[i]]);t._setModuleImplementation(o),n(o)},u=t._getMissingDepenencies(e);u.length?t.require(u,s,o):s()})})}};return Object.keys(n).forEach(function(e){t.prototype[e]=n[e]}),t}),window.Loader=global.Loader,window.require=global.require,window.define=global.define}(); | ||
(function(){function e(e,t){x[C]=e,x[C+1]=t,C+=2,2===C&&P()}function t(e){return"function"==typeof e}function n(){return function(){process.nextTick(s)}}function o(){var e=0,t=new O(s),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function i(){var e=new MessageChannel;return e.port1.onmessage=s,function(){e.port2.postMessage(0)}}function r(){return function(){setTimeout(s,1)}}function s(){for(var e=0;C>e;e+=2)x[e](x[e+1]),x[e]=void 0,x[e+1]=void 0;C=0}function u(){}function a(e,t,n,o){try{e.call(t,n,o)}catch(i){return i}}function l(t,n,o){e(function(e){var t=!1,i=a(o,n,function(o){t||(t=!0,n!==o?f(e,o):h(e,o))},function(n){t||(t=!0,p(e,n))});!t&&i&&(t=!0,p(e,i))},t)}function c(e,t){1===t.a?h(e,t.b):2===e.a?p(e,t.b):g(t,void 0,function(t){f(e,t)},function(t){p(e,t)})}function f(e,n){if(e===n)p(e,new TypeError("You cannot resolve a promise with itself"));else if("function"==typeof n||"object"==typeof n&&null!==n)if(n.constructor===e.constructor)c(e,n);else{var o;try{o=n.then}catch(i){A.error=i,o=A}o===A?p(e,A.error):void 0===o?h(e,n):t(o)?l(e,n,o):h(e,n)}else h(e,n)}function d(e){e.f&&e.f(e.b),m(e)}function h(t,n){void 0===t.a&&(t.b=n,t.a=1,0!==t.e.length&&e(m,t))}function p(t,n){void 0===t.a&&(t.a=2,t.b=n,e(d,t))}function g(t,n,o,i){var r=t.e,s=r.length;t.f=null,r[s]=n,r[s+1]=o,r[s+2]=i,0===s&&t.a&&e(m,t)}function m(e){var t=e.e,n=e.a;if(0!==t.length){for(var o,i,r=e.b,s=0;s<t.length;s+=3)o=t[s],i=t[s+n],o?_(n,o,i,r):i(r);e.e.length=0}}function v(){this.error=null}function _(e,n,o,i){var r,s,u,a,l=t(o);if(l){try{r=o(i)}catch(c){k.error=c,r=k}if(r===k?(a=!0,s=r.error,r=null):u=!0,n===r)return void p(n,new TypeError("A promises callback cannot return that same promise."))}else r=i,u=!0;void 0===n.a&&(l&&u?f(n,r):a?p(n,s):1===e?h(n,r):2===e&&p(n,r))}function y(e,t){try{t(function(t){f(e,t)},function(t){p(e,t)})}catch(n){p(e,n)}}function b(e,t,n,o){this.n=e,this.c=new e(u,o),this.i=n,this.o(t)?(this.m=t,this.d=this.length=t.length,this.l(),0===this.length?h(this.c,this.b):(this.length=this.length||0,this.k(),0===this.d&&h(this.c,this.b))):p(this.c,this.p())}function M(e){if(q++,this.b=this.a=void 0,this.e=[],u!==e){if(!t(e))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof M))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");y(this,e)}}var P,w=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},C=0,j="undefined"!=typeof window?window:{},O=j.MutationObserver||j.WebKitMutationObserver,j="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,x=Array(1e3);P="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?n():O?o():j?i():r();var A=new v,k=new v;b.prototype.o=function(e){return w(e)},b.prototype.p=function(){return Error("Array Methods must be provided an Array")},b.prototype.l=function(){this.b=Array(this.length)},b.prototype.k=function(){for(var e=this.length,t=this.c,n=this.m,o=0;void 0===t.a&&e>o;o++)this.j(n[o],o)},b.prototype.j=function(e,t){var n=this.n;"object"==typeof e&&null!==e?e.constructor===n&&void 0!==e.a?(e.f=null,this.g(e.a,t,e.b)):this.q(n.resolve(e),t):(this.d--,this.b[t]=this.h(e))},b.prototype.g=function(e,t,n){var o=this.c;void 0===o.a&&(this.d--,this.i&&2===e?p(o,n):this.b[t]=this.h(n)),0===this.d&&h(o,this.b)},b.prototype.h=function(e){return e},b.prototype.q=function(e,t){var n=this;g(e,void 0,function(e){n.g(1,t,e)},function(e){n.g(2,t,e)})};var q=0;M.all=function(e,t){return new b(this,e,!0,t).c},M.race=function(e,t){function n(e){f(i,e)}function o(e){p(i,e)}var i=new this(u,t);if(!w(e))return p(i,new TypeError("You must pass an array to race.")),i;for(var r=e.length,s=0;void 0===i.a&&r>s;s++)g(this.resolve(e[s]),void 0,n,o);return i},M.resolve=function(e,t){if(e&&"object"==typeof e&&e.constructor===this)return e;var n=new this(u,t);return f(n,e),n},M.reject=function(e,t){var n=new this(u,t);return p(n,e),n},M.prototype={constructor:M,then:function(t,n){var o=this.a;if(1===o&&!t||2===o&&!n)return this;var i=new this.constructor(u),r=this.b;if(o){var s=arguments[o-1];e(function(){_(o,i,s,r)})}else g(this,i,t,n);return i},"catch":function(e){return this.then(null,e)}};var R={Promise:M,polyfill:function(){var e;e="undefined"!=typeof global?global:"undefined"!=typeof window&&window.document?window:self,"Promise"in e&&"resolve"in e.Promise&&"reject"in e.Promise&&"all"in e.Promise&&"race"in e.Promise&&function(){var n;return new e.Promise(function(e){n=e}),t(n)}()||(e.Promise=M)}};"function"==typeof define&&define.amd?define(function(){return R}):"undefined"!=typeof module&&module.exports?module.exports=R:"undefined"!=typeof this&&(this.ES6Promise=R)}).call(this),function(){var global={};global.__CONFIG__=window.__CONFIG__,function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.EventEmitter=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){this._events={}}return t.prototype={constructor:t,on:function(e,t){var n=this._events[e]=this._events[e]||[];n.push(t)},off:function(e,t){var n=this._events[e];if(n){var o=n.indexOf(t);o>-1&&n.splice(o,1)}},emit:function(e,t){var n=this._events[e];if(n){n=n.slice(0);for(var o=0;o<n.length;o++){var i=n[o];i.call(i,t)}}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.ConfigParser=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._config={},this._modules={},this._conditionalModules={},this._parseConfig(e)}return t.prototype={constructor:t,addModule:function(e){var t=this._modules[e.name];if(t)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);else this._modules[e.name]=e;return this._registerConditionalModule(e),this._modules[e.name]},getConfig:function(){return this._config},getConditionalModules:function(){return this._conditionalModules},getModules:function(){return this._modules},mapModule:function(e){var t;t=Array.isArray(e)?e:[e];for(var n=0;n<t.length;n++){var o=t[n];for(var i in this._config.maps)if(Object.prototype.hasOwnProperty.call(this._config.maps,i)&&(o===i||0===o.indexOf(i+"/"))){o=this._config.maps[i]+o.substring(i.length),t[n]=o;break}}return Array.isArray(e)?t:t[0]},_parseConfig:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&("modules"===t?this._parseModules(e[t]):this._config[t]=e[t]);return this._config},_parseModules:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];n.name=t,this.addModule(n)}return this._modules},_registerConditionalModule:function(e){if(e.condition){var t=this._conditionalModules[e.condition.trigger];t||(this._conditionalModules[e.condition.trigger]=t=[]),t.push(e.name)}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.DependencyBuilder=n}("undefined"!=typeof global?global:this,function(global){"use strict";function DependencyBuilder(e){this._configParser=e,this._pathResolver=new global.PathResolver,this._result=[]}var hasOwnProperty=Object.prototype.hasOwnProperty;return DependencyBuilder.prototype={constructor:DependencyBuilder,resolveDependencies:function(e){this._queue=e.slice(0);var t;try{this._resolveDependencies(),t=this._result.reverse().slice(0)}finally{this._cleanup()}return t},_cleanup:function(){var e=this._configParser.getModules();for(var t in e)if(hasOwnProperty.call(e,t)){var n=e[t];n.conditionalMark=!1,n.mark=!1,n.tmpMark=!1}this._queue.length=0,this._result.length=0},_processConditionalModules:function(e){var t=this._configParser.getConditionalModules()[e.name];if(t&&!e.conditionalMark){for(var n=this._configParser.getModules(),o=0;o<t.length;o++){var i=n[t[o]];-1===this._queue.indexOf(i.name)&&this._testConditionalModule(i.condition.test)&&this._queue.push(i.name)}e.conditionalMark=!0}},_resolveDependencies:function(){for(var e=this._configParser.getModules(),t=0;t<this._queue.length;t++){var n=e[this._queue[t]];n||(n=this._configParser.addModule({name:this._queue[t],dependencies:[]})),n.mark||this._visit(n)}},_testConditionalModule:function(testFunction){return"function"==typeof testFunction?testFunction():eval("false || "+testFunction)()},_visit:function(e){if(e.tmpMark)throw new Error("Error processing module: "+e.name+". The provided configuration is not Directed Acyclic Graph.");if(this._processConditionalModules(e),!e.mark){e.tmpMark=!0;for(var t=this._configParser.getModules(),n=0;n<e.dependencies.length;n++){var o=e.dependencies[n];if("exports"!==o&&"module"!==o){o=this._pathResolver.resolvePath(e.name,o);var i=this._configParser.mapModule(o),r=t[i];r||(r=this._configParser.addModule({name:i,dependencies:[]})),this._visit(r)}}e.mark=!0,e.tmpMark=!1,this._result.unshift(e.name)}},_queue:[]},DependencyBuilder}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.URLBuilder=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._configParser=e}var n=/^https?:\/\/|\/\/|www\./;return t.prototype={constructor:t,build:function(e){var t=[],o=[],i=[],r=this._configParser.getConfig(),s=r.basePath,u=this._configParser.getModules();"/"!==s.charAt(s.length-1)&&(s+="/");for(var a=0;a<e.length;a++){var l=u[e[a]];if(l.fullPath)i.push(l.fullPath);else{var c=this._getModulePath(l),f=0===c.indexOf("/");n.test(c)?i.push(c):r.combine?f?t.push(c):o.push(c):i.push(r.url+(f?"":s)+c)}l.requested=!0}return o.length&&(i.push(r.url+s+o.join("&"+s)),o.length=0),t.length&&(i.push(r.url+t.join("&")),t.length=0),i},_getModulePath:function(e){var t=e.path||e.name,o=this._configParser.getConfig().paths;for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t===i||0===t.indexOf(i+"/"))&&(t=o[i]+t.substring(i.length));return n.test(t)||t.indexOf(".js")===t.length-3||(t+=".js"),t}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.PathResolver=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){}return t.prototype={constructor:t,resolvePath:function(e,t){if("exports"===t||"module"===t||0!==t.indexOf(".")&&0!==t.indexOf(".."))return t;var n=e.split("/");n.splice(-1,1);for(var o=t.split("/"),i=o.splice(-1,1),r=0;r<o.length;r++){var s=o[r];if("."!==s)if(".."===s){if(!n.length){n=n.concat(o.slice(r));break}n.splice(-1,1)}else n.push(s)}return n.push(i),n.join("/")}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.Loader=new n,e.require=e.Loader.require.bind(e.Loader),e.define=e.Loader.define.bind(e.Loader)}("undefined"!=typeof global?global:this,function(e){"use strict";function t(n){t.superclass.constructor.apply(this,arguments),this._config=n||e.__CONFIG__,this._modulesMap={}}t.prototype=Object.create(e.EventEmitter.prototype),t.prototype.constructor=t,t.superclass=e.EventEmitter.prototype;var n={define:function(e,t,n,o){var i=o||{},r=this._getConfigParser(),s=this._getPathResolver();t=t.map(function(t){return s.resolvePath(e,t)}),i.name=e,i.dependencies=t,i.pendingImplementation=n,r.addModule(i),this._modulesMap[i.name]||(this._modulesMap[i.name]=!0),this.emit("moduleRegister",e)},getConditionalModules:function(){return this._getConfigParser().getConditionalModules()},getModules:function(){return this._getConfigParser().getModules()},require:function(){var e,t,n,o,i=this,r=Array.isArray?Array.isArray(arguments[0]):"[object Array]"===Object.prototype.toString.call(arguments[0]);if(r)n=arguments[0],o="function"==typeof arguments[1]?arguments[1]:null,e="function"==typeof arguments[2]?arguments[2]:null;else for(n=[],t=0;t<arguments.length;++t)if("string"==typeof arguments[t])n[t]=arguments[t];else if("function"==typeof arguments[t]){o=arguments[t],e="function"==typeof arguments[++t]?arguments[t]:null;break}n=this._getConfigParser().mapModule(n),i._resolveDependencies(n).then(function(e){return i._loadModules(e)}).then(function(e){if(o){var t=i._getModuleImplementations(n);o.apply(o,t)}},function(t){e&&e.call(e,t)})},_createModulePromise:function(e){var t=this;return new Promise(function(n,o){var i=function(o){o===e&&(t.off("moduleRegister",i),t._modulesMap[e]=!0,n(e))};t.on("moduleRegister",i)})},_getConfigParser:function(){return this._configParser||(this._configParser=new e.ConfigParser(this._config)),this._configParser},_getDependencyBuilder:function(){return this._dependencyBuilder||(this._dependencyBuilder=new e.DependencyBuilder(this._getConfigParser())),this._dependencyBuilder},_getMissingDepenencies:function(e){for(var t=this._getConfigParser().getModules(),n=Object.create(null),o=0;o<e.length;o++)for(var i=t[e[o]],r=0;r<i.dependencies.length;r++){var s=i.dependencies[r],u=t[s];"exports"===s||"module"===s||u&&u.pendingImplementation||(n[s]=1)}return Object.keys(n)},_getModuleImplementations:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];t.push(i?i.implementation:void 0)}return t},_getPathResolver:function(){return this._pathResolver||(this._pathResolver=new e.PathResolver),this._pathResolver},_getURLBuilder:function(){return this._urlBuilder||(this._urlBuilder=new e.URLBuilder(this._getConfigParser())),this._urlBuilder},_filterNotRequestedModules:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];"exports"===i||"module"===i||i&&i.requested||t.push(e[o])}return t},_loadModules:function(e){var t=this;return new Promise(function(n,o){var i=t._filterNotRequestedModules(e);if(i.length){for(var r=t._getURLBuilder().build(i),s=[],u=0;u<r.length;u++)s.push(t._loadScript(r[u]));Promise.all(s).then(function(n){return t._waitForModules(e)}).then(function(e){n(e)})["catch"](function(e){o(e)})}else t._waitForModules(e).then(function(e){n(e)})["catch"](function(e){o(e)})})},_loadScript:function(e){return new Promise(function(t,n){var o=document.createElement("script");o.src=e,o.onload=o.onreadystatechange=function(){this.readyState&&"complete"!==this.readyState&&"load"!==this.readyState||(o.onload=o.onreadystatechange=null,t(o))},o.onerror=function(){document.body.removeChild(o),n(o)},document.body.appendChild(o)})},_resolveDependencies:function(e){var t=this;return new Promise(function(n,o){try{var i=t._getDependencyBuilder().resolveDependencies(e);n(i)}catch(r){o(r)}})},_setModuleImplementation:function(e){for(var t=this._getConfigParser().getModules(),n=0;n<e.length;n++){var o=e[n];if(!o.implementation){for(var i,r=[],s=this._getConfigParser(),u=0;u<o.dependencies.length;u++){var a=o.dependencies[u];if("exports"===a)i={},r.push(i);else if("module"===a)i={exports:{}},r.push(i);else{var l=t[s.mapModule(a)],c=l.implementation;r.push(c)}}var f=o.pendingImplementation.apply(o.pendingImplementation,r);f?o.implementation=f:i&&(o.implementation=i.exports||i)}}},_waitForModule:function(e){var t=this,n=t._modulesMap[e];return n||(n=t._createModulePromise(e),t._modulesMap[e]=n),n},_waitForModules:function(e){var t=this;return new Promise(function(n,o){for(var i=[],r=0;r<e.length;r++)i.push(t._waitForModule(e[r]));Promise.all(i).then(function(i){var r=t._getConfigParser().getModules(),s=function(){for(var o=[],i=0;i<e.length;i++)o.push(r[e[i]]);t._setModuleImplementation(o),n(o)},u=t._getMissingDepenencies(e);u.length?t.require(u,s,o):s()})})}};return Object.keys(n).forEach(function(e){t.prototype[e]=n[e]}),t}),window.Loader=global.Loader,window.require=global.require,window.define=global.define}(); |
@@ -1,1 +0,1 @@ | ||
!function(){var global={};global.__CONFIG__=window.__CONFIG__,function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.EventEmitter=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){this._events={}}return t.prototype={constructor:t,on:function(e,t){var n=this._events[e]=this._events[e]||[];n.push(t)},off:function(e,t){var n=this._events[e];if(n){var o=n.indexOf(t);o>-1?n.splice(o,1):console.warn("Off: callback was not removed: "+t.toString())}else console.warn("Off: there are no listeners for event: "+e)},emit:function(e,t){var n=this._events[e];if(n){n=n.slice(0);for(var o=0;o<n.length;o++){var i=n[o];i.call(i,t)}}else console.warn("No listeners for event: "+e)}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.ConfigParser=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._config={},this._modules={},this._conditionalModules={},this._parseConfig(e)}var n=Object.prototype.hasOwnProperty;return t.prototype={constructor:t,addModule:function(e){var t=this._modules[e.name];if(t)for(var o in e)n.call(e,o)&&(t[o]=e[o]);else this._modules[e.name]=e;return this._registerConditionalModule(e),this._modules[e.name]},getConfig:function(){return this._config},getConditionalModules:function(){return this._conditionalModules},getModules:function(){return this._modules},mapModule:function(e){var t;t=Array.isArray(e)?e:[e];for(var o=0;o<t.length;o++){var i=t[o];for(var r in this._config.maps)if(n.call(this._config.maps,r)&&(i===r||0===i.indexOf(r+"/"))){i=this._config.maps[r]+i.substring(r.length),t[o]=i;break}}return Array.isArray(e)?t:t[0]},_parseConfig:function(e){for(var t in e)n.call(e,t)&&("modules"===t?this._parseModules(e[t]):this._config[t]=e[t]);return this._config},_parseModules:function(e){for(var t in e)if(n.call(e,t)){var o=e[t];o.name=t,this.addModule(o)}return this._modules},_registerConditionalModule:function(e){if(e.condition){var t=this._conditionalModules[e.condition.trigger];t||(this._conditionalModules[e.condition.trigger]=t=[]),t.push(e.name)}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.DependencyBuilder=n}("undefined"!=typeof global?global:this,function(global){"use strict";function DependencyBuilder(e){this._configParser=e,this._pathResolver=new global.PathResolver,this._result=[]}var hasOwnProperty=Object.prototype.hasOwnProperty;return DependencyBuilder.prototype={constructor:DependencyBuilder,resolveDependencies:function(e){this._queue=e.slice(0);var t;try{this._resolveDependencies(),t=this._result.reverse().slice(0)}finally{this._cleanup()}return t},_cleanup:function(){var e=this._configParser.getModules();for(var t in e)if(hasOwnProperty.call(e,t)){var n=e[t];n.conditionalMark=!1,n.mark=!1,n.tmpMark=!1}this._queue.length=0,this._result.length=0},_processConditionalModules:function(e){var t=this._configParser.getConditionalModules()[e.name];if(t&&!e.conditionalMark){for(var n=this._configParser.getModules(),o=0;o<t.length;o++){var i=n[t[o]];-1===this._queue.indexOf(i.name)&&this._testConditionalModule(i.condition.test)&&this._queue.push(i.name)}e.conditionalMark=!0}},_resolveDependencies:function(){for(var e=this._configParser.getModules(),t=0;t<this._queue.length;t++){var n=e[this._queue[t]];n||(n=this._configParser.addModule({name:this._queue[t],dependencies:[]})),n.mark||this._visit(n)}},_testConditionalModule:function(testFunction){return"function"==typeof testFunction?testFunction():eval("false || "+testFunction)()},_visit:function(e){if(e.tmpMark)throw new Error("Error processing module: "+e.name+". The provided configuration is not Directed Acyclic Graph.");if(this._processConditionalModules(e),!e.mark){e.tmpMark=!0;for(var t=this._configParser.getModules(),n=0;n<e.dependencies.length;n++){var o=e.dependencies[n];if("exports"!==o&&"module"!==o){o=this._pathResolver.resolvePath(e.name,o);var i=this._configParser.mapModule(o),r=t[i];r||(r=this._configParser.addModule({name:i,dependencies:[]})),this._visit(r)}}e.mark=!0,e.tmpMark=!1,this._result.unshift(e.name)}},_queue:[]},DependencyBuilder}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.URLBuilder=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._configParser=e}var n=/^https?:\/\/|\/\/|www\./;return t.prototype={constructor:t,build:function(e){var t=[],o=[],i=[],r=this._configParser.getConfig(),s=r.basePath,u=this._configParser.getModules();"/"!==s.charAt(s.length-1)&&(s+="/");for(var a=0;a<e.length;a++){var l=u[e[a]];if(l.fullPath)i.push(l.fullPath);else{var d=this._getModulePath(l),f=0===d.indexOf("/");n.test(d)?i.push(d):r.combine?f?t.push(d):o.push(d):i.push(r.url+(f?"":s)+d)}l.requested=!0}return o.length&&(i.push(r.url+s+o.join("&"+s)),o.length=0),t.length&&(i.push(r.url+t.join("&")),t.length=0),i},_getModulePath:function(e){var t=e.path||e.name,o=this._configParser.getConfig().paths;for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t===i||0===t.indexOf(i+"/"))&&(t=o[i]+t.substring(i.length));return n.test(t)||t.indexOf(".js")===t.length-3||(t+=".js"),t}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.PathResolver=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){}return t.prototype={constructor:t,resolvePath:function(e,t){if("exports"===t||"module"===t||0!==t.indexOf(".")&&0!==t.indexOf(".."))return t;var n=e.split("/");n.splice(-1,1);for(var o=t.split("/"),i=o.splice(-1,1),r=0;r<o.length;r++){var s=o[r];if("."!==s)if(".."===s){if(!n.length){n=n.concat(o.slice(r));break}n.splice(-1,1)}else n.push(s)}return n.push(i),n.join("/")}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.Loader=new n,e.require=e.Loader.require.bind(e.Loader),e.define=e.Loader.define.bind(e.Loader)}("undefined"!=typeof global?global:this,function(e){"use strict";function t(n){t.superclass.constructor.apply(this,arguments),this._config=n||e.__CONFIG__,this._modulesMap={}}t.prototype=Object.create(e.EventEmitter.prototype),t.prototype.constructor=t,t.superclass=e.EventEmitter.prototype;var n={define:function(e,t,n,o){var i=o||{},r=this._getConfigParser(),s=this._getPathResolver();t=t.map(function(t){return s.resolvePath(e,t)}),i.name=e,i.dependencies=t,i.pendingImplementation=n,r.addModule(i),this._modulesMap[i.name]||(this._modulesMap[i.name]=!0),this.emit("moduleRegister",e)},getConditionalModules:function(){return this._getConfigParser().getConditionalModules()},getModules:function(){return this._getConfigParser().getModules()},require:function(){var e,t,n,o,i=this,r=Array.isArray?Array.isArray(arguments[0]):"[object Array]"===Object.prototype.toString.call(arguments[0]);if(r)n=arguments[0],o="function"==typeof arguments[1]?arguments[1]:null,e="function"==typeof arguments[2]?arguments[2]:null;else for(n=[],t=0;t<arguments.length;++t)if("string"==typeof arguments[t])n[t]=arguments[t];else if("function"==typeof arguments[t]){o=arguments[t],e="function"==typeof arguments[++t]?arguments[t]:null;break}n=this._getConfigParser().mapModule(n),i._resolveDependencies(n).then(function(e){return i._loadModules(e)}).then(function(e){if(o){var t=i._getModuleImplementations(n);o.apply(o,t)}},function(t){e&&e.call(e,t)})},_createModulePromise:function(e){var t=this;return new Promise(function(n,o){var i=function(o){o===e&&(t.off("moduleRegister",i),t._modulesMap[e]=!0,n(e))};t.on("moduleRegister",i)})},_getConfigParser:function(){return this._configParser||(this._configParser=new e.ConfigParser(this._config)),this._configParser},_getDependencyBuilder:function(){return this._dependencyBuilder||(this._dependencyBuilder=new e.DependencyBuilder(this._getConfigParser())),this._dependencyBuilder},_getMissingDepenencies:function(e){for(var t=this._getConfigParser().getModules(),n=Object.create(null),o=0;o<e.length;o++)for(var i=t[e[o]],r=0;r<i.dependencies.length;r++){var s=i.dependencies[r];"exports"===s||"module"===s||s.pendingImplementation||(n[s]=1)}return Object.keys(n)},_getModuleImplementations:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];t.push(i?i.implementation:void 0)}return t},_getPathResolver:function(){return this._pathResolver||(this._pathResolver=new e.PathResolver),this._pathResolver},_getURLBuilder:function(){return this._urlBuilder||(this._urlBuilder=new e.URLBuilder(this._getConfigParser())),this._urlBuilder},_filterNotRequestedModules:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];"exports"===i||"module"===i||i&&i.requested||t.push(e[o])}return t},_loadModules:function(e){var t=this;return new Promise(function(n,o){var i=t._filterNotRequestedModules(e);if(i.length){for(var r=t._getURLBuilder().build(i),s=[],u=0;u<r.length;u++)s.push(t._loadScript(r[u]));Promise.all(s).then(function(n){return t._waitForModules(e)}).then(function(e){n(e)})["catch"](function(e){o(e)})}else t._waitForModules(e).then(function(e){n(e)})["catch"](function(e){o(e)})})},_loadScript:function(e){return new Promise(function(t,n){var o=document.createElement("script");o.src=e,o.onload=o.onreadystatechange=function(){this.readyState&&"complete"!==this.readyState&&"load"!==this.readyState||(o.onload=o.onreadystatechange=null,t(o))},o.onerror=function(){document.body.removeChild(o),n(o)},document.body.appendChild(o)})},_resolveDependencies:function(e){var t=this;return new Promise(function(n,o){try{var i=t._getDependencyBuilder().resolveDependencies(e);n(i)}catch(r){o(r)}})},_setModuleImplementation:function(e){for(var t=this._getConfigParser().getModules(),n=0;n<e.length;n++){var o=e[n];if(!o.implementation){for(var i,r=[],s=this._getConfigParser(),u=0;u<o.dependencies.length;u++){var a=o.dependencies[u];if("exports"===a)i={},r.push(i);else if("module"===a)i={exports:{}},r.push(i);else{var l=t[s.mapModule(a)],d=l.implementation;r.push(d)}}var f=o.pendingImplementation.apply(o.pendingImplementation,r);f?o.implementation=f:i&&(o.implementation=i.exports||i)}}},_waitForModule:function(e){var t=this,n=t._modulesMap[e];return n||(n=t._createModulePromise(e),t._modulesMap[e]=n),n},_waitForModules:function(e){var t=this;return new Promise(function(n,o){for(var i=[],r=0;r<e.length;r++)i.push(t._waitForModule(e[r]));Promise.all(i).then(function(i){var r=t._getConfigParser().getModules(),s=function(){for(var o=[],i=0;i<e.length;i++)o.push(r[e[i]]);t._setModuleImplementation(o),n(o)},u=t._getMissingDepenencies(e);u.length?t.require(u,s,o):s()})})}};return Object.keys(n).forEach(function(e){t.prototype[e]=n[e]}),t}),window.Loader=global.Loader,window.require=global.require,window.define=global.define}(); | ||
!function(){var global={};global.__CONFIG__=window.__CONFIG__,function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.EventEmitter=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){this._events={}}return t.prototype={constructor:t,on:function(e,t){var n=this._events[e]=this._events[e]||[];n.push(t)},off:function(e,t){var n=this._events[e];if(n){var o=n.indexOf(t);o>-1&&n.splice(o,1)}},emit:function(e,t){var n=this._events[e];if(n){n=n.slice(0);for(var o=0;o<n.length;o++){var i=n[o];i.call(i,t)}}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.ConfigParser=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._config={},this._modules={},this._conditionalModules={},this._parseConfig(e)}return t.prototype={constructor:t,addModule:function(e){var t=this._modules[e.name];if(t)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);else this._modules[e.name]=e;return this._registerConditionalModule(e),this._modules[e.name]},getConfig:function(){return this._config},getConditionalModules:function(){return this._conditionalModules},getModules:function(){return this._modules},mapModule:function(e){var t;t=Array.isArray(e)?e:[e];for(var n=0;n<t.length;n++){var o=t[n];for(var i in this._config.maps)if(Object.prototype.hasOwnProperty.call(this._config.maps,i)&&(o===i||0===o.indexOf(i+"/"))){o=this._config.maps[i]+o.substring(i.length),t[n]=o;break}}return Array.isArray(e)?t:t[0]},_parseConfig:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&("modules"===t?this._parseModules(e[t]):this._config[t]=e[t]);return this._config},_parseModules:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];n.name=t,this.addModule(n)}return this._modules},_registerConditionalModule:function(e){if(e.condition){var t=this._conditionalModules[e.condition.trigger];t||(this._conditionalModules[e.condition.trigger]=t=[]),t.push(e.name)}}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.DependencyBuilder=n}("undefined"!=typeof global?global:this,function(global){"use strict";function DependencyBuilder(e){this._configParser=e,this._pathResolver=new global.PathResolver,this._result=[]}var hasOwnProperty=Object.prototype.hasOwnProperty;return DependencyBuilder.prototype={constructor:DependencyBuilder,resolveDependencies:function(e){this._queue=e.slice(0);var t;try{this._resolveDependencies(),t=this._result.reverse().slice(0)}finally{this._cleanup()}return t},_cleanup:function(){var e=this._configParser.getModules();for(var t in e)if(hasOwnProperty.call(e,t)){var n=e[t];n.conditionalMark=!1,n.mark=!1,n.tmpMark=!1}this._queue.length=0,this._result.length=0},_processConditionalModules:function(e){var t=this._configParser.getConditionalModules()[e.name];if(t&&!e.conditionalMark){for(var n=this._configParser.getModules(),o=0;o<t.length;o++){var i=n[t[o]];-1===this._queue.indexOf(i.name)&&this._testConditionalModule(i.condition.test)&&this._queue.push(i.name)}e.conditionalMark=!0}},_resolveDependencies:function(){for(var e=this._configParser.getModules(),t=0;t<this._queue.length;t++){var n=e[this._queue[t]];n||(n=this._configParser.addModule({name:this._queue[t],dependencies:[]})),n.mark||this._visit(n)}},_testConditionalModule:function(testFunction){return"function"==typeof testFunction?testFunction():eval("false || "+testFunction)()},_visit:function(e){if(e.tmpMark)throw new Error("Error processing module: "+e.name+". The provided configuration is not Directed Acyclic Graph.");if(this._processConditionalModules(e),!e.mark){e.tmpMark=!0;for(var t=this._configParser.getModules(),n=0;n<e.dependencies.length;n++){var o=e.dependencies[n];if("exports"!==o&&"module"!==o){o=this._pathResolver.resolvePath(e.name,o);var i=this._configParser.mapModule(o),r=t[i];r||(r=this._configParser.addModule({name:i,dependencies:[]})),this._visit(r)}}e.mark=!0,e.tmpMark=!1,this._result.unshift(e.name)}},_queue:[]},DependencyBuilder}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.URLBuilder=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(e){this._configParser=e}var n=/^https?:\/\/|\/\/|www\./;return t.prototype={constructor:t,build:function(e){var t=[],o=[],i=[],r=this._configParser.getConfig(),s=r.basePath,u=this._configParser.getModules();"/"!==s.charAt(s.length-1)&&(s+="/");for(var a=0;a<e.length;a++){var l=u[e[a]];if(l.fullPath)i.push(l.fullPath);else{var d=this._getModulePath(l),c=0===d.indexOf("/");n.test(d)?i.push(d):r.combine?c?t.push(d):o.push(d):i.push(r.url+(c?"":s)+d)}l.requested=!0}return o.length&&(i.push(r.url+s+o.join("&"+s)),o.length=0),t.length&&(i.push(r.url+t.join("&")),t.length=0),i},_getModulePath:function(e){var t=e.path||e.name,o=this._configParser.getConfig().paths;for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t===i||0===t.indexOf(i+"/"))&&(t=o[i]+t.substring(i.length));return n.test(t)||t.indexOf(".js")===t.length-3||(t+=".js"),t}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.PathResolver=n}("undefined"!=typeof global?global:this,function(e){"use strict";function t(){}return t.prototype={constructor:t,resolvePath:function(e,t){if("exports"===t||"module"===t||0!==t.indexOf(".")&&0!==t.indexOf(".."))return t;var n=e.split("/");n.splice(-1,1);for(var o=t.split("/"),i=o.splice(-1,1),r=0;r<o.length;r++){var s=o[r];if("."!==s)if(".."===s){if(!n.length){n=n.concat(o.slice(r));break}n.splice(-1,1)}else n.push(s)}return n.push(i),n.join("/")}},t}),function(e,t){"use strict";var n=t(e);"object"==typeof module&&module&&(module.exports=n),"function"==typeof define&&define.amd&&define(t),e.Loader=new n,e.require=e.Loader.require.bind(e.Loader),e.define=e.Loader.define.bind(e.Loader)}("undefined"!=typeof global?global:this,function(e){"use strict";function t(n){t.superclass.constructor.apply(this,arguments),this._config=n||e.__CONFIG__,this._modulesMap={}}t.prototype=Object.create(e.EventEmitter.prototype),t.prototype.constructor=t,t.superclass=e.EventEmitter.prototype;var n={define:function(e,t,n,o){var i=o||{},r=this._getConfigParser(),s=this._getPathResolver();t=t.map(function(t){return s.resolvePath(e,t)}),i.name=e,i.dependencies=t,i.pendingImplementation=n,r.addModule(i),this._modulesMap[i.name]||(this._modulesMap[i.name]=!0),this.emit("moduleRegister",e)},getConditionalModules:function(){return this._getConfigParser().getConditionalModules()},getModules:function(){return this._getConfigParser().getModules()},require:function(){var e,t,n,o,i=this,r=Array.isArray?Array.isArray(arguments[0]):"[object Array]"===Object.prototype.toString.call(arguments[0]);if(r)n=arguments[0],o="function"==typeof arguments[1]?arguments[1]:null,e="function"==typeof arguments[2]?arguments[2]:null;else for(n=[],t=0;t<arguments.length;++t)if("string"==typeof arguments[t])n[t]=arguments[t];else if("function"==typeof arguments[t]){o=arguments[t],e="function"==typeof arguments[++t]?arguments[t]:null;break}n=this._getConfigParser().mapModule(n),i._resolveDependencies(n).then(function(e){return i._loadModules(e)}).then(function(e){if(o){var t=i._getModuleImplementations(n);o.apply(o,t)}},function(t){e&&e.call(e,t)})},_createModulePromise:function(e){var t=this;return new Promise(function(n,o){var i=function(o){o===e&&(t.off("moduleRegister",i),t._modulesMap[e]=!0,n(e))};t.on("moduleRegister",i)})},_getConfigParser:function(){return this._configParser||(this._configParser=new e.ConfigParser(this._config)),this._configParser},_getDependencyBuilder:function(){return this._dependencyBuilder||(this._dependencyBuilder=new e.DependencyBuilder(this._getConfigParser())),this._dependencyBuilder},_getMissingDepenencies:function(e){for(var t=this._getConfigParser().getModules(),n=Object.create(null),o=0;o<e.length;o++)for(var i=t[e[o]],r=0;r<i.dependencies.length;r++){var s=i.dependencies[r],u=t[s];"exports"===s||"module"===s||u&&u.pendingImplementation||(n[s]=1)}return Object.keys(n)},_getModuleImplementations:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];t.push(i?i.implementation:void 0)}return t},_getPathResolver:function(){return this._pathResolver||(this._pathResolver=new e.PathResolver),this._pathResolver},_getURLBuilder:function(){return this._urlBuilder||(this._urlBuilder=new e.URLBuilder(this._getConfigParser())),this._urlBuilder},_filterNotRequestedModules:function(e){for(var t=[],n=this._getConfigParser().getModules(),o=0;o<e.length;o++){var i=n[e[o]];"exports"===i||"module"===i||i&&i.requested||t.push(e[o])}return t},_loadModules:function(e){var t=this;return new Promise(function(n,o){var i=t._filterNotRequestedModules(e);if(i.length){for(var r=t._getURLBuilder().build(i),s=[],u=0;u<r.length;u++)s.push(t._loadScript(r[u]));Promise.all(s).then(function(n){return t._waitForModules(e)}).then(function(e){n(e)})["catch"](function(e){o(e)})}else t._waitForModules(e).then(function(e){n(e)})["catch"](function(e){o(e)})})},_loadScript:function(e){return new Promise(function(t,n){var o=document.createElement("script");o.src=e,o.onload=o.onreadystatechange=function(){this.readyState&&"complete"!==this.readyState&&"load"!==this.readyState||(o.onload=o.onreadystatechange=null,t(o))},o.onerror=function(){document.body.removeChild(o),n(o)},document.body.appendChild(o)})},_resolveDependencies:function(e){var t=this;return new Promise(function(n,o){try{var i=t._getDependencyBuilder().resolveDependencies(e);n(i)}catch(r){o(r)}})},_setModuleImplementation:function(e){for(var t=this._getConfigParser().getModules(),n=0;n<e.length;n++){var o=e[n];if(!o.implementation){for(var i,r=[],s=this._getConfigParser(),u=0;u<o.dependencies.length;u++){var a=o.dependencies[u];if("exports"===a)i={},r.push(i);else if("module"===a)i={exports:{}},r.push(i);else{var l=t[s.mapModule(a)],d=l.implementation;r.push(d)}}var c=o.pendingImplementation.apply(o.pendingImplementation,r);c?o.implementation=c:i&&(o.implementation=i.exports||i)}}},_waitForModule:function(e){var t=this,n=t._modulesMap[e];return n||(n=t._createModulePromise(e),t._modulesMap[e]=n),n},_waitForModules:function(e){var t=this;return new Promise(function(n,o){for(var i=[],r=0;r<e.length;r++)i.push(t._waitForModule(e[r]));Promise.all(i).then(function(i){var r=t._getConfigParser().getModules(),s=function(){for(var o=[],i=0;i<e.length;i++)o.push(r[e[i]]);t._setModuleImplementation(o),n(o)},u=t._getMissingDepenencies(e);u.length?t.require(u,s,o):s()})})}};return Object.keys(n).forEach(function(e){t.prototype[e]=n[e]}),t}),window.Loader=global.Loader,window.require=global.require,window.define=global.define}(); |
@@ -66,6 +66,6 @@ (function() { | ||
} else { | ||
console.warn('Off: callback was not removed: ' + callback.toString()); | ||
void 0; | ||
} | ||
} else { | ||
console.warn('Off: there are no listeners for event: ' + event); | ||
void 0; | ||
} | ||
@@ -97,3 +97,3 @@ }, | ||
} else { | ||
console.warn('No listeners for event: ' + event); | ||
void 0; | ||
} | ||
@@ -125,4 +125,2 @@ } | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
@@ -170,3 +168,3 @@ * Creates an instance of ConfigurationParser class. | ||
for (var key in module) { | ||
if (hasOwnProperty.call(module, key)) { | ||
if (Object.prototype.hasOwnProperty.call(module, key)) { | ||
moduleDefinition[key] = module[key]; | ||
@@ -240,3 +238,3 @@ } | ||
/* istanbul ignore else */ | ||
if (hasOwnProperty.call(this._config.maps, alias)) { | ||
if (Object.prototype.hasOwnProperty.call(this._config.maps, alias)) { | ||
if (tmpModule === alias || tmpModule.indexOf(alias + '/') === 0) { | ||
@@ -264,3 +262,3 @@ tmpModule = this._config.maps[alias] + tmpModule.substring(alias.length); | ||
for (var key in config) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(config, key)) { | ||
if (Object.prototype.hasOwnProperty.call(config, key)) { | ||
if (key === 'modules') { | ||
@@ -286,3 +284,3 @@ this._parseModules(config[key]); | ||
for (var key in modules) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(modules, key)) { | ||
if (Object.prototype.hasOwnProperty.call(modules, key)) { | ||
var module = modules[key]; | ||
@@ -844,2 +842,4 @@ | ||
define: function(name, dependencies, implementation, config) { | ||
void 0; | ||
// Create a new module by merging the provided config with the passed name, | ||
@@ -907,2 +907,4 @@ // dependencies and implementation. | ||
void 0; | ||
var failureCallback; | ||
@@ -941,8 +943,13 @@ var i; | ||
void 0; | ||
// Map the required modules so we start with clean idea what the hell we should load. | ||
modules = this._getConfigParser().mapModule(modules); | ||
void 0; | ||
// Resolve the dependencies of the specified modules by the user | ||
// then load their JS scripts | ||
self._resolveDependencies(modules).then(function(dependencies) { | ||
void 0; | ||
return self._loadModules(dependencies); | ||
@@ -1040,4 +1047,5 @@ }).then(function(loadedModules) { | ||
var dependency = module.dependencies[j]; | ||
var dependencyModule = registeredModules[dependency]; | ||
if (dependency !== 'exports' && dependency !== 'module' && !dependency.pendingImplementation) { | ||
if (dependency !== 'exports' && dependency !== 'module' && (!dependencyModule || !dependencyModule.pendingImplementation)) { | ||
missingDependencies[dependency] = 1; | ||
@@ -1157,2 +1165,4 @@ } | ||
// As soon as that happens, wait for each module to define itself | ||
void 0; | ||
Promise.all(pendingScripts).then(function(loadedScripts) { | ||
@@ -1374,2 +1384,3 @@ return self._waitForModules(moduleNames); | ||
if (missingDependencies.length) { | ||
void 0; | ||
self.require(missingDependencies, defineModules, reject); | ||
@@ -1376,0 +1387,0 @@ } else { |
@@ -342,6 +342,6 @@ /*! | ||
} else { | ||
console.warn('Off: callback was not removed: ' + callback.toString()); | ||
void 0; | ||
} | ||
} else { | ||
console.warn('Off: there are no listeners for event: ' + event); | ||
void 0; | ||
} | ||
@@ -373,3 +373,3 @@ }, | ||
} else { | ||
console.warn('No listeners for event: ' + event); | ||
void 0; | ||
} | ||
@@ -401,4 +401,2 @@ } | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
@@ -446,3 +444,3 @@ * Creates an instance of ConfigurationParser class. | ||
for (var key in module) { | ||
if (hasOwnProperty.call(module, key)) { | ||
if (Object.prototype.hasOwnProperty.call(module, key)) { | ||
moduleDefinition[key] = module[key]; | ||
@@ -516,3 +514,3 @@ } | ||
/* istanbul ignore else */ | ||
if (hasOwnProperty.call(this._config.maps, alias)) { | ||
if (Object.prototype.hasOwnProperty.call(this._config.maps, alias)) { | ||
if (tmpModule === alias || tmpModule.indexOf(alias + '/') === 0) { | ||
@@ -540,3 +538,3 @@ tmpModule = this._config.maps[alias] + tmpModule.substring(alias.length); | ||
for (var key in config) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(config, key)) { | ||
if (Object.prototype.hasOwnProperty.call(config, key)) { | ||
if (key === 'modules') { | ||
@@ -562,3 +560,3 @@ this._parseModules(config[key]); | ||
for (var key in modules) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(modules, key)) { | ||
if (Object.prototype.hasOwnProperty.call(modules, key)) { | ||
var module = modules[key]; | ||
@@ -1120,2 +1118,4 @@ | ||
define: function(name, dependencies, implementation, config) { | ||
void 0; | ||
// Create a new module by merging the provided config with the passed name, | ||
@@ -1183,2 +1183,4 @@ // dependencies and implementation. | ||
void 0; | ||
var failureCallback; | ||
@@ -1217,8 +1219,13 @@ var i; | ||
void 0; | ||
// Map the required modules so we start with clean idea what the hell we should load. | ||
modules = this._getConfigParser().mapModule(modules); | ||
void 0; | ||
// Resolve the dependencies of the specified modules by the user | ||
// then load their JS scripts | ||
self._resolveDependencies(modules).then(function(dependencies) { | ||
void 0; | ||
return self._loadModules(dependencies); | ||
@@ -1316,4 +1323,5 @@ }).then(function(loadedModules) { | ||
var dependency = module.dependencies[j]; | ||
var dependencyModule = registeredModules[dependency]; | ||
if (dependency !== 'exports' && dependency !== 'module' && !dependency.pendingImplementation) { | ||
if (dependency !== 'exports' && dependency !== 'module' && (!dependencyModule || !dependencyModule.pendingImplementation)) { | ||
missingDependencies[dependency] = 1; | ||
@@ -1433,2 +1441,4 @@ } | ||
// As soon as that happens, wait for each module to define itself | ||
void 0; | ||
Promise.all(pendingScripts).then(function(loadedScripts) { | ||
@@ -1650,2 +1660,3 @@ return self._waitForModules(moduleNames); | ||
if (missingDependencies.length) { | ||
void 0; | ||
self.require(missingDependencies, defineModules, reject); | ||
@@ -1652,0 +1663,0 @@ } else { |
136
gulpfile.js
'use strict'; | ||
var beautify = require('gulp-beautify'); | ||
var babel = require('gulp-babel'); | ||
var concat = require('gulp-concat'); | ||
var del = require('del'); | ||
var babel = require('gulp-babel'); | ||
var exec = require('child_process').exec; | ||
@@ -16,2 +15,3 @@ var fs = require('fs'); | ||
var runSequence = require('run-sequence'); | ||
var stripDebug = require('gulp-strip-debug'); | ||
var template = require('gulp-template'); | ||
@@ -21,6 +21,6 @@ var uglify = require('gulp-uglify'); | ||
gulp.task('build', function(callback) { | ||
runSequence('clean', ['config', 'loader-min', 'source-min', 'modules'], 'build-config', 'demo', callback); | ||
runSequence('clean', 'create-loader-min', 'build-config', 'demo', callback); | ||
}); | ||
gulp.task('build-config', function(callback) { | ||
gulp.task('build-config', ['config', 'modules'], function(callback) { | ||
exec('node node_modules/lfr-module-config-generator/bin/index.js -b src/config/config-base.js -m dist/demo/modules/bower.json -o src/config/config.js -r dist/demo/modules dist/demo/modules', function(err, stdout, stderr) { | ||
@@ -42,20 +42,2 @@ if (err) { | ||
gulp.task('create-loader-pure', function() { | ||
var loaderPureContent = fs.readFileSync('dist/loader-pure.js'); | ||
fs.unlinkSync('dist/loader-pure.js'); | ||
return gulp.src('src/template/loader-pure.template') | ||
.pipe(template({ | ||
vendor: '', | ||
source: loaderPureContent | ||
})) | ||
.pipe(rename('loader-pure.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('combine-js', ['wrap-event-emitter', 'wrap-config-parser', 'wrap-dependency-builder', 'wrap-path-resolver', 'wrap-url-builder', 'wrap-script-loader'], function(callback) { | ||
runSequence('wrap-js-files', 'create-loader-pure', callback); | ||
}); | ||
gulp.task('config', function() { | ||
@@ -78,30 +60,20 @@ return gulp.src('src/config/**/*.*') | ||
gulp.task('format', function() { | ||
var src = gulp.src(['src/**/*.js']) | ||
.pipe(beautify()) | ||
.pipe(gulp.dest('src')); | ||
var test = gulp.src(['test/**/*.js']) | ||
.pipe(beautify()) | ||
.pipe(gulp.dest('test')); | ||
return merge(src, test); | ||
gulp.task('create-loader', ['create-loader-debug'], function() { | ||
return gulp.src('dist/loader-debug.js') | ||
.pipe(stripDebug()) | ||
.pipe(rename('loader.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('js', ['jsdoc', 'combine-js'], function() { | ||
gulp.task('create-loader-debug', ['create-loader-pure-debug'], function() { | ||
return gulp.src('src/template/loader.template') | ||
.pipe(template({ | ||
vendor: fs.readFileSync('src/vendor/promise.js'), | ||
source: fs.readFileSync('dist/loader-pure.js') | ||
source: fs.readFileSync('dist/loader-pure-debug.js') | ||
})) | ||
.pipe(rename('loader.js')) | ||
.pipe(rename('loader-debug.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('jsdoc', function() { | ||
gulp.src(['./src/js/**/*.js', 'README.md']) | ||
.pipe(jsdoc('api')); | ||
}); | ||
gulp.task('loader-min', ['js'], function() { | ||
gulp.task('create-loader-min', ['create-loader', 'create-loader-pure-min'], function() { | ||
return gulp.src('dist/loader.js') | ||
@@ -113,2 +85,48 @@ .pipe(uglify()) | ||
gulp.task('create-loader-pure-debug', ['create-loader-pure-wrapped'], function() { | ||
var loaderPureContent = fs.readFileSync('dist/loader-pure-wrapped.js'); | ||
fs.unlinkSync('dist/loader-pure-wrapped.js'); | ||
return gulp.src('src/template/loader-pure.template') | ||
.pipe(template({ | ||
vendor: '', | ||
source: loaderPureContent | ||
})) | ||
.pipe(rename('loader-pure-debug.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('create-loader-pure-min', ['create-loader-pure'], function() { | ||
return gulp.src('dist/loader-pure.js') | ||
.pipe(uglify()) | ||
.pipe(rename('loader-pure-min.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('create-loader-pure', ['create-loader-pure-debug'], function() { | ||
return gulp.src('dist/loader-pure-debug.js') | ||
.pipe(stripDebug()) | ||
.pipe(rename('loader-pure.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('create-loader-pure-wrapped', ['jsdoc', 'wrap-event-emitter', 'wrap-config-parser', 'wrap-dependency-builder', 'wrap-path-resolver', 'wrap-url-builder', 'wrap-script-loader'], function() { | ||
return gulp.src([ | ||
'umd/event-emitter.js', | ||
'umd/config-parser.js', | ||
'umd/dependency-builder.js', | ||
'umd/url-builder.js', | ||
'umd/path-resolver.js', | ||
'umd/script-loader.js' | ||
]) | ||
.pipe(concat('loader-pure-wrapped.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('jsdoc', function() { | ||
gulp.src(['./src/js/**/*.js', 'README.md']) | ||
.pipe(jsdoc('api')); | ||
}); | ||
gulp.task('modules2', function() { | ||
@@ -129,3 +147,8 @@ return gulp.src('src/modules2/**/*.js') | ||
gulp.task('test', ['build'], function(done) { | ||
gulp.src(['umd/**/*.js']) | ||
var streamStripDebug = gulp.src(['umd/**/*.js', '!umd/event-emitter.js']) | ||
.pipe(stripDebug()); | ||
var streamEventEmitter = gulp.src('umd/event-emitter.js'); | ||
merge(streamEventEmitter, streamStripDebug) | ||
.pipe(istanbul()) | ||
@@ -141,11 +164,2 @@ .pipe(istanbul.hookRequire()) | ||
gulp.task('test:no-coverage', ['build'], function() { | ||
return gulp.src([ | ||
'umd/**/*.js', | ||
'test/**/*.js', | ||
'!test/fixture/**/*.js' | ||
]) | ||
.pipe(mocha()); | ||
}); | ||
gulp.task('test-watch', function() { | ||
@@ -155,9 +169,2 @@ gulp.watch('tests/js/**/*.js', ['test']); | ||
gulp.task('source-min', ['js'], function() { | ||
return gulp.src('dist/loader-pure.js') | ||
.pipe(uglify()) | ||
.pipe(rename('loader-pure-min.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('watch', ['build'], function () { | ||
@@ -194,15 +201,2 @@ gulp.watch(['src/**/*', '!src/config/*'], ['build']); | ||
gulp.task('wrap-js-files', function() { | ||
return gulp.src([ | ||
'umd/event-emitter.js', | ||
'umd/config-parser.js', | ||
'umd/dependency-builder.js', | ||
'umd/url-builder.js', | ||
'umd/path-resolver.js', | ||
'umd/script-loader.js' | ||
]) | ||
.pipe(concat('loader-pure.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('wrap-script-loader', function() { | ||
@@ -209,0 +203,0 @@ return gulp.src('src/template/script-loader.template') |
{ | ||
"name": "lfr-amd-loader", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "AMD Loader with support for combo URL and conditional loading", | ||
@@ -26,3 +26,2 @@ "main": "main.js", | ||
"gulp-babel": "^5.1.0", | ||
"gulp-beautify": "^1.1.2", | ||
"gulp-concat": "^2.5.2", | ||
@@ -33,2 +32,3 @@ "gulp-istanbul": "^0.10.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-strip-debug": "^1.0.2", | ||
"gulp-template": "^3.0.0", | ||
@@ -39,3 +39,3 @@ "gulp-uglify": "^1.2.0", | ||
"lfr-module-config-generator": "latest", | ||
"merge-stream": "^0.1.7", | ||
"merge-stream": "^0.1.8", | ||
"run-sequence": "^1.1.0", | ||
@@ -42,0 +42,0 @@ "sinon": "^1.15.3", |
'use strict'; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
@@ -47,3 +45,3 @@ * Creates an instance of ConfigurationParser class. | ||
for (var key in module) { | ||
if (hasOwnProperty.call(module, key)) { | ||
if (Object.prototype.hasOwnProperty.call(module, key)) { | ||
moduleDefinition[key] = module[key]; | ||
@@ -117,3 +115,3 @@ } | ||
/* istanbul ignore else */ | ||
if (hasOwnProperty.call(this._config.maps, alias)) { | ||
if (Object.prototype.hasOwnProperty.call(this._config.maps, alias)) { | ||
if (tmpModule === alias || tmpModule.indexOf(alias + '/') === 0) { | ||
@@ -141,3 +139,3 @@ tmpModule = this._config.maps[alias] + tmpModule.substring(alias.length); | ||
for (var key in config) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(config, key)) { | ||
if (Object.prototype.hasOwnProperty.call(config, key)) { | ||
if (key === 'modules') { | ||
@@ -163,3 +161,3 @@ this._parseModules(config[key]); | ||
for (var key in modules) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(modules, key)) { | ||
if (Object.prototype.hasOwnProperty.call(modules, key)) { | ||
var module = modules[key]; | ||
@@ -166,0 +164,0 @@ |
@@ -46,2 +46,4 @@ 'use strict'; | ||
define: function(name, dependencies, implementation, config) { | ||
console.log('DEFINE', name, dependencies); | ||
// Create a new module by merging the provided config with the passed name, | ||
@@ -109,2 +111,4 @@ // dependencies and implementation. | ||
console.log('REQUIRE CALLED'); | ||
var failureCallback; | ||
@@ -143,8 +147,13 @@ var i; | ||
console.log('REQUIRE called with', modules); | ||
// Map the required modules so we start with clean idea what the hell we should load. | ||
modules = this._getConfigParser().mapModule(modules); | ||
console.log('REQUIRE modules mapped to', modules); | ||
// Resolve the dependencies of the specified modules by the user | ||
// then load their JS scripts | ||
self._resolveDependencies(modules).then(function(dependencies) { | ||
console.log('REQUIRE dependencies resolved to', dependencies); | ||
return self._loadModules(dependencies); | ||
@@ -242,4 +251,5 @@ }).then(function(loadedModules) { | ||
var dependency = module.dependencies[j]; | ||
var dependencyModule = registeredModules[dependency]; | ||
if (dependency !== 'exports' && dependency !== 'module' && !dependency.pendingImplementation) { | ||
if (dependency !== 'exports' && dependency !== 'module' && (!dependencyModule || !dependencyModule.pendingImplementation)) { | ||
missingDependencies[dependency] = 1; | ||
@@ -359,2 +369,4 @@ } | ||
// As soon as that happens, wait for each module to define itself | ||
console.log('SCRIPTS', urls); | ||
Promise.all(pendingScripts).then(function(loadedScripts) { | ||
@@ -576,2 +588,3 @@ return self._waitForModules(moduleNames); | ||
if (missingDependencies.length) { | ||
console.log('MISSING DEPENDENCIES', 'requested', moduleNames, 'missing', missingDependencies); | ||
self.require(missingDependencies, defineModules, reject); | ||
@@ -578,0 +591,0 @@ } else { |
@@ -176,4 +176,4 @@ 'use strict'; | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled); | ||
assert.ok(success.calledOnce); | ||
assert.isTrue(failure.notCalled); | ||
assert.isTrue(success.calledOnce); | ||
@@ -198,4 +198,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled); | ||
assert.ok(success.calledOnce); | ||
assert.isTrue(failure.notCalled); | ||
assert.isTrue(success.calledOnce); | ||
assert.isFunction(one); | ||
@@ -214,4 +214,4 @@ | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled); | ||
assert.ok(success.calledOnce); | ||
assert.isTrue(failure.notCalled); | ||
assert.isTrue(success.calledOnce); | ||
@@ -229,4 +229,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.calledOnce); | ||
assert.ok(success.notCalled); | ||
assert.isTrue(failure.calledOnce); | ||
assert.isTrue(success.notCalled); | ||
@@ -244,4 +244,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.calledOnce); | ||
assert.ok(success.notCalled); | ||
assert.isTrue(failure.calledOnce); | ||
assert.isTrue(success.notCalled); | ||
@@ -261,4 +261,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled); | ||
assert.ok(success.calledThrice); | ||
assert.isTrue(failure.notCalled); | ||
assert.isTrue(success.calledThrice); | ||
@@ -286,4 +286,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled); | ||
assert.ok(success.calledOnce); | ||
assert.isTrue(failure.notCalled); | ||
assert.isTrue(success.calledOnce); | ||
@@ -301,4 +301,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled, 'Failure should be not called'); | ||
assert.ok(success.calledOnce, 'Success should be called'); | ||
assert.isTrue(failure.notCalled, 'Failure should be not called'); | ||
assert.isTrue(success.calledOnce, 'Success should be called'); | ||
@@ -320,4 +320,4 @@ done(); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled, 'Failure should be not called'); | ||
assert.ok(success.calledOnce, 'Success should be called'); | ||
assert.isTrue(failure.notCalled, 'Failure should be not called'); | ||
assert.isTrue(success.calledOnce, 'Success should be called'); | ||
@@ -344,4 +344,4 @@ assert.isObject(successValue); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled, 'Failure should be not called'); | ||
assert.ok(success.calledOnce, 'Success should be called'); | ||
assert.isTrue(failure.notCalled, 'Failure should be not called'); | ||
assert.isTrue(success.calledOnce, 'Success should be called'); | ||
@@ -366,4 +366,4 @@ assert.isFunction(successValue); | ||
setTimeout(function () { | ||
assert.ok(failure.notCalled, 'Failure should be not called'); | ||
assert.ok(success.calledOnce, 'Success should be called'); | ||
assert.isTrue(failure.notCalled, 'Failure should be not called'); | ||
assert.isTrue(success.calledOnce, 'Success should be called'); | ||
@@ -375,2 +375,18 @@ assert.isObject(successValue); | ||
}); | ||
it('should resolve the missing dependencies without multiple require calls', function(done) { | ||
Loader.require = sinon.spy(Loader.require); | ||
var failure = sinon.stub(); | ||
var success = sinon.stub(); | ||
Loader.require.call(Loader, ['liferay@1.0.0/relative1'], success, failure); | ||
setTimeout(function () { | ||
assert.isTrue(failure.notCalled, 'Failure should be not called'); | ||
assert.isTrue(success.calledOnce, 'Success should be called'); | ||
assert.isTrue(Loader.require.calledOnce, 'Require should be called once'); | ||
done(); | ||
}, 50); | ||
}); | ||
}); |
@@ -21,4 +21,2 @@ (function (global, factory) { | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
@@ -66,3 +64,3 @@ * Creates an instance of ConfigurationParser class. | ||
for (var key in module) { | ||
if (hasOwnProperty.call(module, key)) { | ||
if (Object.prototype.hasOwnProperty.call(module, key)) { | ||
moduleDefinition[key] = module[key]; | ||
@@ -136,3 +134,3 @@ } | ||
/* istanbul ignore else */ | ||
if (hasOwnProperty.call(this._config.maps, alias)) { | ||
if (Object.prototype.hasOwnProperty.call(this._config.maps, alias)) { | ||
if (tmpModule === alias || tmpModule.indexOf(alias + '/') === 0) { | ||
@@ -160,3 +158,3 @@ tmpModule = this._config.maps[alias] + tmpModule.substring(alias.length); | ||
for (var key in config) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(config, key)) { | ||
if (Object.prototype.hasOwnProperty.call(config, key)) { | ||
if (key === 'modules') { | ||
@@ -182,3 +180,3 @@ this._parseModules(config[key]); | ||
for (var key in modules) { /* istanbul ignore else */ | ||
if (hasOwnProperty.call(modules, key)) { | ||
if (Object.prototype.hasOwnProperty.call(modules, key)) { | ||
var module = modules[key]; | ||
@@ -185,0 +183,0 @@ |
@@ -67,2 +67,4 @@ (function (global, factory) { | ||
define: function(name, dependencies, implementation, config) { | ||
console.log('DEFINE', name, dependencies); | ||
// Create a new module by merging the provided config with the passed name, | ||
@@ -130,2 +132,4 @@ // dependencies and implementation. | ||
console.log('REQUIRE CALLED'); | ||
var failureCallback; | ||
@@ -164,8 +168,13 @@ var i; | ||
console.log('REQUIRE called with', modules); | ||
// Map the required modules so we start with clean idea what the hell we should load. | ||
modules = this._getConfigParser().mapModule(modules); | ||
console.log('REQUIRE modules mapped to', modules); | ||
// Resolve the dependencies of the specified modules by the user | ||
// then load their JS scripts | ||
self._resolveDependencies(modules).then(function(dependencies) { | ||
console.log('REQUIRE dependencies resolved to', dependencies); | ||
return self._loadModules(dependencies); | ||
@@ -263,4 +272,5 @@ }).then(function(loadedModules) { | ||
var dependency = module.dependencies[j]; | ||
var dependencyModule = registeredModules[dependency]; | ||
if (dependency !== 'exports' && dependency !== 'module' && !dependency.pendingImplementation) { | ||
if (dependency !== 'exports' && dependency !== 'module' && (!dependencyModule || !dependencyModule.pendingImplementation)) { | ||
missingDependencies[dependency] = 1; | ||
@@ -380,2 +390,4 @@ } | ||
// As soon as that happens, wait for each module to define itself | ||
console.log('SCRIPTS', urls); | ||
Promise.all(pendingScripts).then(function(loadedScripts) { | ||
@@ -597,2 +609,3 @@ return self._waitForModules(moduleNames); | ||
if (missingDependencies.length) { | ||
console.log('MISSING DEPENDENCIES', 'requested', moduleNames, 'missing', missingDependencies); | ||
self.require(missingDependencies, defineModules, reject); | ||
@@ -599,0 +612,0 @@ } else { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
853190
141
10423