@wessberg/di
Version:
A compile-time powered Dependency-Injection container for Typescript that holds services and can produce instances of them as required.
1 lines • 18.6 kB
Source Map (JSON)
{"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/error.ts","../src/util.ts","../src/di-container.ts"],"sourcesContent":["export type {IDIContainer} from \"./type.js\";\nexport {DIContainer} from \"./di-container.js\";\nexport {CONSTRUCTOR_ARGUMENTS_SYMBOL, CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER} from \"./constant.js\";\n","export const CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER = `___CTOR_ARGS___`;\nexport const CONSTRUCTOR_ARGUMENTS_SYMBOL: unique symbol = Symbol.for(CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER);\nexport const DI_COMPILER_ERROR_HINT = `Note: You must use DI-Compiler (https://github.com/wessberg/di-compiler) for this library to work correctly. Please consult the readme for instructions on how to install and configure it for your project.`;\n","import type {Parent} from \"./type.js\";\n\nexport interface InstantiationErrorOptions extends Partial<ErrorOptions> {\n\treadonly identifier: string;\n\treadonly parentChain?: (string | Parent<unknown>)[];\n}\n\ninterface ErrorLike {\n\treadonly message: string | undefined;\n\treadonly stack?: string;\n}\n\nexport class InstantiationError extends TypeError {\n\treadonly #name = \"InstantiationError\";\n\treadonly #originalError: ErrorLike;\n\treadonly #identifier: string;\n\treadonly #parentChain: string[];\n\n\tget [Symbol.toStringTag]() {\n\t\treturn this.#name;\n\t}\n\n\tconstructor(error: unknown, {identifier, parentChain, ...options}: InstantiationErrorOptions) {\n\t\tconst message =\n\t\t\ttypeof error === \"string\"\n\t\t\t\t? error\n\t\t\t\t: error instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: typeof error === \"object\" && error != null && \"message\" in error && typeof error.message === \"string\"\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: undefined;\n\n\t\tconst stack =\n\t\t\ttypeof error === \"string\"\n\t\t\t\t? undefined\n\t\t\t\t: error instanceof Error\n\t\t\t\t\t? error.stack\n\t\t\t\t\t: typeof error === \"object\" && error != null && \"stack\" in error && typeof error.stack === \"string\"\n\t\t\t\t\t\t? error.stack\n\t\t\t\t\t\t: undefined;\n\n\t\tconst originalError = error instanceof Error ? error : {message, stack};\n\n\t\tsuper(message, options);\n\n\t\tthis.#identifier = identifier;\n\t\tthis.#originalError = originalError;\n\t\tthis.#parentChain = parentChain != null && parentChain.length > 0 ? parentChain.map(item => (typeof item === \"string\" ? item : item.identifier)) : [this.#identifier];\n\t\tthis.name = this[Symbol.toStringTag];\n\n\t\tlet currentOriginalError = this.#originalError;\n\t\twhile (currentOriginalError instanceof InstantiationError) {\n\t\t\tcurrentOriginalError = currentOriginalError.#originalError;\n\t\t}\n\n\t\tconst lastService = this.#parentChain[this.#parentChain.length - 1]!;\n\t\tconst head = `Could not instantiate service: '${lastService}'`;\n\t\tconst body = currentOriginalError.message == null || currentOriginalError.message.length < 1 ? \"\" : `: ${currentOriginalError.message}`;\n\t\tconst tail = this.#parentChain.length > 1 ? ` Dependency chain: ${this.#parentChain.join(\" -> \")}` : \"\";\n\n\t\tthis.message = `${head}${body}${tail}`;\n\n\t\tif (currentOriginalError.stack != null) {\n\t\t\tthis.stack = currentOriginalError.stack;\n\t\t}\n\t}\n}\n","import type {CustomConstructableService, NewableService} from \"./type.js\";\n\nexport function isClass<T>(item: unknown): item is NewableService<T> {\n\t// First, ensure the input is a function\n\tif (typeof item !== \"function\") {\n\t\treturn false;\n\t}\n\n\t// Get the property descriptor for 'prototype'\n\tconst descriptor = Object.getOwnPropertyDescriptor(item, \"prototype\");\n\n\t// Classes do not have a writable 'prototype' property\n\t// If 'prototype' is non-writable, it's likely a class constructor\n\treturn !!descriptor && !descriptor.writable;\n}\n\nexport function isCustomConstructableService<T>(item: unknown): item is CustomConstructableService<T> {\n\treturn !isClass(item) && typeof item === \"function\";\n}\n","import {CONSTRUCTOR_ARGUMENTS_SYMBOL, DI_COMPILER_ERROR_HINT} from \"./constant.js\";\nimport {InstantiationError} from \"./error.js\";\n\nimport type {\n\tIDIContainer,\n\tRegistrationRecord,\n\tImplementationInstance,\n\tRegistrationKind,\n\tConstructorArgument,\n\tRegisterOptionsWithoutImplementation,\n\tRegisterOptions,\n\tRegisterOptionsWithImplementation,\n\tGetOptions,\n\tHasOptions,\n\tConstructInstanceOptions,\n\tParent\n} from \"./type.js\";\nimport {isClass, isCustomConstructableService} from \"./util.js\";\n\n/**\n * A Dependency-Injection container that holds services and can produce instances of them as required.\n * It mimics reflection by parsing the app at compile-time and supporting the generic-reflection syntax.\n * @author Frederik Wessberg\n */\nexport class DIContainer implements IDIContainer {\n\tget [Symbol.toStringTag]() {\n\t\treturn \"DIContainer\";\n\t}\n\n\t/**\n\t * A map between interface names and the services that should be dependency injected\n\t */\n\treadonly #constructorArguments = new Map<string, ConstructorArgument[]>();\n\t/**\n\t * A Map between identifying names for services and their IRegistrationRecords.\n\t */\n\treadonly #serviceRegistry = new Map<string, RegistrationRecord<unknown>>();\n\n\t/**\n\t * A map between identifying names for services and concrete instances of their implementation.\n\t */\n\treadonly #instances = new Map<string, unknown>();\n\n\t/**\n\t * Registers a service that will be instantiated once in the application lifecycle. All requests\n\t * for the service will retrieve the same instance of it.\n\t *\n\t * You should not pass any options to the method if using the compiler. It will do that automatically.\n\t */\n\tregisterSingleton<T, U extends T = T>(newExpression: ImplementationInstance<U>, options: RegisterOptionsWithoutImplementation): void;\n\tregisterSingleton<T, U extends T = T>(newExpression: undefined, options: RegisterOptionsWithImplementation<U>): void;\n\tregisterSingleton<T, U extends T = T>(newExpression?: ImplementationInstance<U>, options?: RegisterOptions<U>): void;\n\tregisterSingleton<T, U extends T = T>(newExpression?: ImplementationInstance<U>, options?: RegisterOptions<U>): void {\n\t\tif (options == null) {\n\t\t\tthrow new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);\n\t\t}\n\t\tif (newExpression == null) {\n\t\t\treturn this.#register(\"SINGLETON\", newExpression, options as RegisterOptionsWithImplementation<U>);\n\t\t} else {\n\t\t\treturn this.#register(\"SINGLETON\", newExpression, options);\n\t\t}\n\t}\n\n\t/**\n\t * Registers a service that will be instantiated every time it is requested throughout the application lifecycle.\n\t * This means that every call to get() will return a unique instance of the service.\n\t *\n\t * You should not pass any options to the method if using the compiler. It will do that automatically.\n\t */\n\tregisterTransient<T, U extends T = T>(newExpression: ImplementationInstance<U>, options: RegisterOptionsWithoutImplementation): void;\n\tregisterTransient<T, U extends T = T>(newExpression: undefined, options: RegisterOptionsWithImplementation<U>): void;\n\tregisterTransient<T, U extends T = T>(newExpression?: ImplementationInstance<U>, options?: RegisterOptions<U>): void;\n\tregisterTransient<T, U extends T = T>(newExpression?: ImplementationInstance<U>, options?: RegisterOptions<U>): void {\n\t\tif (options == null) {\n\t\t\tthrow new ReferenceError(`2 arguments required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);\n\t\t}\n\t\tif (newExpression == null) {\n\t\t\treturn this.#register(\"TRANSIENT\", newExpression, options as RegisterOptionsWithImplementation<U>);\n\t\t} else {\n\t\t\treturn this.#register(\"TRANSIENT\", newExpression, options);\n\t\t}\n\t}\n\n\t/**\n\t * Gets an instance of the service matching the interface given as a generic type parameter.\n\t * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the\n\t * generic interface name.\n\t *\n\t * You should not pass any options to the method if using the compiler. It will do that automatically.\n\t */\n\tget<T>(options?: GetOptions): T {\n\t\tif (options == null) {\n\t\t\tthrow new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);\n\t\t}\n\n\t\tif (!this.has(options)) {\n\t\t\tthrow new InstantiationError(`The service wasn't found in the registry.`, {identifier: options.identifier});\n\t\t}\n\n\t\treturn this.#constructInstance<T>(options)!;\n\t}\n\n\t/**\n\t * Returns true if a service has been registered matching the interface given as a generic type parameter.\n\t * For example, 'container.get<IFoo>()' returns a concrete instance of the implementation associated with the\n\t * generic interface name.\n\t *\n\t * You should not pass any options to the method if using the compiler. It will do that automatically.\n\t */\n\t// @ts-expect-error The 'T' type parameter is required for compile-time reflection, even though it is not part of the signature.\n\thas<T>(options?: HasOptions): boolean {\n\t\tif (options == null) {\n\t\t\tthrow new ReferenceError(`1 argument required, but only 0 present. ${DI_COMPILER_ERROR_HINT}`);\n\t\t}\n\t\treturn this.#serviceRegistry.has(options.identifier);\n\t}\n\n\t/**\n\t * Registers a service\n\t */\n\t#register<T, U extends T = T>(kind: RegistrationKind, newExpression: ImplementationInstance<U>, options: RegisterOptionsWithoutImplementation): void;\n\t#register<T, U extends T = T>(kind: RegistrationKind, newExpression: undefined, options: RegisterOptionsWithImplementation<U>): void;\n\t#register<T, U extends T = T>(kind: RegistrationKind, newExpression: ImplementationInstance<U> | undefined, options: RegisterOptions<U>): void {\n\t\t// Take all of the constructor arguments for the implementation\n\t\tconst implementationArguments =\n\t\t\t\"implementation\" in options && options.implementation?.[CONSTRUCTOR_ARGUMENTS_SYMBOL] != null ? options.implementation[CONSTRUCTOR_ARGUMENTS_SYMBOL] : [];\n\t\tthis.#constructorArguments.set(options.identifier, implementationArguments);\n\n\t\tthis.#serviceRegistry.set(\n\t\t\toptions.identifier,\n\t\t\t\"implementation\" in options && options.implementation != null ? {...options, kind} : {...options, kind, newExpression: newExpression!}\n\t\t);\n\t}\n\n\t/**\n\t * Returns true if an instance exists that matches the given identifier.\n\t */\n\t#hasInstance(identifier: string): boolean {\n\t\treturn this.#getInstance(identifier) != null;\n\t}\n\n\t/**\n\t * Gets the cached instance, if any, associated with the given identifier.\n\t */\n\t#getInstance<T>(identifier: string): T | null {\n\t\tconst instance = this.#instances.get(identifier);\n\t\treturn instance == null ? null : (instance as T);\n\t}\n\n\t/**\n\t * Gets an IRegistrationRecord associated with the given identifier.\n\t */\n\t#getRegistrationRecord<T>(identifier: string): RegistrationRecord<T> | undefined {\n\t\treturn this.#serviceRegistry.get(identifier) as RegistrationRecord<T> | undefined;\n\t}\n\n\t/**\n\t * Caches the given instance so that it can be retrieved in the future.\n\t */\n\t#setInstance<T>(identifier: string, instance: T): T {\n\t\tthis.#instances.set(identifier, instance);\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Gets a lazy reference to another service\n\t */\n\t#getLazyIdentifier<T>(lazyPointer: () => T): T {\n\t\treturn new Proxy({}, {get: (_, key: keyof T & string) => lazyPointer()[key]}) as T;\n\t}\n\n\t/**\n\t * Constructs a new instance of the given identifier and returns it.\n\t * It checks the constructor arguments and injects any services it might depend on recursively.\n\t */\n\t#constructInstance<T>({identifier, parentChain = []}: ConstructInstanceOptions): T | undefined {\n\t\tconst registrationRecord = this.#getRegistrationRecord(identifier);\n\n\t\tif (registrationRecord == null) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// If an instance already exists (and it is a singleton), return that one\n\t\tif (this.#hasInstance(identifier) && registrationRecord.kind === \"SINGLETON\") {\n\t\t\treturn this.#getInstance(identifier) as T;\n\t\t}\n\n\t\t// Otherwise, instantiate a new one\n\t\tlet instance: T;\n\n\t\tconst me: Parent<T> = {\n\t\t\tidentifier,\n\t\t\tref: this.#getLazyIdentifier(() => instance)\n\t\t};\n\n\t\tconst implementation = \"newExpression\" in registrationRecord ? registrationRecord.newExpression : registrationRecord.implementation;\n\n\t\tif (isClass<T>(implementation)) {\n\t\t\t// Find the arguments for the identifier\n\t\t\tconst mappedArgs = this.#constructorArguments.get(identifier);\n\t\t\tif (mappedArgs == null) {\n\t\t\t\tthrow new InstantiationError(`Could not find constructor arguments. Have you registered it as a service?`, {identifier, parentChain});\n\t\t\t}\n\n\t\t\t// Instantiate all of the argument services (or re-use them if they were registered as singletons)\n\t\t\tconst instanceArgs = mappedArgs.map(dep => {\n\t\t\t\tif (dep === undefined) return undefined;\n\t\t\t\tconst matchedParent = parentChain.find(parent => parent.identifier === dep);\n\t\t\t\tif (matchedParent != null) return matchedParent.ref;\n\t\t\t\tconst nextParentChain = [...parentChain, me];\n\t\t\t\tconst constructedInstance = this.#constructInstance<T>({\n\t\t\t\t\tidentifier: dep,\n\t\t\t\t\tparentChain: nextParentChain\n\t\t\t\t});\n\n\t\t\t\tif (constructedInstance == null) {\n\t\t\t\t\tthrow new InstantiationError(`Dependency '${dep}' was not found in the service registry.`, {identifier: me.identifier, parentChain: nextParentChain});\n\t\t\t\t}\n\n\t\t\t\treturn constructedInstance;\n\t\t\t});\n\n\t\t\tinstance = new implementation(...instanceArgs);\n\t\t} else if (isCustomConstructableService<T>(implementation)) {\n\t\t\tinstance = implementation();\n\t\t} else {\n\t\t\tthrow new InstantiationError(`No implementation was given!`, {identifier, parentChain});\n\t\t}\n\n\t\treturn registrationRecord.kind === \"SINGLETON\" ? this.#setInstance<T>(identifier, instance) : instance;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,0CAA0C;AAChD,IAAM,+BAA8C,OAAO,IAAI,uCAAuC;AACtG,IAAM,yBAAyB;;;ACU/B,IAAM,qBAAN,MAAM,4BAA2B,UAAU;AAAA,EACxC,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EAET,KAAK,OAAO,WAAW,IAAI;AAC1B,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,YAAY,OAAgB,EAAC,YAAY,aAAa,GAAG,QAAO,GAA8B;AAC7F,UAAM,UACL,OAAO,UAAU,WACd,QACA,iBAAiB,QAChB,MAAM,UACN,OAAO,UAAU,YAAY,SAAS,QAAQ,aAAa,SAAS,OAAO,MAAM,YAAY,WAC5F,MAAM,UACN;AAEN,UAAM,QACL,OAAO,UAAU,WACd,SACA,iBAAiB,QAChB,MAAM,QACN,OAAO,UAAU,YAAY,SAAS,QAAQ,WAAW,SAAS,OAAO,MAAM,UAAU,WACxF,MAAM,QACN;AAEN,UAAM,gBAAgB,iBAAiB,QAAQ,QAAQ,EAAC,SAAS,MAAK;AAEtE,UAAM,SAAS,OAAO;AAEtB,SAAK,cAAc;AACnB,SAAK,iBAAiB;AACtB,SAAK,e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