@o.z/zdi 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@o.z/zdi?style=flat-square)](https://www.npmjs.com/package/@o.z/zdi)
4
4
  [![license](https://img.shields.io/npm/l/@o.z/zdi?style=flat-square)](https://www.npmjs.com/package/@o.z/zdi)
5
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-6.0+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
6
6
 
7
7
  A lightweight, type-safe Dependency Injection container for TypeScript/JavaScript applications.
8
8
 
@@ -132,9 +132,9 @@ container.registerClass(Car, [Engine, 'wrong-type']); // ❌ TypeScript error
132
132
  ---
133
133
 
134
134
  ## License and AI Training
135
+
135
136
  This project is licensed under the GNU General Public License v3.0 (GPLv3).
136
137
 
137
138
  The authors of this software consider the use of this code, including its source code, documentation, and any other project artifacts, for the training of artificial intelligence (AI) systems (including but not limited to machine learning, large language models, and other AI technologies) to be creating a derivative work. As such, any entity using this code for such purposes must comply with the terms of the GPLv3. This includes, but is not limited to, making the entire source code of the AI system that uses this code available under the same GPLv3 license.
138
139
 
139
140
  If you wish to use this code for AI training without being subject to the GPLv3, please contact the authors to negotiate a separate license.
140
-
package/dist/index.cjs CHANGED
@@ -1,10 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _check_private_redeclaration(obj,privateCollection){if(privateCollection.has(obj)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function _class_apply_descriptor_get(receiver,descriptor){if(descriptor.get){return descriptor.get.call(receiver)}return descriptor.value}function _class_apply_descriptor_set(receiver,descriptor,value){if(descriptor.set){descriptor.set.call(receiver,value);}else {if(!descriptor.writable){throw new TypeError("attempted to set read only private field")}descriptor.value=value;}}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _class_extract_field_descriptor(receiver,privateMap,action){if(!privateMap.has(receiver)){throw new TypeError("attempted to "+action+" private field on non-instance")}return privateMap.get(receiver)}function _class_private_field_get(receiver,privateMap){var descriptor=_class_extract_field_descriptor(receiver,privateMap,"get");return _class_apply_descriptor_get(receiver,descriptor)}function _class_private_field_init(obj,privateMap,value){_check_private_redeclaration(obj,privateMap);privateMap.set(obj,value);}function _class_private_field_set(receiver,privateMap,value){var descriptor=_class_extract_field_descriptor(receiver,privateMap,"set");_class_apply_descriptor_set(receiver,descriptor,value);return value}function _class_private_method_get(receiver,privateSet,fn){if(!privateSet.has(receiver)){throw new TypeError("attempted to get private field on non-instance")}return fn}function _class_private_method_init(obj,privateSet){_check_private_redeclaration(obj,privateSet);privateSet.add(obj);}function _construct(Parent,args,Class){if(_is_native_reflect_construct()){_construct=Reflect.construct;}else {_construct=function construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor;if(Class)_set_prototype_of(instance,Class.prototype);return instance};}return _construct.apply(null,arguments)}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _is_native_function(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _wrap_native_super(Class){var _cache=typeof Map==="function"?new Map:undefined;_wrap_native_super=function wrapNativeSuper(Class){if(Class===null||!_is_native_function(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_get_prototype_of(this).constructor)}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _set_prototype_of(Wrapper,Class)};return _wrap_native_super(Class)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value:function(){return this}}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var _services=/*#__PURE__*/new WeakMap,_singletons=/*#__PURE__*/new WeakMap,_disposables=/*#__PURE__*/new WeakMap,_assertNotRegistered=/*#__PURE__*/new WeakSet,_getResolvedSingletons=/*#__PURE__*/new WeakSet;var Container=/*#__PURE__*/function(){function Container(){_class_call_check(this,Container);_class_private_method_init(this,_assertNotRegistered);_class_private_method_init(this,_getResolvedSingletons);_class_private_field_init(this,_services,{writable:true,value:new WeakMap});_class_private_field_init(this,_singletons,{writable:true,value:new WeakMap});_class_private_field_init(this,_disposables,{writable:true,value:new WeakMap});}_create_class(Container,[{key:"register",value:function register(token,factory){_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);_class_private_field_get(this,_services).set(token,{factory:factory,singleton:false});}},{key:"registerSingleton",value:function registerSingleton(token,factory){_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);_class_private_field_get(this,_services).set(token,{factory:factory,singleton:true});}},{key:"registerClass",value:function registerClass(token,dependencies){var _this=this;var singleton=arguments.length>2&&arguments[2]!==void 0?arguments[2]:false,disposeCallback=arguments.length>3?arguments[3]:void 0;_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);var factory=function factory(){var resolved=dependencies.map(function(dep){if(typeof dep==="function"&&_class_private_field_get(_this,_services).has(dep)){return _this.get(dep)}return dep});return _construct(token,_to_consumable_array(resolved))};if(singleton){this.registerSingleton(token,factory);}else {this.register(token,factory);}if(disposeCallback){_class_private_field_get(this,_disposables).set(token,{dispose:disposeCallback});}}},{key:"get",value:function get(token){var entry=_class_private_field_get(this,_services).get(token);if(!entry){throw new ServiceNotFoundError(token)}if(entry.singleton){if(!_class_private_field_get(this,_singletons).has(token)){try{var instance=entry.factory();_class_private_field_get(this,_singletons).set(token,instance);}catch(error){throw new InstantiationError(token,error)}}return _class_private_field_get(this,_singletons).get(token)}try{return entry.factory()}catch(error){throw new InstantiationError(token,error)}}},{key:"has",value:function has(token){return _class_private_field_get(this,_services).has(token)}},{key:"dispose",value:function dispose(){return _async_to_generator(function(){var disposePromises,_iteratorNormalCompletion,_didIteratorError,_iteratorError,_iterator,_step,_step_value,token,instance,disposable,result;return _ts_generator(this,function(_state){switch(_state.label){case 0:disposePromises=[];_iteratorNormalCompletion=true,_didIteratorError=false,_iteratorError=undefined;try{for(_iterator=_class_private_method_get(this,_getResolvedSingletons,getResolvedSingletons).call(this)[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){_step_value=_sliced_to_array(_step.value,2),token=_step_value[0],instance=_step_value[1];disposable=_class_private_field_get(this,_disposables).get(token);if(disposable===null||disposable===void 0?void 0:disposable.dispose){result=disposable.dispose(instance);if(_instanceof(result,Promise)){disposePromises.push(result);}}}}catch(err){_didIteratorError=true;_iteratorError=err;}finally{try{if(!_iteratorNormalCompletion&&_iterator.return!=null){_iterator.return();}}finally{if(_didIteratorError){throw _iteratorError}}}return [4,Promise.all(disposePromises)];case 1:_state.sent();_class_private_field_set(this,_singletons,new WeakMap);return [2]}})}).call(this)}},{key:"createChild",value:function createChild(){var child=new Container;_class_private_field_set(child,_services,_class_private_field_get(this,_services));_class_private_field_set(child,_disposables,_class_private_field_get(this,_disposables));return child}}]);return Container}();function assertNotRegistered(token){if(_class_private_field_get(this,_services).has(token)){throw new DuplicateRegistrationError(token)}}function getResolvedSingletons(){return _ts_generator(this,function(_state){return [2]})}var ServiceNotFoundError=/*#__PURE__*/function(Error1){_inherits(ServiceNotFoundError,Error1);function ServiceNotFoundError(token){_class_call_check(this,ServiceNotFoundError);var _this;_this=_call_super(this,ServiceNotFoundError,["Service not registered: ".concat(getTokenName(token))]);_this.name="ServiceNotFoundError";return _this}return ServiceNotFoundError}(_wrap_native_super(Error));var InstantiationError=/*#__PURE__*/function(Error1){_inherits(InstantiationError,Error1);function InstantiationError(token,cause){_class_call_check(this,InstantiationError);var _this;_this=_call_super(this,InstantiationError,["Failed to instantiate ".concat(getTokenName(token),": ").concat(cause.message)]);_this.name="InstantiationError";_this.cause=cause;return _this}return InstantiationError}(_wrap_native_super(Error));var DuplicateRegistrationError=/*#__PURE__*/function(Error1){_inherits(DuplicateRegistrationError,Error1);function DuplicateRegistrationError(token){_class_call_check(this,DuplicateRegistrationError);var _this;_this=_call_super(this,DuplicateRegistrationError,["Service already registered: ".concat(getTokenName(token))]);_this.name="DuplicateRegistrationError";return _this}return DuplicateRegistrationError}(_wrap_native_super(Error));function getTokenName(token){return token.name||token.toString().slice(0,50)+"..."}
6
-
7
- exports.Container = Container;
8
- exports.DuplicateRegistrationError = DuplicateRegistrationError;
9
- exports.InstantiationError = InstantiationError;
10
- exports.ServiceNotFoundError = ServiceNotFoundError;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function i(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function s(e){i(o,r,a,s,c,`next`,e)}function c(e){i(o,r,a,s,c,`throw`,e)}s(void 0)})}}function o(e,t,n){return t=b(t),O(e,F()?Reflect.construct(t,n||[],b(e).constructor):t.apply(e,n))}function s(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function c(e,t){return t.get?t.get.call(e):t.value}function l(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw TypeError(`attempted to set read only private field`);t.value=n}}function u(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function d(e,t,n){if(!t.has(e))throw TypeError(`attempted to `+n+` private field on non-instance`);return t.get(e)}function f(e,t){return c(e,d(e,t,`get`))}function p(e,t,n){s(e,t),t.set(e,n)}function m(e,t,n){return l(e,d(e,t,`set`),n),n}function h(e,t,n){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return n}function g(e,t){s(e,t),t.add(e)}function _(e,t,n){return _=F()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&k(i,n.prototype),i},_.apply(null,arguments)}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function y(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function x(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&k(e,t)}function S(e,t){"@swc/helpers - instanceof";return t!=null&&typeof Symbol<`u`&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function C(e){return Function.toString.call(e).indexOf(`[native code]`)!==-1}function w(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function T(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function E(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O(e,t){return t&&(M(t)===`object`||typeof t==`function`)?t:r(e)}function k(e,t){return k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},k(e,t)}function A(e,n){return t(e)||T(e,n)||N(e,n)||E()}function j(e){return n(e)||w(e)||N(e)||D()}function M(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function N(t,n){if(t){if(typeof t==`string`)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r===`Object`&&t.constructor&&(r=t.constructor.name),r===`Map`||r===`Set`)return Array.from(r);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}}function P(e){var t=typeof Map==`function`?new Map:void 0;return P=function(e){if(e===null||!C(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return _(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),k(n,e)},P(e)}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(F=function(){return!!e})()}function I(e,t){var n,r,i,a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype),s=Object.defineProperty;return s(o,`next`,{value:c(0)}),s(o,`throw`,{value:c(1)}),s(o,`return`,{value:c(2)}),typeof Symbol==`function`&&s(o,Symbol.iterator,{value:function(){return this}}),o;function c(e){return function(t){return l([e,t])}}function l(s){if(n)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=s[0]&2?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[s[0]&2,i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if((i=a.trys,!(i=i.length>0&&i[i.length-1]))&&(s[0]===6||s[0]===2)){a=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(s[0]===6&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var L=new WeakMap,R=new WeakMap,z=new WeakMap,B=new WeakSet,V=new WeakSet,H=function(){"use strict";function e(){u(this,e),g(this,B),g(this,V),p(this,L,{writable:!0,value:new WeakMap}),p(this,R,{writable:!0,value:new WeakMap}),p(this,z,{writable:!0,value:new WeakMap})}return y(e,[{key:`register`,value:function(e,t){h(this,B,U).call(this,e),f(this,L).set(e,{factory:t,singleton:!1})}},{key:`registerSingleton`,value:function(e,t){h(this,B,U).call(this,e),f(this,L).set(e,{factory:t,singleton:!0})}},{key:`registerClass`,value:function(e,t){var n=this,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3?arguments[3]:void 0;h(this,B,U).call(this,e);var a=function(){var r=t.map(function(e){return typeof e==`function`&&f(n,L).has(e)?n.get(e):e});return _(e,j(r))};r?this.registerSingleton(e,a):this.register(e,a),i&&f(this,z).set(e,{dispose:i})}},{key:`get`,value:function(e){var t=f(this,L).get(e);if(!t)throw new G(e);if(t.singleton){if(!f(this,R).has(e))try{var n=t.factory();f(this,R).set(e,n)}catch(t){throw new K(e,t)}return f(this,R).get(e)}try{return t.factory()}catch(t){throw new K(e,t)}}},{key:`has`,value:function(e){return f(this,L).has(e)}},{key:`dispose`,value:function(){return a(function(){var e,t,n,r,i,a,o,s,c,l,u;return I(this,function(d){switch(d.label){case 0:e=[],t=!0,n=!1,r=void 0;try{for(i=h(this,V,W).call(this)[Symbol.iterator]();!(t=(a=i.next()).done);t=!0)o=A(a.value,2),s=o[0],c=o[1],l=f(this,z).get(s),l?.dispose&&(u=l.dispose(c),S(u,Promise)&&e.push(u))}catch(e){n=!0,r=e}finally{try{!t&&i.return!=null&&i.return()}finally{if(n)throw r}}return[4,Promise.all(e)];case 1:return d.sent(),m(this,R,new WeakMap),[2]}})}).call(this)}},{key:`createChild`,value:function(){var t=new e;return m(t,L,f(this,L)),m(t,z,f(this,z)),t}}]),e}();function U(e){if(f(this,L).has(e))throw new q(e)}function W(){return I(this,function(e){return[2]})}var G=function(e){"use strict";x(t,e);function t(e){u(this,t);var n=o(this,t,[`Service not registered: ${J(e)}`]);return n.name=`ServiceNotFoundError`,n}return t}(P(Error)),K=function(e){"use strict";x(t,e);function t(e,n){u(this,t);var r=o(this,t,[`Failed to instantiate ${J(e)}: ${n.message}`]);return r.name=`InstantiationError`,r.cause=n,r}return t}(P(Error)),q=function(e){"use strict";x(t,e);function t(e){u(this,t);var n=o(this,t,[`Service already registered: ${J(e)}`]);return n.name=`DuplicateRegistrationError`,n}return t}(P(Error));function J(e){return e.name||e.toString().slice(0,50)+`...`}exports.Container=H,exports.DuplicateRegistrationError=q,exports.InstantiationError=K,exports.ServiceNotFoundError=G;
package/dist/index.js CHANGED
@@ -1,3 +1,414 @@
1
- function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);})}}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _check_private_redeclaration(obj,privateCollection){if(privateCollection.has(obj)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function _class_apply_descriptor_get(receiver,descriptor){if(descriptor.get){return descriptor.get.call(receiver)}return descriptor.value}function _class_apply_descriptor_set(receiver,descriptor,value){if(descriptor.set){descriptor.set.call(receiver,value);}else {if(!descriptor.writable){throw new TypeError("attempted to set read only private field")}descriptor.value=value;}}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _class_extract_field_descriptor(receiver,privateMap,action){if(!privateMap.has(receiver)){throw new TypeError("attempted to "+action+" private field on non-instance")}return privateMap.get(receiver)}function _class_private_field_get(receiver,privateMap){var descriptor=_class_extract_field_descriptor(receiver,privateMap,"get");return _class_apply_descriptor_get(receiver,descriptor)}function _class_private_field_init(obj,privateMap,value){_check_private_redeclaration(obj,privateMap);privateMap.set(obj,value);}function _class_private_field_set(receiver,privateMap,value){var descriptor=_class_extract_field_descriptor(receiver,privateMap,"set");_class_apply_descriptor_set(receiver,descriptor,value);return value}function _class_private_method_get(receiver,privateSet,fn){if(!privateSet.has(receiver)){throw new TypeError("attempted to get private field on non-instance")}return fn}function _class_private_method_init(obj,privateSet){_check_private_redeclaration(obj,privateSet);privateSet.add(obj);}function _construct(Parent,args,Class){if(_is_native_reflect_construct()){_construct=Reflect.construct;}else {_construct=function construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor;if(Class)_set_prototype_of(instance,Class.prototype);return instance};}return _construct.apply(null,arguments)}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);return Constructor}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass);}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return !!right[Symbol.hasInstance](left)}else {return left instanceof right}}function _is_native_function(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _wrap_native_super(Class){var _cache=typeof Map==="function"?new Map:undefined;_wrap_native_super=function wrapNativeSuper(Class){if(Class===null||!_is_native_function(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_get_prototype_of(this).constructor)}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _set_prototype_of(Wrapper,Class)};return _wrap_native_super(Class)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(_){}return (_is_native_reflect_construct=function(){return !!result})()}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype),d=Object.defineProperty;return d(g,"next",{value:verb(0)}),d(g,"throw",{value:verb(1)}),d(g,"return",{value:verb(2)}),typeof Symbol==="function"&&d(g,Symbol.iterator,{value:function(){return this}}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return {value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return {value:op[0]?op[1]:void 0,done:true}}}var _services=/*#__PURE__*/new WeakMap,_singletons=/*#__PURE__*/new WeakMap,_disposables=/*#__PURE__*/new WeakMap,_assertNotRegistered=/*#__PURE__*/new WeakSet,_getResolvedSingletons=/*#__PURE__*/new WeakSet;var Container=/*#__PURE__*/function(){function Container(){_class_call_check(this,Container);_class_private_method_init(this,_assertNotRegistered);_class_private_method_init(this,_getResolvedSingletons);_class_private_field_init(this,_services,{writable:true,value:new WeakMap});_class_private_field_init(this,_singletons,{writable:true,value:new WeakMap});_class_private_field_init(this,_disposables,{writable:true,value:new WeakMap});}_create_class(Container,[{key:"register",value:function register(token,factory){_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);_class_private_field_get(this,_services).set(token,{factory:factory,singleton:false});}},{key:"registerSingleton",value:function registerSingleton(token,factory){_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);_class_private_field_get(this,_services).set(token,{factory:factory,singleton:true});}},{key:"registerClass",value:function registerClass(token,dependencies){var _this=this;var singleton=arguments.length>2&&arguments[2]!==void 0?arguments[2]:false,disposeCallback=arguments.length>3?arguments[3]:void 0;_class_private_method_get(this,_assertNotRegistered,assertNotRegistered).call(this,token);var factory=function factory(){var resolved=dependencies.map(function(dep){if(typeof dep==="function"&&_class_private_field_get(_this,_services).has(dep)){return _this.get(dep)}return dep});return _construct(token,_to_consumable_array(resolved))};if(singleton){this.registerSingleton(token,factory);}else {this.register(token,factory);}if(disposeCallback){_class_private_field_get(this,_disposables).set(token,{dispose:disposeCallback});}}},{key:"get",value:function get(token){var entry=_class_private_field_get(this,_services).get(token);if(!entry){throw new ServiceNotFoundError(token)}if(entry.singleton){if(!_class_private_field_get(this,_singletons).has(token)){try{var instance=entry.factory();_class_private_field_get(this,_singletons).set(token,instance);}catch(error){throw new InstantiationError(token,error)}}return _class_private_field_get(this,_singletons).get(token)}try{return entry.factory()}catch(error){throw new InstantiationError(token,error)}}},{key:"has",value:function has(token){return _class_private_field_get(this,_services).has(token)}},{key:"dispose",value:function dispose(){return _async_to_generator(function(){var disposePromises,_iteratorNormalCompletion,_didIteratorError,_iteratorError,_iterator,_step,_step_value,token,instance,disposable,result;return _ts_generator(this,function(_state){switch(_state.label){case 0:disposePromises=[];_iteratorNormalCompletion=true,_didIteratorError=false,_iteratorError=undefined;try{for(_iterator=_class_private_method_get(this,_getResolvedSingletons,getResolvedSingletons).call(this)[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){_step_value=_sliced_to_array(_step.value,2),token=_step_value[0],instance=_step_value[1];disposable=_class_private_field_get(this,_disposables).get(token);if(disposable===null||disposable===void 0?void 0:disposable.dispose){result=disposable.dispose(instance);if(_instanceof(result,Promise)){disposePromises.push(result);}}}}catch(err){_didIteratorError=true;_iteratorError=err;}finally{try{if(!_iteratorNormalCompletion&&_iterator.return!=null){_iterator.return();}}finally{if(_didIteratorError){throw _iteratorError}}}return [4,Promise.all(disposePromises)];case 1:_state.sent();_class_private_field_set(this,_singletons,new WeakMap);return [2]}})}).call(this)}},{key:"createChild",value:function createChild(){var child=new Container;_class_private_field_set(child,_services,_class_private_field_get(this,_services));_class_private_field_set(child,_disposables,_class_private_field_get(this,_disposables));return child}}]);return Container}();function assertNotRegistered(token){if(_class_private_field_get(this,_services).has(token)){throw new DuplicateRegistrationError(token)}}function getResolvedSingletons(){return _ts_generator(this,function(_state){return [2]})}var ServiceNotFoundError=/*#__PURE__*/function(Error1){_inherits(ServiceNotFoundError,Error1);function ServiceNotFoundError(token){_class_call_check(this,ServiceNotFoundError);var _this;_this=_call_super(this,ServiceNotFoundError,["Service not registered: ".concat(getTokenName(token))]);_this.name="ServiceNotFoundError";return _this}return ServiceNotFoundError}(_wrap_native_super(Error));var InstantiationError=/*#__PURE__*/function(Error1){_inherits(InstantiationError,Error1);function InstantiationError(token,cause){_class_call_check(this,InstantiationError);var _this;_this=_call_super(this,InstantiationError,["Failed to instantiate ".concat(getTokenName(token),": ").concat(cause.message)]);_this.name="InstantiationError";_this.cause=cause;return _this}return InstantiationError}(_wrap_native_super(Error));var DuplicateRegistrationError=/*#__PURE__*/function(Error1){_inherits(DuplicateRegistrationError,Error1);function DuplicateRegistrationError(token){_class_call_check(this,DuplicateRegistrationError);var _this;_this=_call_super(this,DuplicateRegistrationError,["Service already registered: ".concat(getTokenName(token))]);_this.name="DuplicateRegistrationError";return _this}return DuplicateRegistrationError}(_wrap_native_super(Error));function getTokenName(token){return token.name||token.toString().slice(0,50)+"..."}
2
-
3
- export { Container, DuplicateRegistrationError, InstantiationError, ServiceNotFoundError };
1
+ //#region src/lib/index.ts
2
+ function e(e, t) {
3
+ (t == null || t > e.length) && (t = e.length);
4
+ for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
5
+ return r;
6
+ }
7
+ function t(e) {
8
+ if (Array.isArray(e)) return e;
9
+ }
10
+ function n(t) {
11
+ if (Array.isArray(t)) return e(t);
12
+ }
13
+ function r(e) {
14
+ if (e === void 0) throw ReferenceError("this hasn't been initialised - super() hasn't been called");
15
+ return e;
16
+ }
17
+ function i(e, t, n, r, i, a, o) {
18
+ try {
19
+ var s = e[a](o), c = s.value;
20
+ } catch (e) {
21
+ n(e);
22
+ return;
23
+ }
24
+ s.done ? t(c) : Promise.resolve(c).then(r, i);
25
+ }
26
+ function a(e) {
27
+ return function() {
28
+ var t = this, n = arguments;
29
+ return new Promise(function(r, a) {
30
+ var o = e.apply(t, n);
31
+ function s(e) {
32
+ i(o, r, a, s, c, "next", e);
33
+ }
34
+ function c(e) {
35
+ i(o, r, a, s, c, "throw", e);
36
+ }
37
+ s(void 0);
38
+ });
39
+ };
40
+ }
41
+ function o(e, t, n) {
42
+ return t = b(t), O(e, F() ? Reflect.construct(t, n || [], b(e).constructor) : t.apply(e, n));
43
+ }
44
+ function s(e, t) {
45
+ if (t.has(e)) throw TypeError("Cannot initialize the same private elements twice on an object");
46
+ }
47
+ function c(e, t) {
48
+ return t.get ? t.get.call(e) : t.value;
49
+ }
50
+ function l(e, t, n) {
51
+ if (t.set) t.set.call(e, n);
52
+ else {
53
+ if (!t.writable) throw TypeError("attempted to set read only private field");
54
+ t.value = n;
55
+ }
56
+ }
57
+ function u(e, t) {
58
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
59
+ }
60
+ function d(e, t, n) {
61
+ if (!t.has(e)) throw TypeError("attempted to " + n + " private field on non-instance");
62
+ return t.get(e);
63
+ }
64
+ function f(e, t) {
65
+ return c(e, d(e, t, "get"));
66
+ }
67
+ function p(e, t, n) {
68
+ s(e, t), t.set(e, n);
69
+ }
70
+ function m(e, t, n) {
71
+ return l(e, d(e, t, "set"), n), n;
72
+ }
73
+ function h(e, t, n) {
74
+ if (!t.has(e)) throw TypeError("attempted to get private field on non-instance");
75
+ return n;
76
+ }
77
+ function g(e, t) {
78
+ s(e, t), t.add(e);
79
+ }
80
+ function _(e, t, n) {
81
+ return _ = F() ? Reflect.construct : function(e, t, n) {
82
+ var r = [null];
83
+ r.push.apply(r, t);
84
+ var i = new (Function.bind.apply(e, r))();
85
+ return n && k(i, n.prototype), i;
86
+ }, _.apply(null, arguments);
87
+ }
88
+ function v(e, t) {
89
+ for (var n = 0; n < t.length; n++) {
90
+ var r = t[n];
91
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
92
+ }
93
+ }
94
+ function y(e, t, n) {
95
+ return t && v(e.prototype, t), n && v(e, n), e;
96
+ }
97
+ function b(e) {
98
+ return b = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
99
+ return e.__proto__ || Object.getPrototypeOf(e);
100
+ }, b(e);
101
+ }
102
+ function x(e, t) {
103
+ if (typeof t != "function" && t !== null) throw TypeError("Super expression must either be null or a function");
104
+ e.prototype = Object.create(t && t.prototype, { constructor: {
105
+ value: e,
106
+ writable: !0,
107
+ configurable: !0
108
+ } }), t && k(e, t);
109
+ }
110
+ function S(e, t) {
111
+ "@swc/helpers - instanceof";
112
+ return t != null && typeof Symbol < "u" && t[Symbol.hasInstance] ? !!t[Symbol.hasInstance](e) : e instanceof t;
113
+ }
114
+ function C(e) {
115
+ return Function.toString.call(e).indexOf("[native code]") !== -1;
116
+ }
117
+ function w(e) {
118
+ if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
119
+ }
120
+ function T(e, t) {
121
+ var n = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
122
+ if (n != null) {
123
+ var r = [], i = !0, a = !1, o, s;
124
+ try {
125
+ for (n = n.call(e); !(i = (o = n.next()).done) && (r.push(o.value), !(t && r.length === t)); i = !0);
126
+ } catch (e) {
127
+ a = !0, s = e;
128
+ } finally {
129
+ try {
130
+ !i && n.return != null && n.return();
131
+ } finally {
132
+ if (a) throw s;
133
+ }
134
+ }
135
+ return r;
136
+ }
137
+ }
138
+ function E() {
139
+ throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
140
+ }
141
+ function D() {
142
+ throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
143
+ }
144
+ function O(e, t) {
145
+ return t && (M(t) === "object" || typeof t == "function") ? t : r(e);
146
+ }
147
+ function k(e, t) {
148
+ return k = Object.setPrototypeOf || function(e, t) {
149
+ return e.__proto__ = t, e;
150
+ }, k(e, t);
151
+ }
152
+ function A(e, n) {
153
+ return t(e) || T(e, n) || N(e, n) || E();
154
+ }
155
+ function j(e) {
156
+ return n(e) || w(e) || N(e) || D();
157
+ }
158
+ function M(e) {
159
+ "@swc/helpers - typeof";
160
+ return e && typeof Symbol < "u" && e.constructor === Symbol ? "symbol" : typeof e;
161
+ }
162
+ function N(t, n) {
163
+ if (t) {
164
+ if (typeof t == "string") return e(t, n);
165
+ var r = Object.prototype.toString.call(t).slice(8, -1);
166
+ if (r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set") return Array.from(r);
167
+ if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return e(t, n);
168
+ }
169
+ }
170
+ function P(e) {
171
+ var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
172
+ return P = function(e) {
173
+ if (e === null || !C(e)) return e;
174
+ if (typeof e != "function") throw TypeError("Super expression must either be null or a function");
175
+ if (t !== void 0) {
176
+ if (t.has(e)) return t.get(e);
177
+ t.set(e, n);
178
+ }
179
+ function n() {
180
+ return _(e, arguments, b(this).constructor);
181
+ }
182
+ return n.prototype = Object.create(e.prototype, { constructor: {
183
+ value: n,
184
+ enumerable: !1,
185
+ writable: !0,
186
+ configurable: !0
187
+ } }), k(n, e);
188
+ }, P(e);
189
+ }
190
+ function F() {
191
+ try {
192
+ var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
193
+ } catch {}
194
+ return (F = function() {
195
+ return !!e;
196
+ })();
197
+ }
198
+ function I(e, t) {
199
+ var n, r, i, a = {
200
+ label: 0,
201
+ sent: function() {
202
+ if (i[0] & 1) throw i[1];
203
+ return i[1];
204
+ },
205
+ trys: [],
206
+ ops: []
207
+ }, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype), s = Object.defineProperty;
208
+ return s(o, "next", { value: c(0) }), s(o, "throw", { value: c(1) }), s(o, "return", { value: c(2) }), typeof Symbol == "function" && s(o, Symbol.iterator, { value: function() {
209
+ return this;
210
+ } }), o;
211
+ function c(e) {
212
+ return function(t) {
213
+ return l([e, t]);
214
+ };
215
+ }
216
+ function l(s) {
217
+ if (n) throw TypeError("Generator is already executing.");
218
+ for (; o && (o = 0, s[0] && (a = 0)), a;) try {
219
+ if (n = 1, r && (i = s[0] & 2 ? r.return : s[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, s[1])).done) return i;
220
+ switch (r = 0, i && (s = [s[0] & 2, i.value]), s[0]) {
221
+ case 0:
222
+ case 1:
223
+ i = s;
224
+ break;
225
+ case 4: return a.label++, {
226
+ value: s[1],
227
+ done: !1
228
+ };
229
+ case 5:
230
+ a.label++, r = s[1], s = [0];
231
+ continue;
232
+ case 7:
233
+ s = a.ops.pop(), a.trys.pop();
234
+ continue;
235
+ default:
236
+ if ((i = a.trys, !(i = i.length > 0 && i[i.length - 1])) && (s[0] === 6 || s[0] === 2)) {
237
+ a = 0;
238
+ continue;
239
+ }
240
+ if (s[0] === 3 && (!i || s[1] > i[0] && s[1] < i[3])) {
241
+ a.label = s[1];
242
+ break;
243
+ }
244
+ if (s[0] === 6 && a.label < i[1]) {
245
+ a.label = i[1], i = s;
246
+ break;
247
+ }
248
+ if (i && a.label < i[2]) {
249
+ a.label = i[2], a.ops.push(s);
250
+ break;
251
+ }
252
+ i[2] && a.ops.pop(), a.trys.pop();
253
+ continue;
254
+ }
255
+ s = t.call(e, a);
256
+ } catch (e) {
257
+ s = [6, e], r = 0;
258
+ } finally {
259
+ n = i = 0;
260
+ }
261
+ if (s[0] & 5) throw s[1];
262
+ return {
263
+ value: s[0] ? s[1] : void 0,
264
+ done: !0
265
+ };
266
+ }
267
+ }
268
+ var L = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakSet(), V = /* @__PURE__ */ new WeakSet(), H = /* @__PURE__ */ function() {
269
+ function e() {
270
+ u(this, e), g(this, B), g(this, V), p(this, L, {
271
+ writable: !0,
272
+ value: /* @__PURE__ */ new WeakMap()
273
+ }), p(this, R, {
274
+ writable: !0,
275
+ value: /* @__PURE__ */ new WeakMap()
276
+ }), p(this, z, {
277
+ writable: !0,
278
+ value: /* @__PURE__ */ new WeakMap()
279
+ });
280
+ }
281
+ return y(e, [
282
+ {
283
+ key: "register",
284
+ value: function(e, t) {
285
+ h(this, B, U).call(this, e), f(this, L).set(e, {
286
+ factory: t,
287
+ singleton: !1
288
+ });
289
+ }
290
+ },
291
+ {
292
+ key: "registerSingleton",
293
+ value: function(e, t) {
294
+ h(this, B, U).call(this, e), f(this, L).set(e, {
295
+ factory: t,
296
+ singleton: !0
297
+ });
298
+ }
299
+ },
300
+ {
301
+ key: "registerClass",
302
+ value: function(e, t) {
303
+ var n = this, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, i = arguments.length > 3 ? arguments[3] : void 0;
304
+ h(this, B, U).call(this, e);
305
+ var a = function() {
306
+ var r = t.map(function(e) {
307
+ return typeof e == "function" && f(n, L).has(e) ? n.get(e) : e;
308
+ });
309
+ return _(e, j(r));
310
+ };
311
+ r ? this.registerSingleton(e, a) : this.register(e, a), i && f(this, z).set(e, { dispose: i });
312
+ }
313
+ },
314
+ {
315
+ key: "get",
316
+ value: function(e) {
317
+ var t = f(this, L).get(e);
318
+ if (!t) throw new G(e);
319
+ if (t.singleton) {
320
+ if (!f(this, R).has(e)) try {
321
+ var n = t.factory();
322
+ f(this, R).set(e, n);
323
+ } catch (t) {
324
+ throw new K(e, t);
325
+ }
326
+ return f(this, R).get(e);
327
+ }
328
+ try {
329
+ return t.factory();
330
+ } catch (t) {
331
+ throw new K(e, t);
332
+ }
333
+ }
334
+ },
335
+ {
336
+ key: "has",
337
+ value: function(e) {
338
+ return f(this, L).has(e);
339
+ }
340
+ },
341
+ {
342
+ key: "dispose",
343
+ value: function() {
344
+ return a(function() {
345
+ var e, t, n, r, i, a, o, s, c, l, u;
346
+ return I(this, function(d) {
347
+ switch (d.label) {
348
+ case 0:
349
+ e = [], t = !0, n = !1, r = void 0;
350
+ try {
351
+ for (i = h(this, V, W).call(this)[Symbol.iterator](); !(t = (a = i.next()).done); t = !0) o = A(a.value, 2), s = o[0], c = o[1], l = f(this, z).get(s), l?.dispose && (u = l.dispose(c), S(u, Promise) && e.push(u));
352
+ } catch (e) {
353
+ n = !0, r = e;
354
+ } finally {
355
+ try {
356
+ !t && i.return != null && i.return();
357
+ } finally {
358
+ if (n) throw r;
359
+ }
360
+ }
361
+ return [4, Promise.all(e)];
362
+ case 1: return d.sent(), m(this, R, /* @__PURE__ */ new WeakMap()), [2];
363
+ }
364
+ });
365
+ }).call(this);
366
+ }
367
+ },
368
+ {
369
+ key: "createChild",
370
+ value: function() {
371
+ var t = new e();
372
+ return m(t, L, f(this, L)), m(t, z, f(this, z)), t;
373
+ }
374
+ }
375
+ ]), e;
376
+ }();
377
+ function U(e) {
378
+ if (f(this, L).has(e)) throw new q(e);
379
+ }
380
+ function W() {
381
+ return I(this, function(e) {
382
+ return [2];
383
+ });
384
+ }
385
+ var G = /* @__PURE__ */ function(e) {
386
+ x(t, e);
387
+ function t(e) {
388
+ u(this, t);
389
+ var n = o(this, t, [`Service not registered: ${J(e)}`]);
390
+ return n.name = "ServiceNotFoundError", n;
391
+ }
392
+ return t;
393
+ }(P(Error)), K = /* @__PURE__ */ function(e) {
394
+ x(t, e);
395
+ function t(e, n) {
396
+ u(this, t);
397
+ var r = o(this, t, [`Failed to instantiate ${J(e)}: ${n.message}`]);
398
+ return r.name = "InstantiationError", r.cause = n, r;
399
+ }
400
+ return t;
401
+ }(P(Error)), q = /* @__PURE__ */ function(e) {
402
+ x(t, e);
403
+ function t(e) {
404
+ u(this, t);
405
+ var n = o(this, t, [`Service already registered: ${J(e)}`]);
406
+ return n.name = "DuplicateRegistrationError", n;
407
+ }
408
+ return t;
409
+ }(P(Error));
410
+ function J(e) {
411
+ return e.name || e.toString().slice(0, 50) + "...";
412
+ }
413
+ //#endregion
414
+ export { H as Container, q as DuplicateRegistrationError, K as InstantiationError, G as ServiceNotFoundError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o.z/zdi",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "A lightweight, type-safe Dependency Injection container for TypeScript/JavaScript applications.",
5
5
  "homepage": "https://github.com/z-npm/zdi#readme",
6
6
  "docs": "https://github.com/z-npm/zdi#readme",
@@ -57,23 +57,23 @@
57
57
  "test:coverage": "vitest run --coverage"
58
58
  },
59
59
  "devDependencies": {
60
- "@o.z/vite-plugin-swc": "^0.6.1",
60
+ "@o.z/vite-plugin-swc": "^0.7.0",
61
61
  "@testing-library/dom": "^10.4.1",
62
62
  "@testing-library/user-event": "^14.6.1",
63
- "@types/jsdom": "^27.0.0",
64
- "@types/node": "^25.3.0",
65
- "@vitest/coverage-v8": "^4.0.18",
66
- "@vitest/ui": "^4.0.18",
63
+ "@types/jsdom": "^28.0.1",
64
+ "@types/node": "^25.5.0",
65
+ "@vitest/coverage-v8": "^4.1.1",
66
+ "@vitest/ui": "^4.1.1",
67
67
  "glob": "^13.0.6",
68
- "jsdom": "^28.1.0",
69
- "sass": "^1.97.3",
70
- "typedoc": "^0.28.17",
71
- "typedoc-plugin-markdown": "^4.10.0",
72
- "typescript": "^5.9.3",
73
- "vite": "^7.3.1",
68
+ "jsdom": "^29.0.1",
69
+ "sass": "^1.98.0",
70
+ "typedoc": "^0.28.18",
71
+ "typedoc-plugin-markdown": "^4.11.0",
72
+ "typescript": "^6.0.2",
73
+ "vite": "^8.0.2",
74
74
  "vite-plugin-dts": "^4.5.4",
75
75
  "vite-plugin-lib-inject-css": "^2.2.2",
76
- "vitest": "^4.0.18"
76
+ "vitest": "^4.1.1"
77
77
  },
78
78
  "types": "./dist/index.d.ts",
79
79
  "module": "./dist/index.js",
@@ -94,5 +94,5 @@
94
94
  "registry": "https://registry.npmjs.org/"
95
95
  },
96
96
  "sideEffects": false,
97
- "packageManager": "yarn@4.12.0"
97
+ "packageManager": "yarn@4.13.0"
98
98
  }