@boundaries/elements 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Support/TypeGuards.ts","../src/Support/Paths.ts","../src/Config/Config.ts","../src/Matcher/BaseElementsMatcher.ts","../src/Matcher/MatcherHelpers.ts","../src/Matcher/DependenciesMatcher.ts","../src/Matcher/ElementsMatcher.ts","../src/Descriptor/ElementsDescriptor.types.ts","../src/Descriptor/ElementsDescriptorHelpers.ts","../src/Descriptor/DependenciesDescriptor.types.ts","../src/Descriptor/DependenciesDescriptorHelpers.ts","../src/Cache/Cache.ts","../src/Cache/CacheDisabled.ts","../src/Descriptor/DependenciesDescriptionsCache.ts","../src/Descriptor/DependenciesDescriptor.ts","../src/Descriptor/ElementsDescriptor.ts","../src/Descriptor/Descriptors.ts","../src/Matcher/Matcher.ts","../src/Matcher/Micromatch.ts","../src/MatchersCache.ts","../src/Elements.ts"],"sourcesContent":["export * from \"./Elements\";\nexport * from \"./Elements.types\";\n\nexport * from \"./Matcher/Public\";\nexport * from \"./Descriptor/Public\";\nexport * from \"./Config/Public\";\n\nexport * from \"./Cache/Public\";\n","/**\n * Determines if the given value is a string.\n * @param value The value to check.\n * @returns True if the value is a string, false otherwise.\n */\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\n/**\n * Determines if the given value is undefined.\n * @param value The value to check.\n * @returns True if the value is undefined, false otherwise.\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined;\n}\n\n/**\n * Determines if the given value is null\n * @param value The value to check\n * @returns True if the value is null, false otherwise\n */\nexport function isNull(value: unknown): value is null {\n return value === null;\n}\n\n/**\n * Determines if the given value is not null or undefined.\n * @param value The value to check.\n * @returns True if the value is not null or undefined, false otherwise.\n */\nexport function isNullish(value: unknown): value is null | undefined {\n return isUndefined(value) || isNull(value);\n}\n\n/**\n * Determines if the given value is a boolean\n * @param value The value to check\n * @returns True if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\n/**\n * Determines if the given value is a non-null object.\n * @param value The value to check.\n * @returns True if the value is a non-null object, false otherwise.\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return (\n !isNullish(value) &&\n !isBoolean(value) &&\n !isArray(value) &&\n typeof value === \"object\"\n );\n}\n\n/**\n * Determines if the given object is an empty object.\n * @param obj The object to check.\n * @returns True if the object is empty, false otherwise.\n */\nexport function isEmptyObject(obj: unknown): boolean {\n return isObject(obj) && Object.keys(obj).length === 0;\n}\n\n/**\n * Determines if the given value is an array.\n * @param value The value to check.\n * @returns True if the value is an array, false otherwise.\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/**\n * Determines if the given array is empty\n * @param arr The array to check\n * @returns Whether the array is empty or not\n */\nexport function isEmptyArray(arr: unknown[]): arr is [] {\n return arr.length === 0;\n}\n\n/**\n * Determines if the given value is a string array.\n * @param value The value to check.\n * @returns True if the value is a string array, false otherwise.\n */\nexport function isStringArray(value: unknown): value is string[] {\n return isArray(value) && value.every(isString);\n}\n\n/**\n * Determines if the given value is an object with the specified property.\n * @param value The value to check.\n * @param key The property key to check for.\n * @returns True if the value is an object with the specified property, false otherwise.\n */\nexport function isObjectWithProperty<Key extends string>(\n value: unknown,\n key: Key\n): value is Record<Key, unknown> & Record<string, unknown> {\n return isObject(value) && Object.hasOwn(value, key);\n}\n\n/**\n * Determines if the given value is an object with any of the specified properties.\n * @param value The value to check\n * @param keys The keys to check for\n * @returns True if the value is an object with any of the specified properties, false otherwise\n */\nexport function isObjectWithAnyOfProperties<Keys extends string>(\n value: unknown,\n keys: Keys[]\n): value is Record<Keys, unknown> & Record<string, unknown> {\n return isObject(value) && keys.some((key) => key in value);\n}\n","/**\n * Normalizes a file path by replacing backslashes with forward slashes.\n * @param filePath The file path to normalize.\n * @returns The normalized file path.\n */\nexport function normalizePath(filePath: string): string {\n return filePath.replaceAll(\"\\\\\", \"/\");\n}\n","import { normalizePath } from \"../Support\";\n\nimport type {\n ConfigOptions,\n MicromatchPattern,\n ConfigOptionsNormalized,\n DescriptorOptionsNormalized,\n MatchersOptionsNormalized,\n FlagAsExternalOptionsNormalized,\n} from \"./Config.types\";\n\nexport class Config {\n /** The ignore paths */\n private readonly _ignorePaths?: MicromatchPattern;\n /** The include paths */\n private readonly _includePaths?: MicromatchPattern;\n /** Whether legacy template support is enabled */\n private readonly _legacyTemplates: boolean;\n /** Whether the cache is enabled */\n private readonly _cache: boolean;\n /** Configuration for categorizing dependencies as external or local */\n private readonly _flagAsExternal: FlagAsExternalOptionsNormalized;\n /** Root path of the project */\n private readonly _rootPath?: string;\n /**\n * Creates a new Config instance\n * @param options Configuration options\n */\n constructor(options?: ConfigOptions) {\n this._ignorePaths = options?.ignorePaths;\n this._includePaths = options?.includePaths;\n this._legacyTemplates = options?.legacyTemplates ?? true;\n this._cache = options?.cache ?? true;\n this._flagAsExternal = {\n unresolvableAlias: options?.flagAsExternal?.unresolvableAlias ?? true,\n inNodeModules: options?.flagAsExternal?.inNodeModules ?? true,\n outsideRootPath: options?.flagAsExternal?.outsideRootPath ?? false,\n customSourcePatterns: options?.flagAsExternal?.customSourcePatterns ?? [],\n };\n if (options?.rootPath) {\n const normalizedRoot = normalizePath(options.rootPath);\n this._rootPath = normalizedRoot.endsWith(\"/\")\n ? normalizedRoot\n : `${normalizedRoot}/`;\n } else {\n this._rootPath = undefined;\n }\n }\n\n /**\n * The normalized configuration options\n */\n public get options(): ConfigOptionsNormalized {\n return {\n ignorePaths: this._ignorePaths,\n includePaths: this._includePaths,\n legacyTemplates: this._legacyTemplates,\n cache: this._cache,\n flagAsExternal: this._flagAsExternal,\n rootPath: this._rootPath,\n };\n }\n\n /**\n * Normalized options for descriptors\n */\n public get descriptorOptions(): DescriptorOptionsNormalized {\n return {\n ignorePaths: this._ignorePaths,\n includePaths: this._includePaths,\n cache: this._cache,\n flagAsExternal: this._flagAsExternal,\n rootPath: this._rootPath,\n };\n }\n\n /**\n * Normalized options for element matchers\n */\n public get matchersOptions(): MatchersOptionsNormalized {\n return {\n legacyTemplates: this._legacyTemplates,\n };\n }\n\n /**\n * Whether caching is enabled\n */\n public get cache(): boolean {\n return this._cache;\n }\n}\n","import Handlebars from \"handlebars\";\n\nimport type {\n MicromatchPatternNullable,\n MatchersOptionsNormalized,\n} from \"../Config\";\nimport type { BaseElementDescription } from \"../Descriptor\";\nimport {\n isArray,\n isObjectWithProperty,\n isString,\n isBoolean,\n isNull,\n isUndefined,\n} from \"../Support\";\n\nimport type {\n BaseElementSelectorData,\n TemplateData,\n SelectableElement,\n} from \"./Matcher.types\";\nimport type { Micromatch } from \"./Micromatch\";\n\nconst LEGACY_TEMPLATE_REGEX = /\\$\\{([^}]+)\\}/g;\nconst HANDLEBARS_TEMPLATE_REGEX = /{{\\s*[^{}\\s][^{}]*}}/;\n\n/**\n * Base matcher class to determine if elements or dependencies match a given selector.\n */\nexport class BaseElementsMatcher {\n /**\n * Option to use legacy templates with ${} syntax.\n */\n protected readonly _legacyTemplates: boolean;\n\n /**\n * Micromatch instance for matching.\n */\n protected micromatch: Micromatch;\n\n /**\n * Creates a new BaseElementsMatcher.\n * @param config Configuration options for the matcher.\n * @param globalCache Global cache instance.\n */\n constructor(config: MatchersOptionsNormalized, micromatch: Micromatch) {\n this.micromatch = micromatch;\n this._legacyTemplates = config.legacyTemplates;\n }\n\n /**\n * Converts a template with ${} to Handlebars {{}} templates for backwards compatibility.\n * @param template The template to convert.\n * @returns The converted template.\n */\n private _getBackwardsCompatibleTemplate(\n template: string | null\n ): string | null {\n if (!template) {\n return template;\n }\n return template.replaceAll(LEGACY_TEMPLATE_REGEX, \"{{ $1 }}\");\n }\n\n /**\n * Determines if a template contains Handlebars syntax.\n * @param template The template to check.\n * @returns True if the template contains Handlebars syntax, false otherwise.\n */\n private _isHandlebarsTemplate(template: string | null): boolean {\n if (!template) {\n return false;\n }\n return HANDLEBARS_TEMPLATE_REGEX.test(template);\n }\n\n /**\n * Returns a rendered template using the provided template data.\n * Optimized version with template caching for better performance.\n * @param template The template to render.\n * @param templateData The data to use for replace in the template.\n * @returns The rendered template.\n */\n private _getRenderedTemplate(\n template: string | null,\n templateData: TemplateData\n ): string | null {\n const templateToUse = this._legacyTemplates\n ? this._getBackwardsCompatibleTemplate(template)\n : template;\n if (!this._isHandlebarsTemplate(templateToUse)) {\n // If the template does not contain any Handlebars syntax, return it as is.\n return template;\n }\n\n const compiledTemplate = Handlebars.compile(templateToUse);\n\n return compiledTemplate(templateData);\n }\n\n /**\n * Returns rendered templates using the provided template data.\n * @param template The templates to render.\n * @param extraTemplateData The data to use for replace in the templates.\n * @returns The rendered templates.\n */\n protected getRenderedTemplates(\n template: MicromatchPatternNullable,\n templateData: TemplateData\n ): MicromatchPatternNullable {\n if (isArray(template)) {\n return template.map((temp) => {\n return this._getRenderedTemplate(temp, templateData);\n });\n }\n return this._getRenderedTemplate(template, templateData);\n }\n\n /**\n * Cleans a micromatch pattern by removing falsy values from arrays.\n * @param pattern The micromatch pattern(s) to clean.\n * @returns The cleaned pattern. If an array is provided, falsy entries are removed and the resulting array may be empty. If null is provided, null is returned unchanged.\n */\n protected cleanMicromatchPattern(\n pattern: MicromatchPatternNullable\n ): string | string[] | null {\n return isArray(pattern) ? (pattern.filter(Boolean) as string[]) : pattern;\n }\n\n /**\n * Returns whether the given value matches the micromatch pattern, converting non-string values to strings.\n * Optimized version with caching for better performance.\n * @param value The value to check.\n * @param pattern The micromatch pattern to match against.\n * @returns Whether the value matches the pattern.\n */\n protected isMicromatchMatch(\n value: unknown,\n pattern: MicromatchPatternNullable\n ): boolean {\n if (isNull(pattern)) {\n return isNull(value);\n }\n if (isNull(value)) {\n return isArray(pattern) && pattern.some(isNull);\n }\n\n // Clean empty strings from arrays to avoid matching them.\n const patternToCheck = this.cleanMicromatchPattern(pattern);\n\n if (!patternToCheck?.length) {\n return false;\n }\n\n // Convert non-string element values to string for matching.\n const elementValueToCheck =\n !value || !isString(value) ? String(value) : value;\n\n return this.micromatch.isMatch(elementValueToCheck, patternToCheck);\n }\n\n /**\n * Returns whether the given value matches the micromatch pattern after rendering it as a template.\n * @param pattern The micromatch pattern to render and match against.\n * @param templateData The data to use for rendering the pattern as a template.\n * @param value The value to check.\n * @returns Whether the value matches the rendered pattern.\n */\n protected isTemplateMicromatchMatch(\n pattern: MicromatchPatternNullable,\n templateData: TemplateData,\n value?: unknown\n ): boolean {\n // If the element value is undefined, it cannot match anything.\n if (isUndefined(value)) {\n return false;\n }\n\n const patternRendered = this.getRenderedTemplates(pattern, templateData);\n\n // Empty rendered selector values do not match anything. (It may happen due to templates rendering to empty strings.)\n if (!isNull(patternRendered) && !patternRendered) {\n return false;\n }\n\n if (isArray(value)) {\n // If the value is an array, we check if any of its items matches the pattern.\n return value.some((val) => this.isMicromatchMatch(val, patternRendered));\n }\n\n return this.isMicromatchMatch(value, patternRendered);\n }\n\n /**\n * Whether the given element key matches the selector key as booleans.\n * @param param0 The parameters object.\n * @returns Whether the element key matches the selector key.\n */\n protected isElementKeyBooleanMatch<\n T extends BaseElementDescription,\n S extends BaseElementSelectorData,\n >({\n /** The element to check. */\n element,\n /** The selector to check against. */\n selector,\n /** The key of the element to check. */\n elementKey,\n /** The key of the selector to check against. */\n selectorKey,\n }: {\n /** The element to check. */\n element: T;\n /** The selector to check against. */\n selector: S;\n /** The key of the element to check. */\n elementKey: keyof T;\n /** The key of the selector to check against. */\n selectorKey: keyof S;\n }): boolean {\n // The selector key does not exist in the selector, so it matches any value.\n if (!(selectorKey in selector)) {\n return true;\n }\n // The selector key exists in the selector, but it does not exist in the element. No match.\n // istanbul ignore next - This case should not happen due to element validations, but we guard against it anyway.\n if (!(elementKey in element)) {\n return false;\n }\n // Both values must be booleans to match.\n if (!isBoolean(selector[selectorKey]) || !isBoolean(element[elementKey])) {\n return false;\n }\n return (\n (selector[selectorKey] as boolean) === (element[elementKey] as boolean)\n );\n }\n\n /**\n * Whether the given element key matches the selector key using micromatch.\n * @param param0 The parameters object.\n * @returns Whether the element key matches the selector key.\n */\n protected isElementKeyMicromatchMatch<\n T extends SelectableElement,\n S extends BaseElementSelectorData,\n >({\n element,\n selector,\n elementKey,\n selectorKey,\n selectorValue,\n templateData,\n }: {\n /** The element to check. */\n element: T;\n /** The selector to check against. */\n selector: S;\n /** The key of the element to check. */\n elementKey: keyof T;\n /** The key of the selector to check against. */\n selectorKey: keyof BaseElementSelectorData;\n /** The value of the selector key to check against. */\n selectorValue?: MicromatchPatternNullable;\n /** Data to pass when the selector value is rendered as a template */\n templateData: TemplateData;\n }): boolean {\n // The selector key does not exist in the selector, so it matches any value. We also check the value passed separately in order to improve typing inference.\n if (!(selectorKey in selector)) {\n return true;\n }\n // Undefined selector values do not match anything.\n // The selector key exists in the selector, but it does not exist in the element. No match.\n /* istanbul ignore next - This cases should not happen due to selector validations, but we guard against it anyway. */\n if (\n isUndefined(selectorValue) ||\n !isObjectWithProperty(element, String(elementKey))\n ) {\n return false;\n }\n\n const elementValue = (element as Record<string, unknown>)[\n String(elementKey)\n ];\n\n return this.isTemplateMicromatchMatch(\n selectorValue,\n templateData,\n elementValue\n );\n }\n}\n","import {\n isObject,\n isString,\n isArray,\n isStringArray,\n isObjectWithProperty,\n isEmptyArray,\n isObjectWithAnyOfProperties,\n} from \"../Support/TypeGuards\";\n\nimport type {\n ElementSelector,\n ElementSelectorWithOptions,\n ElementSelectors,\n CapturedValuesSelector,\n SimpleElementSelectorByType,\n DependencySelector,\n DependencyDataSelector,\n DependencyDataSelectorData,\n BaseElementSelector,\n BaseElementSelectorData,\n BaseElementsSelector,\n ElementsSelector,\n} from \"./Matcher.types\";\n\n/**\n * Determines if the given value is a captured values object selector (single object with pattern properties).\n * @param value The value to check.\n * @returns True if the value is a captured values object selector, false otherwise.\n */\nfunction isCapturedValuesObjectSelector(\n value: unknown\n): value is Record<string, string | string[]> {\n if (!isObject(value) || isArray(value)) {\n return false;\n }\n // Ensure all values are strings or string arrays\n return Object.values(value).every(\n (pattern) => isString(pattern) || isStringArray(pattern)\n );\n}\n\n/**\n * Determines if the given value is a captured values selector.\n * @param value The value to check.\n * @returns True if the value is a captured values selector, false otherwise.\n */\nexport function isCapturedValuesSelector(\n value: unknown\n): value is CapturedValuesSelector {\n // Handle array of captured values selectors\n if (isArray(value)) {\n return value.every((item) => isCapturedValuesObjectSelector(item));\n }\n\n // Handle single captured values selector\n return isCapturedValuesObjectSelector(value);\n}\n\n/**\n * Determines if the given value is a simple element selector.\n * @param value The value to check.\n * @returns True if the value is a simple element selector, false otherwise.\n */\nexport function isSimpleElementSelectorByType(\n value: unknown\n): value is SimpleElementSelectorByType {\n return isString(value);\n}\n\n/**\n * Determines if the given selector is a base element selector.\n * @param value The value to check.\n * @returns True if the selector is a base element selector\n */\nexport function isBaseElementSelectorData(\n value: unknown\n): value is BaseElementSelectorData {\n return isObjectWithAnyOfProperties(value, [\n \"path\",\n \"elementPath\",\n \"internalPath\",\n \"type\",\n \"category\",\n \"captured\",\n \"parent\",\n \"origin\",\n \"source\",\n \"module\",\n \"isIgnored\",\n \"isUnknown\",\n ]);\n}\n\n/**\n * Determines if the given selector is an element or dependency element selector data.\n * @param value The value to check.\n * @returns True if the selector is an element or dependency element selector data, false otherwise.\n */\nexport function isElementSelectorData(\n value: unknown\n): value is BaseElementSelectorData {\n return isBaseElementSelectorData(value);\n}\n\n/**\n * Determines if the given selector is an element selector with options.\n * @param value The value to check.\n * @returns True if the selector is an element selector with options, false otherwise.\n */\nexport function isElementSelectorWithLegacyOptions(\n value: unknown\n): value is ElementSelectorWithOptions {\n return (\n isArray(value) &&\n ((value.length === 2 &&\n isSimpleElementSelectorByType(value[0]) &&\n // NOTE: Arrays of length 2 with captured values selector as second element having a key \"type\" or \"category\" will be treated as legacy options instead of two different selectors. We have to live with this limitation for now.\n isCapturedValuesSelector(value[1])) ||\n // NOTE: Backwards compatibility: Allow arrays of length 1 with simple element selector. Some users might defined arrays without options.\n (value.length === 1 && isSimpleElementSelectorByType(value[0])))\n );\n}\n\n/**\n * Determines if the given value is an element selector.\n * @param value The value to check.\n * @returns True if the value is an element selector, false otherwise.\n */\nexport function isElementSelector(value: unknown): value is ElementSelector {\n return (\n isSimpleElementSelectorByType(value) ||\n isElementSelectorData(value) ||\n isElementSelectorWithLegacyOptions(value)\n );\n}\n\n/**\n * Determines if the given value is an elements selector.\n * @param value The value to check.\n * @returns True if the value is an elements selector, false otherwise.\n */\nexport function isElementsSelector(value: unknown): value is ElementSelectors {\n return (\n isElementSelector(value) ||\n (isArray(value) && !isEmptyArray(value) && value.every(isElementSelector))\n );\n}\n\n/**\n * Normalizes a selector into ElementSelectorData format.\n * @param selector The selector to normalize.\n * @returns The normalized selector data.\n */\nexport function normalizeElementSelector(\n selector: BaseElementSelector\n): BaseElementSelectorData;\nexport function normalizeElementSelector(\n selector: ElementSelector\n): BaseElementSelectorData {\n if (isSimpleElementSelectorByType(selector)) {\n return { type: selector };\n }\n\n if (isElementSelectorData(selector)) {\n return { ...selector };\n }\n\n if (isElementSelectorWithLegacyOptions(selector)) {\n return {\n type: selector[0],\n captured: selector[1] ? { ...selector[1] } : undefined,\n };\n }\n throw new Error(\"Invalid element selector\");\n}\n\n/**\n * Normalizes an ElementsSelector into an array of ElementSelectorData.\n * @param elementsSelector The elements selector, in any supported format.\n * @returns The normalized array of selector data.\n */\nexport function normalizeElementsSelector(\n elementsSelector: BaseElementsSelector\n): BaseElementSelectorData[];\nexport function normalizeElementsSelector(\n elementsSelector: ElementsSelector\n): BaseElementSelectorData[] {\n if (isArray(elementsSelector)) {\n if (isElementSelectorWithLegacyOptions(elementsSelector)) {\n return [normalizeElementSelector(elementsSelector)];\n }\n return elementsSelector.map((sel) => normalizeElementSelector(sel));\n }\n return [normalizeElementSelector(elementsSelector)];\n}\n\n/**\n * Determines if the given value is a dependency selector.\n * @param value The value to check\n * @returns True if the value is a dependency selector, false otherwise.\n */\nexport function isDependencySelector(\n value: unknown\n): value is DependencySelector {\n if (!isObjectWithAnyOfProperties(value, [\"from\", \"to\", \"dependency\"])) {\n return false;\n }\n\n const fromIsValid =\n !isObjectWithProperty(value, \"from\") || isElementsSelector(value.from);\n const toIsValid =\n !isObjectWithProperty(value, \"to\") || isElementsSelector(value.to);\n const dependencyIsValid =\n !isObjectWithProperty(value, \"dependency\") ||\n isDependencyDataSelector(value.dependency);\n\n return fromIsValid && toIsValid && dependencyIsValid;\n}\n\n/**\n * Determines if the given value is dependency metadata selector data.\n * @param value The value to check.\n * @returns True if the value is dependency metadata selector data, false otherwise.\n */\nexport function isDependencyDataSelectorData(\n value: unknown\n): value is DependencyDataSelectorData {\n return isObjectWithAnyOfProperties(value, [\n \"kind\",\n \"relationship\",\n \"specifiers\",\n \"nodeKind\",\n \"source\",\n \"module\",\n ]);\n}\n\n/**\n * Determines if the given value is dependency metadata selector(s).\n * @param value The value to check.\n * @returns True if the value is dependency metadata selector(s), false otherwise.\n */\nexport function isDependencyDataSelector(\n value: unknown\n): value is DependencyDataSelector {\n return (\n isDependencyDataSelectorData(value) ||\n (isArray(value) &&\n !isEmptyArray(value) &&\n value.every(isDependencyDataSelectorData))\n );\n}\n","import type { MatchersOptionsNormalized } from \"../Config\";\nimport type {\n DependencyDescription,\n DependencyRelationship,\n} from \"../Descriptor\";\nimport { isArray } from \"../Support\";\n\nimport { BaseElementsMatcher } from \"./BaseElementsMatcher\";\nimport type { ElementsMatcher } from \"./ElementsMatcher\";\nimport type {\n TemplateData,\n DependencySelector,\n DependencySelectorNormalized,\n MatcherOptions,\n DependencyMatchResult,\n DependencyDataSelectorData,\n} from \"./Matcher.types\";\nimport {\n normalizeElementsSelector,\n isDependencyDataSelector,\n isDependencySelector,\n} from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to determine if dependencies match a given dependencies selector.\n */\nexport class DependenciesMatcher extends BaseElementsMatcher {\n /**\n * Elements matcher to use for matching elements within dependencies.\n */\n private readonly _elementsMatcher: ElementsMatcher;\n\n /**\n * Creates a new DependenciesMatcher.\n * @param elementsMatcher Elements matcher to use for matching elements within dependencies.\n * @param config Configuration options for the matcher.\n * @param micromatch Micromatch instance for matching.\n * @param globalCache Global cache instance.\n */\n constructor(\n elementsMatcher: ElementsMatcher,\n config: MatchersOptionsNormalized,\n micromatch: Micromatch\n ) {\n super(config, micromatch);\n this._elementsMatcher = elementsMatcher;\n }\n\n /**\n * Normalizes selector into DependencySelectorNormalized format, containing arrays of selectors data.\n * @param selector The dependency selector to normalize.\n * @returns The normalized dependency selector.\n */\n private _normalizeDependencySelector(\n selector: DependencySelector\n ): DependencySelectorNormalized {\n if (!isDependencySelector(selector)) {\n throw new Error(\"Invalid dependency selector\");\n }\n\n let normalizedDependencySelectors: DependencyDataSelectorData[] | null =\n null;\n\n if (selector.dependency && isDependencyDataSelector(selector.dependency)) {\n normalizedDependencySelectors = isArray(selector.dependency)\n ? selector.dependency\n : [selector.dependency];\n }\n\n return {\n from: selector.from ? normalizeElementsSelector(selector.from) : null,\n to: selector.to ? normalizeElementsSelector(selector.to) : null,\n dependency: normalizedDependencySelectors,\n };\n }\n\n /**\n * Returns the selectors matching result for the given dependency.\n * @param dependency The dependency description.\n * @param selector The dependency selector normalized.\n * @param extraTemplateData The extra template data for selector values.\n * @returns The selectors matching result for the given dependency.\n */\n private _getSelectorsMatching(\n dependency: DependencyDescription,\n selector: DependencySelectorNormalized,\n templateData: TemplateData\n ): DependencyMatchResult {\n const getDependencyMetadataSelectorMatching =\n (): DependencyDataSelectorData | null => {\n for (const dependencySelectorData of selector.dependency!) {\n const dependencyPropertiesMatch = this._dependencyPropertiesMatch(\n dependency,\n dependencySelectorData,\n templateData\n );\n if (dependencyPropertiesMatch) {\n return dependencySelectorData;\n }\n }\n return null;\n };\n\n const fromSelectorMatching = selector.from\n ? this._elementsMatcher.getSelectorMatching(\n dependency.from,\n selector.from,\n {\n extraTemplateData: templateData,\n }\n )\n : null;\n const toSelectorMatching = selector.to\n ? this._elementsMatcher.getSelectorMatching(dependency.to, selector.to, {\n extraTemplateData: templateData,\n })\n : null;\n const dependencyMetadataSelectorMatching = selector.dependency\n ? getDependencyMetadataSelectorMatching()\n : null;\n\n return {\n from: fromSelectorMatching,\n to: toSelectorMatching,\n dependency: dependencyMetadataSelectorMatching,\n isMatch: Boolean(\n (selector.from ? fromSelectorMatching : true) &&\n (selector.to ? toSelectorMatching : true) &&\n (selector.dependency ? dependencyMetadataSelectorMatching : true)\n ),\n };\n }\n\n /**\n * Determines if the dependency relationship matches the selector.\n * @param dependency The dependency description.\n * @param selector The data of an element selector.\n * @returns Whether the dependency relationship matches the selector.\n */\n private _relationshipFromMatches(\n selector: DependencyDataSelectorData,\n relationship: DependencyRelationship | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.relationship?.from) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.relationship.from,\n templateData,\n relationship\n );\n }\n\n /**\n * Determines if the dependency origin relationship matches the selector.\n * @param selector The dependency selector data.\n * @param relationship The relationship from origin element to target element.\n * @param templateData The template data for rendering selector values.\n * @returns Whether the dependency origin relationship matches.\n */\n private _relationshipToMatches(\n selector: DependencyDataSelectorData,\n relationship: DependencyRelationship | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.relationship?.to) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.relationship.to,\n templateData,\n relationship\n );\n }\n\n /**\n * Determines if the selector matches an specific kind\n * @param selector The dependency selector data\n * @param kind Kind to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the kind\n */\n private _kindMatches(\n selector: DependencyDataSelectorData,\n kind: string,\n templateData: TemplateData\n ): boolean {\n if (!selector.kind) {\n return true;\n }\n return this.isTemplateMicromatchMatch(selector.kind, templateData, kind);\n }\n\n /**\n * Determines if the selector matches some of the specifiers\n * @param selector The dependency selector data\n * @param specifiers Specifiers to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches some of the specifiers\n */\n private _specifierMatches(\n selector: DependencyDataSelectorData,\n specifiers: string[] | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.specifiers) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.specifiers,\n templateData,\n specifiers\n );\n }\n\n /**\n * Determines if the selector matches the nodeKind\n * @param selector The dependency selector data\n * @param nodeKind The nodeKind to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the nodeKind\n */\n private _nodeKindMatches(\n selector: DependencyDataSelectorData,\n nodeKind: string | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.nodeKind) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.nodeKind,\n templateData,\n nodeKind\n );\n }\n\n /**\n * Determines if the dependency description matches the selector for 'to'.\n * @param dependency The dependency description.\n * @param toSelector The selector for 'to' elements.\n * @param templateData The template data for rendering selector values\n * @returns Whether the dependency properties match the selector for 'to'.\n */\n private _sourceMatches(\n selector: DependencyDataSelectorData,\n source: string,\n templateData: TemplateData\n ): boolean {\n if (!selector.source) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.source,\n templateData,\n source\n );\n }\n\n /**\n * Determines if the selector matches the module\n * @param selector The dependency selector data\n * @param module The module to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the module\n */\n private _moduleMatches(\n selector: DependencyDataSelectorData,\n dependencyModule: string | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.module) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.module,\n templateData,\n dependencyModule\n );\n }\n\n /**\n * Determines if the dependency description matches the selector for dependency metadata.\n * @param dependency The dependency description.\n * @param selectorData The selector for dependency metadata.\n * @param templateData The template data for rendering selector values\n * @returns Whether the dependency properties match the selector.\n */\n private _dependencyPropertiesMatch(\n dependency: DependencyDescription,\n selectorData: DependencyDataSelectorData,\n templateData: TemplateData\n ): boolean {\n const dependencyInfo = dependency.dependency;\n const relationshipFrom = dependencyInfo.relationship.from;\n const relationshipTo = dependencyInfo.relationship.to;\n const kind = dependencyInfo.kind;\n const nodeKind = dependencyInfo.nodeKind;\n const specifiers = dependencyInfo.specifiers;\n const source = dependencyInfo.source;\n const dependencyModule = dependencyInfo.module;\n\n return (\n this._kindMatches(selectorData, kind, templateData) &&\n this._nodeKindMatches(selectorData, nodeKind, templateData) &&\n this._sourceMatches(selectorData, source, templateData) &&\n this._moduleMatches(selectorData, dependencyModule, templateData) &&\n this._relationshipFromMatches(\n selectorData,\n relationshipFrom,\n templateData\n ) &&\n this._relationshipToMatches(selectorData, relationshipTo, templateData) &&\n this._specifierMatches(selectorData, specifiers, templateData)\n );\n }\n\n /**\n * Returns the selectors matching result for the given dependency.\n * @param dependency The dependency to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The matching result for the dependency against the selector.\n */\n public getSelectorsMatching(\n dependency: DependencyDescription,\n selector: DependencySelector,\n { extraTemplateData = {} }: MatcherOptions = {}\n ): DependencyMatchResult {\n const normalizedSelector = this._normalizeDependencySelector(selector);\n\n const fromExtraData = extraTemplateData.from || {};\n const toExtraData = extraTemplateData.to || {};\n\n // Add `to` and `from` data to the template when checking elements in dependencies\n const templateData: TemplateData = {\n ...extraTemplateData,\n from: {\n ...dependency.from,\n ...fromExtraData,\n },\n to: {\n ...dependency.to,\n ...toExtraData,\n },\n dependency: dependency.dependency,\n };\n\n const result = this._getSelectorsMatching(\n dependency,\n normalizedSelector,\n templateData\n );\n return result;\n }\n\n /**\n * Returns whether the given dependency matches the selector.\n * @param dependency The dependency to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns Whether the dependency matches the selector properties.\n */\n public isDependencyMatch(\n dependency: DependencyDescription,\n selector: DependencySelector,\n options?: MatcherOptions\n ): boolean {\n const matchResult = this.getSelectorsMatching(\n dependency,\n selector,\n options\n );\n return matchResult.isMatch;\n }\n}\n","import type {\n MatchersOptionsNormalized,\n MicromatchPatternNullable,\n} from \"../Config\";\nimport type { ElementDescription } from \"../Descriptor\";\nimport {\n isArray,\n isNullish,\n isEmptyObject,\n isUndefined,\n isNull,\n} from \"../Support\";\n\nimport { BaseElementsMatcher } from \"./BaseElementsMatcher\";\nimport type {\n BaseElementSelectorData,\n ParentElementSelectorData,\n SelectableElement,\n TemplateData,\n BaseElementsSelector,\n MatcherOptions,\n} from \"./Matcher.types\";\nimport { normalizeElementsSelector } from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to determine if elements match a given selector.\n */\nexport class ElementsMatcher extends BaseElementsMatcher {\n /**\n * Creates a new ElementsSelectorMatcher.\n * @param config Configuration options for the matcher.\n * @param micromatch Micromatch instance for matching.\n * @param globalCache Global cache instance.\n */\n constructor(config: MatchersOptionsNormalized, micromatch: Micromatch) {\n super(config, micromatch);\n }\n\n /**\n * Whether the given element type matches the selector type.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element type matches the selector type.\n */\n private _isTypeMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"type\",\n selectorKey: \"type\",\n selectorValue: selector.type,\n templateData,\n });\n }\n\n /**\n * Whether the given element category matches the selector category.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element category matches the selector category.\n */\n private _isCategoryMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"category\",\n selectorKey: \"category\",\n selectorValue: selector.category,\n templateData,\n });\n }\n\n /**\n * Whether the given element path matches the selector path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element path matches the selector path.\n */\n private _isPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"path\",\n selectorKey: \"path\",\n selectorValue: selector.path,\n templateData,\n });\n }\n\n /**\n * Whether the given element path matches the selector element path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element path matches the selector element path.\n */\n private _isElementPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"elementPath\",\n selectorKey: \"elementPath\",\n selectorValue: selector.elementPath,\n templateData,\n });\n }\n\n /**\n * Whether the given element internal path matches the selector internal path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element internal path matches the selector internal path.\n */\n private _isInternalPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"internalPath\",\n selectorKey: \"internalPath\",\n selectorValue: selector.internalPath,\n templateData,\n });\n }\n\n /**\n * Whether the given element origin matches the selector origin\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element origin matches the selector origin.\n */\n private _isOriginMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"origin\",\n selectorKey: \"origin\",\n selectorValue: selector.origin,\n templateData,\n });\n }\n\n /**\n * Checks if a single captured values object matches the element.\n * @param capturedValues The captured values to check.\n * @param capturedSelector The captured values selector object to check against\n * @param templateData The data to use for replace in selector values\n * @returns True if all captured values in the selector match those in the element, false otherwise.\n */\n private _checkCapturedValuesObject(\n capturedValues: SelectableElement[\"captured\"],\n capturedSelector: Record<string, MicromatchPatternNullable>,\n templateData: TemplateData\n ): boolean {\n if (!capturedValues) {\n return false;\n }\n // Use for...of with early return for better performance than every()\n for (const [key, pattern] of Object.entries(capturedSelector)) {\n const elementValue = capturedValues[key];\n if (!elementValue) {\n return false;\n }\n\n const renderedPattern = this.getRenderedTemplates(pattern, templateData);\n\n const filteredPattern = this.cleanMicromatchPattern(renderedPattern);\n\n if (!filteredPattern) {\n return false;\n }\n\n const isMatch = this.micromatch.isMatch(elementValue, filteredPattern);\n if (!isMatch) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Determines if the captured values of the element match those in the selector.\n * When the selector is an array, the element matches if it matches any of the array elements (OR logic).\n * @param element The element to check.\n * @param selector The selector to check against\n * @param templateData The data to use for replace in selector values\n * @returns True if the captured values match, false otherwise.\n */\n private _isCapturedValuesMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n if (!selector.captured || isEmptyObject(selector.captured)) {\n return true;\n }\n\n // Handle array of captured values selectors (OR logic)\n if (isArray(selector.captured)) {\n // Empty array doesn't match anything\n if (selector.captured.length === 0) {\n return false;\n }\n // Match if any of the array elements matches\n return selector.captured.some((capturedSelector) =>\n this._checkCapturedValuesObject(\n element.captured,\n capturedSelector,\n templateData\n )\n );\n }\n\n // Handle single captured values selector object\n return this._checkCapturedValuesObject(\n element.captured,\n selector.captured,\n templateData\n );\n }\n\n /**\n * Determines if the parent captured values match the selector.\n * @param parentSelector The parent selector to match.\n * @param parentCaptured The captured values from first parent.\n * @param templateData The data to use for replace in selector values\n * @returns True if the captured values match, false otherwise.\n */\n private _isParentCapturedValuesMatch(\n parentSelector: ParentElementSelectorData,\n parentCaptured: SelectableElement[\"captured\"],\n templateData: TemplateData\n ): boolean {\n if (!parentSelector.captured || isEmptyObject(parentSelector.captured)) {\n return true;\n }\n\n if (isArray(parentSelector.captured)) {\n if (parentSelector.captured.length === 0) {\n return false;\n }\n return parentSelector.captured.some((capturedSelector) =>\n this._checkCapturedValuesObject(\n parentCaptured,\n capturedSelector,\n templateData\n )\n );\n }\n\n return this._checkCapturedValuesObject(\n parentCaptured,\n parentSelector.captured,\n templateData\n );\n }\n\n /**\n * Whether the given element first parent matches the selector parent.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector values\n * @returns Whether the first parent matches the selector parent.\n */\n private _isParentMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n if (isUndefined(selector.parent)) {\n return true;\n }\n if (isNull(selector.parent)) {\n return !element.parents || element.parents.length === 0;\n }\n\n const firstParent = element.parents?.[0];\n\n if (!firstParent) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.type) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.type,\n templateData,\n firstParent.type\n )\n ) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.category) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.category,\n templateData,\n firstParent.category\n )\n ) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.elementPath) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.elementPath,\n templateData,\n firstParent.elementPath\n )\n ) {\n return false;\n }\n\n if (\n !this._isParentCapturedValuesMatch(\n selector.parent,\n firstParent.captured,\n templateData\n )\n ) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Determines if the isIgnored property of the element matches that in the selector.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @returns True if the isIgnored properties match, false otherwise.\n */\n private _isIgnoredMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData\n ): boolean {\n return this.isElementKeyBooleanMatch({\n element,\n selector,\n elementKey: \"isIgnored\",\n selectorKey: \"isIgnored\",\n });\n }\n\n /**\n * Determines if the isUnknown property of the element matches that in the selector.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @returns True if the isUnknown properties match, false otherwise.\n */\n private _isUnknownMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData\n ): boolean {\n return this.isElementKeyBooleanMatch({\n element,\n selector,\n elementKey: \"isUnknown\",\n selectorKey: \"isUnknown\",\n });\n }\n\n /**\n * Returns the selector matching result for the given local or external element.\n * @param element The local or external element to check.\n * @param selector The selector to check against.\n * @param extraTemplateData Extra template data to use for matching.\n * @returns The selector matching result for the given element, or null if none matches.\n */\n private _getSelectorMatching(\n element: SelectableElement,\n selectorsData: BaseElementSelectorData[],\n extraTemplateData: TemplateData\n ): BaseElementSelectorData | null {\n const templateData: TemplateData = {\n element,\n ...extraTemplateData,\n };\n // Optimized loop with early exits for better performance\n for (const selectorData of selectorsData) {\n // Order checks by likelihood of failing for better short-circuiting\n // Most restrictive checks first to fail fast\n if (\n !this._isTypeMatch(element, selectorData, templateData) ||\n !this._isCategoryMatch(element, selectorData, templateData) ||\n !this._isOriginMatch(element, selectorData, templateData) ||\n !this._isIgnoredMatch(element, selectorData) ||\n !this._isUnknownMatch(element, selectorData) ||\n !this._isPathMatch(element, selectorData, templateData) ||\n !this._isElementPathMatch(element, selectorData, templateData) ||\n !this._isInternalPathMatch(element, selectorData, templateData) ||\n !this._isCapturedValuesMatch(element, selectorData, templateData) ||\n !this._isParentMatch(element, selectorData, templateData)\n ) {\n continue; // Early exit on first failed condition\n }\n\n // All conditions passed, return the first matching selector\n return selectorData;\n }\n\n return null;\n }\n\n /**\n * Returns the selector matching result for the given element, or null if none matches.\n * It omits checks in keys applying only to dependency between elements, such as relationship.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The selector matching result for the given element, or null if none matches.\n */\n public getSelectorMatching(\n element: ElementDescription,\n selector: BaseElementsSelector,\n { extraTemplateData = {} }: MatcherOptions = {}\n ): BaseElementSelectorData | null {\n const selectorsData = normalizeElementsSelector(selector);\n return this._getSelectorMatching(element, selectorsData, extraTemplateData);\n }\n\n /**\n * Returns whether the given element matches the selector.\n * It omits checks in keys applying only to dependency between elements, such as relationship.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns Whether the element matches the selector properties applying to elements.\n */\n public isElementMatch(\n element: ElementDescription,\n selector: BaseElementsSelector,\n options?: MatcherOptions\n ): boolean {\n const selectorMatching = this.getSelectorMatching(\n element,\n selector,\n options\n );\n return !isNullish(selectorMatching);\n }\n}\n","/**\n * Map of the modes to interpret the pattern in an ElementDescriptor.\n */\nexport const ELEMENT_DESCRIPTOR_MODES_MAP = {\n /** Mode to interpret the pattern as a folder */\n FOLDER: \"folder\",\n /** Mode to interpret the pattern as a file */\n FILE: \"file\",\n /** Mode to interpret the pattern as a full path */\n FULL: \"full\",\n} as const;\n\n/**\n * Mode to interpret the pattern in an ElementDescriptor.\n */\nexport type ElementDescriptorMode =\n (typeof ELEMENT_DESCRIPTOR_MODES_MAP)[keyof typeof ELEMENT_DESCRIPTOR_MODES_MAP];\n\n/**\n * Pattern(s) to match files for an element descriptor.\n */\nexport type ElementDescriptorPattern = string | string[];\n\n/**\n * Descriptor for an element (or layer) in the project.\n * Defines the type of the element, the pattern to match files, and optional settings like mode and capture groups.\n */\nexport type BaseElementDescriptor = {\n /** Micromatch pattern(s) to match files belonging to this element. */\n pattern: ElementDescriptorPattern;\n /**\n * Optional micromatch pattern. If provided, the left side of the element path must match also with this pattern from the root of the project (like if pattern is [basePattern]/** /[pattern]).\n * This option is useful when using the option mode with file or folder values, but capturing fragments from the rest of the full path is also needed\n **/\n basePattern?: string;\n /**\n * Mode to interpret the pattern. Can be \"folder\" (default), \"file\", or \"full\".\n * - \"folder\": Default value. the element type will be assigned to the first file's parent folder matching the pattern.\n * In the practice, it is like adding ** /* to the given pattern, but the plugin makes it by itself because it needs to know exactly which parent folder has to be considered the element.\n * - \"file\": The given pattern will not be modified, but the plugin will still try to match the last part of the path.\n * So, a pattern like *.model.js would match with paths src/foo.model.js, src/modules/foo/foo.model.js, src/modules/foo/models/foo.model.js, etc.\n * - \"full\": The given pattern will only match with patterns matching the full path.\n * This means that you will have to provide patterns matching from the base project path.\n * So, in order to match src/modules/foo/foo.model.js you'll have to provide patterns like ** /*.model.js, ** /* /*.model.js, src/* /* /*.model.js, etc. (the chosen pattern will depend on what do you want to capture from the path)\n */\n mode?: ElementDescriptorMode;\n /**\n * It allows to capture values of some fragments in the matching path to use them later in the rules configuration.\n * Must be an array of strings representing the names of the capture groups in the pattern.\n * The number of capture names must be equal to the number of capturing groups in the pattern.\n * For example, if the pattern is \"src/modules/(* *)/(* *).service.js\" the capture could be [\"module\", \"service\"].\n * Then, in the rules configuration, you could use [\"service\", { module: \"auth\" }] to match only services from the auth module.\n */\n capture?: string[];\n /**\n * Like capture, but for the basePattern.\n * This allows to capture values from the left side of the path, which is useful when using the basePattern option.\n * The captured values will be merged with the ones from the capture option. If the same name is used in both captures, the value from capture will take precedence.\n */\n baseCapture?: string[];\n};\n\n/**\n * Element descriptor with a type.\n */\nexport type ElementDescriptorWithType = BaseElementDescriptor & {\n /** Type of the element (e.g., \"service\", \"component\", \"util\"). */\n type: string;\n /** Category of the element */\n category?: never;\n};\n\n/**\n * Element descriptor with a category.\n */\nexport type ElementDescriptorWithCategory = BaseElementDescriptor & {\n /** Category of the element (e.g., \"domain\", \"infrastructure\", \"application\"). */\n category: string;\n /** Type of the element*/\n type?: never;\n};\n\n/**\n * Element descriptor with both type and category.\n */\nexport type ElementDescriptorWithTypeAndCategory = BaseElementDescriptor & {\n /** Type of the element (e.g., \"service\", \"component\", \"util\"). */\n type: string;\n /** Category of the element (e.g., \"domain\", \"infrastructure\", \"application\"). */\n category: string;\n};\n\n/**\n * Element descriptor, which can be defined by type, category, or both.\n */\nexport type ElementDescriptor =\n | ElementDescriptorWithType\n | ElementDescriptorWithCategory\n | ElementDescriptorWithTypeAndCategory;\n\n/**\n * Array of element descriptors.\n */\nexport type ElementDescriptors = ElementDescriptor[];\n\nexport type ElementDescriptionWithSource = ElementDescription & {\n module?: string | null;\n};\n\n/**\n * Serialized cache of element descriptions.\n */\nexport type DescriptionsSerializedCache = Record<\n string,\n ElementDescription | ElementDescriptionWithSource\n>;\n\n/**\n * Serialized cache of file elements.\n */\nexport type FileElementsSerializedCache = Record<string, ElementDescription>;\n\n/**\n * Serialized cache for ElementsDescriptor class.\n */\nexport type ElementsDescriptorSerializedCache = {\n /** Serialized descriptions cache */\n descriptions: DescriptionsSerializedCache;\n /** Serialized files cache */\n files: FileElementsSerializedCache;\n};\n\n/**\n * Captured values from an element path.\n */\nexport type CapturedValues = Record<string, string>;\n\n/**\n * Origins of an element\n */\nexport const ELEMENT_ORIGINS_MAP = {\n /** Origin of local elements (files) */\n LOCAL: \"local\",\n /** Origin of external elements (libraries) */\n EXTERNAL: \"external\",\n /** Origin of core elements */\n CORE: \"core\",\n} as const;\n\n/**\n * Kind of element origin, either local, external, or core.\n */\nexport type ElementOrigin =\n (typeof ELEMENT_ORIGINS_MAP)[keyof typeof ELEMENT_ORIGINS_MAP];\n\n/**\n * Base element properties related to captured values\n */\nexport type BaseElementDescription = {\n /** Absolute path of the file. It might be null when a dependency path can't be resolved */\n path: string | null;\n /** Path of the file relative to the element, or null if the element is ignored or unknown */\n elementPath: string | null;\n /** Internal path of the file relative to the elementPath, or null if the element is ignored or unknown */\n internalPath: string | null;\n /** Type of the element, or null if the element is ignored or unknown */\n type: string | null;\n /** Category of the element, or null if the element is ignored or unknown */\n category: string | null;\n /** Captured values from the element, or null if the element descriptor has no capture or the element is ignored or unknown */\n captured: CapturedValues | null;\n /** Parent elements, or null if the element is ignored, unknown, or it is not a local element */\n parents: ElementParent[] | null;\n /** Origin of the element, or null if the element is ignored */\n origin: ElementOrigin | null;\n /** Indicates if the element is ignored by settings. If true, the element will be excluded from processing any other properties. */\n isIgnored: boolean;\n /** Indicates if the element is unknown, which means that it cannot be resolved to any descriptor */\n isUnknown: boolean;\n};\n\n/**\n * Parent elements\n */\nexport type ElementParent = {\n /** Type of the parent element */\n type: string | null;\n /** Category of the parent element */\n category: string | null;\n /** Path of the element relative to the project */\n elementPath: string;\n /** Captured values from the parent element */\n captured: CapturedValues | null;\n};\n\n/**\n * Description of an ignored element\n */\nexport type IgnoredElement = BaseElementDescription & {\n /** Type of the element */\n type: null;\n /** Category of the element */\n category: null;\n /** Ignored elements have not captured values */\n captured: null;\n /** Origin of the element */\n origin: null;\n /** Indicates if the file is ignored */\n isIgnored: true;\n /** Indicates that the element is unknown */\n isUnknown: true;\n};\n\n/**\n * Description of an unknown local element\n */\nexport type LocalElementUnknown = BaseElementDescription & {\n /** Type of the element */\n type: null;\n /** Category of the element */\n category: null;\n /** Unknown elements have not captured values */\n captured: null;\n /** Indicates that the element is local */\n origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;\n /** Indicates that the file is not ignored */\n isIgnored: false;\n /** Indicates that the element is unknown */\n isUnknown: true;\n};\n\n/**\n * Description of a local element (file)\n */\nexport type LocalElementKnown = BaseElementDescription & {\n /** Path of the element */\n path: string;\n /** Captured values from the parent element */\n captured: CapturedValues | null;\n /** Path of the file relative to the element */\n elementPath: string;\n /** Internal path of the file relative to the elementPath */\n internalPath: string;\n /** Parent elements */\n parents: ElementParent[];\n /** Indicates that the element is local */\n origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;\n /** Indicates that the file is not ignored */\n isIgnored: false;\n /** Indicates that the element is known */\n isUnknown: false;\n};\n\n/**\n * Description of an unknown external element.\n */\nexport type ExternalElementDescription = BaseElementDescription & {\n origin: typeof ELEMENT_ORIGINS_MAP.EXTERNAL;\n isIgnored: false;\n};\n\n/**\n * Description of an unknown core element.\n */\nexport type CoreElementDescription = BaseElementDescription & {\n origin: typeof ELEMENT_ORIGINS_MAP.CORE;\n isIgnored: false;\n};\n\n/**\n * Description of an element, either local or dependency\n */\nexport type ElementDescription =\n | LocalElementKnown\n | LocalElementUnknown\n | IgnoredElement\n | ExternalElementDescription\n | CoreElementDescription;\n","import {\n isString,\n isObjectWithProperty,\n isArray,\n isEmptyArray,\n} from \"../Support/TypeGuards\";\n\nimport type {\n ElementDescription,\n LocalElementKnown,\n BaseElementDescriptor,\n ElementDescriptorPattern,\n ElementDescriptorMode,\n ElementDescriptorWithType,\n ElementDescriptorWithCategory,\n ElementDescriptor,\n IgnoredElement,\n LocalElementUnknown,\n BaseElementDescription,\n} from \"./ElementsDescriptor.types\";\nimport {\n ELEMENT_DESCRIPTOR_MODES_MAP,\n ELEMENT_ORIGINS_MAP,\n} from \"./ElementsDescriptor.types\";\n\n/**\n * Determines if the given value is a valid element descriptor mode.\n * @param value The value to check.\n * @returns True if the value is a valid element descriptor mode, false otherwise.\n */\nexport function isElementDescriptorMode(\n value: unknown\n): value is ElementDescriptorMode {\n return (\n isString(value) &&\n Object.values(ELEMENT_DESCRIPTOR_MODES_MAP).includes(\n value as ElementDescriptorMode\n )\n );\n}\n\n/**\n * Determines if the given value is a valid element descriptor pattern.\n * @param value The value to check.\n * @returns True if the value is a valid element descriptor pattern, false otherwise.\n */\nexport function isElementDescriptorPattern(\n value: unknown\n): value is ElementDescriptorPattern {\n return (\n isString(value) ||\n (isArray(value) && !isEmptyArray(value) && value.every(isString))\n );\n}\n\n/**\n * Determines if the given value is a base element descriptor.\n * @param value The value to check.\n * @returns True if the value is a base element descriptor, false otherwise.\n */\nexport function isBaseElementDescriptor(\n value: unknown\n): value is BaseElementDescriptor {\n return (\n isObjectWithProperty(value, \"pattern\") &&\n isElementDescriptorPattern(value.pattern)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor with type.\n * @param value The value to check.\n * @returns True if the value is an element descriptor with type, false otherwise.\n */\nexport function isElementDescriptorWithType(\n value: unknown\n): value is ElementDescriptorWithType {\n return (\n isBaseElementDescriptor(value) &&\n isObjectWithProperty(value, \"type\") &&\n isString(value.type)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor with category.\n * @param value The value to check.\n * @returns True if the value is an element descriptor with category, false otherwise.\n */\nexport function isElementDescriptorWithCategory(\n value: unknown\n): value is ElementDescriptorWithCategory {\n return (\n isBaseElementDescriptor(value) &&\n isObjectWithProperty(value, \"category\") &&\n isString(value.category)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor.\n * @param value The value to check.\n * @returns True if the value is an element descriptor, false otherwise.\n */\nexport function isElementDescriptor(\n value: unknown\n): value is ElementDescriptor {\n return (\n isElementDescriptorWithType(value) || isElementDescriptorWithCategory(value)\n );\n}\n\n/**\n * Determines if the value is a BaseElement\n * @param value The value to check\n * @returns True if the value is a valid BaseElement, false otherwise\n */\nexport function isBaseElement(value: unknown): value is BaseElementDescription {\n return (\n isObjectWithProperty(value, \"type\") &&\n isObjectWithProperty(value, \"category\") &&\n isObjectWithProperty(value, \"path\") &&\n isObjectWithProperty(value, \"captured\") &&\n isObjectWithProperty(value, \"origin\") &&\n isObjectWithProperty(value, \"isIgnored\") &&\n isObjectWithProperty(value, \"isUnknown\")\n );\n}\n\n/**\n * Determines if the given value is an ignored element.\n * @param value The element to check.\n * @returns True if the element is an ignored element, false otherwise.\n */\nexport function isIgnoredElement(value: unknown): value is IgnoredElement {\n return (\n isBaseElement(value) &&\n isObjectWithProperty(value, \"isIgnored\") &&\n value.isIgnored === true\n );\n}\n\n/**\n * Determines if the given value is a local element.\n * @param value The value to check.\n * @returns True if the value is a local element, false otherwise.\n */\nexport function isLocalElement(\n value: unknown\n): value is LocalElementKnown | LocalElementUnknown {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.LOCAL;\n}\n\n/**\n * Determines if the given element is local and unknown, because its type and category could not be determined.\n * @param value The value to check.\n * @returns True if the element is an unknown element, false otherwise.\n */\nexport function isUnknownLocalElement(\n value: unknown\n): value is LocalElementUnknown {\n return isLocalElement(value) && value.isUnknown === true;\n}\n\n/**\n * Determines if the given element is local and known, because its type and category were determined.\n * @param value The value to check.\n * @returns True if the element is an unknown element, false otherwise.\n */\nexport function isKnownLocalElement(\n value: unknown\n): value is LocalElementKnown {\n return isLocalElement(value) && value.isUnknown === false;\n}\n\n/**\n * Determines if the given value is a local dependency element.\n * @param value The value to check.\n * @returns True if the element is a local dependency element, false otherwise.\n */\nexport function isLocalDependencyElement(\n value: unknown\n): value is LocalElementKnown | LocalElementUnknown {\n return isLocalElement(value) && value.isIgnored === false;\n}\n\n/**\n * Determines if the given value is an external element.\n * @param value The value to check.\n * @returns True if the element is an external dependency element, false otherwise.\n */\nexport function isExternalDependencyElement(\n value: unknown\n): value is ElementDescription {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.EXTERNAL;\n}\n\n/**\n * Determines if the given value is a core element.\n * @param value The value to check.\n * @returns True if the element is a core dependency element, false otherwise.\n */\nexport function isCoreDependencyElement(\n value: unknown\n): value is ElementDescription {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.CORE;\n}\n\n/**\n * Determines if the given value is an element (local or dependency).\n * @param value The value to check.\n * @returns True if the value is an element, false otherwise.\n */\nexport function isElementDescription(\n value: unknown\n): value is ElementDescription {\n return (\n isIgnoredElement(value) ||\n isUnknownLocalElement(value) ||\n isKnownLocalElement(value) ||\n isExternalDependencyElement(value) ||\n isCoreDependencyElement(value)\n );\n}\n","import type { ElementDescription } from \"./ElementsDescriptor.types\";\n\nexport const DEPENDENCY_KIND_TYPE = \"type\" as const;\nexport const DEPENDENCY_KIND_VALUE = \"value\" as const;\nexport const DEPENDENCY_KIND_TYPEOF = \"typeof\" as const;\n\n/** Map of the kinds of dependency, either a type dependency or a value dependency */\nexport const DEPENDENCY_KINDS_MAP = {\n /** Type import, e.g., `import type { X } from 'module'` */\n TYPE: DEPENDENCY_KIND_TYPE,\n\n /** Value import, e.g., `import { X } from 'module'` */\n VALUE: DEPENDENCY_KIND_VALUE,\n\n /** typeof import, e.g. `type ModuleType = typeof import(\"./my_module\");` */\n TYPE_OF: DEPENDENCY_KIND_TYPEOF,\n} as const;\n\n/** Kind of dependency, either a type dependency or a value dependency */\nexport type DependencyKind =\n (typeof DEPENDENCY_KINDS_MAP)[keyof typeof DEPENDENCY_KINDS_MAP];\n\n/** Map of possible kinds of relationships between elements being dependencies */\nexport const DEPENDENCY_RELATIONSHIPS_MAP = {\n /** The dependency is internal to the element */\n INTERNAL: \"internal\",\n /** The dependency is a child of the element */\n CHILD: \"child\",\n /** The dependency is a descendant of the element */\n DESCENDANT: \"descendant\",\n /** The dependency is a sibling of the element (both have the same parent) */\n SIBLING: \"sibling\",\n /** The dependency is a parent of the element */\n PARENT: \"parent\",\n /** The dependency is an uncle of the element */\n UNCLE: \"uncle\",\n /** The dependency is a nephew of the element */\n NEPHEW: \"nephew\",\n /** The dependency is an ancestor of the element */\n ANCESTOR: \"ancestor\",\n} as const;\n\nexport const DEPENDENCY_RELATIONSHIPS_INVERTED_MAP = {\n [DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL]:\n DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL,\n [DEPENDENCY_RELATIONSHIPS_MAP.CHILD]: DEPENDENCY_RELATIONSHIPS_MAP.PARENT,\n [DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT]:\n DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR,\n [DEPENDENCY_RELATIONSHIPS_MAP.SIBLING]: DEPENDENCY_RELATIONSHIPS_MAP.SIBLING,\n [DEPENDENCY_RELATIONSHIPS_MAP.PARENT]: DEPENDENCY_RELATIONSHIPS_MAP.CHILD,\n [DEPENDENCY_RELATIONSHIPS_MAP.UNCLE]: DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW,\n [DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW]: DEPENDENCY_RELATIONSHIPS_MAP.UNCLE,\n [DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR]:\n DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT,\n} as const;\n\n/** Kind of relationship between elements being dependencies */\nexport type DependencyRelationship =\n (typeof DEPENDENCY_RELATIONSHIPS_MAP)[keyof typeof DEPENDENCY_RELATIONSHIPS_MAP];\n\n/** Information about a dependency between two elements */\nexport type ElementsDependencyInfo = {\n /** Source of the dependency (import/export path) */\n source: string;\n /** Base source of the dependency for external/core modules */\n module: string | null;\n /** Kind of the dependency */\n kind: DependencyKind;\n /** Type of the node creating the dependency in the dependent element */\n nodeKind: string | null;\n /** Specifiers imported or exported in the dependency */\n specifiers: string[] | null;\n /** Relationship between the elements from both perspectives */\n relationship: {\n /** Relationship between the elements from the perspective of the file */\n from: DependencyRelationship | null;\n /** Relationship between the elements from the perspective of the dependency */\n to: DependencyRelationship | null;\n };\n};\n\n/**\n * Description of a dependency between two elements\n */\nexport type DependencyDescription = {\n /** Source element of the dependency */\n from: ElementDescription;\n /** Target element of the dependency */\n to: ElementDescription;\n /** Information about the dependency */\n dependency: ElementsDependencyInfo;\n};\n\n/**\n * Serialized cache of dependencies descriptor.\n */\nexport type DependenciesDescriptorSerializedCache = Record<\n string,\n DependencyDescription\n>;\n\n/** Options for describing a dependency between two elements */\nexport type DescribeDependencyOptions = {\n /** Path of the element where the dependency originates */\n from: string;\n /** Path of the element where the dependency points to */\n to?: string;\n /** Source of the dependency (import/export path) */\n source: string;\n /** Kind of the dependency (type, runtime) */\n kind: DependencyKind;\n /** Type of the node creating the dependency in the dependent element */\n nodeKind?: string;\n /** Specifiers imported or exported in the dependency */\n specifiers?: string[];\n};\n","import {\n isString,\n isObjectWithProperty,\n isNull,\n isNullish,\n isStringArray,\n} from \"../Support/TypeGuards\";\n\nimport type {\n DependencyKind,\n DependencyRelationship,\n ElementsDependencyInfo,\n DependencyDescription,\n} from \"./DependenciesDescriptor.types\";\nimport {\n DEPENDENCY_KINDS_MAP,\n DEPENDENCY_RELATIONSHIPS_MAP,\n} from \"./DependenciesDescriptor.types\";\nimport { isElementDescription } from \"./ElementsDescriptorHelpers\";\n\n/**\n * Determines if the value is a valid dependency kind.\n * @param value The value to check\n * @returns True if the value is a valid dependency kind, false otherwise.\n */\nexport function isDependencyKind(value: unknown): value is DependencyKind {\n return (\n isString(value) &&\n Object.values(DEPENDENCY_KINDS_MAP).includes(value as DependencyKind)\n );\n}\n\n/**\n * Determines if the given value is a valid dependency relationship.\n * @param value The value to check.\n * @returns True if the value is a valid dependency relationship, false otherwise.\n */\nexport function isDependencyRelationship(\n value: unknown\n): value is DependencyRelationship {\n return (\n isString(value) &&\n Object.values(DEPENDENCY_RELATIONSHIPS_MAP).includes(\n value as DependencyRelationship\n )\n );\n}\n\n/**\n * Determines if the given value is a valid dependency relationship description.\n * @param value The value to check.\n * @returns True if the value is a valid dependency relationship, false otherwise.\n */\nexport function isDependencyRelationshipDescription(\n value: unknown\n): value is DependencyRelationship {\n return (\n isObjectWithProperty(value, \"to\") &&\n (isNull(value.to) || isDependencyRelationship(value.to)) &&\n isObjectWithProperty(value, \"from\") &&\n (isNull(value.from) || isDependencyRelationship(value.from))\n );\n}\n\n/**\n * Returns whether the given value is a valid ElementsDependencyInfo object.\n * @param value The value to check.\n * @returns True if the value is a valid ElementsDependencyInfo object, false otherwise.\n */\nexport function isElementsDependencyInfo(\n value: unknown\n): value is ElementsDependencyInfo {\n return (\n isObjectWithProperty(value, \"source\") &&\n isString(value.source) &&\n isObjectWithProperty(value, \"module\") &&\n (isNullish(value.module) || isString(value.module)) &&\n isObjectWithProperty(value, \"kind\") &&\n isDependencyKind(value.kind) &&\n isObjectWithProperty(value, \"relationship\") &&\n isDependencyRelationshipDescription(value.relationship) &&\n isObjectWithProperty(value, \"nodeKind\") &&\n (isNull(value.nodeKind) || isString(value.nodeKind)) &&\n isObjectWithProperty(value, \"specifiers\") &&\n (isNull(value.specifiers) || isStringArray(value.specifiers))\n );\n}\n\n/**\n * Determines whether the given value is a valid DependencyDescription object.\n * @param value The value to check\n * @returns True if the value is a valid DependencyDescription object, false otherwise.\n */\nexport function isDependencyDescription(\n value: unknown\n): value is DependencyDescription {\n return (\n isObjectWithProperty(value, \"to\") &&\n isElementDescription(value.to) &&\n isObjectWithProperty(value, \"from\") &&\n isElementDescription(value.from) &&\n isObjectWithProperty(value, \"dependency\") &&\n isElementsDependencyInfo(value.dependency)\n );\n}\n\n/**\n * Determines whether the given dependency description is internal.\n * @param dependency The dependency to check\n * @returns True if the dependency is internal, false otherwise\n */\nexport function isInternalDependency(\n dependency: DependencyDescription\n): boolean {\n return (\n dependency.dependency.relationship.to ===\n DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL\n );\n}\n","import { isString } from \"../Support\";\n\nimport type { NotUndefined } from \"./Cache.types\";\n\n/**\n * Generic cache manager class. Enables caching of values based on complex keys.\n */\nexport class CacheManager<CacheKey extends NotUndefined, CachedValue> {\n /**\n * Internal cache map\n */\n private readonly _cache: Map<string, CachedValue>;\n\n /**\n * Creates a new CacheManager instance\n */\n constructor() {\n this._cache = new Map<string, CachedValue>();\n }\n\n /**\n * Generates a string key from the given cache key. Has to be implemented for non-string keys.\n * @param key The cache key to generate from\n * @returns The generated string key\n */\n protected generateKey(key: CacheKey): string {\n if (isString(key)) {\n return key;\n }\n const errorMessage =\n \"Cache key generation for non-string keys is not implemented because it causes performance issues: \" +\n JSON.stringify(key);\n throw new Error(errorMessage);\n }\n\n /**\n * Generates a hashed key for the given cache key\n * @param key The cache key to hash\n * @returns The hashed key as a string\n */\n public getKey(key: CacheKey): string {\n return this.generateKey(key);\n }\n\n /**\n * Retrieves a value from the cache based on the given hashed key\n * @param hashedKey The hashed key to retrieve\n * @returns The cached value or undefined if not found\n */\n public get(hashedKey: string): CachedValue | undefined {\n return this._cache.get(hashedKey);\n }\n\n /**\n * Stores a value in the cache with a given hashed key\n * @param hashedKey The hashed key to store\n * @param value The value to cache\n */\n public set(hashedKey: string, value: CachedValue): void {\n this._cache.set(hashedKey, value);\n }\n\n /**\n * Checks if a value exists in the cache based on the given hashed key\n * @param hashedKey The hashed key to check\n * @returns True if the value exists, false otherwise\n */\n public has(hashedKey: string): boolean {\n return this._cache.has(hashedKey);\n }\n\n /**\n * Retrieves all cached values\n * @returns A map of all cached values\n */\n public getAll(): Map<string, CachedValue> {\n return this._cache;\n }\n\n /**\n * Clears the entire cache\n */\n public clear(): void {\n this._cache.clear();\n }\n\n /**\n * Serializes the cache to a plain object.\n * @returns The serialized cache.\n */\n public serialize(): Record<string, CachedValue> {\n return Array.from(this.getAll().entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = value;\n return acc;\n },\n {} as Record<string, CachedValue>\n );\n }\n\n /**\n * Sets the cache from a serialized object.\n * @param serializedCache The serialized cache.\n */\n public setFromSerialized(serializedCache: Record<string, CachedValue>): void {\n for (const key in serializedCache) {\n this.set(key, serializedCache[key]);\n }\n }\n}\n","import { CacheManager } from \"./Cache\";\nimport type { NotUndefined } from \"./Cache.types\";\n\n/**\n * Disabled cache manager class. Disables caching of values.\n */\nexport class CacheManagerDisabled<\n CacheKey extends NotUndefined,\n CachedValue,\n> extends CacheManager<CacheKey, CachedValue> {\n /**\n * Generates a fake cache key as caching is disabled\n * @param key The cache key to hash\n * @returns An empty string\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getKey(_key: CacheKey): string {\n return \"\";\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to retrieve\n * @returns Undefined as caching is disabled\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public get(_hashedKey: string): CachedValue | undefined {\n return undefined;\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to store\n * @param value The value to cache\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public set(_hashedKey: string, _value: CachedValue): void {\n return;\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to check\n * @returns False as caching is disabled\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public has(_hashedKey: string): boolean {\n return false;\n }\n}\n","import { CacheManager } from \"../Cache\";\n\nimport type {\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\n\n/**\n * Cache to store previously described dependencies.\n */\nexport class DependenciesDescriptionsCache extends CacheManager<\n DescribeDependencyOptions,\n DependencyDescription\n> {\n /** Generates a unique key for the given dependency description options.\n * @param options The options to generate the key from.\n * @returns The generated key.\n */\n protected generateKey(options: {\n from: string;\n to?: string;\n source: string;\n kind: string;\n nodeKind?: string;\n specifiers?: string[];\n }): string {\n return `${options.from}|${options.to}|${options.source}|${options.kind}|${\n options.nodeKind\n }|${options.specifiers ? options.specifiers.join(\",\") : \"\"}`;\n }\n}\n","import { CacheManagerDisabled } from \"../Cache\";\nimport type { DescriptorOptionsNormalized } from \"../Config\";\n\nimport { DependenciesDescriptionsCache } from \"./DependenciesDescriptionsCache\";\nimport {\n DEPENDENCY_RELATIONSHIPS_MAP,\n DEPENDENCY_RELATIONSHIPS_INVERTED_MAP,\n} from \"./DependenciesDescriptor.types\";\nimport type {\n DependenciesDescriptorSerializedCache,\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\nimport type { ElementsDescriptor } from \"./ElementsDescriptor\";\nimport type {\n ElementDescription,\n LocalElementKnown,\n} from \"./ElementsDescriptor.types\";\nimport {\n isIgnoredElement,\n isKnownLocalElement,\n} from \"./ElementsDescriptorHelpers\";\n\n/**\n * Class describing dependencies between elements.\n */\nexport class DependenciesDescriptor {\n /**\n * Cache to store previously described dependencies.\n */\n private readonly _dependenciesCache:\n | DependenciesDescriptionsCache\n | CacheManagerDisabled<DescribeDependencyOptions, DependencyDescription>;\n\n /**\n * Elements descriptor instance.\n */\n private readonly _elementsDescriptor: ElementsDescriptor;\n\n /**\n * Configuration options.\n */\n private readonly _config: DescriptorOptionsNormalized;\n\n /**\n * Creates a new DependenciesDescriptor instance.\n * @param elementsDescriptor The elements descriptor instance.\n * @param config The configuration options.\n */\n constructor(\n elementsDescriptor: ElementsDescriptor,\n config: DescriptorOptionsNormalized\n ) {\n this._elementsDescriptor = elementsDescriptor;\n this._config = config;\n this._dependenciesCache = this._config.cache\n ? new DependenciesDescriptionsCache()\n : new CacheManagerDisabled<\n DescribeDependencyOptions,\n DependencyDescription\n >();\n }\n\n /**\n * Serializes the elements cache to a plain object.\n * @returns The serialized elements cache.\n */\n public serializeCache(): DependenciesDescriptorSerializedCache {\n return this._dependenciesCache.serialize();\n }\n\n /**\n * Sets the elements cache from a serialized object.\n * @param serializedCache The serialized elements cache.\n */\n public setCacheFromSerialized(\n serializedCache: DependenciesDescriptorSerializedCache\n ): void {\n this._dependenciesCache.setFromSerialized(serializedCache);\n }\n\n /**\n * Clears the elements cache.\n */\n public clearCache(): void {\n this._dependenciesCache.clear();\n }\n\n /**\n * Retrieves the element path of the parent of a given element.\n * @param elementInfo The element whose parent is to be retrieved.\n * @returns The parent element path, or undefined if none exists.\n */\n private _getParent(elementInfo: LocalElementKnown) {\n return elementInfo.parents[0]?.elementPath;\n }\n\n /**\n * Retrieves the common ancestor of two elements.\n * @param elementInfoA The first element.\n * @param elementInfoB The second element.\n * @returns The common ancestor element path, or undefined if none exists.\n */\n private _getCommonAncestor(\n elementInfoA: LocalElementKnown,\n elementInfoB: LocalElementKnown\n ) {\n const commonAncestor = elementInfoA.parents.find((elementParentA) => {\n return elementInfoB.parents.some((elementParentB) => {\n return elementParentA.elementPath === elementParentB.elementPath;\n });\n });\n return commonAncestor?.elementPath;\n }\n\n /**\n * Checks if the parent of element A is an ancestor of element B.\n * @param elementA The element A.\n * @param elementB The element B.\n * @returns True if the parent of element A is an ancestor of element B, false otherwise.\n */\n private _isDescendantOfParent(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n const commonAncestor = this._getCommonAncestor(elementA, elementB);\n return commonAncestor && commonAncestor === this._getParent(elementA);\n }\n\n /**\n * Checks if two elements are siblings (same parent).\n * @param elementA The first element.\n * @param elementB The second element.\n * @returns True if the elements are siblings, false otherwise.\n */\n private _isSibling(elementA: LocalElementKnown, elementB: LocalElementKnown) {\n const parentA = this._getParent(elementA);\n const parentB = this._getParent(elementB);\n return parentA && parentB && parentA === parentB;\n }\n\n /**\n * Checks if one element is a descendant of another.\n * @param elementA The potential descendant element.\n * @param elementB The potential ancestor element.\n * @returns True if elementA is a descendant of elementB, false otherwise.\n */\n private _isDescendant(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n return elementA.parents.some(\n (parent) => parent.elementPath === elementB.elementPath\n );\n }\n\n /**\n * Checks if one element is a child of another.\n * @param elementA The potential child element.\n * @param elementB The potential parent element.\n * @returns True if elementA is a child of elementB, false otherwise.\n */\n private _isChild(elementA: LocalElementKnown, elementB: LocalElementKnown) {\n return this._getParent(elementA) === elementB.elementPath;\n }\n\n /**\n * Checks if two local elements are internally related (same element).\n * @param elementA The first element.\n * @param elementB The second element.\n * @returns True if the elements are internally related, false otherwise.\n */\n private _isInternal(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n return elementA.elementPath === elementB.elementPath;\n }\n\n /**\n * Retrieves the relationship between two local known elements in terms of dependency.\n * @param element The element depending on another element.\n * @param dependency The element being depended on.\n * @returns The relationship between the elements.\n */\n private _dependencyRelationship(\n element: ElementDescription,\n dependency: ElementDescription\n ) {\n if (\n isIgnoredElement(dependency) ||\n !isKnownLocalElement(dependency) ||\n !isKnownLocalElement(element)\n ) {\n return null;\n }\n if (this._isInternal(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL;\n }\n if (this._isChild(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.CHILD;\n }\n if (this._isDescendant(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT;\n }\n if (this._isSibling(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.SIBLING;\n }\n if (this._isChild(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.PARENT;\n }\n if (this._isDescendant(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR;\n }\n if (this._isDescendantOfParent(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.UNCLE;\n }\n if (this._isDescendantOfParent(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW;\n }\n return null;\n }\n\n private _dependencyRelationships(\n element: ElementDescription,\n dependency: ElementDescription\n ) {\n const toRelationship = this._dependencyRelationship(element, dependency);\n const fromRelationship = toRelationship\n ? DEPENDENCY_RELATIONSHIPS_INVERTED_MAP[toRelationship]\n : null;\n return {\n from: fromRelationship,\n to: toRelationship,\n };\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency({\n from,\n to,\n source,\n kind,\n nodeKind,\n specifiers,\n }: DescribeDependencyOptions): DependencyDescription {\n const cacheKey = this._dependenciesCache.getKey({\n from,\n to,\n source,\n kind,\n nodeKind,\n specifiers,\n });\n if (this._dependenciesCache.has(cacheKey)) {\n return this._dependenciesCache.get(cacheKey)!;\n }\n\n const fromElement = this._elementsDescriptor.describeElement(from);\n const toElement = this._elementsDescriptor.describeElement(to, source);\n const { module: dependencyModule, ...toElementDescription } = toElement;\n\n const result = {\n from: fromElement,\n to: toElementDescription,\n dependency: {\n source,\n module: dependencyModule || null,\n kind,\n nodeKind: nodeKind || null,\n relationship: this._dependencyRelationships(\n fromElement,\n toElementDescription\n ),\n specifiers: specifiers || null,\n },\n };\n\n this._dependenciesCache.set(cacheKey, result);\n\n return result;\n }\n}\n","import type Mod from \"node:module\";\n\nimport isCoreModule from \"is-core-module\";\n\nimport { CacheManager, CacheManagerDisabled } from \"../Cache\";\nimport type { DescriptorOptionsNormalized, MicromatchPattern } from \"../Config\";\nimport type { Micromatch } from \"../Matcher\";\nimport { isArray, isNullish, normalizePath } from \"../Support\";\n\nimport type {\n ElementDescriptionWithSource,\n ElementDescription,\n ElementDescriptor,\n ElementDescriptors,\n LocalElementKnown,\n CapturedValues,\n LocalElementUnknown,\n ElementsDescriptorSerializedCache,\n} from \"./ElementsDescriptor.types\";\nimport {\n ELEMENT_DESCRIPTOR_MODES_MAP,\n ELEMENT_ORIGINS_MAP,\n} from \"./ElementsDescriptor.types\";\nimport {\n isElementDescriptorMode,\n isKnownLocalElement,\n isElementDescriptor,\n} from \"./ElementsDescriptorHelpers\";\n\nconst UNKNOWN_ELEMENT: LocalElementUnknown = {\n path: null,\n elementPath: null,\n internalPath: null,\n parents: null,\n type: null,\n category: null,\n captured: null,\n origin: ELEMENT_ORIGINS_MAP.LOCAL,\n isIgnored: false,\n isUnknown: true,\n};\n\n/** Options for the _fileDescriptorMatch private method */\ntype FileDescriptorMatchOptions = {\n /** The element descriptor to match. */\n elementDescriptor: ElementDescriptor;\n /** The file path to match against the descriptor */\n filePath: string;\n /** The current path segments leading to the element */\n currentPathSegments: string[];\n /** The last path segment that was matched */\n lastPathSegmentMatching: number;\n /** Whether the element matched previously */\n alreadyMatched: boolean;\n};\n\nconst SCOPED_PACKAGE_REGEX = /^@[^/]*\\/?[^/]+/;\nconst EXTERNAL_PATH_REGEX = /^\\w/;\n\n/**\n * Class describing elements in a project given their paths and configuration.\n */\nexport class ElementsDescriptor {\n private _mod: typeof Mod | null = null;\n /**\n * Cache to store previously described elements.\n */\n private readonly _descriptionsCache:\n | CacheManager<string, ElementDescription | ElementDescriptionWithSource>\n | CacheManagerDisabled<\n string,\n ElementDescription | ElementDescriptionWithSource\n >;\n\n /**\n * Cache to store previously described files.\n */\n private readonly _filesCache:\n | CacheManager<string, ElementDescription>\n | CacheManagerDisabled<string, ElementDescription>;\n\n /**\n * Configuration instance for this descriptor.\n */\n private readonly _config: DescriptorOptionsNormalized;\n\n /**\n * Element descriptors used by this descriptor.\n */\n private readonly _elementDescriptors: ElementDescriptors;\n\n /** Micromatch instance for path matching */\n private readonly _micromatch: Micromatch;\n\n /**\n * The configuration options for this descriptor.\n * @param elementDescriptors The element descriptors.\n * @param configOptions The configuration options.\n * @param globalCache The global cache for various caching needs.\n * @param micromatch The micromatch instance for path matching.\n */\n constructor(\n elementDescriptors: ElementDescriptors,\n configOptions: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._micromatch = micromatch;\n this._elementDescriptors = elementDescriptors;\n this._validateDescriptors(elementDescriptors);\n this._config = configOptions;\n this._filesCache = this._config.cache\n ? new CacheManager<string, ElementDescription>()\n : new CacheManagerDisabled<string, ElementDescription>();\n this._descriptionsCache = this._config.cache\n ? new CacheManager<string, ElementDescription>()\n : new CacheManagerDisabled<string, ElementDescription>();\n this._loadModuleInNode();\n }\n\n /**\n * Serializes the elements cache to a plain object.\n * @returns The serialized elements cache.\n */\n public serializeCache(): ElementsDescriptorSerializedCache {\n return {\n descriptions: this._descriptionsCache.serialize(),\n files: this._filesCache.serialize(),\n };\n }\n\n /**\n * Sets the elements cache from a serialized object.\n * @param serializedCache The serialized elements cache.\n */\n public setCacheFromSerialized(\n serializedCache: ElementsDescriptorSerializedCache\n ): void {\n this._descriptionsCache.setFromSerialized(serializedCache.descriptions);\n this._filesCache.setFromSerialized(serializedCache.files);\n }\n\n /**\n * Clears the elements cache.\n */\n public clearCache(): void {\n this._descriptionsCache.clear();\n this._filesCache.clear();\n }\n\n /**\n * Loads the Node.js module to access built-in modules information when running in Node.js environment.\n */\n private _loadModuleInNode(): void {\n // istanbul ignore next: Fallback for non-Node.js environments\n if (\n !this._mod &&\n !isNullish(process) &&\n !isNullish(process.versions) &&\n !isNullish(process.versions.node)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n this._mod = require(\"node:module\");\n }\n }\n\n /**\n * Validates the element descriptors to ensure they are correctly defined.\n */\n private _validateDescriptors(elementDescriptors: ElementDescriptors): void {\n let index = 0;\n for (const descriptor of elementDescriptors) {\n if (!isElementDescriptor(descriptor)) {\n throw new Error(\n `Element descriptor at index ${index} must have a pattern, and either a 'type' or 'category' defined.`\n );\n }\n index++;\n }\n }\n\n /**\n * Determines if a dependency source is a core module.\n * @param dependencySource The source of the dependency to check.\n * @param baseDependencySource The base source of the dependency to check.\n * @returns True if the dependency source is a core module, false otherwise.\n */\n private _dependencySourceIsCoreModule(\n dependencySource: string,\n baseDependencySource: string\n ): boolean {\n // istanbul ignore next: Fallback for non-Node.js environments\n if (this._mod) {\n const moduleWithoutPrefix = baseDependencySource.startsWith(\"node:\")\n ? baseDependencySource.slice(5)\n : baseDependencySource;\n return this._mod.builtinModules.includes(moduleWithoutPrefix);\n }\n // istanbul ignore next: Fallback for non-Node.js environments\n return isCoreModule(dependencySource);\n }\n\n /**\n * Determines if a dependency source is scoped (e.g., @scope/package).\n * @param dependencySource The source of the dependency to check.\n * @returns True if the dependency source is scoped, false otherwise.\n */\n private _dependencySourceIsScoped(dependencySource: string): boolean {\n return SCOPED_PACKAGE_REGEX.test(dependencySource);\n }\n\n /**\n * Determines if a dependency source is external or an alias.\n * @param dependencySource The source of the dependency to check.\n * @returns True if the dependency source is external or an alias, false otherwise.\n */\n private _dependencySourceIsExternalOrScoped(\n dependencySource: string\n ): boolean {\n return (\n EXTERNAL_PATH_REGEX.test(dependencySource) ||\n this._dependencySourceIsScoped(dependencySource)\n );\n }\n\n /**\n * Gets the base source of an external module.\n * @param dependencySource The source of the dependency to check.\n * @returns The base source of the external module. (e.g., for \"@scope/package/submodule\", it returns \"@scope/package\")\n */\n private _getExternalOrCoreModuleModule(dependencySource: string): string {\n if (this._dependencySourceIsScoped(dependencySource)) {\n const [scope, packageName] = dependencySource.split(\"/\");\n return `${scope}/${packageName}`;\n }\n const [pkg] = dependencySource.split(\"/\");\n return pkg;\n }\n\n /**\n * Determines if a file path is outside the configured root path.\n * @param filePath The file path to check.\n * @returns True if the file path is outside the root path, false otherwise.\n */\n private _isOutsideRootPath(filePath: string): boolean {\n if (!this._config.rootPath) {\n return false;\n }\n return !filePath.startsWith(this._config.rootPath);\n }\n\n /**\n * Converts an absolute file path to a relative path if rootPath is configured.\n * If rootPath is not configured, returns the path as-is (maintains backward compatibility).\n * @param filePath The file path to convert (can be absolute or relative)\n * @returns The relative path if rootPath is configured and path is absolute, otherwise the original path\n */\n private _toRelativePath(filePath: string): string {\n if (!this._config.rootPath || this._isOutsideRootPath(filePath)) {\n return filePath;\n }\n return filePath.replace(this._config.rootPath, \"\");\n }\n\n /**\n * Checks if a source string matches any of the provided patterns using micromatch.\n * @param patterns - Array of micromatch patterns\n * @param source - The source string to match against patterns\n * @returns True if the source matches any pattern, false otherwise\n */\n private _matchesAnyPattern(\n patterns: MicromatchPattern,\n source?: string\n ): boolean {\n if (!source || patterns.length === 0) {\n return false;\n }\n return this._micromatch.isMatch(source, patterns);\n }\n\n /**\n * Determines if an element is external based on its file path and dependency source.\n * Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:\n * - unresolvableAlias: Files whose path cannot be resolved (filePath is null)\n * - inNodeModules: Non-relative paths that include \"node_modules\"\n * - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)\n * - customSourcePatterns: Source matches any of the configured patterns\n * @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.\n * @param isOutsideRootPath Whether the file path is outside the configured root path.\n * @param dependencySource The import/export source string\n * @returns True if any of the configured conditions is met, false otherwise\n */\n private _isExternalDependency(\n filePath: string | null,\n isOutsideRootPath: boolean,\n dependencySource?: string\n ): boolean {\n const {\n unresolvableAlias,\n inNodeModules,\n outsideRootPath,\n customSourcePatterns,\n } = this._config.flagAsExternal;\n\n // Check outsideRootPath: resolved path is outside configured root path\n if (outsideRootPath && isOutsideRootPath) {\n return true;\n }\n\n // Check inNodeModules: path includes node_modules\n if (inNodeModules && filePath?.includes(\"node_modules\")) {\n return true;\n }\n\n // Check unresolvableAlias: dependency whose path cannot be resolved\n if (\n unresolvableAlias &&\n !filePath &&\n dependencySource &&\n this._dependencySourceIsExternalOrScoped(dependencySource)\n ) {\n return true;\n }\n\n // Check customSourcePatterns: source matches configured patterns\n if (this._matchesAnyPattern(customSourcePatterns, dependencySource)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines if a given path is included based on the configuration.\n * Uses caching for better performance on repeated calls.\n * @param elementPath The element path to check.\n * @param includeExternal Whether to include external files.\n * @returns True if the path is included, false otherwise.\n */\n private _pathIsIncluded(elementPath: string): boolean {\n let result: boolean;\n\n if (this._config.includePaths && this._config.ignorePaths) {\n const isIncluded = this._micromatch.isMatch(\n elementPath,\n this._config.includePaths\n );\n const isIgnored = this._micromatch.isMatch(\n elementPath,\n this._config.ignorePaths\n );\n result = isIncluded && !isIgnored;\n } else if (this._config.includePaths) {\n result = this._micromatch.isMatch(elementPath, this._config.includePaths);\n } else if (this._config.ignorePaths) {\n result = !this._micromatch.isMatch(elementPath, this._config.ignorePaths);\n } else {\n result = true;\n }\n\n return result;\n }\n\n /**\n * Gets captured values from the captured array and capture configuration.\n * @param captured The array of captured strings.\n * @param captureConfig The configuration for capturing values.\n * @returns The captured values as an object.\n */\n private _getCapturedValues(\n captured: string[],\n captureConfig?: string[]\n ): CapturedValues | null {\n if (!captureConfig) {\n return null;\n }\n return captured.reduce((capturedValues, captureValue, index) => {\n if (captureConfig[index]) {\n capturedValues[captureConfig[index]] = captureValue;\n }\n return capturedValues;\n }, {} as CapturedValues);\n }\n\n /**\n * Gets the element path based on the path pattern, path segments to the element, and all path segments from the file path.\n * @param pathPattern The element path pattern.\n * @param pathSegments The path segments leading to the element.\n * @param allPathSegments The full path segments from the file path.\n * @returns The element path.\n */\n private _getElementPath(\n pathPattern: string,\n pathSegments: string[],\n allPathSegments: string[]\n ): string {\n const elementPathRegexp = this._micromatch.makeRe(pathPattern);\n\n const testedSegments: string[] = [];\n let result: string | undefined;\n\n for (const pathSegment of pathSegments) {\n testedSegments.push(pathSegment);\n const joinedSegments = testedSegments.join(\"/\");\n if (elementPathRegexp.test(joinedSegments)) {\n result = joinedSegments;\n break; // Early exit when match is found\n }\n }\n // NOTE: result should never be undefined here, as we already matched the pattern before\n return `${[...allPathSegments].reverse().join(\"/\").split(result!)[0]}${result}`;\n }\n\n /**\n * Determines if an element descriptor matches the given parameters in the provided path.\n * @param options The options for matching the descriptor.\n * @returns The result of the match, including whether it matched and any captured values.\n */\n private _fileDescriptorMatch(options: FileDescriptorMatchOptions): {\n matched: true;\n capture: string[];\n baseCapture: string[] | null;\n useFullPathMatch: boolean;\n patternUsed: string;\n };\n\n /**\n * Determines if an element descriptor matches the given parameters in the provided path.\n * @param options The options for matching the descriptor.\n * @param options.elementDescriptor The element descriptor to match.\n * @param options.filePath The file path to match against the descriptor.\n * @param options.currentPathSegments The current path segments leading to the element.\n * @param options.lastPathSegmentMatching The last path segment that was matched.\n * @param options.alreadyMatched Whether the element matched previously.\n * @returns The result of the match, including whether it matched.\n */\n private _fileDescriptorMatch({\n elementDescriptor,\n filePath,\n currentPathSegments,\n lastPathSegmentMatching,\n alreadyMatched,\n }: FileDescriptorMatchOptions): {\n matched: boolean;\n capture?: string[];\n baseCapture?: string[] | null;\n useFullPathMatch?: boolean;\n patternUsed?: string;\n } {\n const mode = isElementDescriptorMode(elementDescriptor.mode)\n ? elementDescriptor.mode\n : ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER;\n const patterns = isArray(elementDescriptor.pattern)\n ? elementDescriptor.pattern\n : [elementDescriptor.pattern];\n\n for (const pattern of patterns) {\n const useFullPathMatch =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FULL && !alreadyMatched;\n const effectivePattern =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER && !alreadyMatched\n ? `${pattern}/**/*`\n : pattern;\n\n const targetPath = useFullPathMatch\n ? filePath\n : currentPathSegments.join(\"/\");\n\n let baseCapture: string[] | null = null;\n let hasCapture = true;\n\n if (elementDescriptor.basePattern) {\n const baseTarget = filePath\n .split(\"/\")\n .slice(0, filePath.split(\"/\").length - lastPathSegmentMatching)\n .join(\"/\");\n baseCapture = this._micromatch.capture(\n [elementDescriptor.basePattern, \"**\", effectivePattern].join(\"/\"),\n baseTarget\n );\n hasCapture = baseCapture !== null;\n }\n\n const capture = this._micromatch.capture(effectivePattern, targetPath);\n\n if (capture && hasCapture) {\n return {\n matched: true,\n capture,\n baseCapture,\n useFullPathMatch,\n patternUsed: pattern,\n };\n }\n }\n\n return { matched: false };\n }\n\n /**\n * Retrieves the description of a local file given its path.\n * @param elementPath The path of the element to describe.\n * @returns The description of the element.\n */\n private _getFileDescription(filePath?: string): ElementDescription {\n // Return unknown element if no file path is provided. Filepath couldn't be resolved.\n if (!filePath) {\n return {\n ...UNKNOWN_ELEMENT,\n };\n }\n\n // Return ignored element if the path is not included in the configuration.\n if (!this._pathIsIncluded(filePath)) {\n return {\n ...UNKNOWN_ELEMENT,\n path: filePath,\n isIgnored: true,\n origin: null,\n };\n }\n\n const parents: LocalElementKnown[\"parents\"] = [];\n const elementResult: Partial<LocalElementKnown> = {\n path: filePath,\n type: null,\n category: null,\n captured: null,\n origin: ELEMENT_ORIGINS_MAP.LOCAL,\n isIgnored: false,\n };\n\n interface State {\n pathSegmentsAccumulator: string[];\n lastPathSegmentMatching: number;\n }\n\n const state: State = {\n pathSegmentsAccumulator: [],\n lastPathSegmentMatching: 0,\n };\n\n const pathSegments = filePath.split(\"/\").reverse();\n\n const processElementMatch = (\n elementDescriptor: ElementDescriptor,\n matchInfo: {\n matched: true;\n capture: string[];\n baseCapture: string[] | null;\n useFullPathMatch: boolean;\n patternUsed: string;\n },\n currentPathSegments: string[],\n elementPaths: string[]\n ) => {\n const { capture, baseCapture, useFullPathMatch, patternUsed } = matchInfo;\n\n let capturedValues = this._getCapturedValues(\n capture,\n elementDescriptor.capture\n );\n\n if (elementDescriptor.basePattern && baseCapture) {\n capturedValues = {\n ...this._getCapturedValues(\n baseCapture,\n elementDescriptor.baseCapture\n ),\n ...capturedValues,\n };\n }\n\n const elementPath = useFullPathMatch\n ? filePath\n : this._getElementPath(patternUsed, currentPathSegments, elementPaths);\n\n if (!elementResult.type && !elementResult.category) {\n const mode =\n elementDescriptor.mode || ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER;\n // It is the main element\n elementResult.type = elementDescriptor.type || null;\n elementResult.category = elementDescriptor.category || null;\n elementResult.isUnknown = false;\n elementResult.elementPath = elementPath;\n elementResult.captured = capturedValues;\n elementResult.internalPath =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER ||\n filePath !== elementPath // When using 'file' mode, but the pattern matches a folder, we need to calculate the internal path\n ? filePath.replace(`${elementPath}/`, \"\")\n : filePath.split(\"/\").pop(); // In 'file' mode, if the pattern matches the full file, internalPath is the file name\n } else {\n // It is a parent element, because we have already matched the main one\n parents.push({\n type: elementDescriptor.type || null,\n category: elementDescriptor.category || null,\n elementPath,\n captured: capturedValues,\n });\n }\n };\n\n // Optimized matching loop - reduced complexity from O(n*m) to better performance\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i];\n state.pathSegmentsAccumulator.unshift(segment);\n\n // Early exit if we have both type and category (main element found)\n const alreadyHasMainElement =\n Boolean(elementResult.type) || Boolean(elementResult.category);\n\n for (const elementDescriptor of this._elementDescriptors) {\n const match = this._fileDescriptorMatch({\n elementDescriptor,\n filePath,\n currentPathSegments: state.pathSegmentsAccumulator,\n lastPathSegmentMatching: state.lastPathSegmentMatching,\n alreadyMatched: alreadyHasMainElement,\n });\n\n if (match.matched) {\n processElementMatch(\n elementDescriptor,\n match,\n state.pathSegmentsAccumulator,\n pathSegments\n );\n state.pathSegmentsAccumulator = [];\n state.lastPathSegmentMatching = i + 1;\n\n // Break out of the inner loop since we found a match\n break;\n }\n }\n }\n\n const result = { ...elementResult, parents };\n\n // Not matched as any element, ensure that it is marked as unknown\n if (!isKnownLocalElement(result)) {\n return {\n ...UNKNOWN_ELEMENT,\n path: filePath,\n };\n }\n\n return result;\n }\n\n /**\n * Describes a file given its path.\n * @param includeExternal Whether to include external files (inside node_modules) in the matching process.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n private _describeFile(filePath?: string): ElementDescription {\n const cacheKey = this._filesCache.getKey(String(filePath));\n if (this._filesCache.has(cacheKey)) {\n return this._filesCache.get(cacheKey)!;\n }\n const description = this._getFileDescription(filePath);\n this._filesCache.set(cacheKey, description);\n return description;\n }\n\n /**\n * Returns an external or core dependency element given its dependency source and file path.\n * @param dependencySource The source of the dependency.\n * @param isOutsideRootPath Whether the file path is outside the configured root path.\n * @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.\n * @returns The external or core dependency element, or null if it is a local dependency.\n */\n private _getExternalOrCoreDependencyElement(\n dependencySource: string,\n isOutsideRootPath: boolean,\n filePath?: string\n ): ElementDescriptionWithSource | null {\n const baseDependencySource =\n this._getExternalOrCoreModuleModule(dependencySource);\n\n // Determine if the dependency source is a core module\n const isCore = this._dependencySourceIsCoreModule(\n dependencySource,\n baseDependencySource\n );\n\n if (isCore) {\n const coreElement: ElementDescriptionWithSource = {\n ...UNKNOWN_ELEMENT,\n module: baseDependencySource,\n origin: ELEMENT_ORIGINS_MAP.CORE,\n };\n return coreElement;\n }\n\n const isExternal = this._isExternalDependency(\n filePath || null,\n isOutsideRootPath,\n dependencySource\n );\n\n if (isExternal) {\n const externalElement: ElementDescriptionWithSource = {\n ...UNKNOWN_ELEMENT,\n path: filePath || null,\n internalPath:\n dependencySource.replace(baseDependencySource, \"\") || null,\n module: baseDependencySource,\n origin: ELEMENT_ORIGINS_MAP.EXTERNAL,\n };\n return externalElement;\n }\n return null;\n }\n\n /**\n * Describes an element given its file path and dependency source, if any.\n * @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.\n * @param dependencySource The source of the dependency, if the element to describe is so. It refers to the import/export path used to reference the file or external module.\n * @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.\n */\n private _describeElement(): LocalElementUnknown;\n private _describeElement(filePath?: string): ElementDescription;\n private _describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescriptionWithSource;\n\n private _describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescription | ElementDescriptionWithSource {\n const cacheKey = `${String(dependencySource)}::${String(filePath)}`;\n if (this._descriptionsCache.has(cacheKey)) {\n return this._descriptionsCache.get(cacheKey)!;\n }\n\n const normalizedFilePath = filePath ? normalizePath(filePath) : filePath;\n const isOutsideRootPath = normalizedFilePath\n ? this._isOutsideRootPath(normalizedFilePath)\n : false;\n const relativePath =\n normalizedFilePath && this._config.rootPath\n ? this._toRelativePath(normalizedFilePath)\n : normalizedFilePath;\n\n const externalOrCoreDependencyElement = dependencySource\n ? this._getExternalOrCoreDependencyElement(\n dependencySource,\n isOutsideRootPath,\n relativePath\n )\n : null;\n\n if (externalOrCoreDependencyElement) {\n this._descriptionsCache.set(cacheKey, externalOrCoreDependencyElement);\n return externalOrCoreDependencyElement;\n }\n\n const fileDescription = this._describeFile(relativePath);\n\n this._descriptionsCache.set(cacheKey, fileDescription);\n return fileDescription;\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.\n * @returns The description of the element.\n */\n public describeElement(filePath?: string): ElementDescription;\n /**\n * Describes a dependency target element given dependency source and target file path.\n * @param filePath The path of the dependency target file, if known. Can be absolute if rootPath is configured, or relative if not.\n * @param dependencySource The source of the dependency.\n * @returns The description of the dependency element.\n */\n public describeElement(\n filePath: string | undefined,\n dependencySource: string\n ): ElementDescriptionWithSource;\n public describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescription | ElementDescriptionWithSource {\n return this._describeElement(filePath, dependencySource);\n }\n}\n","import type { DescriptorOptionsNormalized } from \"../Config\";\nimport type { Micromatch } from \"../Matcher\";\n\nimport { DependenciesDescriptor } from \"./DependenciesDescriptor\";\nimport type {\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\nimport type { DescriptorsSerializedCache } from \"./Descriptors.types\";\nimport { ElementsDescriptor } from \"./ElementsDescriptor\";\nimport type {\n ElementDescriptors,\n ElementDescription,\n} from \"./ElementsDescriptor.types\";\n\n/**\n * Class with methods to describe elements and dependencies between them.\n */\nexport class Descriptors {\n private readonly _elementsDescriptor: ElementsDescriptor;\n private readonly _dependenciesDescriptor: DependenciesDescriptor;\n\n /** Creates a new DescriptorsManager instance\n * @param elementDescriptors The element descriptors.\n * @param configOptions The configuration options.\n * @param micromatch The Micromatch instance.\n */\n constructor(\n elementDescriptors: ElementDescriptors,\n config: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._elementsDescriptor = new ElementsDescriptor(\n elementDescriptors,\n config,\n micromatch\n );\n this._dependenciesDescriptor = new DependenciesDescriptor(\n this._elementsDescriptor,\n config\n );\n }\n\n /**\n * Serializes the elements and dependencies cache to a plain object.\n * @returns The serialized elements and dependencies cache.\n */\n public serializeCache(): DescriptorsSerializedCache {\n return {\n elements: this._elementsDescriptor.serializeCache(),\n dependencies: this._dependenciesDescriptor.serializeCache(),\n };\n }\n\n /**\n * Sets the elements and dependencies cache from a serialized object.\n * @param serializedCache The serialized elements and dependencies cache.\n */\n public setCacheFromSerialized(\n serializedCache: DescriptorsSerializedCache\n ): void {\n this._elementsDescriptor.setCacheFromSerialized(serializedCache.elements);\n this._dependenciesDescriptor.setCacheFromSerialized(\n serializedCache.dependencies\n );\n }\n\n /**\n * Clears all caches.\n */\n public clearCache(): void {\n this._elementsDescriptor.clearCache();\n this._dependenciesDescriptor.clearCache();\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n public describeElement(filePath?: string): ElementDescription {\n return this._elementsDescriptor.describeElement(filePath);\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency(\n options: DescribeDependencyOptions\n ): DependencyDescription {\n return this._dependenciesDescriptor.describeDependency(options);\n }\n}\n","import type { DescriptorOptionsNormalized } from \"../Config\";\nimport type {\n ElementDescriptors,\n DescribeDependencyOptions,\n ElementDescription,\n DependencyDescription,\n} from \"../Descriptor\";\nimport {\n Descriptors,\n isElementDescription,\n isDependencyDescription,\n} from \"../Descriptor\";\n\nimport type { DependenciesMatcher } from \"./DependenciesMatcher\";\nimport type { ElementsMatcher } from \"./ElementsMatcher\";\nimport type {\n DependencySelector,\n MatcherOptions,\n ElementsSelector,\n DependencyMatchResult,\n MatcherSerializedCache,\n BaseElementSelectorData,\n} from \"./Matcher.types\";\nimport { isDependencySelector, isElementsSelector } from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to evaluate if elements or dependencies match given selectors.\n */\nexport class Matcher {\n private readonly _descriptors: Descriptors;\n private readonly _elementsMatcher: ElementsMatcher;\n private readonly _dependenciesMatcher: DependenciesMatcher;\n\n /**\n * Constructor for the Matcher class.\n * @param descriptors Element descriptors to use for matching.\n * @param elementsMatcher Elements matcher instance.\n * @param dependenciesMatcher Dependencies matcher instance.\n * @param config Configuration options.\n * @param globalCache Global cache instance.\n */\n constructor(\n descriptors: ElementDescriptors,\n elementsMatcher: ElementsMatcher,\n dependenciesMatcher: DependenciesMatcher,\n config: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._descriptors = new Descriptors(descriptors, config, micromatch);\n this._elementsMatcher = elementsMatcher;\n this._dependenciesMatcher = dependenciesMatcher;\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n public describeElement(filePath: string) {\n return this._descriptors.describeElement(filePath);\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency(options: DescribeDependencyOptions) {\n return this._descriptors.describeDependency(options);\n }\n\n /**\n * Determines if an element matches a given selector.\n * @param filePath The file path of the element\n * @param selector The selector to match against\n * @param options Extra matcher options\n * @returns True if the element matches the selector, false otherwise\n */\n public isElementMatch(\n filePath: string,\n selector: ElementsSelector,\n options?: MatcherOptions\n ): boolean {\n const description = this._descriptors.describeElement(filePath);\n return this._elementsMatcher.isElementMatch(description, selector, options);\n }\n\n /**\n * Determines if a dependency matches a given selector.\n * @param dependencyData The data describing the dependency\n * @param selector The selector to match against\n * @param options Extra matcher options\n * @returns True if the dependency matches the selector, false otherwise\n */\n public isDependencyMatch(\n dependencyData: DescribeDependencyOptions,\n selector: DependencySelector,\n options?: MatcherOptions\n ): boolean {\n const description = this._descriptors.describeDependency(dependencyData);\n return this._dependenciesMatcher.isDependencyMatch(\n description,\n selector,\n options\n );\n }\n\n /**\n * Determines the selector matching for an element.\n * @param filePath The file path of the element\n * @param selector The selectors to match against\n * @param options Extra options for matching\n * @returns The matching selector data or null if no match is found\n */\n public getElementSelectorMatching(\n filePath: string,\n selector: ElementsSelector,\n options?: MatcherOptions\n ) {\n const description = this._descriptors.describeElement(filePath);\n return this._elementsMatcher.getSelectorMatching(\n description,\n selector,\n options\n );\n }\n\n /**\n * Determines the selector matching for a dependency.\n * @param dependencyData The data describing the dependency\n * @param selector The selectors to match against\n * @param options Extra options for matching\n * @returns The matching dependency result or null if no match is found\n */\n public getDependencySelectorMatching(\n dependencyData: DescribeDependencyOptions,\n selector: DependencySelector,\n options?: MatcherOptions\n ) {\n const description = this._descriptors.describeDependency(dependencyData);\n return this._dependenciesMatcher.getSelectorsMatching(\n description,\n selector,\n options\n );\n }\n\n /**\n * Returns the selectors matching result for the given element or dependency description.\n * @param description The element or dependency description to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The selectors matching result for the given description, and whether it matches or not.\n */\n public getDependencySelectorMatchingDescription(\n description: DependencyDescription,\n selector: DependencySelector,\n options?: MatcherOptions\n ): DependencyMatchResult {\n if (\n isDependencySelector(selector) &&\n isDependencyDescription(description)\n ) {\n return this._dependenciesMatcher.getSelectorsMatching(\n description,\n selector,\n options\n );\n }\n throw new Error(\n \"Invalid arguments: Please provide a valid description and selector\"\n );\n }\n\n /**\n * Returns the first element selector matching result for the given element description.\n * @param description The element description to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The first matching selector result for the given description, or null if no match is found.\n */\n public getElementSelectorMatchingDescription(\n description: ElementDescription,\n selector: ElementsSelector,\n options?: MatcherOptions\n ): BaseElementSelectorData | null {\n if (isElementsSelector(selector) && isElementDescription(description)) {\n return this._elementsMatcher.getSelectorMatching(\n description,\n selector,\n options\n );\n }\n throw new Error(\n \"Invalid arguments: Please provide a valid description and selector\"\n );\n }\n\n /**\n * Clears all caches.\n */\n public clearCache() {\n this._descriptors.clearCache();\n }\n\n /**\n * Serializes the descriptors matchers cache to a plain object.\n * @returns The serialized cache\n */\n public serializeCache(): MatcherSerializedCache {\n return {\n descriptors: this._descriptors.serializeCache(),\n };\n }\n\n /**\n * Sets the descriptors matchers cache from a serialized object.\n * @param serializedCache The serialized cache\n */\n public setCacheFromSerialized(serializedCache: {\n descriptors: ReturnType<Descriptors[\"serializeCache\"]>;\n }) {\n this._descriptors.setCacheFromSerialized(serializedCache.descriptors);\n }\n}\n","import micromatch from \"micromatch\";\n\nimport { CacheManager, CacheManagerDisabled } from \"../Cache\";\nimport { isArray } from \"../Support\";\n\nimport type { MicromatchSerializedCache } from \"./Matcher.types\";\n\n/**\n * Cache key type for micromatch matching results\n */\ntype MatchingResultsCacheKey = {\n value: string;\n pattern: string | string[];\n};\n\n/**\n * Cache for micromatch matching results\n */\nclass MatchingResultsCache extends CacheManager<\n MatchingResultsCacheKey,\n boolean\n> {\n /**\n * Generates a unique cache key based on the value and pattern\n * @param param0 The cache key components\n * @returns The generated cache key\n */\n protected generateKey({ value, pattern }: MatchingResultsCacheKey): string {\n return `${value}::${isArray(pattern) ? pattern.join(\"|\") : pattern}`;\n }\n}\n\n/**\n * Cache key type for micromatch captured values\n */\ntype CapturedValueCacheKey = {\n pattern: string;\n target: string;\n};\n\n/**\n * Cache for micromatch captured values\n */\nclass CapturedValueCache extends CacheManager<\n CapturedValueCacheKey,\n string[] | null\n> {\n /**\n * Generates a unique cache key based on the pattern and target\n * @param param0 The cache key components\n * @returns The generated cache key\n */\n protected generateKey({ pattern, target }: CapturedValueCacheKey): string {\n return `${pattern}|${target}`;\n }\n}\n\n/**\n * Micromatch wrapper class with caching capabilities.\n */\n\nexport class Micromatch {\n /**\n * Cache for micromatch matching results\n */\n private readonly _matchingResultsCache:\n | MatchingResultsCache\n | CacheManagerDisabled<MatchingResultsCacheKey, boolean>;\n\n /**\n * Cache for micromatch captures\n */\n private readonly _capturesCache:\n | CapturedValueCache\n | CacheManagerDisabled<CapturedValueCacheKey, string[] | null> =\n new CacheManagerDisabled<CapturedValueCacheKey, string[] | null>();\n\n /**\n * Cache for micromatch makeRe results\n */\n private readonly _makeReCache: CacheManagerDisabled<string, RegExp> =\n new CacheManagerDisabled<string, RegExp>();\n\n /**\n * Creates an instance of Micromatch class.\n * @param cache Whether to use caching or not.\n */\n constructor(cache: boolean) {\n this._matchingResultsCache = cache\n ? new MatchingResultsCache()\n : new CacheManagerDisabled<MatchingResultsCacheKey, boolean>();\n this._capturesCache = cache\n ? new CapturedValueCache()\n : new CacheManagerDisabled<CapturedValueCacheKey, string[] | null>();\n this._makeReCache = cache\n ? new CacheManager<string, RegExp>()\n : new CacheManagerDisabled<string, RegExp>();\n }\n\n /**\n * Clears all caches.\n */\n public clearCache(): void {\n this._matchingResultsCache.clear();\n this._capturesCache.clear();\n this._makeReCache.clear();\n }\n\n /**\n * Serializes the current cache state.\n * @returns The serialized cache data.\n */\n public serializeCache(): MicromatchSerializedCache {\n return {\n matchingResults: this._matchingResultsCache.serialize(),\n captures: this._capturesCache.serialize(),\n };\n }\n\n /**\n * Restores the cache state from serialized data.\n * @param serializedCache The serialized cache data.\n */\n public setFromSerialized(serializedCache: MicromatchSerializedCache): void {\n this._matchingResultsCache.setFromSerialized(\n serializedCache.matchingResults\n );\n this._capturesCache.setFromSerialized(serializedCache.captures);\n }\n\n /**\n * Optimized micromatch match with caching.\n * @param value The value to match.\n * @param pattern The pattern to match against.\n * @returns True if the value matches the pattern, false otherwise.\n */\n public isMatch(value: string, pattern: string | string[]): boolean {\n const cacheKey = this._matchingResultsCache.getKey({\n value,\n pattern,\n });\n\n if (this._matchingResultsCache.has(cacheKey)) {\n return this._matchingResultsCache.get(cacheKey)!;\n }\n\n const isMatch = micromatch.isMatch(value, pattern);\n this._matchingResultsCache.set(cacheKey, isMatch);\n return isMatch;\n }\n\n /**\n * Optimized micromatch capture with caching.\n * @param pattern The pattern to match against.\n * @param target The target string to test.\n * @returns Captured groups or null if no match.\n */\n public capture(pattern: string, target: string): string[] | null {\n const cacheKey = this._capturesCache.getKey({ pattern, target });\n\n if (this._capturesCache.has(cacheKey)) {\n return this._capturesCache.get(cacheKey)!;\n }\n\n const result = micromatch.capture(pattern, target);\n this._capturesCache.set(cacheKey, result);\n return result;\n }\n\n /**\n * Optimized micromatch makeRe with caching.\n * @param pattern The pattern to convert to RegExp.\n * @returns The RegExp instance.\n */\n public makeRe(pattern: string): RegExp {\n if (this._makeReCache.has(pattern)) {\n return this._makeReCache.get(pattern)!;\n }\n const regexp = micromatch.makeRe(pattern);\n this._makeReCache.set(pattern, regexp);\n return regexp;\n }\n}\n","import { CacheManager } from \"./Cache\";\nimport type { ConfigOptionsNormalized } from \"./Config\";\nimport type { ElementDescriptors } from \"./Descriptor\";\nimport type { Matcher } from \"./Matcher\";\n\n/**\n * Cache manager for Matcher instances, unique for each different configuration\n */\nexport class MatchersCache extends CacheManager<\n {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n },\n {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n matcher: Matcher;\n }\n> {\n /**\n * Generates a unique key based on the configuration options and element descriptors\n * @param params The configuration and element descriptors\n * @returns A unique string key\n */\n protected generateKey({\n config,\n elementDescriptors,\n }: {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n }): string {\n const configHash = `${config.legacyTemplates}|${config.includePaths}|${config.ignorePaths}|${\n config.cache\n }|${config.rootPath}|${config.flagAsExternal.inNodeModules}|${config.flagAsExternal.unresolvableAlias}|${\n config.flagAsExternal.outsideRootPath\n }|${config.flagAsExternal.customSourcePatterns.join(\",\")}`;\n\n const elementDescriptorsHash = elementDescriptors\n .map(\n (descriptor) =>\n `${descriptor.type}|${descriptor.category}|${descriptor.pattern}|${descriptor.basePattern}|${descriptor.mode}|${descriptor.capture}|${descriptor.baseCapture}`\n )\n .join(\",\");\n return `${configHash}|:|${elementDescriptorsHash}`;\n }\n}\n","import type { ConfigOptions, ConfigOptionsNormalized } from \"./Config\";\nimport { Config } from \"./Config\";\nimport type { ElementDescriptors } from \"./Descriptor\";\nimport type { ElementsSerializedCache } from \"./Elements.types\";\nimport {\n Micromatch,\n DependenciesMatcher,\n ElementsMatcher,\n Matcher,\n} from \"./Matcher\";\nimport { MatchersCache } from \"./MatchersCache\";\n\n/**\n * Main class to interact with Elements functionality.\n * It include one method to get descriptors with different caching for different configurations, methods to manage the cache, and methods to match element selectors against element descriptions.\n */\nexport class Elements {\n /** The global configuration options for Elements. Can be overridden when getting a descriptor */\n private readonly _globalConfigOptions: ConfigOptionsNormalized;\n\n /** Cache manager for Matcher instances, unique for each different configuration */\n private readonly _matchersCache = new MatchersCache();\n\n /** Micromatch instances for pattern matching */\n private readonly _micromatchWithCache = new Micromatch(true);\n private readonly _micromatchWithoutCache = new Micromatch(false);\n\n /**\n * Creates a new Elements instance\n * @param configOptions The global configuration options for Elements. Can be overridden when getting a descriptor.\n */\n constructor(configOptions?: ConfigOptions) {\n const globalConfig = new Config(configOptions);\n this._globalConfigOptions = globalConfig.options;\n }\n\n /**\n * Returns a serialized representation of the current state of the cache.\n * @returns A serialized representation of the cache.\n */\n public serializeCache(): ElementsSerializedCache {\n const matchersCache = Array.from(\n this._matchersCache.getAll().entries()\n ).reduce(\n (acc, [key, cache]) => {\n acc[key] = {\n config: cache.config,\n elementDescriptors: cache.elementDescriptors,\n cache: cache.matcher.serializeCache(),\n };\n return acc;\n },\n {} as ElementsSerializedCache[\"matchers\"]\n );\n\n const micromatchCache = this._micromatchWithCache.serializeCache();\n\n return {\n matchers: matchersCache,\n micromatch: micromatchCache,\n };\n }\n\n /**\n * Sets the Elements cache from a serialized representation.\n * @param serializedCache The serialized cache to set.\n */\n public setCacheFromSerialized(\n serializedCache: ElementsSerializedCache\n ): void {\n this._micromatchWithCache.setFromSerialized(serializedCache.micromatch);\n for (const key in serializedCache.matchers) {\n const matcher = this.getMatcher(\n serializedCache.matchers[key].elementDescriptors,\n serializedCache.matchers[key].config\n );\n matcher.setCacheFromSerialized(serializedCache.matchers[key].cache);\n this._matchersCache.set(key, {\n config: serializedCache.matchers[key].config,\n elementDescriptors: serializedCache.matchers[key].elementDescriptors,\n matcher: matcher,\n });\n }\n }\n\n /**\n * Clears cache\n */\n public clearCache(): void {\n for (const { matcher } of this._matchersCache.getAll().values()) {\n matcher.clearCache();\n }\n this._matchersCache.clear();\n this._micromatchWithCache.clearCache();\n }\n\n /**\n * Gets a Matcher instance for the given configuration options.\n * It uses caching to return the same instance for the same configuration options. If no options are provided, the global configuration options are used.\n * @param elementDescriptors The element descriptors to use.\n * @param config Optional configuration options to override the global ones.\n * @returns A matcher instance, unique for each different configuration.\n */\n public getMatcher(\n elementDescriptors: ElementDescriptors,\n config?: ConfigOptions\n ): Matcher {\n const optionsToUse = config || this._globalConfigOptions;\n const configInstance = new Config(optionsToUse);\n const cacheIsEnabled = configInstance.cache;\n const configOptionsNormalized = configInstance.options;\n const descriptorNormalizedOptions = configInstance.descriptorOptions;\n const matchersNormalizedOptions = configInstance.matchersOptions;\n\n const cacheKey = this._matchersCache.getKey({\n config: configOptionsNormalized,\n elementDescriptors,\n });\n\n if (this._matchersCache.has(cacheKey)) {\n return this._matchersCache.get(cacheKey)!.matcher;\n }\n\n const micromatch = cacheIsEnabled\n ? this._micromatchWithCache\n : this._micromatchWithoutCache;\n\n const elementsMatcher = new ElementsMatcher(\n matchersNormalizedOptions,\n micromatch\n );\n const dependenciesMatcher = new DependenciesMatcher(\n elementsMatcher,\n matchersNormalizedOptions,\n micromatch\n );\n\n const matcher = new Matcher(\n elementDescriptors,\n elementsMatcher,\n dependenciesMatcher,\n descriptorNormalizedOptions,\n micromatch\n );\n\n this._matchersCache.set(cacheKey, {\n config: configOptionsNormalized,\n elementDescriptors,\n matcher,\n });\n return matcher;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAA;AAAA,EAKO,aAAmB;AACxB,eAAW,EAAE,QAAQ,KAAK,KAAK,eAAe,OAAO,EAAE,OAAO,GAAG;AAC/D,cAAQ,WAAW;AAAA,IACrB;AACA,SAAK,eAAe,MAAM;AAC1B,SAAK,qBAAqB,WAAW;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,WACL,oBACA,QACS;AACT,UAAM,eAAe,UAAU,KAAK;AACpC,UAAM,iBAAiB,IAAI,OAAO,YAAY;AAC9C,UAAM,iBAAiB,eAAe;AACtC,UAAM,0BAA0B,eAAe;AAC/C,UAAM,8BAA8B,eAAe;AACnD,UAAM,4BAA4B,eAAe;AAEjD,UAAM,WAAW,KAAK,eAAe,OAAO;AAAA,MAC1C,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,QAAI,KAAK,eAAe,IAAI,QAAQ,GAAG;AACrC,aAAO,KAAK,eAAe,IAAI,QAAQ,EAAG;AAAA,IAC5C;AAEA,UAAMC,cAAa,iBACf,KAAK,uBACL,KAAK;AAET,UAAM,kBAAkB,IAAI;AAAA,MAC1B;AAAA,MACAA;AAAA,IACF;AACA,UAAM,sBAAsB,IAAI;AAAA,MAC9B;AAAA,MACA;AAAA,MACAA;AAAA,IACF;AAEA,UAAM,UAAU,IAAI;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACAA;AAAA,IACF;AAEA,SAAK,eAAe,IAAI,UAAU;AAAA,MAChC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AACF;","names":["micromatch","Handlebars","micromatch","micromatch","micromatch","isCoreModule","micromatch","micromatch","micromatch","micromatch"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Support/TypeGuards.ts","../src/Support/Paths.ts","../src/Config/Config.ts","../src/Matcher/BaseElementsMatcher.ts","../src/Matcher/MatcherHelpers.ts","../src/Matcher/DependenciesMatcher.ts","../src/Matcher/ElementsMatcher.ts","../src/Descriptor/ElementsDescriptor.types.ts","../src/Descriptor/ElementsDescriptorHelpers.ts","../src/Descriptor/DependenciesDescriptor.types.ts","../src/Descriptor/DependenciesDescriptorHelpers.ts","../src/Cache/Cache.ts","../src/Cache/CacheDisabled.ts","../src/Descriptor/DependenciesDescriptionsCache.ts","../src/Descriptor/DependenciesDescriptor.ts","../src/Descriptor/ElementsDescriptor.ts","../src/Descriptor/Descriptors.ts","../src/Matcher/Matcher.ts","../src/Matcher/Micromatch.ts","../src/MatchersCache.ts","../src/Elements.ts"],"sourcesContent":["export * from \"./Elements\";\nexport * from \"./Elements.types\";\n\nexport * from \"./Matcher/Public\";\nexport * from \"./Descriptor/Public\";\nexport * from \"./Config/Public\";\n\nexport * from \"./Cache/Public\";\n","/**\n * Determines if the given value is a string.\n * @param value The value to check.\n * @returns True if the value is a string, false otherwise.\n */\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\n/**\n * Determines if the given value is undefined.\n * @param value The value to check.\n * @returns True if the value is undefined, false otherwise.\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined;\n}\n\n/**\n * Determines if the given value is null\n * @param value The value to check\n * @returns True if the value is null, false otherwise\n */\nexport function isNull(value: unknown): value is null {\n return value === null;\n}\n\n/**\n * Determines if the given value is not null or undefined.\n * @param value The value to check.\n * @returns True if the value is not null or undefined, false otherwise.\n */\nexport function isNullish(value: unknown): value is null | undefined {\n return isUndefined(value) || isNull(value);\n}\n\n/**\n * Determines if the given value is a boolean\n * @param value The value to check\n * @returns True if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\n/**\n * Determines if the given value is a non-null object.\n * @param value The value to check.\n * @returns True if the value is a non-null object, false otherwise.\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return (\n !isNullish(value) &&\n !isBoolean(value) &&\n !isArray(value) &&\n typeof value === \"object\"\n );\n}\n\n/**\n * Determines if the given object is an empty object.\n * @param obj The object to check.\n * @returns True if the object is empty, false otherwise.\n */\nexport function isEmptyObject(obj: unknown): boolean {\n return isObject(obj) && Object.keys(obj).length === 0;\n}\n\n/**\n * Determines if the given value is an array.\n * @param value The value to check.\n * @returns True if the value is an array, false otherwise.\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/**\n * Determines if the given array is empty\n * @param arr The array to check\n * @returns Whether the array is empty or not\n */\nexport function isEmptyArray(arr: unknown[]): arr is [] {\n return arr.length === 0;\n}\n\n/**\n * Determines if the given value is a string array.\n * @param value The value to check.\n * @returns True if the value is a string array, false otherwise.\n */\nexport function isStringArray(value: unknown): value is string[] {\n return isArray(value) && value.every(isString);\n}\n\n/**\n * Determines if the given value is an object with the specified property.\n * @param value The value to check.\n * @param key The property key to check for.\n * @returns True if the value is an object with the specified property, false otherwise.\n */\nexport function isObjectWithProperty<Key extends string>(\n value: unknown,\n key: Key\n): value is Record<Key, unknown> & Record<string, unknown> {\n return isObject(value) && Object.hasOwn(value, key);\n}\n\n/**\n * Determines if the given value is an object with any of the specified properties.\n * @param value The value to check\n * @param keys The keys to check for\n * @returns True if the value is an object with any of the specified properties, false otherwise\n */\nexport function isObjectWithAnyOfProperties<Keys extends string>(\n value: unknown,\n keys: Keys[]\n): value is Record<Keys, unknown> & Record<string, unknown> {\n return isObject(value) && keys.some((key) => key in value);\n}\n","/**\n * Normalizes a file path by replacing backslashes with forward slashes.\n * @param filePath The file path to normalize.\n * @returns The normalized file path.\n */\nexport function normalizePath(filePath: string): string {\n return filePath.replaceAll(\"\\\\\", \"/\");\n}\n","import { normalizePath } from \"../Support\";\n\nimport type {\n ConfigOptions,\n MicromatchPattern,\n ConfigOptionsNormalized,\n DescriptorOptionsNormalized,\n MatchersOptionsNormalized,\n FlagAsExternalOptionsNormalized,\n} from \"./Config.types\";\n\nexport class Config {\n /** The ignore paths */\n private readonly _ignorePaths?: MicromatchPattern;\n /** The include paths */\n private readonly _includePaths?: MicromatchPattern;\n /** Whether legacy template support is enabled */\n private readonly _legacyTemplates: boolean;\n /** Whether the cache is enabled */\n private readonly _cache: boolean;\n /** Configuration for categorizing dependencies as external or local */\n private readonly _flagAsExternal: FlagAsExternalOptionsNormalized;\n /** Root path of the project */\n private readonly _rootPath?: string;\n /**\n * Creates a new Config instance\n * @param options Configuration options\n */\n constructor(options?: ConfigOptions) {\n this._ignorePaths = options?.ignorePaths;\n this._includePaths = options?.includePaths;\n this._legacyTemplates = options?.legacyTemplates ?? true;\n this._cache = options?.cache ?? true;\n this._flagAsExternal = {\n unresolvableAlias: options?.flagAsExternal?.unresolvableAlias ?? true,\n inNodeModules: options?.flagAsExternal?.inNodeModules ?? true,\n outsideRootPath: options?.flagAsExternal?.outsideRootPath ?? false,\n customSourcePatterns: options?.flagAsExternal?.customSourcePatterns ?? [],\n };\n if (options?.rootPath) {\n const normalizedRoot = normalizePath(options.rootPath);\n this._rootPath = normalizedRoot.endsWith(\"/\")\n ? normalizedRoot\n : `${normalizedRoot}/`;\n } else {\n this._rootPath = undefined;\n }\n }\n\n /**\n * The normalized configuration options\n */\n public get options(): ConfigOptionsNormalized {\n return {\n ignorePaths: this._ignorePaths,\n includePaths: this._includePaths,\n legacyTemplates: this._legacyTemplates,\n cache: this._cache,\n flagAsExternal: this._flagAsExternal,\n rootPath: this._rootPath,\n };\n }\n\n /**\n * Normalized options for descriptors\n */\n public get descriptorOptions(): DescriptorOptionsNormalized {\n return {\n ignorePaths: this._ignorePaths,\n includePaths: this._includePaths,\n cache: this._cache,\n flagAsExternal: this._flagAsExternal,\n rootPath: this._rootPath,\n };\n }\n\n /**\n * Normalized options for element matchers\n */\n public get matchersOptions(): MatchersOptionsNormalized {\n return {\n legacyTemplates: this._legacyTemplates,\n };\n }\n\n /**\n * Whether caching is enabled\n */\n public get cache(): boolean {\n return this._cache;\n }\n}\n","import Handlebars from \"handlebars\";\n\nimport type {\n MicromatchPatternNullable,\n MatchersOptionsNormalized,\n MicromatchMatchableValue,\n} from \"../Config\";\nimport type { BaseElementDescription } from \"../Descriptor\";\nimport {\n isArray,\n isObjectWithProperty,\n isString,\n isBoolean,\n isNull,\n isUndefined,\n} from \"../Support\";\n\nimport type {\n BaseElementSelectorData,\n TemplateData,\n SelectableElement,\n} from \"./Matcher.types\";\nimport type { Micromatch } from \"./Micromatch\";\n\nconst LEGACY_TEMPLATE_REGEX = /\\$\\{([^}]+)\\}/g;\nconst HANDLEBARS_TEMPLATE_REGEX = /{{\\s*[^{}\\s][^{}]*}}/;\n\n/**\n * Base matcher class to determine if elements or dependencies match a given selector.\n */\nexport class BaseElementsMatcher {\n /**\n * Option to use legacy templates with ${} syntax.\n */\n protected readonly _legacyTemplates: boolean;\n\n /**\n * Micromatch instance for matching.\n */\n protected micromatch: Micromatch;\n\n /**\n * Creates a new BaseElementsMatcher.\n * @param config Configuration options for the matcher.\n * @param globalCache Global cache instance.\n */\n constructor(config: MatchersOptionsNormalized, micromatch: Micromatch) {\n this.micromatch = micromatch;\n this._legacyTemplates = config.legacyTemplates;\n }\n\n /**\n * Converts a template with ${} to Handlebars {{}} templates for backwards compatibility.\n * @param template The template to convert.\n * @returns The converted template.\n */\n private _getBackwardsCompatibleTemplate(\n template: string | null\n ): string | null {\n if (!template) {\n return template;\n }\n return template.replaceAll(LEGACY_TEMPLATE_REGEX, \"{{ $1 }}\");\n }\n\n /**\n * Determines if a template contains Handlebars syntax.\n * @param template The template to check.\n * @returns True if the template contains Handlebars syntax, false otherwise.\n */\n private _isHandlebarsTemplate(template: string | null): boolean {\n if (!template) {\n return false;\n }\n return HANDLEBARS_TEMPLATE_REGEX.test(template);\n }\n\n /**\n * Returns a rendered template using the provided template data.\n * Optimized version with template caching for better performance.\n * @param template The template to render.\n * @param templateData The data to use for replace in the template.\n * @returns The rendered template.\n */\n private _getRenderedTemplate(\n template: string | null,\n templateData: TemplateData\n ): string | null {\n const templateToUse = this._legacyTemplates\n ? this._getBackwardsCompatibleTemplate(template)\n : template;\n if (!this._isHandlebarsTemplate(templateToUse)) {\n // If the template does not contain any Handlebars syntax, return it as is.\n return template;\n }\n\n const compiledTemplate = Handlebars.compile(templateToUse);\n\n return compiledTemplate(templateData);\n }\n\n /**\n * Returns rendered templates using the provided template data.\n * @param template The templates to render.\n * @param extraTemplateData The data to use for replace in the templates.\n * @returns The rendered templates.\n */\n protected getRenderedTemplates(\n template: MicromatchPatternNullable,\n templateData: TemplateData\n ): MicromatchPatternNullable {\n if (isArray(template)) {\n return template.map((temp) => {\n return this._getRenderedTemplate(temp, templateData);\n });\n }\n return this._getRenderedTemplate(template, templateData);\n }\n\n /**\n * Cleans a micromatch pattern by removing falsy values from arrays.\n * @param pattern The micromatch pattern(s) to clean.\n * @returns The cleaned pattern. If an array is provided, falsy entries are removed and the resulting array may be empty. If null is provided, null is returned unchanged.\n */\n protected cleanMicromatchPattern(\n pattern: MicromatchPatternNullable\n ): string | string[] | null {\n return isArray(pattern) ? (pattern.filter(Boolean) as string[]) : pattern;\n }\n\n /**\n * Returns whether the given value matches the micromatch pattern, converting non-string values to strings.\n * Optimized version with caching for better performance.\n * @param value The value to check.\n * @param pattern The micromatch pattern to match against.\n * @returns Whether the value matches the pattern.\n */\n protected isMicromatchMatch(\n value: string | null | undefined | boolean,\n pattern: MicromatchPatternNullable\n ): boolean {\n if (isNull(pattern)) {\n return isNull(value);\n }\n if (isNull(value)) {\n return isArray(pattern) && pattern.some(isNull);\n }\n\n // Clean empty strings from arrays to avoid matching them.\n const patternToCheck = this.cleanMicromatchPattern(pattern);\n\n if (!patternToCheck?.length) {\n return false;\n }\n\n // Convert non-string element values to string for matching.\n const elementValueToCheck =\n !value || !isString(value) ? String(value) : value;\n\n return this.micromatch.isMatch(elementValueToCheck, patternToCheck);\n }\n\n /**\n * Returns whether the given value matches the micromatch pattern after rendering it as a template.\n * @param pattern The micromatch pattern to render and match against.\n * @param templateData The data to use for rendering the pattern as a template.\n * @param value The value to check.\n * @returns Whether the value matches the rendered pattern.\n */\n protected isTemplateMicromatchMatch(\n pattern: MicromatchPatternNullable,\n templateData: TemplateData,\n value: MicromatchMatchableValue\n ): boolean {\n // If the element value is undefined, it cannot match anything.\n if (isUndefined(value)) {\n return false;\n }\n\n const patternRendered = this.getRenderedTemplates(pattern, templateData);\n\n // Empty rendered selector values do not match anything. (It may happen due to templates rendering to empty strings.)\n if (!isNull(patternRendered) && !patternRendered) {\n return false;\n }\n\n if (isArray(value)) {\n // If the value is an array, we check if any of its items matches the pattern.\n return value.some((val) => this.isMicromatchMatch(val, patternRendered));\n }\n\n return this.isMicromatchMatch(value, patternRendered);\n }\n\n /**\n * Whether the given element key matches the selector key as booleans.\n * @param param0 The parameters object.\n * @returns Whether the element key matches the selector key.\n */\n protected isElementKeyBooleanMatch<\n T extends BaseElementDescription,\n S extends BaseElementSelectorData,\n >({\n /** The element to check. */\n element,\n /** The selector to check against. */\n selector,\n /** The key of the element to check. */\n elementKey,\n /** The key of the selector to check against. */\n selectorKey,\n }: {\n /** The element to check. */\n element: T;\n /** The selector to check against. */\n selector: S;\n /** The key of the element to check. */\n elementKey: keyof T;\n /** The key of the selector to check against. */\n selectorKey: keyof S;\n }): boolean {\n // The selector key does not exist in the selector, so it matches any value.\n if (!(selectorKey in selector)) {\n return true;\n }\n // The selector key exists in the selector, but it does not exist in the element. No match.\n // istanbul ignore next - This case should not happen due to element validations, but we guard against it anyway.\n if (!(elementKey in element)) {\n return false;\n }\n // Both values must be booleans to match.\n if (!isBoolean(selector[selectorKey]) || !isBoolean(element[elementKey])) {\n return false;\n }\n return (\n (selector[selectorKey] as boolean) === (element[elementKey] as boolean)\n );\n }\n\n /**\n * Whether the given element key matches the selector key using micromatch.\n * @param param0 The parameters object.\n * @returns Whether the element key matches the selector key.\n */\n protected isElementKeyMicromatchMatch<\n T extends SelectableElement,\n S extends BaseElementSelectorData,\n K extends keyof T,\n >({\n element,\n selector,\n elementKey,\n selectorKey,\n selectorValue,\n templateData,\n }: {\n /** The element to check. */\n element: T & Record<K, MicromatchMatchableValue>;\n /** The selector to check against. */\n selector: S;\n /** The key of the element to check. */\n elementKey: K;\n /** The key of the selector to check against. */\n selectorKey: keyof BaseElementSelectorData;\n /** The value of the selector key to check against. */\n selectorValue?: MicromatchPatternNullable;\n /** Data to pass when the selector value is rendered as a template */\n templateData: TemplateData;\n }): boolean {\n // The selector key does not exist in the selector, so it matches any value. We also check the value passed separately in order to improve typing inference.\n if (!(selectorKey in selector)) {\n return true;\n }\n // Undefined selector values do not match anything.\n // The selector key exists in the selector, but it does not exist in the element. No match.\n /* istanbul ignore next - This cases should not happen due to selector validations, but we guard against it anyway. */\n if (\n isUndefined(selectorValue) ||\n !isObjectWithProperty(element, String(elementKey))\n ) {\n return false;\n }\n\n const elementValue = element[elementKey];\n\n return this.isTemplateMicromatchMatch(\n selectorValue,\n templateData,\n elementValue\n );\n }\n}\n","import {\n isObject,\n isString,\n isArray,\n isStringArray,\n isObjectWithProperty,\n isEmptyArray,\n isObjectWithAnyOfProperties,\n} from \"../Support/TypeGuards\";\n\nimport type {\n ElementSelector,\n ElementSelectorWithOptions,\n ElementSelectors,\n CapturedValuesSelector,\n SimpleElementSelectorByType,\n DependencySelector,\n DependencyDataSelector,\n DependencyDataSelectorData,\n BaseElementSelector,\n BaseElementSelectorData,\n BaseElementsSelector,\n ElementsSelector,\n} from \"./Matcher.types\";\n\n/**\n * Determines if the given value is a captured values object selector (single object with pattern properties).\n * @param value The value to check.\n * @returns True if the value is a captured values object selector, false otherwise.\n */\nfunction isCapturedValuesObjectSelector(\n value: unknown\n): value is Record<string, string | string[]> {\n if (!isObject(value) || isArray(value)) {\n return false;\n }\n // Ensure all values are strings or string arrays\n return Object.values(value).every(\n (pattern) => isString(pattern) || isStringArray(pattern)\n );\n}\n\n/**\n * Determines if the given value is a captured values selector.\n * @param value The value to check.\n * @returns True if the value is a captured values selector, false otherwise.\n */\nexport function isCapturedValuesSelector(\n value: unknown\n): value is CapturedValuesSelector {\n // Handle array of captured values selectors\n if (isArray(value)) {\n return value.every((item) => isCapturedValuesObjectSelector(item));\n }\n\n // Handle single captured values selector\n return isCapturedValuesObjectSelector(value);\n}\n\n/**\n * Determines if the given value is a simple element selector.\n * @param value The value to check.\n * @returns True if the value is a simple element selector, false otherwise.\n */\nexport function isSimpleElementSelectorByType(\n value: unknown\n): value is SimpleElementSelectorByType {\n return isString(value);\n}\n\n/**\n * Determines if the given selector is a base element selector.\n * @param value The value to check.\n * @returns True if the selector is a base element selector\n */\nexport function isBaseElementSelectorData(\n value: unknown\n): value is BaseElementSelectorData {\n return isObjectWithAnyOfProperties(value, [\n \"path\",\n \"elementPath\",\n \"internalPath\",\n \"type\",\n \"category\",\n \"captured\",\n \"parent\",\n \"origin\",\n \"source\",\n \"module\",\n \"isIgnored\",\n \"isUnknown\",\n ]);\n}\n\n/**\n * Determines if the given selector is an element or dependency element selector data.\n * @param value The value to check.\n * @returns True if the selector is an element or dependency element selector data, false otherwise.\n */\nexport function isElementSelectorData(\n value: unknown\n): value is BaseElementSelectorData {\n return isBaseElementSelectorData(value);\n}\n\n/**\n * Determines if the given selector is an element selector with options.\n * @param value The value to check.\n * @returns True if the selector is an element selector with options, false otherwise.\n */\nexport function isElementSelectorWithLegacyOptions(\n value: unknown\n): value is ElementSelectorWithOptions {\n return (\n isArray(value) &&\n ((value.length === 2 &&\n isSimpleElementSelectorByType(value[0]) &&\n // NOTE: Arrays of length 2 with captured values selector as second element having a key \"type\" or \"category\" will be treated as legacy options instead of two different selectors. We have to live with this limitation for now.\n isCapturedValuesSelector(value[1])) ||\n // NOTE: Backwards compatibility: Allow arrays of length 1 with simple element selector. Some users might defined arrays without options.\n (value.length === 1 && isSimpleElementSelectorByType(value[0])))\n );\n}\n\n/**\n * Determines if the given value is an element selector.\n * @param value The value to check.\n * @returns True if the value is an element selector, false otherwise.\n */\nexport function isElementSelector(value: unknown): value is ElementSelector {\n return (\n isSimpleElementSelectorByType(value) ||\n isElementSelectorData(value) ||\n isElementSelectorWithLegacyOptions(value)\n );\n}\n\n/**\n * Determines if the given value is an elements selector.\n * @param value The value to check.\n * @returns True if the value is an elements selector, false otherwise.\n */\nexport function isElementsSelector(value: unknown): value is ElementSelectors {\n return (\n isElementSelector(value) ||\n (isArray(value) && !isEmptyArray(value) && value.every(isElementSelector))\n );\n}\n\n/**\n * Normalizes a selector into ElementSelectorData format.\n * @param selector The selector to normalize.\n * @returns The normalized selector data.\n */\nexport function normalizeElementSelector(\n selector: BaseElementSelector\n): BaseElementSelectorData;\nexport function normalizeElementSelector(\n selector: ElementSelector\n): BaseElementSelectorData {\n if (isSimpleElementSelectorByType(selector)) {\n return { type: selector };\n }\n\n if (isElementSelectorData(selector)) {\n return { ...selector };\n }\n\n if (isElementSelectorWithLegacyOptions(selector)) {\n return {\n type: selector[0],\n captured: selector[1] ? { ...selector[1] } : undefined,\n };\n }\n throw new Error(\"Invalid element selector\");\n}\n\n/**\n * Normalizes an ElementsSelector into an array of ElementSelectorData.\n * @param elementsSelector The elements selector, in any supported format.\n * @returns The normalized array of selector data.\n */\nexport function normalizeElementsSelector(\n elementsSelector: BaseElementsSelector\n): BaseElementSelectorData[];\nexport function normalizeElementsSelector(\n elementsSelector: ElementsSelector\n): BaseElementSelectorData[] {\n if (isArray(elementsSelector)) {\n if (isElementSelectorWithLegacyOptions(elementsSelector)) {\n return [normalizeElementSelector(elementsSelector)];\n }\n return elementsSelector.map((sel) => normalizeElementSelector(sel));\n }\n return [normalizeElementSelector(elementsSelector)];\n}\n\n/**\n * Determines if the given value is a dependency selector.\n * @param value The value to check\n * @returns True if the value is a dependency selector, false otherwise.\n */\nexport function isDependencySelector(\n value: unknown\n): value is DependencySelector {\n if (!isObjectWithAnyOfProperties(value, [\"from\", \"to\", \"dependency\"])) {\n return false;\n }\n\n const fromIsValid =\n !isObjectWithProperty(value, \"from\") || isElementsSelector(value.from);\n const toIsValid =\n !isObjectWithProperty(value, \"to\") || isElementsSelector(value.to);\n const dependencyIsValid =\n !isObjectWithProperty(value, \"dependency\") ||\n isDependencyDataSelector(value.dependency);\n\n return fromIsValid && toIsValid && dependencyIsValid;\n}\n\n/**\n * Determines if the given value is dependency metadata selector data.\n * @param value The value to check.\n * @returns True if the value is dependency metadata selector data, false otherwise.\n */\nexport function isDependencyDataSelectorData(\n value: unknown\n): value is DependencyDataSelectorData {\n return isObjectWithAnyOfProperties(value, [\n \"kind\",\n \"relationship\",\n \"specifiers\",\n \"nodeKind\",\n \"source\",\n \"module\",\n ]);\n}\n\n/**\n * Determines if the given value is dependency metadata selector(s).\n * @param value The value to check.\n * @returns True if the value is dependency metadata selector(s), false otherwise.\n */\nexport function isDependencyDataSelector(\n value: unknown\n): value is DependencyDataSelector {\n return (\n isDependencyDataSelectorData(value) ||\n (isArray(value) &&\n !isEmptyArray(value) &&\n value.every(isDependencyDataSelectorData))\n );\n}\n","import type { MatchersOptionsNormalized } from \"../Config\";\nimport type {\n DependencyDescription,\n DependencyRelationship,\n} from \"../Descriptor\";\nimport { isArray } from \"../Support\";\n\nimport { BaseElementsMatcher } from \"./BaseElementsMatcher\";\nimport type { ElementsMatcher } from \"./ElementsMatcher\";\nimport type {\n TemplateData,\n DependencySelector,\n DependencySelectorNormalized,\n MatcherOptions,\n DependencyMatchResult,\n DependencyDataSelectorData,\n} from \"./Matcher.types\";\nimport {\n normalizeElementsSelector,\n isDependencyDataSelector,\n isDependencySelector,\n} from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to determine if dependencies match a given dependencies selector.\n */\nexport class DependenciesMatcher extends BaseElementsMatcher {\n /**\n * Elements matcher to use for matching elements within dependencies.\n */\n private readonly _elementsMatcher: ElementsMatcher;\n\n /**\n * Creates a new DependenciesMatcher.\n * @param elementsMatcher Elements matcher to use for matching elements within dependencies.\n * @param config Configuration options for the matcher.\n * @param micromatch Micromatch instance for matching.\n * @param globalCache Global cache instance.\n */\n constructor(\n elementsMatcher: ElementsMatcher,\n config: MatchersOptionsNormalized,\n micromatch: Micromatch\n ) {\n super(config, micromatch);\n this._elementsMatcher = elementsMatcher;\n }\n\n /**\n * Normalizes selector into DependencySelectorNormalized format, containing arrays of selectors data.\n * @param selector The dependency selector to normalize.\n * @returns The normalized dependency selector.\n */\n private _normalizeDependencySelector(\n selector: DependencySelector\n ): DependencySelectorNormalized {\n if (!isDependencySelector(selector)) {\n throw new Error(\"Invalid dependency selector\");\n }\n\n let normalizedDependencySelectors: DependencyDataSelectorData[] | null =\n null;\n\n if (selector.dependency && isDependencyDataSelector(selector.dependency)) {\n normalizedDependencySelectors = isArray(selector.dependency)\n ? selector.dependency\n : [selector.dependency];\n }\n\n return {\n from: selector.from ? normalizeElementsSelector(selector.from) : null,\n to: selector.to ? normalizeElementsSelector(selector.to) : null,\n dependency: normalizedDependencySelectors,\n };\n }\n\n /**\n * Returns the selectors matching result for the given dependency.\n * @param dependency The dependency description.\n * @param selector The dependency selector normalized.\n * @param extraTemplateData The extra template data for selector values.\n * @returns The selectors matching result for the given dependency.\n */\n private _getSelectorsMatching(\n dependency: DependencyDescription,\n selector: DependencySelectorNormalized,\n templateData: TemplateData\n ): DependencyMatchResult {\n const getDependencyMetadataSelectorMatching =\n (): DependencyDataSelectorData | null => {\n for (const dependencySelectorData of selector.dependency!) {\n const dependencyPropertiesMatch = this._dependencyPropertiesMatch(\n dependency,\n dependencySelectorData,\n templateData\n );\n if (dependencyPropertiesMatch) {\n return dependencySelectorData;\n }\n }\n return null;\n };\n\n const fromSelectorMatching = selector.from\n ? this._elementsMatcher.getSelectorMatching(\n dependency.from,\n selector.from,\n {\n extraTemplateData: templateData,\n }\n )\n : null;\n const toSelectorMatching = selector.to\n ? this._elementsMatcher.getSelectorMatching(dependency.to, selector.to, {\n extraTemplateData: templateData,\n })\n : null;\n const dependencyMetadataSelectorMatching = selector.dependency\n ? getDependencyMetadataSelectorMatching()\n : null;\n\n return {\n from: fromSelectorMatching,\n to: toSelectorMatching,\n dependency: dependencyMetadataSelectorMatching,\n isMatch: Boolean(\n (selector.from ? fromSelectorMatching : true) &&\n (selector.to ? toSelectorMatching : true) &&\n (selector.dependency ? dependencyMetadataSelectorMatching : true)\n ),\n };\n }\n\n /**\n * Determines if the dependency relationship matches the selector.\n * @param dependency The dependency description.\n * @param selector The data of an element selector.\n * @returns Whether the dependency relationship matches the selector.\n */\n private _relationshipFromMatches(\n selector: DependencyDataSelectorData,\n relationship: DependencyRelationship | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.relationship?.from) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.relationship.from,\n templateData,\n relationship\n );\n }\n\n /**\n * Determines if the dependency origin relationship matches the selector.\n * @param selector The dependency selector data.\n * @param relationship The relationship from origin element to target element.\n * @param templateData The template data for rendering selector values.\n * @returns Whether the dependency origin relationship matches.\n */\n private _relationshipToMatches(\n selector: DependencyDataSelectorData,\n relationship: DependencyRelationship | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.relationship?.to) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.relationship.to,\n templateData,\n relationship\n );\n }\n\n /**\n * Determines if the selector matches an specific kind\n * @param selector The dependency selector data\n * @param kind Kind to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the kind\n */\n private _kindMatches(\n selector: DependencyDataSelectorData,\n kind: string,\n templateData: TemplateData\n ): boolean {\n if (!selector.kind) {\n return true;\n }\n return this.isTemplateMicromatchMatch(selector.kind, templateData, kind);\n }\n\n /**\n * Determines if the selector matches some of the specifiers\n * @param selector The dependency selector data\n * @param specifiers Specifiers to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches some of the specifiers\n */\n private _specifierMatches(\n selector: DependencyDataSelectorData,\n specifiers: string[] | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.specifiers) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.specifiers,\n templateData,\n specifiers\n );\n }\n\n /**\n * Determines if the selector matches the nodeKind\n * @param selector The dependency selector data\n * @param nodeKind The nodeKind to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the nodeKind\n */\n private _nodeKindMatches(\n selector: DependencyDataSelectorData,\n nodeKind: string | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.nodeKind) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.nodeKind,\n templateData,\n nodeKind\n );\n }\n\n /**\n * Determines if the dependency description matches the selector for 'to'.\n * @param dependency The dependency description.\n * @param toSelector The selector for 'to' elements.\n * @param templateData The template data for rendering selector values\n * @returns Whether the dependency properties match the selector for 'to'.\n */\n private _sourceMatches(\n selector: DependencyDataSelectorData,\n source: string,\n templateData: TemplateData\n ): boolean {\n if (!selector.source) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.source,\n templateData,\n source\n );\n }\n\n /**\n * Determines if the selector matches the module\n * @param selector The dependency selector data\n * @param module The module to check\n * @param templateData The template data for rendering selector values\n * @returns Whether the selector matches the module\n */\n private _moduleMatches(\n selector: DependencyDataSelectorData,\n dependencyModule: string | null,\n templateData: TemplateData\n ): boolean {\n if (!selector.module) {\n return true;\n }\n return this.isTemplateMicromatchMatch(\n selector.module,\n templateData,\n dependencyModule\n );\n }\n\n /**\n * Determines if the dependency description matches the selector for dependency metadata.\n * @param dependency The dependency description.\n * @param selectorData The selector for dependency metadata.\n * @param templateData The template data for rendering selector values\n * @returns Whether the dependency properties match the selector.\n */\n private _dependencyPropertiesMatch(\n dependency: DependencyDescription,\n selectorData: DependencyDataSelectorData,\n templateData: TemplateData\n ): boolean {\n const dependencyInfo = dependency.dependency;\n const relationshipFrom = dependencyInfo.relationship.from;\n const relationshipTo = dependencyInfo.relationship.to;\n const kind = dependencyInfo.kind;\n const nodeKind = dependencyInfo.nodeKind;\n const specifiers = dependencyInfo.specifiers;\n const source = dependencyInfo.source;\n const dependencyModule = dependencyInfo.module;\n\n return (\n this._kindMatches(selectorData, kind, templateData) &&\n this._nodeKindMatches(selectorData, nodeKind, templateData) &&\n this._sourceMatches(selectorData, source, templateData) &&\n this._moduleMatches(selectorData, dependencyModule, templateData) &&\n this._relationshipFromMatches(\n selectorData,\n relationshipFrom,\n templateData\n ) &&\n this._relationshipToMatches(selectorData, relationshipTo, templateData) &&\n this._specifierMatches(selectorData, specifiers, templateData)\n );\n }\n\n /**\n * Returns the selectors matching result for the given dependency.\n * @param dependency The dependency to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The matching result for the dependency against the selector.\n */\n public getSelectorsMatching(\n dependency: DependencyDescription,\n selector: DependencySelector,\n { extraTemplateData = {} }: MatcherOptions = {}\n ): DependencyMatchResult {\n const normalizedSelector = this._normalizeDependencySelector(selector);\n\n const fromExtraData = extraTemplateData.from || {};\n const toExtraData = extraTemplateData.to || {};\n\n // Add `to` and `from` data to the template when checking elements in dependencies\n const templateData: TemplateData = {\n ...extraTemplateData,\n from: {\n ...dependency.from,\n ...fromExtraData,\n },\n to: {\n ...dependency.to,\n ...toExtraData,\n },\n dependency: dependency.dependency,\n };\n\n const result = this._getSelectorsMatching(\n dependency,\n normalizedSelector,\n templateData\n );\n return result;\n }\n\n /**\n * Returns whether the given dependency matches the selector.\n * @param dependency The dependency to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns Whether the dependency matches the selector properties.\n */\n public isDependencyMatch(\n dependency: DependencyDescription,\n selector: DependencySelector,\n options?: MatcherOptions\n ): boolean {\n const matchResult = this.getSelectorsMatching(\n dependency,\n selector,\n options\n );\n return matchResult.isMatch;\n }\n}\n","import type {\n MatchersOptionsNormalized,\n MicromatchPatternNullable,\n} from \"../Config\";\nimport type { ElementDescription } from \"../Descriptor\";\nimport {\n isArray,\n isNullish,\n isEmptyObject,\n isUndefined,\n isNull,\n} from \"../Support\";\n\nimport { BaseElementsMatcher } from \"./BaseElementsMatcher\";\nimport type {\n BaseElementSelectorData,\n ParentElementSelectorData,\n SelectableElement,\n TemplateData,\n BaseElementsSelector,\n MatcherOptions,\n} from \"./Matcher.types\";\nimport { normalizeElementsSelector } from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to determine if elements match a given selector.\n */\nexport class ElementsMatcher extends BaseElementsMatcher {\n /**\n * Creates a new ElementsSelectorMatcher.\n * @param config Configuration options for the matcher.\n * @param micromatch Micromatch instance for matching.\n * @param globalCache Global cache instance.\n */\n constructor(config: MatchersOptionsNormalized, micromatch: Micromatch) {\n super(config, micromatch);\n }\n\n /**\n * Whether the given element type matches the selector type.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element type matches the selector type.\n */\n private _isTypeMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"type\",\n selectorKey: \"type\",\n selectorValue: selector.type,\n templateData,\n });\n }\n\n /**\n * Whether the given element category matches the selector category.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element category matches the selector category.\n */\n private _isCategoryMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"category\",\n selectorKey: \"category\",\n selectorValue: selector.category,\n templateData,\n });\n }\n\n /**\n * Whether the given element path matches the selector path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element path matches the selector path.\n */\n private _isPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"path\",\n selectorKey: \"path\",\n selectorValue: selector.path,\n templateData,\n });\n }\n\n /**\n * Whether the given element path matches the selector element path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element path matches the selector element path.\n */\n private _isElementPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"elementPath\",\n selectorKey: \"elementPath\",\n selectorValue: selector.elementPath,\n templateData,\n });\n }\n\n /**\n * Whether the given element internal path matches the selector internal path.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element internal path matches the selector internal path.\n */\n private _isInternalPathMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"internalPath\",\n selectorKey: \"internalPath\",\n selectorValue: selector.internalPath,\n templateData,\n });\n }\n\n /**\n * Whether the given element origin matches the selector origin\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector value\n * @returns Whether the element origin matches the selector origin.\n */\n private _isOriginMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n return this.isElementKeyMicromatchMatch({\n element,\n selector,\n elementKey: \"origin\",\n selectorKey: \"origin\",\n selectorValue: selector.origin,\n templateData,\n });\n }\n\n /**\n * Checks if a single captured values object matches the element.\n * @param capturedValues The captured values to check.\n * @param capturedSelector The captured values selector object to check against\n * @param templateData The data to use for replace in selector values\n * @returns True if all captured values in the selector match those in the element, false otherwise.\n */\n private _checkCapturedValuesObject(\n capturedValues: SelectableElement[\"captured\"],\n capturedSelector: Record<string, MicromatchPatternNullable>,\n templateData: TemplateData\n ): boolean {\n if (!capturedValues) {\n return false;\n }\n // Use for...of with early return for better performance than every()\n for (const [key, pattern] of Object.entries(capturedSelector)) {\n const elementValue = capturedValues[key];\n if (!elementValue) {\n return false;\n }\n\n const renderedPattern = this.getRenderedTemplates(pattern, templateData);\n\n const filteredPattern = this.cleanMicromatchPattern(renderedPattern);\n\n if (!filteredPattern) {\n return false;\n }\n\n const isMatch = this.micromatch.isMatch(elementValue, filteredPattern);\n if (!isMatch) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Determines if the captured values of the element match those in the selector.\n * When the selector is an array, the element matches if it matches any of the array elements (OR logic).\n * @param element The element to check.\n * @param selector The selector to check against\n * @param templateData The data to use for replace in selector values\n * @returns True if the captured values match, false otherwise.\n */\n private _isCapturedValuesMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n if (!selector.captured || isEmptyObject(selector.captured)) {\n return true;\n }\n\n // Handle array of captured values selectors (OR logic)\n if (isArray(selector.captured)) {\n // Empty array doesn't match anything\n if (selector.captured.length === 0) {\n return false;\n }\n // Match if any of the array elements matches\n return selector.captured.some((capturedSelector) =>\n this._checkCapturedValuesObject(\n element.captured,\n capturedSelector,\n templateData\n )\n );\n }\n\n // Handle single captured values selector object\n return this._checkCapturedValuesObject(\n element.captured,\n selector.captured,\n templateData\n );\n }\n\n /**\n * Determines if the parent captured values match the selector.\n * @param parentSelector The parent selector to match.\n * @param parentCaptured The captured values from first parent.\n * @param templateData The data to use for replace in selector values\n * @returns True if the captured values match, false otherwise.\n */\n private _isParentCapturedValuesMatch(\n parentSelector: ParentElementSelectorData,\n parentCaptured: SelectableElement[\"captured\"],\n templateData: TemplateData\n ): boolean {\n if (!parentSelector.captured || isEmptyObject(parentSelector.captured)) {\n return true;\n }\n\n if (isArray(parentSelector.captured)) {\n if (parentSelector.captured.length === 0) {\n return false;\n }\n return parentSelector.captured.some((capturedSelector) =>\n this._checkCapturedValuesObject(\n parentCaptured,\n capturedSelector,\n templateData\n )\n );\n }\n\n return this._checkCapturedValuesObject(\n parentCaptured,\n parentSelector.captured,\n templateData\n );\n }\n\n /**\n * Whether the given element first parent matches the selector parent.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param templateData The data to use for replace in selector values\n * @returns Whether the first parent matches the selector parent.\n */\n private _isParentMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData,\n templateData: TemplateData\n ): boolean {\n if (isUndefined(selector.parent)) {\n return true;\n }\n if (isNull(selector.parent)) {\n return !element.parents || element.parents.length === 0;\n }\n\n const firstParent = element.parents?.[0];\n\n if (!firstParent) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.type) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.type,\n templateData,\n firstParent.type\n )\n ) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.category) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.category,\n templateData,\n firstParent.category\n )\n ) {\n return false;\n }\n\n if (\n !isUndefined(selector.parent.elementPath) &&\n !this.isTemplateMicromatchMatch(\n selector.parent.elementPath,\n templateData,\n firstParent.elementPath\n )\n ) {\n return false;\n }\n\n if (\n !this._isParentCapturedValuesMatch(\n selector.parent,\n firstParent.captured,\n templateData\n )\n ) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Determines if the isIgnored property of the element matches that in the selector.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @returns True if the isIgnored properties match, false otherwise.\n */\n private _isIgnoredMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData\n ): boolean {\n return this.isElementKeyBooleanMatch({\n element,\n selector,\n elementKey: \"isIgnored\",\n selectorKey: \"isIgnored\",\n });\n }\n\n /**\n * Determines if the isUnknown property of the element matches that in the selector.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @returns True if the isUnknown properties match, false otherwise.\n */\n private _isUnknownMatch(\n element: SelectableElement,\n selector: BaseElementSelectorData\n ): boolean {\n return this.isElementKeyBooleanMatch({\n element,\n selector,\n elementKey: \"isUnknown\",\n selectorKey: \"isUnknown\",\n });\n }\n\n /**\n * Returns the selector matching result for the given local or external element.\n * @param element The local or external element to check.\n * @param selector The selector to check against.\n * @param extraTemplateData Extra template data to use for matching.\n * @returns The selector matching result for the given element, or null if none matches.\n */\n private _getSelectorMatching(\n element: SelectableElement,\n selectorsData: BaseElementSelectorData[],\n extraTemplateData: TemplateData\n ): BaseElementSelectorData | null {\n const templateData: TemplateData = {\n element,\n ...extraTemplateData,\n };\n // Optimized loop with early exits for better performance\n for (const selectorData of selectorsData) {\n // Order checks by likelihood of failing for better short-circuiting\n // Most restrictive checks first to fail fast\n if (\n !this._isTypeMatch(element, selectorData, templateData) ||\n !this._isCategoryMatch(element, selectorData, templateData) ||\n !this._isOriginMatch(element, selectorData, templateData) ||\n !this._isIgnoredMatch(element, selectorData) ||\n !this._isUnknownMatch(element, selectorData) ||\n !this._isPathMatch(element, selectorData, templateData) ||\n !this._isElementPathMatch(element, selectorData, templateData) ||\n !this._isInternalPathMatch(element, selectorData, templateData) ||\n !this._isCapturedValuesMatch(element, selectorData, templateData) ||\n !this._isParentMatch(element, selectorData, templateData)\n ) {\n continue; // Early exit on first failed condition\n }\n\n // All conditions passed, return the first matching selector\n return selectorData;\n }\n\n return null;\n }\n\n /**\n * Returns the selector matching result for the given element, or null if none matches.\n * It omits checks in keys applying only to dependency between elements, such as relationship.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The selector matching result for the given element, or null if none matches.\n */\n public getSelectorMatching(\n element: ElementDescription,\n selector: BaseElementsSelector,\n { extraTemplateData = {} }: MatcherOptions = {}\n ): BaseElementSelectorData | null {\n const selectorsData = normalizeElementsSelector(selector);\n return this._getSelectorMatching(element, selectorsData, extraTemplateData);\n }\n\n /**\n * Returns whether the given element matches the selector.\n * It omits checks in keys applying only to dependency between elements, such as relationship.\n * @param element The element to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns Whether the element matches the selector properties applying to elements.\n */\n public isElementMatch(\n element: ElementDescription,\n selector: BaseElementsSelector,\n options?: MatcherOptions\n ): boolean {\n const selectorMatching = this.getSelectorMatching(\n element,\n selector,\n options\n );\n return !isNullish(selectorMatching);\n }\n}\n","/**\n * Map of the modes to interpret the pattern in an ElementDescriptor.\n */\nexport const ELEMENT_DESCRIPTOR_MODES_MAP = {\n /** Mode to interpret the pattern as a folder */\n FOLDER: \"folder\",\n /** Mode to interpret the pattern as a file */\n FILE: \"file\",\n /** Mode to interpret the pattern as a full path */\n FULL: \"full\",\n} as const;\n\n/**\n * Mode to interpret the pattern in an ElementDescriptor.\n */\nexport type ElementDescriptorMode =\n (typeof ELEMENT_DESCRIPTOR_MODES_MAP)[keyof typeof ELEMENT_DESCRIPTOR_MODES_MAP];\n\n/**\n * Pattern(s) to match files for an element descriptor.\n */\nexport type ElementDescriptorPattern = string | string[];\n\n/**\n * Descriptor for an element (or layer) in the project.\n * Defines the type of the element, the pattern to match files, and optional settings like mode and capture groups.\n */\nexport type BaseElementDescriptor = {\n /** Micromatch pattern(s) to match files belonging to this element. */\n pattern: ElementDescriptorPattern;\n /**\n * Optional micromatch pattern. If provided, the left side of the element path must match also with this pattern from the root of the project (like if pattern is [basePattern]/** /[pattern]).\n * This option is useful when using the option mode with file or folder values, but capturing fragments from the rest of the full path is also needed\n **/\n basePattern?: string;\n /**\n * Mode to interpret the pattern. Can be \"folder\" (default), \"file\", or \"full\".\n * - \"folder\": Default value. the element type will be assigned to the first file's parent folder matching the pattern.\n * In the practice, it is like adding ** /* to the given pattern, but the plugin makes it by itself because it needs to know exactly which parent folder has to be considered the element.\n * - \"file\": The given pattern will not be modified, but the plugin will still try to match the last part of the path.\n * So, a pattern like *.model.js would match with paths src/foo.model.js, src/modules/foo/foo.model.js, src/modules/foo/models/foo.model.js, etc.\n * - \"full\": The given pattern will only match with patterns matching the full path.\n * This means that you will have to provide patterns matching from the base project path.\n * So, in order to match src/modules/foo/foo.model.js you'll have to provide patterns like ** /*.model.js, ** /* /*.model.js, src/* /* /*.model.js, etc. (the chosen pattern will depend on what do you want to capture from the path)\n */\n mode?: ElementDescriptorMode;\n /**\n * It allows to capture values of some fragments in the matching path to use them later in the rules configuration.\n * Must be an array of strings representing the names of the capture groups in the pattern.\n * The number of capture names must be equal to the number of capturing groups in the pattern.\n * For example, if the pattern is \"src/modules/(* *)/(* *).service.js\" the capture could be [\"module\", \"service\"].\n * Then, in the rules configuration, you could use [\"service\", { module: \"auth\" }] to match only services from the auth module.\n */\n capture?: string[];\n /**\n * Like capture, but for the basePattern.\n * This allows to capture values from the left side of the path, which is useful when using the basePattern option.\n * The captured values will be merged with the ones from the capture option. If the same name is used in both captures, the value from capture will take precedence.\n */\n baseCapture?: string[];\n};\n\n/**\n * Element descriptor with a type.\n */\nexport type ElementDescriptorWithType = BaseElementDescriptor & {\n /** Type of the element (e.g., \"service\", \"component\", \"util\"). */\n type: string;\n /** Category of the element */\n category?: never;\n};\n\n/**\n * Element descriptor with a category.\n */\nexport type ElementDescriptorWithCategory = BaseElementDescriptor & {\n /** Category of the element (e.g., \"domain\", \"infrastructure\", \"application\"). */\n category: string;\n /** Type of the element*/\n type?: never;\n};\n\n/**\n * Element descriptor with both type and category.\n */\nexport type ElementDescriptorWithTypeAndCategory = BaseElementDescriptor & {\n /** Type of the element (e.g., \"service\", \"component\", \"util\"). */\n type: string;\n /** Category of the element (e.g., \"domain\", \"infrastructure\", \"application\"). */\n category: string;\n};\n\n/**\n * Element descriptor, which can be defined by type, category, or both.\n */\nexport type ElementDescriptor =\n | ElementDescriptorWithType\n | ElementDescriptorWithCategory\n | ElementDescriptorWithTypeAndCategory;\n\n/**\n * Array of element descriptors.\n */\nexport type ElementDescriptors = ElementDescriptor[];\n\nexport type ElementDescriptionWithSource = ElementDescription & {\n module?: string | null;\n};\n\n/**\n * Serialized cache of element descriptions.\n */\nexport type DescriptionsSerializedCache = Record<\n string,\n ElementDescription | ElementDescriptionWithSource\n>;\n\n/**\n * Serialized cache of file elements.\n */\nexport type FileElementsSerializedCache = Record<string, ElementDescription>;\n\n/**\n * Serialized cache for ElementsDescriptor class.\n */\nexport type ElementsDescriptorSerializedCache = {\n /** Serialized descriptions cache */\n descriptions: DescriptionsSerializedCache;\n /** Serialized files cache */\n files: FileElementsSerializedCache;\n};\n\n/**\n * Captured values from an element path.\n */\nexport type CapturedValues = Record<string, string>;\n\n/**\n * Origins of an element\n */\nexport const ELEMENT_ORIGINS_MAP = {\n /** Origin of local elements (files) */\n LOCAL: \"local\",\n /** Origin of external elements (libraries) */\n EXTERNAL: \"external\",\n /** Origin of core elements */\n CORE: \"core\",\n} as const;\n\n/**\n * Kind of element origin, either local, external, or core.\n */\nexport type ElementOrigin =\n (typeof ELEMENT_ORIGINS_MAP)[keyof typeof ELEMENT_ORIGINS_MAP];\n\n/**\n * Base element properties related to captured values\n */\nexport type BaseElementDescription = {\n /** Absolute path of the file. It might be null when a dependency path can't be resolved */\n path: string | null;\n /** Path of the file relative to the element, or null if the element is ignored or unknown */\n elementPath: string | null;\n /** Internal path of the file relative to the elementPath, or null if the element is ignored or unknown */\n internalPath: string | null;\n /** Type of the element, or null if the element is ignored or unknown */\n type: string | null;\n /** Category of the element, or null if the element is ignored or unknown */\n category: string | null;\n /** Captured values from the element, or null if the element descriptor has no capture or the element is ignored or unknown */\n captured: CapturedValues | null;\n /** Parent elements, or null if the element is ignored, unknown, or it is not a local element */\n parents: ElementParent[] | null;\n /** Origin of the element, or null if the element is ignored */\n origin: ElementOrigin | null;\n /** Indicates if the element is ignored by settings. If true, the element will be excluded from processing any other properties. */\n isIgnored: boolean;\n /** Indicates if the element is unknown, which means that it cannot be resolved to any descriptor */\n isUnknown: boolean;\n};\n\n/**\n * Parent elements\n */\nexport type ElementParent = {\n /** Type of the parent element */\n type: string | null;\n /** Category of the parent element */\n category: string | null;\n /** Path of the element relative to the project */\n elementPath: string;\n /** Captured values from the parent element */\n captured: CapturedValues | null;\n};\n\n/**\n * Description of an ignored element\n */\nexport type IgnoredElement = BaseElementDescription & {\n /** Type of the element */\n type: null;\n /** Category of the element */\n category: null;\n /** Ignored elements have not captured values */\n captured: null;\n /** Origin of the element */\n origin: null;\n /** Indicates if the file is ignored */\n isIgnored: true;\n /** Indicates that the element is unknown */\n isUnknown: true;\n};\n\n/**\n * Description of an unknown local element\n */\nexport type LocalElementUnknown = BaseElementDescription & {\n /** Type of the element */\n type: null;\n /** Category of the element */\n category: null;\n /** Unknown elements have not captured values */\n captured: null;\n /** Indicates that the element is local */\n origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;\n /** Indicates that the file is not ignored */\n isIgnored: false;\n /** Indicates that the element is unknown */\n isUnknown: true;\n};\n\n/**\n * Description of a local element (file)\n */\nexport type LocalElementKnown = BaseElementDescription & {\n /** Path of the element */\n path: string;\n /** Captured values from the parent element */\n captured: CapturedValues | null;\n /** Path of the file relative to the element */\n elementPath: string;\n /** Internal path of the file relative to the elementPath */\n internalPath: string;\n /** Parent elements */\n parents: ElementParent[];\n /** Indicates that the element is local */\n origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;\n /** Indicates that the file is not ignored */\n isIgnored: false;\n /** Indicates that the element is known */\n isUnknown: false;\n};\n\n/**\n * Description of an unknown external element.\n */\nexport type ExternalElementDescription = BaseElementDescription & {\n origin: typeof ELEMENT_ORIGINS_MAP.EXTERNAL;\n isIgnored: false;\n};\n\n/**\n * Description of an unknown core element.\n */\nexport type CoreElementDescription = BaseElementDescription & {\n origin: typeof ELEMENT_ORIGINS_MAP.CORE;\n isIgnored: false;\n};\n\n/**\n * Description of an element, either local or dependency\n */\nexport type ElementDescription =\n | LocalElementKnown\n | LocalElementUnknown\n | IgnoredElement\n | ExternalElementDescription\n | CoreElementDescription;\n","import {\n isString,\n isObjectWithProperty,\n isArray,\n isEmptyArray,\n} from \"../Support/TypeGuards\";\n\nimport type {\n ElementDescription,\n LocalElementKnown,\n BaseElementDescriptor,\n ElementDescriptorPattern,\n ElementDescriptorMode,\n ElementDescriptorWithType,\n ElementDescriptorWithCategory,\n ElementDescriptor,\n IgnoredElement,\n LocalElementUnknown,\n BaseElementDescription,\n} from \"./ElementsDescriptor.types\";\nimport {\n ELEMENT_DESCRIPTOR_MODES_MAP,\n ELEMENT_ORIGINS_MAP,\n} from \"./ElementsDescriptor.types\";\n\n/**\n * Determines if the given value is a valid element descriptor mode.\n * @param value The value to check.\n * @returns True if the value is a valid element descriptor mode, false otherwise.\n */\nexport function isElementDescriptorMode(\n value: unknown\n): value is ElementDescriptorMode {\n return (\n isString(value) &&\n Object.values(ELEMENT_DESCRIPTOR_MODES_MAP).includes(\n value as ElementDescriptorMode\n )\n );\n}\n\n/**\n * Determines if the given value is a valid element descriptor pattern.\n * @param value The value to check.\n * @returns True if the value is a valid element descriptor pattern, false otherwise.\n */\nexport function isElementDescriptorPattern(\n value: unknown\n): value is ElementDescriptorPattern {\n return (\n isString(value) ||\n (isArray(value) && !isEmptyArray(value) && value.every(isString))\n );\n}\n\n/**\n * Determines if the given value is a base element descriptor.\n * @param value The value to check.\n * @returns True if the value is a base element descriptor, false otherwise.\n */\nexport function isBaseElementDescriptor(\n value: unknown\n): value is BaseElementDescriptor {\n return (\n isObjectWithProperty(value, \"pattern\") &&\n isElementDescriptorPattern(value.pattern)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor with type.\n * @param value The value to check.\n * @returns True if the value is an element descriptor with type, false otherwise.\n */\nexport function isElementDescriptorWithType(\n value: unknown\n): value is ElementDescriptorWithType {\n return (\n isBaseElementDescriptor(value) &&\n isObjectWithProperty(value, \"type\") &&\n isString(value.type)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor with category.\n * @param value The value to check.\n * @returns True if the value is an element descriptor with category, false otherwise.\n */\nexport function isElementDescriptorWithCategory(\n value: unknown\n): value is ElementDescriptorWithCategory {\n return (\n isBaseElementDescriptor(value) &&\n isObjectWithProperty(value, \"category\") &&\n isString(value.category)\n );\n}\n\n/**\n * Determines if the given value is an element descriptor.\n * @param value The value to check.\n * @returns True if the value is an element descriptor, false otherwise.\n */\nexport function isElementDescriptor(\n value: unknown\n): value is ElementDescriptor {\n return (\n isElementDescriptorWithType(value) || isElementDescriptorWithCategory(value)\n );\n}\n\n/**\n * Determines if the value is a BaseElement\n * @param value The value to check\n * @returns True if the value is a valid BaseElement, false otherwise\n */\nexport function isBaseElement(value: unknown): value is BaseElementDescription {\n return (\n isObjectWithProperty(value, \"type\") &&\n isObjectWithProperty(value, \"category\") &&\n isObjectWithProperty(value, \"path\") &&\n isObjectWithProperty(value, \"captured\") &&\n isObjectWithProperty(value, \"origin\") &&\n isObjectWithProperty(value, \"isIgnored\") &&\n isObjectWithProperty(value, \"isUnknown\")\n );\n}\n\n/**\n * Determines if the given value is an ignored element.\n * @param value The element to check.\n * @returns True if the element is an ignored element, false otherwise.\n */\nexport function isIgnoredElement(value: unknown): value is IgnoredElement {\n return (\n isBaseElement(value) &&\n isObjectWithProperty(value, \"isIgnored\") &&\n value.isIgnored === true\n );\n}\n\n/**\n * Determines if the given value is a local element.\n * @param value The value to check.\n * @returns True if the value is a local element, false otherwise.\n */\nexport function isLocalElement(\n value: unknown\n): value is LocalElementKnown | LocalElementUnknown {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.LOCAL;\n}\n\n/**\n * Determines if the given element is local and unknown, because its type and category could not be determined.\n * @param value The value to check.\n * @returns True if the element is an unknown element, false otherwise.\n */\nexport function isUnknownLocalElement(\n value: unknown\n): value is LocalElementUnknown {\n return isLocalElement(value) && value.isUnknown === true;\n}\n\n/**\n * Determines if the given element is local and known, because its type and category were determined.\n * @param value The value to check.\n * @returns True if the element is an unknown element, false otherwise.\n */\nexport function isKnownLocalElement(\n value: unknown\n): value is LocalElementKnown {\n return isLocalElement(value) && value.isUnknown === false;\n}\n\n/**\n * Determines if the given value is a local dependency element.\n * @param value The value to check.\n * @returns True if the element is a local dependency element, false otherwise.\n */\nexport function isLocalDependencyElement(\n value: unknown\n): value is LocalElementKnown | LocalElementUnknown {\n return isLocalElement(value) && value.isIgnored === false;\n}\n\n/**\n * Determines if the given value is an external element.\n * @param value The value to check.\n * @returns True if the element is an external dependency element, false otherwise.\n */\nexport function isExternalDependencyElement(\n value: unknown\n): value is ElementDescription {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.EXTERNAL;\n}\n\n/**\n * Determines if the given value is a core element.\n * @param value The value to check.\n * @returns True if the element is a core dependency element, false otherwise.\n */\nexport function isCoreDependencyElement(\n value: unknown\n): value is ElementDescription {\n return isBaseElement(value) && value.origin === ELEMENT_ORIGINS_MAP.CORE;\n}\n\n/**\n * Determines if the given value is an element (local or dependency).\n * @param value The value to check.\n * @returns True if the value is an element, false otherwise.\n */\nexport function isElementDescription(\n value: unknown\n): value is ElementDescription {\n return (\n isIgnoredElement(value) ||\n isUnknownLocalElement(value) ||\n isKnownLocalElement(value) ||\n isExternalDependencyElement(value) ||\n isCoreDependencyElement(value)\n );\n}\n","import type { ElementDescription } from \"./ElementsDescriptor.types\";\n\nexport const DEPENDENCY_KIND_TYPE = \"type\" as const;\nexport const DEPENDENCY_KIND_VALUE = \"value\" as const;\nexport const DEPENDENCY_KIND_TYPEOF = \"typeof\" as const;\n\n/** Map of the kinds of dependency, either a type dependency or a value dependency */\nexport const DEPENDENCY_KINDS_MAP = {\n /** Type import, e.g., `import type { X } from 'module'` */\n TYPE: DEPENDENCY_KIND_TYPE,\n\n /** Value import, e.g., `import { X } from 'module'` */\n VALUE: DEPENDENCY_KIND_VALUE,\n\n /** typeof import, e.g. `type ModuleType = typeof import(\"./my_module\");` */\n TYPE_OF: DEPENDENCY_KIND_TYPEOF,\n} as const;\n\n/** Kind of dependency, either a type dependency or a value dependency */\nexport type DependencyKind =\n (typeof DEPENDENCY_KINDS_MAP)[keyof typeof DEPENDENCY_KINDS_MAP];\n\n/** Map of possible kinds of relationships between elements being dependencies */\nexport const DEPENDENCY_RELATIONSHIPS_MAP = {\n /** The dependency is internal to the element */\n INTERNAL: \"internal\",\n /** The dependency is a child of the element */\n CHILD: \"child\",\n /** The dependency is a descendant of the element */\n DESCENDANT: \"descendant\",\n /** The dependency is a sibling of the element (both have the same parent) */\n SIBLING: \"sibling\",\n /** The dependency is a parent of the element */\n PARENT: \"parent\",\n /** The dependency is an uncle of the element */\n UNCLE: \"uncle\",\n /** The dependency is a nephew of the element */\n NEPHEW: \"nephew\",\n /** The dependency is an ancestor of the element */\n ANCESTOR: \"ancestor\",\n} as const;\n\nexport const DEPENDENCY_RELATIONSHIPS_INVERTED_MAP = {\n [DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL]:\n DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL,\n [DEPENDENCY_RELATIONSHIPS_MAP.CHILD]: DEPENDENCY_RELATIONSHIPS_MAP.PARENT,\n [DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT]:\n DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR,\n [DEPENDENCY_RELATIONSHIPS_MAP.SIBLING]: DEPENDENCY_RELATIONSHIPS_MAP.SIBLING,\n [DEPENDENCY_RELATIONSHIPS_MAP.PARENT]: DEPENDENCY_RELATIONSHIPS_MAP.CHILD,\n [DEPENDENCY_RELATIONSHIPS_MAP.UNCLE]: DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW,\n [DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW]: DEPENDENCY_RELATIONSHIPS_MAP.UNCLE,\n [DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR]:\n DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT,\n} as const;\n\n/** Kind of relationship between elements being dependencies */\nexport type DependencyRelationship =\n (typeof DEPENDENCY_RELATIONSHIPS_MAP)[keyof typeof DEPENDENCY_RELATIONSHIPS_MAP];\n\n/** Information about a dependency between two elements */\nexport type ElementsDependencyInfo = {\n /** Source of the dependency (import/export path) */\n source: string;\n /** Base source of the dependency for external/core modules */\n module: string | null;\n /** Kind of the dependency */\n kind: DependencyKind;\n /** Type of the node creating the dependency in the dependent element */\n nodeKind: string | null;\n /** Specifiers imported or exported in the dependency */\n specifiers: string[] | null;\n /** Relationship between the elements from both perspectives */\n relationship: {\n /** Relationship between the elements from the perspective of the file */\n from: DependencyRelationship | null;\n /** Relationship between the elements from the perspective of the dependency */\n to: DependencyRelationship | null;\n };\n};\n\n/**\n * Description of a dependency between two elements\n */\nexport type DependencyDescription = {\n /** Source element of the dependency */\n from: ElementDescription;\n /** Target element of the dependency */\n to: ElementDescription;\n /** Information about the dependency */\n dependency: ElementsDependencyInfo;\n};\n\n/**\n * Serialized cache of dependencies descriptor.\n */\nexport type DependenciesDescriptorSerializedCache = Record<\n string,\n DependencyDescription\n>;\n\n/** Options for describing a dependency between two elements */\nexport type DescribeDependencyOptions = {\n /** Path of the element where the dependency originates */\n from: string;\n /** Path of the element where the dependency points to */\n to?: string;\n /** Source of the dependency (import/export path) */\n source: string;\n /** Kind of the dependency (type, runtime) */\n kind: DependencyKind;\n /** Type of the node creating the dependency in the dependent element */\n nodeKind?: string;\n /** Specifiers imported or exported in the dependency */\n specifiers?: string[];\n};\n","import {\n isString,\n isObjectWithProperty,\n isNull,\n isNullish,\n isStringArray,\n} from \"../Support/TypeGuards\";\n\nimport type {\n DependencyKind,\n DependencyRelationship,\n ElementsDependencyInfo,\n DependencyDescription,\n} from \"./DependenciesDescriptor.types\";\nimport {\n DEPENDENCY_KINDS_MAP,\n DEPENDENCY_RELATIONSHIPS_MAP,\n} from \"./DependenciesDescriptor.types\";\nimport { isElementDescription } from \"./ElementsDescriptorHelpers\";\n\n/**\n * Determines if the value is a valid dependency kind.\n * @param value The value to check\n * @returns True if the value is a valid dependency kind, false otherwise.\n */\nexport function isDependencyKind(value: unknown): value is DependencyKind {\n return (\n isString(value) &&\n Object.values(DEPENDENCY_KINDS_MAP).includes(value as DependencyKind)\n );\n}\n\n/**\n * Determines if the given value is a valid dependency relationship.\n * @param value The value to check.\n * @returns True if the value is a valid dependency relationship, false otherwise.\n */\nexport function isDependencyRelationship(\n value: unknown\n): value is DependencyRelationship {\n return (\n isString(value) &&\n Object.values(DEPENDENCY_RELATIONSHIPS_MAP).includes(\n value as DependencyRelationship\n )\n );\n}\n\n/**\n * Determines if the given value is a valid dependency relationship description.\n * @param value The value to check.\n * @returns True if the value is a valid dependency relationship, false otherwise.\n */\nexport function isDependencyRelationshipDescription(\n value: unknown\n): value is DependencyRelationship {\n return (\n isObjectWithProperty(value, \"to\") &&\n (isNull(value.to) || isDependencyRelationship(value.to)) &&\n isObjectWithProperty(value, \"from\") &&\n (isNull(value.from) || isDependencyRelationship(value.from))\n );\n}\n\n/**\n * Returns whether the given value is a valid ElementsDependencyInfo object.\n * @param value The value to check.\n * @returns True if the value is a valid ElementsDependencyInfo object, false otherwise.\n */\nexport function isElementsDependencyInfo(\n value: unknown\n): value is ElementsDependencyInfo {\n return (\n isObjectWithProperty(value, \"source\") &&\n isString(value.source) &&\n isObjectWithProperty(value, \"module\") &&\n (isNullish(value.module) || isString(value.module)) &&\n isObjectWithProperty(value, \"kind\") &&\n isDependencyKind(value.kind) &&\n isObjectWithProperty(value, \"relationship\") &&\n isDependencyRelationshipDescription(value.relationship) &&\n isObjectWithProperty(value, \"nodeKind\") &&\n (isNull(value.nodeKind) || isString(value.nodeKind)) &&\n isObjectWithProperty(value, \"specifiers\") &&\n (isNull(value.specifiers) || isStringArray(value.specifiers))\n );\n}\n\n/**\n * Determines whether the given value is a valid DependencyDescription object.\n * @param value The value to check\n * @returns True if the value is a valid DependencyDescription object, false otherwise.\n */\nexport function isDependencyDescription(\n value: unknown\n): value is DependencyDescription {\n return (\n isObjectWithProperty(value, \"to\") &&\n isElementDescription(value.to) &&\n isObjectWithProperty(value, \"from\") &&\n isElementDescription(value.from) &&\n isObjectWithProperty(value, \"dependency\") &&\n isElementsDependencyInfo(value.dependency)\n );\n}\n\n/**\n * Determines whether the given dependency description is internal.\n * @param dependency The dependency to check\n * @returns True if the dependency is internal, false otherwise\n */\nexport function isInternalDependency(\n dependency: DependencyDescription\n): boolean {\n return (\n dependency.dependency.relationship.to ===\n DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL\n );\n}\n","import { isString } from \"../Support\";\n\nimport type { NotUndefined } from \"./Cache.types\";\n\n/**\n * Generic cache manager class. Enables caching of values based on complex keys.\n */\nexport class CacheManager<CacheKey extends NotUndefined, CachedValue> {\n /**\n * Internal cache map\n */\n private readonly _cache: Map<string, CachedValue>;\n\n /**\n * Creates a new CacheManager instance\n */\n constructor() {\n this._cache = new Map<string, CachedValue>();\n }\n\n /**\n * Generates a string key from the given cache key. Has to be implemented for non-string keys.\n * @param key The cache key to generate from\n * @returns The generated string key\n */\n protected generateKey(key: CacheKey): string {\n if (isString(key)) {\n return key;\n }\n const errorMessage =\n \"Cache key generation for non-string keys is not implemented because it causes performance issues: \" +\n JSON.stringify(key);\n throw new Error(errorMessage);\n }\n\n /**\n * Generates a hashed key for the given cache key\n * @param key The cache key to hash\n * @returns The hashed key as a string\n */\n public getKey(key: CacheKey): string {\n return this.generateKey(key);\n }\n\n /**\n * Retrieves a value from the cache based on the given hashed key\n * @param hashedKey The hashed key to retrieve\n * @returns The cached value or undefined if not found\n */\n public get(hashedKey: string): CachedValue | undefined {\n return this._cache.get(hashedKey);\n }\n\n /**\n * Stores a value in the cache with a given hashed key\n * @param hashedKey The hashed key to store\n * @param value The value to cache\n */\n public set(hashedKey: string, value: CachedValue): void {\n this._cache.set(hashedKey, value);\n }\n\n /**\n * Checks if a value exists in the cache based on the given hashed key\n * @param hashedKey The hashed key to check\n * @returns True if the value exists, false otherwise\n */\n public has(hashedKey: string): boolean {\n return this._cache.has(hashedKey);\n }\n\n /**\n * Retrieves all cached values\n * @returns A map of all cached values\n */\n public getAll(): Map<string, CachedValue> {\n return this._cache;\n }\n\n /**\n * Clears the entire cache\n */\n public clear(): void {\n this._cache.clear();\n }\n\n /**\n * Serializes the cache to a plain object.\n * @returns The serialized cache.\n */\n public serialize(): Record<string, CachedValue> {\n return Array.from(this.getAll().entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = value;\n return acc;\n },\n {} as Record<string, CachedValue>\n );\n }\n\n /**\n * Sets the cache from a serialized object.\n * @param serializedCache The serialized cache.\n */\n public setFromSerialized(serializedCache: Record<string, CachedValue>): void {\n for (const key in serializedCache) {\n this.set(key, serializedCache[key]);\n }\n }\n}\n","import { CacheManager } from \"./Cache\";\nimport type { NotUndefined } from \"./Cache.types\";\n\n/**\n * Disabled cache manager class. Disables caching of values.\n */\nexport class CacheManagerDisabled<\n CacheKey extends NotUndefined,\n CachedValue,\n> extends CacheManager<CacheKey, CachedValue> {\n /**\n * Generates a fake cache key as caching is disabled\n * @param key The cache key to hash\n * @returns An empty string\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getKey(_key: CacheKey): string {\n return \"\";\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to retrieve\n * @returns Undefined as caching is disabled\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public get(_hashedKey: string): CachedValue | undefined {\n return undefined;\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to store\n * @param value The value to cache\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public set(_hashedKey: string, _value: CachedValue): void {\n return;\n }\n\n /**\n * Does nothing as caching is disabled\n * @param hashedKey The hashed key to check\n * @returns False as caching is disabled\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public has(_hashedKey: string): boolean {\n return false;\n }\n}\n","import { CacheManager } from \"../Cache\";\n\nimport type {\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\n\n/**\n * Cache to store previously described dependencies.\n */\nexport class DependenciesDescriptionsCache extends CacheManager<\n DescribeDependencyOptions,\n DependencyDescription\n> {\n /** Generates a unique key for the given dependency description options.\n * @param options The options to generate the key from.\n * @returns The generated key.\n */\n protected generateKey(options: {\n from: string;\n to?: string;\n source: string;\n kind: string;\n nodeKind?: string;\n specifiers?: string[];\n }): string {\n return `${options.from}|${options.to}|${options.source}|${options.kind}|${\n options.nodeKind\n }|${options.specifiers ? options.specifiers.join(\",\") : \"\"}`;\n }\n}\n","import { CacheManagerDisabled } from \"../Cache\";\nimport type { DescriptorOptionsNormalized } from \"../Config\";\n\nimport { DependenciesDescriptionsCache } from \"./DependenciesDescriptionsCache\";\nimport {\n DEPENDENCY_RELATIONSHIPS_MAP,\n DEPENDENCY_RELATIONSHIPS_INVERTED_MAP,\n} from \"./DependenciesDescriptor.types\";\nimport type {\n DependenciesDescriptorSerializedCache,\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\nimport type { ElementsDescriptor } from \"./ElementsDescriptor\";\nimport type {\n ElementDescription,\n LocalElementKnown,\n} from \"./ElementsDescriptor.types\";\nimport {\n isIgnoredElement,\n isKnownLocalElement,\n} from \"./ElementsDescriptorHelpers\";\n\n/**\n * Class describing dependencies between elements.\n */\nexport class DependenciesDescriptor {\n /**\n * Cache to store previously described dependencies.\n */\n private readonly _dependenciesCache:\n | DependenciesDescriptionsCache\n | CacheManagerDisabled<DescribeDependencyOptions, DependencyDescription>;\n\n /**\n * Elements descriptor instance.\n */\n private readonly _elementsDescriptor: ElementsDescriptor;\n\n /**\n * Configuration options.\n */\n private readonly _config: DescriptorOptionsNormalized;\n\n /**\n * Creates a new DependenciesDescriptor instance.\n * @param elementsDescriptor The elements descriptor instance.\n * @param config The configuration options.\n */\n constructor(\n elementsDescriptor: ElementsDescriptor,\n config: DescriptorOptionsNormalized\n ) {\n this._elementsDescriptor = elementsDescriptor;\n this._config = config;\n this._dependenciesCache = this._config.cache\n ? new DependenciesDescriptionsCache()\n : new CacheManagerDisabled<\n DescribeDependencyOptions,\n DependencyDescription\n >();\n }\n\n /**\n * Serializes the elements cache to a plain object.\n * @returns The serialized elements cache.\n */\n public serializeCache(): DependenciesDescriptorSerializedCache {\n return this._dependenciesCache.serialize();\n }\n\n /**\n * Sets the elements cache from a serialized object.\n * @param serializedCache The serialized elements cache.\n */\n public setCacheFromSerialized(\n serializedCache: DependenciesDescriptorSerializedCache\n ): void {\n this._dependenciesCache.setFromSerialized(serializedCache);\n }\n\n /**\n * Clears the elements cache.\n */\n public clearCache(): void {\n this._dependenciesCache.clear();\n }\n\n /**\n * Retrieves the element path of the parent of a given element.\n * @param elementInfo The element whose parent is to be retrieved.\n * @returns The parent element path, or undefined if none exists.\n */\n private _getParent(elementInfo: LocalElementKnown) {\n return elementInfo.parents[0]?.elementPath;\n }\n\n /**\n * Retrieves the common ancestor of two elements.\n * @param elementInfoA The first element.\n * @param elementInfoB The second element.\n * @returns The common ancestor element path, or undefined if none exists.\n */\n private _getCommonAncestor(\n elementInfoA: LocalElementKnown,\n elementInfoB: LocalElementKnown\n ) {\n const commonAncestor = elementInfoA.parents.find((elementParentA) => {\n return elementInfoB.parents.some((elementParentB) => {\n return elementParentA.elementPath === elementParentB.elementPath;\n });\n });\n return commonAncestor?.elementPath;\n }\n\n /**\n * Checks if the parent of element A is an ancestor of element B.\n * @param elementA The element A.\n * @param elementB The element B.\n * @returns True if the parent of element A is an ancestor of element B, false otherwise.\n */\n private _isDescendantOfParent(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n const commonAncestor = this._getCommonAncestor(elementA, elementB);\n return commonAncestor && commonAncestor === this._getParent(elementA);\n }\n\n /**\n * Checks if two elements are siblings (same parent).\n * @param elementA The first element.\n * @param elementB The second element.\n * @returns True if the elements are siblings, false otherwise.\n */\n private _isSibling(elementA: LocalElementKnown, elementB: LocalElementKnown) {\n const parentA = this._getParent(elementA);\n const parentB = this._getParent(elementB);\n return parentA && parentB && parentA === parentB;\n }\n\n /**\n * Checks if one element is a descendant of another.\n * @param elementA The potential descendant element.\n * @param elementB The potential ancestor element.\n * @returns True if elementA is a descendant of elementB, false otherwise.\n */\n private _isDescendant(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n return elementA.parents.some(\n (parent) => parent.elementPath === elementB.elementPath\n );\n }\n\n /**\n * Checks if one element is a child of another.\n * @param elementA The potential child element.\n * @param elementB The potential parent element.\n * @returns True if elementA is a child of elementB, false otherwise.\n */\n private _isChild(elementA: LocalElementKnown, elementB: LocalElementKnown) {\n return this._getParent(elementA) === elementB.elementPath;\n }\n\n /**\n * Checks if two local elements are internally related (same element).\n * @param elementA The first element.\n * @param elementB The second element.\n * @returns True if the elements are internally related, false otherwise.\n */\n private _isInternal(\n elementA: LocalElementKnown,\n elementB: LocalElementKnown\n ) {\n return elementA.elementPath === elementB.elementPath;\n }\n\n /**\n * Retrieves the relationship between two local known elements in terms of dependency.\n * @param element The element depending on another element.\n * @param dependency The element being depended on.\n * @returns The relationship between the elements.\n */\n private _dependencyRelationship(\n element: ElementDescription,\n dependency: ElementDescription\n ) {\n if (\n isIgnoredElement(dependency) ||\n !isKnownLocalElement(dependency) ||\n !isKnownLocalElement(element)\n ) {\n return null;\n }\n if (this._isInternal(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.INTERNAL;\n }\n if (this._isChild(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.CHILD;\n }\n if (this._isDescendant(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.DESCENDANT;\n }\n if (this._isSibling(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.SIBLING;\n }\n if (this._isChild(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.PARENT;\n }\n if (this._isDescendant(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.ANCESTOR;\n }\n if (this._isDescendantOfParent(dependency, element)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.UNCLE;\n }\n if (this._isDescendantOfParent(element, dependency)) {\n return DEPENDENCY_RELATIONSHIPS_MAP.NEPHEW;\n }\n return null;\n }\n\n private _dependencyRelationships(\n element: ElementDescription,\n dependency: ElementDescription\n ) {\n const toRelationship = this._dependencyRelationship(element, dependency);\n const fromRelationship = toRelationship\n ? DEPENDENCY_RELATIONSHIPS_INVERTED_MAP[toRelationship]\n : null;\n return {\n from: fromRelationship,\n to: toRelationship,\n };\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency({\n from,\n to,\n source,\n kind,\n nodeKind,\n specifiers,\n }: DescribeDependencyOptions): DependencyDescription {\n const cacheKey = this._dependenciesCache.getKey({\n from,\n to,\n source,\n kind,\n nodeKind,\n specifiers,\n });\n if (this._dependenciesCache.has(cacheKey)) {\n return this._dependenciesCache.get(cacheKey)!;\n }\n\n const fromElement = this._elementsDescriptor.describeElement(from);\n const toElement = this._elementsDescriptor.describeElement(to, source);\n const { module: dependencyModule, ...toElementDescription } = toElement;\n\n const result = {\n from: fromElement,\n to: toElementDescription,\n dependency: {\n source,\n module: dependencyModule || null,\n kind,\n nodeKind: nodeKind || null,\n relationship: this._dependencyRelationships(\n fromElement,\n toElementDescription\n ),\n specifiers: specifiers || null,\n },\n };\n\n this._dependenciesCache.set(cacheKey, result);\n\n return result;\n }\n}\n","import type Mod from \"node:module\";\n\nimport isCoreModule from \"is-core-module\";\n\nimport { CacheManager, CacheManagerDisabled } from \"../Cache\";\nimport type { DescriptorOptionsNormalized, MicromatchPattern } from \"../Config\";\nimport type { Micromatch } from \"../Matcher\";\nimport { isArray, isNullish, normalizePath } from \"../Support\";\n\nimport type {\n ElementDescriptionWithSource,\n ElementDescription,\n ElementDescriptor,\n ElementDescriptors,\n LocalElementKnown,\n CapturedValues,\n LocalElementUnknown,\n ElementsDescriptorSerializedCache,\n} from \"./ElementsDescriptor.types\";\nimport {\n ELEMENT_DESCRIPTOR_MODES_MAP,\n ELEMENT_ORIGINS_MAP,\n} from \"./ElementsDescriptor.types\";\nimport {\n isElementDescriptorMode,\n isKnownLocalElement,\n isElementDescriptor,\n} from \"./ElementsDescriptorHelpers\";\n\nconst UNKNOWN_ELEMENT: LocalElementUnknown = {\n path: null,\n elementPath: null,\n internalPath: null,\n parents: null,\n type: null,\n category: null,\n captured: null,\n origin: ELEMENT_ORIGINS_MAP.LOCAL,\n isIgnored: false,\n isUnknown: true,\n};\n\n/** Options for the _fileDescriptorMatch private method */\ntype FileDescriptorMatchOptions = {\n /** The element descriptor to match. */\n elementDescriptor: ElementDescriptor;\n /** The file path to match against the descriptor */\n filePath: string;\n /** The current path segments leading to the element */\n currentPathSegments: string[];\n /** The last path segment that was matched */\n lastPathSegmentMatching: number;\n /** Whether the element matched previously */\n alreadyMatched: boolean;\n};\n\nconst SCOPED_PACKAGE_REGEX = /^@[^/]*\\/?[^/]+/;\nconst EXTERNAL_PATH_REGEX = /^\\w/;\n\n/**\n * Class describing elements in a project given their paths and configuration.\n */\nexport class ElementsDescriptor {\n private _mod: typeof Mod | null = null;\n /**\n * Cache to store previously described elements.\n */\n private readonly _descriptionsCache:\n | CacheManager<string, ElementDescription | ElementDescriptionWithSource>\n | CacheManagerDisabled<\n string,\n ElementDescription | ElementDescriptionWithSource\n >;\n\n /**\n * Cache to store previously described files.\n */\n private readonly _filesCache:\n | CacheManager<string, ElementDescription>\n | CacheManagerDisabled<string, ElementDescription>;\n\n /**\n * Configuration instance for this descriptor.\n */\n private readonly _config: DescriptorOptionsNormalized;\n\n /**\n * Element descriptors used by this descriptor.\n */\n private readonly _elementDescriptors: ElementDescriptors;\n\n /** Micromatch instance for path matching */\n private readonly _micromatch: Micromatch;\n\n /**\n * The configuration options for this descriptor.\n * @param elementDescriptors The element descriptors.\n * @param configOptions The configuration options.\n * @param globalCache The global cache for various caching needs.\n * @param micromatch The micromatch instance for path matching.\n */\n constructor(\n elementDescriptors: ElementDescriptors,\n configOptions: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._micromatch = micromatch;\n this._elementDescriptors = elementDescriptors;\n this._validateDescriptors(elementDescriptors);\n this._config = configOptions;\n this._filesCache = this._config.cache\n ? new CacheManager<string, ElementDescription>()\n : new CacheManagerDisabled<string, ElementDescription>();\n this._descriptionsCache = this._config.cache\n ? new CacheManager<string, ElementDescription>()\n : new CacheManagerDisabled<string, ElementDescription>();\n this._loadModuleInNode();\n }\n\n /**\n * Serializes the elements cache to a plain object.\n * @returns The serialized elements cache.\n */\n public serializeCache(): ElementsDescriptorSerializedCache {\n return {\n descriptions: this._descriptionsCache.serialize(),\n files: this._filesCache.serialize(),\n };\n }\n\n /**\n * Sets the elements cache from a serialized object.\n * @param serializedCache The serialized elements cache.\n */\n public setCacheFromSerialized(\n serializedCache: ElementsDescriptorSerializedCache\n ): void {\n this._descriptionsCache.setFromSerialized(serializedCache.descriptions);\n this._filesCache.setFromSerialized(serializedCache.files);\n }\n\n /**\n * Clears the elements cache.\n */\n public clearCache(): void {\n this._descriptionsCache.clear();\n this._filesCache.clear();\n }\n\n /**\n * Loads the Node.js module to access built-in modules information when running in Node.js environment.\n */\n private _loadModuleInNode(): void {\n // istanbul ignore next: Fallback for non-Node.js environments\n if (\n !this._mod &&\n !isNullish(process) &&\n !isNullish(process.versions) &&\n !isNullish(process.versions.node)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n this._mod = require(\"node:module\");\n }\n }\n\n /**\n * Validates the element descriptors to ensure they are correctly defined.\n */\n private _validateDescriptors(elementDescriptors: ElementDescriptors): void {\n let index = 0;\n for (const descriptor of elementDescriptors) {\n if (!isElementDescriptor(descriptor)) {\n throw new Error(\n `Element descriptor at index ${index} must have a pattern, and either a 'type' or 'category' defined.`\n );\n }\n index++;\n }\n }\n\n /**\n * Determines if a dependency source is a core module.\n * @param dependencySource The source of the dependency to check.\n * @param baseDependencySource The base source of the dependency to check.\n * @returns True if the dependency source is a core module, false otherwise.\n */\n private _dependencySourceIsCoreModule(\n dependencySource: string,\n baseDependencySource: string\n ): boolean {\n // istanbul ignore next: Fallback for non-Node.js environments\n if (this._mod) {\n const moduleWithoutPrefix = baseDependencySource.startsWith(\"node:\")\n ? baseDependencySource.slice(5)\n : baseDependencySource;\n return this._mod.builtinModules.includes(moduleWithoutPrefix);\n }\n // istanbul ignore next: Fallback for non-Node.js environments\n return isCoreModule(dependencySource);\n }\n\n /**\n * Determines if a dependency source is scoped (e.g., @scope/package).\n * @param dependencySource The source of the dependency to check.\n * @returns True if the dependency source is scoped, false otherwise.\n */\n private _dependencySourceIsScoped(dependencySource: string): boolean {\n return SCOPED_PACKAGE_REGEX.test(dependencySource);\n }\n\n /**\n * Determines if a dependency source is external or an alias.\n * @param dependencySource The source of the dependency to check.\n * @returns True if the dependency source is external or an alias, false otherwise.\n */\n private _dependencySourceIsExternalOrScoped(\n dependencySource: string\n ): boolean {\n return (\n EXTERNAL_PATH_REGEX.test(dependencySource) ||\n this._dependencySourceIsScoped(dependencySource)\n );\n }\n\n /**\n * Gets the base source of an external module.\n * @param dependencySource The source of the dependency to check.\n * @returns The base source of the external module. (e.g., for \"@scope/package/submodule\", it returns \"@scope/package\")\n */\n private _getExternalOrCoreModuleModule(dependencySource: string): string {\n if (this._dependencySourceIsScoped(dependencySource)) {\n const [scope, packageName] = dependencySource.split(\"/\");\n return `${scope}/${packageName}`;\n }\n const [pkg] = dependencySource.split(\"/\");\n return pkg;\n }\n\n /**\n * Determines if a file path is outside the configured root path.\n * @param filePath The file path to check.\n * @returns True if the file path is outside the root path, false otherwise.\n */\n private _isOutsideRootPath(filePath: string): boolean {\n if (!this._config.rootPath) {\n return false;\n }\n return !filePath.startsWith(this._config.rootPath);\n }\n\n /**\n * Converts an absolute file path to a relative path if rootPath is configured.\n * If rootPath is not configured, returns the path as-is (maintains backward compatibility).\n * @param filePath The file path to convert (can be absolute or relative)\n * @returns The relative path if rootPath is configured and path is absolute, otherwise the original path\n */\n private _toRelativePath(filePath: string): string {\n if (!this._config.rootPath || this._isOutsideRootPath(filePath)) {\n return filePath;\n }\n return filePath.replace(this._config.rootPath, \"\");\n }\n\n /**\n * Checks if a source string matches any of the provided patterns using micromatch.\n * @param patterns - Array of micromatch patterns\n * @param source - The source string to match against patterns\n * @returns True if the source matches any pattern, false otherwise\n */\n private _matchesAnyPattern(\n patterns: MicromatchPattern,\n source?: string\n ): boolean {\n if (!source || patterns.length === 0) {\n return false;\n }\n return this._micromatch.isMatch(source, patterns);\n }\n\n /**\n * Determines if an element is external based on its file path and dependency source.\n * Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:\n * - unresolvableAlias: Files whose path cannot be resolved (filePath is null)\n * - inNodeModules: Non-relative paths that include \"node_modules\"\n * - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)\n * - customSourcePatterns: Source matches any of the configured patterns\n * @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.\n * @param isOutsideRootPath Whether the file path is outside the configured root path.\n * @param dependencySource The import/export source string\n * @returns True if any of the configured conditions is met, false otherwise\n */\n private _isExternalDependency(\n filePath: string | null,\n isOutsideRootPath: boolean,\n dependencySource?: string\n ): boolean {\n const {\n unresolvableAlias,\n inNodeModules,\n outsideRootPath,\n customSourcePatterns,\n } = this._config.flagAsExternal;\n\n // Check outsideRootPath: resolved path is outside configured root path\n if (outsideRootPath && isOutsideRootPath) {\n return true;\n }\n\n // Check inNodeModules: path includes node_modules\n if (inNodeModules && filePath?.includes(\"node_modules\")) {\n return true;\n }\n\n // Check unresolvableAlias: dependency whose path cannot be resolved\n if (\n unresolvableAlias &&\n !filePath &&\n dependencySource &&\n this._dependencySourceIsExternalOrScoped(dependencySource)\n ) {\n return true;\n }\n\n // Check customSourcePatterns: source matches configured patterns\n if (this._matchesAnyPattern(customSourcePatterns, dependencySource)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines if a given path is included based on the configuration.\n * Uses caching for better performance on repeated calls.\n * @param elementPath The element path to check.\n * @param includeExternal Whether to include external files.\n * @returns True if the path is included, false otherwise.\n */\n private _pathIsIncluded(elementPath: string): boolean {\n let result: boolean;\n\n if (this._config.includePaths && this._config.ignorePaths) {\n const isIncluded = this._micromatch.isMatch(\n elementPath,\n this._config.includePaths\n );\n const isIgnored = this._micromatch.isMatch(\n elementPath,\n this._config.ignorePaths\n );\n result = isIncluded && !isIgnored;\n } else if (this._config.includePaths) {\n result = this._micromatch.isMatch(elementPath, this._config.includePaths);\n } else if (this._config.ignorePaths) {\n result = !this._micromatch.isMatch(elementPath, this._config.ignorePaths);\n } else {\n result = true;\n }\n\n return result;\n }\n\n /**\n * Gets captured values from the captured array and capture configuration.\n * @param captured The array of captured strings.\n * @param captureConfig The configuration for capturing values.\n * @returns The captured values as an object.\n */\n private _getCapturedValues(\n captured: string[],\n captureConfig?: string[]\n ): CapturedValues | null {\n if (!captureConfig) {\n return null;\n }\n return captured.reduce((capturedValues, captureValue, index) => {\n if (captureConfig[index]) {\n capturedValues[captureConfig[index]] = captureValue;\n }\n return capturedValues;\n }, {} as CapturedValues);\n }\n\n /**\n * Gets the element path based on the path pattern, path segments to the element, and all path segments from the file path.\n * @param pathPattern The element path pattern.\n * @param pathSegments The path segments leading to the element.\n * @param allPathSegments The full path segments from the file path.\n * @returns The element path.\n */\n private _getElementPath(\n pathPattern: string,\n pathSegments: string[],\n allPathSegments: string[]\n ): string {\n const elementPathRegexp = this._micromatch.makeRe(pathPattern);\n\n const testedSegments: string[] = [];\n let result: string | undefined;\n\n for (const pathSegment of pathSegments) {\n testedSegments.push(pathSegment);\n const joinedSegments = testedSegments.join(\"/\");\n if (elementPathRegexp.test(joinedSegments)) {\n result = joinedSegments;\n break; // Early exit when match is found\n }\n }\n // NOTE: result should never be undefined here, as we already matched the pattern before\n return `${[...allPathSegments].reverse().join(\"/\").split(result!)[0]}${result}`;\n }\n\n /**\n * Determines if an element descriptor matches the given parameters in the provided path.\n * @param options The options for matching the descriptor.\n * @returns The result of the match, including whether it matched and any captured values.\n */\n private _fileDescriptorMatch(options: FileDescriptorMatchOptions): {\n matched: true;\n capture: string[];\n baseCapture: string[] | null;\n useFullPathMatch: boolean;\n patternUsed: string;\n };\n\n /**\n * Determines if an element descriptor matches the given parameters in the provided path.\n * @param options The options for matching the descriptor.\n * @param options.elementDescriptor The element descriptor to match.\n * @param options.filePath The file path to match against the descriptor.\n * @param options.currentPathSegments The current path segments leading to the element.\n * @param options.lastPathSegmentMatching The last path segment that was matched.\n * @param options.alreadyMatched Whether the element matched previously.\n * @returns The result of the match, including whether it matched.\n */\n private _fileDescriptorMatch({\n elementDescriptor,\n filePath,\n currentPathSegments,\n lastPathSegmentMatching,\n alreadyMatched,\n }: FileDescriptorMatchOptions): {\n matched: boolean;\n capture?: string[];\n baseCapture?: string[] | null;\n useFullPathMatch?: boolean;\n patternUsed?: string;\n } {\n const mode = isElementDescriptorMode(elementDescriptor.mode)\n ? elementDescriptor.mode\n : ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER;\n const patterns = isArray(elementDescriptor.pattern)\n ? elementDescriptor.pattern\n : [elementDescriptor.pattern];\n\n for (const pattern of patterns) {\n const useFullPathMatch =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FULL && !alreadyMatched;\n const effectivePattern =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER && !alreadyMatched\n ? `${pattern}/**/*`\n : pattern;\n\n const targetPath = useFullPathMatch\n ? filePath\n : currentPathSegments.join(\"/\");\n\n let baseCapture: string[] | null = null;\n let hasCapture = true;\n\n if (elementDescriptor.basePattern) {\n const baseTarget = filePath\n .split(\"/\")\n .slice(0, filePath.split(\"/\").length - lastPathSegmentMatching)\n .join(\"/\");\n baseCapture = this._micromatch.capture(\n [elementDescriptor.basePattern, \"**\", effectivePattern].join(\"/\"),\n baseTarget\n );\n hasCapture = baseCapture !== null;\n }\n\n const capture = this._micromatch.capture(effectivePattern, targetPath);\n\n if (capture && hasCapture) {\n return {\n matched: true,\n capture,\n baseCapture,\n useFullPathMatch,\n patternUsed: pattern,\n };\n }\n }\n\n return { matched: false };\n }\n\n /**\n * Retrieves the description of a local file given its path.\n * @param elementPath The path of the element to describe.\n * @returns The description of the element.\n */\n private _getFileDescription(filePath?: string): ElementDescription {\n // Return unknown element if no file path is provided. Filepath couldn't be resolved.\n if (!filePath) {\n return {\n ...UNKNOWN_ELEMENT,\n };\n }\n\n // Return ignored element if the path is not included in the configuration.\n if (!this._pathIsIncluded(filePath)) {\n return {\n ...UNKNOWN_ELEMENT,\n path: filePath,\n isIgnored: true,\n origin: null,\n };\n }\n\n const parents: LocalElementKnown[\"parents\"] = [];\n const elementResult: Partial<LocalElementKnown> = {\n path: filePath,\n type: null,\n category: null,\n captured: null,\n origin: ELEMENT_ORIGINS_MAP.LOCAL,\n isIgnored: false,\n };\n\n interface State {\n pathSegmentsAccumulator: string[];\n lastPathSegmentMatching: number;\n }\n\n const state: State = {\n pathSegmentsAccumulator: [],\n lastPathSegmentMatching: 0,\n };\n\n const pathSegments = filePath.split(\"/\").reverse();\n\n const processElementMatch = (\n elementDescriptor: ElementDescriptor,\n matchInfo: {\n matched: true;\n capture: string[];\n baseCapture: string[] | null;\n useFullPathMatch: boolean;\n patternUsed: string;\n },\n currentPathSegments: string[],\n elementPaths: string[]\n ) => {\n const { capture, baseCapture, useFullPathMatch, patternUsed } = matchInfo;\n\n let capturedValues = this._getCapturedValues(\n capture,\n elementDescriptor.capture\n );\n\n if (elementDescriptor.basePattern && baseCapture) {\n capturedValues = {\n ...this._getCapturedValues(\n baseCapture,\n elementDescriptor.baseCapture\n ),\n ...capturedValues,\n };\n }\n\n const elementPath = useFullPathMatch\n ? filePath\n : this._getElementPath(patternUsed, currentPathSegments, elementPaths);\n\n if (!elementResult.type && !elementResult.category) {\n const mode =\n elementDescriptor.mode || ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER;\n // It is the main element\n elementResult.type = elementDescriptor.type || null;\n elementResult.category = elementDescriptor.category || null;\n elementResult.isUnknown = false;\n elementResult.elementPath = elementPath;\n elementResult.captured = capturedValues;\n elementResult.internalPath =\n mode === ELEMENT_DESCRIPTOR_MODES_MAP.FOLDER ||\n filePath !== elementPath // When using 'file' mode, but the pattern matches a folder, we need to calculate the internal path\n ? filePath.replace(`${elementPath}/`, \"\")\n : filePath.split(\"/\").pop(); // In 'file' mode, if the pattern matches the full file, internalPath is the file name\n } else {\n // It is a parent element, because we have already matched the main one\n parents.push({\n type: elementDescriptor.type || null,\n category: elementDescriptor.category || null,\n elementPath,\n captured: capturedValues,\n });\n }\n };\n\n // Optimized matching loop - reduced complexity from O(n*m) to better performance\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i];\n state.pathSegmentsAccumulator.unshift(segment);\n\n // Early exit if we have both type and category (main element found)\n const alreadyHasMainElement =\n Boolean(elementResult.type) || Boolean(elementResult.category);\n\n for (const elementDescriptor of this._elementDescriptors) {\n const match = this._fileDescriptorMatch({\n elementDescriptor,\n filePath,\n currentPathSegments: state.pathSegmentsAccumulator,\n lastPathSegmentMatching: state.lastPathSegmentMatching,\n alreadyMatched: alreadyHasMainElement,\n });\n\n if (match.matched) {\n processElementMatch(\n elementDescriptor,\n match,\n state.pathSegmentsAccumulator,\n pathSegments\n );\n state.pathSegmentsAccumulator = [];\n state.lastPathSegmentMatching = i + 1;\n\n // Break out of the inner loop since we found a match\n break;\n }\n }\n }\n\n const result = { ...elementResult, parents };\n\n // Not matched as any element, ensure that it is marked as unknown\n if (!isKnownLocalElement(result)) {\n return {\n ...UNKNOWN_ELEMENT,\n path: filePath,\n };\n }\n\n return result;\n }\n\n /**\n * Describes a file given its path.\n * @param includeExternal Whether to include external files (inside node_modules) in the matching process.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n private _describeFile(filePath?: string): ElementDescription {\n const cacheKey = this._filesCache.getKey(String(filePath));\n if (this._filesCache.has(cacheKey)) {\n return this._filesCache.get(cacheKey)!;\n }\n const description = this._getFileDescription(filePath);\n this._filesCache.set(cacheKey, description);\n return description;\n }\n\n /**\n * Returns an external or core dependency element given its dependency source and file path.\n * @param dependencySource The source of the dependency.\n * @param isOutsideRootPath Whether the file path is outside the configured root path.\n * @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.\n * @returns The external or core dependency element, or null if it is a local dependency.\n */\n private _getExternalOrCoreDependencyElement(\n dependencySource: string,\n isOutsideRootPath: boolean,\n filePath?: string\n ): ElementDescriptionWithSource | null {\n const baseDependencySource =\n this._getExternalOrCoreModuleModule(dependencySource);\n\n // Determine if the dependency source is a core module\n const isCore = this._dependencySourceIsCoreModule(\n dependencySource,\n baseDependencySource\n );\n\n if (isCore) {\n const coreElement: ElementDescriptionWithSource = {\n ...UNKNOWN_ELEMENT,\n module: baseDependencySource,\n origin: ELEMENT_ORIGINS_MAP.CORE,\n };\n return coreElement;\n }\n\n const isExternal = this._isExternalDependency(\n filePath || null,\n isOutsideRootPath,\n dependencySource\n );\n\n if (isExternal) {\n const externalElement: ElementDescriptionWithSource = {\n ...UNKNOWN_ELEMENT,\n path: filePath || null,\n internalPath:\n dependencySource.replace(baseDependencySource, \"\") || null,\n module: baseDependencySource,\n origin: ELEMENT_ORIGINS_MAP.EXTERNAL,\n };\n return externalElement;\n }\n return null;\n }\n\n /**\n * Describes an element given its file path and dependency source, if any.\n * @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.\n * @param dependencySource The source of the dependency, if the element to describe is so. It refers to the import/export path used to reference the file or external module.\n * @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.\n */\n private _describeElement(): LocalElementUnknown;\n private _describeElement(filePath?: string): ElementDescription;\n private _describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescriptionWithSource;\n\n private _describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescription | ElementDescriptionWithSource {\n const cacheKey = `${String(dependencySource)}::${String(filePath)}`;\n if (this._descriptionsCache.has(cacheKey)) {\n return this._descriptionsCache.get(cacheKey)!;\n }\n\n const normalizedFilePath = filePath ? normalizePath(filePath) : filePath;\n const isOutsideRootPath = normalizedFilePath\n ? this._isOutsideRootPath(normalizedFilePath)\n : false;\n const relativePath =\n normalizedFilePath && this._config.rootPath\n ? this._toRelativePath(normalizedFilePath)\n : normalizedFilePath;\n\n const externalOrCoreDependencyElement = dependencySource\n ? this._getExternalOrCoreDependencyElement(\n dependencySource,\n isOutsideRootPath,\n relativePath\n )\n : null;\n\n if (externalOrCoreDependencyElement) {\n this._descriptionsCache.set(cacheKey, externalOrCoreDependencyElement);\n return externalOrCoreDependencyElement;\n }\n\n const fileDescription = this._describeFile(relativePath);\n\n this._descriptionsCache.set(cacheKey, fileDescription);\n return fileDescription;\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.\n * @returns The description of the element.\n */\n public describeElement(filePath?: string): ElementDescription;\n /**\n * Describes a dependency target element given dependency source and target file path.\n * @param filePath The path of the dependency target file, if known. Can be absolute if rootPath is configured, or relative if not.\n * @param dependencySource The source of the dependency.\n * @returns The description of the dependency element.\n */\n public describeElement(\n filePath: string | undefined,\n dependencySource: string\n ): ElementDescriptionWithSource;\n public describeElement(\n filePath?: string,\n dependencySource?: string\n ): ElementDescription | ElementDescriptionWithSource {\n return this._describeElement(filePath, dependencySource);\n }\n}\n","import type { DescriptorOptionsNormalized } from \"../Config\";\nimport type { Micromatch } from \"../Matcher\";\n\nimport { DependenciesDescriptor } from \"./DependenciesDescriptor\";\nimport type {\n DependencyDescription,\n DescribeDependencyOptions,\n} from \"./DependenciesDescriptor.types\";\nimport type { DescriptorsSerializedCache } from \"./Descriptors.types\";\nimport { ElementsDescriptor } from \"./ElementsDescriptor\";\nimport type {\n ElementDescriptors,\n ElementDescription,\n} from \"./ElementsDescriptor.types\";\n\n/**\n * Class with methods to describe elements and dependencies between them.\n */\nexport class Descriptors {\n private readonly _elementsDescriptor: ElementsDescriptor;\n private readonly _dependenciesDescriptor: DependenciesDescriptor;\n\n /** Creates a new DescriptorsManager instance\n * @param elementDescriptors The element descriptors.\n * @param configOptions The configuration options.\n * @param micromatch The Micromatch instance.\n */\n constructor(\n elementDescriptors: ElementDescriptors,\n config: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._elementsDescriptor = new ElementsDescriptor(\n elementDescriptors,\n config,\n micromatch\n );\n this._dependenciesDescriptor = new DependenciesDescriptor(\n this._elementsDescriptor,\n config\n );\n }\n\n /**\n * Serializes the elements and dependencies cache to a plain object.\n * @returns The serialized elements and dependencies cache.\n */\n public serializeCache(): DescriptorsSerializedCache {\n return {\n elements: this._elementsDescriptor.serializeCache(),\n dependencies: this._dependenciesDescriptor.serializeCache(),\n };\n }\n\n /**\n * Sets the elements and dependencies cache from a serialized object.\n * @param serializedCache The serialized elements and dependencies cache.\n */\n public setCacheFromSerialized(\n serializedCache: DescriptorsSerializedCache\n ): void {\n this._elementsDescriptor.setCacheFromSerialized(serializedCache.elements);\n this._dependenciesDescriptor.setCacheFromSerialized(\n serializedCache.dependencies\n );\n }\n\n /**\n * Clears all caches.\n */\n public clearCache(): void {\n this._elementsDescriptor.clearCache();\n this._dependenciesDescriptor.clearCache();\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n public describeElement(filePath?: string): ElementDescription {\n return this._elementsDescriptor.describeElement(filePath);\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency(\n options: DescribeDependencyOptions\n ): DependencyDescription {\n return this._dependenciesDescriptor.describeDependency(options);\n }\n}\n","import type { DescriptorOptionsNormalized } from \"../Config\";\nimport type {\n ElementDescriptors,\n DescribeDependencyOptions,\n ElementDescription,\n DependencyDescription,\n} from \"../Descriptor\";\nimport {\n Descriptors,\n isElementDescription,\n isDependencyDescription,\n} from \"../Descriptor\";\n\nimport type { DependenciesMatcher } from \"./DependenciesMatcher\";\nimport type { ElementsMatcher } from \"./ElementsMatcher\";\nimport type {\n DependencySelector,\n MatcherOptions,\n ElementsSelector,\n DependencyMatchResult,\n MatcherSerializedCache,\n BaseElementSelectorData,\n} from \"./Matcher.types\";\nimport { isDependencySelector, isElementsSelector } from \"./MatcherHelpers\";\nimport type { Micromatch } from \"./Micromatch\";\n\n/**\n * Matcher class to evaluate if elements or dependencies match given selectors.\n */\nexport class Matcher {\n private readonly _descriptors: Descriptors;\n private readonly _elementsMatcher: ElementsMatcher;\n private readonly _dependenciesMatcher: DependenciesMatcher;\n\n /**\n * Constructor for the Matcher class.\n * @param descriptors Element descriptors to use for matching.\n * @param elementsMatcher Elements matcher instance.\n * @param dependenciesMatcher Dependencies matcher instance.\n * @param config Configuration options.\n * @param globalCache Global cache instance.\n */\n constructor(\n descriptors: ElementDescriptors,\n elementsMatcher: ElementsMatcher,\n dependenciesMatcher: DependenciesMatcher,\n config: DescriptorOptionsNormalized,\n micromatch: Micromatch\n ) {\n this._descriptors = new Descriptors(descriptors, config, micromatch);\n this._elementsMatcher = elementsMatcher;\n this._dependenciesMatcher = dependenciesMatcher;\n }\n\n /**\n * Describes an element given its file path.\n * @param filePath The path of the file to describe.\n * @returns The description of the element.\n */\n public describeElement(filePath: string) {\n return this._descriptors.describeElement(filePath);\n }\n\n /**\n * Describes elements in a dependency relationship, and provides additional information about the dependency itself.\n * @param options The options for describing the elements and the dependency details.\n * @returns The description of the dependency between the elements.\n */\n public describeDependency(options: DescribeDependencyOptions) {\n return this._descriptors.describeDependency(options);\n }\n\n /**\n * Determines if an element matches a given selector.\n * @param filePath The file path of the element\n * @param selector The selector to match against\n * @param options Extra matcher options\n * @returns True if the element matches the selector, false otherwise\n */\n public isElementMatch(\n filePath: string,\n selector: ElementsSelector,\n options?: MatcherOptions\n ): boolean {\n const description = this._descriptors.describeElement(filePath);\n return this._elementsMatcher.isElementMatch(description, selector, options);\n }\n\n /**\n * Determines if a dependency matches a given selector.\n * @param dependencyData The data describing the dependency\n * @param selector The selector to match against\n * @param options Extra matcher options\n * @returns True if the dependency matches the selector, false otherwise\n */\n public isDependencyMatch(\n dependencyData: DescribeDependencyOptions,\n selector: DependencySelector,\n options?: MatcherOptions\n ): boolean {\n const description = this._descriptors.describeDependency(dependencyData);\n return this._dependenciesMatcher.isDependencyMatch(\n description,\n selector,\n options\n );\n }\n\n /**\n * Determines the selector matching for an element.\n * @param filePath The file path of the element\n * @param selector The selectors to match against\n * @param options Extra options for matching\n * @returns The matching selector data or null if no match is found\n */\n public getElementSelectorMatching(\n filePath: string,\n selector: ElementsSelector,\n options?: MatcherOptions\n ) {\n const description = this._descriptors.describeElement(filePath);\n return this._elementsMatcher.getSelectorMatching(\n description,\n selector,\n options\n );\n }\n\n /**\n * Determines the selector matching for a dependency.\n * @param dependencyData The data describing the dependency\n * @param selector The selectors to match against\n * @param options Extra options for matching\n * @returns The matching dependency result or null if no match is found\n */\n public getDependencySelectorMatching(\n dependencyData: DescribeDependencyOptions,\n selector: DependencySelector,\n options?: MatcherOptions\n ) {\n const description = this._descriptors.describeDependency(dependencyData);\n return this._dependenciesMatcher.getSelectorsMatching(\n description,\n selector,\n options\n );\n }\n\n /**\n * Returns the selectors matching result for the given element or dependency description.\n * @param description The element or dependency description to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The selectors matching result for the given description, and whether it matches or not.\n */\n public getDependencySelectorMatchingDescription(\n description: DependencyDescription,\n selector: DependencySelector,\n options?: MatcherOptions\n ): DependencyMatchResult {\n if (\n isDependencySelector(selector) &&\n isDependencyDescription(description)\n ) {\n return this._dependenciesMatcher.getSelectorsMatching(\n description,\n selector,\n options\n );\n }\n throw new Error(\n \"Invalid arguments: Please provide a valid description and selector\"\n );\n }\n\n /**\n * Returns the first element selector matching result for the given element description.\n * @param description The element description to check.\n * @param selector The selector to check against.\n * @param options Extra options for matching, such as templates data, etc.\n * @returns The first matching selector result for the given description, or null if no match is found.\n */\n public getElementSelectorMatchingDescription(\n description: ElementDescription,\n selector: ElementsSelector,\n options?: MatcherOptions\n ): BaseElementSelectorData | null {\n if (isElementsSelector(selector) && isElementDescription(description)) {\n return this._elementsMatcher.getSelectorMatching(\n description,\n selector,\n options\n );\n }\n throw new Error(\n \"Invalid arguments: Please provide a valid description and selector\"\n );\n }\n\n /**\n * Clears all caches.\n */\n public clearCache() {\n this._descriptors.clearCache();\n }\n\n /**\n * Serializes the descriptors matchers cache to a plain object.\n * @returns The serialized cache\n */\n public serializeCache(): MatcherSerializedCache {\n return {\n descriptors: this._descriptors.serializeCache(),\n };\n }\n\n /**\n * Sets the descriptors matchers cache from a serialized object.\n * @param serializedCache The serialized cache\n */\n public setCacheFromSerialized(serializedCache: {\n descriptors: ReturnType<Descriptors[\"serializeCache\"]>;\n }) {\n this._descriptors.setCacheFromSerialized(serializedCache.descriptors);\n }\n}\n","import micromatch from \"micromatch\";\n\nimport { CacheManager, CacheManagerDisabled } from \"../Cache\";\nimport { isArray } from \"../Support\";\n\nimport type { MicromatchSerializedCache } from \"./Matcher.types\";\n\n/**\n * Cache key type for micromatch matching results\n */\ntype MatchingResultsCacheKey = {\n value: string;\n pattern: string | string[];\n};\n\n/**\n * Cache for micromatch matching results\n */\nclass MatchingResultsCache extends CacheManager<\n MatchingResultsCacheKey,\n boolean\n> {\n /**\n * Generates a unique cache key based on the value and pattern\n * @param param0 The cache key components\n * @returns The generated cache key\n */\n protected generateKey({ value, pattern }: MatchingResultsCacheKey): string {\n return `${value}::${isArray(pattern) ? pattern.join(\"|\") : pattern}`;\n }\n}\n\n/**\n * Cache key type for micromatch captured values\n */\ntype CapturedValueCacheKey = {\n pattern: string;\n target: string;\n};\n\n/**\n * Cache for micromatch captured values\n */\nclass CapturedValueCache extends CacheManager<\n CapturedValueCacheKey,\n string[] | null\n> {\n /**\n * Generates a unique cache key based on the pattern and target\n * @param param0 The cache key components\n * @returns The generated cache key\n */\n protected generateKey({ pattern, target }: CapturedValueCacheKey): string {\n return `${pattern}|${target}`;\n }\n}\n\n/**\n * Micromatch wrapper class with caching capabilities.\n */\n\nexport class Micromatch {\n /**\n * Cache for micromatch matching results\n */\n private readonly _matchingResultsCache:\n | MatchingResultsCache\n | CacheManagerDisabled<MatchingResultsCacheKey, boolean>;\n\n /**\n * Cache for micromatch captures\n */\n private readonly _capturesCache:\n | CapturedValueCache\n | CacheManagerDisabled<CapturedValueCacheKey, string[] | null> =\n new CacheManagerDisabled<CapturedValueCacheKey, string[] | null>();\n\n /**\n * Cache for micromatch makeRe results\n */\n private readonly _makeReCache: CacheManagerDisabled<string, RegExp> =\n new CacheManagerDisabled<string, RegExp>();\n\n /**\n * Creates an instance of Micromatch class.\n * @param cache Whether to use caching or not.\n */\n constructor(cache: boolean) {\n this._matchingResultsCache = cache\n ? new MatchingResultsCache()\n : new CacheManagerDisabled<MatchingResultsCacheKey, boolean>();\n this._capturesCache = cache\n ? new CapturedValueCache()\n : new CacheManagerDisabled<CapturedValueCacheKey, string[] | null>();\n this._makeReCache = cache\n ? new CacheManager<string, RegExp>()\n : new CacheManagerDisabled<string, RegExp>();\n }\n\n /**\n * Clears all caches.\n */\n public clearCache(): void {\n this._matchingResultsCache.clear();\n this._capturesCache.clear();\n this._makeReCache.clear();\n }\n\n /**\n * Serializes the current cache state.\n * @returns The serialized cache data.\n */\n public serializeCache(): MicromatchSerializedCache {\n return {\n matchingResults: this._matchingResultsCache.serialize(),\n captures: this._capturesCache.serialize(),\n };\n }\n\n /**\n * Restores the cache state from serialized data.\n * @param serializedCache The serialized cache data.\n */\n public setFromSerialized(serializedCache: MicromatchSerializedCache): void {\n this._matchingResultsCache.setFromSerialized(\n serializedCache.matchingResults\n );\n this._capturesCache.setFromSerialized(serializedCache.captures);\n }\n\n /**\n * Optimized micromatch match with caching.\n * @param value The value to match.\n * @param pattern The pattern to match against.\n * @returns True if the value matches the pattern, false otherwise.\n */\n public isMatch(value: string, pattern: string | string[]): boolean {\n const cacheKey = this._matchingResultsCache.getKey({\n value,\n pattern,\n });\n\n if (this._matchingResultsCache.has(cacheKey)) {\n return this._matchingResultsCache.get(cacheKey)!;\n }\n\n const isMatch = micromatch.isMatch(value, pattern);\n this._matchingResultsCache.set(cacheKey, isMatch);\n return isMatch;\n }\n\n /**\n * Optimized micromatch capture with caching.\n * @param pattern The pattern to match against.\n * @param target The target string to test.\n * @returns Captured groups or null if no match.\n */\n public capture(pattern: string, target: string): string[] | null {\n const cacheKey = this._capturesCache.getKey({ pattern, target });\n\n if (this._capturesCache.has(cacheKey)) {\n return this._capturesCache.get(cacheKey)!;\n }\n\n const result = micromatch.capture(pattern, target);\n this._capturesCache.set(cacheKey, result);\n return result;\n }\n\n /**\n * Optimized micromatch makeRe with caching.\n * @param pattern The pattern to convert to RegExp.\n * @returns The RegExp instance.\n */\n public makeRe(pattern: string): RegExp {\n if (this._makeReCache.has(pattern)) {\n return this._makeReCache.get(pattern)!;\n }\n const regexp = micromatch.makeRe(pattern);\n this._makeReCache.set(pattern, regexp);\n return regexp;\n }\n}\n","import { CacheManager } from \"./Cache\";\nimport type { ConfigOptionsNormalized } from \"./Config\";\nimport type { ElementDescriptors } from \"./Descriptor\";\nimport type { Matcher } from \"./Matcher\";\n\n/**\n * Cache manager for Matcher instances, unique for each different configuration\n */\nexport class MatchersCache extends CacheManager<\n {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n },\n {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n matcher: Matcher;\n }\n> {\n /**\n * Generates a unique key based on the configuration options and element descriptors\n * @param params The configuration and element descriptors\n * @returns A unique string key\n */\n protected generateKey({\n config,\n elementDescriptors,\n }: {\n config: ConfigOptionsNormalized;\n elementDescriptors: ElementDescriptors;\n }): string {\n const configHash = `${config.legacyTemplates}|${config.includePaths}|${config.ignorePaths}|${\n config.cache\n }|${config.rootPath}|${config.flagAsExternal.inNodeModules}|${config.flagAsExternal.unresolvableAlias}|${\n config.flagAsExternal.outsideRootPath\n }|${config.flagAsExternal.customSourcePatterns.join(\",\")}`;\n\n const elementDescriptorsHash = elementDescriptors\n .map(\n (descriptor) =>\n `${descriptor.type}|${descriptor.category}|${descriptor.pattern}|${descriptor.basePattern}|${descriptor.mode}|${descriptor.capture}|${descriptor.baseCapture}`\n )\n .join(\",\");\n return `${configHash}|:|${elementDescriptorsHash}`;\n }\n}\n","import type { ConfigOptions, ConfigOptionsNormalized } from \"./Config\";\nimport { Config } from \"./Config\";\nimport type { ElementDescriptors } from \"./Descriptor\";\nimport type { ElementsSerializedCache } from \"./Elements.types\";\nimport {\n Micromatch,\n DependenciesMatcher,\n ElementsMatcher,\n Matcher,\n} from \"./Matcher\";\nimport { MatchersCache } from \"./MatchersCache\";\n\n/**\n * Main class to interact with Elements functionality.\n * It include one method to get descriptors with different caching for different configurations, methods to manage the cache, and methods to match element selectors against element descriptions.\n */\nexport class Elements {\n /** The global configuration options for Elements. Can be overridden when getting a descriptor */\n private readonly _globalConfigOptions: ConfigOptionsNormalized;\n\n /** Cache manager for Matcher instances, unique for each different configuration */\n private readonly _matchersCache = new MatchersCache();\n\n /** Micromatch instances for pattern matching */\n private readonly _micromatchWithCache = new Micromatch(true);\n private readonly _micromatchWithoutCache = new Micromatch(false);\n\n /**\n * Creates a new Elements instance\n * @param configOptions The global configuration options for Elements. Can be overridden when getting a descriptor.\n */\n constructor(configOptions?: ConfigOptions) {\n const globalConfig = new Config(configOptions);\n this._globalConfigOptions = globalConfig.options;\n }\n\n /**\n * Returns a serialized representation of the current state of the cache.\n * @returns A serialized representation of the cache.\n */\n public serializeCache(): ElementsSerializedCache {\n const matchersCache = Array.from(\n this._matchersCache.getAll().entries()\n ).reduce(\n (acc, [key, cache]) => {\n acc[key] = {\n config: cache.config,\n elementDescriptors: cache.elementDescriptors,\n cache: cache.matcher.serializeCache(),\n };\n return acc;\n },\n {} as ElementsSerializedCache[\"matchers\"]\n );\n\n const micromatchCache = this._micromatchWithCache.serializeCache();\n\n return {\n matchers: matchersCache,\n micromatch: micromatchCache,\n };\n }\n\n /**\n * Sets the Elements cache from a serialized representation.\n * @param serializedCache The serialized cache to set.\n */\n public setCacheFromSerialized(\n serializedCache: ElementsSerializedCache\n ): void {\n this._micromatchWithCache.setFromSerialized(serializedCache.micromatch);\n for (const key in serializedCache.matchers) {\n const matcher = this.getMatcher(\n serializedCache.matchers[key].elementDescriptors,\n serializedCache.matchers[key].config\n );\n matcher.setCacheFromSerialized(serializedCache.matchers[key].cache);\n this._matchersCache.set(key, {\n config: serializedCache.matchers[key].config,\n elementDescriptors: serializedCache.matchers[key].elementDescriptors,\n matcher: matcher,\n });\n }\n }\n\n /**\n * Clears cache\n */\n public clearCache(): void {\n for (const { matcher } of this._matchersCache.getAll().values()) {\n matcher.clearCache();\n }\n this._matchersCache.clear();\n this._micromatchWithCache.clearCache();\n }\n\n /**\n * Gets a Matcher instance for the given configuration options.\n * It uses caching to return the same instance for the same configuration options. If no options are provided, the global configuration options are used.\n * @param elementDescriptors The element descriptors to use.\n * @param config Optional configuration options to override the global ones.\n * @returns A matcher instance, unique for each different configuration.\n */\n public getMatcher(\n elementDescriptors: ElementDescriptors,\n config?: ConfigOptions\n ): Matcher {\n const optionsToUse = config || this._globalConfigOptions;\n const configInstance = new Config(optionsToUse);\n const cacheIsEnabled = configInstance.cache;\n const configOptionsNormalized = configInstance.options;\n const descriptorNormalizedOptions = configInstance.descriptorOptions;\n const matchersNormalizedOptions = configInstance.matchersOptions;\n\n const cacheKey = this._matchersCache.getKey({\n config: configOptionsNormalized,\n elementDescriptors,\n });\n\n if (this._matchersCache.has(cacheKey)) {\n return this._matchersCache.get(cacheKey)!.matcher;\n }\n\n const micromatch = cacheIsEnabled\n ? this._micromatchWithCache\n : this._micromatchWithoutCache;\n\n const elementsMatcher = new ElementsMatcher(\n matchersNormalizedOptions,\n micromatch\n );\n const dependenciesMatcher = new DependenciesMatcher(\n elementsMatcher,\n matchersNormalizedOptions,\n micromatch\n );\n\n const matcher = new Matcher(\n elementDescriptors,\n elementsMatcher,\n dependenciesMatcher,\n descriptorNormalizedOptions,\n micromatch\n );\n\n this._matchersCache.set(cacheKey, {\n config: configOptionsNormalized,\n elementDescriptors,\n matcher,\n });\n return matcher;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UA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Ae,UAAU,KAAK;AACpC,UAAM,iBAAiB,IAAI,OAAO,YAAY;AAC9C,UAAM,iBAAiB,eAAe;AACtC,UAAM,0BAA0B,eAAe;AAC/C,UAAM,8BAA8B,eAAe;AACnD,UAAM,4BAA4B,eAAe;AAEjD,UAAM,WAAW,KAAK,eAAe,OAAO;AAAA,MAC1C,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,QAAI,KAAK,eAAe,IAAI,QAAQ,GAAG;AACrC,aAAO,KAAK,eAAe,IAAI,QAAQ,EAAG;AAAA,IAC5C;AAEA,UAAMC,cAAa,iBACf,KAAK,uBACL,KAAK;AAET,UAAM,kBAAkB,IAAI;AAAA,MAC1B;AAAA,MACAA;AAAA,IACF;AACA,UAAM,sBAAsB,IAAI;AAAA,MAC9B;AAAA,MACA;AAAA,MACAA;AAAA,IACF;AAEA,UAAM,UAAU,IAAI;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACAA;AAAA,IACF;AAEA,SAAK,eAAe,IAAI,UAAU;AAAA,MAChC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AACF;","names":["micromatch","Handlebars","micromatch","micromatch","micromatch","isCoreModule","micromatch","micromatch","micromatch","micromatch"]}