X-Git-Url: https://git.josue.xyz/?p=VSoRC%2F.git;a=blobdiff_plain;f=node_modules%2Fxterm%2Fsrc%2Fcommon%2Fservices%2FServiceRegistry.ts;fp=node_modules%2Fxterm%2Fsrc%2Fcommon%2Fservices%2FServiceRegistry.ts;h=0000000000000000000000000000000000000000;hp=450af4924d872401d3166c05bdba4b5a5c6c0e1a;hb=5e96dd57ddd883604e87f62bdddcb111c63a6e1a;hpb=acb5f682a2b75b972710cabd81658f63071324b0 diff --git a/node_modules/xterm/src/common/services/ServiceRegistry.ts b/node_modules/xterm/src/common/services/ServiceRegistry.ts deleted file mode 100644 index 450af49..0000000 --- a/node_modules/xterm/src/common/services/ServiceRegistry.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - * - * This was heavily inspired from microsoft/vscode's dependency injection system (MIT). - */ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { IServiceIdentifier } from 'common/services/Services'; - -const DI_TARGET = 'di$target'; -const DI_DEPENDENCIES = 'di$dependencies'; - -export const serviceRegistry: Map> = new Map(); - -export function getServiceDependencies(ctor: any): { id: IServiceIdentifier, index: number, optional: boolean }[] { - return ctor[DI_DEPENDENCIES] || []; -} - -export function createDecorator(id: string): IServiceIdentifier { - if (serviceRegistry.has(id)) { - return serviceRegistry.get(id)!; - } - - const decorator = function (target: Function, key: string, index: number): any { - if (arguments.length !== 3) { - throw new Error('@IServiceName-decorator can only be used to decorate a parameter'); - } - - storeServiceDependency(decorator, target, index); - }; - - decorator.toString = () => id; - - serviceRegistry.set(id, decorator); - return decorator; -} - -function storeServiceDependency(id: Function, target: Function, index: number): void { - if ((target as any)[DI_TARGET] === target) { - (target as any)[DI_DEPENDENCIES].push({ id, index }); - } else { - (target as any)[DI_DEPENDENCIES] = [{ id, index }]; - (target as any)[DI_TARGET] = target; - } -}