UNPKG

8.05 kBJavaScriptView Raw
1!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.iniettore=t()}}(function(){return function t(n,e,r){function i(s,a){if(!e[s]){if(!n[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=e[s]={exports:{}};n[s][0].call(c.exports,function(t){var e=n[s][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,n){"use strict";function e(t,n,e,r){var i;if("function"!=typeof t)throw new Error("Invalid container creation, missing contribution function");this.$Container0=e||{},this.$Container1=g,this.$Container2=n,this.$Container3={},this.$Container4=[],this.$Container5={},this.$Container6=r||l,this.$Container7(u,this,p,[]),i=this.$Container8=C(this.$Container7.bind(this)),this.$Container7(c,i,p,[]),t(i),i.flush(),this.$Container9(c)}var r=t("./signals"),i=r.ACQUIRE,o=r.RELEASE,s=r.DISPOSE,a=t("./constants"),u=a.CONTAINER_ALIAS,c=a.CONTEXT_ALIAS,p=t("./options").VALUE,f=t("./utils"),l=(f.generateMask,f.noop),h=f.isEagerSingleton,g=t("./resolvers"),C=t("./createContext");e.prototype.get=function(t){return this.$Container2.log("resolving '"+t+"'",function(){if(this.$Container3[t])throw new Error("Circular dependency detected while resolving '"+t+"'");if(!(t in this.$Container0))throw new Error("'"+t+"' is not available. Has it ever been registered?.");this.$Container3[t]=!0;try{return this.$Container0[t](i)}catch(n){throw n.message="Failed while resolving '"+t+"' due to:\n "+n.message,n}finally{this.$Container3[t]=!1}}.bind(this))},e.prototype.using=function(t){return{get:function(n){var e,r=this.$Container8;for(e in t)r.map(e).to(t[e]).as(p);r.flush(),this.get(n);for(e in t)this.$Container9(e)}.bind(this)}},e.prototype.release=function(t){try{this.$Container0[t](o)}catch(n){throw n.message="Failed while releasing '"+t+"' due to:\n "+n.message,n}},e.prototype.createChild=function(t){var n=Object.keys(this.$Container5).length+1,r=new e(t,this.$Container2,Object.create(this.$Container0),this.$Containera.bind(this,n));return this.$Container5[n]=r,r},e.prototype.dispose=function(){this.$Containerb(),this.$Containerc(),this.$Container6(),this.$Container6=l},e.prototype.$Containerd=function(){},e.prototype.$Containerb=function(){var t,n=this.$Container5;for(t in n)n.hasOwnProperty(t)&&(n[t].dispose(),this.$Containera(t))},e.prototype.$Containera=function(t){delete this.$Container5[t]},e.prototype.$Containerc=function(){var t,n=this.$Container0;for(t in n)if(n.hasOwnProperty(t)){try{n[t](s)}catch(e){throw e.message="Failed while disposing '"+t+"' due to:\n "+e.message,e}delete n[t]}},e.prototype.$Container7=function(t,n,e,r){if(!(e in this.$Container1))throw new Error("Invalid flags combination. See documentation for valid flags combinations.");this.$Container0[t]=this.$Container1[e].call(null,n,this.$Containere.bind(this,r),this.$Containerf.bind(this,r)),h(e)&&this.get(t)},e.prototype.$Container9=function(t){this.$Container0[t](s),delete this.$Container0[t]},e.prototype.$Containerf=function(t){return t.forEach(function(t){this.release(t)}.bind(this))},e.prototype.$Containere=function(t){return t.map(function(t){return this.get(t)}.bind(this))},n.exports=e},{"./constants":3,"./createContext":4,"./options":7,"./resolvers":8,"./signals":9,"./utils":11}],2:[function(t,n){"use strict";function e(t){this.$Logger0=t,this.$Logger1=0,this.$Logger2={}}e.prototype.log=function(t,n){return n()},e.prototype.$Logger3=function(t){var n=this.$Logger5(),e=new Date;this.$Logger2[t]=e,console.log("["+e.toISOString()+"] "+n+"Starting "+t+"...")},e.prototype.$Logger4=function(t){var n=this.$Logger6(),e=new Date,r=e-this.$Logger2[t];console.log("["+e.toISOString()+"] "+n+"Finished "+t+" after "+r+" ms")},e.prototype.$Logger5=function(){return Array(++this.$Logger1).join(" ")},e.prototype.$Logger6=function(){return Array(this.$Logger1--).join(" ")},n.exports=e},{}],3:[function(t,n){"use strict";var e="$container",r="$context";n.exports.CONTAINER_ALIAS=e,n.exports.CONTEXT_ALIAS=r},{}],4:[function(t,n){"use strict";function e(t){return function(n){return n.createChild(t)}}function r(t,n){return function(e){return t(e).get(n)}}var i=t("./utils").generateMask,o=t("./options"),s=o.BLUEPRINT,a=o.PROVIDER,u=t("./constants"),c=u.CONTAINER_ALIAS,p=(u.CONTEXT_ALIAS,0),f=1,l=2,h=3;n.exports=function(t){var n=[],o={map:function(t){return o.flush(),n.push(t),{to:function(t){return n.push(t),{as:function(){var t=Array.prototype.slice.call(arguments,0),u=i(t);return u===s?(t=[a],n[f]=e(n[f]),n.push(i(t)),n.push([c]),{exports:function(t){return n[f]=r(n[f],t),{map:o.map}},map:o.map}):(n.push(u),{map:o.map,injecting:function(){var t=Array.prototype.slice.call(arguments,0);return n.push(t),{map:o.map}}})}}}}},flush:function(){var e=n[h]||[];n.length>2&&(t(n[p],n[f],n[l],e),n=[])}};return o}},{"./constants":3,"./options":7,"./utils":11}],5:[function(t,n){"use strict";function e(t,n){var e;return n=n||{},e=new i(n),new r(t,e)}var r=t("./Container"),i=t("./Logger");n.exports.create=e},{"./Container":1,"./Logger":2}],6:[function(t,n){"use strict";n.exports=function(t,n){var e,r;return e=function(){},e.prototype=t.prototype,r=new e,t.apply(r,n),r}},{}],7:[function(t,n){"use strict";n.exports=["VALUE","PROVIDER","CONSTRUCTOR","SINGLETON","FUNCTION","INSTANCE","PERSISTENT","TRANSIENT","BLUEPRINT","EAGER"].reduce(function(t,n,e){return t[n]=Math.pow(2,e),t},{})},{}],8:[function(t,n){"use strict";var e=t("./utils"),r=e.leftCurryTwice,i=e.identity,o=e.compose,s=e.partial,a=e.resolveDeps,u=e.invoke,c=e.instanciate,p=e.singletonify,f=e.generateMask,l=t("./options"),h=l.VALUE,g=l.PROVIDER,C=l.CONSTRUCTOR,y=l.SINGLETON,$=l.FUNCTION,d=l.INSTANCE,E=l.TRANSIENT,v=l.PERSISTENT,A=l.EAGER,S={};S[f([h])]=o(r,a)(i),S[f([$])]=o(r,a)(s),S[f([C])]=o(r,a)(c),S[f([E,C,y])]=p(c),S[f([v,C,y])]=p(c,!0),S[f([g])]=o(r,a)(u),S[f([E,y,g])]=p(u),S[f([v,y,g])]=p(u,!0),S[f([A,y,g])]=p(u,!0),S[f([A,C,y])]=p(c,!0),S[f([d])]=S[f([h])],n.exports=S},{"./options":7,"./utils":11}],9:[function(t,n){"use strict";n.exports={ACQUIRE:"ACQUIRE",RELEASE:"RELEASE",DISPOSE:"DISPOSE"}},{}],10:[function(t,n){"use strict";var e=t("./signals"),r=e.ACQUIRE,i=e.RELEASE,o=e.DISPOSE;n.exports=function(t,n){return n=n||!1,function(e,s,a){function u(){"function"==typeof c.dispose&&c.dispose(),c=void 0,f=0}var c,p={},f=0;return p[r]=function(n){return"undefined"==typeof c&&(c=t.call(this,n,s())),f++,c},p[i]=function(){f--,0!=f||n||(a(),u())},p[o]=function(){c&&(a(),u())},function(t){return p[t].call(this,e)}}}},{"./signals":9}],11:[function(t,n){"use strict";function e(t){return t}function r(t){return function(){var n=Array.prototype.slice.call(arguments,0);return function(){var e=Array.prototype.slice.call(arguments,0);return t.apply(null,n.concat(e))}}}function i(){var t=Array.prototype.slice.call(arguments,0);return function(){var n,e=Array.prototype.slice.call(arguments,0);for(n=t.length-1;n>=0;n--)e=[t[n].apply(this,e)];return e[0]}}function o(t){return function(n,e){return t.call(this,n,e())}}function s(t,n){return t.apply(null,n)}function a(t,n){return function(){var e=Array.prototype.slice.call(arguments,0);return t.apply(this,n.concat(e))}}function u(t){return t.reduce(function(t,n){return t|n},0)}function c(t){return[d,E].indexOf(t)>-1}function p(){}var f=t("./instanciate"),l=t("./singletonify"),h=t("./options"),g=h.EAGER,C=h.SINGLETON,y=h.PROVIDER,$=h.CONSTRUCTOR,d=u([g,C,y]),E=u([g,C,$]);n.exports.identity=e,n.exports.leftCurryTwice=r,n.exports.compose=i,n.exports.resolveDeps=o,n.exports.invoke=s,n.exports.partial=a,n.exports.generateMask=u,n.exports.isEagerSingleton=c,n.exports.noop=p,n.exports.instanciate=f,n.exports.singletonify=l},{"./instanciate":6,"./options":7,"./singletonify":10}]},{},[5])(5)});
\No newline at end of file