async-injection 2.2.0 → 3.0.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 +134 -194
- package/lib/async-factory-provider.d.ts +4 -4
- package/lib/bindable-provider.d.ts +4 -4
- package/lib/binding.d.ts +80 -0
- package/lib/cjs/async-factory-provider.js +5 -5
- package/lib/cjs/async-factory-provider.js.map +1 -1
- package/lib/cjs/bindable-provider.js +23 -36
- package/lib/cjs/bindable-provider.js.map +1 -1
- package/lib/cjs/{binder.js → binding.js} +1 -1
- package/lib/cjs/binding.js.map +1 -0
- package/lib/cjs/class-provider.js +168 -66
- package/lib/cjs/class-provider.js.map +1 -1
- package/lib/cjs/constant-provider.js +4 -4
- package/lib/cjs/constant-provider.js.map +1 -1
- package/lib/cjs/container.js +81 -45
- package/lib/cjs/container.js.map +1 -1
- package/lib/cjs/decorators.js +80 -40
- package/lib/cjs/decorators.js.map +1 -1
- package/lib/cjs/index.js +10 -10
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/injector.js +5 -5
- package/lib/cjs/injector.js.map +1 -1
- package/lib/cjs/provider.js +16 -11
- package/lib/cjs/provider.js.map +1 -1
- package/lib/cjs/state.js +2 -2
- package/lib/cjs/state.js.map +1 -1
- package/lib/cjs/sync-factory-provider.js +7 -7
- package/lib/cjs/sync-factory-provider.js.map +1 -1
- package/lib/cjs/utils.js +10 -13
- package/lib/cjs/utils.js.map +1 -1
- package/lib/class-provider.d.ts +20 -6
- package/lib/constant-provider.d.ts +2 -2
- package/lib/container.d.ts +45 -19
- package/lib/decorators.d.ts +16 -3
- package/lib/esm/async-factory-provider.js +1 -1
- package/lib/esm/async-factory-provider.js.map +1 -1
- package/lib/esm/bindable-provider.js +19 -32
- package/lib/esm/bindable-provider.js.map +1 -1
- package/lib/esm/binding.js +2 -0
- package/lib/esm/binding.js.map +1 -0
- package/lib/esm/class-provider.js +155 -53
- package/lib/esm/class-provider.js.map +1 -1
- package/lib/esm/constant-provider.js.map +1 -1
- package/lib/esm/container.js +63 -27
- package/lib/esm/container.js.map +1 -1
- package/lib/esm/decorators.js +61 -22
- package/lib/esm/decorators.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/injector.js +5 -5
- package/lib/esm/injector.js.map +1 -1
- package/lib/esm/provider.js +14 -9
- package/lib/esm/provider.js.map +1 -1
- package/lib/esm/state.js.map +1 -1
- package/lib/esm/sync-factory-provider.js +1 -1
- package/lib/esm/sync-factory-provider.js.map +1 -1
- package/lib/esm/utils.js +6 -8
- package/lib/esm/utils.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/injector.d.ts +1 -1
- package/lib/provider.d.ts +4 -4
- package/lib/state.d.ts +3 -3
- package/lib/sync-factory-provider.d.ts +5 -5
- package/package.json +7 -18
- package/lib/binder.d.ts +0 -106
- package/lib/cjs/binder.js.map +0 -1
- package/lib/esm/binder.js +0 -2
- package/lib/esm/binder.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":";;;AAAA,iDAAiD;AACjD;;GAEG;AACH,iDAA4M;AAG5M,0CAA0C;AAC1C,SAAS,UAAU,CAAC,MAAgB;IACnC,IAAI,IAAwB,CAAC;IAC7B,IAAI,MAAM,EAAE;QACX,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE;YAClC,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;SAC/B;KACD;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,0DAA0D;AAC1D,SAAS,kBAAkB,CAAC,MAAW;IACtC,yGAAyG;IACzG,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;QACvE,sEAAsE;QACtE,OAAO,MAAM,CA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AE,GAAG,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC;SACrH;QACD,IAAI,OAAO,CAAC,cAAc,CAAC,mCAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC;SAC5F;QACD,OAAO,CAAC,cAAc,CAAC,mCAAoB,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC;AACH,CAAC;AAjBD,0BAiBC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\n/**\n * These decorators all apply the information they collect (whether class, method, or parameter data) as tagged metadata on the class's constructor\n */\nimport {INJECT_METADATA_KEY, INJECTABLE_METADATA_KEY, OPTIONAL_METADATA_KEY, POSTCONSTRUCT_ASYNC_METADATA_KEY, POSTCONSTRUCT_SYNC_METADATA_KEY, REFLECT_RETURN, RELEASE_METADATA_KEY} from './constants.js';\nimport {InjectableId} from './injector.js';\n\n// Help user locate misapplied decorators.\nfunction targetHint(target: Function) {\n\tlet hint: string | undefined;\n\tif (target) {\n\t\thint = target.name;\n\t\tif ((!hint) && target.constructor) {\n\t\t\thint = target.constructor.name;\n\t\t}\n\t}\n\treturn hint;\n}\n\n// Validate that 'target' is a class constructor function.\nfunction isClassConstructor(target: any) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n\tif (typeof target === 'function' && target.hasOwnProperty('prototype')) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\treturn target.prototype.constructor === target;\n\t}\n\treturn false;\n}\n\n// Ensure consistency in our meta-data name getting/setting.\nfunction makeParamIdxKey(idx: number): string {\n\treturn `index-${idx}`;\n}\n\n// Validate that the specified target is a parameter of a class constructor\nfunction validateConstructorParam(decorator: string, target: Function, idx: number): string {\n\tif (!isClassConstructor(target)) {\n\t\tthrow new Error('@' + decorator + ' is not valid here [' + targetHint(target) + ']');\n\t}\n\treturn makeParamIdxKey(idx);\n}\n\n// Validate the decorator was only applied once.\nfunction validateSingleConstructorParam(decorator: string, target: Function, idx: number): string {\n\tconst propKey = validateConstructorParam(decorator, target, idx);\n\tif (Reflect.hasOwnMetadata(decorator, target, propKey)) {\n\t\tthrow new Error('@' + decorator + ' applied multiple times [' + target.constructor.name + ']');\n\t}\n\treturn propKey;\n}\n\n/**\n * Placed just before the class declaration, this class decorator applies metadata to the class constructor indicating that the user intends to bind the class into the container.\n * This decorator will throw if not placed on a class declaration, or if placed more than once on a class declaration.\n */\nexport function Injectable(): ClassDecorator {\n\t/**\n\t * @param target The constructor function of the class that is being decorated\n\t * @returns Undefined (nothing), as this decorator does not modify the constructor in any way.\n\t */\n\treturn function (target: Function): void {\n\t\tif (Reflect.hasOwnMetadata(INJECTABLE_METADATA_KEY, target)) {\n\t\t\tthrow new Error('@Injectable applied multiple times [' + targetHint(target) + ']');\n\t\t}\n\t\tReflect.defineMetadata(INJECTABLE_METADATA_KEY, true, target);\n\t};\n}\n\n/**\n * Placed just before a constructor parameter, this parameter decorator allows for specificity and control over the type of the type of Object that will be injected into the parameter.\n * In the absence of this decorator the container will use whatever is bound to a parameter's type (or throw an error if it is unable to recognize the type).\n *\n * @param id The identifier of the bound type that should be injected.\n */\nexport function Inject(id: InjectableId<any>): ParameterDecorator {\n\t/**\n\t * @param target The constructor function of the class (we don't allow @Inject on anything else).\n\t * @param parameterName The name of the parameter\n\t * @param parameterIndex The ordinal index of the parameter in the function’s parameter list\n\t * @returns Undefined (nothing), as this decorator does not modify the parameter in any way.\n\t */\n\treturn function (target: Function, parameterName: string | symbol, parameterIndex: number): void {\n\t\tif (id === undefined) {\n\t\t\tthrow new Error('Undefined id passed to @Inject [' + targetHint(target) + ']');\n\t\t}\n\t\tconst paramKey = validateSingleConstructorParam('Inject', target, parameterIndex);\n\t\tReflect.defineMetadata(INJECT_METADATA_KEY, id, target, paramKey);\n\t};\n}\n\n/**\n * This is a helper function used by the container to retrieve the @Inject metadata for a specifically indexed constructor parameter\n *\n * @param target The constructor function of the class (we don't allow @Inject on anything else).\n * @param parameterIndex The ordinal index of the parameter in the constructor’s parameter list\n * @see Inject\n */\nexport function _getInjectedIdAt(target: Function, parameterIndex: number): InjectableId<any> {\n\treturn Reflect.getMetadata(INJECT_METADATA_KEY, target, makeParamIdxKey(parameterIndex)) as InjectableId<any>;\n}\n\n/**\n * Placed just before a constructor parameter, this parameter decorator signals the container that it should supply the 'alt' constant value (undefined by default) if for *any* reason it is unable to otherwise resolve the type of the parameter.\n * WARNING! It is your responsibility to ensure that alt is of the appropriate type/value.\n */\nexport function Optional(alt?: any): ParameterDecorator { // eslint-disable-line @typescript-eslint/explicit-module-boundary-types\n\t/**\n\t * @param target The constructor function of the class (we don't allow @Optional on anything else).\n\t * @param parameterName The name of the parameter\n\t * @param parameterIndex The ordinal index of the parameter in the function’s parameter list\n\t * @returns Undefined (nothing), as this decorator does not modify the parameter in any way.\n\t */\n\treturn function (target: Function, parameterName: string | symbol, parameterIndex: number): void {\n\t\tconst paramKey = validateSingleConstructorParam('Optional', target, parameterIndex);\n\t\tReflect.defineMetadata(OPTIONAL_METADATA_KEY, {value: alt}, target, paramKey);\n\t};\n}\n\n/**\n * This is a helper function used by the container to retrieve the @Optional metadata for a specifically indexed constructor parameter\n *\n * @param target The constructor function of the class (we don't allow @Optional on anything else).\n * @param parameterIndex The ordinal index of the parameter in the constructor’s parameter list\n * @see Optional\n * @returns an object containing the value provided in the decorator, or undefined if no annotation was present.\n */\nexport function _getOptionalDefaultAt(target: Function, parameterIndex: number): { value: any } {\n\treturn Reflect.getMetadata(OPTIONAL_METADATA_KEY, target, makeParamIdxKey(parameterIndex)) as { value: any }; // See the @Optional decorator before making any changes here.\n}\n\n/**\n * Placed just before a class method, this method decorator flags a method that should be called after an object has been instantiated by the container, but before it is put into service.\n * The method will be assumed to be synchronous unless the method signature explicitly declares it's return type to be \": Promise<something>\"\n * This decorator will throw if placed on a non-method or a static method of a class, or if placed on a method more than once, or if placed on more than one method for a class.\n */\nexport function PostConstruct(): MethodDecorator {\n\t/**\n\t * @param prototypeOrConstructor The prototype of the class (we don't allow @PostConstruct on anything other than a class instance method.\n\t * @param methodName The name of the method.\n\t * @param descriptor The Property Descriptor for the method.\n\t * @returns Undefined (nothing), as this decorator does not modify the method in any way.\n\t */\n\t// noinspection JSUnusedLocalSymbols\n\treturn function (target: Object, methodName: string | symbol, descriptor: PropertyDescriptor) { // eslint-disable-line @typescript-eslint/no-unused-vars\n\t\tif (typeof target !== 'object' || typeof target.constructor !== 'function') {\n\t\t\tthrow new Error('@PostConstruct not applied to instance method [' + target.toString() + '/' + methodName.toString() + ']');\n\t\t}\n\t\tif (Reflect.hasOwnMetadata(POSTCONSTRUCT_SYNC_METADATA_KEY, target.constructor) || Reflect.hasOwnMetadata(POSTCONSTRUCT_ASYNC_METADATA_KEY, target.constructor)) {\n\t\t\tthrow new Error('@PostConstruct applied multiple times [' + targetHint(target.constructor) + ']');\n\t\t}\n\t\tconst rt = Reflect.getMetadata(REFLECT_RETURN, target, methodName);\n\t\tif (typeof rt === 'function') {\n\t\t\tReflect.defineMetadata(POSTCONSTRUCT_ASYNC_METADATA_KEY, methodName, target.constructor);\n\t\t}\n\t\telse {\n\t\t\tReflect.defineMetadata(POSTCONSTRUCT_SYNC_METADATA_KEY, methodName, target.constructor);\n\t\t}\n\t};\n}\n\n// noinspection JSUnusedGlobalSymbols\n/**\n * Placed just before a class method, this decorator identifies a method which should be called when an object is removed from service.\n * If invoked by the container, the container will drop any references it has to the object when the method returns.\n * Note that this decorator is *not* a guarantee (or even an implication) that the decorated method will be called (JavaScript has no mechanism to enforce such a contract).\n * This decorator simply serves as a flag to indicate a method which is intended to clean up resources allocated by the object *which would not otherwise be garbage collected*.\n * You should *not* use this decorator as a general \"object finalization\" method. It has very limited scope and purpose.\n * The decorated method must complete normally (no throwing), as \"release\" is not an abort-able process.\n * This decorator will throw if placed on a non-method or a static method of a class, or if placed on a method more than once, or if placed on more than one method for a class.\n * The @see InvokeReleaseMethod helper function can search for and invoke the @Release decorated method of an object.\n * Also @see Container.releaseSingletons for the intended usage of this decorator.\n * It is intended that after the @Release decorated method of an object is called, that object will not be used again, but this is of course not enforced).\n */\nexport function Release(): MethodDecorator {\n\t/**\n\t * @param prototypeOrConstructor The prototype of the class (we don't allow @Release on anything other than a class instance method.\n\t * @param methodName The name of the method.\n\t * @param descriptor The Property Descriptor for the method.\n\t * @returns Undefined (nothing), as this decorator does not modify the method in any way.\n\t */\n\t// noinspection JSUnusedLocalSymbols\n\treturn function (target: Object, methodName: string | symbol, descriptor: PropertyDescriptor) { // eslint-disable-line @typescript-eslint/no-unused-vars\n\t\tif (typeof target !== 'object' || typeof target.constructor !== 'function') {\n\t\t\tthrow new Error('@Release not applied to instance method [' + target.toString() + '/' + methodName.toString() + ']');\n\t\t}\n\t\tif (Reflect.hasOwnMetadata(RELEASE_METADATA_KEY, target.constructor)) {\n\t\t\tthrow new Error('@Release applied multiple times [' + targetHint(target.constructor) + ']');\n\t\t}\n\t\tReflect.defineMetadata(RELEASE_METADATA_KEY, methodName, target.constructor);\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":";;AAoEA,gCAWC;AASD,wBAsBC;AASD,4CAEC;AAKD,0DAEC;AAOD,4BAmBC;AAUD,sDAEC;AAKD,oEAEC;AAQD,sCAsBC;AAcD,0BAgBC;AAzOD;;GAEG;AACH,2CAAyN;AAGzN,0CAA0C;AAC1C,SAAS,UAAU,CAAC,MAAgB;IACnC,IAAI,IAAwB,CAAC;IAC7B,IAAI,MAAM,EAAE,CAAC;QACZ,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACnC,I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CAAC,GAAG,GAAG,CAAC,CAAC;QACnG,CAAC;QACD,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACnE,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,4CAAgC,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1F,CAAC;aACI,CAAC;YACL,OAAO,CAAC,cAAc,CAAC,2CAA+B,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QACzF,CAAC;IACF,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,OAAO;IACtB;;;;;OAKG;IACH,OAAO,UAAU,MAAc,EAAE,UAA2B,EAAE,WAA+B;QAC5F,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,2CAA2C,GAAG,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC;QACtH,CAAC;QACD,IAAI,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC;QAC7F,CAAC;QACD,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC;AACH,CAAC","sourcesContent":["/**\n * These decorators all apply the information they collect (whether class, method, or parameter data) as tagged metadata on the class's constructor\n */\nimport {INJECT_METADATA_KEY, INJECTABLE_METADATA_KEY, OPTIONAL_METADATA_KEY, POSTCONSTRUCT_ASYNC_METADATA_KEY, POSTCONSTRUCT_SYNC_METADATA_KEY, REFLECT_PARAMS, REFLECT_RETURN, RELEASE_METADATA_KEY} from './constants';\nimport {InjectableId} from './injector';\n\n// Help user locate misapplied decorators.\nfunction targetHint(target: Function): string {\n\tlet hint: string | undefined;\n\tif (target) {\n\t\thint = target.name;\n\t\tif ((!hint) && target.constructor) {\n\t\t\thint = target.constructor.name;\n\t\t}\n\t}\n\treturn hint ?? '';\n}\n\n// Validate that 'target' is a class constructor function.\nfunction isClassConstructor(target: any) {\n\tif (typeof target === 'function' && target.hasOwnProperty('prototype')) {\n\t\treturn target.prototype.constructor === target;\n\t}\n\treturn false;\n}\n\n// Ensure consistency in our meta-data name getting/setting.\nfunction makeParamIdxKey(idx: number): string {\n\treturn `index-${idx}`;\n}\n\n// Key for @Inject/@Optional metadata stored on a method parameter.\nfunction makeMethodParamIdxKey(methodName: string | symbol, idx: number): string {\n\treturn `${String(methodName)}:index-${idx}`;\n}\n\n// Validate that the specified target is a parameter of a class constructor\nfunction validateConstructorParam(decorator: string, target: Function, idx: number): string {\n\tif (!isClassConstructor(target)) {\n\t\tthrow new Error('@' + decorator + ' is not valid here [' + targetHint(target) + ']');\n\t}\n\treturn makeParamIdxKey(idx);\n}\n\n// Validate that the target is an instance method parameter (non-constructor).\nfunction validateMethodParam(decorator: string, target: object, methodName: string | symbol, idx: number): string {\n\tif (typeof target !== 'object' || typeof (target as any).constructor !== 'function') {\n\t\tthrow new Error('@' + decorator + ' is not valid here [' + targetHint(target as Function) + ']');\n\t}\n\tif (!Reflect.hasOwnMetadata(REFLECT_PARAMS, target, methodName)) {\n\t\t// REFLECT_PARAMS not yet set (decoration order), so we cannot pre-validate the method; accept silently.\n\t}\n\treturn makeMethodParamIdxKey(methodName, idx);\n}\n\n// Validate the decorator was only applied once.\nfunction validateSingleConstructorParam(decorator: string, target: Function, idx: number): string {\n\tconst propKey = validateConstructorParam(decorator, target, idx);\n\tif (Reflect.hasOwnMetadata(decorator, target, propKey)) {\n\t\tthrow new Error('@' + decorator + ' applied multiple times [' + target.constructor.name + ']');\n\t}\n\treturn propKey;\n}\n\n/**\n * Placed just before the class declaration, this class decorator applies metadata to the class constructor indicating that the user intends to bind the class into the container.\n * This decorator will throw if not placed on a class declaration, or if placed more than once on a class declaration.\n */\nexport function Injectable(): ClassDecorator {\n\t/**\n\t * @param target The constructor function of the class that is being decorated\n\t * @returns Undefined (nothing), as this decorator does not modify the constructor in any way.\n\t */\n\treturn function (target: Function): void {\n\t\tif (Reflect.hasOwnMetadata(INJECTABLE_METADATA_KEY, target)) {\n\t\t\tthrow new Error('@Injectable applied multiple times [' + targetHint(target) + ']');\n\t\t}\n\t\tReflect.defineMetadata(INJECTABLE_METADATA_KEY, true, target);\n\t};\n}\n\n/**\n * Placed just before a constructor parameter, this parameter decorator allows for specificity and control over the type of Object that will be injected into the parameter.\n * In the absence of this decorator the container will use whatever is bound to a parameter's type (or throw an error if it is unable to recognize the type).\n * This decorator may also be placed on a parameter of a method annotated with @PostConstruct, in which case the container will resolve and inject the value before invoking that method.\n *\n * @param id The identifier of the bound type that should be injected.\n */\nexport function Inject(id: InjectableId<any>): ParameterDecorator {\n\t/**\n\t * @param target The constructor function of the class (for constructor params), or the class prototype (for method params).\n\t * @param parameterName The name of the parameter (undefined for constructor params, the method name for method params)\n\t * @param parameterIndex The ordinal index of the parameter in the function’s parameter list\n\t * @returns Undefined (nothing), as this decorator does not modify the parameter in any way.\n\t */\n\treturn function (target: object, parameterName: string | symbol | undefined, parameterIndex: number): void {\n\t\tif (id === undefined) {\n\t\t\tthrow new Error('Undefined id passed to @Inject [' + targetHint(target as Function) + ']');\n\t\t}\n\t\tif (parameterName === undefined) {\n\t\t\t// Constructor parameter\n\t\t\tconst paramKey = validateSingleConstructorParam('Inject', target as Function, parameterIndex);\n\t\t\tReflect.defineMetadata(INJECT_METADATA_KEY, id, target, paramKey);\n\t\t}\n\t\telse {\n\t\t\t// Method parameter — silently accepted (intended for @PostConstruct methods)\n\t\t\tconst paramKey = validateMethodParam('Inject', target, parameterName, parameterIndex);\n\t\t\tReflect.defineMetadata(INJECT_METADATA_KEY, id, target, paramKey);\n\t\t}\n\t};\n}\n\n/**\n * This is a helper function used by the container to retrieve the @Inject metadata for a specifically indexed constructor parameter\n *\n * @param target The constructor function of the class (we don't allow @Inject on anything else).\n * @param parameterIndex The ordinal index of the parameter in the constructor’s parameter list\n * @see Inject\n */\nexport function _getInjectedIdAt(target: Function, parameterIndex: number): InjectableId<any> {\n\treturn Reflect.getMetadata(INJECT_METADATA_KEY, target, makeParamIdxKey(parameterIndex)) as InjectableId<any>;\n}\n\n/**\n * Retrieve the @Inject metadata for a specifically indexed parameter of a named method.\n */\nexport function _getInjectedIdForMethod(prototype: object, methodName: string | symbol, parameterIndex: number): InjectableId<any> {\n\treturn Reflect.getMetadata(INJECT_METADATA_KEY, prototype, makeMethodParamIdxKey(methodName, parameterIndex)) as InjectableId<any>;\n}\n\n/**\n * Placed just before a constructor parameter, this parameter decorator signals the container that it should supply the 'alt' constant value (undefined by default) if for *any* reason it is unable to otherwise resolve the type of the parameter.\n * This decorator may also be placed on a parameter of a method annotated with @PostConstruct.\n * WARNING! It is your responsibility to ensure that alt is of the appropriate type/value.\n */\nexport function Optional(alt?: any): ParameterDecorator {\n\t/**\n\t * @param target The constructor function of the class (for constructor params), or the class prototype (for method params).\n\t * @param parameterName The name of the parameter (undefined for constructor params, the method name for method params)\n\t * @param parameterIndex The ordinal index of the parameter in the function’s parameter list\n\t * @returns Undefined (nothing), as this decorator does not modify the parameter in any way.\n\t */\n\treturn function (target: object, parameterName: string | symbol | undefined, parameterIndex: number): void {\n\t\tif (parameterName === undefined) {\n\t\t\t// Constructor parameter\n\t\t\tconst paramKey = validateSingleConstructorParam('Optional', target as Function, parameterIndex);\n\t\t\tReflect.defineMetadata(OPTIONAL_METADATA_KEY, {value: alt}, target, paramKey);\n\t\t}\n\t\telse {\n\t\t\t// Method parameter — silently accepted (intended for @PostConstruct methods)\n\t\t\tconst paramKey = validateMethodParam('Optional', target, parameterName, parameterIndex);\n\t\t\tReflect.defineMetadata(OPTIONAL_METADATA_KEY, {value: alt}, target, paramKey);\n\t\t}\n\t};\n}\n\n/**\n * This is a helper function used by the container to retrieve the @Optional metadata for a specifically indexed constructor parameter\n *\n * @param target The constructor function of the class (we don't allow @Optional on anything else).\n * @param parameterIndex The ordinal index of the parameter in the constructor’s parameter list\n * @see Optional\n * @returns an object containing the value provided in the decorator, or undefined if no annotation was present.\n */\nexport function _getOptionalDefaultAt(target: Function, parameterIndex: number): { value: any } {\n\treturn Reflect.getMetadata(OPTIONAL_METADATA_KEY, target, makeParamIdxKey(parameterIndex)) as { value: any }; // See the @Optional decorator before making any changes here.\n}\n\n/**\n * Retrieve the @Optional metadata for a specifically indexed parameter of a named method.\n */\nexport function _getOptionalDefaultForMethod(prototype: object, methodName: string | symbol, parameterIndex: number): { value: any } {\n\treturn Reflect.getMetadata(OPTIONAL_METADATA_KEY, prototype, makeMethodParamIdxKey(methodName, parameterIndex)) as { value: any };\n}\n\n/**\n * Placed just before a class method, this method decorator flags a method that should be called after an object has been instantiated by the container, but before it is put into service.\n * The method will be assumed to be synchronous unless the method signature explicitly declares its return type to be \": Promise<something>\".\n * Parameters will be resolved by the container just as they are for constructors.\n * This decorator will throw if placed on a non-method or a static method of a class, or if placed on a method more than once, or if placed on more than one method for a class.\n */\nexport function PostConstruct(): MethodDecorator {\n\t/**\n\t * @param prototypeOrConstructor The prototype of the class (we don't allow @PostConstruct on anything other than a class instance method.\n\t * @param methodName The name of the method.\n\t * @param _descriptor The Property Descriptor for the method.\n\t * @returns Undefined (nothing), as this decorator does not modify the method in any way.\n\t */\n\treturn function (target: Object, methodName: string | symbol, _descriptor: PropertyDescriptor) {\n\t\tif (typeof target !== 'object' || typeof target.constructor !== 'function') {\n\t\t\tthrow new Error('@PostConstruct not applied to instance method [' + target.toString() + '/' + methodName.toString() + ']');\n\t\t}\n\t\tif (Reflect.hasOwnMetadata(POSTCONSTRUCT_SYNC_METADATA_KEY, target.constructor) || Reflect.hasOwnMetadata(POSTCONSTRUCT_ASYNC_METADATA_KEY, target.constructor)) {\n\t\t\tthrow new Error('@PostConstruct applied multiple times [' + targetHint(target.constructor) + ']');\n\t\t}\n\t\tconst rt = Reflect.getMetadata(REFLECT_RETURN, target, methodName);\n\t\tif (typeof rt === 'function') {\n\t\t\tReflect.defineMetadata(POSTCONSTRUCT_ASYNC_METADATA_KEY, methodName, target.constructor);\n\t\t}\n\t\telse {\n\t\t\tReflect.defineMetadata(POSTCONSTRUCT_SYNC_METADATA_KEY, methodName, target.constructor);\n\t\t}\n\t};\n}\n\n/**\n * Placed just before a class method, this decorator identifies a method which should be called when an object is removed from service.\n * If invoked by the container, the container will drop any references it has to the object when the method returns.\n * Note that this decorator is *not* a guarantee (or even an implication) that the decorated method will be called (JavaScript has no mechanism to enforce such a contract).\n * This decorator simply serves as a flag to indicate a method which is intended to clean up resources allocated by the object *which would not otherwise be garbage collected*.\n * You should *not* use this decorator as a general \"object finalization\" method. It has very limited scope and purpose.\n * The decorated method must complete normally (no throwing), as \"release\" is not an abort-able process.\n * This decorator will throw if placed on a non-method or a static method of a class, or if placed on a method more than once, or if placed on more than one method for a class.\n * The @see InvokeReleaseMethod helper function can search for and invoke the @Release decorated method of an object.\n * Also @see Container.releaseSingletons for the intended usage of this decorator.\n * It is intended that after the @Release decorated method of an object is called, that object will not be used again, but this is of course not enforced).\n */\nexport function Release(): MethodDecorator {\n\t/**\n\t * @param prototypeOrConstructor The prototype of the class (we don't allow @Release on anything other than a class instance method.\n\t * @param methodName The name of the method.\n\t * @param _descriptor The Property Descriptor for the method.\n\t * @returns Undefined (nothing), as this decorator does not modify the method in any way.\n\t */\n\treturn function (target: Object, methodName: string | symbol, _descriptor: PropertyDescriptor) {\n\t\tif (typeof target !== 'object' || typeof target.constructor !== 'function') {\n\t\t\tthrow new Error('@Release not applied to instance method [' + target.toString() + '/' + methodName.toString() + ']');\n\t\t}\n\t\tif (Reflect.hasOwnMetadata(RELEASE_METADATA_KEY, target.constructor)) {\n\t\t\tthrow new Error('@Release applied multiple times [' + targetHint(target.constructor) + ']');\n\t\t}\n\t\tReflect.defineMetadata(RELEASE_METADATA_KEY, methodName, target.constructor);\n\t};\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InjectionToken = exports.Release = exports.PostConstruct = exports.Optional = exports.Injectable = exports.Inject = exports.Container = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return
|
|
8
|
-
Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return
|
|
9
|
-
Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "PostConstruct", { enumerable: true, get: function () { return
|
|
11
|
-
Object.defineProperty(exports, "Release", { enumerable: true, get: function () { return
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "InjectionToken", { enumerable: true, get: function () { return
|
|
4
|
+
var container_1 = require("./container");
|
|
5
|
+
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
|
|
6
|
+
var decorators_1 = require("./decorators");
|
|
7
|
+
Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return decorators_1.Inject; } });
|
|
8
|
+
Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return decorators_1.Injectable; } });
|
|
9
|
+
Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return decorators_1.Optional; } });
|
|
10
|
+
Object.defineProperty(exports, "PostConstruct", { enumerable: true, get: function () { return decorators_1.PostConstruct; } });
|
|
11
|
+
Object.defineProperty(exports, "Release", { enumerable: true, get: function () { return decorators_1.Release; } });
|
|
12
|
+
var injector_1 = require("./injector");
|
|
13
|
+
Object.defineProperty(exports, "InjectionToken", { enumerable: true, get: function () { return injector_1.InjectionToken; } });
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,2CAAkF;AAA1E,oGAAA,MAAM,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,qGAAA,OAAO,OAAA;AAC5D,uCAAoF;AAA5C,0GAAA,cAAc,OAAA","sourcesContent":["export {Container} from './container';\nexport {Inject, Injectable, Optional, PostConstruct, Release} from './decorators';\nexport {ClassConstructor, InjectableId, InjectionToken, Injector} from './injector';\nexport {AsyncFactory, OnErrorCallback, OnSuccessCallback, RegisterDescriptor, SyncFactory} from './binding';\n"]}
|
package/lib/cjs/injector.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.InjectionToken = void 0;
|
|
|
5
5
|
* Allow for implicit typing of constants and interfaces.
|
|
6
6
|
* Inspired by Angular and some colleges at work.
|
|
7
7
|
*/
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
8
|
class InjectionToken {
|
|
10
9
|
constructor(id) {
|
|
11
10
|
this.id = id;
|
|
@@ -14,10 +13,11 @@ class InjectionToken {
|
|
|
14
13
|
return this.toString();
|
|
15
14
|
}
|
|
16
15
|
toString() {
|
|
17
|
-
//
|
|
18
|
-
if (typeof this.id === 'symbol'
|
|
19
|
-
|
|
20
|
-
return this.id.
|
|
16
|
+
// noinspection SuspiciousTypeOfGuard
|
|
17
|
+
if (typeof this.id === 'symbol') {
|
|
18
|
+
const desc = this.id.description;
|
|
19
|
+
return desc !== undefined ? desc : this.id.toString();
|
|
20
|
+
}
|
|
21
21
|
return this.id.toString();
|
|
22
22
|
}
|
|
23
23
|
}
|
package/lib/cjs/injector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":";;;AASA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":";;;AASA;;;GAGG;AACH,MAAa,cAAc;IAC1B,YAAoB,EAAmB;QAAnB,OAAE,GAAF,EAAE,CAAiB;IACvC,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,QAAQ;QACP,qCAAqC;QACrC,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,GAAI,IAAI,CAAC,EAA0C,CAAC,WAAW,CAAC;YAC1E,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACD;AAhBD,wCAgBC","sourcesContent":["/**\n * This is about as close as we can get in Typescript\n */\nexport type AbstractConstructor<T> = Function & { prototype: T };\n/**\n * Standard definition of a constructor.\n */\nexport type ClassConstructor<T> = new (...args: any[]) => T;\n\n/**\n * Allow for implicit typing of constants and interfaces.\n * Inspired by Angular and some colleges at work.\n */\nexport class InjectionToken<T> {\n\tconstructor(private id: string | symbol) {\n\t}\n\n\tget description(): string {\n\t\treturn this.toString();\n\t}\n\n\ttoString(): string {\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (typeof this.id === 'symbol') {\n\t\t\tconst desc = (this.id as unknown as { description?: string }).description;\n\t\t\treturn desc !== undefined ? desc : this.id.toString();\n\t\t}\n\t\treturn this.id.toString();\n\t}\n}\n\n/**\n * Universal id that can be bound to a constant, class, or factories.\n */\nexport type InjectableId<T> = (string | symbol | AbstractConstructor<T> | ClassConstructor<T> | InjectionToken<T>) & { readonly description?: string };\n\n/**\n * Retrieve instances previously bound to the specified InjectableId.\n */\nexport interface Injector {\n\t/**\n\t * Check to see if the existing InjectableId is known (aka has been bound).\n\t * Error callbacks may wish to know if a particular InjectableId is available.\n\t * Also the Container's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.\n\t *\n\t * @param id The id to check for.\n\t * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container).\n\t */\n\tisIdKnown<T>(id: InjectableId<T> | AbstractConstructor<T>, ascending?: boolean): boolean;\n\n\t/**\n\t * Return an instance of <T> previously bound to 'id'.\n\t *\n\t * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'.\n\t */\n\tget<T>(id: InjectableId<T> | AbstractConstructor<T>): T;\n\n\t/**\n\t * awaits the asynchronous resolution of all dependencies in the tree for 'id'.\n\t */\n\tresolve<T>(id?: InjectableId<T> | AbstractConstructor<T>): Promise<T>;\n}\n"]}
|
package/lib/cjs/provider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Provider = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
/**
|
|
6
6
|
* Internally all InjectableIds are mapped to an abstract Provider<T>.
|
|
7
7
|
* A Provider may choose to return a singleton or a new value each time it is queried.
|
|
@@ -13,10 +13,10 @@ class Provider {
|
|
|
13
13
|
* Base method to initialize the state of this Provider *if* (and only if) it has been configured as a Singleton.
|
|
14
14
|
* If this Provider has not been configured as a singleton, this method is essentially a noop that returns undefined.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param _asyncOnly This default implementation ignores this parameter.
|
|
17
17
|
* @returns A completion Promise if initialization requires asynchronicity, otherwise the return value is undefined.
|
|
18
18
|
*/
|
|
19
|
-
resolveIfSingleton(
|
|
19
|
+
resolveIfSingleton(_asyncOnly) {
|
|
20
20
|
if (this.singleton === null) {
|
|
21
21
|
const s = this.provideAsState();
|
|
22
22
|
if (s.pending)
|
|
@@ -41,18 +41,23 @@ class Provider {
|
|
|
41
41
|
if (this.singleton) {
|
|
42
42
|
const s = this.provideAsState();
|
|
43
43
|
if (s.pending) {
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
return (async () => {
|
|
45
|
+
try {
|
|
46
|
+
const v = await s.promise;
|
|
47
|
+
this.singleton = null;
|
|
48
|
+
(0, utils_1.InvokeReleaseMethod)(v);
|
|
49
|
+
return v;
|
|
50
|
+
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
this.singleton = null;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
51
56
|
}
|
|
52
57
|
else {
|
|
53
58
|
this.singleton = null;
|
|
54
59
|
if ((!s.rejected) && s.fulfilled) {
|
|
55
|
-
(0,
|
|
60
|
+
(0, utils_1.InvokeReleaseMethod)(s.fulfilled);
|
|
56
61
|
return s.fulfilled;
|
|
57
62
|
}
|
|
58
63
|
return null;
|
package/lib/cjs/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";;;AACA,mCAA4C;AAG5C;;;GAGG;AACH,MAAsB,QAAQ;IAC7B;IACA,CAAC;IAiBD;;;;;;OAMG;IACH,kBAAkB,CAAC,UAAmB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Content":["import {State} from './state';\nimport {InvokeReleaseMethod} from './utils';\n\n\n/**\n * Internally all InjectableIds are mapped to an abstract Provider<T>.\n * A Provider may choose to return a singleton or a new value each time it is queried.\n */\nexport abstract class Provider<T = any> {\n\tprotected constructor() {\n\t}\n\n\t/**\n\t * If the provider is configured as a singleton, this property will be the state of that singleton.\n\t * This value will be defined for resolved/resolving Singletons, null for Singletons that have not yet been queried, and will remain undefined for non-Singleton Providers.\n\t * Default value is undefined (e.g. not a Singleton).\n\t */\n\tprotected singleton?: State<T> | null;\n\n\t/**\n\t * This is the workhorse method of the Provider, and is invoked directly or indirectly by both Injector.get and Injector.resolve.\n\t * This method returns the current State<T> if it is already known (which it might be for Singleton scenarios).\n\t * Otherwise it resolves the State<T>.\n\t * IF the Provider<T> is a Singleton, it's State<T> is updated before returning.\n\t */\n\tabstract provideAsState(): State<T>;\n\n\t/**\n\t * Base method to initialize the state of this Provider *if* (and only if) it has been configured as a Singleton.\n\t * If this Provider has not been configured as a singleton, this method is essentially a noop that returns undefined.\n\t *\n\t * @param _asyncOnly This default implementation ignores this parameter.\n\t * @returns A completion Promise if initialization requires asynchronicity, otherwise the return value is undefined.\n\t */\n\tresolveIfSingleton(_asyncOnly: boolean): Promise<T> | undefined {\n\t\tif (this.singleton === null) {\n\t\t\tconst s = this.provideAsState();\n\t\t\tif (s.pending)\n\t\t\t\treturn s.promise!;\n\t\t\telse if (s.rejected)\n\t\t\t\treturn Promise.reject(s.rejected);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * If (and only if) this Provider has been configured as a Singleton, and if it has been (or is being resolved), find and invoke the @Release decorated method (if there is one).\n\t * NOTE that if the singleton is actively being resolved when this method is called, this method waits for the resolution to complete and then invokes the @Release decorated method; But in any case this is a synchronous method and returns immediately to it's caller.\n\t * Also note that invoking this method does not release or invalidate the Provider;\n\t * Rather, it resets a Singleton Provider to a fresh (unresolved/unqueried) state (aka sets this.singleton to null).\n\t * It is assumed that the Singleton itself will no longer be used after this method returns.\n\t * If not a singleton, this method returns undefined.\n\t * If the singleton has been resolved, it is returned, otherwise null is returned.\n\t * If the singleton is pending resolution, a Promise for the singleton or for null is returned.\n\t * Note that if a singleton is returned, its Release method will already have been invoked.\n\t */\n\treleaseIfSingleton(): T | undefined | null | Promise<T | null> {\n\t\tif (this.singleton) {\n\t\t\tconst s = this.provideAsState();\n\t\t\tif (s.pending) {\n\t\t\t\treturn (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst v = await s.promise!;\n\t\t\t\t\t\tthis.singleton = null;\n\t\t\t\t\t\tInvokeReleaseMethod(v);\n\t\t\t\t\t\treturn v;\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tthis.singleton = null;\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.singleton = null;\n\t\t\t\tif ((!s.rejected) && s.fulfilled) {\n\t\t\t\t\tInvokeReleaseMethod(s.fulfilled);\n\t\t\t\t\treturn s.fulfilled;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
package/lib/cjs/state.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.State = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
/**
|
|
6
6
|
* Internal class that allows us to track the state of a promise (chain).
|
|
7
7
|
*/
|
|
8
8
|
class State {
|
|
9
9
|
static MakeState(promise, rejected, fulfilled) {
|
|
10
10
|
const retVal = new State();
|
|
11
|
-
if ((0,
|
|
11
|
+
if ((0, utils_1.isPromise)(promise)) {
|
|
12
12
|
retVal._pending = true;
|
|
13
13
|
retVal._promise = promise.then((v) => {
|
|
14
14
|
retVal._fulfilled = v;
|
package/lib/cjs/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAElC;;GAEG;AACH,MAAa,KAAK;IACjB,MAAM,CAAC,SAAS,CAAe,OAA+B,EAAE,QAAkB,EAAE,SAAkB;QACrG,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,IAAI,IAAA,iBAAS,EAAC,OAAO,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;YACvB,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAC7B,CAAC,CAAC,EAAE,EAAE;gBACL,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;gBACtB,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACxB,OAAO,CAAC,CAAC;YACV,CAAC,EACD,CAAC,CAAM,EAAE,EAAE;gBACV,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;gBACrB,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACxB,MAAM,CAAC,CAAC;YACT,CAAC,CACD,CAAC;QACH,CAAC;aACI,CAAC;YACL,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACd,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC7B,CAAC;iBACI,CAAC;gBACL,MAAM,CAAC,UAAU,GAAG,SAAmB,CAAC;YACzC,CAAC;YACD,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACxB,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;IACA,CAAC;IAID,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAID,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAID,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAID,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;CACD;AAzDD,sBAyDC","sourcesContent":["import {isPromise} from './utils';\n\n/**\n * Internal class that allows us to track the state of a promise (chain).\n */\nexport class State<T = any> {\n\tstatic MakeState<TState = any>(promise: Promise<TState> | null, rejected?: unknown, fulfilled?: TState): State<TState> {\n\t\tconst retVal = new State<TState>();\n\t\tif (isPromise(promise)) {\n\t\t\tretVal._pending = true;\n\t\t\tretVal._promise = promise.then(\n\t\t\t\t(v) => {\n\t\t\t\t\tretVal._fulfilled = v;\n\t\t\t\t\tretVal._pending = false;\n\t\t\t\t\treturn v;\n\t\t\t\t},\n\t\t\t\t(e: any) => {\n\t\t\t\t\tretVal._rejected = e;\n\t\t\t\t\tretVal._pending = false;\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\telse {\n\t\t\tretVal._pending = false;\n\t\t\tif (rejected) {\n\t\t\t\tretVal._rejected = rejected;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tretVal._fulfilled = fulfilled as TState;\n\t\t\t}\n\t\t\tretVal._promise = null;\n\t\t}\n\t\treturn retVal;\n\t}\n\n\tprotected constructor() {\n\t}\n\n\tprotected _promise!: Promise<T> | null;\n\n\tget promise(): Promise<T> | null {\n\t\treturn this._promise;\n\t}\n\n\tprotected _pending!: boolean;\n\n\tget pending(): boolean {\n\t\treturn this._pending;\n\t}\n\n\tprotected _fulfilled!: T;\n\n\tget fulfilled(): T {\n\t\treturn this._fulfilled;\n\t}\n\n\tprotected _rejected: unknown;\n\n\tget rejected(): unknown {\n\t\treturn this._rejected;\n\t}\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FactoryBasedProvider = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const bindable_provider_1 = require("./bindable-provider");
|
|
5
|
+
const state_1 = require("./state");
|
|
6
6
|
/**
|
|
7
7
|
* @inheritDoc
|
|
8
8
|
* This specialization simply invokes it's configured Factory and provides the result.
|
|
9
9
|
*/
|
|
10
|
-
class FactoryBasedProvider extends
|
|
10
|
+
class FactoryBasedProvider extends bindable_provider_1.BindableProvider {
|
|
11
11
|
constructor(injector, id, maker) {
|
|
12
12
|
super(injector, id, maker);
|
|
13
13
|
}
|
|
@@ -19,17 +19,17 @@ class FactoryBasedProvider extends bindable_provider_js_1.BindableProvider {
|
|
|
19
19
|
let retVal = this.singleton;
|
|
20
20
|
if (!retVal) {
|
|
21
21
|
try {
|
|
22
|
-
retVal =
|
|
22
|
+
retVal = state_1.State.MakeState(null, undefined, this.maker(this.injector));
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
|
25
25
|
// There was an error, give the errorHandler (if any) a crack at recovery.
|
|
26
26
|
try {
|
|
27
|
-
// queryErrorHandler will throw if it could not
|
|
28
|
-
retVal =
|
|
27
|
+
// queryErrorHandler will throw if it could not get a substitute object.
|
|
28
|
+
retVal = state_1.State.MakeState(null, undefined, this.queryErrorHandler(err));
|
|
29
29
|
}
|
|
30
30
|
catch (e) {
|
|
31
31
|
// could not recover, propagate the error.
|
|
32
|
-
retVal =
|
|
32
|
+
retVal = state_1.State.MakeState(null, e, undefined);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-factory-provider.js","sourceRoot":"","sources":["../../src/sync-factory-provider.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"sync-factory-provider.js","sourceRoot":"","sources":["../../src/sync-factory-provider.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAGrD,mCAA8B;AAE9B;;;GAGG;AACH,MAAa,oBAAwB,SAAQ,oCAAmC;IAC/E,YAAY,QAAkB,EAAE,EAAmB,EAAE,KAAqB;QACzE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,cAAc;QACb,IAAI,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,IAAI,CAAC;gBACJ,MAAM,GAAG,aAAK,CAAC,SAAS,CAAI,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,CAAC;YACD,OAAO,GAAG,EAAE,CAAC;gBACZ,0EAA0E;gBAC1E,IAAI,CAAC;oBACJ,wEAAwE;oBACxE,MAAM,GAAG,aAAK,CAAC,SAAS,CAAI,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC3E,CAAC;gBACD,OAAO,CAAC,EAAE,CAAC;oBACV,0CAA0C;oBAC1C,MAAM,GAAG,aAAK,CAAC,SAAS,CAAI,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;gBACjD,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;YAC1B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,SAAkB;QACpC,IAAI,SAAS;YACZ,OAAO,SAAS,CAAC;QAClB,OAAO,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACD;AAzCD,oDAyCC","sourcesContent":["import {BindableProvider} from './bindable-provider';\nimport {SyncFactory} from './binding';\nimport {InjectableId, Injector} from './injector';\nimport {State} from './state';\n\n/**\n * @inheritDoc\n * This specialization simply invokes it's configured Factory and provides the result.\n */\nexport class FactoryBasedProvider<T> extends BindableProvider<T, SyncFactory<T>> {\n\tconstructor(injector: Injector, id: InjectableId<T>, maker: SyncFactory<T>) {\n\t\tsuper(injector, id, maker);\n\t}\n\n\t/**\n\t * @inheritDoc\n\t * This specialization invokes it's configured Factory and provides the result (or invokes the error handler if necessary).\n\t */\n\tprovideAsState(): State<T> {\n\t\tlet retVal = this.singleton;\n\t\tif (!retVal) {\n\t\t\ttry {\n\t\t\t\tretVal = State.MakeState<T>(null, undefined, this.maker(this.injector));\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\t// There was an error, give the errorHandler (if any) a crack at recovery.\n\t\t\t\ttry {\n\t\t\t\t\t// queryErrorHandler will throw if it could not get a substitute object.\n\t\t\t\t\tretVal = State.MakeState<T>(null, undefined, this.queryErrorHandler(err));\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\t// could not recover, propagate the error.\n\t\t\t\t\tretVal = State.MakeState<T>(null, e, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.singleton === null)\n\t\t\tthis.singleton = retVal;\n\t\treturn retVal;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t * This specialization returns undefined anytime 'asyncOnly' is true (since this Provider is by definition synchronous).\n\t */\n\tresolveIfSingleton(asyncOnly: boolean): Promise<T> | undefined {\n\t\tif (asyncOnly)\n\t\t\treturn undefined;\n\t\treturn super.resolveIfSingleton(false);\n\t}\n}\n"]}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.isErrorObj = isErrorObj;
|
|
4
|
+
exports.isPromise = isPromise;
|
|
5
|
+
exports.InvokeReleaseMethod = InvokeReleaseMethod;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
6
7
|
/**
|
|
7
8
|
* Returns true if the specified object looks like a JavaScript Error object.
|
|
8
9
|
*/
|
|
@@ -11,9 +12,8 @@ function isErrorObj(err) {
|
|
|
11
12
|
return false;
|
|
12
13
|
if (err instanceof Error)
|
|
13
14
|
return true;
|
|
14
|
-
return err && typeof err.message === 'string' && typeof err.stack === 'string';
|
|
15
|
+
return !!(err && typeof err.message === 'string' && typeof err.stack === 'string');
|
|
15
16
|
}
|
|
16
|
-
exports.isErrorObj = isErrorObj;
|
|
17
17
|
/**
|
|
18
18
|
* Returns true if the specified value is "thenable" (aka a Promise).
|
|
19
19
|
*/
|
|
@@ -22,9 +22,8 @@ function isPromise(value) {
|
|
|
22
22
|
return false;
|
|
23
23
|
if (value instanceof Promise)
|
|
24
24
|
return true;
|
|
25
|
-
return value && typeof value.then === 'function';
|
|
25
|
+
return !!(value && typeof value.then === 'function');
|
|
26
26
|
}
|
|
27
|
-
exports.isPromise = isPromise;
|
|
28
27
|
/**
|
|
29
28
|
* Simple helper function to find the @Release decorated method of an object (if any), and invoke it.
|
|
30
29
|
* This is primarily an internal method as you probably know the exact method, and should invoke it yourself.
|
|
@@ -32,17 +31,15 @@ exports.isPromise = isPromise;
|
|
|
32
31
|
*/
|
|
33
32
|
function InvokeReleaseMethod(obj) {
|
|
34
33
|
var _a, _b;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (releaseMethod &&
|
|
38
|
-
const releaseFn = (_b = (_a =
|
|
34
|
+
const o = obj;
|
|
35
|
+
const releaseMethod = Reflect.getMetadata(constants_1.RELEASE_METADATA_KEY, o.constructor);
|
|
36
|
+
if (releaseMethod && o.constructor.prototype[releaseMethod] && typeof o.constructor.prototype[releaseMethod] === 'function') {
|
|
37
|
+
const releaseFn = (_b = (_a = o[releaseMethod]).bind) === null || _b === void 0 ? void 0 : _b.call(_a, o);
|
|
39
38
|
if (releaseFn) {
|
|
40
39
|
releaseFn();
|
|
41
40
|
return true;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
/* eslint-enable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
|
|
45
43
|
return false;
|
|
46
44
|
}
|
|
47
|
-
exports.InvokeReleaseMethod = InvokeReleaseMethod;
|
|
48
45
|
//# sourceMappingURL=utils.js.map
|
package/lib/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;AAKA,gCAQC;AAKD,8BAQC;AAOD,kDAWC;AA5CD,2CAAiD;AAEjD;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAQ;IAClC,IAAI,CAAC,GAAG;QACP,OAAO,KAAK,CAAC;IAEd,IAAI,GAAG,YAAY,KAAK;QACvB,OAAO,IAAI,CAAC;IAEb,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAI,KAAU;IACtC,IAAI,CAAC,KAAK;QACT,OAAO,KAAK,CAAC;IAEd,IAAI,KAAK,YAAY,OAAO;QAC3B,OAAO,IAAI,CAAC;IAEb,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAc,GAAM;;IACtD,MAAM,CAAC,GAAG,GAAU,CAAC;IACrB,MAAM,aAAa,GAAW,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,CAAC,CAAC,WAAW,CAAW,CAAC;IACjG,IAAI,aAAa,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,UAAU,EAAE,CAAC;QAC7H,MAAM,SAAS,GAAG,MAAA,MAAA,CAAC,CAAC,aAAa,CAAC,EAAC,IAAI,mDAAG,CAAC,CAAC,CAAC;QAC7C,IAAI,SAAS,EAAE,CAAC;YACf,SAAS,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import {RELEASE_METADATA_KEY} from './constants';\n\n/**\n * Returns true if the specified object looks like a JavaScript Error object.\n */\nexport function isErrorObj(err: any): err is Error {\n\tif (!err)\n\t\treturn false;\n\n\tif (err instanceof Error)\n\t\treturn true;\n\n\treturn !!(err && typeof err.message === 'string' && typeof err.stack === 'string');\n}\n\n/**\n * Returns true if the specified value is \"thenable\" (aka a Promise).\n */\nexport function isPromise<T>(value: any): value is Promise<T> {\n\tif (!value)\n\t\treturn false;\n\n\tif (value instanceof Promise)\n\t\treturn true;\n\n\treturn !!(value && typeof value.then === 'function');\n}\n\n/**\n * Simple helper function to find the @Release decorated method of an object (if any), and invoke it.\n * This is primarily an internal method as you probably know the exact method, and should invoke it yourself.\n * async-injection uses this helper to allow Singletons to clean up any non-garbage-collectable resources they may have allocated.\n */\nexport function InvokeReleaseMethod<T = unknown>(obj: T): boolean {\n\tconst o = obj as any;\n\tconst releaseMethod: string = Reflect.getMetadata(RELEASE_METADATA_KEY, o.constructor) as string;\n\tif (releaseMethod && o.constructor.prototype[releaseMethod] && typeof o.constructor.prototype[releaseMethod] === 'function') {\n\t\tconst releaseFn = o[releaseMethod].bind?.(o);\n\t\tif (releaseFn) {\n\t\t\treleaseFn();\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n"]}
|
package/lib/class-provider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BindableProvider } from './bindable-provider
|
|
2
|
-
import { ClassConstructor, InjectableId, Injector } from './injector
|
|
3
|
-
import { State } from './state
|
|
1
|
+
import { BindableProvider } from './bindable-provider';
|
|
2
|
+
import { ClassConstructor, InjectableId, Injector } from './injector';
|
|
3
|
+
import { State } from './state';
|
|
4
4
|
interface StateResolvingInjector extends Injector {
|
|
5
5
|
resolveState<T>(id: InjectableId<T>): State<T>;
|
|
6
6
|
}
|
|
@@ -18,13 +18,27 @@ export declare class ClassBasedProvider<T> extends BindableProvider<T, ClassCons
|
|
|
18
18
|
provideAsState(): State<T>;
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
|
-
* This specialization returns undefined if 'asyncOnly' is true and there is no asynchronous PostConstruct annotation (since class constructors can never by asynchronous)
|
|
21
|
+
* This specialization returns undefined if 'asyncOnly' is true **and** there is no asynchronous PostConstruct annotation (since class constructors can never by asynchronous),
|
|
22
|
+
* **unless** the @PostConstruct method has injectable parameters, which may themselves require async resolution.
|
|
22
23
|
*/
|
|
23
|
-
resolveIfSingleton(asyncOnly: boolean): Promise<T
|
|
24
|
+
resolveIfSingleton(asyncOnly: boolean): Promise<T> | undefined;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Returns true if the @PostConstruct method (if any) has at least one parameter.
|
|
27
|
+
* Any parameter may require async resolution, so this class must participate in resolveSingletons.
|
|
28
|
+
*/
|
|
29
|
+
private postConstructHasParams;
|
|
30
|
+
/**
|
|
31
|
+
* Make a resolved or pending State that reflects any @PostConstruct annotations and/or onSuccess handler.
|
|
32
|
+
* Any @PostConstruct method (with any injected parameters) runs first; the onSuccess handler runs after.
|
|
26
33
|
*/
|
|
27
34
|
protected makePostConstructState(obj: T): State<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Collects the resolved States for all injectable parameters of a @PostConstruct method.
|
|
37
|
+
* Uses the same resolution rules as constructor parameters: the reflected type (or an explicit @Inject token) is used to look up the binding, and an error is thrown if the type cannot be determined.
|
|
38
|
+
* Use @Optional() on a parameter to supply a fallback when no binding is found.
|
|
39
|
+
* Returns an empty array if the method has no parameters.
|
|
40
|
+
*/
|
|
41
|
+
protected getMethodParameterStates(ctor: Function, methodName: string): State[];
|
|
28
42
|
/**
|
|
29
43
|
* This method collects the States of all the constructor parameters for our target class.
|
|
30
44
|
*/
|
package/lib/container.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { AsyncFactory, BindAs,
|
|
2
|
-
import { AbstractConstructor, ClassConstructor, InjectableId, Injector } from './injector
|
|
3
|
-
import { Provider } from './provider
|
|
4
|
-
import { State } from './state
|
|
1
|
+
import { AsyncFactory, BindAs, RegisterDescriptor, SyncFactory } from './binding';
|
|
2
|
+
import { AbstractConstructor, ClassConstructor, InjectableId, Injector } from './injector';
|
|
3
|
+
import { Provider } from './provider';
|
|
4
|
+
import { State } from './state';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Injector (aka Container) to handle (a)synchronous dependency management.
|
|
7
7
|
*/
|
|
8
|
-
export declare class Container implements
|
|
9
|
-
protected parent?: Injector;
|
|
8
|
+
export declare class Container implements Injector {
|
|
9
|
+
protected parent?: Injector | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Create a new Container, with an optional parent Injector which will be searched if any given InjectableId is not bound within this Container.
|
|
12
12
|
*/
|
|
13
|
-
constructor(parent?: Injector);
|
|
13
|
+
constructor(parent?: Injector | undefined);
|
|
14
14
|
protected providers: Map<InjectableId<any>, Provider<any>>;
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
@@ -25,14 +25,40 @@ export declare class Container implements Binder {
|
|
|
25
25
|
*/
|
|
26
26
|
resolve<T>(id: InjectableId<T>): Promise<T>;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Removes a binding from this Container (and optionally its ancestor chain).
|
|
29
|
+
* Most useful in unit tests to replace or clear bindings between test cases.
|
|
30
|
+
* **Caution:** Removing a binding after initialization may have unexpected consequences if other parts of the application still hold or expect to obtain an instance of the removed id.
|
|
30
31
|
*
|
|
31
|
-
* @param id The id to
|
|
32
|
-
* @param ascending If true,
|
|
33
|
-
* @param releaseIfSingleton If true,
|
|
32
|
+
* @param id The id of the binding to remove.
|
|
33
|
+
* @param ascending If true, the binding is also removed from every Container in the parent chain.
|
|
34
|
+
* @param releaseIfSingleton If true, Provider.releaseIfSingleton is called before removal.
|
|
34
35
|
*/
|
|
35
36
|
removeBinding<T>(id: InjectableId<T>, ascending?: boolean, releaseIfSingleton?: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Alias for {@link isIdKnown}. Familiar to users migrating from TypeDI.
|
|
39
|
+
*/
|
|
40
|
+
has<T>(id: InjectableId<T>, ascending?: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Alias for {@link removeBinding}. Familiar to users migrating from InversifyJS.
|
|
43
|
+
*/
|
|
44
|
+
unbind<T>(id: InjectableId<T>, ascending?: boolean, releaseIfSingleton?: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new child Container that inherits unbound ids from this Container.
|
|
47
|
+
* Familiar to users migrating from TSyringe.
|
|
48
|
+
*/
|
|
49
|
+
createChildContainer(): Container;
|
|
50
|
+
/**
|
|
51
|
+
* Descriptor-based binding dispatching to the appropriate bindXXX method.
|
|
52
|
+
* Familiar to users migrating from TSyringe.
|
|
53
|
+
* Returns a {@link BindAs} chain for class and factory bindings; returns undefined for value bindings (which are always singletons).
|
|
54
|
+
*/
|
|
55
|
+
register<T>(id: InjectableId<T>, descriptor: RegisterDescriptor<T>): BindAs<T, any> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Binds a class as a singleton in one step.
|
|
58
|
+
* Shorthand for {@link bindClass}(...).{@link BindAs.asSingleton asSingleton}().
|
|
59
|
+
* Familiar to users migrating from TSyringe.
|
|
60
|
+
*/
|
|
61
|
+
registerSingleton<T>(id: InjectableId<T>, constructor: ClassConstructor<T>): void;
|
|
36
62
|
/**
|
|
37
63
|
* @inheritDoc
|
|
38
64
|
*/
|
|
@@ -61,18 +87,18 @@ export declare class Container implements Binder {
|
|
|
61
87
|
protected resolveState<T>(id: InjectableId<T>): State<T>;
|
|
62
88
|
/**
|
|
63
89
|
* Convenience method to assist in releasing non-garbage-collectable resources that Singletons in this Container may have allocated.
|
|
64
|
-
* It will walk through all registered Providers (of this Container only), and invoke their
|
|
65
|
-
* This method is not part of the
|
|
90
|
+
* It will walk through all registered Providers (of this Container only), and invoke their Provider.releaseIfSingleton method.
|
|
91
|
+
* This method is not part of the Injector interface, because you normally only create (and release) from Containers.
|
|
66
92
|
* NOTE:
|
|
67
93
|
* This *only* releases active/pending Singleton's that have already been created by this Container.
|
|
68
|
-
* The most likely use of this method would be when you have created a new child Container for a limited
|
|
94
|
+
* The most likely use of this method would be when you have created a new child Container for a limited-duration transaction, and you want to easily clean up temporary resources.
|
|
69
95
|
* For example, your service object may need to know when it should unsubscribe from an RxJs stream (failure to do so can result in your Singleton not being garbage collected at the end of a transaction).
|
|
70
96
|
* In theory, you could handle all unsubscription and cleanup yourself, but the @Release decorator and this method are meant to simply make that easier.
|
|
71
97
|
*/
|
|
72
98
|
releaseSingletons(): void;
|
|
73
99
|
/**
|
|
74
100
|
* Releases a Singleton instance if it exists.
|
|
75
|
-
* However, it does **not** remove the binding, so if you call
|
|
101
|
+
* However, it does **not** remove the binding, so if you call get or resolve (directly or indirectly) on the id, a new Singleton will be created.
|
|
76
102
|
* If not a singleton, this method returns undefined.
|
|
77
103
|
* If the singleton has been resolved, it is returned, otherwise null is returned.
|
|
78
104
|
* If the singleton is pending resolution, a Promise for the singleton (or for null) is returned.
|
|
@@ -80,7 +106,7 @@ export declare class Container implements Binder {
|
|
|
80
106
|
*/
|
|
81
107
|
releaseSingleton<T>(id: InjectableId<T>): T | undefined | null | Promise<T | null>;
|
|
82
108
|
/**
|
|
83
|
-
* Make a copy of this
|
|
109
|
+
* Make a copy of this Container.
|
|
84
110
|
* This is an experimental feature!
|
|
85
111
|
* I have not thought through all the dark corners, so use at your own peril!
|
|
86
112
|
* Here are some notes:
|
|
@@ -92,7 +118,7 @@ export declare class Container implements Binder {
|
|
|
92
118
|
* If released by the clone, they will be considered released by "this" container.
|
|
93
119
|
* If a singleton is currently being asynchronously constructed any callbacks will reference "this" Container, however both Containers should have no problem awaiting resolution.
|
|
94
120
|
* If a singleton is not resolved when the container is cloned, then if both containers resolve, you will create *two* "singletons".
|
|
95
|
-
* The way to avoid this last effect is to
|
|
121
|
+
* The way to avoid this last effect is to call resolveSingletons first
|
|
96
122
|
*/
|
|
97
123
|
clone(clazz?: ClassConstructor<Container>): Container;
|
|
98
124
|
}
|