Permalink
Browse files

Module loading not working in Node #9

Signed-off-by: Phil Mander <philip.mander@gmail.com>
  • Loading branch information...
1 parent 8ade111 commit f54666efee1d2a23d04046fe90944dfce6c5dcdc @philmander committed Aug 12, 2013
Showing with 593 additions and 601 deletions.
  1. +7 −7 lib/inverted-min.js
  2. +293 −297 lib/inverted.js
  3. +1 −1 package.json
  4. +292 −296 src/inverted/AppContext.js
View
@@ -1,5 +1,5 @@
/*
- Inverted IOC container v0.2.2
+ Inverted IOC container v99
https://github.com/philmander/inverted-js
@@ -21,9 +21,9 @@ e.ref||a.matchProtoRefString(e))d=e.ref||e.substr(1),j[c]=this.getProto(d,f);els
d,[],d.injectAppContext,f):d)}else j[c]=e}return j};g.prototype._extendProto=function(a,f){var j={},d;for(d in a.prototype)j[d]=a.prototype[d];a.prototype=f;a.prototype.__super__=f.constructor;for(var c in j)a.prototype[c]=j[c];a.prototype.constructor=a};g.prototype._mixin=function(a,f,j,d){for(var c in f)"function"===typeof f[c]&&(!(c in a)||c in a&&d)&&function(c){a[c]=function(){return f[c].apply(f,arguments)}}(c);a["__"+j+"__"]=f};g.prototype._checkImplements=function(h,f,j){var d,c,e,b,g;for(d=
0;d<j.length;d++){e=this.getInterfaceConfig(j[d]);g=[];for(c=0;c<e.length;c++)b=a.trim(e[c]),"function"!==typeof f[b]&&g.push(h+" does not implement the method '"+b+"'");if(g.length)throw a.createError("Interface [ "+j[d]+"] not implemented: \n\t"+g.join("\n\t"));}};g.prototype.getProtoConfig=function(h){var f=this.config.protos;h=a.trim(h);if(f&&f.hasOwnProperty(h))return f[h];throw a.createError("No proto is defined for ["+h+"]");};g.prototype.getInterfaceConfig=function(h){var f=this.config.interfaces;
h=a.trim(h);if(f&&f.hasOwnProperty(h))return f[h];throw a.createError("No interface is defined for ["+h+"]");};return g});
-define("inverted/AppContext",["inverted/ProtoFactory","inverted/DependencyTree","inverted/Promise","inverted/Util"],function(k,a,g,h){var f=function(a,d,c){this.config=a;this.protoFactory=d;this.originalModule=c||module;this.allowCircular=this.config.allowCircular||!1;this.modules=[];define.amd?"undefined"!==typeof requirejs?this._loader=require:"undefined"!==typeof curl&&(this._loader=curl):this._loader=this._commonRequire};f.create=function(a,d){var c=new k(a),e=new f(a,c,d);return c.appContext=
-e};f.loader=function(a){this._loader=a};f.prototype.getProto=function(a,d,c){var e=this,b=new g;if(!this._loader)throw Error("No AMD loader is defined");if("string"===typeof d)throw h.createError('Inverted\'s interface has changed. Please now pass proto ID\'s as an array in a single argument\n\tgetProto(["one", "two","three"], onSuccess, onError);');"string"===typeof a&&(a=[a]);var f=[],l,k=[];for(l=0;l<a.length;l++)try{k.push(this._getDependencies(a[l]))}catch(n){if(n instanceof h.InvertedError&&
-!n.circular)f.push(n);else throw n;}this._loader(this.modules,function(){var g={};for(l=0;l<e.modules.length;l++)g[e.modules[l]]=arguments[l];e.protoFactory.addLoadedModules(g);var g=[],k;for(l=0;l<a.length;l++)try{k=e.protoFactory.getProto(a[l]),g.push(k)}catch(m){if(m instanceof h.InvertedError)f.push(m);else throw m;}for(l=0;l<f.length;l++)k=f[l],"function"===typeof c&&c.call(e,k),b.notifyFailure(k),k.print();"function"===typeof d&&d.apply(e,g);b.notifySuccess(g)});return b};f.prototype._getDependencies=
-function(f,d){d=d||new a;var c=this.protoFactory.getProtoConfig(f);try{d.addProto(f,null,!0),0>h.inArray(c.module,this.modules)&&this.modules.push(c.module)}catch(e){if(e.circular&&this.allowCircular)return d;throw e;}var b=d.addChild();if(c.extendsRef){var g=h.parseProtoReference(c.extendsRef).protoId;this._getDependencies(g,b)}c.args&&this._getDependenciesFromArgs(c.args,b);if(c.props)for(var k in c.props)c.props.hasOwnProperty(k)&&this._getDependenciesFromArgs([c.props[k]],b);if(c.mixin&&c.mixin.length){k=
-c.mixin.length;for(var m,g=0;g<k;g++)m=c.mixin[g],m="string"===typeof m?m:m.ref,m=h.parseProtoReference(m).protoId,this._getDependencies(m,b)}return d};f.prototype._getDependenciesFromArgs=function(a,d){if(a)for(var c,e=0;e<a.length;e++){var b=a[e];if(!(null===b||"undefined"===typeof b))if((c="object"===typeof b)&&b.ref||h.matchProtoRefString(b))c=h.parseProtoReference(b.ref||b.substr(1)).protoId,this._getDependencies(c,d);else if(c&&b.factoryRef)this._getDependencies(b.factoryRef,d);else if(c&&b.module)d.addProto({module:b.module});
-else if(c)for(var f in b)b.hasOwnProperty(f)&&((c=b[f])&&(c.ref||h.matchProtoRefString(c))?(c=h.parseProtoReference(c.ref||c.substr(1)).protoId,this._getDependencies(c,d)):c&&c.factoryRef?this._getDependencies(c.factoryRef,d):c&&c.module&&d.addProto({module:c.module}))}return d};f.prototype._commonRequire=function(a,d){var c=this,e=[];a.forEach(function(a){e.push(c.originalModule.require(a))});d.apply(this,e)};return f});define(["inverted/AppContext"],function(k){return k});
+define("inverted/AppContext",["inverted/ProtoFactory","inverted/DependencyTree","inverted/Promise","inverted/Util"],function(k,a,g,h){var f=function(a,d,c){this.config=a;this.protoFactory=d;this.originalModule=c||module;this.allowCircular=this.config.allowCircular||!1;this.modules=[];this._loader=define.amd&&"undefined"!==typeof requirejs?require:define.amd&&"undefined"!==typeof curl?curl:this._commonRequire};f.create=function(a,d){var c=new k(a),e=new f(a,c,d);return c.appContext=e};f.loader=function(a){this._loader=
+a};f.prototype.getProto=function(a,d,c){var e=this,b=new g;if(!this._loader)throw Error("No AMD loader is defined");if("string"===typeof d)throw h.createError('Inverted\'s interface has changed. Please now pass proto ID\'s as an array in a single argument\n\tgetProto(["one", "two","three"], onSuccess, onError);');"string"===typeof a&&(a=[a]);var f=[],l,k=[];for(l=0;l<a.length;l++)try{k.push(this._getDependencies(a[l]))}catch(n){if(n instanceof h.InvertedError&&!n.circular)f.push(n);else throw n;}this._loader(this.modules,
+function(){var g={};for(l=0;l<e.modules.length;l++)g[e.modules[l]]=arguments[l];e.protoFactory.addLoadedModules(g);var g=[],k;for(l=0;l<a.length;l++)try{k=e.protoFactory.getProto(a[l]),g.push(k)}catch(m){if(m instanceof h.InvertedError)f.push(m);else throw m;}for(l=0;l<f.length;l++)k=f[l],"function"===typeof c&&c.call(e,k),b.notifyFailure(k),k.print();"function"===typeof d&&d.apply(e,g);b.notifySuccess(g)});return b};f.prototype._getDependencies=function(f,d){d=d||new a;var c=this.protoFactory.getProtoConfig(f);
+try{d.addProto(f,null,!0),0>h.inArray(c.module,this.modules)&&this.modules.push(c.module)}catch(e){if(e.circular&&this.allowCircular)return d;throw e;}var b=d.addChild();if(c.extendsRef){var g=h.parseProtoReference(c.extendsRef).protoId;this._getDependencies(g,b)}c.args&&this._getDependenciesFromArgs(c.args,b);if(c.props)for(var k in c.props)c.props.hasOwnProperty(k)&&this._getDependenciesFromArgs([c.props[k]],b);if(c.mixin&&c.mixin.length){k=c.mixin.length;for(var m,g=0;g<k;g++)m=c.mixin[g],m="string"===
+typeof m?m:m.ref,m=h.parseProtoReference(m).protoId,this._getDependencies(m,b)}return d};f.prototype._getDependenciesFromArgs=function(a,d){if(a)for(var c,e=0;e<a.length;e++){var b=a[e];if(!(null===b||"undefined"===typeof b))if((c="object"===typeof b)&&b.ref||h.matchProtoRefString(b))c=h.parseProtoReference(b.ref||b.substr(1)).protoId,this._getDependencies(c,d);else if(c&&b.factoryRef)this._getDependencies(b.factoryRef,d);else if(c&&b.module)d.addProto({module:b.module});else if(c)for(var f in b)b.hasOwnProperty(f)&&
+((c=b[f])&&(c.ref||h.matchProtoRefString(c))?(c=h.parseProtoReference(c.ref||c.substr(1)).protoId,this._getDependencies(c,d)):c&&c.factoryRef?this._getDependencies(c.factoryRef,d):c&&c.module&&d.addProto({module:c.module}))}return d};f.prototype._commonRequire=function(a,d){var c=this,e=[];a.forEach(function(a){e.push(c.originalModule.require(a))});d.apply(this,e)};return f});define(["inverted/AppContext"],function(k){return k});
Oops, something went wrong. Retry.

0 comments on commit f54666e

Please sign in to comment.