@boundaries/elements 1.1.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +348 -64
- package/dist/index.browser.d.mts +280 -319
- package/dist/index.browser.d.ts +280 -319
- package/dist/index.browser.js +562 -469
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +562 -469
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +280 -319
- package/dist/index.d.ts +280 -319
- package/dist/index.js +565 -476
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +562 -469
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
* Type representing a micromatch pattern, which can be a string or an array of strings.
|
|
3
3
|
*/
|
|
4
4
|
type MicromatchPattern = string | string[];
|
|
5
|
+
/**
|
|
6
|
+
* Type representing a micromatch pattern supporting null values
|
|
7
|
+
*/
|
|
8
|
+
type MicromatchPatternNullable = string | null | (string | null)[];
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for categorizing dependencies as external or local.
|
|
11
|
+
*/
|
|
12
|
+
type FlagAsExternalOptions = {
|
|
13
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external (default: true) */
|
|
14
|
+
unresolvableAlias?: boolean;
|
|
15
|
+
/** When true, non-relative paths that include node_modules are categorized as external (default: true) */
|
|
16
|
+
inNodeModules?: boolean;
|
|
17
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external (default: false) */
|
|
18
|
+
outsideRootPath?: boolean;
|
|
19
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external (default: []) */
|
|
20
|
+
customSourcePatterns?: string[];
|
|
21
|
+
};
|
|
5
22
|
/** Configuration options for the Config class */
|
|
6
23
|
type ConfigOptions = {
|
|
7
24
|
/** An array of path patterns to include when resolving elements. Defaults to all files if not specified */
|
|
@@ -15,15 +32,33 @@ type ConfigOptions = {
|
|
|
15
32
|
legacyTemplates?: boolean;
|
|
16
33
|
/** Whether to enable caching */
|
|
17
34
|
cache?: boolean;
|
|
35
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
36
|
+
flagAsExternal?: FlagAsExternalOptions;
|
|
37
|
+
/** Root path of the project, used for determining if dependencies are outside the project */
|
|
38
|
+
rootPath?: string;
|
|
39
|
+
};
|
|
40
|
+
type FlagAsExternalOptionsNormalized = {
|
|
41
|
+
/** When true, non-relative dependencies whose path cannot be resolved are categorized as external */
|
|
42
|
+
unresolvableAlias: boolean;
|
|
43
|
+
/** When true, non-relative paths that include node_modules are categorized as external */
|
|
44
|
+
inNodeModules: boolean;
|
|
45
|
+
/** When true, dependencies whose resolved path is outside the configured root path are categorized as external */
|
|
46
|
+
outsideRootPath: boolean;
|
|
47
|
+
/** List of patterns (using micromatch syntax) that, when matching the source of the dependency, categorize it as external */
|
|
48
|
+
customSourcePatterns: string[];
|
|
18
49
|
};
|
|
19
|
-
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache"> & {
|
|
50
|
+
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates" | "cache" | "flagAsExternal"> & {
|
|
20
51
|
/** Whether to enable legacy template support */
|
|
21
52
|
legacyTemplates: boolean;
|
|
22
53
|
/** Cache configuration options */
|
|
23
54
|
cache: boolean;
|
|
55
|
+
/** Configuration for categorizing dependencies as external or local */
|
|
56
|
+
flagAsExternal: FlagAsExternalOptionsNormalized;
|
|
57
|
+
/** Root path of the project, already normalized, and finishing with a slash, used for determining if dependencies are outside the project */
|
|
58
|
+
rootPath: string | undefined;
|
|
24
59
|
};
|
|
25
60
|
/** Options for descriptors */
|
|
26
|
-
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache">;
|
|
61
|
+
type DescriptorOptionsNormalized = Pick<ConfigOptionsNormalized, "includePaths" | "ignorePaths" | "cache" | "flagAsExternal" | "rootPath">;
|
|
27
62
|
/** Options for element matchers */
|
|
28
63
|
type MatchersOptionsNormalized = Pick<ConfigOptionsNormalized, "legacyTemplates">;
|
|
29
64
|
|
|
@@ -119,14 +154,17 @@ type ElementDescriptor = ElementDescriptorWithType | ElementDescriptorWithCatego
|
|
|
119
154
|
* Array of element descriptors.
|
|
120
155
|
*/
|
|
121
156
|
type ElementDescriptors = ElementDescriptor[];
|
|
157
|
+
type ElementDescriptionWithSource = ElementDescription & {
|
|
158
|
+
module?: string | null;
|
|
159
|
+
};
|
|
122
160
|
/**
|
|
123
161
|
* Serialized cache of element descriptions.
|
|
124
162
|
*/
|
|
125
|
-
type DescriptionsSerializedCache = Record<string, ElementDescription>;
|
|
163
|
+
type DescriptionsSerializedCache = Record<string, ElementDescription | ElementDescriptionWithSource>;
|
|
126
164
|
/**
|
|
127
165
|
* Serialized cache of file elements.
|
|
128
166
|
*/
|
|
129
|
-
type FileElementsSerializedCache = Record<string,
|
|
167
|
+
type FileElementsSerializedCache = Record<string, ElementDescription>;
|
|
130
168
|
/**
|
|
131
169
|
* Serialized cache for ElementsDescriptor class.
|
|
132
170
|
*/
|
|
@@ -158,17 +196,13 @@ type ElementOrigin = (typeof ELEMENT_ORIGINS_MAP)[keyof typeof ELEMENT_ORIGINS_M
|
|
|
158
196
|
/**
|
|
159
197
|
* Base element properties related to captured values
|
|
160
198
|
*/
|
|
161
|
-
type
|
|
199
|
+
type BaseElementDescription = {
|
|
162
200
|
/** Absolute path of the file. It might be null when a dependency path can't be resolved */
|
|
163
201
|
path: string | null;
|
|
164
202
|
/** Path of the file relative to the element, or null if the element is ignored or unknown */
|
|
165
203
|
elementPath: string | null;
|
|
166
204
|
/** Internal path of the file relative to the elementPath, or null if the element is ignored or unknown */
|
|
167
205
|
internalPath: string | null;
|
|
168
|
-
/** Source of the element when it is a dependency, or null if the element is not a dependency, or it is ignored or unknown */
|
|
169
|
-
source: string | null;
|
|
170
|
-
/** Base source of the element when it is an external or core dependency, null otherwise */
|
|
171
|
-
baseSource: string | null;
|
|
172
206
|
/** Type of the element, or null if the element is ignored or unknown */
|
|
173
207
|
type: string | null;
|
|
174
208
|
/** Category of the element, or null if the element is ignored or unknown */
|
|
@@ -200,7 +234,7 @@ type ElementParent = {
|
|
|
200
234
|
/**
|
|
201
235
|
* Description of an ignored element
|
|
202
236
|
*/
|
|
203
|
-
type IgnoredElement =
|
|
237
|
+
type IgnoredElement = BaseElementDescription & {
|
|
204
238
|
/** Type of the element */
|
|
205
239
|
type: null;
|
|
206
240
|
/** Category of the element */
|
|
@@ -217,7 +251,7 @@ type IgnoredElement = BaseElement & {
|
|
|
217
251
|
/**
|
|
218
252
|
* Description of an unknown local element
|
|
219
253
|
*/
|
|
220
|
-
type LocalElementUnknown =
|
|
254
|
+
type LocalElementUnknown = BaseElementDescription & {
|
|
221
255
|
/** Type of the element */
|
|
222
256
|
type: null;
|
|
223
257
|
/** Category of the element */
|
|
@@ -234,7 +268,7 @@ type LocalElementUnknown = BaseElement & {
|
|
|
234
268
|
/**
|
|
235
269
|
* Description of a local element (file)
|
|
236
270
|
*/
|
|
237
|
-
type LocalElementKnown =
|
|
271
|
+
type LocalElementKnown = BaseElementDescription & {
|
|
238
272
|
/** Path of the element */
|
|
239
273
|
path: string;
|
|
240
274
|
/** Captured values from the parent element */
|
|
@@ -253,65 +287,23 @@ type LocalElementKnown = BaseElement & {
|
|
|
253
287
|
isUnknown: false;
|
|
254
288
|
};
|
|
255
289
|
/**
|
|
256
|
-
*
|
|
257
|
-
*/
|
|
258
|
-
type BaseDependencyElement = BaseElement & {
|
|
259
|
-
/** Dependency source */
|
|
260
|
-
source: string;
|
|
261
|
-
/** Indicates that dependencies are not ignored */
|
|
262
|
-
isIgnored: false;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* Description of a local dependency (known)
|
|
290
|
+
* Description of an unknown external element.
|
|
266
291
|
*/
|
|
267
|
-
type
|
|
268
|
-
/**
|
|
269
|
-
* Description of a local dependency (unknown)
|
|
270
|
-
*/
|
|
271
|
-
type LocalDependencyElementUnknown = LocalElementUnknown & BaseDependencyElement;
|
|
272
|
-
/**
|
|
273
|
-
* Description of a local dependency
|
|
274
|
-
*/
|
|
275
|
-
type LocalDependencyElement = LocalDependencyElementKnown | LocalDependencyElementUnknown;
|
|
276
|
-
/**
|
|
277
|
-
* Description of an external dependency
|
|
278
|
-
*/
|
|
279
|
-
type ExternalDependencyElement = BaseDependencyElement & {
|
|
280
|
-
/** Path of the dependency relative to the base module */
|
|
281
|
-
internalPath: string;
|
|
282
|
-
/** Base module of the external dependency */
|
|
283
|
-
baseSource: string;
|
|
284
|
-
/** Indicates that the dependency is external */
|
|
292
|
+
type ExternalElementDescription = BaseElementDescription & {
|
|
285
293
|
origin: typeof ELEMENT_ORIGINS_MAP.EXTERNAL;
|
|
294
|
+
isIgnored: false;
|
|
286
295
|
};
|
|
287
296
|
/**
|
|
288
|
-
* Description of
|
|
297
|
+
* Description of an unknown core element.
|
|
289
298
|
*/
|
|
290
|
-
type
|
|
291
|
-
/** Base module of the core dependency */
|
|
292
|
-
baseSource: string;
|
|
293
|
-
/** Indicates that the dependency is core */
|
|
299
|
+
type CoreElementDescription = BaseElementDescription & {
|
|
294
300
|
origin: typeof ELEMENT_ORIGINS_MAP.CORE;
|
|
301
|
+
isIgnored: false;
|
|
295
302
|
};
|
|
296
|
-
/**
|
|
297
|
-
* Description of an ignored dependency element
|
|
298
|
-
*/
|
|
299
|
-
type IgnoredDependencyElement = IgnoredElement & {
|
|
300
|
-
/** The source of the dependency */
|
|
301
|
-
source: string;
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* Description of a file
|
|
305
|
-
*/
|
|
306
|
-
type FileElement = IgnoredElement | LocalElementKnown | LocalElementUnknown;
|
|
307
|
-
/**
|
|
308
|
-
* Description of a dependency
|
|
309
|
-
*/
|
|
310
|
-
type DependencyElementDescription = IgnoredDependencyElement | CoreDependencyElement | LocalDependencyElement | ExternalDependencyElement;
|
|
311
303
|
/**
|
|
312
304
|
* Description of an element, either local or dependency
|
|
313
305
|
*/
|
|
314
|
-
type ElementDescription =
|
|
306
|
+
type ElementDescription = LocalElementKnown | LocalElementUnknown | IgnoredElement | ExternalElementDescription | CoreElementDescription;
|
|
315
307
|
|
|
316
308
|
/**
|
|
317
309
|
* Determines if the given value is a valid element descriptor mode.
|
|
@@ -354,7 +346,7 @@ declare function isElementDescriptor(value: unknown): value is ElementDescriptor
|
|
|
354
346
|
* @param value The value to check
|
|
355
347
|
* @returns True if the value is a valid BaseElement, false otherwise
|
|
356
348
|
*/
|
|
357
|
-
declare function isBaseElement(value: unknown): value is
|
|
349
|
+
declare function isBaseElement(value: unknown): value is BaseElementDescription;
|
|
358
350
|
/**
|
|
359
351
|
* Determines if the given value is an ignored element.
|
|
360
352
|
* @param value The element to check.
|
|
@@ -379,36 +371,30 @@ declare function isUnknownLocalElement(value: unknown): value is LocalElementUnk
|
|
|
379
371
|
* @returns True if the element is an unknown element, false otherwise.
|
|
380
372
|
*/
|
|
381
373
|
declare function isKnownLocalElement(value: unknown): value is LocalElementKnown;
|
|
382
|
-
/**
|
|
383
|
-
* Determines if the given value is a dependency element.
|
|
384
|
-
* @param value The element to check.
|
|
385
|
-
* @returns True if the element is a dependency element, false otherwise.
|
|
386
|
-
*/
|
|
387
|
-
declare function isDependencyElementDescription(value: unknown): value is DependencyElementDescription;
|
|
388
|
-
/**
|
|
389
|
-
* Determines if the given value is an element (local or dependency).
|
|
390
|
-
* @param value The value to check.
|
|
391
|
-
* @returns True if the value is an element, false otherwise.
|
|
392
|
-
*/
|
|
393
|
-
declare function isElementDescription(value: unknown): value is ElementDescription;
|
|
394
374
|
/**
|
|
395
375
|
* Determines if the given value is a local dependency element.
|
|
396
376
|
* @param value The value to check.
|
|
397
377
|
* @returns True if the element is a local dependency element, false otherwise.
|
|
398
378
|
*/
|
|
399
|
-
declare function isLocalDependencyElement(value: unknown): value is
|
|
379
|
+
declare function isLocalDependencyElement(value: unknown): value is LocalElementKnown | LocalElementUnknown;
|
|
400
380
|
/**
|
|
401
381
|
* Determines if the given value is an external element.
|
|
402
382
|
* @param value The value to check.
|
|
403
383
|
* @returns True if the element is an external dependency element, false otherwise.
|
|
404
384
|
*/
|
|
405
|
-
declare function isExternalDependencyElement(value: unknown): value is
|
|
385
|
+
declare function isExternalDependencyElement(value: unknown): value is ElementDescription;
|
|
406
386
|
/**
|
|
407
387
|
* Determines if the given value is a core element.
|
|
408
388
|
* @param value The value to check.
|
|
409
389
|
* @returns True if the element is a core dependency element, false otherwise.
|
|
410
390
|
*/
|
|
411
|
-
declare function isCoreDependencyElement(value: unknown): value is
|
|
391
|
+
declare function isCoreDependencyElement(value: unknown): value is ElementDescription;
|
|
392
|
+
/**
|
|
393
|
+
* Determines if the given value is an element (local or dependency).
|
|
394
|
+
* @param value The value to check.
|
|
395
|
+
* @returns True if the value is an element, false otherwise.
|
|
396
|
+
*/
|
|
397
|
+
declare function isElementDescription(value: unknown): value is ElementDescription;
|
|
412
398
|
|
|
413
399
|
declare const DEPENDENCY_KIND_TYPE: "type";
|
|
414
400
|
declare const DEPENDENCY_KIND_VALUE: "value";
|
|
@@ -457,6 +443,10 @@ declare const DEPENDENCY_RELATIONSHIPS_INVERTED_MAP: {
|
|
|
457
443
|
type DependencyRelationship = (typeof DEPENDENCY_RELATIONSHIPS_MAP)[keyof typeof DEPENDENCY_RELATIONSHIPS_MAP];
|
|
458
444
|
/** Information about a dependency between two elements */
|
|
459
445
|
type ElementsDependencyInfo = {
|
|
446
|
+
/** Source of the dependency (import/export path) */
|
|
447
|
+
source: string;
|
|
448
|
+
/** Base source of the dependency for external/core modules */
|
|
449
|
+
module: string | null;
|
|
460
450
|
/** Kind of the dependency */
|
|
461
451
|
kind: DependencyKind;
|
|
462
452
|
/** Type of the node creating the dependency in the dependent element */
|
|
@@ -476,9 +466,9 @@ type ElementsDependencyInfo = {
|
|
|
476
466
|
*/
|
|
477
467
|
type DependencyDescription = {
|
|
478
468
|
/** Source element of the dependency */
|
|
479
|
-
from:
|
|
469
|
+
from: ElementDescription;
|
|
480
470
|
/** Target element of the dependency */
|
|
481
|
-
to:
|
|
471
|
+
to: ElementDescription;
|
|
482
472
|
/** Information about the dependency */
|
|
483
473
|
dependency: ElementsDependencyInfo;
|
|
484
474
|
};
|
|
@@ -554,16 +544,18 @@ type DescriptorsSerializedCache = {
|
|
|
554
544
|
*/
|
|
555
545
|
type DependencyMatchResult = {
|
|
556
546
|
/** The selector matching result for the 'from' element. */
|
|
557
|
-
from:
|
|
547
|
+
from: BaseElementSelectorData | null;
|
|
558
548
|
/** The selector matching result for the 'to' element. */
|
|
559
|
-
to:
|
|
549
|
+
to: BaseElementSelectorData | null;
|
|
550
|
+
/** The selector matching result for the dependency metadata. */
|
|
551
|
+
dependency: DependencyDataSelectorData | null;
|
|
560
552
|
/** Whether the dependency matches all the selector properties provided */
|
|
561
553
|
isMatch: boolean;
|
|
562
554
|
};
|
|
563
555
|
/**
|
|
564
556
|
* Serialized cache of elements matcher.
|
|
565
557
|
*/
|
|
566
|
-
type ElementsMatcherSerializedCache = Record<string,
|
|
558
|
+
type ElementsMatcherSerializedCache = Record<string, BaseElementSelectorData | null>;
|
|
567
559
|
/**
|
|
568
560
|
* Serialized cache of dependencies matcher.
|
|
569
561
|
*/
|
|
@@ -584,34 +576,36 @@ type MicromatchSerializedCache = {
|
|
|
584
576
|
/**
|
|
585
577
|
* Elements that can return a match when using an element selector.
|
|
586
578
|
*/
|
|
587
|
-
type SelectableElement =
|
|
579
|
+
type SelectableElement = ElementDescription;
|
|
588
580
|
/**
|
|
589
581
|
* Selector for matching captured values in element selectors.
|
|
590
582
|
* It is a record where the keys are the names of the captured values and the values are the patterns to match on those captured values.
|
|
583
|
+
* When provided as an array, each element in the array represents an alternative (OR logic) - the selector matches if any of the array elements matches.
|
|
591
584
|
*/
|
|
592
|
-
type CapturedValuesSelector = Record<string,
|
|
585
|
+
type CapturedValuesSelector = Record<string, MicromatchPatternNullable> | Array<Record<string, MicromatchPatternNullable>>;
|
|
593
586
|
/**
|
|
594
|
-
*
|
|
587
|
+
* Selector for matching the first parent element.
|
|
595
588
|
*/
|
|
596
|
-
type
|
|
589
|
+
type ParentElementSelectorData = {
|
|
590
|
+
/** Type of the first parent element */
|
|
591
|
+
type?: MicromatchPatternNullable;
|
|
592
|
+
/** Category of the first parent element */
|
|
593
|
+
category?: MicromatchPatternNullable;
|
|
594
|
+
/** Path of the first parent element */
|
|
595
|
+
elementPath?: MicromatchPatternNullable;
|
|
596
|
+
/** Captured values from the first parent element */
|
|
597
|
+
captured?: CapturedValuesSelector;
|
|
598
|
+
};
|
|
597
599
|
/**
|
|
598
|
-
*
|
|
600
|
+
* Data to pass to selector templates when they are rendered before matching.
|
|
599
601
|
*/
|
|
600
|
-
type
|
|
601
|
-
/** The kind of the dependency */
|
|
602
|
-
kind?: MicromatchPattern;
|
|
603
|
-
};
|
|
602
|
+
type TemplateData = Record<string, unknown>;
|
|
604
603
|
/**
|
|
605
604
|
* Options for elements and dependencies matchers.
|
|
606
605
|
*/
|
|
607
606
|
type MatcherOptions = {
|
|
608
607
|
/** Extra data to pass to captured values templates. By default, data from the element and dependency being matched is passed as to/from. */
|
|
609
608
|
extraTemplateData?: TemplateData;
|
|
610
|
-
/**
|
|
611
|
-
* Properties to add to all dependency selectors used in the matcher. Added for backwards compatibility, because eslint-plugin rules defined importKind at the top level of the rule options.
|
|
612
|
-
* @deprecated Use 'kind' property directly in the dependency element selectors instead.
|
|
613
|
-
**/
|
|
614
|
-
dependencySelectorsGlobals?: MatcherOptionsDependencySelectorsGlobals;
|
|
615
609
|
};
|
|
616
610
|
/**
|
|
617
611
|
* Simple element selector by type, represented as a string matching the element type.
|
|
@@ -623,40 +617,47 @@ type SimpleElementSelectorByType = string;
|
|
|
623
617
|
*/
|
|
624
618
|
type BaseElementSelectorData = {
|
|
625
619
|
/** Micromatch pattern(s) to match the path of the element */
|
|
626
|
-
path?:
|
|
620
|
+
path?: MicromatchPatternNullable;
|
|
627
621
|
/** Micromatch pattern(s) to match the path of the element containing the file */
|
|
628
|
-
elementPath?:
|
|
622
|
+
elementPath?: MicromatchPatternNullable;
|
|
629
623
|
/** Micromatch pattern(s) to match internal paths within the file or dependency, relative to the element path */
|
|
630
|
-
internalPath?:
|
|
624
|
+
internalPath?: MicromatchPatternNullable;
|
|
631
625
|
/** Type of the element */
|
|
632
|
-
type?:
|
|
626
|
+
type?: MicromatchPatternNullable;
|
|
633
627
|
/** Category of the element */
|
|
634
|
-
category?:
|
|
628
|
+
category?: MicromatchPatternNullable;
|
|
635
629
|
/** Captured values selector for dynamic matching */
|
|
636
630
|
captured?: CapturedValuesSelector;
|
|
631
|
+
/** Selector for matching the first parent element */
|
|
632
|
+
parent?: ParentElementSelectorData | null;
|
|
637
633
|
/** Origin of the element */
|
|
638
|
-
origin?:
|
|
639
|
-
/** Micromatch pattern(s) to match the source of the dependency */
|
|
640
|
-
source?: MicromatchPattern;
|
|
641
|
-
/** Base source of the element, e.g., the import path of a dependency */
|
|
642
|
-
baseSource?: MicromatchPattern;
|
|
634
|
+
origin?: MicromatchPatternNullable;
|
|
643
635
|
/** Whether the element is ignored */
|
|
644
636
|
isIgnored?: boolean;
|
|
645
637
|
/** Whether the element is unknown */
|
|
646
638
|
isUnknown?: boolean;
|
|
647
639
|
};
|
|
648
640
|
/**
|
|
649
|
-
* Selector for dependency
|
|
641
|
+
* Selector for dependency metadata.
|
|
650
642
|
*/
|
|
651
|
-
type
|
|
652
|
-
/** Relationship
|
|
653
|
-
relationship?:
|
|
643
|
+
type DependencyDataSelectorData = {
|
|
644
|
+
/** Relationship between both elements, from both perspectives */
|
|
645
|
+
relationship?: {
|
|
646
|
+
/** Relationship from dependant element perspective */
|
|
647
|
+
from?: MicromatchPatternNullable;
|
|
648
|
+
/** Relationship from dependency element perspective */
|
|
649
|
+
to?: MicromatchPatternNullable;
|
|
650
|
+
};
|
|
654
651
|
/** Dependency kind to filter elements */
|
|
655
|
-
kind?:
|
|
652
|
+
kind?: MicromatchPatternNullable;
|
|
656
653
|
/** Micromatch pattern(s) to match only specific imports/exports */
|
|
657
|
-
specifiers?:
|
|
654
|
+
specifiers?: MicromatchPatternNullable;
|
|
658
655
|
/** Node kind to filter elements */
|
|
659
|
-
nodeKind?:
|
|
656
|
+
nodeKind?: MicromatchPatternNullable;
|
|
657
|
+
/** Dependency source used in import/export statements */
|
|
658
|
+
source?: MicromatchPatternNullable;
|
|
659
|
+
/** Base source of the dependency for external/core modules */
|
|
660
|
+
module?: MicromatchPatternNullable;
|
|
660
661
|
};
|
|
661
662
|
/**
|
|
662
663
|
* File Element selector with options, including captured values for dynamic matching.
|
|
@@ -668,32 +669,16 @@ type BaseElementSelectorWithOptions = [
|
|
|
668
669
|
SimpleElementSelectorByType,
|
|
669
670
|
CapturedValuesSelector
|
|
670
671
|
];
|
|
671
|
-
/**
|
|
672
|
-
* Dependency Element selector with options, including captured values for dynamic matching.
|
|
673
|
-
* It is represented as a tuple where the first element is the element type (string)
|
|
674
|
-
* and the second element is an object containing a selector for captured values.
|
|
675
|
-
* @deprecated Use DependencyElementSelectorData defining an object with type and/or category and the rest of properties directly instead.
|
|
676
|
-
*/
|
|
677
|
-
type DependencyElementSelectorWithOptions = [
|
|
678
|
-
SimpleElementSelectorByType,
|
|
679
|
-
CapturedValuesSelector
|
|
680
|
-
];
|
|
681
672
|
/**
|
|
682
673
|
* Base Element selector, which can be a simple string, object with type and/or category, or a base element selector with options.
|
|
683
674
|
*/
|
|
684
675
|
type BaseElementSelector = SimpleElementSelectorByType | BaseElementSelectorData | BaseElementSelectorWithOptions;
|
|
685
676
|
/**
|
|
686
|
-
*
|
|
677
|
+
* Base elements selector, which can be a single base element selector or an array of base element selectors.
|
|
687
678
|
*/
|
|
688
|
-
type DependencyElementSelector = SimpleElementSelectorByType | DependencyElementSelectorData | DependencyElementSelectorWithOptions;
|
|
689
|
-
/** Base elements selector, which can be a single base element selector or an array of base element selectors. */
|
|
690
679
|
type BaseElementsSelector = BaseElementSelector | BaseElementSelector[];
|
|
691
|
-
/** Dependency
|
|
692
|
-
type
|
|
693
|
-
/**
|
|
694
|
-
* Element selector data, which may be a base element selector or a dependency element selector.
|
|
695
|
-
*/
|
|
696
|
-
type ElementSelectorData = BaseElementSelectorData | DependencyElementSelectorData;
|
|
680
|
+
/** Dependency metadata selector, which can be a single selector or an array of selectors. */
|
|
681
|
+
type DependencyDataSelector = DependencyDataSelectorData | DependencyDataSelectorData[];
|
|
697
682
|
/**
|
|
698
683
|
* Generic Element selector with options, including captured values for dynamic matching.
|
|
699
684
|
* It is represented as a tuple where the first element is the element type (string)
|
|
@@ -707,11 +692,11 @@ type ElementSelectorWithOptions = [
|
|
|
707
692
|
/**
|
|
708
693
|
* Element selector, which can be a simple string, object with type and/or category, or an element selector with options.
|
|
709
694
|
*/
|
|
710
|
-
type ElementSelector = SimpleElementSelectorByType |
|
|
695
|
+
type ElementSelector = SimpleElementSelectorByType | BaseElementSelectorData | ElementSelectorWithOptions;
|
|
711
696
|
/**
|
|
712
697
|
* Elements selector, which can be a single element selector or an array of element selectors.
|
|
713
698
|
*/
|
|
714
|
-
type ElementsSelector = BaseElementsSelector
|
|
699
|
+
type ElementsSelector = BaseElementsSelector;
|
|
715
700
|
/**
|
|
716
701
|
* Element selectors, which can be a single element selector or an array of element selectors.
|
|
717
702
|
* @deprecated Use ElementsSelector instead.
|
|
@@ -724,7 +709,9 @@ type DependencySelector = {
|
|
|
724
709
|
/** Selector for the dependant elements. The file originating the dependency */
|
|
725
710
|
from?: BaseElementsSelector;
|
|
726
711
|
/** Selector for the dependency elements. The element being imported/exported */
|
|
727
|
-
to?:
|
|
712
|
+
to?: BaseElementsSelector;
|
|
713
|
+
/** Selector for dependency metadata */
|
|
714
|
+
dependency?: DependencyDataSelector;
|
|
728
715
|
};
|
|
729
716
|
/**
|
|
730
717
|
* Normalized dependency selector, where 'from' and 'to' are always arrays or null.
|
|
@@ -733,40 +720,14 @@ type DependencySelectorNormalized = {
|
|
|
733
720
|
/** Selector for the dependant elements. The file originating the dependency */
|
|
734
721
|
from: BaseElementSelectorData[] | null;
|
|
735
722
|
/** Selector for the dependency elements. The element being imported/exported */
|
|
736
|
-
to:
|
|
723
|
+
to: BaseElementSelectorData[] | null;
|
|
724
|
+
/** Selector for dependency metadata */
|
|
725
|
+
dependency: DependencyDataSelectorData[] | null;
|
|
737
726
|
};
|
|
738
727
|
/**
|
|
739
|
-
*
|
|
740
|
-
* If specifiers are provided, they will be used to match specific imports from the external library.
|
|
728
|
+
* @deprecated Use DependencySelectorDependencyData instead.
|
|
741
729
|
*/
|
|
742
|
-
type
|
|
743
|
-
/**
|
|
744
|
-
* Micromatch pattern(s) to match only one or more specific subpaths of the external library.
|
|
745
|
-
*/
|
|
746
|
-
path?: MicromatchPattern;
|
|
747
|
-
/** Micromatch pattern(s) to match only specific imports/exports */
|
|
748
|
-
specifiers?: string[];
|
|
749
|
-
};
|
|
750
|
-
/**
|
|
751
|
-
* External library selector with options, represented as a tuple where the first element is the import path of the external library, and the second element is an object containing options for selecting only specific paths or specifiers from that library.
|
|
752
|
-
*/
|
|
753
|
-
type ExternalLibrarySelectorWithOptions = [
|
|
754
|
-
SimpleElementSelectorByType,
|
|
755
|
-
ExternalLibrarySelectorOptions
|
|
756
|
-
];
|
|
757
|
-
/**
|
|
758
|
-
* External library selector, which can be a simple string (the import path) or an external library selector with options.
|
|
759
|
-
*/
|
|
760
|
-
type ExternalLibrarySelector = SimpleElementSelectorByType | ExternalLibrarySelectorWithOptions;
|
|
761
|
-
/**
|
|
762
|
-
* External library selectors, which can be a single external library selector or an array of external library selectors.
|
|
763
|
-
* @deprecated Use ExternalLibrariesSelector instead.
|
|
764
|
-
*/
|
|
765
|
-
type ExternalLibrarySelectors = ExternalLibrariesSelector;
|
|
766
|
-
/**
|
|
767
|
-
* External libraries selector, which can be a single external library selector or an array of external library selectors.
|
|
768
|
-
*/
|
|
769
|
-
type ExternalLibrariesSelector = ExternalLibrarySelector | ExternalLibrarySelector[];
|
|
730
|
+
type DependencyElementSelectorData = DependencyDataSelectorData;
|
|
770
731
|
|
|
771
732
|
/**
|
|
772
733
|
* Micromatch wrapper class with caching capabilities.
|
|
@@ -825,13 +786,6 @@ declare class Micromatch {
|
|
|
825
786
|
makeRe(pattern: string): RegExp;
|
|
826
787
|
}
|
|
827
788
|
|
|
828
|
-
/**
|
|
829
|
-
* Normalizes an ElementsSelector into an array of ElementSelectorData.
|
|
830
|
-
* @param elementsSelector The elements selector, in any supported format.
|
|
831
|
-
* @returns The normalized array of selector data.
|
|
832
|
-
*/
|
|
833
|
-
declare function normalizeElementsSelector(elementsSelector: BaseElementsSelector): BaseElementSelectorData[];
|
|
834
|
-
declare function normalizeElementsSelector(elementsSelector: DependencyElementsSelector): DependencyElementSelectorData[];
|
|
835
789
|
/**
|
|
836
790
|
* Base matcher class to determine if elements or dependencies match a given selector.
|
|
837
791
|
*/
|
|
@@ -876,7 +830,13 @@ declare class BaseElementsMatcher {
|
|
|
876
830
|
* @param extraTemplateData The data to use for replace in the templates.
|
|
877
831
|
* @returns The rendered templates.
|
|
878
832
|
*/
|
|
879
|
-
protected getRenderedTemplates(template:
|
|
833
|
+
protected getRenderedTemplates(template: MicromatchPatternNullable, templateData: TemplateData): MicromatchPatternNullable;
|
|
834
|
+
/**
|
|
835
|
+
* Cleans a micromatch pattern by removing falsy values from arrays.
|
|
836
|
+
* @param pattern The micromatch pattern(s) to clean.
|
|
837
|
+
* @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.
|
|
838
|
+
*/
|
|
839
|
+
protected cleanMicromatchPattern(pattern: MicromatchPatternNullable): string | string[] | null;
|
|
880
840
|
/**
|
|
881
841
|
* Returns whether the given value matches the micromatch pattern, converting non-string values to strings.
|
|
882
842
|
* Optimized version with caching for better performance.
|
|
@@ -884,7 +844,7 @@ declare class BaseElementsMatcher {
|
|
|
884
844
|
* @param pattern The micromatch pattern to match against.
|
|
885
845
|
* @returns Whether the value matches the pattern.
|
|
886
846
|
*/
|
|
887
|
-
protected isMicromatchMatch(value: unknown, pattern:
|
|
847
|
+
protected isMicromatchMatch(value: unknown, pattern: MicromatchPatternNullable): boolean;
|
|
888
848
|
/**
|
|
889
849
|
* Returns whether the given value matches the micromatch pattern after rendering it as a template.
|
|
890
850
|
* @param pattern The micromatch pattern to render and match against.
|
|
@@ -892,13 +852,13 @@ declare class BaseElementsMatcher {
|
|
|
892
852
|
* @param value The value to check.
|
|
893
853
|
* @returns Whether the value matches the rendered pattern.
|
|
894
854
|
*/
|
|
895
|
-
protected isTemplateMicromatchMatch(pattern:
|
|
855
|
+
protected isTemplateMicromatchMatch(pattern: MicromatchPatternNullable, templateData: TemplateData, value?: unknown): boolean;
|
|
896
856
|
/**
|
|
897
857
|
* Whether the given element key matches the selector key as booleans.
|
|
898
858
|
* @param param0 The parameters object.
|
|
899
859
|
* @returns Whether the element key matches the selector key.
|
|
900
860
|
*/
|
|
901
|
-
protected isElementKeyBooleanMatch<T extends
|
|
861
|
+
protected isElementKeyBooleanMatch<T extends BaseElementDescription, S extends BaseElementSelectorData>({
|
|
902
862
|
/** The element to check. */
|
|
903
863
|
element,
|
|
904
864
|
/** The selector to check against. */
|
|
@@ -921,17 +881,17 @@ declare class BaseElementsMatcher {
|
|
|
921
881
|
* @param param0 The parameters object.
|
|
922
882
|
* @returns Whether the element key matches the selector key.
|
|
923
883
|
*/
|
|
924
|
-
protected isElementKeyMicromatchMatch<T extends SelectableElement, S extends BaseElementSelectorData
|
|
884
|
+
protected isElementKeyMicromatchMatch<T extends SelectableElement, S extends BaseElementSelectorData>({ element, selector, elementKey, selectorKey, selectorValue, templateData, }: {
|
|
925
885
|
/** The element to check. */
|
|
926
886
|
element: T;
|
|
927
887
|
/** The selector to check against. */
|
|
928
888
|
selector: S;
|
|
929
889
|
/** The key of the element to check. */
|
|
930
|
-
elementKey:
|
|
890
|
+
elementKey: keyof T;
|
|
931
891
|
/** The key of the selector to check against. */
|
|
932
|
-
selectorKey:
|
|
892
|
+
selectorKey: keyof BaseElementSelectorData;
|
|
933
893
|
/** The value of the selector key to check against. */
|
|
934
|
-
selectorValue?:
|
|
894
|
+
selectorValue?: MicromatchPatternNullable;
|
|
935
895
|
/** Data to pass when the selector value is rendered as a template */
|
|
936
896
|
templateData: TemplateData;
|
|
937
897
|
}): boolean;
|
|
@@ -941,8 +901,6 @@ declare class BaseElementsMatcher {
|
|
|
941
901
|
* Matcher class to determine if elements match a given selector.
|
|
942
902
|
*/
|
|
943
903
|
declare class ElementsMatcher extends BaseElementsMatcher {
|
|
944
|
-
/** Whether the cache is enabled or not */
|
|
945
|
-
private readonly _cacheIsEnabled;
|
|
946
904
|
/**
|
|
947
905
|
* Creates a new ElementsSelectorMatcher.
|
|
948
906
|
* @param config Configuration options for the matcher.
|
|
@@ -999,29 +957,38 @@ declare class ElementsMatcher extends BaseElementsMatcher {
|
|
|
999
957
|
*/
|
|
1000
958
|
private _isOriginMatch;
|
|
1001
959
|
/**
|
|
1002
|
-
*
|
|
1003
|
-
* @param
|
|
1004
|
-
* @param
|
|
1005
|
-
* @param templateData The data to use for replace in selector
|
|
1006
|
-
* @returns
|
|
1007
|
-
*/
|
|
1008
|
-
private _isBaseSourceMatch;
|
|
1009
|
-
/**
|
|
1010
|
-
* Whether the given element source matches the selector source
|
|
1011
|
-
* @param element The element to check.
|
|
1012
|
-
* @param selector The selector to check against.
|
|
1013
|
-
* @param templateData The data to use for replace in selector value
|
|
1014
|
-
* @returns Whether the element source matches the selector source.
|
|
960
|
+
* Checks if a single captured values object matches the element.
|
|
961
|
+
* @param capturedValues The captured values to check.
|
|
962
|
+
* @param capturedSelector The captured values selector object to check against
|
|
963
|
+
* @param templateData The data to use for replace in selector values
|
|
964
|
+
* @returns True if all captured values in the selector match those in the element, false otherwise.
|
|
1015
965
|
*/
|
|
1016
|
-
private
|
|
966
|
+
private _checkCapturedValuesObject;
|
|
1017
967
|
/**
|
|
1018
968
|
* Determines if the captured values of the element match those in the selector.
|
|
969
|
+
* When the selector is an array, the element matches if it matches any of the array elements (OR logic).
|
|
1019
970
|
* @param element The element to check.
|
|
1020
971
|
* @param selector The selector to check against
|
|
1021
972
|
* @param templateData The data to use for replace in selector values
|
|
1022
973
|
* @returns True if the captured values match, false otherwise.
|
|
1023
974
|
*/
|
|
1024
975
|
private _isCapturedValuesMatch;
|
|
976
|
+
/**
|
|
977
|
+
* Determines if the parent captured values match the selector.
|
|
978
|
+
* @param parentSelector The parent selector to match.
|
|
979
|
+
* @param parentCaptured The captured values from first parent.
|
|
980
|
+
* @param templateData The data to use for replace in selector values
|
|
981
|
+
* @returns True if the captured values match, false otherwise.
|
|
982
|
+
*/
|
|
983
|
+
private _isParentCapturedValuesMatch;
|
|
984
|
+
/**
|
|
985
|
+
* Whether the given element first parent matches the selector parent.
|
|
986
|
+
* @param element The element to check.
|
|
987
|
+
* @param selector The selector to check against.
|
|
988
|
+
* @param templateData The data to use for replace in selector values
|
|
989
|
+
* @returns Whether the first parent matches the selector parent.
|
|
990
|
+
*/
|
|
991
|
+
private _isParentMatch;
|
|
1025
992
|
/**
|
|
1026
993
|
* Determines if the isIgnored property of the element matches that in the selector.
|
|
1027
994
|
* @param element The element to check.
|
|
@@ -1049,16 +1016,16 @@ declare class ElementsMatcher extends BaseElementsMatcher {
|
|
|
1049
1016
|
* It omits checks in keys applying only to dependency between elements, such as relationship.
|
|
1050
1017
|
* @param element The element to check.
|
|
1051
1018
|
* @param selector The selector to check against.
|
|
1052
|
-
* @param options Extra options for matching, such as templates data,
|
|
1019
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1053
1020
|
* @returns The selector matching result for the given element, or null if none matches.
|
|
1054
1021
|
*/
|
|
1055
|
-
getSelectorMatching(element: ElementDescription, selector: BaseElementsSelector, { extraTemplateData }?: MatcherOptions):
|
|
1022
|
+
getSelectorMatching(element: ElementDescription, selector: BaseElementsSelector, { extraTemplateData }?: MatcherOptions): BaseElementSelectorData | null;
|
|
1056
1023
|
/**
|
|
1057
1024
|
* Returns whether the given element matches the selector.
|
|
1058
1025
|
* It omits checks in keys applying only to dependency between elements, such as relationship.
|
|
1059
1026
|
* @param element The element to check.
|
|
1060
1027
|
* @param selector The selector to check against.
|
|
1061
|
-
* @param options Extra options for matching, such as templates data,
|
|
1028
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1062
1029
|
* @returns Whether the element matches the selector properties applying to elements.
|
|
1063
1030
|
*/
|
|
1064
1031
|
isElementMatch(element: ElementDescription, selector: BaseElementsSelector, options?: MatcherOptions): boolean;
|
|
@@ -1086,12 +1053,6 @@ declare class DependenciesMatcher extends BaseElementsMatcher {
|
|
|
1086
1053
|
* @returns The normalized dependency selector.
|
|
1087
1054
|
*/
|
|
1088
1055
|
private _normalizeDependencySelector;
|
|
1089
|
-
/**
|
|
1090
|
-
* Converts a DependencyElementSelectorData to a BaseElementSelectorData, by removing dependency-specific properties.
|
|
1091
|
-
* @param selector The dependency element selector data.
|
|
1092
|
-
* @returns The base element selector data.
|
|
1093
|
-
*/
|
|
1094
|
-
private _convertDependencyElementSelectorDataToBaseElementSelectorData;
|
|
1095
1056
|
/**
|
|
1096
1057
|
* Returns the selectors matching result for the given dependency.
|
|
1097
1058
|
* @param dependency The dependency description.
|
|
@@ -1099,14 +1060,22 @@ declare class DependenciesMatcher extends BaseElementsMatcher {
|
|
|
1099
1060
|
* @param extraTemplateData The extra template data for selector values.
|
|
1100
1061
|
* @returns The selectors matching result for the given dependency.
|
|
1101
1062
|
*/
|
|
1102
|
-
private
|
|
1063
|
+
private _getSelectorsMatching;
|
|
1103
1064
|
/**
|
|
1104
1065
|
* Determines if the dependency relationship matches the selector.
|
|
1105
1066
|
* @param dependency The dependency description.
|
|
1106
1067
|
* @param selector The data of an element selector.
|
|
1107
1068
|
* @returns Whether the dependency relationship matches the selector.
|
|
1108
1069
|
*/
|
|
1109
|
-
private
|
|
1070
|
+
private _relationshipFromMatches;
|
|
1071
|
+
/**
|
|
1072
|
+
* Determines if the dependency origin relationship matches the selector.
|
|
1073
|
+
* @param selector The dependency selector data.
|
|
1074
|
+
* @param relationship The relationship from origin element to target element.
|
|
1075
|
+
* @param templateData The template data for rendering selector values.
|
|
1076
|
+
* @returns Whether the dependency origin relationship matches.
|
|
1077
|
+
*/
|
|
1078
|
+
private _relationshipToMatches;
|
|
1110
1079
|
/**
|
|
1111
1080
|
* Determines if the selector matches an specific kind
|
|
1112
1081
|
* @param selector The dependency selector data
|
|
@@ -1132,34 +1101,42 @@ declare class DependenciesMatcher extends BaseElementsMatcher {
|
|
|
1132
1101
|
*/
|
|
1133
1102
|
private _nodeKindMatches;
|
|
1134
1103
|
/**
|
|
1135
|
-
* Determines if the dependency description matches the selector for '
|
|
1104
|
+
* Determines if the dependency description matches the selector for 'to'.
|
|
1136
1105
|
* @param dependency The dependency description.
|
|
1137
|
-
* @param
|
|
1106
|
+
* @param toSelector The selector for 'to' elements.
|
|
1138
1107
|
* @param templateData The template data for rendering selector values
|
|
1139
|
-
* @returns Whether the dependency properties match the selector for '
|
|
1108
|
+
* @returns Whether the dependency properties match the selector for 'to'.
|
|
1140
1109
|
*/
|
|
1141
|
-
private
|
|
1110
|
+
private _sourceMatches;
|
|
1142
1111
|
/**
|
|
1143
|
-
* Determines if the
|
|
1112
|
+
* Determines if the selector matches the module
|
|
1113
|
+
* @param selector The dependency selector data
|
|
1114
|
+
* @param module The module to check
|
|
1115
|
+
* @param templateData The template data for rendering selector values
|
|
1116
|
+
* @returns Whether the selector matches the module
|
|
1117
|
+
*/
|
|
1118
|
+
private _moduleMatches;
|
|
1119
|
+
/**
|
|
1120
|
+
* Determines if the dependency description matches the selector for dependency metadata.
|
|
1144
1121
|
* @param dependency The dependency description.
|
|
1145
|
-
* @param
|
|
1122
|
+
* @param selectorData The selector for dependency metadata.
|
|
1146
1123
|
* @param templateData The template data for rendering selector values
|
|
1147
|
-
* @returns Whether the dependency properties match the selector
|
|
1124
|
+
* @returns Whether the dependency properties match the selector.
|
|
1148
1125
|
*/
|
|
1149
|
-
private
|
|
1126
|
+
private _dependencyPropertiesMatch;
|
|
1150
1127
|
/**
|
|
1151
1128
|
* Returns the selectors matching result for the given dependency.
|
|
1152
1129
|
* @param dependency The dependency to check.
|
|
1153
1130
|
* @param selector The selector to check against.
|
|
1154
|
-
* @param options Extra options for matching, such as templates data,
|
|
1131
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1155
1132
|
* @returns The matching result for the dependency against the selector.
|
|
1156
1133
|
*/
|
|
1157
|
-
getSelectorsMatching(dependency: DependencyDescription, selector: DependencySelector, { extraTemplateData
|
|
1134
|
+
getSelectorsMatching(dependency: DependencyDescription, selector: DependencySelector, { extraTemplateData }?: MatcherOptions): DependencyMatchResult;
|
|
1158
1135
|
/**
|
|
1159
1136
|
* Returns whether the given dependency matches the selector.
|
|
1160
1137
|
* @param dependency The dependency to check.
|
|
1161
1138
|
* @param selector The selector to check against.
|
|
1162
|
-
* @param options Extra options for matching, such as templates data,
|
|
1139
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1163
1140
|
* @returns Whether the dependency matches the selector properties.
|
|
1164
1141
|
*/
|
|
1165
1142
|
isDependencyMatch(dependency: DependencyDescription, selector: DependencySelector, options?: MatcherOptions): boolean;
|
|
@@ -1182,13 +1159,13 @@ declare function isSimpleElementSelectorByType(value: unknown): value is SimpleE
|
|
|
1182
1159
|
* @param value The value to check.
|
|
1183
1160
|
* @returns True if the selector is a base element selector
|
|
1184
1161
|
*/
|
|
1185
|
-
declare function isBaseElementSelectorData(value: unknown): value is
|
|
1162
|
+
declare function isBaseElementSelectorData(value: unknown): value is BaseElementSelectorData;
|
|
1186
1163
|
/**
|
|
1187
1164
|
* Determines if the given selector is an element or dependency element selector data.
|
|
1188
1165
|
* @param value The value to check.
|
|
1189
1166
|
* @returns True if the selector is an element or dependency element selector data, false otherwise.
|
|
1190
1167
|
*/
|
|
1191
|
-
declare function isElementSelectorData(value: unknown): value is
|
|
1168
|
+
declare function isElementSelectorData(value: unknown): value is BaseElementSelectorData;
|
|
1192
1169
|
/**
|
|
1193
1170
|
* Determines if the given selector is an element selector with options.
|
|
1194
1171
|
* @param value The value to check.
|
|
@@ -1208,51 +1185,35 @@ declare function isElementSelector(value: unknown): value is ElementSelector;
|
|
|
1208
1185
|
*/
|
|
1209
1186
|
declare function isElementsSelector(value: unknown): value is ElementSelectors;
|
|
1210
1187
|
/**
|
|
1211
|
-
*
|
|
1212
|
-
* @param
|
|
1213
|
-
* @returns
|
|
1214
|
-
*/
|
|
1215
|
-
declare function isDependencySelector(value: unknown): value is DependencySelector;
|
|
1216
|
-
/**
|
|
1217
|
-
* Determines if the given value is external library selector options with a path.
|
|
1218
|
-
* @param value The value to check.
|
|
1219
|
-
* @returns True if the value is external library selector options with a path, false otherwise.
|
|
1220
|
-
*/
|
|
1221
|
-
declare function isExternalLibrarySelectorOptionsWithPath(value: unknown): value is ExternalLibrarySelectorOptions & {
|
|
1222
|
-
path: string | string[];
|
|
1223
|
-
};
|
|
1224
|
-
/**
|
|
1225
|
-
* Determines if the given value is external library selector options with specifiers.
|
|
1226
|
-
* @param value The value to check.
|
|
1227
|
-
* @returns True if the value is external library selector options with specifiers, false otherwise.
|
|
1188
|
+
* Normalizes a selector into ElementSelectorData format.
|
|
1189
|
+
* @param selector The selector to normalize.
|
|
1190
|
+
* @returns The normalized selector data.
|
|
1228
1191
|
*/
|
|
1229
|
-
declare function
|
|
1230
|
-
specifiers: string[];
|
|
1231
|
-
};
|
|
1192
|
+
declare function normalizeElementSelector(selector: BaseElementSelector): BaseElementSelectorData;
|
|
1232
1193
|
/**
|
|
1233
|
-
*
|
|
1234
|
-
* @param
|
|
1235
|
-
* @returns
|
|
1194
|
+
* Normalizes an ElementsSelector into an array of ElementSelectorData.
|
|
1195
|
+
* @param elementsSelector The elements selector, in any supported format.
|
|
1196
|
+
* @returns The normalized array of selector data.
|
|
1236
1197
|
*/
|
|
1237
|
-
declare function
|
|
1198
|
+
declare function normalizeElementsSelector(elementsSelector: BaseElementsSelector): BaseElementSelectorData[];
|
|
1238
1199
|
/**
|
|
1239
|
-
* Determines if the given value is
|
|
1240
|
-
* @param value The value to check
|
|
1241
|
-
* @returns True if the value is
|
|
1200
|
+
* Determines if the given value is a dependency selector.
|
|
1201
|
+
* @param value The value to check
|
|
1202
|
+
* @returns True if the value is a dependency selector, false otherwise.
|
|
1242
1203
|
*/
|
|
1243
|
-
declare function
|
|
1204
|
+
declare function isDependencySelector(value: unknown): value is DependencySelector;
|
|
1244
1205
|
/**
|
|
1245
|
-
* Determines if the given value is
|
|
1206
|
+
* Determines if the given value is dependency metadata selector data.
|
|
1246
1207
|
* @param value The value to check.
|
|
1247
|
-
* @returns True if the value is
|
|
1208
|
+
* @returns True if the value is dependency metadata selector data, false otherwise.
|
|
1248
1209
|
*/
|
|
1249
|
-
declare function
|
|
1210
|
+
declare function isDependencyDataSelectorData(value: unknown): value is DependencyDataSelectorData;
|
|
1250
1211
|
/**
|
|
1251
|
-
* Determines if the given value is
|
|
1212
|
+
* Determines if the given value is dependency metadata selector(s).
|
|
1252
1213
|
* @param value The value to check.
|
|
1253
|
-
* @returns True if the value is
|
|
1214
|
+
* @returns True if the value is dependency metadata selector(s), false otherwise.
|
|
1254
1215
|
*/
|
|
1255
|
-
declare function
|
|
1216
|
+
declare function isDependencyDataSelector(value: unknown): value is DependencyDataSelector;
|
|
1256
1217
|
|
|
1257
1218
|
/**
|
|
1258
1219
|
* Matcher class to evaluate if elements or dependencies match given selectors.
|
|
@@ -1270,6 +1231,18 @@ declare class Matcher {
|
|
|
1270
1231
|
* @param globalCache Global cache instance.
|
|
1271
1232
|
*/
|
|
1272
1233
|
constructor(descriptors: ElementDescriptors, elementsMatcher: ElementsMatcher, dependenciesMatcher: DependenciesMatcher, config: DescriptorOptionsNormalized, micromatch: Micromatch);
|
|
1234
|
+
/**
|
|
1235
|
+
* Describes an element given its file path.
|
|
1236
|
+
* @param filePath The path of the file to describe.
|
|
1237
|
+
* @returns The description of the element.
|
|
1238
|
+
*/
|
|
1239
|
+
describeElement(filePath: string): ElementDescription;
|
|
1240
|
+
/**
|
|
1241
|
+
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
1242
|
+
* @param options The options for describing the elements and the dependency details.
|
|
1243
|
+
* @returns The description of the dependency between the elements.
|
|
1244
|
+
*/
|
|
1245
|
+
describeDependency(options: DescribeDependencyOptions): DependencyDescription;
|
|
1273
1246
|
/**
|
|
1274
1247
|
* Determines if an element matches a given selector.
|
|
1275
1248
|
* @param filePath The file path of the element
|
|
@@ -1277,7 +1250,7 @@ declare class Matcher {
|
|
|
1277
1250
|
* @param options Extra matcher options
|
|
1278
1251
|
* @returns True if the element matches the selector, false otherwise
|
|
1279
1252
|
*/
|
|
1280
|
-
|
|
1253
|
+
isElementMatch(filePath: string, selector: ElementsSelector, options?: MatcherOptions): boolean;
|
|
1281
1254
|
/**
|
|
1282
1255
|
* Determines if a dependency matches a given selector.
|
|
1283
1256
|
* @param dependencyData The data describing the dependency
|
|
@@ -1285,15 +1258,7 @@ declare class Matcher {
|
|
|
1285
1258
|
* @param options Extra matcher options
|
|
1286
1259
|
* @returns True if the dependency matches the selector, false otherwise
|
|
1287
1260
|
*/
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Determines if the given element or dependency matches the provided selector.
|
|
1291
|
-
* @param descriptorOptions The file path or dependency options to describe the element or dependency
|
|
1292
|
-
* @param selector The selector to match against
|
|
1293
|
-
* @param options Extra matcher options
|
|
1294
|
-
*/
|
|
1295
|
-
isMatch(descriptorOptions: string, selector: ElementsSelector, options?: MatcherOptions): boolean;
|
|
1296
|
-
isMatch(descriptorOptions: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): boolean;
|
|
1261
|
+
isDependencyMatch(dependencyData: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): boolean;
|
|
1297
1262
|
/**
|
|
1298
1263
|
* Determines the selector matching for an element.
|
|
1299
1264
|
* @param filePath The file path of the element
|
|
@@ -1301,7 +1266,7 @@ declare class Matcher {
|
|
|
1301
1266
|
* @param options Extra options for matching
|
|
1302
1267
|
* @returns The matching selector data or null if no match is found
|
|
1303
1268
|
*/
|
|
1304
|
-
|
|
1269
|
+
getElementSelectorMatching(filePath: string, selector: ElementsSelector, options?: MatcherOptions): BaseElementSelectorData | null;
|
|
1305
1270
|
/**
|
|
1306
1271
|
* Determines the selector matching for a dependency.
|
|
1307
1272
|
* @param dependencyData The data describing the dependency
|
|
@@ -1309,44 +1274,23 @@ declare class Matcher {
|
|
|
1309
1274
|
* @param options Extra options for matching
|
|
1310
1275
|
* @returns The matching dependency result or null if no match is found
|
|
1311
1276
|
*/
|
|
1312
|
-
|
|
1313
|
-
/**
|
|
1314
|
-
* Determines the selector matching for a dependency or element.
|
|
1315
|
-
* @param descriptorOptions The file path or dependency options to describe the element or dependency
|
|
1316
|
-
* @param selector The selectors to match against
|
|
1317
|
-
* @param options Extra options for matching
|
|
1318
|
-
* @returns The matching dependency result or element selector data, or null if no match is found
|
|
1319
|
-
*/
|
|
1320
|
-
getSelectorMatching(descriptorOptions: string, selector: ElementsSelector, options?: MatcherOptions): ElementSelectorData | null;
|
|
1321
|
-
getSelectorMatching(descriptorOptions: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): DependencyMatchResult | null;
|
|
1277
|
+
getDependencySelectorMatching(dependencyData: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): DependencyMatchResult;
|
|
1322
1278
|
/**
|
|
1323
1279
|
* Returns the selectors matching result for the given element or dependency description.
|
|
1324
1280
|
* @param description The element or dependency description to check.
|
|
1325
1281
|
* @param selector The selector to check against.
|
|
1326
|
-
* @param options Extra options for matching, such as templates data,
|
|
1282
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1327
1283
|
* @returns The selectors matching result for the given description, and whether it matches or not.
|
|
1328
1284
|
*/
|
|
1329
|
-
|
|
1330
|
-
getSelectorMatchingDescription(description: ElementDescription, selector: ElementsSelector, options?: MatcherOptions): ElementSelectorData;
|
|
1285
|
+
getDependencySelectorMatchingDescription(description: DependencyDescription, selector: DependencySelector, options?: MatcherOptions): DependencyMatchResult;
|
|
1331
1286
|
/**
|
|
1332
|
-
*
|
|
1333
|
-
* @param
|
|
1334
|
-
* @
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
/**
|
|
1338
|
-
* Describes a dependency element given its dependency source and file path.
|
|
1339
|
-
* @param dependencySource The source of the dependency.
|
|
1340
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
1341
|
-
* @returns The description of the dependency element.
|
|
1342
|
-
*/
|
|
1343
|
-
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
1344
|
-
/**
|
|
1345
|
-
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
1346
|
-
* @param options The options for describing the elements and the dependency details.
|
|
1347
|
-
* @returns The description of the dependency between the elements.
|
|
1287
|
+
* Returns the first element selector matching result for the given element description.
|
|
1288
|
+
* @param description The element description to check.
|
|
1289
|
+
* @param selector The selector to check against.
|
|
1290
|
+
* @param options Extra options for matching, such as templates data, etc.
|
|
1291
|
+
* @returns The first matching selector result for the given description, or null if no match is found.
|
|
1348
1292
|
*/
|
|
1349
|
-
|
|
1293
|
+
getElementSelectorMatchingDescription(description: ElementDescription, selector: ElementsSelector, options?: MatcherOptions): BaseElementSelectorData | null;
|
|
1350
1294
|
/**
|
|
1351
1295
|
* Clears all caches.
|
|
1352
1296
|
*/
|
|
@@ -1396,14 +1340,7 @@ declare class Descriptors {
|
|
|
1396
1340
|
* @param filePath The path of the file to describe.
|
|
1397
1341
|
* @returns The description of the element.
|
|
1398
1342
|
*/
|
|
1399
|
-
describeElement(filePath?: string):
|
|
1400
|
-
/**
|
|
1401
|
-
* Describes a dependency element given its dependency source and file path.
|
|
1402
|
-
* @param dependencySource The source of the dependency.
|
|
1403
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
1404
|
-
* @returns The description of the dependency element.
|
|
1405
|
-
*/
|
|
1406
|
-
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
1343
|
+
describeElement(filePath?: string): ElementDescription;
|
|
1407
1344
|
/**
|
|
1408
1345
|
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
1409
1346
|
* @param options The options for describing the elements and the dependency details.
|
|
@@ -1543,15 +1480,38 @@ declare class ElementsDescriptor {
|
|
|
1543
1480
|
* @param dependencySource The source of the dependency to check.
|
|
1544
1481
|
* @returns The base source of the external module. (e.g., for "@scope/package/submodule", it returns "@scope/package")
|
|
1545
1482
|
*/
|
|
1546
|
-
private
|
|
1483
|
+
private _getExternalOrCoreModuleModule;
|
|
1484
|
+
/**
|
|
1485
|
+
* Determines if a file path is outside the configured root path.
|
|
1486
|
+
* @param filePath The file path to check.
|
|
1487
|
+
* @returns True if the file path is outside the root path, false otherwise.
|
|
1488
|
+
*/
|
|
1489
|
+
private _isOutsideRootPath;
|
|
1490
|
+
/**
|
|
1491
|
+
* Converts an absolute file path to a relative path if rootPath is configured.
|
|
1492
|
+
* If rootPath is not configured, returns the path as-is (maintains backward compatibility).
|
|
1493
|
+
* @param filePath The file path to convert (can be absolute or relative)
|
|
1494
|
+
* @returns The relative path if rootPath is configured and path is absolute, otherwise the original path
|
|
1495
|
+
*/
|
|
1496
|
+
private _toRelativePath;
|
|
1497
|
+
/**
|
|
1498
|
+
* Checks if a source string matches any of the provided patterns using micromatch.
|
|
1499
|
+
* @param patterns - Array of micromatch patterns
|
|
1500
|
+
* @param source - The source string to match against patterns
|
|
1501
|
+
* @returns True if the source matches any pattern, false otherwise
|
|
1502
|
+
*/
|
|
1503
|
+
private _matchesAnyPattern;
|
|
1547
1504
|
/**
|
|
1548
1505
|
* Determines if an element is external based on its file path and dependency source.
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
* @
|
|
1506
|
+
* Uses the flagAsExternal configuration to evaluate multiple conditions with OR logic:
|
|
1507
|
+
* - unresolvableAlias: Files whose path cannot be resolved (filePath is null)
|
|
1508
|
+
* - inNodeModules: Non-relative paths that include "node_modules"
|
|
1509
|
+
* - outsideRootPath: Resolved path is outside the configured root path (only if rootPath is configured)
|
|
1510
|
+
* - customSourcePatterns: Source matches any of the configured patterns
|
|
1511
|
+
* @param filePath The resolved file path (null if unresolved). Can be absolute if rootPath is configured, or relative if rootPath is not configured.
|
|
1512
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1513
|
+
* @param dependencySource The import/export source string
|
|
1514
|
+
* @returns True if any of the configured conditions is met, false otherwise
|
|
1555
1515
|
*/
|
|
1556
1516
|
private _isExternalDependency;
|
|
1557
1517
|
/**
|
|
@@ -1599,30 +1559,31 @@ declare class ElementsDescriptor {
|
|
|
1599
1559
|
/**
|
|
1600
1560
|
* Returns an external or core dependency element given its dependency source and file path.
|
|
1601
1561
|
* @param dependencySource The source of the dependency.
|
|
1602
|
-
* @param
|
|
1562
|
+
* @param isOutsideRootPath Whether the file path is outside the configured root path.
|
|
1563
|
+
* @param filePath The resolved file path of the dependency, if known. Can be absolute if rootPath is configured.
|
|
1603
1564
|
* @returns The external or core dependency element, or null if it is a local dependency.
|
|
1604
1565
|
*/
|
|
1605
1566
|
private _getExternalOrCoreDependencyElement;
|
|
1606
1567
|
/**
|
|
1607
1568
|
* Describes an element given its file path and dependency source, if any.
|
|
1608
|
-
* @param filePath The path of the file to describe.
|
|
1569
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1609
1570
|
* @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.
|
|
1610
1571
|
* @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.
|
|
1611
1572
|
*/
|
|
1612
1573
|
private _describeElement;
|
|
1613
1574
|
/**
|
|
1614
1575
|
* Describes an element given its file path.
|
|
1615
|
-
* @param filePath The path of the file to describe.
|
|
1576
|
+
* @param filePath The path of the file to describe. Can be absolute if rootPath is configured, or relative if not.
|
|
1616
1577
|
* @returns The description of the element.
|
|
1617
1578
|
*/
|
|
1618
|
-
describeElement(filePath?: string):
|
|
1579
|
+
describeElement(filePath?: string): ElementDescription;
|
|
1619
1580
|
/**
|
|
1620
|
-
* Describes a dependency element given
|
|
1581
|
+
* Describes a dependency target element given dependency source and target file path.
|
|
1582
|
+
* @param filePath The path of the dependency target file, if known. Can be absolute if rootPath is configured, or relative if not.
|
|
1621
1583
|
* @param dependencySource The source of the dependency.
|
|
1622
|
-
* @param filePath The path of the file being the dependency, if known.
|
|
1623
1584
|
* @returns The description of the dependency element.
|
|
1624
1585
|
*/
|
|
1625
|
-
|
|
1586
|
+
describeElement(filePath: string | undefined, dependencySource: string): ElementDescriptionWithSource;
|
|
1626
1587
|
}
|
|
1627
1588
|
|
|
1628
1589
|
/**
|
|
@@ -1791,4 +1752,4 @@ declare class CacheManager<CacheKey extends NotUndefined, CachedValue> {
|
|
|
1791
1752
|
setFromSerialized(serializedCache: Record<string, CachedValue>): void;
|
|
1792
1753
|
}
|
|
1793
1754
|
|
|
1794
|
-
export { type
|
|
1755
|
+
export { type BaseElementDescription, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreElementDescription, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_TYPEOF, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDataSelector, type DependencyDataSelectorData, type DependencyDescription, type DependencyElementSelectorData, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, type DescriptionsSerializedCache, type DescriptorOptionsNormalized, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptionWithSource, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalElementDescription, type FileElementsSerializedCache, type FlagAsExternalOptions, type FlagAsExternalOptionsNormalized, type IgnoredElement, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherSerializedCache, type MatchersOptionsNormalized, type MicromatchPattern, type MicromatchPatternNullable, type MicromatchSerializedCache, type NotUndefined, type ObjectCacheKey, type ParentElementSelectorData, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDataSelector, isDependencyDataSelectorData, isDependencyDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementSelector, normalizeElementsSelector };
|