@boundaries/elements 1.0.0
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/LICENSE +21 -0
- package/README.md +568 -0
- package/dist/index.browser.d.mts +1701 -0
- package/dist/index.browser.d.ts +1701 -0
- package/dist/index.browser.js +2279 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.browser.mjs +2253 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.d.mts +1701 -0
- package/dist/index.d.ts +1701 -0
- package/dist/index.js +2328 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2253 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,1701 @@
|
|
|
1
|
+
import { NotUndefined } from 'object-hash';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type representing a micromatch pattern, which can be a string or an array of strings.
|
|
5
|
+
*/
|
|
6
|
+
type MicromatchPattern = string | string[];
|
|
7
|
+
/** Configuration options for the Config class */
|
|
8
|
+
type ConfigOptions = {
|
|
9
|
+
/** An array of path patterns to include when resolving elements. Defaults to all files if not specified */
|
|
10
|
+
includePaths?: MicromatchPattern;
|
|
11
|
+
/** An array of path patterns to ignore when resolving elements */
|
|
12
|
+
ignorePaths?: MicromatchPattern;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to enable legacy template support (default: true)
|
|
15
|
+
* When enabled, it supports using "${...}" syntax in templates.
|
|
16
|
+
**/
|
|
17
|
+
legacyTemplates?: boolean;
|
|
18
|
+
};
|
|
19
|
+
type ConfigOptionsNormalized = Omit<ConfigOptions, "legacyTemplates"> & {
|
|
20
|
+
/** Whether to enable legacy template support */
|
|
21
|
+
legacyTemplates: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Map of the modes to interpret the pattern in an ElementDescriptor.
|
|
26
|
+
*/
|
|
27
|
+
declare const ELEMENT_DESCRIPTOR_MODES_MAP: {
|
|
28
|
+
/** Mode to interpret the pattern as a folder */
|
|
29
|
+
readonly FOLDER: "folder";
|
|
30
|
+
/** Mode to interpret the pattern as a file */
|
|
31
|
+
readonly FILE: "file";
|
|
32
|
+
/** Mode to interpret the pattern as a full path */
|
|
33
|
+
readonly FULL: "full";
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Mode to interpret the pattern in an ElementDescriptor.
|
|
37
|
+
*/
|
|
38
|
+
type ElementDescriptorMode = (typeof ELEMENT_DESCRIPTOR_MODES_MAP)[keyof typeof ELEMENT_DESCRIPTOR_MODES_MAP];
|
|
39
|
+
/**
|
|
40
|
+
* Pattern(s) to match files for an element descriptor.
|
|
41
|
+
*/
|
|
42
|
+
type ElementDescriptorPattern = string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* Descriptor for an element (or layer) in the project.
|
|
45
|
+
* Defines the type of the element, the pattern to match files, and optional settings like mode and capture groups.
|
|
46
|
+
*/
|
|
47
|
+
type BaseElementDescriptor = {
|
|
48
|
+
/** Micromatch pattern(s) to match files belonging to this element. */
|
|
49
|
+
pattern: ElementDescriptorPattern;
|
|
50
|
+
/**
|
|
51
|
+
* 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]).
|
|
52
|
+
* 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
|
|
53
|
+
**/
|
|
54
|
+
basePattern?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Mode to interpret the pattern. Can be "folder" (default), "file", or "full".
|
|
57
|
+
* - "folder": Default value. the element type will be assigned to the first file's parent folder matching the pattern.
|
|
58
|
+
* 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.
|
|
59
|
+
* - "file": The given pattern will not be modified, but the plugin will still try to match the last part of the path.
|
|
60
|
+
* 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.
|
|
61
|
+
* - "full": The given pattern will only match with patterns matching the full path.
|
|
62
|
+
* This means that you will have to provide patterns matching from the base project path.
|
|
63
|
+
* 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)
|
|
64
|
+
*/
|
|
65
|
+
mode?: ElementDescriptorMode;
|
|
66
|
+
/**
|
|
67
|
+
* It allows to capture values of some fragments in the matching path to use them later in the rules configuration.
|
|
68
|
+
* Must be an array of strings representing the names of the capture groups in the pattern.
|
|
69
|
+
* The number of capture names must be equal to the number of capturing groups in the pattern.
|
|
70
|
+
* For example, if the pattern is "src/modules/(* *)/(* *).service.js" the capture could be ["module", "service"].
|
|
71
|
+
* Then, in the rules configuration, you could use ["service", { module: "auth" }] to match only services from the auth module.
|
|
72
|
+
*/
|
|
73
|
+
capture?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Like capture, but for the basePattern.
|
|
76
|
+
* This allows to capture values from the left side of the path, which is useful when using the basePattern option.
|
|
77
|
+
* 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.
|
|
78
|
+
*/
|
|
79
|
+
baseCapture?: string[];
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Element descriptor with a type.
|
|
83
|
+
*/
|
|
84
|
+
type ElementDescriptorWithType = BaseElementDescriptor & {
|
|
85
|
+
/** Type of the element (e.g., "service", "component", "util"). */
|
|
86
|
+
type: string;
|
|
87
|
+
/** Category of the element */
|
|
88
|
+
category?: never;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Element descriptor with a category.
|
|
92
|
+
*/
|
|
93
|
+
type ElementDescriptorWithCategory = BaseElementDescriptor & {
|
|
94
|
+
/** Category of the element (e.g., "domain", "infrastructure", "application"). */
|
|
95
|
+
category: string;
|
|
96
|
+
/** Type of the element*/
|
|
97
|
+
type?: never;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Element descriptor with both type and category.
|
|
101
|
+
*/
|
|
102
|
+
type ElementDescriptorWithTypeAndCategory = BaseElementDescriptor & {
|
|
103
|
+
/** Type of the element (e.g., "service", "component", "util"). */
|
|
104
|
+
type: string;
|
|
105
|
+
/** Category of the element (e.g., "domain", "infrastructure", "application"). */
|
|
106
|
+
category: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Element descriptor, which can be defined by type, category, or both.
|
|
110
|
+
*/
|
|
111
|
+
type ElementDescriptor = ElementDescriptorWithType | ElementDescriptorWithCategory | ElementDescriptorWithTypeAndCategory;
|
|
112
|
+
/**
|
|
113
|
+
* Array of element descriptors.
|
|
114
|
+
*/
|
|
115
|
+
type ElementDescriptors = ElementDescriptor[];
|
|
116
|
+
/**
|
|
117
|
+
* Serialized cache of element descriptions.
|
|
118
|
+
*/
|
|
119
|
+
type ElementsDescriptorSerializedCache = Record<string, ElementDescription>;
|
|
120
|
+
/**
|
|
121
|
+
* Captured values from an element path.
|
|
122
|
+
*/
|
|
123
|
+
type CapturedValues = Record<string, string>;
|
|
124
|
+
/**
|
|
125
|
+
* Origins of an element
|
|
126
|
+
*/
|
|
127
|
+
declare const ELEMENT_ORIGINS_MAP: {
|
|
128
|
+
/** Origin of local elements (files) */
|
|
129
|
+
readonly LOCAL: "local";
|
|
130
|
+
/** Origin of external elements (libraries) */
|
|
131
|
+
readonly EXTERNAL: "external";
|
|
132
|
+
/** Origin of core elements */
|
|
133
|
+
readonly CORE: "core";
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Kind of element origin, either local, external, or core.
|
|
137
|
+
*/
|
|
138
|
+
type ElementOrigin = (typeof ELEMENT_ORIGINS_MAP)[keyof typeof ELEMENT_ORIGINS_MAP];
|
|
139
|
+
/**
|
|
140
|
+
* Base element properties related to captured values
|
|
141
|
+
*/
|
|
142
|
+
type BaseElement = {
|
|
143
|
+
/** Absolute path of the file. It might be null when a dependency path can't be resolved */
|
|
144
|
+
path: string | null;
|
|
145
|
+
/** Path of the file relative to the element, or null if the element is ignored or unknown */
|
|
146
|
+
elementPath: string | null;
|
|
147
|
+
/** Internal path of the file relative to the elementPath, or null if the element is ignored or unknown */
|
|
148
|
+
internalPath: string | null;
|
|
149
|
+
/** Source of the element when it is a dependency, or null if the element is not a dependency, or it is ignored or unknown */
|
|
150
|
+
source: string | null;
|
|
151
|
+
/** Base source of the element when it is an external or core dependency, null otherwise */
|
|
152
|
+
baseSource: string | null;
|
|
153
|
+
/** Type of the element, or null if the element is ignored or unknown */
|
|
154
|
+
type: string | null;
|
|
155
|
+
/** Category of the element, or null if the element is ignored or unknown */
|
|
156
|
+
category: string | null;
|
|
157
|
+
/** Captured values from the element, or null if the element descriptor has no capture or the element is ignored or unknown */
|
|
158
|
+
captured: CapturedValues | null;
|
|
159
|
+
/** Parent elements, or null if the element is ignored, unknown, or it is not a local element */
|
|
160
|
+
parents: ElementParent[] | null;
|
|
161
|
+
/** Origin of the element, or null if the element is ignored */
|
|
162
|
+
origin: ElementOrigin | null;
|
|
163
|
+
/** Indicates if the element is ignored by settings. If true, the element will be excluded from processing any other properties. */
|
|
164
|
+
isIgnored: boolean;
|
|
165
|
+
/** Indicates if the element is unknown, which means that it cannot be resolved to any descriptor */
|
|
166
|
+
isUnknown: boolean;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Parent elements
|
|
170
|
+
*/
|
|
171
|
+
type ElementParent = {
|
|
172
|
+
/** Type of the parent element */
|
|
173
|
+
type: string | null;
|
|
174
|
+
/** Category of the parent element */
|
|
175
|
+
category: string | null;
|
|
176
|
+
/** Path of the element relative to the project */
|
|
177
|
+
elementPath: string;
|
|
178
|
+
/** Captured values from the parent element */
|
|
179
|
+
captured: CapturedValues | null;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Description of an ignored element
|
|
183
|
+
*/
|
|
184
|
+
type IgnoredElement = BaseElement & {
|
|
185
|
+
/** Type of the element */
|
|
186
|
+
type: null;
|
|
187
|
+
/** Category of the element */
|
|
188
|
+
category: null;
|
|
189
|
+
/** Ignored elements have not captured values */
|
|
190
|
+
captured: null;
|
|
191
|
+
/** Origin of the element */
|
|
192
|
+
origin: null;
|
|
193
|
+
/** Indicates if the file is ignored */
|
|
194
|
+
isIgnored: true;
|
|
195
|
+
/** Indicates that the element is unknown */
|
|
196
|
+
isUnknown: true;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Description of an unknown local element
|
|
200
|
+
*/
|
|
201
|
+
type LocalElementUnknown = BaseElement & {
|
|
202
|
+
/** Type of the element */
|
|
203
|
+
type: null;
|
|
204
|
+
/** Category of the element */
|
|
205
|
+
category: null;
|
|
206
|
+
/** Unknown elements have not captured values */
|
|
207
|
+
captured: null;
|
|
208
|
+
/** Indicates that the element is local */
|
|
209
|
+
origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;
|
|
210
|
+
/** Indicates that the file is not ignored */
|
|
211
|
+
isIgnored: false;
|
|
212
|
+
/** Indicates that the element is unknown */
|
|
213
|
+
isUnknown: true;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Description of a local element (file)
|
|
217
|
+
*/
|
|
218
|
+
type LocalElementKnown = BaseElement & {
|
|
219
|
+
/** Path of the element */
|
|
220
|
+
path: string;
|
|
221
|
+
/** Captured values from the parent element */
|
|
222
|
+
captured: CapturedValues | null;
|
|
223
|
+
/** Path of the file relative to the element */
|
|
224
|
+
elementPath: string;
|
|
225
|
+
/** Internal path of the file relative to the elementPath */
|
|
226
|
+
internalPath: string;
|
|
227
|
+
/** Parent elements */
|
|
228
|
+
parents: ElementParent[];
|
|
229
|
+
/** Indicates that the element is local */
|
|
230
|
+
origin: typeof ELEMENT_ORIGINS_MAP.LOCAL;
|
|
231
|
+
/** Indicates that the file is not ignored */
|
|
232
|
+
isIgnored: false;
|
|
233
|
+
/** Indicates that the element is known */
|
|
234
|
+
isUnknown: false;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Base description of a dependency
|
|
238
|
+
*/
|
|
239
|
+
type BaseDependencyElement = BaseElement & {
|
|
240
|
+
/** Dependency source */
|
|
241
|
+
source: string;
|
|
242
|
+
/** Indicates that dependencies are not ignored */
|
|
243
|
+
isIgnored: false;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Description of a local dependency (known)
|
|
247
|
+
*/
|
|
248
|
+
type LocalDependencyElementKnown = LocalElementKnown & BaseDependencyElement;
|
|
249
|
+
/**
|
|
250
|
+
* Description of a local dependency (unknown)
|
|
251
|
+
*/
|
|
252
|
+
type LocalDependencyElementUnknown = LocalElementUnknown & BaseDependencyElement;
|
|
253
|
+
/**
|
|
254
|
+
* Description of a local dependency
|
|
255
|
+
*/
|
|
256
|
+
type LocalDependencyElement = LocalDependencyElementKnown | LocalDependencyElementUnknown;
|
|
257
|
+
/**
|
|
258
|
+
* Description of an external dependency
|
|
259
|
+
*/
|
|
260
|
+
type ExternalDependencyElement = BaseDependencyElement & {
|
|
261
|
+
/** Path of the dependency relative to the base module */
|
|
262
|
+
internalPath: string;
|
|
263
|
+
/** Base module of the external dependency */
|
|
264
|
+
baseSource: string;
|
|
265
|
+
/** Indicates that the dependency is external */
|
|
266
|
+
origin: typeof ELEMENT_ORIGINS_MAP.EXTERNAL;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Description of a core dependency
|
|
270
|
+
*/
|
|
271
|
+
type CoreDependencyElement = BaseDependencyElement & {
|
|
272
|
+
/** Base module of the core dependency */
|
|
273
|
+
baseSource: string;
|
|
274
|
+
/** Indicates that the dependency is core */
|
|
275
|
+
origin: typeof ELEMENT_ORIGINS_MAP.CORE;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Description of an ignored dependency element
|
|
279
|
+
*/
|
|
280
|
+
type IgnoredDependencyElement = IgnoredElement & {
|
|
281
|
+
/** The source of the dependency */
|
|
282
|
+
source: string;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Description of a file
|
|
286
|
+
*/
|
|
287
|
+
type FileElement = IgnoredElement | LocalElementKnown | LocalElementUnknown;
|
|
288
|
+
/**
|
|
289
|
+
* Description of a dependency
|
|
290
|
+
*/
|
|
291
|
+
type DependencyElementDescription = IgnoredDependencyElement | CoreDependencyElement | LocalDependencyElement | ExternalDependencyElement;
|
|
292
|
+
/**
|
|
293
|
+
* Description of an element, either local or dependency
|
|
294
|
+
*/
|
|
295
|
+
type ElementDescription = FileElement | DependencyElementDescription;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Determines if the given value is a valid element descriptor mode.
|
|
299
|
+
* @param value The value to check.
|
|
300
|
+
* @returns True if the value is a valid element descriptor mode, false otherwise.
|
|
301
|
+
*/
|
|
302
|
+
declare function isElementDescriptorMode(value: unknown): value is ElementDescriptorMode;
|
|
303
|
+
/**
|
|
304
|
+
* Determines if the given value is a valid element descriptor pattern.
|
|
305
|
+
* @param value The value to check.
|
|
306
|
+
* @returns True if the value is a valid element descriptor pattern, false otherwise.
|
|
307
|
+
*/
|
|
308
|
+
declare function isElementDescriptorPattern(value: unknown): value is ElementDescriptorPattern;
|
|
309
|
+
/**
|
|
310
|
+
* Determines if the given value is a base element descriptor.
|
|
311
|
+
* @param value The value to check.
|
|
312
|
+
* @returns True if the value is a base element descriptor, false otherwise.
|
|
313
|
+
*/
|
|
314
|
+
declare function isBaseElementDescriptor(value: unknown): value is BaseElementDescriptor;
|
|
315
|
+
/**
|
|
316
|
+
* Determines if the given value is an element descriptor with type.
|
|
317
|
+
* @param value The value to check.
|
|
318
|
+
* @returns True if the value is an element descriptor with type, false otherwise.
|
|
319
|
+
*/
|
|
320
|
+
declare function isElementDescriptorWithType(value: unknown): value is ElementDescriptorWithType;
|
|
321
|
+
/**
|
|
322
|
+
* Determines if the given value is an element descriptor with category.
|
|
323
|
+
* @param value The value to check.
|
|
324
|
+
* @returns True if the value is an element descriptor with category, false otherwise.
|
|
325
|
+
*/
|
|
326
|
+
declare function isElementDescriptorWithCategory(value: unknown): value is ElementDescriptorWithCategory;
|
|
327
|
+
/**
|
|
328
|
+
* Determines if the given value is an element descriptor.
|
|
329
|
+
* @param value The value to check.
|
|
330
|
+
* @returns True if the value is an element descriptor, false otherwise.
|
|
331
|
+
*/
|
|
332
|
+
declare function isElementDescriptor(value: unknown): value is ElementDescriptor;
|
|
333
|
+
/**
|
|
334
|
+
* Determines if the value is a BaseElement
|
|
335
|
+
* @param value The value to check
|
|
336
|
+
* @returns True if the value is a valid BaseElement, false otherwise
|
|
337
|
+
*/
|
|
338
|
+
declare function isBaseElement(value: unknown): value is BaseElement;
|
|
339
|
+
/**
|
|
340
|
+
* Determines if the given value is an ignored element.
|
|
341
|
+
* @param value The element to check.
|
|
342
|
+
* @returns True if the element is an ignored element, false otherwise.
|
|
343
|
+
*/
|
|
344
|
+
declare function isIgnoredElement(value: unknown): value is IgnoredElement;
|
|
345
|
+
/**
|
|
346
|
+
* Determines if the given value is a local element.
|
|
347
|
+
* @param value The value to check.
|
|
348
|
+
* @returns True if the value is a local element, false otherwise.
|
|
349
|
+
*/
|
|
350
|
+
declare function isLocalElement(value: unknown): value is LocalElementKnown | LocalElementUnknown;
|
|
351
|
+
/**
|
|
352
|
+
* Determines if the given element is local and unknown, because its type and category could not be determined.
|
|
353
|
+
* @param value The value to check.
|
|
354
|
+
* @returns True if the element is an unknown element, false otherwise.
|
|
355
|
+
*/
|
|
356
|
+
declare function isUnknownLocalElement(value: unknown): value is LocalElementUnknown;
|
|
357
|
+
/**
|
|
358
|
+
* Determines if the given element is local and known, because its type and category were determined.
|
|
359
|
+
* @param value The value to check.
|
|
360
|
+
* @returns True if the element is an unknown element, false otherwise.
|
|
361
|
+
*/
|
|
362
|
+
declare function isKnownLocalElement(value: unknown): value is LocalElementKnown;
|
|
363
|
+
/**
|
|
364
|
+
* Determines if the given value is a dependency element.
|
|
365
|
+
* @param value The element to check.
|
|
366
|
+
* @returns True if the element is a dependency element, false otherwise.
|
|
367
|
+
*/
|
|
368
|
+
declare function isDependencyElementDescription(value: unknown): value is DependencyElementDescription;
|
|
369
|
+
/**
|
|
370
|
+
* Determines if the given value is an element (local or dependency).
|
|
371
|
+
* @param value The value to check.
|
|
372
|
+
* @returns True if the value is an element, false otherwise.
|
|
373
|
+
*/
|
|
374
|
+
declare function isElementDescription(value: unknown): value is ElementDescription;
|
|
375
|
+
/**
|
|
376
|
+
* Determines if the given value is a local dependency element.
|
|
377
|
+
* @param value The value to check.
|
|
378
|
+
* @returns True if the element is a local dependency element, false otherwise.
|
|
379
|
+
*/
|
|
380
|
+
declare function isLocalDependencyElement(value: unknown): value is LocalDependencyElement;
|
|
381
|
+
/**
|
|
382
|
+
* Determines if the given value is an external element.
|
|
383
|
+
* @param value The value to check.
|
|
384
|
+
* @returns True if the element is an external dependency element, false otherwise.
|
|
385
|
+
*/
|
|
386
|
+
declare function isExternalDependencyElement(value: unknown): value is ExternalDependencyElement;
|
|
387
|
+
/**
|
|
388
|
+
* Determines if the given value is a core element.
|
|
389
|
+
* @param value The value to check.
|
|
390
|
+
* @returns True if the element is a core dependency element, false otherwise.
|
|
391
|
+
*/
|
|
392
|
+
declare function isCoreDependencyElement(value: unknown): value is CoreDependencyElement;
|
|
393
|
+
|
|
394
|
+
declare const DEPENDENCY_KIND_TYPE: "type";
|
|
395
|
+
declare const DEPENDENCY_KIND_VALUE: "value";
|
|
396
|
+
/** Map of the kinds of dependency, either a type dependency or a value dependency */
|
|
397
|
+
declare const DEPENDENCY_KINDS_MAP: {
|
|
398
|
+
/** Type import, e.g., `import type { X } from 'module'` */
|
|
399
|
+
readonly TYPE: "type";
|
|
400
|
+
/** Value import, e.g., `import { X } from 'module'` */
|
|
401
|
+
readonly VALUE: "value";
|
|
402
|
+
};
|
|
403
|
+
/** Kind of dependency, either a type dependency or a value dependency */
|
|
404
|
+
type DependencyKind = (typeof DEPENDENCY_KINDS_MAP)[keyof typeof DEPENDENCY_KINDS_MAP];
|
|
405
|
+
/** Map of possible kinds of relationships between elements being dependencies */
|
|
406
|
+
declare const DEPENDENCY_RELATIONSHIPS_MAP: {
|
|
407
|
+
/** The dependency is internal to the element */
|
|
408
|
+
readonly INTERNAL: "internal";
|
|
409
|
+
/** The dependency is a child of the element */
|
|
410
|
+
readonly CHILD: "child";
|
|
411
|
+
/** The dependency is a descendant of the element */
|
|
412
|
+
readonly DESCENDANT: "descendant";
|
|
413
|
+
/** The dependency is a sibling of the element (both have the same parent) */
|
|
414
|
+
readonly SIBLING: "sibling";
|
|
415
|
+
/** The dependency is a parent of the element */
|
|
416
|
+
readonly PARENT: "parent";
|
|
417
|
+
/** The dependency is an uncle of the element */
|
|
418
|
+
readonly UNCLE: "uncle";
|
|
419
|
+
/** The dependency is a nephew of the element */
|
|
420
|
+
readonly NEPHEW: "nephew";
|
|
421
|
+
/** The dependency is an ancestor of the element */
|
|
422
|
+
readonly ANCESTOR: "ancestor";
|
|
423
|
+
};
|
|
424
|
+
declare const DEPENDENCY_RELATIONSHIPS_INVERTED_MAP: {
|
|
425
|
+
readonly internal: "internal";
|
|
426
|
+
readonly child: "parent";
|
|
427
|
+
readonly descendant: "ancestor";
|
|
428
|
+
readonly sibling: "sibling";
|
|
429
|
+
readonly parent: "child";
|
|
430
|
+
readonly uncle: "nephew";
|
|
431
|
+
readonly nephew: "uncle";
|
|
432
|
+
readonly ancestor: "descendant";
|
|
433
|
+
};
|
|
434
|
+
/** Kind of relationship between elements being dependencies */
|
|
435
|
+
type DependencyRelationship = (typeof DEPENDENCY_RELATIONSHIPS_MAP)[keyof typeof DEPENDENCY_RELATIONSHIPS_MAP];
|
|
436
|
+
/** Information about a dependency between two elements */
|
|
437
|
+
type ElementsDependencyInfo = {
|
|
438
|
+
/** Kind of the dependency */
|
|
439
|
+
kind: DependencyKind;
|
|
440
|
+
/** Type of the node creating the dependency in the dependent element */
|
|
441
|
+
nodeKind: string | null;
|
|
442
|
+
/** Specifiers imported or exported in the dependency */
|
|
443
|
+
specifiers: string[] | null;
|
|
444
|
+
/** Relationship between the elements from both perspectives */
|
|
445
|
+
relationship: {
|
|
446
|
+
/** Relationship between the elements from the perspective of the file */
|
|
447
|
+
from: DependencyRelationship | null;
|
|
448
|
+
/** Relationship between the elements from the perspective of the dependency */
|
|
449
|
+
to: DependencyRelationship | null;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Description of a dependency between two elements
|
|
454
|
+
*/
|
|
455
|
+
type DependencyDescription = {
|
|
456
|
+
/** Source element of the dependency */
|
|
457
|
+
from: FileElement;
|
|
458
|
+
/** Target element of the dependency */
|
|
459
|
+
to: DependencyElementDescription;
|
|
460
|
+
/** Information about the dependency */
|
|
461
|
+
dependency: ElementsDependencyInfo;
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* Serialized cache of dependencies descriptor.
|
|
465
|
+
*/
|
|
466
|
+
type DependenciesDescriptorSerializedCache = Record<string, DependencyDescription>;
|
|
467
|
+
/** Options for describing a dependency between two elements */
|
|
468
|
+
type DescribeDependencyOptions = {
|
|
469
|
+
/** Path of the element where the dependency originates */
|
|
470
|
+
from: string;
|
|
471
|
+
/** Path of the element where the dependency points to */
|
|
472
|
+
to?: string;
|
|
473
|
+
/** Source of the dependency (import/export path) */
|
|
474
|
+
source: string;
|
|
475
|
+
/** Kind of the dependency (type, runtime) */
|
|
476
|
+
kind: DependencyKind;
|
|
477
|
+
/** Type of the node creating the dependency in the dependent element */
|
|
478
|
+
nodeKind?: string;
|
|
479
|
+
/** Specifiers imported or exported in the dependency */
|
|
480
|
+
specifiers?: string[];
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Determines if the value is a valid dependency kind.
|
|
485
|
+
* @param value The value to check
|
|
486
|
+
* @returns True if the value is a valid dependency kind, false otherwise.
|
|
487
|
+
*/
|
|
488
|
+
declare function isDependencyKind(value: unknown): value is DependencyKind;
|
|
489
|
+
/**
|
|
490
|
+
* Determines if the given value is a valid dependency relationship.
|
|
491
|
+
* @param value The value to check.
|
|
492
|
+
* @returns True if the value is a valid dependency relationship, false otherwise.
|
|
493
|
+
*/
|
|
494
|
+
declare function isDependencyRelationship(value: unknown): value is DependencyRelationship;
|
|
495
|
+
/**
|
|
496
|
+
* Determines if the given value is a valid dependency relationship description.
|
|
497
|
+
* @param value The value to check.
|
|
498
|
+
* @returns True if the value is a valid dependency relationship, false otherwise.
|
|
499
|
+
*/
|
|
500
|
+
declare function isDependencyRelationshipDescription(value: unknown): value is DependencyRelationship;
|
|
501
|
+
/**
|
|
502
|
+
* Returns whether the given value is a valid ElementsDependencyInfo object.
|
|
503
|
+
* @param value The value to check.
|
|
504
|
+
* @returns True if the value is a valid ElementsDependencyInfo object, false otherwise.
|
|
505
|
+
*/
|
|
506
|
+
declare function isElementsDependencyInfo(value: unknown): value is ElementsDependencyInfo;
|
|
507
|
+
/**
|
|
508
|
+
* Determines whether the given value is a valid DependencyDescription object.
|
|
509
|
+
* @param value The value to check
|
|
510
|
+
* @returns True if the value is a valid DependencyDescription object, false otherwise.
|
|
511
|
+
*/
|
|
512
|
+
declare function isDependencyDescription(value: unknown): value is DependencyDescription;
|
|
513
|
+
/**
|
|
514
|
+
* Determines whether the given dependency description is internal.
|
|
515
|
+
* @param dependency The dependency to check
|
|
516
|
+
* @returns True if the dependency is internal, false otherwise
|
|
517
|
+
*/
|
|
518
|
+
declare function isInternalDependency(dependency: DependencyDescription): boolean;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Serialized cache for Descriptors class.
|
|
522
|
+
*/
|
|
523
|
+
type DescriptorsSerializedCache = {
|
|
524
|
+
/** Serialized elements cache */
|
|
525
|
+
elements: ElementsDescriptorSerializedCache;
|
|
526
|
+
/** Serialized dependencies cache */
|
|
527
|
+
dependencies: DependenciesDescriptorSerializedCache;
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Class with methods to describe elements and dependencies between them.
|
|
532
|
+
*/
|
|
533
|
+
declare class Descriptors {
|
|
534
|
+
private readonly _elementsDescriptor;
|
|
535
|
+
private readonly _dependenciesDescriptor;
|
|
536
|
+
/** Creates a new DescriptorsManager instance
|
|
537
|
+
* @param elementDescriptors The element descriptors.
|
|
538
|
+
* @param configOptions The configuration options.
|
|
539
|
+
*/
|
|
540
|
+
constructor(elementDescriptors: ElementDescriptors, configOptions?: ConfigOptions);
|
|
541
|
+
/**
|
|
542
|
+
* Serializes the elements and dependencies cache to a plain object.
|
|
543
|
+
* @returns The serialized elements and dependencies cache.
|
|
544
|
+
*/
|
|
545
|
+
serializeCache(): DescriptorsSerializedCache;
|
|
546
|
+
/**
|
|
547
|
+
* Sets the elements and dependencies cache from a serialized object.
|
|
548
|
+
* @param serializedCache The serialized elements and dependencies cache.
|
|
549
|
+
*/
|
|
550
|
+
setCacheFromSerialized(serializedCache: DescriptorsSerializedCache): void;
|
|
551
|
+
/**
|
|
552
|
+
* Clears all caches.
|
|
553
|
+
*/
|
|
554
|
+
clearCache(): void;
|
|
555
|
+
/**
|
|
556
|
+
* Describes an element given its file path.
|
|
557
|
+
* @param filePath The path of the file to describe.
|
|
558
|
+
* @returns The description of the element.
|
|
559
|
+
*/
|
|
560
|
+
describeElement(filePath?: string): FileElement;
|
|
561
|
+
/**
|
|
562
|
+
* Describes a dependency element given its dependency source and file path.
|
|
563
|
+
* @param dependencySource The source of the dependency.
|
|
564
|
+
* @param filePath The path of the file being the dependency, if known.
|
|
565
|
+
* @returns The description of the dependency element.
|
|
566
|
+
*/
|
|
567
|
+
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
568
|
+
/**
|
|
569
|
+
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
570
|
+
* @param options The options for describing the elements and the dependency details.
|
|
571
|
+
* @returns The description of the dependency between the elements.
|
|
572
|
+
*/
|
|
573
|
+
describeDependency(options: DescribeDependencyOptions): DependencyDescription;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Result of matching an element selector against an element.
|
|
578
|
+
*/
|
|
579
|
+
type DependencyMatchResult = {
|
|
580
|
+
/** The selector matching result for the 'from' element. */
|
|
581
|
+
from: ElementSelectorData | null;
|
|
582
|
+
/** The selector matching result for the 'to' element. */
|
|
583
|
+
to: ElementSelectorData | null;
|
|
584
|
+
/** Whether the dependency matches all the selector properties provided */
|
|
585
|
+
isMatch: boolean;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Serialized cache of elements matcher.
|
|
589
|
+
*/
|
|
590
|
+
type ElementsMatcherSerializedCache = Record<string, ElementSelectorData | null>;
|
|
591
|
+
/**
|
|
592
|
+
* Serialized cache of dependencies matcher.
|
|
593
|
+
*/
|
|
594
|
+
type DependenciesMatcherSerializedCache = Record<string, DependencyMatchResult>;
|
|
595
|
+
type MatcherSerializedCache = {
|
|
596
|
+
descriptors: DescriptorsSerializedCache;
|
|
597
|
+
elementsMatcher: ElementsMatcherSerializedCache;
|
|
598
|
+
dependenciesMatcher: DependenciesMatcherSerializedCache;
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* Elements that can return a match when using an element selector.
|
|
602
|
+
*/
|
|
603
|
+
type SelectableElement = IgnoredElement | LocalElementKnown | LocalElementUnknown | CoreDependencyElement | ExternalDependencyElement | LocalDependencyElementKnown;
|
|
604
|
+
/**
|
|
605
|
+
* Selector for matching captured values in element selectors.
|
|
606
|
+
* 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.
|
|
607
|
+
*/
|
|
608
|
+
type CapturedValuesSelector = Record<string, MicromatchPattern>;
|
|
609
|
+
/**
|
|
610
|
+
* Data to pass to selector templates when they are rendered before matching.
|
|
611
|
+
*/
|
|
612
|
+
type TemplateData = Record<string, unknown>;
|
|
613
|
+
/**
|
|
614
|
+
* Options for elements and dependencies matchers.
|
|
615
|
+
*/
|
|
616
|
+
type MatcherOptionsDependencySelectorsGlobals = {
|
|
617
|
+
/** The kind of the dependency */
|
|
618
|
+
kind?: MicromatchPattern;
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* Options for elements and dependencies matchers.
|
|
622
|
+
*/
|
|
623
|
+
type MatcherOptions = {
|
|
624
|
+
/** Extra data to pass to captured values templates. By default, data from the element and dependency being matched is passed as to/from. */
|
|
625
|
+
extraTemplateData?: TemplateData;
|
|
626
|
+
/**
|
|
627
|
+
* 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.
|
|
628
|
+
* @deprecated Use 'kind' property directly in the dependency element selectors instead.
|
|
629
|
+
**/
|
|
630
|
+
dependencySelectorsGlobals?: MatcherOptionsDependencySelectorsGlobals;
|
|
631
|
+
};
|
|
632
|
+
/**
|
|
633
|
+
* Simple element selector by type, represented as a string matching the element type.
|
|
634
|
+
* @deprecated Use BaseElementSelectorData or DependencyElementSelectorData instead.
|
|
635
|
+
*/
|
|
636
|
+
type SimpleElementSelectorByType = string;
|
|
637
|
+
/**
|
|
638
|
+
* Selector for base elements, including captured values for dynamic matching.
|
|
639
|
+
*/
|
|
640
|
+
type BaseElementSelectorData = {
|
|
641
|
+
/** Micromatch pattern(s) to match the path of the element */
|
|
642
|
+
path?: MicromatchPattern;
|
|
643
|
+
/** Micromatch pattern(s) to match the path of the element containing the file */
|
|
644
|
+
elementPath?: MicromatchPattern;
|
|
645
|
+
/** Micromatch pattern(s) to match internal paths within the file or dependency, relative to the element path */
|
|
646
|
+
internalPath?: MicromatchPattern;
|
|
647
|
+
/** Type of the element */
|
|
648
|
+
type?: MicromatchPattern;
|
|
649
|
+
/** Category of the element */
|
|
650
|
+
category?: MicromatchPattern;
|
|
651
|
+
/** Captured values selector for dynamic matching */
|
|
652
|
+
captured?: CapturedValuesSelector;
|
|
653
|
+
/** Origin of the element */
|
|
654
|
+
origin?: MicromatchPattern;
|
|
655
|
+
/** Micromatch pattern(s) to match the source of the dependency */
|
|
656
|
+
source?: MicromatchPattern;
|
|
657
|
+
/** Base source of the element, e.g., the import path of a dependency */
|
|
658
|
+
baseSource?: MicromatchPattern;
|
|
659
|
+
/** Whether the element is ignored */
|
|
660
|
+
isIgnored?: boolean;
|
|
661
|
+
/** Whether the element is unknown */
|
|
662
|
+
isUnknown?: boolean;
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* Selector for dependency elements, including kind, specifier, and node kind filters.
|
|
666
|
+
*/
|
|
667
|
+
type DependencyElementSelectorData = BaseElementSelectorData & {
|
|
668
|
+
/** Relationship of the file element with the dependency declared in it */
|
|
669
|
+
relationship?: MicromatchPattern;
|
|
670
|
+
/** Dependency kind to filter elements */
|
|
671
|
+
kind?: MicromatchPattern;
|
|
672
|
+
/** Micromatch pattern(s) to match only specific imports/exports */
|
|
673
|
+
specifiers?: MicromatchPattern;
|
|
674
|
+
/** Node kind to filter elements */
|
|
675
|
+
nodeKind?: MicromatchPattern;
|
|
676
|
+
};
|
|
677
|
+
/**
|
|
678
|
+
* File Element selector with options, including captured values for dynamic matching.
|
|
679
|
+
* It is represented as a tuple where the first element is the element type (string)
|
|
680
|
+
* and the second element is an object containing a selector for captured values.
|
|
681
|
+
* @deprecated Use FileElementSelectorData defining an object with type and/or category and the rest of properties directly instead.
|
|
682
|
+
*/
|
|
683
|
+
type BaseElementSelectorWithOptions = [
|
|
684
|
+
SimpleElementSelectorByType,
|
|
685
|
+
CapturedValuesSelector
|
|
686
|
+
];
|
|
687
|
+
/**
|
|
688
|
+
* Dependency Element selector with options, including captured values for dynamic matching.
|
|
689
|
+
* It is represented as a tuple where the first element is the element type (string)
|
|
690
|
+
* and the second element is an object containing a selector for captured values.
|
|
691
|
+
* @deprecated Use DependencyElementSelectorData defining an object with type and/or category and the rest of properties directly instead.
|
|
692
|
+
*/
|
|
693
|
+
type DependencyElementSelectorWithOptions = [
|
|
694
|
+
SimpleElementSelectorByType,
|
|
695
|
+
CapturedValuesSelector
|
|
696
|
+
];
|
|
697
|
+
/**
|
|
698
|
+
* Base Element selector, which can be a simple string, object with type and/or category, or a base element selector with options.
|
|
699
|
+
*/
|
|
700
|
+
type BaseElementSelector = SimpleElementSelectorByType | BaseElementSelectorData | BaseElementSelectorWithOptions;
|
|
701
|
+
/**
|
|
702
|
+
* Dependency Element selector, which can be a simple string, object with type and/or category, or a dependency element selector with options.
|
|
703
|
+
*/
|
|
704
|
+
type DependencyElementSelector = SimpleElementSelectorByType | DependencyElementSelectorData | DependencyElementSelectorWithOptions;
|
|
705
|
+
/** Base elements selector, which can be a single base element selector or an array of base element selectors. */
|
|
706
|
+
type BaseElementsSelector = BaseElementSelector | BaseElementSelector[];
|
|
707
|
+
/** Dependency elements selector, which can be a single dependency element selector or an array of dependency element selectors. */
|
|
708
|
+
type DependencyElementsSelector = DependencyElementSelector | DependencyElementSelector[];
|
|
709
|
+
/**
|
|
710
|
+
* Element selector data, which may be a base element selector or a dependency element selector.
|
|
711
|
+
*/
|
|
712
|
+
type ElementSelectorData = BaseElementSelectorData | DependencyElementSelectorData;
|
|
713
|
+
/**
|
|
714
|
+
* Generic Element selector with options, including captured values for dynamic matching.
|
|
715
|
+
* It is represented as a tuple where the first element is the element type (string)
|
|
716
|
+
* and the second element is an object containing a selector for captured values.
|
|
717
|
+
* @deprecated Use ElementSelector defining an object with type and/or category and the rest of properties directly instead.
|
|
718
|
+
*/
|
|
719
|
+
type ElementSelectorWithOptions = [
|
|
720
|
+
SimpleElementSelectorByType,
|
|
721
|
+
CapturedValuesSelector
|
|
722
|
+
];
|
|
723
|
+
/**
|
|
724
|
+
* Element selector, which can be a simple string, object with type and/or category, or an element selector with options.
|
|
725
|
+
*/
|
|
726
|
+
type ElementSelector = SimpleElementSelectorByType | ElementSelectorData | ElementSelectorWithOptions;
|
|
727
|
+
/**
|
|
728
|
+
* Elements selector, which can be a single element selector or an array of element selectors.
|
|
729
|
+
*/
|
|
730
|
+
type ElementsSelector = BaseElementsSelector | DependencyElementsSelector;
|
|
731
|
+
/**
|
|
732
|
+
* Element selectors, which can be a single element selector or an array of element selectors.
|
|
733
|
+
* @deprecated Use ElementsSelector instead.
|
|
734
|
+
*/
|
|
735
|
+
type ElementSelectors = ElementsSelector;
|
|
736
|
+
/**
|
|
737
|
+
* Dependency selector, which includes optional 'from' and 'to' elements selectors.
|
|
738
|
+
*/
|
|
739
|
+
type DependencySelector = {
|
|
740
|
+
/** Selector for the dependant elements. The file originating the dependency */
|
|
741
|
+
from?: BaseElementsSelector;
|
|
742
|
+
/** Selector for the dependency elements. The element being imported/exported */
|
|
743
|
+
to?: DependencyElementsSelector;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Normalized dependency selector, where 'from' and 'to' are always arrays or null.
|
|
747
|
+
*/
|
|
748
|
+
type DependencySelectorNormalized = {
|
|
749
|
+
/** Selector for the dependant elements. The file originating the dependency */
|
|
750
|
+
from: BaseElementSelectorData[] | null;
|
|
751
|
+
/** Selector for the dependency elements. The element being imported/exported */
|
|
752
|
+
to: DependencyElementSelectorData[] | null;
|
|
753
|
+
};
|
|
754
|
+
/**
|
|
755
|
+
* Options for selecting external libraries, including path patterns and optional specifiers.
|
|
756
|
+
* If specifiers are provided, they will be used to match specific imports from the external library.
|
|
757
|
+
*/
|
|
758
|
+
type ExternalLibrarySelectorOptions = {
|
|
759
|
+
/**
|
|
760
|
+
* Micromatch pattern(s) to match only one or more specific subpaths of the external library.
|
|
761
|
+
*/
|
|
762
|
+
path?: MicromatchPattern;
|
|
763
|
+
/** Micromatch pattern(s) to match only specific imports/exports */
|
|
764
|
+
specifiers?: string[];
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* 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.
|
|
768
|
+
*/
|
|
769
|
+
type ExternalLibrarySelectorWithOptions = [
|
|
770
|
+
SimpleElementSelectorByType,
|
|
771
|
+
ExternalLibrarySelectorOptions
|
|
772
|
+
];
|
|
773
|
+
/**
|
|
774
|
+
* External library selector, which can be a simple string (the import path) or an external library selector with options.
|
|
775
|
+
*/
|
|
776
|
+
type ExternalLibrarySelector = SimpleElementSelectorByType | ExternalLibrarySelectorWithOptions;
|
|
777
|
+
/**
|
|
778
|
+
* External library selectors, which can be a single external library selector or an array of external library selectors.
|
|
779
|
+
* @deprecated Use ExternalLibrariesSelector instead.
|
|
780
|
+
*/
|
|
781
|
+
type ExternalLibrarySelectors = ExternalLibrariesSelector;
|
|
782
|
+
/**
|
|
783
|
+
* External libraries selector, which can be a single external library selector or an array of external library selectors.
|
|
784
|
+
*/
|
|
785
|
+
type ExternalLibrariesSelector = ExternalLibrarySelector | ExternalLibrarySelector[];
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Normalizes an ElementsSelector into an array of ElementSelectorData.
|
|
789
|
+
* @param elementsSelector The elements selector, in any supported format.
|
|
790
|
+
* @returns The normalized array of selector data.
|
|
791
|
+
*/
|
|
792
|
+
declare function normalizeElementsSelector(elementsSelector: BaseElementsSelector): BaseElementSelectorData[];
|
|
793
|
+
declare function normalizeElementsSelector(elementsSelector: DependencyElementsSelector): DependencyElementSelectorData[];
|
|
794
|
+
/**
|
|
795
|
+
* Base matcher class to determine if elements or dependencies match a given selector.
|
|
796
|
+
*/
|
|
797
|
+
declare class BaseElementsMatcher {
|
|
798
|
+
protected readonly _legacyTemplates: boolean;
|
|
799
|
+
/**
|
|
800
|
+
* Creates a new BaseElementsMatcher.
|
|
801
|
+
* @param config Configuration options for the matcher.
|
|
802
|
+
*/
|
|
803
|
+
constructor(config: ConfigOptionsNormalized);
|
|
804
|
+
/**
|
|
805
|
+
* Converts a template with ${} to Handlebars {{}} templates for backwards compatibility.
|
|
806
|
+
* @param template The template to convert.
|
|
807
|
+
* @returns The converted template.
|
|
808
|
+
*/
|
|
809
|
+
private _getBackwardsCompatibleTemplate;
|
|
810
|
+
/**
|
|
811
|
+
* Returns a rendered template using the provided template data.
|
|
812
|
+
* @param template The template to render.
|
|
813
|
+
* @param extraTemplateData The data to use for replace in the template.
|
|
814
|
+
* @returns The rendered template.
|
|
815
|
+
*/
|
|
816
|
+
private _getRenderedTemplate;
|
|
817
|
+
/**
|
|
818
|
+
* Returns rendered templates using the provided template data.
|
|
819
|
+
* @param template The templates to render.
|
|
820
|
+
* @param extraTemplateData The data to use for replace in the templates.
|
|
821
|
+
* @returns The rendered templates.
|
|
822
|
+
*/
|
|
823
|
+
protected getRenderedTemplates(template: MicromatchPattern, templateData: TemplateData): MicromatchPattern;
|
|
824
|
+
/**
|
|
825
|
+
* Returns whether the given value matches the micromatch pattern, converting non-string values to strings.
|
|
826
|
+
* @param value The value to check.
|
|
827
|
+
* @param pattern The micromatch pattern to match against.
|
|
828
|
+
* @returns Whether the value matches the pattern.
|
|
829
|
+
*/
|
|
830
|
+
protected isMicromatchMatch(value: unknown, pattern: MicromatchPattern): boolean;
|
|
831
|
+
/**
|
|
832
|
+
* Whether the given element key matches the selector key as booleans.
|
|
833
|
+
* @param param0 The parameters object.
|
|
834
|
+
* @returns Whether the element key matches the selector key.
|
|
835
|
+
*/
|
|
836
|
+
protected isElementKeyBooleanMatch<T extends BaseElement, S extends BaseElementSelectorData>({
|
|
837
|
+
/** The element to check. */
|
|
838
|
+
element,
|
|
839
|
+
/** The selector to check against. */
|
|
840
|
+
selector,
|
|
841
|
+
/** The key of the element to check. */
|
|
842
|
+
elementKey,
|
|
843
|
+
/** The key of the selector to check against. */
|
|
844
|
+
selectorKey, }: {
|
|
845
|
+
/** The element to check. */
|
|
846
|
+
element: T;
|
|
847
|
+
/** The selector to check against. */
|
|
848
|
+
selector: S;
|
|
849
|
+
/** The key of the element to check. */
|
|
850
|
+
elementKey: keyof T;
|
|
851
|
+
/** The key of the selector to check against. */
|
|
852
|
+
selectorKey: keyof S;
|
|
853
|
+
}): boolean;
|
|
854
|
+
/**
|
|
855
|
+
* Whether the given element key matches the selector key using micromatch.
|
|
856
|
+
* @param param0 The parameters object.
|
|
857
|
+
* @returns Whether the element key matches the selector key.
|
|
858
|
+
*/
|
|
859
|
+
protected isElementKeyMicromatchMatch<T extends SelectableElement, S extends BaseElementSelectorData | DependencyElementSelectorData>({ element, selector, elementKey, selectorKey, selectorValue, templateData, }: {
|
|
860
|
+
/** The element to check. */
|
|
861
|
+
element: T;
|
|
862
|
+
/** The selector to check against. */
|
|
863
|
+
selector: S;
|
|
864
|
+
/** The key of the element to check. */
|
|
865
|
+
elementKey: T extends LocalElementKnown ? keyof LocalElementKnown : T extends CoreDependencyElement ? keyof CoreDependencyElement : T extends ExternalDependencyElement ? keyof ExternalDependencyElement : T extends IgnoredElement ? keyof IgnoredElement : keyof LocalDependencyElementKnown;
|
|
866
|
+
/** The key of the selector to check against. */
|
|
867
|
+
selectorKey: S extends DependencyElementSelectorData ? keyof DependencyElementSelectorData : keyof BaseElementSelectorData;
|
|
868
|
+
/** The value of the selector key to check against. */
|
|
869
|
+
selectorValue?: MicromatchPattern;
|
|
870
|
+
/** Data to pass when the selector value is rendered as a template */
|
|
871
|
+
templateData: TemplateData;
|
|
872
|
+
}): boolean;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Matcher class to determine if elements match a given selector.
|
|
877
|
+
*/
|
|
878
|
+
declare class ElementsMatcher extends BaseElementsMatcher {
|
|
879
|
+
/**
|
|
880
|
+
* Cache to store previously described elements.
|
|
881
|
+
*/
|
|
882
|
+
private readonly _cache;
|
|
883
|
+
/**
|
|
884
|
+
* Creates a new ElementsSelectorMatcher.
|
|
885
|
+
*/
|
|
886
|
+
constructor(config: ConfigOptionsNormalized);
|
|
887
|
+
/**
|
|
888
|
+
* Serializes the cache to a plain object.
|
|
889
|
+
* @returns The serialized cache.
|
|
890
|
+
*/
|
|
891
|
+
serializeCache(): ElementsMatcherSerializedCache;
|
|
892
|
+
/**
|
|
893
|
+
* Sets the cache from a serialized object.
|
|
894
|
+
* @param serializedCache The serialized cache.
|
|
895
|
+
*/
|
|
896
|
+
setCacheFromSerialized(serializedCache: ElementsMatcherSerializedCache): void;
|
|
897
|
+
/**
|
|
898
|
+
* Clears the cache.
|
|
899
|
+
*/
|
|
900
|
+
clearCache(): void;
|
|
901
|
+
/**
|
|
902
|
+
* Whether the given element type matches the selector type.
|
|
903
|
+
* @param element The element to check.
|
|
904
|
+
* @param selector The selector to check against.
|
|
905
|
+
* @param templateData The data to use for replace in selector value
|
|
906
|
+
* @returns Whether the element type matches the selector type.
|
|
907
|
+
*/
|
|
908
|
+
private _isTypeMatch;
|
|
909
|
+
/**
|
|
910
|
+
* Whether the given element category matches the selector category.
|
|
911
|
+
* @param element The element to check.
|
|
912
|
+
* @param selector The selector to check against.
|
|
913
|
+
* @param templateData The data to use for replace in selector value
|
|
914
|
+
* @returns Whether the element category matches the selector category.
|
|
915
|
+
*/
|
|
916
|
+
private _isCategoryMatch;
|
|
917
|
+
/**
|
|
918
|
+
* Whether the given element path matches the selector path.
|
|
919
|
+
* @param element The element to check.
|
|
920
|
+
* @param selector The selector to check against.
|
|
921
|
+
* @param templateData The data to use for replace in selector value
|
|
922
|
+
* @returns Whether the element path matches the selector path.
|
|
923
|
+
*/
|
|
924
|
+
private _isPathMatch;
|
|
925
|
+
/**
|
|
926
|
+
* Whether the given element path matches the selector element path.
|
|
927
|
+
* @param element The element to check.
|
|
928
|
+
* @param selector The selector to check against.
|
|
929
|
+
* @param templateData The data to use for replace in selector value
|
|
930
|
+
* @returns Whether the element path matches the selector element path.
|
|
931
|
+
*/
|
|
932
|
+
private _isElementPathMatch;
|
|
933
|
+
/**
|
|
934
|
+
* Whether the given element internal path matches the selector internal path.
|
|
935
|
+
* @param element The element to check.
|
|
936
|
+
* @param selector The selector to check against.
|
|
937
|
+
* @param templateData The data to use for replace in selector value
|
|
938
|
+
* @returns Whether the element internal path matches the selector internal path.
|
|
939
|
+
*/
|
|
940
|
+
private _isInternalPathMatch;
|
|
941
|
+
/**
|
|
942
|
+
* Whether the given element origin matches the selector origin
|
|
943
|
+
* @param element The element to check.
|
|
944
|
+
* @param selector The selector to check against.
|
|
945
|
+
* @param templateData The data to use for replace in selector value
|
|
946
|
+
* @returns Whether the element origin matches the selector origin.
|
|
947
|
+
*/
|
|
948
|
+
private _isOriginMatch;
|
|
949
|
+
/**
|
|
950
|
+
* Whether the given element baseSource matches the selector baseSource
|
|
951
|
+
* @param element The element to check.
|
|
952
|
+
* @param selector The selector to check against.
|
|
953
|
+
* @param templateData The data to use for replace in selector value
|
|
954
|
+
* @returns Whether the element baseSource matches the selector baseSource.
|
|
955
|
+
*/
|
|
956
|
+
private _isBaseSourceMatch;
|
|
957
|
+
/**
|
|
958
|
+
* Whether the given element source matches the selector source
|
|
959
|
+
* @param element The element to check.
|
|
960
|
+
* @param selector The selector to check against.
|
|
961
|
+
* @param templateData The data to use for replace in selector value
|
|
962
|
+
* @returns Whether the element source matches the selector source.
|
|
963
|
+
*/
|
|
964
|
+
private _isSourceMatch;
|
|
965
|
+
/**
|
|
966
|
+
* Determines if the captured values of the element match those in the selector.
|
|
967
|
+
* @param element The element to check.
|
|
968
|
+
* @param selector The selector to check against
|
|
969
|
+
* @param templateData The data to use for replace in selector values
|
|
970
|
+
* @returns True if the captured values match, false otherwise.
|
|
971
|
+
*/
|
|
972
|
+
private _isCapturedValuesMatch;
|
|
973
|
+
/**
|
|
974
|
+
* Determines if the isIgnored property of the element matches that in the selector.
|
|
975
|
+
* @param element The element to check.
|
|
976
|
+
* @param selector The selector to check against.
|
|
977
|
+
* @returns True if the isIgnored properties match, false otherwise.
|
|
978
|
+
*/
|
|
979
|
+
private _isIgnoredMatch;
|
|
980
|
+
/**
|
|
981
|
+
* Determines if the isUnknown property of the element matches that in the selector.
|
|
982
|
+
* @param element The element to check.
|
|
983
|
+
* @param selector The selector to check against.
|
|
984
|
+
* @returns True if the isUnknown properties match, false otherwise.
|
|
985
|
+
*/
|
|
986
|
+
private _isUnknownMatch;
|
|
987
|
+
/**
|
|
988
|
+
* Returns the selector matching result for the given local or external element.
|
|
989
|
+
* @param element The local or external element to check.
|
|
990
|
+
* @param selector The selector to check against.
|
|
991
|
+
* @param extraTemplateData Extra template data to use for matching.
|
|
992
|
+
* @returns The selector matching result for the given element, or null if none matches.
|
|
993
|
+
*/
|
|
994
|
+
private _getSelectorMatching;
|
|
995
|
+
/**
|
|
996
|
+
* Returns the selector matching result for the given element, or null if none matches.
|
|
997
|
+
* It omits checks in keys applying only to dependency between elements, such as relationship.
|
|
998
|
+
* @param element The element to check.
|
|
999
|
+
* @param selector The selector to check against.
|
|
1000
|
+
* @param options Extra options for matching, such as templates data, globals for dependency selectors, etc.
|
|
1001
|
+
* @returns The selector matching result for the given element, or null if none matches.
|
|
1002
|
+
*/
|
|
1003
|
+
getSelectorMatching(element: ElementDescription, selector: BaseElementsSelector, { extraTemplateData }?: MatcherOptions): ElementSelectorData | null;
|
|
1004
|
+
/**
|
|
1005
|
+
* Returns whether the given element matches the selector.
|
|
1006
|
+
* It omits checks in keys applying only to dependency between elements, such as relationship.
|
|
1007
|
+
* @param element The element to check.
|
|
1008
|
+
* @param selector The selector to check against.
|
|
1009
|
+
* @param options Extra options for matching, such as templates data, globals for dependency selectors, etc.
|
|
1010
|
+
* @returns Whether the element matches the selector properties applying to elements.
|
|
1011
|
+
*/
|
|
1012
|
+
isElementMatch(element: ElementDescription, selector: BaseElementsSelector, options?: MatcherOptions): boolean;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Matcher class to determine if dependencies match a given dependencies selector.
|
|
1017
|
+
*/
|
|
1018
|
+
declare class DependenciesMatcher extends BaseElementsMatcher {
|
|
1019
|
+
/**
|
|
1020
|
+
* Cache to store previously described dependencies.
|
|
1021
|
+
*/
|
|
1022
|
+
private readonly _cache;
|
|
1023
|
+
/**
|
|
1024
|
+
* Elements matcher to use for matching elements within dependencies.
|
|
1025
|
+
*/
|
|
1026
|
+
private readonly _elementsMatcher;
|
|
1027
|
+
/**
|
|
1028
|
+
* Creates a new DependenciesMatcher.
|
|
1029
|
+
*/
|
|
1030
|
+
constructor(elementsMatcher: ElementsMatcher, config: ConfigOptionsNormalized);
|
|
1031
|
+
/**
|
|
1032
|
+
* Serializes the cache to a plain object.
|
|
1033
|
+
* @returns The serialized cache.
|
|
1034
|
+
*/
|
|
1035
|
+
serializeCache(): DependenciesMatcherSerializedCache;
|
|
1036
|
+
/**
|
|
1037
|
+
* Sets the cache from a serialized object.
|
|
1038
|
+
* @param serializedCache The serialized cache.
|
|
1039
|
+
*/
|
|
1040
|
+
setCacheFromSerialized(serializedCache: DependenciesMatcherSerializedCache): void;
|
|
1041
|
+
/**
|
|
1042
|
+
* Clears the cache.
|
|
1043
|
+
*/
|
|
1044
|
+
clearCache(): void;
|
|
1045
|
+
/**
|
|
1046
|
+
* Normalizes selector into DependencySelectorNormalized format, containing arrays of selectors data.
|
|
1047
|
+
* @param selector The dependency selector to normalize.
|
|
1048
|
+
* @returns The normalized dependency selector.
|
|
1049
|
+
*/
|
|
1050
|
+
private _normalizeDependencySelector;
|
|
1051
|
+
/**
|
|
1052
|
+
* Converts a DependencyElementSelectorData to a BaseElementSelectorData, by removing dependency-specific properties.
|
|
1053
|
+
* @param selector The dependency element selector data.
|
|
1054
|
+
* @returns The base element selector data.
|
|
1055
|
+
*/
|
|
1056
|
+
private _convertDependencyElementSelectorDataToBaseElementSelectorData;
|
|
1057
|
+
/**
|
|
1058
|
+
* Returns the selectors matching result for the given dependency.
|
|
1059
|
+
* @param dependency The dependency description.
|
|
1060
|
+
* @param selector The dependency selector normalized.
|
|
1061
|
+
* @param extraTemplateData The extra template data for selector values.
|
|
1062
|
+
* @returns The selectors matching result for the given dependency.
|
|
1063
|
+
*/
|
|
1064
|
+
private _getSelectorMatching;
|
|
1065
|
+
/**
|
|
1066
|
+
* Determines if the dependency relationship matches the selector.
|
|
1067
|
+
* @param dependency The dependency description.
|
|
1068
|
+
* @param selector The data of an element selector.
|
|
1069
|
+
* @returns Whether the dependency relationship matches the selector.
|
|
1070
|
+
*/
|
|
1071
|
+
private _relationshipMatches;
|
|
1072
|
+
/**
|
|
1073
|
+
* Determines if the selector matches an specific kind
|
|
1074
|
+
* @param selector The dependency selector data
|
|
1075
|
+
* @param kind Kind to check
|
|
1076
|
+
* @param templateData The template data for rendering selector values
|
|
1077
|
+
* @returns Whether the selector matches the kind
|
|
1078
|
+
*/
|
|
1079
|
+
private _kindMatches;
|
|
1080
|
+
/**
|
|
1081
|
+
* Determines if the selector matches some of the specifiers
|
|
1082
|
+
* @param selector The dependency selector data
|
|
1083
|
+
* @param specifiers Specifiers to check
|
|
1084
|
+
* @param templateData The template data for rendering selector values
|
|
1085
|
+
* @returns Whether the selector matches some of the specifiers
|
|
1086
|
+
*/
|
|
1087
|
+
private _specifierMatches;
|
|
1088
|
+
/**
|
|
1089
|
+
* Determines if the selector matches the nodeKind
|
|
1090
|
+
* @param selector The dependency selector data
|
|
1091
|
+
* @param nodeKind The nodeKind to check
|
|
1092
|
+
* @param templateData The template data for rendering selector values
|
|
1093
|
+
* @returns Whether the selector matches the nodeKind
|
|
1094
|
+
*/
|
|
1095
|
+
private _nodeKindMatches;
|
|
1096
|
+
/**
|
|
1097
|
+
* Determines if the dependency description matches the selector for 'from'.
|
|
1098
|
+
* @param dependency The dependency description.
|
|
1099
|
+
* @param fromSelector The selector for 'from' elements.
|
|
1100
|
+
* @param templateData The template data for rendering selector values
|
|
1101
|
+
* @returns Whether the dependency properties match the selector for 'from'.
|
|
1102
|
+
*/
|
|
1103
|
+
private _dependencyFromPropertiesMatch;
|
|
1104
|
+
/**
|
|
1105
|
+
* Determines if the dependency description matches the selector for 'to'.
|
|
1106
|
+
* @param dependency The dependency description.
|
|
1107
|
+
* @param toSelector The selector for 'to' elements.
|
|
1108
|
+
* @param templateData The template data for rendering selector values
|
|
1109
|
+
* @returns Whether the dependency properties match the selector for 'to'.
|
|
1110
|
+
*/
|
|
1111
|
+
private _dependencyToPropertiesMatch;
|
|
1112
|
+
/**
|
|
1113
|
+
* Returns the selectors matching result for the given dependency.
|
|
1114
|
+
* @param dependency The dependency to check.
|
|
1115
|
+
* @param selector The selector to check against.
|
|
1116
|
+
* @param options Extra options for matching, such as templates data, globals for dependency selectors, etc.
|
|
1117
|
+
* @returns The matching result for the dependency against the selector.
|
|
1118
|
+
*/
|
|
1119
|
+
getSelectorsMatching(dependency: DependencyDescription, selector: DependencySelector, { extraTemplateData, dependencySelectorsGlobals, }?: MatcherOptions): DependencyMatchResult;
|
|
1120
|
+
/**
|
|
1121
|
+
* Returns whether the given dependency matches the selector.
|
|
1122
|
+
* @param dependency The dependency to check.
|
|
1123
|
+
* @param selector The selector to check against.
|
|
1124
|
+
* @param options Extra options for matching, such as templates data, globals for dependency selectors, etc.
|
|
1125
|
+
* @returns Whether the dependency matches the selector properties.
|
|
1126
|
+
*/
|
|
1127
|
+
isDependencyMatch(dependency: DependencyDescription, selector: DependencySelector, options?: MatcherOptions): boolean;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Determines if the given value is a captured values selector.
|
|
1132
|
+
* @param value The value to check.
|
|
1133
|
+
* @returns True if the value is a captured values selector, false otherwise.
|
|
1134
|
+
*/
|
|
1135
|
+
declare function isCapturedValuesSelector(value: unknown): value is CapturedValuesSelector;
|
|
1136
|
+
/**
|
|
1137
|
+
* Determines if the given value is a simple element selector.
|
|
1138
|
+
* @param value The value to check.
|
|
1139
|
+
* @returns True if the value is a simple element selector, false otherwise.
|
|
1140
|
+
*/
|
|
1141
|
+
declare function isSimpleElementSelectorByType(value: unknown): value is SimpleElementSelectorByType;
|
|
1142
|
+
/**
|
|
1143
|
+
* Determines if the given selector is a base element selector.
|
|
1144
|
+
* @param value The value to check.
|
|
1145
|
+
* @returns True if the selector is a base element selector
|
|
1146
|
+
*/
|
|
1147
|
+
declare function isBaseElementSelectorData(value: unknown): value is ElementSelectorData;
|
|
1148
|
+
/**
|
|
1149
|
+
* Determines if the given selector is an element or dependency element selector data.
|
|
1150
|
+
* @param value The value to check.
|
|
1151
|
+
* @returns True if the selector is an element or dependency element selector data, false otherwise.
|
|
1152
|
+
*/
|
|
1153
|
+
declare function isElementSelectorData(value: unknown): value is ElementSelectorData;
|
|
1154
|
+
/**
|
|
1155
|
+
* Determines if the given selector is an element selector with options.
|
|
1156
|
+
* @param value The value to check.
|
|
1157
|
+
* @returns True if the selector is an element selector with options, false otherwise.
|
|
1158
|
+
*/
|
|
1159
|
+
declare function isElementSelectorWithLegacyOptions(value: unknown): value is ElementSelectorWithOptions;
|
|
1160
|
+
/**
|
|
1161
|
+
* Determines if the given value is an element selector.
|
|
1162
|
+
* @param value The value to check.
|
|
1163
|
+
* @returns True if the value is an element selector, false otherwise.
|
|
1164
|
+
*/
|
|
1165
|
+
declare function isElementSelector(value: unknown): value is ElementSelector;
|
|
1166
|
+
/**
|
|
1167
|
+
* Determines if the given value is an elements selector.
|
|
1168
|
+
* @param value The value to check.
|
|
1169
|
+
* @returns True if the value is an elements selector, false otherwise.
|
|
1170
|
+
*/
|
|
1171
|
+
declare function isElementsSelector(value: unknown): value is ElementSelectors;
|
|
1172
|
+
/**
|
|
1173
|
+
* Determines if the given value is a dependency selector.
|
|
1174
|
+
* @param value The value to check
|
|
1175
|
+
* @returns True if the value is a dependency selector, false otherwise.
|
|
1176
|
+
*/
|
|
1177
|
+
declare function isDependencySelector(value: unknown): value is DependencySelector;
|
|
1178
|
+
/**
|
|
1179
|
+
* Determines if the given value is external library selector options with a path.
|
|
1180
|
+
* @param value The value to check.
|
|
1181
|
+
* @returns True if the value is external library selector options with a path, false otherwise.
|
|
1182
|
+
*/
|
|
1183
|
+
declare function isExternalLibrarySelectorOptionsWithPath(value: unknown): value is ExternalLibrarySelectorOptions & {
|
|
1184
|
+
path: string | string[];
|
|
1185
|
+
};
|
|
1186
|
+
/**
|
|
1187
|
+
* Determines if the given value is external library selector options with specifiers.
|
|
1188
|
+
* @param value The value to check.
|
|
1189
|
+
* @returns True if the value is external library selector options with specifiers, false otherwise.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function isExternalLibrarySelectorOptionsWithSpecifiers(value: unknown): value is ExternalLibrarySelectorOptions & {
|
|
1192
|
+
specifiers: string[];
|
|
1193
|
+
};
|
|
1194
|
+
/**
|
|
1195
|
+
* Determines if the given value is external library selector options.
|
|
1196
|
+
* @param value The value to check.
|
|
1197
|
+
* @returns True if the value is external library selector options, false otherwise.
|
|
1198
|
+
*/
|
|
1199
|
+
declare function isExternalLibrarySelectorOptions(value: unknown): value is ExternalLibrarySelectorOptions;
|
|
1200
|
+
/**
|
|
1201
|
+
* Determines if the given value is an external library selector with options.
|
|
1202
|
+
* @param value The value to check.
|
|
1203
|
+
* @returns True if the value is an external library selector with options, false otherwise.
|
|
1204
|
+
*/
|
|
1205
|
+
declare function isExternalLibrarySelectorWithOptions(value: unknown): value is ExternalLibrarySelectorWithOptions;
|
|
1206
|
+
/**
|
|
1207
|
+
* Determines if the given value is an external library selector.
|
|
1208
|
+
* @param value The value to check.
|
|
1209
|
+
* @returns True if the value is an external library selector, false otherwise.
|
|
1210
|
+
*/
|
|
1211
|
+
declare function isExternalLibrarySelector(value: unknown): value is ExternalLibrarySelector;
|
|
1212
|
+
/**
|
|
1213
|
+
* Determines if the given value is an external libraries selector.
|
|
1214
|
+
* @param value The value to check.
|
|
1215
|
+
* @returns True if the value is an external libraries selector, false otherwise.
|
|
1216
|
+
*/
|
|
1217
|
+
declare function isExternalLibrariesSelector(value: unknown): value is ExternalLibrariesSelector;
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Matcher class to evaluate if elements or dependencies match given selectors.
|
|
1221
|
+
*/
|
|
1222
|
+
declare class Matcher {
|
|
1223
|
+
private readonly _descriptors;
|
|
1224
|
+
private readonly _elementsMatcher;
|
|
1225
|
+
private readonly _dependenciesMatcher;
|
|
1226
|
+
/**
|
|
1227
|
+
* Constructor for the Matcher class.
|
|
1228
|
+
* @param descriptors Element descriptors to use for matching.
|
|
1229
|
+
* @param config Configuration options.
|
|
1230
|
+
*/
|
|
1231
|
+
constructor(descriptors: ElementDescriptors, config: ConfigOptionsNormalized);
|
|
1232
|
+
/**
|
|
1233
|
+
* Determines if an element matches a given selector.
|
|
1234
|
+
* @param filePath The file path of the element
|
|
1235
|
+
* @param selector The selector to match against
|
|
1236
|
+
* @param options Extra matcher options
|
|
1237
|
+
* @returns True if the element matches the selector, false otherwise
|
|
1238
|
+
*/
|
|
1239
|
+
private _isElementMatch;
|
|
1240
|
+
/**
|
|
1241
|
+
* Determines if a dependency matches a given selector.
|
|
1242
|
+
* @param dependencyData The data describing the dependency
|
|
1243
|
+
* @param selector The selector to match against
|
|
1244
|
+
* @param options Extra matcher options
|
|
1245
|
+
* @returns True if the dependency matches the selector, false otherwise
|
|
1246
|
+
*/
|
|
1247
|
+
private _isDependencyMatch;
|
|
1248
|
+
/**
|
|
1249
|
+
* Determines if the given element or dependency matches the provided selector.
|
|
1250
|
+
* @param descriptorOptions The file path or dependency options to describe the element or dependency
|
|
1251
|
+
* @param selector The selector to match against
|
|
1252
|
+
* @param options Extra matcher options
|
|
1253
|
+
*/
|
|
1254
|
+
isMatch(descriptorOptions: string, selector: ElementsSelector, options?: MatcherOptions): boolean;
|
|
1255
|
+
isMatch(descriptorOptions: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): boolean;
|
|
1256
|
+
/**
|
|
1257
|
+
* Determines the selector matching for an element.
|
|
1258
|
+
* @param filePath The file path of the element
|
|
1259
|
+
* @param selector The selectors to match against
|
|
1260
|
+
* @param options Extra options for matching
|
|
1261
|
+
* @returns The matching selector data or null if no match is found
|
|
1262
|
+
*/
|
|
1263
|
+
private _getElementSelectorMatching;
|
|
1264
|
+
/**
|
|
1265
|
+
* Determines the selector matching for a dependency.
|
|
1266
|
+
* @param dependencyData The data describing the dependency
|
|
1267
|
+
* @param selector The selectors to match against
|
|
1268
|
+
* @param options Extra options for matching
|
|
1269
|
+
* @returns The matching dependency result or null if no match is found
|
|
1270
|
+
*/
|
|
1271
|
+
private _isDependencySelectorMatching;
|
|
1272
|
+
/**
|
|
1273
|
+
* Determines the selector matching for a dependency or element.
|
|
1274
|
+
* @param descriptorOptions The file path or dependency options to describe the element or dependency
|
|
1275
|
+
* @param selector The selectors to match against
|
|
1276
|
+
* @param options Extra options for matching
|
|
1277
|
+
* @returns The matching dependency result or element selector data, or null if no match is found
|
|
1278
|
+
*/
|
|
1279
|
+
getSelectorMatching(descriptorOptions: string, selector: ElementsSelector, options?: MatcherOptions): ElementSelectorData | null;
|
|
1280
|
+
getSelectorMatching(descriptorOptions: DescribeDependencyOptions, selector: DependencySelector, options?: MatcherOptions): DependencyMatchResult | null;
|
|
1281
|
+
/**
|
|
1282
|
+
* Returns the selectors matching result for the given element or dependency description.
|
|
1283
|
+
* @param description The element or dependency description to check.
|
|
1284
|
+
* @param selector The selector to check against.
|
|
1285
|
+
* @param options Extra options for matching, such as templates data, globals for dependency selectors, etc.
|
|
1286
|
+
* @returns The selectors matching result for the given description, and whether it matches or not.
|
|
1287
|
+
*/
|
|
1288
|
+
getSelectorMatchingDescription(description: DependencyDescription, selector: DependencySelector, options?: MatcherOptions): DependencyMatchResult;
|
|
1289
|
+
getSelectorMatchingDescription(description: ElementDescription, selector: ElementsSelector, options?: MatcherOptions): ElementSelectorData;
|
|
1290
|
+
/**
|
|
1291
|
+
* Describes an element given its file path.
|
|
1292
|
+
* @param filePath The path of the file to describe.
|
|
1293
|
+
* @returns The description of the element.
|
|
1294
|
+
*/
|
|
1295
|
+
describeElement(filePath: string): FileElement;
|
|
1296
|
+
/**
|
|
1297
|
+
* Describes a dependency element given its dependency source and file path.
|
|
1298
|
+
* @param dependencySource The source of the dependency.
|
|
1299
|
+
* @param filePath The path of the file being the dependency, if known.
|
|
1300
|
+
* @returns The description of the dependency element.
|
|
1301
|
+
*/
|
|
1302
|
+
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
1303
|
+
/**
|
|
1304
|
+
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
1305
|
+
* @param options The options for describing the elements and the dependency details.
|
|
1306
|
+
* @returns The description of the dependency between the elements.
|
|
1307
|
+
*/
|
|
1308
|
+
describeDependency(options: DescribeDependencyOptions): DependencyDescription;
|
|
1309
|
+
/**
|
|
1310
|
+
* Clears all caches.
|
|
1311
|
+
*/
|
|
1312
|
+
clearCache(): void;
|
|
1313
|
+
/**
|
|
1314
|
+
* Serializes the descriptors and elements matchers cache to a plain object.
|
|
1315
|
+
* @returns The serialized cache
|
|
1316
|
+
*/
|
|
1317
|
+
serializeCache(): MatcherSerializedCache;
|
|
1318
|
+
/**
|
|
1319
|
+
* Sets the descriptors and elements matchers cache from a serialized object.
|
|
1320
|
+
* @param serializedCache The serialized cache
|
|
1321
|
+
*/
|
|
1322
|
+
setCacheFromSerialized(serializedCache: {
|
|
1323
|
+
descriptors: ReturnType<Descriptors["serializeCache"]>;
|
|
1324
|
+
elementsMatcher: ReturnType<ElementsMatcher["serializeCache"]>;
|
|
1325
|
+
dependenciesMatcher: ReturnType<DependenciesMatcher["serializeCache"]>;
|
|
1326
|
+
}): void;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Serialized cache for Elements class.
|
|
1331
|
+
*/
|
|
1332
|
+
type ElementsSerializedCache = {
|
|
1333
|
+
/** Cache for Matcher instances per configuration */
|
|
1334
|
+
matchers: Record<string, {
|
|
1335
|
+
config: ConfigOptionsNormalized;
|
|
1336
|
+
elementDescriptors: ElementDescriptors;
|
|
1337
|
+
cache: MatcherSerializedCache;
|
|
1338
|
+
}>;
|
|
1339
|
+
/** Cache for ElementsMatcher */
|
|
1340
|
+
elementsMatcher: ElementsMatcherSerializedCache;
|
|
1341
|
+
/** Cache for DependenciesMatcher */
|
|
1342
|
+
dependenciesMatcher: DependenciesMatcherSerializedCache;
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Main class to interact with Elements functionality.
|
|
1347
|
+
* 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.
|
|
1348
|
+
*/
|
|
1349
|
+
declare class Elements {
|
|
1350
|
+
/** The global configuration options for Elements. Can be overridden when getting a descriptor */
|
|
1351
|
+
private readonly _globalConfigOptions;
|
|
1352
|
+
/** Cache manager for Matcher instances, unique for each different configuration */
|
|
1353
|
+
private readonly _matchersCache;
|
|
1354
|
+
/** Matcher for element selectors */
|
|
1355
|
+
private readonly _elementsMatcher;
|
|
1356
|
+
/** Matcher for dependency selectors */
|
|
1357
|
+
private readonly _dependenciesMatcher;
|
|
1358
|
+
/**
|
|
1359
|
+
* Creates a new Elements instance
|
|
1360
|
+
* @param configOptions The global configuration options for Elements. Can be overridden when getting a descriptor.
|
|
1361
|
+
*/
|
|
1362
|
+
constructor(configOptions?: ConfigOptions);
|
|
1363
|
+
/**
|
|
1364
|
+
* Returns a serialized representation of the current state of the cache.
|
|
1365
|
+
* @returns A serialized representation of the cache.
|
|
1366
|
+
*/
|
|
1367
|
+
serializeCache(): ElementsSerializedCache;
|
|
1368
|
+
/**
|
|
1369
|
+
* Sets the Elements cache from a serialized representation.
|
|
1370
|
+
* @param serializedCache The serialized cache to set.
|
|
1371
|
+
*/
|
|
1372
|
+
setCacheFromSerialized(serializedCache: ElementsSerializedCache): void;
|
|
1373
|
+
/**
|
|
1374
|
+
* Clears cache
|
|
1375
|
+
*/
|
|
1376
|
+
clearCache(): void;
|
|
1377
|
+
/**
|
|
1378
|
+
* Gets a Matcher instance for the given configuration options.
|
|
1379
|
+
* It uses caching to return the same instance for the same configuration options. If no options are provided, the global configuration options are used.
|
|
1380
|
+
* @param elementDescriptors The element descriptors to use.
|
|
1381
|
+
* @param configOptions Optional configuration options to override the global ones.
|
|
1382
|
+
* @returns A matcher instance, unique for each different configuration.
|
|
1383
|
+
*/
|
|
1384
|
+
getMatcher(elementDescriptors: ElementDescriptors, configOptions?: ConfigOptions): Matcher;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Class describing elements in a project given their paths and configuration.
|
|
1389
|
+
*/
|
|
1390
|
+
declare class ElementsDescriptor {
|
|
1391
|
+
private _mod;
|
|
1392
|
+
/**
|
|
1393
|
+
* Cache to store previously described elements.
|
|
1394
|
+
*/
|
|
1395
|
+
private readonly _elementsCache;
|
|
1396
|
+
/**
|
|
1397
|
+
* Cache to store previously described files.
|
|
1398
|
+
*/
|
|
1399
|
+
private readonly _filesCache;
|
|
1400
|
+
/**
|
|
1401
|
+
* Configuration instance for this descriptor.
|
|
1402
|
+
*/
|
|
1403
|
+
private readonly _config;
|
|
1404
|
+
/**
|
|
1405
|
+
* Element descriptors used by this descriptor.
|
|
1406
|
+
*/
|
|
1407
|
+
private readonly _elementDescriptors;
|
|
1408
|
+
/**
|
|
1409
|
+
* The configuration options for this descriptor.
|
|
1410
|
+
* @param elementDescriptors The element descriptors.
|
|
1411
|
+
* @param configOptions The configuration options.
|
|
1412
|
+
*/
|
|
1413
|
+
constructor(elementDescriptors: ElementDescriptors, configOptions?: ConfigOptions);
|
|
1414
|
+
/**
|
|
1415
|
+
* Serializes the elements cache to a plain object.
|
|
1416
|
+
* @returns The serialized elements cache.
|
|
1417
|
+
*/
|
|
1418
|
+
serializeCache(): ElementsDescriptorSerializedCache;
|
|
1419
|
+
/**
|
|
1420
|
+
* Sets the elements cache from a serialized object.
|
|
1421
|
+
* @param serializedCache The serialized elements cache.
|
|
1422
|
+
*/
|
|
1423
|
+
setCacheFromSerialized(serializedCache: ElementsDescriptorSerializedCache): void;
|
|
1424
|
+
/**
|
|
1425
|
+
* Clears the elements cache.
|
|
1426
|
+
*/
|
|
1427
|
+
clearCache(): void;
|
|
1428
|
+
/**
|
|
1429
|
+
* Loads the Node.js module to access built-in modules information when running in Node.js environment.
|
|
1430
|
+
*/
|
|
1431
|
+
private _loadModuleInNode;
|
|
1432
|
+
/**
|
|
1433
|
+
* Validates the element descriptors to ensure they are correctly defined.
|
|
1434
|
+
*/
|
|
1435
|
+
private _validateDescriptors;
|
|
1436
|
+
/**
|
|
1437
|
+
* Determines if a dependency source is a core module.
|
|
1438
|
+
* @param dependencySource The source of the dependency to check.
|
|
1439
|
+
* @param baseDependencySource The base source of the dependency to check.
|
|
1440
|
+
* @returns True if the dependency source is a core module, false otherwise.
|
|
1441
|
+
*/
|
|
1442
|
+
private _dependencySourceIsCoreModule;
|
|
1443
|
+
/**
|
|
1444
|
+
* Determines if a dependency source is scoped (e.g., @scope/package).
|
|
1445
|
+
* @param dependencySource The source of the dependency to check.
|
|
1446
|
+
* @returns True if the dependency source is scoped, false otherwise.
|
|
1447
|
+
*/
|
|
1448
|
+
private _dependencySourceIsScoped;
|
|
1449
|
+
/**
|
|
1450
|
+
* Determines if a dependency source is external or an alias.
|
|
1451
|
+
* @param dependencySource The source of the dependency to check.
|
|
1452
|
+
* @returns True if the dependency source is external or an alias, false otherwise.
|
|
1453
|
+
*/
|
|
1454
|
+
private _dependencySourceIsExternalOrScoped;
|
|
1455
|
+
/**
|
|
1456
|
+
* Gets the base source of an external module.
|
|
1457
|
+
* @param dependencySource The source of the dependency to check.
|
|
1458
|
+
* @returns The base source of the external module. (e.g., for "@scope/package/submodule", it returns "@scope/package")
|
|
1459
|
+
*/
|
|
1460
|
+
private _getExternalModuleBaseSource;
|
|
1461
|
+
/**
|
|
1462
|
+
* Determines if an element is external based on its file path and dependency source.
|
|
1463
|
+
* Files inside "node_modules" are considered external.
|
|
1464
|
+
* If the dependency source is not provided, only the file path is considered.
|
|
1465
|
+
* If the dependency source is provided, it must not be a local path (i.e, it should start by "./", "../", or "/").
|
|
1466
|
+
* @param filePath
|
|
1467
|
+
* @param dependencySource
|
|
1468
|
+
* @returns
|
|
1469
|
+
*/
|
|
1470
|
+
private _isExternalDependency;
|
|
1471
|
+
/**
|
|
1472
|
+
* Determines if a given path is included based on the configuration.
|
|
1473
|
+
* @param elementPath The element path to check.
|
|
1474
|
+
* @returns True if the path is included, false otherwise.
|
|
1475
|
+
*/
|
|
1476
|
+
private _pathIsIncluded;
|
|
1477
|
+
/**
|
|
1478
|
+
* Gets captured values from the captured array and capture configuration.
|
|
1479
|
+
* @param captured The array of captured strings.
|
|
1480
|
+
* @param captureConfig The configuration for capturing values.
|
|
1481
|
+
* @returns The captured values as an object.
|
|
1482
|
+
*/
|
|
1483
|
+
private _getCapturedValues;
|
|
1484
|
+
/**
|
|
1485
|
+
* Gets the element path based on the path pattern, path segments to the element, and all path segments from the file path.
|
|
1486
|
+
* @param pathPattern The element path pattern.
|
|
1487
|
+
* @param pathSegments The path segments leading to the element.
|
|
1488
|
+
* @param allPathSegments The full path segments from the file path.
|
|
1489
|
+
* @returns The element path.
|
|
1490
|
+
*/
|
|
1491
|
+
private _getElementPath;
|
|
1492
|
+
/**
|
|
1493
|
+
* Determines if an element descriptor matches the given parameters in the provided path.
|
|
1494
|
+
* @param options The options for matching the descriptor.
|
|
1495
|
+
* @returns The result of the match, including whether it matched and any captured values.
|
|
1496
|
+
*/
|
|
1497
|
+
private _fileDescriptorMatch;
|
|
1498
|
+
/**
|
|
1499
|
+
* Retrieves the description of an element given its path.
|
|
1500
|
+
* It does not identify external files. Files not matching any element are considered unknown.
|
|
1501
|
+
* If a file in node_modules does a match, it is considered local as well.
|
|
1502
|
+
* @param includeExternal Whether to include external files (inside node_modules) in the matching process.
|
|
1503
|
+
* @param elementPath The path of the element to describe.
|
|
1504
|
+
* @returns The description of the element.
|
|
1505
|
+
*/
|
|
1506
|
+
private _getFileDescription;
|
|
1507
|
+
/**
|
|
1508
|
+
* Describes a file given its path.
|
|
1509
|
+
* @param includeExternal Whether to include external files (inside node_modules) in the matching process.
|
|
1510
|
+
* @param filePath The path of the file to describe.
|
|
1511
|
+
* @returns The description of the element.
|
|
1512
|
+
*/
|
|
1513
|
+
private _describeFile;
|
|
1514
|
+
/**
|
|
1515
|
+
* Describes a dependency element given the file element and dependency source, by completing the file description.
|
|
1516
|
+
* @param element The file element to complete the description for.
|
|
1517
|
+
* @param dependencySource The source of the dependency.
|
|
1518
|
+
* @returns The description of the dependency element.
|
|
1519
|
+
*/
|
|
1520
|
+
private _describeDependencyElement;
|
|
1521
|
+
/**
|
|
1522
|
+
* Describes an element given its file path and dependency source, if any.
|
|
1523
|
+
* @param filePath The path of the file to describe.
|
|
1524
|
+
* @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.
|
|
1525
|
+
* @returns The description of the element. A dependency element if dependency source is provided, otherwise a file element.
|
|
1526
|
+
*/
|
|
1527
|
+
private _describeElement;
|
|
1528
|
+
/**
|
|
1529
|
+
* Describes an element given its file path.
|
|
1530
|
+
* @param filePath The path of the file to describe.
|
|
1531
|
+
* @returns The description of the element.
|
|
1532
|
+
*/
|
|
1533
|
+
describeElement(filePath?: string): FileElement;
|
|
1534
|
+
/**
|
|
1535
|
+
* Describes a dependency element given its dependency source and file path.
|
|
1536
|
+
* @param dependencySource The source of the dependency.
|
|
1537
|
+
* @param filePath The path of the file being the dependency, if known.
|
|
1538
|
+
* @returns The description of the dependency element.
|
|
1539
|
+
*/
|
|
1540
|
+
describeDependencyElement(dependencySource: string, filePath?: string): DependencyElementDescription;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* Class describing dependencies between elements.
|
|
1545
|
+
*/
|
|
1546
|
+
declare class DependenciesDescriptor {
|
|
1547
|
+
/**
|
|
1548
|
+
* Cache to store previously described dependencies.
|
|
1549
|
+
*/
|
|
1550
|
+
private readonly _dependenciesCache;
|
|
1551
|
+
/**
|
|
1552
|
+
* Elements descriptor instance.
|
|
1553
|
+
*/
|
|
1554
|
+
private readonly _elementsDescriptor;
|
|
1555
|
+
/**
|
|
1556
|
+
* Creates a new DependenciesDescriptor instance.
|
|
1557
|
+
* @param elementsDescriptor The elements descriptor instance.
|
|
1558
|
+
*/
|
|
1559
|
+
constructor(elementsDescriptor: ElementsDescriptor);
|
|
1560
|
+
/**
|
|
1561
|
+
* Serializes the elements cache to a plain object.
|
|
1562
|
+
* @returns The serialized elements cache.
|
|
1563
|
+
*/
|
|
1564
|
+
serializeCache(): DependenciesDescriptorSerializedCache;
|
|
1565
|
+
/**
|
|
1566
|
+
* Sets the elements cache from a serialized object.
|
|
1567
|
+
* @param serializedCache The serialized elements cache.
|
|
1568
|
+
*/
|
|
1569
|
+
setCacheFromSerialized(serializedCache: DependenciesDescriptorSerializedCache): void;
|
|
1570
|
+
/**
|
|
1571
|
+
* Clears the elements cache.
|
|
1572
|
+
*/
|
|
1573
|
+
clearCache(): void;
|
|
1574
|
+
/**
|
|
1575
|
+
* Retrieves the element path of the parent of a given element.
|
|
1576
|
+
* @param elementInfo The element whose parent is to be retrieved.
|
|
1577
|
+
* @returns The parent element path, or undefined if none exists.
|
|
1578
|
+
*/
|
|
1579
|
+
private _getParent;
|
|
1580
|
+
/**
|
|
1581
|
+
* Retrieves the common ancestor of two elements.
|
|
1582
|
+
* @param elementInfoA The first element.
|
|
1583
|
+
* @param elementInfoB The second element.
|
|
1584
|
+
* @returns The common ancestor element path, or undefined if none exists.
|
|
1585
|
+
*/
|
|
1586
|
+
private _getCommonAncestor;
|
|
1587
|
+
/**
|
|
1588
|
+
* Checks if the parent of element A is an ancestor of element B.
|
|
1589
|
+
* @param elementA The element A.
|
|
1590
|
+
* @param elementB The element B.
|
|
1591
|
+
* @returns True if the parent of element A is an ancestor of element B, false otherwise.
|
|
1592
|
+
*/
|
|
1593
|
+
private _isDescendantOfParent;
|
|
1594
|
+
/**
|
|
1595
|
+
* Checks if two elements are siblings (same parent).
|
|
1596
|
+
* @param elementA The first element.
|
|
1597
|
+
* @param elementB The second element.
|
|
1598
|
+
* @returns True if the elements are siblings, false otherwise.
|
|
1599
|
+
*/
|
|
1600
|
+
private _isSibling;
|
|
1601
|
+
/**
|
|
1602
|
+
* Checks if one element is a descendant of another.
|
|
1603
|
+
* @param elementA The potential descendant element.
|
|
1604
|
+
* @param elementB The potential ancestor element.
|
|
1605
|
+
* @returns True if elementA is a descendant of elementB, false otherwise.
|
|
1606
|
+
*/
|
|
1607
|
+
private _isDescendant;
|
|
1608
|
+
/**
|
|
1609
|
+
* Checks if one element is a child of another.
|
|
1610
|
+
* @param elementA The potential child element.
|
|
1611
|
+
* @param elementB The potential parent element.
|
|
1612
|
+
* @returns True if elementA is a child of elementB, false otherwise.
|
|
1613
|
+
*/
|
|
1614
|
+
private _isChild;
|
|
1615
|
+
/**
|
|
1616
|
+
* Checks if two local elements are internally related (same element).
|
|
1617
|
+
* @param elementA The first element.
|
|
1618
|
+
* @param elementB The second element.
|
|
1619
|
+
* @returns True if the elements are internally related, false otherwise.
|
|
1620
|
+
*/
|
|
1621
|
+
private _isInternal;
|
|
1622
|
+
/**
|
|
1623
|
+
* Retrieves the relationship between two local known elements in terms of dependency.
|
|
1624
|
+
* @param element The element depending on another element.
|
|
1625
|
+
* @param dependency The element being depended on.
|
|
1626
|
+
* @returns The relationship between the elements.
|
|
1627
|
+
*/
|
|
1628
|
+
private _dependencyRelationship;
|
|
1629
|
+
private _dependencyRelationships;
|
|
1630
|
+
/**
|
|
1631
|
+
* Describes elements in a dependency relationship, and provides additional information about the dependency itself.
|
|
1632
|
+
* @param options The options for describing the elements and the dependency details.
|
|
1633
|
+
* @returns The description of the dependency between the elements.
|
|
1634
|
+
*/
|
|
1635
|
+
describeDependency({ from, to, source, kind, nodeKind, specifiers, }: DescribeDependencyOptions): DependencyDescription;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* Generic cache manager class. Enables caching of values based on complex keys.
|
|
1640
|
+
*/
|
|
1641
|
+
declare class CacheManager<CacheKey extends NotUndefined, CachedValue> {
|
|
1642
|
+
/**
|
|
1643
|
+
* Internal cache map
|
|
1644
|
+
*/
|
|
1645
|
+
private readonly _cache;
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a new CacheManager instance
|
|
1648
|
+
*/
|
|
1649
|
+
constructor();
|
|
1650
|
+
/**
|
|
1651
|
+
* Generates a hashed key for the given cache key
|
|
1652
|
+
* @param key The cache key to hash
|
|
1653
|
+
* @returns The hashed key as a string
|
|
1654
|
+
*/
|
|
1655
|
+
private _getHashedKey;
|
|
1656
|
+
/**
|
|
1657
|
+
* Retrieves a value from the cache based on the given key
|
|
1658
|
+
* @param key The cache key to retrieve
|
|
1659
|
+
* @returns The cached value or undefined if not found
|
|
1660
|
+
*/
|
|
1661
|
+
get(key: CacheKey): CachedValue | undefined;
|
|
1662
|
+
/**
|
|
1663
|
+
* Stores a value in the cache
|
|
1664
|
+
* @param key The cache key to store
|
|
1665
|
+
* @param value The value to cache
|
|
1666
|
+
*/
|
|
1667
|
+
set(key: CacheKey, value: CachedValue): void;
|
|
1668
|
+
/**
|
|
1669
|
+
* Restores a value in the cache from a given already hashed key
|
|
1670
|
+
* @param key The hashed key to restore
|
|
1671
|
+
* @param value The value to restore
|
|
1672
|
+
*/
|
|
1673
|
+
restore(key: string, value: CachedValue): void;
|
|
1674
|
+
/**
|
|
1675
|
+
* Checks if a value exists in the cache
|
|
1676
|
+
* @param key The cache key to check
|
|
1677
|
+
* @returns True if the value exists, false otherwise
|
|
1678
|
+
*/
|
|
1679
|
+
has(key: CacheKey): boolean;
|
|
1680
|
+
/**
|
|
1681
|
+
* Retrieves all cached values
|
|
1682
|
+
* @returns A map of all cached values
|
|
1683
|
+
*/
|
|
1684
|
+
getAll(): Map<string, CachedValue>;
|
|
1685
|
+
/**
|
|
1686
|
+
* Clears the entire cache
|
|
1687
|
+
*/
|
|
1688
|
+
clear(): void;
|
|
1689
|
+
/**
|
|
1690
|
+
* Serializes the cache to a plain object.
|
|
1691
|
+
* @returns The serialized cache.
|
|
1692
|
+
*/
|
|
1693
|
+
serialize(): Record<string, CachedValue>;
|
|
1694
|
+
/**
|
|
1695
|
+
* Sets the cache from a serialized object.
|
|
1696
|
+
* @param serializedCache The serialized cache.
|
|
1697
|
+
*/
|
|
1698
|
+
setFromSerialized(serializedCache: Record<string, CachedValue>): void;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
export { type BaseDependencyElement, type BaseElement, type BaseElementDescriptor, type BaseElementSelector, type BaseElementSelectorData, type BaseElementSelectorWithOptions, type BaseElementsSelector, CacheManager, type CapturedValues, type CapturedValuesSelector, type ConfigOptions, type ConfigOptionsNormalized, type CoreDependencyElement, DEPENDENCY_KINDS_MAP, DEPENDENCY_KIND_TYPE, DEPENDENCY_KIND_VALUE, DEPENDENCY_RELATIONSHIPS_INVERTED_MAP, DEPENDENCY_RELATIONSHIPS_MAP, DependenciesDescriptor, type DependenciesDescriptorSerializedCache, DependenciesMatcher, type DependenciesMatcherSerializedCache, type DependencyDescription, type DependencyElementDescription, type DependencyElementSelector, type DependencyElementSelectorData, type DependencyElementSelectorWithOptions, type DependencyElementsSelector, type DependencyKind, type DependencyMatchResult, type DependencyRelationship, type DependencySelector, type DependencySelectorNormalized, type DescribeDependencyOptions, Descriptors, type DescriptorsSerializedCache, ELEMENT_DESCRIPTOR_MODES_MAP, ELEMENT_ORIGINS_MAP, type ElementDescription, type ElementDescriptor, type ElementDescriptorMode, type ElementDescriptorPattern, type ElementDescriptorWithCategory, type ElementDescriptorWithType, type ElementDescriptorWithTypeAndCategory, type ElementDescriptors, type ElementOrigin, type ElementParent, type ElementSelector, type ElementSelectorData, type ElementSelectorWithOptions, type ElementSelectors, Elements, type ElementsDependencyInfo, ElementsDescriptor, type ElementsDescriptorSerializedCache, ElementsMatcher, type ElementsMatcherSerializedCache, type ElementsSelector, type ElementsSerializedCache, type ExternalDependencyElement, type ExternalLibrariesSelector, type ExternalLibrarySelector, type ExternalLibrarySelectorOptions, type ExternalLibrarySelectorWithOptions, type ExternalLibrarySelectors, type FileElement, type IgnoredDependencyElement, type IgnoredElement, type LocalDependencyElement, type LocalDependencyElementKnown, type LocalDependencyElementUnknown, type LocalElementKnown, type LocalElementUnknown, Matcher, type MatcherOptions, type MatcherOptionsDependencySelectorsGlobals, type MatcherSerializedCache, type MicromatchPattern, type SelectableElement, type SimpleElementSelectorByType, type TemplateData, isBaseElement, isBaseElementDescriptor, isBaseElementSelectorData, isCapturedValuesSelector, isCoreDependencyElement, isDependencyDescription, isDependencyElementDescription, isDependencyKind, isDependencyRelationship, isDependencyRelationshipDescription, isDependencySelector, isElementDescription, isElementDescriptor, isElementDescriptorMode, isElementDescriptorPattern, isElementDescriptorWithCategory, isElementDescriptorWithType, isElementSelector, isElementSelectorData, isElementSelectorWithLegacyOptions, isElementsDependencyInfo, isElementsSelector, isExternalDependencyElement, isExternalLibrariesSelector, isExternalLibrarySelector, isExternalLibrarySelectorOptions, isExternalLibrarySelectorOptionsWithPath, isExternalLibrarySelectorOptionsWithSpecifiers, isExternalLibrarySelectorWithOptions, isIgnoredElement, isInternalDependency, isKnownLocalElement, isLocalDependencyElement, isLocalElement, isSimpleElementSelectorByType, isUnknownLocalElement, normalizeElementsSelector };
|