@zvenigora/ng-eval-core 0.2.2 → 0.4.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/README.md +296 -0
- package/fesm2022/zvenigora-ng-eval-core.mjs +2242 -198
- package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
- package/package.json +6 -6
- package/types/zvenigora-ng-eval-core.d.ts +2303 -0
- package/index.d.ts +0 -1270
package/index.d.ts
DELETED
|
@@ -1,1270 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { OnDestroy } from '@angular/core';
|
|
3
|
-
import * as acorn from 'acorn';
|
|
4
|
-
import { AnyNode, Program, Expression } from 'acorn';
|
|
5
|
-
import { WalkerCallback } from 'acorn-walk';
|
|
6
|
-
|
|
7
|
-
type ParserOptions = Partial<acorn.Options> & {
|
|
8
|
-
extractExpressions?: boolean;
|
|
9
|
-
cacheSize?: number;
|
|
10
|
-
ecmaVersion?: acorn.ecmaVersion;
|
|
11
|
-
};
|
|
12
|
-
type AnyNodeTypes = acorn.AnyNode['type'];
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Represents a registry that stores key-value pairs.
|
|
16
|
-
* @template TKey - The type of the keys in the registry.
|
|
17
|
-
* @template TValue - The type of the values in the registry.
|
|
18
|
-
*/
|
|
19
|
-
interface RegistryType<TKey, TValue> extends Iterable<[TKey, TValue]> {
|
|
20
|
-
type: Readonly<'Registry' | string>;
|
|
21
|
-
options: Readonly<{
|
|
22
|
-
caseInsensitive: boolean;
|
|
23
|
-
} | Record<string, unknown>>;
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the value associated with the specified key.
|
|
26
|
-
* @param key - The key to retrieve the value for.
|
|
27
|
-
* @returns The value associated with the key, or undefined if the key does not exist.
|
|
28
|
-
*/
|
|
29
|
-
get(key: TKey): TValue | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Sets the value for the specified key.
|
|
32
|
-
* @param key - The key to set the value for.
|
|
33
|
-
* @param value - The value to set.
|
|
34
|
-
*/
|
|
35
|
-
set(key: TKey, value: TValue): void;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the registry contains the specified key.
|
|
38
|
-
* @param key - The key to check.
|
|
39
|
-
* @returns True if the registry contains the key, false otherwise.
|
|
40
|
-
*/
|
|
41
|
-
has(key: TKey): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Deletes the key-value pair associated with the specified key.
|
|
44
|
-
* @param key - The key to delete.
|
|
45
|
-
* @returns True if the key-value pair was deleted, false if the key does not exist.
|
|
46
|
-
*/
|
|
47
|
-
delete(key: TKey): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Clears all key-value pairs from the registry.
|
|
50
|
-
*/
|
|
51
|
-
clear(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Gets the number of key-value pairs in the registry.
|
|
54
|
-
*/
|
|
55
|
-
readonly size: number;
|
|
56
|
-
/**
|
|
57
|
-
* Gets an iterator for the keys in the registry.
|
|
58
|
-
*/
|
|
59
|
-
readonly keys: IterableIterator<TKey>;
|
|
60
|
-
/**
|
|
61
|
-
* Gets an iterator for the values in the registry.
|
|
62
|
-
*/
|
|
63
|
-
readonly values: IterableIterator<TValue>;
|
|
64
|
-
/**
|
|
65
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
66
|
-
*/
|
|
67
|
-
readonly entries: IterableIterator<[TKey, TValue]>;
|
|
68
|
-
/**
|
|
69
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
70
|
-
* @param callbackfn - The function to execute for each key-value pair.
|
|
71
|
-
* @param thisArg - Optional value to use as `this` when executing the callback function.
|
|
72
|
-
*/
|
|
73
|
-
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: unknown): void;
|
|
74
|
-
/**
|
|
75
|
-
* Returns an iterator for the entries of the registry.
|
|
76
|
-
* @returns An iterator that yields key-value pairs of type [TKey, unknown].
|
|
77
|
-
*/
|
|
78
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
79
|
-
}
|
|
80
|
-
type RegistryEntries<TKey, TValue> = [TKey, TValue][] | Record<string | number | symbol, TValue>;
|
|
81
|
-
|
|
82
|
-
interface StackType<T> {
|
|
83
|
-
peek(): T;
|
|
84
|
-
pop(): T | undefined;
|
|
85
|
-
push(value: T): number;
|
|
86
|
-
swap(): void;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface QueueType<T> {
|
|
90
|
-
length: number;
|
|
91
|
-
dequeue(): T | undefined;
|
|
92
|
-
enqueue(value: T): number;
|
|
93
|
-
peek(): T;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface ScopeOptions {
|
|
97
|
-
global?: boolean;
|
|
98
|
-
caseInsensitive?: boolean;
|
|
99
|
-
namespace?: string;
|
|
100
|
-
}
|
|
101
|
-
interface RegistryOptionType<TKey, TValue> {
|
|
102
|
-
registry: Readonly<RegistryType<TKey, TValue>>;
|
|
103
|
-
options: Readonly<ScopeOptions>;
|
|
104
|
-
}
|
|
105
|
-
interface ScopeType<TKey, TValue> {
|
|
106
|
-
registries: RegistryOptionType<TKey, TValue>[];
|
|
107
|
-
add: (registry: RegistryOptionType<TKey, TValue>) => void;
|
|
108
|
-
get: (key: TKey, namespace?: string) => [TKey, TValue] | undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Represents a registry that stores key-value pairs.
|
|
113
|
-
*/
|
|
114
|
-
declare class BaseRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {
|
|
115
|
-
private readonly _registry;
|
|
116
|
-
type: Readonly<string>;
|
|
117
|
-
/**
|
|
118
|
-
* Options for the base registry.
|
|
119
|
-
*/
|
|
120
|
-
options: Readonly<Record<string, unknown>>;
|
|
121
|
-
/**
|
|
122
|
-
* Creates a new Registry instance.
|
|
123
|
-
* @param entries - Optional array of key-value pairs to initialize the registry.
|
|
124
|
-
*/
|
|
125
|
-
constructor(entries?: RegistryEntries<TKey, TValue> | null);
|
|
126
|
-
/**
|
|
127
|
-
* Creates a new Registry instance from an object.
|
|
128
|
-
* @param object - The object containing key-value pairs.
|
|
129
|
-
* @returns A new Registry instance.
|
|
130
|
-
*/
|
|
131
|
-
static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): BaseRegistry<TKey, TValue>;
|
|
132
|
-
/**
|
|
133
|
-
* Retrieves the value associated with the specified key.
|
|
134
|
-
* @param key - The key to retrieve the value for.
|
|
135
|
-
* @returns The value associated with the key, or undefined if the key does not exist.
|
|
136
|
-
*/
|
|
137
|
-
get(key: TKey): TValue | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* Sets the value for the specified key.
|
|
140
|
-
* @param key - The key to set the value for.
|
|
141
|
-
* @param value - The value to set.
|
|
142
|
-
*/
|
|
143
|
-
set(key: TKey, value: TValue): void;
|
|
144
|
-
/**
|
|
145
|
-
* Checks if the registry contains the specified key.
|
|
146
|
-
* @param key - The key to check.
|
|
147
|
-
* @returns True if the registry contains the key, false otherwise.
|
|
148
|
-
*/
|
|
149
|
-
has(key: TKey): boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Deletes the key-value pair associated with the specified key.
|
|
152
|
-
* @param key - The key to delete.
|
|
153
|
-
* @returns True if the key-value pair was deleted, false if the key does not exist.
|
|
154
|
-
*/
|
|
155
|
-
delete(key: TKey): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Clears all key-value pairs from the registry.
|
|
158
|
-
*/
|
|
159
|
-
clear(): void;
|
|
160
|
-
/**
|
|
161
|
-
* Gets the number of key-value pairs in the registry.
|
|
162
|
-
*/
|
|
163
|
-
get size(): number;
|
|
164
|
-
/**
|
|
165
|
-
* Gets an iterator for the keys in the registry.
|
|
166
|
-
*/
|
|
167
|
-
get keys(): IterableIterator<TKey>;
|
|
168
|
-
/**
|
|
169
|
-
* Gets an iterator for the values in the registry.
|
|
170
|
-
*/
|
|
171
|
-
get values(): IterableIterator<TValue>;
|
|
172
|
-
/**
|
|
173
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
174
|
-
*/
|
|
175
|
-
get entries(): IterableIterator<[TKey, TValue]>;
|
|
176
|
-
/**
|
|
177
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
178
|
-
* @param callbackfn - The function to execute for each key-value pair.
|
|
179
|
-
* @param thisArg - Optional value to use as `this` when executing the callback function.
|
|
180
|
-
*/
|
|
181
|
-
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void;
|
|
182
|
-
/**
|
|
183
|
-
* Returns an iterator for the entries of the registry.
|
|
184
|
-
* @returns An iterator that yields key-value pairs of type [TKey, TValue].
|
|
185
|
-
*/
|
|
186
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
187
|
-
/**
|
|
188
|
-
* Converts a BaseRegistry instance to an object.
|
|
189
|
-
* @param registry The BaseRegistry instance to convert.
|
|
190
|
-
* @returns An object representing the key-value pairs in the registry.
|
|
191
|
-
*/
|
|
192
|
-
toObject(): Record<string | number | symbol, TValue>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Represents a case-insensitive registry that maps keys to values.
|
|
197
|
-
*/
|
|
198
|
-
declare class CaseInsensitiveRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {
|
|
199
|
-
private readonly registry;
|
|
200
|
-
private keysMap;
|
|
201
|
-
type: Readonly<string>;
|
|
202
|
-
/**
|
|
203
|
-
* Options for the registry.
|
|
204
|
-
*/
|
|
205
|
-
options: Readonly<Record<string, unknown>>;
|
|
206
|
-
/**
|
|
207
|
-
* Creates a new instance of CaseInsensitiveRegistry.
|
|
208
|
-
* @param entries - Optional initial entries to populate the registry.
|
|
209
|
-
*/
|
|
210
|
-
constructor(entries?: RegistryEntries<TKey, TValue> | null);
|
|
211
|
-
/**
|
|
212
|
-
* Creates a new CaseInsensitiveRegistry from an object.
|
|
213
|
-
* @param object - The object containing key-value pairs.
|
|
214
|
-
* @returns A new CaseInsensitiveRegistry instance.
|
|
215
|
-
*/
|
|
216
|
-
static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): CaseInsensitiveRegistry<TKey, TValue>;
|
|
217
|
-
/**
|
|
218
|
-
* Retrieves the value associated with the specified key.
|
|
219
|
-
* @param key - The key.
|
|
220
|
-
* @returns The value associated with the key, or undefined if the key is not found.
|
|
221
|
-
*/
|
|
222
|
-
get(key: TKey): TValue | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* Sets a key-value pair in the registry.
|
|
225
|
-
* @param key - The key.
|
|
226
|
-
* @param value - The value.
|
|
227
|
-
*/
|
|
228
|
-
set(key: TKey, value: TValue): void;
|
|
229
|
-
/**
|
|
230
|
-
* Checks if the registry contains the specified key.
|
|
231
|
-
* @param key - The key.
|
|
232
|
-
* @returns True if the key is found, false otherwise.
|
|
233
|
-
*/
|
|
234
|
-
has(key: TKey): boolean;
|
|
235
|
-
/**
|
|
236
|
-
* Deletes the key-value pair associated with the specified key.
|
|
237
|
-
* @param key - The key.
|
|
238
|
-
* @returns True if the key-value pair is deleted, false if the key is not found.
|
|
239
|
-
*/
|
|
240
|
-
delete(key: TKey): boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Clears all key-value pairs from the registry.
|
|
243
|
-
*/
|
|
244
|
-
clear(): void;
|
|
245
|
-
/**
|
|
246
|
-
* Gets the number of key-value pairs in the registry.
|
|
247
|
-
*/
|
|
248
|
-
get size(): number;
|
|
249
|
-
/**
|
|
250
|
-
* Gets an iterator for the keys in the registry.
|
|
251
|
-
*/
|
|
252
|
-
get keys(): IterableIterator<TKey>;
|
|
253
|
-
/**
|
|
254
|
-
* Gets an iterator for the values in the registry.
|
|
255
|
-
*/
|
|
256
|
-
get values(): IterableIterator<TValue>;
|
|
257
|
-
/**
|
|
258
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
259
|
-
*/
|
|
260
|
-
get entries(): IterableIterator<[TKey, TValue]>;
|
|
261
|
-
/**
|
|
262
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
263
|
-
* @param callbackfn - The function to execute for each key-value pair.
|
|
264
|
-
*/
|
|
265
|
-
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void;
|
|
266
|
-
/**
|
|
267
|
-
* Returns an iterator for the entries of the registry.
|
|
268
|
-
* @returns An iterator that yields key-value pairs of type [string, unknown].
|
|
269
|
-
*/
|
|
270
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
271
|
-
private getKey;
|
|
272
|
-
/**
|
|
273
|
-
* Converts a BaseRegistry instance to an object.
|
|
274
|
-
* @param registry The BaseRegistry instance to convert.
|
|
275
|
-
* @returns An object representing the key-value pairs in the registry.
|
|
276
|
-
*/
|
|
277
|
-
toObject(): Record<string | number | symbol, TValue>;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Represents a generic registry that stores key-value pairs.
|
|
282
|
-
* @template TKey The type of the keys in the registry.
|
|
283
|
-
* @template TValue The type of the values in the registry.
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
declare class Registry<TKey, TValue> implements RegistryType<TKey, TValue> {
|
|
287
|
-
private readonly _registry;
|
|
288
|
-
type: Readonly<string>;
|
|
289
|
-
/**
|
|
290
|
-
* Options for the registry.
|
|
291
|
-
*/
|
|
292
|
-
options: Readonly<Record<string, unknown>>;
|
|
293
|
-
/**
|
|
294
|
-
* Creates a new Registry instance.
|
|
295
|
-
* @param entries - Optional array of key-value pairs to initialize the registry.
|
|
296
|
-
*/
|
|
297
|
-
constructor(entries?: RegistryEntries<TKey, TValue> | null, options?: Record<string, unknown>);
|
|
298
|
-
/**
|
|
299
|
-
* Creates a new Registry instance from an object.
|
|
300
|
-
* @param object - The object containing key-value pairs.
|
|
301
|
-
* @returns A new Registry instance.
|
|
302
|
-
*/
|
|
303
|
-
static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>, options?: Record<string, unknown>): Registry<TKey, TValue>;
|
|
304
|
-
/**
|
|
305
|
-
* Retrieves the value associated with the specified key.
|
|
306
|
-
* @param key - The key to retrieve the value for.
|
|
307
|
-
* @returns The value associated with the key, or undefined if the key does not exist.
|
|
308
|
-
*/
|
|
309
|
-
get(key: TKey): TValue | undefined;
|
|
310
|
-
/**
|
|
311
|
-
* Sets the value for the specified key.
|
|
312
|
-
* @param key - The key to set the value for.
|
|
313
|
-
* @param value - The value to set.
|
|
314
|
-
*/
|
|
315
|
-
set(key: TKey, value: TValue): void;
|
|
316
|
-
/**
|
|
317
|
-
* Checks if the registry contains the specified key.
|
|
318
|
-
* @param key - The key to check.
|
|
319
|
-
* @returns True if the registry contains the key, false otherwise.
|
|
320
|
-
*/
|
|
321
|
-
has(key: TKey): boolean;
|
|
322
|
-
/**
|
|
323
|
-
* Deletes the key-value pair associated with the specified key.
|
|
324
|
-
* @param key - The key to delete.
|
|
325
|
-
* @returns True if the key-value pair was deleted, false if the key does not exist.
|
|
326
|
-
*/
|
|
327
|
-
delete(key: TKey): boolean;
|
|
328
|
-
/**
|
|
329
|
-
* Clears all key-value pairs from the registry.
|
|
330
|
-
*/
|
|
331
|
-
clear(): void;
|
|
332
|
-
/**
|
|
333
|
-
* Gets the number of key-value pairs in the registry.
|
|
334
|
-
*/
|
|
335
|
-
get size(): number;
|
|
336
|
-
/**
|
|
337
|
-
* Gets an iterator for the keys in the registry.
|
|
338
|
-
*/
|
|
339
|
-
get keys(): IterableIterator<TKey>;
|
|
340
|
-
/**
|
|
341
|
-
* Gets an iterator for the values in the registry.
|
|
342
|
-
*/
|
|
343
|
-
get values(): IterableIterator<TValue>;
|
|
344
|
-
/**
|
|
345
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
346
|
-
*/
|
|
347
|
-
get entries(): IterableIterator<[TKey, TValue]>;
|
|
348
|
-
/**
|
|
349
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
350
|
-
* @param callbackfn - The function to execute for each key-value pair.
|
|
351
|
-
* @param thisArg - Optional value to use as `this` when executing the callback function.
|
|
352
|
-
*/
|
|
353
|
-
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void;
|
|
354
|
-
/**
|
|
355
|
-
* Returns an iterator for the entries of the registry.
|
|
356
|
-
* @returns An iterator that yields key-value pairs of type [TKey, TValue].
|
|
357
|
-
*/
|
|
358
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
359
|
-
/**
|
|
360
|
-
* Converts a BaseRegistry instance to an object.
|
|
361
|
-
* @param registry The BaseRegistry instance to convert.
|
|
362
|
-
* @returns An object representing the key-value pairs in the registry.
|
|
363
|
-
*/
|
|
364
|
-
toObject(): Record<string | number | symbol, TValue>;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Represents a generic queue data structure.
|
|
369
|
-
* @template T The type of elements stored in the queue.
|
|
370
|
-
*/
|
|
371
|
-
declare class Queue<T> implements QueueType<T> {
|
|
372
|
-
private readonly _queue;
|
|
373
|
-
/**
|
|
374
|
-
* Creates a new instance of the Queue class.
|
|
375
|
-
* @param _queue Optional initial array of elements.
|
|
376
|
-
*/
|
|
377
|
-
constructor(_queue?: T[]);
|
|
378
|
-
/**
|
|
379
|
-
* Gets the number of elements in the queue.
|
|
380
|
-
*/
|
|
381
|
-
get length(): number;
|
|
382
|
-
/**
|
|
383
|
-
* Removes and returns the first element in the queue.
|
|
384
|
-
* @returns The first element in the queue, or undefined if the queue is empty.
|
|
385
|
-
*/
|
|
386
|
-
dequeue(): T | undefined;
|
|
387
|
-
/**
|
|
388
|
-
* Adds an element to the end of the queue.
|
|
389
|
-
* @param value The element to add to the queue.
|
|
390
|
-
* @returns The new length of the queue.
|
|
391
|
-
*/
|
|
392
|
-
enqueue(value: T): number;
|
|
393
|
-
/**
|
|
394
|
-
* Returns the first element in the queue without removing it.
|
|
395
|
-
* @returns The first element in the queue.
|
|
396
|
-
*/
|
|
397
|
-
peek(): T;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Represents a stack data structure with proper memory management.
|
|
402
|
-
* @template T The type of elements in the stack.
|
|
403
|
-
*/
|
|
404
|
-
declare class Stack<T> implements StackType<T> {
|
|
405
|
-
private _stack;
|
|
406
|
-
private _disposed;
|
|
407
|
-
/**
|
|
408
|
-
* Creates a new instance of the Stack class.
|
|
409
|
-
* @param _stack An optional array to initialize the stack.
|
|
410
|
-
*/
|
|
411
|
-
constructor(_stack?: T[]);
|
|
412
|
-
/**
|
|
413
|
-
* Check if the stack has been disposed
|
|
414
|
-
*/
|
|
415
|
-
private checkDisposed;
|
|
416
|
-
/**
|
|
417
|
-
* Gets the number of elements in the stack.
|
|
418
|
-
*/
|
|
419
|
-
get length(): number;
|
|
420
|
-
/**
|
|
421
|
-
* Returns the top element of the stack without removing it.
|
|
422
|
-
* @returns The top element of the stack.
|
|
423
|
-
*/
|
|
424
|
-
peek(): T;
|
|
425
|
-
/**
|
|
426
|
-
* Removes and returns the top element of the stack.
|
|
427
|
-
* @returns The top element of the stack, or undefined if the stack is empty.
|
|
428
|
-
*/
|
|
429
|
-
pop(): T | undefined;
|
|
430
|
-
/**
|
|
431
|
-
* Adds an element to the top of the stack.
|
|
432
|
-
* @param value The element to be added to the stack.
|
|
433
|
-
* @returns The new length of the stack.
|
|
434
|
-
*/
|
|
435
|
-
push(value: T): number;
|
|
436
|
-
/**
|
|
437
|
-
* Swaps the positions of the top two elements in the stack.
|
|
438
|
-
*/
|
|
439
|
-
swap(): void;
|
|
440
|
-
/**
|
|
441
|
-
* Returns the elements of the stack as an array in reverse order.
|
|
442
|
-
*
|
|
443
|
-
* @returns An array containing the elements of the stack in reverse order.
|
|
444
|
-
*/
|
|
445
|
-
asArray(): T[];
|
|
446
|
-
/**
|
|
447
|
-
* Clears all elements from the stack
|
|
448
|
-
*/
|
|
449
|
-
clear(): void;
|
|
450
|
-
/**
|
|
451
|
-
* Properly dispose of the stack and clean up memory
|
|
452
|
-
*/
|
|
453
|
-
dispose(): void;
|
|
454
|
-
/**
|
|
455
|
-
* Check if the stack has been disposed
|
|
456
|
-
*/
|
|
457
|
-
isDisposed(): boolean;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Represents a cache implementation that stores key-value pairs.
|
|
462
|
-
* @template TValue The type of values stored in the cache.
|
|
463
|
-
*/
|
|
464
|
-
declare class Cache<TValue> implements CacheType<TValue> {
|
|
465
|
-
private readonly _maxCacheSize;
|
|
466
|
-
/**
|
|
467
|
-
* The registry that stores the key-value pairs.
|
|
468
|
-
*/
|
|
469
|
-
private readonly _registry;
|
|
470
|
-
/**
|
|
471
|
-
* The queue that keeps track of the keys in the cache.
|
|
472
|
-
*/
|
|
473
|
-
private readonly _keyQueue;
|
|
474
|
-
type: Readonly<string>;
|
|
475
|
-
/**
|
|
476
|
-
* Options for the cache.
|
|
477
|
-
*/
|
|
478
|
-
options: Readonly<Record<string, unknown>>;
|
|
479
|
-
/**
|
|
480
|
-
* Creates a new instance of the Cache class.
|
|
481
|
-
* @param _maxCacheSize The maximum size of the cache.
|
|
482
|
-
*/
|
|
483
|
-
constructor(_maxCacheSize: number);
|
|
484
|
-
/**
|
|
485
|
-
* Gets the maximum size of the cache.
|
|
486
|
-
*/
|
|
487
|
-
get maxCacheSize(): number;
|
|
488
|
-
/**
|
|
489
|
-
* Generates a hash key based on the given namespace and value.
|
|
490
|
-
* @param namespace The namespace for the key.
|
|
491
|
-
* @param value The value for the key.
|
|
492
|
-
* @returns The generated hash key.
|
|
493
|
-
*/
|
|
494
|
-
getHashKey(namespace: string, value: string): string;
|
|
495
|
-
/**
|
|
496
|
-
* Gets the value associated with the specified key.
|
|
497
|
-
* @param key The key to retrieve the value for.
|
|
498
|
-
* @returns The value associated with the key, or undefined if the key does not exist in the cache.
|
|
499
|
-
*/
|
|
500
|
-
get(key: string): TValue | undefined;
|
|
501
|
-
/**
|
|
502
|
-
* Sets the value for the specified key in the cache.
|
|
503
|
-
* @param key The key to set the value for.
|
|
504
|
-
* @param value The value to set.
|
|
505
|
-
*/
|
|
506
|
-
set(key: string, value: TValue): void;
|
|
507
|
-
/**
|
|
508
|
-
* Checks if the cache contains the specified key.
|
|
509
|
-
* @param key The key to check.
|
|
510
|
-
* @returns True if the cache contains the key, false otherwise.
|
|
511
|
-
*/
|
|
512
|
-
has(key: string): boolean;
|
|
513
|
-
/**
|
|
514
|
-
* Deletes the value associated with the specified key from the cache.
|
|
515
|
-
* @param key The key to delete.
|
|
516
|
-
* @returns True if the value was successfully deleted, false otherwise.
|
|
517
|
-
*/
|
|
518
|
-
delete(key: string): boolean;
|
|
519
|
-
/**
|
|
520
|
-
* Clears the cache, removing all key-value pairs.
|
|
521
|
-
*/
|
|
522
|
-
clear(): void;
|
|
523
|
-
/**
|
|
524
|
-
* Gets the number of key-value pairs in the cache.
|
|
525
|
-
*/
|
|
526
|
-
get size(): number;
|
|
527
|
-
/**
|
|
528
|
-
* Gets an iterator for the keys in the cache.
|
|
529
|
-
*/
|
|
530
|
-
get keys(): IterableIterator<string>;
|
|
531
|
-
/**
|
|
532
|
-
* Gets an iterator for the values in the cache.
|
|
533
|
-
*/
|
|
534
|
-
get values(): IterableIterator<TValue>;
|
|
535
|
-
/**
|
|
536
|
-
* Gets an iterator for the entries (key-value pairs) in the cache.
|
|
537
|
-
*/
|
|
538
|
-
get entries(): IterableIterator<[string, TValue]>;
|
|
539
|
-
/**
|
|
540
|
-
* Executes a provided function once for each key-value pair in the cache.
|
|
541
|
-
* @param callbackfn The function to execute for each key-value pair.
|
|
542
|
-
* @param thisArg The value to use as `this` when executing the callback function.
|
|
543
|
-
*/
|
|
544
|
-
forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: TValue): void;
|
|
545
|
-
/**
|
|
546
|
-
* Returns an iterator for the entries (key-value pairs) in the cache.
|
|
547
|
-
*/
|
|
548
|
-
[Symbol.iterator](): IterableIterator<[string, TValue]>;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Represents the options for evaluating expressions.
|
|
553
|
-
*/
|
|
554
|
-
type EvalOptions = Record<string, unknown> | {
|
|
555
|
-
caseInsensitive: false;
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
type EvalLookup = (key: unknown, thisArg?: unknown, options?: EvalOptions) => unknown;
|
|
559
|
-
|
|
560
|
-
interface EvalScopeOptions {
|
|
561
|
-
global?: boolean;
|
|
562
|
-
caseInsensitive?: boolean;
|
|
563
|
-
namespace?: string;
|
|
564
|
-
thisArg?: unknown;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Represents an evaluation scope.
|
|
568
|
-
*/
|
|
569
|
-
declare class EvalScope {
|
|
570
|
-
type: string;
|
|
571
|
-
private _context;
|
|
572
|
-
private _options;
|
|
573
|
-
/**
|
|
574
|
-
* Gets the context of the evaluation scope.
|
|
575
|
-
* @returns The context object.
|
|
576
|
-
*/
|
|
577
|
-
get context(): Context;
|
|
578
|
-
/**
|
|
579
|
-
* Gets the options for evaluating the scope.
|
|
580
|
-
* @returns The evaluation options.
|
|
581
|
-
*/
|
|
582
|
-
get options(): EvalScopeOptions;
|
|
583
|
-
/**
|
|
584
|
-
* Creates a new instance of EvalScope.
|
|
585
|
-
* @param context - The context of the evaluation scope.
|
|
586
|
-
* @param options - The options for evaluating the scope.
|
|
587
|
-
*/
|
|
588
|
-
constructor(context?: Context, options?: EvalScopeOptions);
|
|
589
|
-
/**
|
|
590
|
-
* Creates an instance of EvalScope from the given context and options.
|
|
591
|
-
*
|
|
592
|
-
* @param context - The context object.
|
|
593
|
-
* @param options - The options object.
|
|
594
|
-
* @returns An instance of EvalScope.
|
|
595
|
-
*/
|
|
596
|
-
static fromObject(context?: Context, options?: EvalScopeOptions): EvalScope;
|
|
597
|
-
/**
|
|
598
|
-
* Gets the value of the specified key.
|
|
599
|
-
* @param key - The key to retrieve the value for.
|
|
600
|
-
* @returns The value of the specified key, or undefined if the key is not found.
|
|
601
|
-
*/
|
|
602
|
-
get(key: unknown): unknown | undefined;
|
|
603
|
-
/**
|
|
604
|
-
* Sets the value of the specified key.
|
|
605
|
-
* @param key - The key to set the value for.
|
|
606
|
-
* @param value - The value to set.
|
|
607
|
-
*/
|
|
608
|
-
set(key: string, value: unknown): void;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Represents the evaluation context for the code execution.
|
|
613
|
-
*/
|
|
614
|
-
declare class EvalContext {
|
|
615
|
-
type: string;
|
|
616
|
-
private _original;
|
|
617
|
-
private _priorScopes;
|
|
618
|
-
private _scopes;
|
|
619
|
-
private _lookups;
|
|
620
|
-
private _options;
|
|
621
|
-
/**
|
|
622
|
-
* Gets the original registry.
|
|
623
|
-
*/
|
|
624
|
-
get original(): Context;
|
|
625
|
-
/**
|
|
626
|
-
* Gets the scopes registry.
|
|
627
|
-
*/
|
|
628
|
-
get priorScopes(): EvalScope[];
|
|
629
|
-
/**
|
|
630
|
-
* Gets the scopes registry.
|
|
631
|
-
*/
|
|
632
|
-
get scopes(): Readonly<Stack<Context>>;
|
|
633
|
-
/**
|
|
634
|
-
* Gets the lookups registry.
|
|
635
|
-
*/
|
|
636
|
-
get lookups(): EvalLookup[];
|
|
637
|
-
/**
|
|
638
|
-
* Gets the evaluation options.
|
|
639
|
-
*/
|
|
640
|
-
get options(): EvalOptions;
|
|
641
|
-
/**
|
|
642
|
-
* Creates a new instance of EvalContext.
|
|
643
|
-
* @param original - The original registry or an object to create a registry from.
|
|
644
|
-
* @param options - The evaluation options.
|
|
645
|
-
*/
|
|
646
|
-
constructor(original: Context, options: EvalOptions);
|
|
647
|
-
/**
|
|
648
|
-
* Converts the given context to an instance of EvalContext.
|
|
649
|
-
* @param context - The context to convert.
|
|
650
|
-
* @param options - The evaluation options.
|
|
651
|
-
* @returns The converted EvalContext instance.
|
|
652
|
-
*/
|
|
653
|
-
static fromContext(context?: EvalContext | Context | undefined, options?: EvalOptions): EvalContext;
|
|
654
|
-
/**
|
|
655
|
-
* Gets the value associated with the specified key from the evaluation context.
|
|
656
|
-
* @param key - The key to retrieve the value for.
|
|
657
|
-
* @returns The value associated with the key, or undefined if not found.
|
|
658
|
-
*/
|
|
659
|
-
get(key: unknown): unknown | undefined;
|
|
660
|
-
/**
|
|
661
|
-
* Retrieves the `this` value of the specified key from the evaluation context.
|
|
662
|
-
* The value is searched in the original context, prior scopes, and lookup functions.
|
|
663
|
-
* @param key - The key to retrieve the value for.
|
|
664
|
-
* @returns The `this` value associated with the key, or undefined if not found.
|
|
665
|
-
*/
|
|
666
|
-
getThis(key: unknown): unknown | undefined;
|
|
667
|
-
/**
|
|
668
|
-
* Retrieves the value associated with the specified key from the evaluation context.
|
|
669
|
-
*
|
|
670
|
-
* @param key - The key to retrieve the value for.
|
|
671
|
-
* @returns The value associated with the key, or undefined if the key is not found.
|
|
672
|
-
*/
|
|
673
|
-
getKey(key: string | number | symbol): string | number | symbol | undefined;
|
|
674
|
-
/**
|
|
675
|
-
* Sets a key-value pair in the context.
|
|
676
|
-
* If the original context is a Registry, the key-value pair is set using the Registry's set method.
|
|
677
|
-
* If the original context is an Object, the key-value pair is set directly on the object.
|
|
678
|
-
* @param key - The key of the pair.
|
|
679
|
-
* @param value - The value of the pair.
|
|
680
|
-
*/
|
|
681
|
-
set(key: unknown, value: unknown): void;
|
|
682
|
-
/**
|
|
683
|
-
* Pushes a context to the scope stack.
|
|
684
|
-
* @param context - The context to push.
|
|
685
|
-
* @param options - The evaluation options.
|
|
686
|
-
*/
|
|
687
|
-
push(context: Context, options?: EvalOptions): void;
|
|
688
|
-
/**
|
|
689
|
-
* Pops a context from the scope stack.
|
|
690
|
-
*/
|
|
691
|
-
pop(): void;
|
|
692
|
-
/**
|
|
693
|
-
* Converts the EvalContext instance to an object representation.
|
|
694
|
-
* If the original value is an instance of Registry, it converts it to an object using the toObject method of the registry.
|
|
695
|
-
* If the original value is an object, it returns the original object.
|
|
696
|
-
* @returns The object representation of the EvalContext instance.
|
|
697
|
-
*/
|
|
698
|
-
toObject(): Record<string | number | symbol, unknown> | undefined;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
interface EvalTraceItem {
|
|
702
|
-
start?: number;
|
|
703
|
-
end?: number;
|
|
704
|
-
type: string;
|
|
705
|
-
expression?: string;
|
|
706
|
-
value: unknown;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Represents a trace of evaluation for a specific code execution.
|
|
710
|
-
*/
|
|
711
|
-
declare class EvalTrace extends Array<EvalTraceItem> {
|
|
712
|
-
/**
|
|
713
|
-
* Adds a new trace item to the evaluation trace.
|
|
714
|
-
* @param node - The AST node associated with the trace item.
|
|
715
|
-
* @param value - The value of the evaluated expression.
|
|
716
|
-
* @param expression - The expression being evaluated.
|
|
717
|
-
*/
|
|
718
|
-
add(node: AnyNode, value?: unknown, expression?: string): void;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
type UnknownValue = unknown | Promise<unknown>;
|
|
722
|
-
/**
|
|
723
|
-
* Represents the result of an evaluation.
|
|
724
|
-
*/
|
|
725
|
-
declare class EvalResult {
|
|
726
|
-
private _stack;
|
|
727
|
-
private _value?;
|
|
728
|
-
private _error?;
|
|
729
|
-
private _errorMessage?;
|
|
730
|
-
private _isError?;
|
|
731
|
-
private _isSuccess?;
|
|
732
|
-
private _isUndefined?;
|
|
733
|
-
private _trace;
|
|
734
|
-
private _context;
|
|
735
|
-
private _startDate?;
|
|
736
|
-
private _endDate?;
|
|
737
|
-
private _expression?;
|
|
738
|
-
/**
|
|
739
|
-
* Gets the stack of evaluated values.
|
|
740
|
-
*/
|
|
741
|
-
get stack(): Stack<UnknownValue>;
|
|
742
|
-
/**
|
|
743
|
-
* Gets the evaluated value.
|
|
744
|
-
*/
|
|
745
|
-
get value(): UnknownValue | undefined;
|
|
746
|
-
/**
|
|
747
|
-
* Gets the error that occurred during evaluation.
|
|
748
|
-
*/
|
|
749
|
-
get error(): unknown | undefined;
|
|
750
|
-
/**
|
|
751
|
-
* Gets the error message associated with the evaluation error.
|
|
752
|
-
*/
|
|
753
|
-
get errorMessage(): string | undefined;
|
|
754
|
-
/**
|
|
755
|
-
* Gets whether the evaluation resulted in an error.
|
|
756
|
-
*/
|
|
757
|
-
get isError(): boolean | undefined;
|
|
758
|
-
/**
|
|
759
|
-
* Gets whether the evaluation was successful.
|
|
760
|
-
*/
|
|
761
|
-
get isSuccess(): boolean | undefined;
|
|
762
|
-
/**
|
|
763
|
-
* Gets whether the evaluated value is undefined.
|
|
764
|
-
*/
|
|
765
|
-
get isUndefined(): boolean | undefined;
|
|
766
|
-
/**
|
|
767
|
-
* Gets the trace of evaluated values.
|
|
768
|
-
*/
|
|
769
|
-
get trace(): EvalTrace;
|
|
770
|
-
/**
|
|
771
|
-
* Gets the evaluation context.
|
|
772
|
-
*/
|
|
773
|
-
get context(): EvalContext;
|
|
774
|
-
/**
|
|
775
|
-
* Gets the evaluation options.
|
|
776
|
-
*/
|
|
777
|
-
get options(): EvalOptions;
|
|
778
|
-
/**
|
|
779
|
-
* Gets the duration of the evaluation result.
|
|
780
|
-
* @returns The duration in milliseconds.
|
|
781
|
-
*/
|
|
782
|
-
get duration(): number | undefined;
|
|
783
|
-
/**
|
|
784
|
-
* Gets the expression associated with the evaluation result.
|
|
785
|
-
* @returns The expression as a string, or undefined if no expression is associated.
|
|
786
|
-
*/
|
|
787
|
-
get expression(): string | undefined;
|
|
788
|
-
/**
|
|
789
|
-
* Sets the expression for the evaluation result.
|
|
790
|
-
*
|
|
791
|
-
* @param value - The expression to be set.
|
|
792
|
-
*/
|
|
793
|
-
set expression(value: string | undefined);
|
|
794
|
-
/**
|
|
795
|
-
* Creates a new instance of EvalResult.
|
|
796
|
-
* @param trace The trace of evaluated values.
|
|
797
|
-
* @param context The evaluation context.
|
|
798
|
-
*/
|
|
799
|
-
constructor(context: EvalContext);
|
|
800
|
-
/**
|
|
801
|
-
* Starts the evaluation process.
|
|
802
|
-
*/
|
|
803
|
-
start(): void;
|
|
804
|
-
/**
|
|
805
|
-
* Stops the evaluation and records the end date.
|
|
806
|
-
*/
|
|
807
|
-
stop(): number | undefined;
|
|
808
|
-
/**
|
|
809
|
-
* Sets the success value of the evaluation result.
|
|
810
|
-
*
|
|
811
|
-
* @param value The value to set as the success value.
|
|
812
|
-
* @returns void
|
|
813
|
-
*/
|
|
814
|
-
setSuccess(value: UnknownValue): void;
|
|
815
|
-
/**
|
|
816
|
-
* Sets the failure state of the evaluation result.
|
|
817
|
-
* @param error The error object associated with the failure.
|
|
818
|
-
*/
|
|
819
|
-
setFailure(error: unknown): void;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
/**
|
|
823
|
-
* Represents the evaluation state, which includes the context, result, and options.
|
|
824
|
-
*/
|
|
825
|
-
declare class EvalState {
|
|
826
|
-
private _context;
|
|
827
|
-
private _result;
|
|
828
|
-
private _options;
|
|
829
|
-
private _isAsync;
|
|
830
|
-
/**
|
|
831
|
-
* Gets the evaluation context.
|
|
832
|
-
*/
|
|
833
|
-
get context(): EvalContext | undefined;
|
|
834
|
-
/**
|
|
835
|
-
* Gets the evaluation result.
|
|
836
|
-
*/
|
|
837
|
-
get result(): EvalResult;
|
|
838
|
-
/**
|
|
839
|
-
* Gets the evaluation options.
|
|
840
|
-
*/
|
|
841
|
-
get options(): EvalOptions | undefined;
|
|
842
|
-
/**
|
|
843
|
-
* Gets whether the evaluation is asynchronous.
|
|
844
|
-
*/
|
|
845
|
-
get isAsync(): boolean | undefined;
|
|
846
|
-
/**
|
|
847
|
-
* Represents the state of an evaluation.
|
|
848
|
-
* @param context The evaluation context.
|
|
849
|
-
* @param result The evaluation result.
|
|
850
|
-
* @param options The evaluation options.
|
|
851
|
-
* @param isAsync Indicates whether the evaluation is asynchronous.
|
|
852
|
-
*/
|
|
853
|
-
constructor(context: EvalContext | undefined, result: EvalResult, options?: EvalOptions, isAsync?: boolean);
|
|
854
|
-
/**
|
|
855
|
-
* Creates an instance of EvalState from a given context, options, and async flag.
|
|
856
|
-
*
|
|
857
|
-
* @param context - The evaluation context or context object.
|
|
858
|
-
* @param options - The evaluation options.
|
|
859
|
-
* @param isAsync - A flag indicating whether the evaluation is asynchronous.
|
|
860
|
-
* @returns The created EvalState instance.
|
|
861
|
-
*/
|
|
862
|
-
static fromContext(context?: EvalContext | Context, options?: EvalOptions, isAsync?: boolean): EvalState;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
declare const defaultParserOptions: ParserOptions;
|
|
866
|
-
|
|
867
|
-
type BaseContext = Record<string | number | symbol, unknown>;
|
|
868
|
-
type Context = Registry<unknown, unknown> | BaseContext;
|
|
869
|
-
declare function isRegistryContext(context?: Context): boolean;
|
|
870
|
-
/**
|
|
871
|
-
* Converts a context object to a Context instance.
|
|
872
|
-
* @param context - The context object to convert.
|
|
873
|
-
* @param options - Optional evaluation options.
|
|
874
|
-
* @returns The converted Context instance.
|
|
875
|
-
*/
|
|
876
|
-
declare const fromContext: (context?: Context, options?: EvalOptions) => Context;
|
|
877
|
-
/**
|
|
878
|
-
* Retrieves the value associated with the specified key from the given context.
|
|
879
|
-
* If the context is an instance of Registry, it uses the `get` method to retrieve the value.
|
|
880
|
-
* If the context is an object, it accesses the value using the key as a property name.
|
|
881
|
-
* If the context is neither an instance of Registry nor an object, it returns undefined.
|
|
882
|
-
*
|
|
883
|
-
* @param context The context from which to retrieve the value.
|
|
884
|
-
* @param key The key associated with the value to retrieve.
|
|
885
|
-
* @returns The value associated with the specified key, or undefined if not found.
|
|
886
|
-
*/
|
|
887
|
-
declare const getContextValue: (context?: Context, key?: unknown) => unknown;
|
|
888
|
-
/**
|
|
889
|
-
* Retrieves the key from the given context object.
|
|
890
|
-
* If the context is an instance of Registry, it searches for the key in a case-insensitive manner if specified.
|
|
891
|
-
* If the context is an instance of Object, it uses the getKeyValue function to retrieve the key-value pair.
|
|
892
|
-
* @param context - The context object.
|
|
893
|
-
* @param key - The key to retrieve.
|
|
894
|
-
* @param caseInsensitive - Specifies whether the search should be case-insensitive (only applicable for Registry instances).
|
|
895
|
-
* @returns The retrieved key, or undefined if the key is not found.
|
|
896
|
-
*/
|
|
897
|
-
declare const getContextKey: (context: Context, key: string | number | symbol, caseInsensitive: boolean) => string | number | symbol | undefined;
|
|
898
|
-
|
|
899
|
-
interface CacheType<TValue> extends RegistryType<string, TValue> {
|
|
900
|
-
type: Readonly<'Cache' | string>;
|
|
901
|
-
maxCacheSize: number;
|
|
902
|
-
getHashKey: (namespace: string, value: string) => string;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
interface RecursiveVisitorState {
|
|
906
|
-
scope: Registry<unknown, unknown>;
|
|
907
|
-
result: RecursiveVisitorResult<unknown | undefined>;
|
|
908
|
-
option: RecursiveVisitorOptions;
|
|
909
|
-
beforeVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>;
|
|
910
|
-
afterVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>;
|
|
911
|
-
}
|
|
912
|
-
interface RecursiveVisitorOptions {
|
|
913
|
-
trackTime?: boolean;
|
|
914
|
-
resultType?: 'stack' | 'registry';
|
|
915
|
-
}
|
|
916
|
-
interface RecursiveVisitorContext {
|
|
917
|
-
placeholder?: unknown;
|
|
918
|
-
}
|
|
919
|
-
declare enum RecursiveVisitorResultType {
|
|
920
|
-
Stack = 0,
|
|
921
|
-
Registry = 1
|
|
922
|
-
}
|
|
923
|
-
type RecursiveVisitorResult<TValue> = RecursiveVisitorStackResult<TValue> | RecursiveVisitorRegistryResult<TValue>;
|
|
924
|
-
interface RecursiveVisitorStackResult<TValue> {
|
|
925
|
-
type: 'stack';
|
|
926
|
-
stack: StackType<TValue>;
|
|
927
|
-
}
|
|
928
|
-
interface RecursiveVisitorRegistryResult<TValue> {
|
|
929
|
-
type: 'registry';
|
|
930
|
-
registry: BaseRegistry<AnyNode, TValue>;
|
|
931
|
-
}
|
|
932
|
-
type AggregateType = {
|
|
933
|
-
Expression: acorn.Expression;
|
|
934
|
-
Statement: acorn.Statement;
|
|
935
|
-
Function: acorn.Function;
|
|
936
|
-
Class: acorn.Class;
|
|
937
|
-
Pattern: acorn.Pattern;
|
|
938
|
-
ForInit: acorn.VariableDeclaration | acorn.Expression;
|
|
939
|
-
};
|
|
940
|
-
type RecursiveVisitor<TState> = (node: acorn.AnyNode, state: TState, callback: WalkerCallback<TState>) => void;
|
|
941
|
-
type RecursiveAggregateVisitor<TState> = (node: AggregateType, state: TState, callback: WalkerCallback<TState>) => void;
|
|
942
|
-
|
|
943
|
-
/**
|
|
944
|
-
* @description
|
|
945
|
-
* Service for parsing expressions and returning ES6/ES2020 AST.
|
|
946
|
-
* Implements OnDestroy for proper memory cleanup.
|
|
947
|
-
*/
|
|
948
|
-
declare class ParserService implements OnDestroy {
|
|
949
|
-
private _parserOptions;
|
|
950
|
-
private _cache?;
|
|
951
|
-
private _cacheCleanupInterval?;
|
|
952
|
-
private _isDestroyed;
|
|
953
|
-
/**
|
|
954
|
-
* Gets the parser options.
|
|
955
|
-
*/
|
|
956
|
-
get parserOptions(): ParserOptions;
|
|
957
|
-
/**
|
|
958
|
-
* Sets the parser options.
|
|
959
|
-
* @param value The parser options to set.
|
|
960
|
-
*/
|
|
961
|
-
set parserOptions(value: ParserOptions);
|
|
962
|
-
/**
|
|
963
|
-
* Constructs a new instance of the ParserService class.
|
|
964
|
-
*/
|
|
965
|
-
constructor();
|
|
966
|
-
/**
|
|
967
|
-
* Setup periodic cache cleanup to prevent memory leaks
|
|
968
|
-
*/
|
|
969
|
-
private setupCacheCleanup;
|
|
970
|
-
/**
|
|
971
|
-
* Clean up resources to prevent memory leaks
|
|
972
|
-
*/
|
|
973
|
-
ngOnDestroy(): void;
|
|
974
|
-
/**
|
|
975
|
-
* @description
|
|
976
|
-
* Returns acorn version.
|
|
977
|
-
*/
|
|
978
|
-
get version(): string;
|
|
979
|
-
/**
|
|
980
|
-
* Gets the parser options.
|
|
981
|
-
* @returns The parser options.
|
|
982
|
-
*/
|
|
983
|
-
get options(): ParserOptions;
|
|
984
|
-
/**
|
|
985
|
-
* @description
|
|
986
|
-
* Parses expression and returns ES6/ES2023 AST.
|
|
987
|
-
* @param expr expression to parse
|
|
988
|
-
* @param options optional parser options
|
|
989
|
-
* @returns The parsed AST (Abstract Syntax Tree).
|
|
990
|
-
*/
|
|
991
|
-
parse(expr: string, options?: ParserOptions): Program | AnyNode | Expression | undefined;
|
|
992
|
-
private fromCacheOrParse;
|
|
993
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ParserService, never>;
|
|
994
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ParserService>;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
/**
|
|
998
|
-
* Base class for evaluation.
|
|
999
|
-
*/
|
|
1000
|
-
declare abstract class BaseEval {
|
|
1001
|
-
protected parserService: ParserService;
|
|
1002
|
-
private _parserOptions;
|
|
1003
|
-
constructor(parserService: ParserService);
|
|
1004
|
-
/**
|
|
1005
|
-
* Gets the parser options.
|
|
1006
|
-
*/
|
|
1007
|
-
protected get parserOptions(): ParserOptions;
|
|
1008
|
-
/**
|
|
1009
|
-
* Sets the parser options.
|
|
1010
|
-
* @param value The parser options to set.
|
|
1011
|
-
*/
|
|
1012
|
-
protected set parserOptions(value: ParserOptions);
|
|
1013
|
-
/**
|
|
1014
|
-
* Parses the given expression into an abstract syntax tree (AST).
|
|
1015
|
-
* @param expression - The expression to parse.
|
|
1016
|
-
* @returns The parsed AST.
|
|
1017
|
-
*/
|
|
1018
|
-
protected parse(expression: string | AnyNode | undefined): AnyNode | undefined;
|
|
1019
|
-
/**
|
|
1020
|
-
* Creates an instance of EvalState.
|
|
1021
|
-
* @param context - The evaluation context or context object.
|
|
1022
|
-
* @param options - The evaluation options.
|
|
1023
|
-
* @returns The created EvalState instance.
|
|
1024
|
-
*/
|
|
1025
|
-
createState(context?: EvalContext | Context, options?: EvalOptions): EvalState;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* Service for evaluating and parsing expressions with proper memory management.
|
|
1030
|
-
*/
|
|
1031
|
-
declare class EvalService extends BaseEval implements OnDestroy {
|
|
1032
|
-
protected parserService: ParserService;
|
|
1033
|
-
private _isDestroyed;
|
|
1034
|
-
private _activeContexts;
|
|
1035
|
-
private _activeStates;
|
|
1036
|
-
/**
|
|
1037
|
-
* Constructs a new instance of the EvalService class.
|
|
1038
|
-
* @param parserService The parser service used for parsing expressions.
|
|
1039
|
-
*/
|
|
1040
|
-
constructor(parserService: ParserService);
|
|
1041
|
-
/**
|
|
1042
|
-
* Override createState to track active contexts and states for cleanup
|
|
1043
|
-
*/
|
|
1044
|
-
createState(context?: EvalContext | Context, options?: EvalOptions): EvalState;
|
|
1045
|
-
/**
|
|
1046
|
-
* Clean up resources to prevent memory leaks
|
|
1047
|
-
*/
|
|
1048
|
-
ngOnDestroy(): void;
|
|
1049
|
-
/**
|
|
1050
|
-
* Evaluates the given expression.
|
|
1051
|
-
* @param expression The expression to evaluate.
|
|
1052
|
-
* @param context The evaluation context.
|
|
1053
|
-
* @param options The evaluation options.
|
|
1054
|
-
* @returns The result of the evaluation.
|
|
1055
|
-
*/
|
|
1056
|
-
simpleEval(expression: string | AnyNode | undefined, context?: EvalContext | Context, options?: EvalOptions): unknown | undefined;
|
|
1057
|
-
/**
|
|
1058
|
-
* Evaluates an expression using the provided state.
|
|
1059
|
-
*
|
|
1060
|
-
* @param expression - The expression to evaluate.
|
|
1061
|
-
* @param state - The state object containing variables and functions used in the evaluation.
|
|
1062
|
-
* @returns The result of the evaluation.
|
|
1063
|
-
* @throws If an error occurs during evaluation.
|
|
1064
|
-
*/
|
|
1065
|
-
eval(expression: string | AnyNode | undefined, state: EvalState): unknown | undefined;
|
|
1066
|
-
/**
|
|
1067
|
-
* Asynchronously evaluates the given expression.
|
|
1068
|
-
* @param expression The expression to evaluate.
|
|
1069
|
-
* @param context The evaluation context.
|
|
1070
|
-
* @param options The evaluation options.
|
|
1071
|
-
* @returns A promise that resolves to the result of the evaluation.
|
|
1072
|
-
*/
|
|
1073
|
-
simpleEvalAsync(expression: string | AnyNode | undefined, context?: EvalContext | Context, options?: EvalOptions): Promise<unknown | undefined>;
|
|
1074
|
-
/**
|
|
1075
|
-
* Asynchronously evaluates an expression using the provided state.
|
|
1076
|
-
*
|
|
1077
|
-
* @param expression - The expression to evaluate. Can be a string or an AST node.
|
|
1078
|
-
* @param state - The evaluation state.
|
|
1079
|
-
* @returns A promise that resolves to the result of the evaluation.
|
|
1080
|
-
* @throws If an error occurs during evaluation.
|
|
1081
|
-
*/
|
|
1082
|
-
evalAsync(expression: string | AnyNode | undefined, state: EvalState): Promise<unknown | undefined>;
|
|
1083
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<EvalService, never>;
|
|
1084
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<EvalService>;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
* @description
|
|
1089
|
-
* Parses expression and returns ES6/ES2020 AST.
|
|
1090
|
-
* @param expr expression to parse
|
|
1091
|
-
* @param options parser options
|
|
1092
|
-
*/
|
|
1093
|
-
declare const parse: (expr: string, options: ParserOptions) => Program | AnyNode | undefined;
|
|
1094
|
-
/**
|
|
1095
|
-
* @description
|
|
1096
|
-
* Walks through the AST and extracts first expression.
|
|
1097
|
-
* @param expr expression to parse
|
|
1098
|
-
*/
|
|
1099
|
-
declare const extractExpression: (program: Program) => Expression | undefined;
|
|
1100
|
-
|
|
1101
|
-
/**
|
|
1102
|
-
* Evaluates the given node and returns the result.
|
|
1103
|
-
*
|
|
1104
|
-
* @param node The node to evaluate.
|
|
1105
|
-
* @param state The evaluation state.
|
|
1106
|
-
* @returns The result of the evaluation.
|
|
1107
|
-
*/
|
|
1108
|
-
declare const evaluate: (node: AnyNode | undefined, state: EvalState) => unknown | undefined;
|
|
1109
|
-
/**
|
|
1110
|
-
* Asynchronously evaluates the given abstract syntax tree (AST) using the provided evaluation state.
|
|
1111
|
-
* @param ast The abstract syntax tree to evaluate.
|
|
1112
|
-
* @param state The evaluation state.
|
|
1113
|
-
* @returns A promise that resolves to the evaluated value or undefined.
|
|
1114
|
-
*/
|
|
1115
|
-
declare const evaluateAsync: (ast: AnyNode | undefined, state: EvalState) => Promise<unknown | undefined>;
|
|
1116
|
-
|
|
1117
|
-
type stateCallback = (state: EvalState) => unknown;
|
|
1118
|
-
type stateCallbackAsync = (state: EvalState) => Promise<unknown | undefined>;
|
|
1119
|
-
/**
|
|
1120
|
-
* Compiles the given node and returns a function that can be used to evaluate it.
|
|
1121
|
-
*
|
|
1122
|
-
* @param node The node to compile.
|
|
1123
|
-
* @returns A function that takes an `EvalState` and returns the result of evaluating the node.
|
|
1124
|
-
*/
|
|
1125
|
-
declare const compile: (node: AnyNode | undefined) => stateCallback;
|
|
1126
|
-
/**
|
|
1127
|
-
* Compiles the given node asynchronously.
|
|
1128
|
-
*
|
|
1129
|
-
* @param node - The node to compile.
|
|
1130
|
-
* @returns A function that takes an `EvalState` object and returns a `Promise` that resolves to the compiled result.
|
|
1131
|
-
*/
|
|
1132
|
-
declare const compileAsync: (node: AnyNode | undefined) => stateCallbackAsync;
|
|
1133
|
-
/**
|
|
1134
|
-
* Calls the provided function with the given state and returns the result.
|
|
1135
|
-
*
|
|
1136
|
-
* @param fn The function to be called.
|
|
1137
|
-
* @param state The state to be passed to the function.
|
|
1138
|
-
* @returns The result of calling the function.
|
|
1139
|
-
*/
|
|
1140
|
-
declare const call: (fn: stateCallback, state: EvalState) => unknown | undefined;
|
|
1141
|
-
/**
|
|
1142
|
-
* Calls an asynchronous function with the given state and returns a promise that resolves to the result.
|
|
1143
|
-
* @param fn The asynchronous function to call.
|
|
1144
|
-
* @param state The state to pass to the function.
|
|
1145
|
-
* @returns A promise that resolves to the result of the function.
|
|
1146
|
-
*/
|
|
1147
|
-
declare const callAsync: (fn: stateCallbackAsync, state: EvalState) => Promise<unknown | undefined>;
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Finds all nodes of a specific type in the given AST.
|
|
1151
|
-
*
|
|
1152
|
-
* @param ast The AST to search in.
|
|
1153
|
-
* @param searchType The type of nodes to search for.
|
|
1154
|
-
* @returns An array of nodes of the specified type if found, otherwise undefined.
|
|
1155
|
-
*/
|
|
1156
|
-
declare const extract: (node: AnyNode | undefined, searchType: AnyNodeTypes) => AnyNode[] | undefined;
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* CompilerService class that extends BaseEval.
|
|
1160
|
-
* Provides methods for compiling and evaluating expressions with performance caching.
|
|
1161
|
-
*/
|
|
1162
|
-
declare class CompilerService extends BaseEval implements OnDestroy {
|
|
1163
|
-
protected parserService: ParserService;
|
|
1164
|
-
protected evalService: EvalService;
|
|
1165
|
-
private readonly _compilationCache;
|
|
1166
|
-
private readonly _maxCacheSize;
|
|
1167
|
-
private readonly _cacheTTL;
|
|
1168
|
-
private readonly _accessOrder;
|
|
1169
|
-
private _cacheCleanupInterval?;
|
|
1170
|
-
private _isDestroyed;
|
|
1171
|
-
constructor(parserService: ParserService, evalService: EvalService);
|
|
1172
|
-
/**
|
|
1173
|
-
* OnDestroy lifecycle hook for cleanup
|
|
1174
|
-
*/
|
|
1175
|
-
ngOnDestroy(): void;
|
|
1176
|
-
/**
|
|
1177
|
-
* Setup periodic cache cleanup to prevent memory leaks and stale entries
|
|
1178
|
-
*/
|
|
1179
|
-
private setupCacheCleanup;
|
|
1180
|
-
/**
|
|
1181
|
-
* Clean expired entries and enforce cache size limits
|
|
1182
|
-
*/
|
|
1183
|
-
private cleanupCache;
|
|
1184
|
-
/**
|
|
1185
|
-
* Generate cache key for expression
|
|
1186
|
-
*/
|
|
1187
|
-
private generateCacheKey;
|
|
1188
|
-
/**
|
|
1189
|
-
* Update access order for LRU cache
|
|
1190
|
-
*/
|
|
1191
|
-
private updateAccessOrder;
|
|
1192
|
-
/**
|
|
1193
|
-
* Compiles the given expression into a state callback function with caching.
|
|
1194
|
-
* @param expression - The expression to compile.
|
|
1195
|
-
* @returns The compiled state callback function.
|
|
1196
|
-
* @throws Error if there is an error during compilation.
|
|
1197
|
-
*/
|
|
1198
|
-
compile(expression: string | AnyNode | undefined): stateCallback | undefined;
|
|
1199
|
-
/**
|
|
1200
|
-
* Calls the given state callback function with the specified context and options.
|
|
1201
|
-
* @param fn - The state callback function to call.
|
|
1202
|
-
* @param context - The evaluation context or context object.
|
|
1203
|
-
* @param options - The evaluation options.
|
|
1204
|
-
* @returns The result of the evaluation.
|
|
1205
|
-
* @throws Error if there is an error during the evaluation.
|
|
1206
|
-
*/
|
|
1207
|
-
simpleCall(fn: stateCallback | undefined, context?: EvalContext | Context, options?: EvalOptions): unknown;
|
|
1208
|
-
/**
|
|
1209
|
-
* Calls the provided function with the given state.
|
|
1210
|
-
*
|
|
1211
|
-
* @param fn - The function to be called.
|
|
1212
|
-
* @param state - The state to be passed to the function.
|
|
1213
|
-
* @returns The value returned by the function.
|
|
1214
|
-
* @throws If an error occurs during the function call.
|
|
1215
|
-
*/
|
|
1216
|
-
call(fn: stateCallback | undefined, state: EvalState): unknown;
|
|
1217
|
-
/**
|
|
1218
|
-
* Compiles the given expression into an asynchronous state callback function with caching.
|
|
1219
|
-
* @param expression - The expression to compile.
|
|
1220
|
-
* @returns The compiled asynchronous state callback function.
|
|
1221
|
-
* @throws Error if there is an error during compilation.
|
|
1222
|
-
*/
|
|
1223
|
-
compileAsync(expression: string | AnyNode | undefined): stateCallbackAsync | undefined;
|
|
1224
|
-
/**
|
|
1225
|
-
* Calls the given asynchronous state callback function with the specified context and options.
|
|
1226
|
-
* @param fn - The asynchronous state callback function to call.
|
|
1227
|
-
* @param context - The evaluation context or context object.
|
|
1228
|
-
* @param options - The evaluation options.
|
|
1229
|
-
* @returns A promise that resolves to the result of the evaluation.
|
|
1230
|
-
* @throws Error if there is an error during the evaluation.
|
|
1231
|
-
*/
|
|
1232
|
-
simpleCallAsync(fn: stateCallbackAsync | undefined, context?: EvalContext | Context, options?: EvalOptions): Promise<unknown>;
|
|
1233
|
-
/**
|
|
1234
|
-
* Calls the provided asynchronous function with the given state.
|
|
1235
|
-
*
|
|
1236
|
-
* @param fn - The asynchronous function to call.
|
|
1237
|
-
* @param state - The state to pass to the function.
|
|
1238
|
-
* @returns A promise that resolves to the value returned by the function.
|
|
1239
|
-
* @throws If an error occurs during the function call.
|
|
1240
|
-
*/
|
|
1241
|
-
callAsync(fn: stateCallbackAsync | undefined, state: EvalState): Promise<unknown>;
|
|
1242
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<CompilerService, never>;
|
|
1243
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<CompilerService>;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Service responsible for discovering nodes in an abstract syntax tree (AST).
|
|
1248
|
-
*/
|
|
1249
|
-
declare class DiscoveryService extends BaseEval {
|
|
1250
|
-
protected parserService: ParserService;
|
|
1251
|
-
/**
|
|
1252
|
-
* Creates a new instance of the DiscoveryService class.
|
|
1253
|
-
* @param parserService The parser service to be used.
|
|
1254
|
-
*/
|
|
1255
|
-
constructor(parserService: ParserService);
|
|
1256
|
-
/**
|
|
1257
|
-
* Finds all nodes in the AST that match the given expression and search type.
|
|
1258
|
-
* @param expression The expression to search for. Can be a string or an AST node.
|
|
1259
|
-
* @param searchType The type of nodes to search for.
|
|
1260
|
-
* @param options Optional parser options.
|
|
1261
|
-
* @returns An array of nodes that match the search criteria, or undefined if no nodes are found.
|
|
1262
|
-
* @throws If an error occurs during the search process.
|
|
1263
|
-
*/
|
|
1264
|
-
extract(expression: string | AnyNode | undefined, searchType: AnyNodeTypes): AnyNode[] | undefined;
|
|
1265
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DiscoveryService, never>;
|
|
1266
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DiscoveryService>;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
export { BaseRegistry, Cache, CaseInsensitiveRegistry, CompilerService, DiscoveryService, EvalContext, EvalResult, EvalScope, EvalService, EvalState, EvalTrace, ParserService, Queue, RecursiveVisitorResultType, Registry, Stack, call, callAsync, compile, compileAsync, defaultParserOptions, evaluate, evaluateAsync, extract, extractExpression, fromContext, getContextKey, getContextValue, isRegistryContext, parse };
|
|
1270
|
-
export type { AggregateType, AnyNodeTypes, BaseContext, CacheType, Context, EvalLookup, EvalOptions, EvalScopeOptions, EvalTraceItem, ParserOptions, QueueType, RecursiveAggregateVisitor, RecursiveVisitor, RecursiveVisitorContext, RecursiveVisitorOptions, RecursiveVisitorRegistryResult, RecursiveVisitorResult, RecursiveVisitorStackResult, RecursiveVisitorState, RegistryEntries, RegistryOptionType, RegistryType, ScopeOptions, ScopeType, StackType, stateCallback, stateCallbackAsync };
|