import { ExtensionCategory } from '../constants';
import type { Loosen } from '../types';
import { EXTENSION_REGISTRY } from './store';
import type { ExtensionRegistry } from './types';
/**
* 根据类别和类型获取扩展
*
* Get the extension by category and type
* @param category - 扩展类别 | Extension category
* @param type - 扩展类型 | Extension type
* @returns 注册的扩展 | Registered extension
* @internal
*/
export function getExtension(
category: Loosen,
type: string,
): ExtensionRegistry[T][string] | undefined {
const extension = EXTENSION_REGISTRY[category]?.[type];
if (extension) {
return extension as ExtensionRegistry[T][string];
}
return undefined;
}
/**
* 根据类别获取扩展
*
* Get the extension by category and type
* @param category - 扩展类别 | Extension category
* @returns 注册的扩展 | Registered extension
* @internal
*/
export function getExtensions>(category: T): ExtensionRegistry[T] {
return EXTENSION_REGISTRY[category];
}