@zvenigora/ng-eval-core 0.3.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"zvenigora-ng-eval-core.mjs","sources":["../../../../modules/eval-core/src/lib/internal/classes/common/base-registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/case-insensitive-registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/queue.ts","../../../../modules/eval-core/src/lib/internal/classes/common/stack.ts","../../../../modules/eval-core/src/lib/internal/classes/common/cache.ts","../../../../modules/eval-core/src/lib/internal/visitors/utils.ts","../../../../modules/eval-core/src/lib/internal/classes/common/context.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-context.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-trace.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-result.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-hooks.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/hooks/timing-hook.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-state.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/parser-options.ts","../../../../modules/eval-core/src/lib/internal/visitors/visitor-result.ts","../../../../modules/eval-core/src/lib/internal/visitors/before-visitor.ts","../../../../modules/eval-core/src/lib/internal/visitors/after-visitor.ts","../../../../modules/eval-core/src/lib/internal/interfaces/recursive-visitors.ts","../../../../modules/eval-core/src/lib/internal/visitors/identifier.ts","../../../../modules/eval-core/src/lib/internal/visitors/literal.ts","../../../../modules/eval-core/src/lib/internal/visitors/binary-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/prototype-pollution-guard.ts","../../../../modules/eval-core/src/lib/internal/visitors/property-lookup-cache.ts","../../../../modules/eval-core/src/lib/internal/visitors/member-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/array-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/call-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/import-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/await-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/conditional-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/unary-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/logical-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/this-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/new-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/template-literal.ts","../../../../modules/eval-core/src/lib/internal/visitors/tagged-template-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/object-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/recursive-visitors.ts","../../../../modules/eval-core/src/lib/internal/visitors/assignment-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/update-expression.ts","../../../../modules/eval-core/src/lib/internal/functions/parse.ts","../../../../modules/eval-core/src/lib/internal/functions/evaluate.ts","../../../../modules/eval-core/src/lib/internal/functions/compile.ts","../../../../modules/eval-core/src/lib/internal/functions/extract.ts","../../../../modules/eval-core/src/lib/internal/visitors/arrow-function-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/pattern.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-scope.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/hooks/dependency-tracker.ts","../../../../modules/eval-core/src/lib/actual/services/base-eval.ts","../../../../modules/eval-core/src/lib/actual/services/parser.service.ts","../../../../modules/eval-core/src/lib/actual/services/eval.service.ts","../../../../modules/eval-core/src/lib/actual/services/compiler.service.ts","../../../../modules/eval-core/src/lib/actual/services/discovery.service.ts","../../../../modules/eval-core/src/zvenigora-ng-eval-core.ts"],"sourcesContent":["import { RegistryEntries, RegistryType } from \"../../interfaces\";\r\n\r\n/**\r\n * Represents a registry that stores key-value pairs.\r\n */\r\nexport class BaseRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n private readonly _registry: Map<TKey, TValue> = new Map();\r\n\r\n type: Readonly<string> = 'BaseRegistry';\r\n\r\n /**\r\n * Options for the base registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new Registry instance.\r\n * @param entries - Optional array of key-value pairs to initialize the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null) {\r\n if (entries && Array.isArray(entries)) {\r\n for (const [key, value] of entries) {\r\n this.set(key, value);\r\n }\r\n } else if (entries && typeof entries === 'object') {\r\n for (const [key, value] of Object.entries(entries)) {\r\n this.set(key as TKey, value as TValue);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new Registry instance from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new Registry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): BaseRegistry<TKey, TValue> {\r\n const registry = new BaseRegistry<TKey, TValue>();\r\n for (const [key, value] of Object.entries(object)) {\r\n registry.set(key as TKey, value as TValue);\r\n }\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist.\r\n */\r\n public get(key: TKey): TValue | undefined{\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key to check.\r\n * @returns True if the registry contains the key, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key to delete.\r\n * @returns True if the key-value pair was deleted, false if the key does not exist.\r\n */\r\n public delete(key: TKey): boolean {\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this._registry.keys();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this._registry.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries();\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n * @param thisArg - Optional value to use as `this` when executing the callback function.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [TKey, TValue].\r\n */\r\n public [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries();\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n}\r\n","import { RegistryEntries, RegistryType } from \"../../interfaces\";\r\n\r\n// some code here:\r\n// https://stackoverflow.com/questions/50019920/javascript-map-key-value-pairs-case-insensitive-search\r\n\r\n/**\r\n * Represents a case-insensitive registry that maps keys to values.\r\n */\r\nexport class CaseInsensitiveRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n\r\n private readonly registry: Map<TKey, TValue> = new Map();\r\n private keysMap = new Map<TKey, TKey>();\r\n\r\n type: Readonly<string> = 'CaseInsensitiveRegistry';\r\n\r\n /**\r\n * Options for the registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: true\r\n };\r\n\r\n /**\r\n * Creates a new instance of CaseInsensitiveRegistry.\r\n * @param entries - Optional initial entries to populate the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null) {\r\n if (entries && Array.isArray(entries)) {\r\n for (const [key, value] of entries) {\r\n this.set(key, value);\r\n }\r\n } else if (entries && typeof entries === 'object') {\r\n for (const [key, value] of Object.entries(entries)) {\r\n this.set(key as TKey, value as TValue);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new CaseInsensitiveRegistry from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new CaseInsensitiveRegistry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): CaseInsensitiveRegistry<TKey, TValue> {\r\n const registry = new CaseInsensitiveRegistry<TKey, TValue>();\r\n for (const [key, value] of Object.entries(object)) {\r\n registry.set(key as TKey, value as TValue);\r\n }\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\n public get(key: TKey): TValue | undefined {\r\n return this.registry.get(this.getKey(key));\r\n }\r\n\r\n /**\r\n * Sets a key-value pair in the registry.\r\n * @param key - The key.\r\n * @param value - The value.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n const newKey = this.getKey(key);\r\n this.registry.set(newKey, value);\r\n this.keysMap.set(newKey, key);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key.\r\n * @returns True if the key is found, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this.registry.has(this.getKey(key));\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key.\r\n * @returns True if the key-value pair is deleted, false if the key is not found.\r\n */\r\n public delete(key: TKey): boolean {\r\n const newKey = this.getKey(key);\r\n this.keysMap.delete(newKey);\r\n return this.registry.delete(newKey);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this.registry.clear();\r\n this.keysMap.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this.registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this.keysMap.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this.registry.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n const keys = this.keysMap.values();\r\n const values = this.registry.values();\r\n const entries = new Array<[TKey, TValue]> ;\r\n for (let i = 0; i < this.registry.size; i++) {\r\n const keyResult = keys.next();\r\n const valueResult = values.next();\r\n if (!keyResult.done && !valueResult.done) {\r\n entries.push([keyResult.value, valueResult.value]);\r\n }\r\n }\r\n return entries.values();\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void {\r\n this.registry.forEach(callbackfn);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [string, unknown].\r\n */\r\n [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this.registry[Symbol.iterator]();\r\n }\r\n\r\n private getKey(key: TKey): TKey {\r\n const keyLowerCase = typeof key === 'string'\r\n ? key.toLowerCase() as unknown as TKey\r\n : key;\r\n return keyLowerCase;\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n\r\n}\r\n","/**\r\n * Represents a generic registry that stores key-value pairs.\r\n * @template TKey The type of the keys in the registry.\r\n * @template TValue The type of the values in the registry.\r\n */\r\nimport { RegistryEntries, RegistryType } from \"../../interfaces\";\r\nimport { BaseRegistry } from \"./base-registry\";\r\nimport { CaseInsensitiveRegistry } from \"./case-insensitive-registry\";\r\n\r\nexport class Registry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n private readonly _registry: CaseInsensitiveRegistry<TKey, TValue> | BaseRegistry<TKey, TValue>;\r\n\r\n type: Readonly<string> = 'Registry';\r\n\r\n /**\r\n * Options for the registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new Registry instance.\r\n * @param entries - Optional array of key-value pairs to initialize the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null,\r\n options: Record<string, unknown> = { caseInsensitive: false }) {\r\n this.options = options;\r\n const caseInsensitive = typeof options?.['caseInsensitive'] === 'boolean' ? options['caseInsensitive'] : false;\r\n this._registry = caseInsensitive\r\n ? new CaseInsensitiveRegistry<TKey, TValue>(entries)\r\n : new BaseRegistry<TKey, TValue>(entries)\r\n }\r\n\r\n /**\r\n * Creates a new Registry instance from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new Registry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>,\r\n options: Record<string, unknown> = { caseInsensitive: false }): Registry<TKey, TValue> {\r\n\r\n const entries = Object.entries(object) as [TKey, TValue][];\r\n const registry = new Registry<TKey, TValue>(entries, options);\r\n\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist.\r\n */\r\n public get(key: TKey): TValue | undefined{\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key to check.\r\n * @returns True if the registry contains the key, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key to delete.\r\n * @returns True if the key-value pair was deleted, false if the key does not exist.\r\n */\r\n public delete(key: TKey): boolean {\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this._registry.keys;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this._registry.values;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n * @param thisArg - Optional value to use as `this` when executing the callback function.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [TKey, TValue].\r\n */\r\n public [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n}\r\n","import { QueueType } from '../../interfaces';\r\n\r\n/**\r\n * Represents a generic queue data structure.\r\n * @template T The type of elements stored in the queue.\r\n */\r\nexport class Queue<T> implements QueueType<T> {\r\n\r\n /**\r\n * Creates a new instance of the Queue class.\r\n * @param _queue Optional initial array of elements.\r\n */\r\n public constructor(\r\n private readonly _queue: T[] = []\r\n ) {}\r\n\r\n /**\r\n * Gets the number of elements in the queue.\r\n */\r\n public get length(): number {\r\n return this._queue.length;\r\n }\r\n\r\n /**\r\n * Removes and returns the first element in the queue.\r\n * @returns The first element in the queue, or undefined if the queue is empty.\r\n */\r\n public dequeue(): T | undefined {\r\n return this._queue.shift();\r\n }\r\n\r\n /**\r\n * Adds an element to the end of the queue.\r\n * @param value The element to add to the queue.\r\n * @returns The new length of the queue.\r\n */\r\n public enqueue(value: T): number {\r\n return this._queue.push(value);\r\n }\r\n\r\n /**\r\n * Returns the first element in the queue without removing it.\r\n * @returns The first element in the queue.\r\n */\r\n public peek(): T {\r\n return this._queue[0];\r\n }\r\n}\r\n","import { StackType } from '../../interfaces';\r\n\r\n/**\r\n * Represents a stack data structure with proper memory management.\r\n * @template T The type of elements in the stack.\r\n */\r\nexport class Stack<T> implements StackType<T> {\r\n private _disposed = false;\r\n\r\n /**\r\n * Creates a new instance of the Stack class.\r\n * @param _stack An optional array to initialize the stack.\r\n */\r\n public constructor(\r\n private _stack: T[] = []\r\n ) {}\r\n\r\n /**\r\n * Check if the stack has been disposed\r\n */\r\n private checkDisposed(): void {\r\n if (this._disposed) {\r\n throw new Error('Stack has been disposed and cannot be used');\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of elements in the stack.\r\n */\r\n public get length(): number {\r\n this.checkDisposed();\r\n return this._stack.length;\r\n }\r\n\r\n /**\r\n * Returns the top element of the stack without removing it.\r\n * @returns The top element of the stack.\r\n */\r\n public peek(): T {\r\n this.checkDisposed();\r\n return this._stack[this._stack.length - 1];\r\n }\r\n\r\n /**\r\n * Removes and returns the top element of the stack.\r\n * @returns The top element of the stack, or undefined if the stack is empty.\r\n */\r\n public pop(): T | undefined{\r\n this.checkDisposed();\r\n return this._stack.pop();\r\n }\r\n\r\n /**\r\n * Adds an element to the top of the stack.\r\n * @param value The element to be added to the stack.\r\n * @returns The new length of the stack.\r\n */\r\n public push(value: T): number {\r\n this.checkDisposed();\r\n return this._stack.push(value);\r\n }\r\n\r\n /**\r\n * Swaps the positions of the top two elements in the stack.\r\n */\r\n public swap(): void {\r\n this.checkDisposed();\r\n const length = this._stack.length;\r\n const temp = this._stack[length - 1];\r\n this._stack[length - 1] = this._stack[length - 2];\r\n this._stack[length - 2] = temp;\r\n }\r\n\r\n /**\r\n * Returns the elements of the stack as an array in reverse order.\r\n *\r\n * @returns An array containing the elements of the stack in reverse order.\r\n */\r\n public asArray(): T[] {\r\n this.checkDisposed();\r\n return [...this._stack].reverse();\r\n }\r\n\r\n /**\r\n * Clears all elements from the stack\r\n */\r\n public clear(): void {\r\n this.checkDisposed();\r\n // Clear all references to help with garbage collection\r\n if (this._stack) {\r\n this._stack.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Properly dispose of the stack and clean up memory\r\n */\r\n public dispose(): void {\r\n if (!this._disposed) {\r\n this._disposed = true;\r\n \r\n // Clear the stack array and nullify reference\r\n if (this._stack) {\r\n this._stack.length = 0;\r\n (this as unknown as { _stack?: T[] })._stack = undefined;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Check if the stack has been disposed\r\n */\r\n public isDisposed(): boolean {\r\n return this._disposed;\r\n }\r\n}\r\n","import { sha256 } from 'js-sha256';\r\nimport { RegistryType, CacheType } from '../../interfaces';\r\nimport { BaseRegistry } from './base-registry';\r\n\r\n/**\r\n * Represents a cache implementation that stores key-value pairs.\r\n * @template TValue The type of values stored in the cache.\r\n */\r\nexport class Cache<TValue> implements CacheType<TValue> {\r\n /**\r\n * The registry that stores the key-value pairs.\r\n */\r\n private readonly _registry: RegistryType<string, TValue>;\r\n /**\r\n * The queue that keeps track of the keys in the cache.\r\n */\r\n private readonly _keyQueue: string[];\r\n\r\n type: Readonly<string> = 'Cache';\r\n\r\n /**\r\n * Options for the cache.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new instance of the Cache class.\r\n * @param _maxCacheSize The maximum size of the cache.\r\n */\r\n constructor(\r\n private readonly _maxCacheSize: number,\r\n ) {\r\n this._registry = new BaseRegistry<string, TValue>();\r\n this._keyQueue = [];\r\n }\r\n\r\n /**\r\n * Gets the maximum size of the cache.\r\n */\r\n get maxCacheSize(): number {\r\n return this._maxCacheSize;\r\n }\r\n\r\n /**\r\n * Generates a hash key based on the given namespace and value.\r\n * @param namespace The namespace for the key.\r\n * @param value The value for the key.\r\n * @returns The generated hash key.\r\n */\r\n getHashKey(namespace: string, value: string): string {\r\n const key = sha256(`${namespace}:${value}`);\r\n return key;\r\n }\r\n\r\n /**\r\n * Gets the value associated with the specified key.\r\n * @param key The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist in the cache.\r\n */\r\n get(key: string): TValue | undefined {\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key in the cache.\r\n * @param key The key to set the value for.\r\n * @param value The value to set.\r\n */\r\n set(key: string, value: TValue): void {\r\n const index = this._keyQueue.indexOf(key);\r\n if (index === -1) {\r\n this._keyQueue.push(key);\r\n }\r\n while(this._keyQueue.length > this._maxCacheSize) {\r\n const removeKey = this._keyQueue.shift();\r\n if (removeKey) {\r\n this._registry.delete(removeKey);\r\n }\r\n }\r\n\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the cache contains the specified key.\r\n * @param key The key to check.\r\n * @returns True if the cache contains the key, false otherwise.\r\n */\r\n has(key: string): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the value associated with the specified key from the cache.\r\n * @param key The key to delete.\r\n * @returns True if the value was successfully deleted, false otherwise.\r\n */\r\n delete(key: string): boolean {\r\n const index = this._keyQueue.indexOf(key);\r\n if (index > -1) {\r\n this._keyQueue.splice(index, 1);\r\n }\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears the cache, removing all key-value pairs.\r\n */\r\n clear(): void {\r\n this._keyQueue.length = 0;\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the cache.\r\n */\r\n get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the cache.\r\n */\r\n get keys(): IterableIterator<string> {\r\n return this._registry.keys;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the cache.\r\n */\r\n get values(): IterableIterator<TValue> {\r\n return this._registry.values;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the entries (key-value pairs) in the cache.\r\n */\r\n get entries(): IterableIterator<[string, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the cache.\r\n * @param callbackfn The function to execute for each key-value pair.\r\n * @param thisArg The value to use as `this` when executing the callback function.\r\n */\r\n forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries (key-value pairs) in the cache.\r\n */\r\n [Symbol.iterator](): IterableIterator<[string, TValue]> {\r\n return this._registry[Symbol.iterator]();\r\n }\r\n}\r\n","import { BaseContext } from \"../classes/common/context\";\r\n\r\n/**\r\n * Retrieves the key-value pair from an object based on the provided key.\r\n * @param obj - The object to search for the key-value pair.\r\n * @param key - The key to search for in the object.\r\n * @param caseInsesitive - Specifies whether the key comparison should be case-insensitive.\r\n * @returns The key-value pair as an array, or undefined if the key is not found.\r\n */\r\nexport const getKeyValue = (obj: BaseContext,\r\n key: string | number | symbol,\r\n caseInsesitive: boolean): [string | number | symbol, unknown] | undefined => {\r\n\r\n if (!caseInsesitive || typeof key !== 'string') {\r\n const value = obj[key];\r\n return [key, value];\r\n }\r\n\r\n if (typeof key === 'string') {\r\n let currentObj = obj;\r\n do {\r\n const keys: string[] = Object.getOwnPropertyNames(currentObj);\r\n if (Array.isArray(keys)) {\r\n const foundKey = keys.find(k => equalIgnoreCase(key, k));\r\n if (foundKey) {\r\n const value = currentObj[foundKey];\r\n return [foundKey, value];\r\n }\r\n }\r\n } while ((currentObj = Object.getPrototypeOf(currentObj)));\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Compares two values for equality, ignoring case sensitivity.\r\n * @param a - The first value to compare.\r\n * @param b - The second value to compare.\r\n * @returns `true` if the values are equal, `false` otherwise.\r\n */\r\nexport const equalIgnoreCase = (a: string | number | symbol, b: string | number | symbol) => {\r\n if (typeof a === 'number' || typeof b === 'number') {\r\n return a === b;\r\n } else if (typeof a === 'symbol' || typeof b === 'symbol') {\r\n return a === b;\r\n } else if (typeof a === 'string' || typeof b === 'string') {\r\n return a.localeCompare(b, 'en', { sensitivity: 'base' }) === 0;\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Retrieves the value from an object, ignoring the case of the key.\r\n * @param obj - The object to retrieve the value from.\r\n * @param key - The key to search for, ignoring the case.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\nexport const getValueIgnoreCase = (obj: BaseContext,\r\n key: string | number | symbol): unknown | undefined => {\r\n const pair = getKeyValue(obj, key, true);\r\n if (pair) {\r\n return pair[1];\r\n }\r\n return undefined;\r\n}\r\n","import { equalIgnoreCase, getKeyValue } from '../../visitors/utils';\r\nimport { Registry } from '../common';\r\nimport { EvalOptions } from '../eval';\r\n\r\nexport type BaseContext = Record<string | number | symbol, unknown>;\r\n\r\nexport type Context = Registry<unknown, unknown> | BaseContext;\r\n\r\nexport function isRegistryContext (context?: Context): boolean {\r\n const value = ['Registry', 'CaseInsensitiveRegistry', 'BaseRegistry'].includes(context?.type as string);\r\n return value;\r\n}\r\n\r\n/**\r\n * Converts a context object to a Context instance.\r\n * @param context - The context object to convert.\r\n * @param options - Optional evaluation options.\r\n * @returns The converted Context instance.\r\n */\r\nexport const fromContext = (context?: Context, options?: EvalOptions): Context => {\r\n const caseInsensitive = options?.caseInsensitive;\r\n if (!context) {\r\n return {} as Record<string | number | symbol, unknown>;\r\n } else if (context instanceof Registry) {\r\n return context;\r\n } else if (caseInsensitive && context instanceof Object) {\r\n return Registry.fromObject(context as Record<string | number | symbol, unknown>, options) as Context;\r\n } else {\r\n return context;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the value associated with the specified key from the given context.\r\n * If the context is an instance of Registry, it uses the `get` method to retrieve the value.\r\n * If the context is an object, it accesses the value using the key as a property name.\r\n * If the context is neither an instance of Registry nor an object, it returns undefined.\r\n *\r\n * @param context The context from which to retrieve the value.\r\n * @param key The key associated with the value to retrieve.\r\n * @returns The value associated with the specified key, or undefined if not found.\r\n */\r\nexport const getContextValue = (context?: Context, key?: unknown): unknown => {\r\n if (context instanceof Registry) {\r\n return context.get(key);\r\n } else if (context instanceof Object) {\r\n return context[key as string | number | symbol];\r\n } else {\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Sets a value in the given context object.\r\n * If the context is an instance of Registry, the value is set using the key.\r\n * If the context is a plain object, the value is set using the key as a property name.\r\n * @param context - The context object.\r\n * @param key - The key or property name.\r\n * @param value - The value to be set.\r\n */\r\nexport const setContextValue = (context: Context, key: unknown, value: unknown): void => {\r\n if (context instanceof Registry) {\r\n const registry = context as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (context instanceof Object) {\r\n const object = context as Record<string, unknown>;\r\n object[key as string | number] = value;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the key from the given context object.\r\n * If the context is an instance of Registry, it searches for the key in a case-insensitive manner if specified.\r\n * If the context is an instance of Object, it uses the getKeyValue function to retrieve the key-value pair.\r\n * @param context - The context object.\r\n * @param key - The key to retrieve.\r\n * @param caseInsensitive - Specifies whether the search should be case-insensitive (only applicable for Registry instances).\r\n * @returns The retrieved key, or undefined if the key is not found.\r\n */\r\nexport const getContextKey = (context: Context,\r\n key: string | number | symbol,\r\n caseInsensitive: boolean): string | number | symbol | undefined => {\r\n\r\n if (context instanceof Registry) {\r\n const keys = [...context.keys]; // : (string | number | symbol)[]\r\n const foundKey = caseInsensitive && typeof key === 'string'\r\n ? keys.find(k => equalIgnoreCase(key as string, k as string))\r\n : keys.find(k => k === key);\r\n if (foundKey) {\r\n return foundKey as string | number | symbol;\r\n }\r\n } else if (context instanceof Object) {\r\n const pair = getKeyValue(context as BaseContext,\r\n key as string | number | symbol, caseInsensitive);\r\n\r\n if (pair) {\r\n return pair[0] as string | number | symbol;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n","import { Context, Registry, Stack, fromContext } from '../common';\r\nimport { getContextKey, getContextValue } from '../common/context';\r\nimport { EvalLookup } from './eval-lookup';\r\nimport { EvalOptions } from './eval-options';\r\nimport { EvalScope } from './eval-scope';\r\n\r\n/**\r\n * Whether a context holds a key at all, regardless of the value bound to it.\r\n *\r\n * There is no `getContextValue` counterpart for this: that helper cannot\r\n * distinguish an absent key from one bound to `undefined`, and `getContextKey`\r\n * with `caseInsensitive: false` reports every key as present for a plain\r\n * object. Own properties only - the scopes this is used on are object literals\r\n * built by `evaluatePatterns`, and inherited names are not bindings.\r\n */\r\nconst hasContextKey = (context: Context, key: unknown): boolean => {\r\n if (context instanceof Registry) {\r\n return context.has(key);\r\n }\r\n return context instanceof Object\r\n && Object.prototype.hasOwnProperty.call(context, key as PropertyKey);\r\n};\r\n\r\n/**\r\n * Represents the evaluation context for the code execution.\r\n */\r\nexport class EvalContext {\r\n\r\n type = 'EvalContext';\r\n\r\n private _original: Readonly<Context>;\r\n private _priorScopes: EvalScope[];\r\n private _scopes: Stack<Context>;\r\n private _lookups: EvalLookup[];\r\n private _options: Readonly<EvalOptions>;\r\n\r\n /**\r\n * Gets the original registry.\r\n */\r\n public get original(): Context {\r\n return this._original;\r\n }\r\n\r\n /**\r\n * Gets the scopes registry.\r\n */\r\n public get priorScopes(): EvalScope[] {\r\n return this._priorScopes;\r\n }\r\n\r\n /**\r\n * Gets the scopes registry.\r\n */\r\n public get scopes(): Readonly<Stack<Context>> {\r\n return this._scopes;\r\n }\r\n\r\n /**\r\n * Gets the lookups registry.\r\n */\r\n public get lookups(): EvalLookup[] {\r\n return this._lookups;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalContext.\r\n * @param original - The original registry or an object to create a registry from.\r\n * @param options - The evaluation options.\r\n */\r\n constructor(\r\n original: Context,\r\n options: EvalOptions\r\n ) {\r\n this._original = original;\r\n this._priorScopes = [];\r\n this._scopes = new Stack<Context>();\r\n this._options = options;\r\n this._lookups = [];\r\n }\r\n\r\n /**\r\n * Converts the given context to an instance of EvalContext.\r\n * @param context - The context to convert.\r\n * @param options - The evaluation options.\r\n * @returns The converted EvalContext instance.\r\n */\r\n public static fromContext(context?: EvalContext | Context | undefined,\r\n options?: EvalOptions): EvalContext {\r\n\r\n if (context instanceof EvalContext) {\r\n return context;\r\n }\r\n\r\n const ctx = fromContext(context ?? {}, options);\r\n return new EvalContext(ctx, options ?? {});\r\n }\r\n\r\n /**\r\n * Gets the value associated with the specified key from the evaluation context.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if not found.\r\n */\r\n public get(key: unknown): unknown | undefined {\r\n\r\n const scoped = this.getFromScopes(key);\r\n if (scoped !== undefined) {\r\n return scoped;\r\n }\r\n\r\n if (this._original) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n\r\n for (const scope of this._priorScopes) {\r\n const value = scope.get(key);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n\r\n for (const lookup of this._lookups) {\r\n const value = lookup(key, this, this._options);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Step 1 of {@link get}'s resolution order on its own: the scopes pushed\r\n * during this evaluation, innermost first.\r\n *\r\n * {@link get} calls this rather than inlining the loop, so that the read\r\n * hooks' `scoped` flag and the resolution it describes are the *same*\r\n * implementation. A second copy of the order would drift - `getKey` already\r\n * shows what that looks like when it does.\r\n *\r\n * A binding whose value is `undefined` reads as absent here, exactly as it\r\n * does in {@link get}, which falls through to the original context for it.\r\n *\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value bound by the innermost scope holding the key, or\r\n * undefined when no pushed scope holds it.\r\n */\r\n public getFromScopes(key: unknown): unknown | undefined {\r\n\r\n for (const scope of this._scopes.asArray()) {\r\n const value = getContextValue(scope, key);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Whether any scope pushed during this evaluation *binds* the key - the\r\n * question the read hooks' `scoped` flag asks.\r\n *\r\n * Deliberately about binding rather than about value, which is where it parts\r\n * company with {@link getFromScopes}: a parameter bound to `undefined` is\r\n * still a parameter, but `get` falls through past it to the original context.\r\n * Reading the flag off the value would make it depend on the *data* - the\r\n * same arrow function over `[{ name: 'a' }]` and over `[undefined]` would\r\n * report different bindings, and a dependency tracker's output would vary\r\n * between two recomputes of one expression. That is the failure this flag\r\n * exists to prevent, so presence is the correct predicate.\r\n *\r\n * Both queries iterate the same stack in the same direction, so neither is a\r\n * second copy of the four-step resolution order; they answer two different\r\n * questions about its first step.\r\n *\r\n * @param key - The key to look for.\r\n * @returns True when a pushed scope holds the key, whatever its value.\r\n */\r\n public hasInScopes(key: unknown): boolean {\r\n\r\n for (const scope of this._scopes.asArray()) {\r\n if (hasContextKey(scope, key)) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Retrieves the `this` value of the specified key from the evaluation context.\r\n * The value is searched in the original context, prior scopes, and lookup functions.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The `this` value associated with the key, or undefined if not found.\r\n */\r\n public getThis(key: unknown): unknown | undefined {\r\n if (this._original) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return this._original;\r\n }\r\n }\r\n for (const scope of this._priorScopes) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return scope;\r\n }\r\n }\r\n for (const lookup of this._lookups) {\r\n const value = lookup(key, this, this._options);\r\n if (value !== undefined) {\r\n return lookup;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key from the evaluation context.\r\n *\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\n public getKey(key: string | number | symbol): string | number | symbol | undefined {\r\n\r\n const caseInsensitive = !!this._options.caseInsensitive;\r\n\r\n for (const scope of this._scopes.asArray()) {\r\n const foundKey = getContextKey(scope, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n if (this._original) {\r\n const foundKey = getContextKey(this._original, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n for (const scope of this._priorScopes) {\r\n const foundKey = getContextKey(scope.context, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Sets a key-value pair in the context.\r\n * If the original context is a Registry, the key-value pair is set using the Registry's set method.\r\n * If the original context is an Object, the key-value pair is set directly on the object.\r\n * @param key - The key of the pair.\r\n * @param value - The value of the pair.\r\n */\r\n public set(key: unknown, value: unknown): void {\r\n if (this._original && this._original instanceof Registry) {\r\n const registry = this._original as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (this._original && this._original instanceof Object) {\r\n const obj = this._original as Record<string, unknown>;\r\n obj[key as string | number] = value;\r\n }\r\n }\r\n\r\n /**\r\n * Pushes a context to the scope stack.\r\n * @param context - The context to push.\r\n * @param options - The evaluation options.\r\n */\r\n public push(context: Context, options?: EvalOptions): void {\r\n const ctx = fromContext(context, options);\r\n this._scopes.push(ctx);\r\n }\r\n\r\n /**\r\n * Pops a context from the scope stack.\r\n */\r\n public pop(): void {\r\n this._scopes.pop();\r\n }\r\n\r\n\r\n /**\r\n * Converts the EvalContext instance to an object representation.\r\n * If the original value is an instance of Registry, it converts it to an object using the toObject method of the registry.\r\n * If the original value is an object, it returns the original object.\r\n * @returns The object representation of the EvalContext instance.\r\n */\r\n public toObject(): Record<string | number | symbol, unknown> | undefined{\r\n\r\n if (this._original && this._original instanceof Registry) {\r\n const registry = this._original as Registry<unknown, unknown>;\r\n const object = registry.toObject();\r\n return object;\r\n } else if (this._original && this._original instanceof Object) {\r\n const obj = this._original as Record<string, unknown>;\r\n return obj;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n}\r\n","import { AnyNode } from \"acorn\";\r\n\r\nexport interface EvalTraceItem {\r\n start?: number;\r\n end?: number;\r\n type: string;\r\n expression?: string;\r\n value: unknown;\r\n}\r\n\r\n/**\r\n * Represents a trace of evaluation for a specific code execution.\r\n */\r\nexport class EvalTrace extends Array<EvalTraceItem> {\r\n\r\n /**\r\n * Adds a new trace item to the evaluation trace.\r\n * @param node - The AST node associated with the trace item.\r\n * @param value - The value of the evaluated expression.\r\n * @param expression - The expression being evaluated.\r\n */\r\n add(node: AnyNode, value?: unknown, expression?: string) {\r\n const item: EvalTraceItem = {\r\n type: node.type,\r\n value\r\n };\r\n if (expression) {\r\n item.expression = expression.substring(node.start, node.end);\r\n }\r\n this.push(item);\r\n }\r\n}\r\n","import { Stack } from \"../common\";\r\nimport { EvalContext } from \"./eval-context\";\r\nimport { EvalOptions } from \"./eval-options\";\r\nimport { EvalTrace } from \"./eval-trace\";\r\n\r\ntype UnknownValue = unknown | Promise<unknown>;\r\n\r\n/**\r\n * Represents the result of an evaluation.\r\n */\r\nexport class EvalResult {\r\n\r\n private _stack: Stack<UnknownValue>;\r\n private _value?: UnknownValue;\r\n private _error?: unknown;\r\n private _errorMessage?: string;\r\n private _isError?: boolean;\r\n private _isSuccess?: boolean;\r\n private _isUndefined?: boolean;\r\n private _trace: EvalTrace;\r\n private _context: EvalContext;\r\n private _startDate?: number;\r\n private _endDate?: number;\r\n private _expression?: string;\r\n\r\n /**\r\n * Gets the stack of evaluated values.\r\n */\r\n public get stack(): Stack<UnknownValue> {\r\n return this._stack;\r\n }\r\n\r\n /**\r\n * Gets the evaluated value.\r\n */\r\n public get value(): UnknownValue | undefined {\r\n return this._value;\r\n }\r\n\r\n /**\r\n * Gets the error that occurred during evaluation.\r\n */\r\n public get error(): unknown | undefined {\r\n return this._error;\r\n }\r\n\r\n /**\r\n * Gets the error message associated with the evaluation error.\r\n */\r\n public get errorMessage(): string | undefined {\r\n return this._errorMessage;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation resulted in an error.\r\n */\r\n public get isError(): boolean | undefined {\r\n return this._isError;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation was successful.\r\n */\r\n public get isSuccess(): boolean | undefined {\r\n return this._isSuccess;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluated value is undefined.\r\n */\r\n public get isUndefined(): boolean | undefined {\r\n return this._isUndefined;\r\n }\r\n\r\n /**\r\n * Gets the trace of evaluated values.\r\n */\r\n public get trace(): EvalTrace {\r\n return this._trace;\r\n }\r\n\r\n /**\r\n * Gets the evaluation context.\r\n */\r\n public get context(): EvalContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions {\r\n return this._context.options;\r\n }\r\n\r\n /**\r\n * Gets the duration of the evaluation result.\r\n * @returns The duration in milliseconds.\r\n */\r\n public get duration(): number | undefined {\r\n if (!this._startDate || !this._endDate) {\r\n return undefined;\r\n }\r\n return this._endDate - this._startDate;\r\n }\r\n\r\n /**\r\n * Gets the expression associated with the evaluation result.\r\n * @returns The expression as a string, or undefined if no expression is associated.\r\n */\r\n public get expression(): string | undefined {\r\n return this._expression;\r\n }\r\n\r\n /**\r\n * Sets the expression for the evaluation result.\r\n *\r\n * @param value - The expression to be set.\r\n */\r\n public set expression(value: string | undefined) {\r\n this._expression = value;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalResult.\r\n * @param trace The trace of evaluated values.\r\n * @param context The evaluation context.\r\n */\r\n constructor(context: EvalContext) {\r\n\r\n this._stack = new Stack<UnknownValue>();\r\n this._trace = new EvalTrace();\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Starts the evaluation process.\r\n */\r\n public start(): void {\r\n this._startDate = performance.now();\r\n }\r\n\r\n /**\r\n * Stops the evaluation and records the end date.\r\n */\r\n public stop(): number | undefined {\r\n this._endDate = performance.now();\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Sets the success value of the evaluation result.\r\n *\r\n * @param value The value to set as the success value.\r\n * @returns void\r\n */\r\n public setSuccess(value: UnknownValue): void {\r\n this._value = value;\r\n this._isSuccess = true;\r\n this._isError = false;\r\n this._isUndefined = false;\r\n }\r\n\r\n /**\r\n * Sets the failure state of the evaluation result.\r\n * @param error The error object associated with the failure.\r\n */\r\n public setFailure(error: unknown): void {\r\n this._error = error;\r\n if (error instanceof Error) {\r\n this._errorMessage = error.message;\r\n }\r\n this._isSuccess = false;\r\n this._isError = true;\r\n this._isUndefined = false;\r\n }\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../../interfaces';\r\nimport { EvalOptions } from './eval-options';\r\nimport type { EvalState } from './eval-state';\r\n\r\n/**\r\n * The two points at which a visitor brackets its body.\r\n */\r\nexport type EvalHookPhase = 'before' | 'after';\r\n\r\n/**\r\n * Payload handed to a node hook.\r\n */\r\nexport interface EvalNodeHookEvent {\r\n readonly phase: EvalHookPhase;\r\n readonly node: AnyNode;\r\n readonly state: EvalState;\r\n /** Value pushed by the visitor; only present on 'after'. */\r\n readonly value?: unknown;\r\n /** False when this 'after' event was synthesised rather than dispatched by a visitor. */\r\n readonly completed: boolean;\r\n /**\r\n * The error that aborted evaluation.\r\n *\r\n * Present only on events synthesised by `unwindTo`, where evaluation really\r\n * did fail. Frames closed by `exit` - because an enclosing visitor moved on\r\n * without them - also carry `completed: false`, but no error: nothing threw,\r\n * and the evaluation may well succeed. Test for the property rather than\r\n * assuming `completed: false` implies one.\r\n */\r\n readonly error?: unknown;\r\n}\r\n\r\n/**\r\n * A node hook. Hooks are observers: they are called for their side effects and\r\n * their return value is discarded. A hook that returns a promise is *not*\r\n * awaited - see {@link ASYNC_HOOK_MESSAGE}.\r\n */\r\nexport type EvalNodeHook = (event: EvalNodeHookEvent) => void;\r\n\r\n/**\r\n * Which resolution produced a read event.\r\n */\r\nexport type EvalReadKind = 'identifier' | 'member';\r\n\r\n/**\r\n * Payload handed to a read hook: one resolved context read.\r\n *\r\n * Node hooks cannot report *which key* an expression read - the AST node alone\r\n * is not enough once case correction and computed members are in play - so this\r\n * is the event a dependency tracker actually needs.\r\n */\r\nexport interface EvalReadEvent {\r\n readonly kind: EvalReadKind;\r\n readonly node: AnyNode;\r\n readonly state: EvalState;\r\n /** The key as resolved against the context (case-corrected when caseInsensitive). */\r\n readonly key: string | number | symbol;\r\n /** The object the key was read from - the context, an EvalScope, or a plain object. */\r\n readonly target: unknown;\r\n /**\r\n * Dotted path when statically reconstructible (`a.b.c`), else undefined.\r\n *\r\n * Reconstructed from the source spelling, so it is *not* case-corrected even\r\n * when {@link key} is. Computed members (`obj[expr]`) yield undefined; their\r\n * `key` is still exact.\r\n */\r\n readonly path?: string;\r\n readonly value: unknown;\r\n /**\r\n * True when the key resolved from a scope pushed *during this evaluation* -\r\n * `EvalContext.scopes`, the stack `arrow-function-expression.ts` pushes and\r\n * pops around a call. Such a read is an arrow-function parameter binding,\r\n * not a dependency, and a tracker should skip it.\r\n *\r\n * The definition is **lifetime, not type**: caller-registered `priorScopes`\r\n * are `EvalScope` instances holding long-lived objects and are real\r\n * dependencies, so they are never flagged. Absent reads as \"not scoped\",\r\n * which is right for every member emission site.\r\n */\r\n readonly scoped?: boolean;\r\n}\r\n\r\n/**\r\n * A read hook. Like a node hook it is an observer: its return value is\r\n * discarded and a returned promise is not awaited.\r\n */\r\nexport type EvalReadHook = (event: EvalReadEvent) => void;\r\n\r\n/**\r\n * Removes the hook that returned it. Calling it more than once is a no-op.\r\n */\r\nexport type Unsubscribe = () => void;\r\n\r\n/**\r\n * What to do with an error raised by a hook.\r\n *\r\n * - `collect` (default) - wrap it, append it to `state.hookErrors`, keep evaluating.\r\n * - `throw` - rethrow it into the visitor, failing the evaluation.\r\n * - `ignore` - swallow it silently.\r\n */\r\nexport type EvalHookErrorPolicy = 'collect' | 'throw' | 'ignore';\r\n\r\n/**\r\n * An error raised by a hook, recorded under the 'collect' policy.\r\n *\r\n * `phase` is `'read'` for an error raised by a read hook: a read is neither of\r\n * the two node phases, and reporting one as 'before' or 'after' would mislead a\r\n * consumer reading the log.\r\n */\r\nexport interface EvalHookError {\r\n readonly phase: EvalHookPhase | 'read';\r\n readonly nodeType: AnyNodeTypes;\r\n readonly error: unknown;\r\n}\r\n\r\n/**\r\n * How long one node type took over an evaluation, accumulated by the timing\r\n * hook and read back as `EvalState.nodeTimings`.\r\n *\r\n * `total` is *inclusive*: a node's children are counted in its own elapsed\r\n * time, so the totals of nested types overlap and summing them exceeds the\r\n * walk's duration. Per-type comparison is what this supports; a breakdown that\r\n * adds up is not.\r\n */\r\nexport interface EvalNodeTiming {\r\n /** How many nodes of this type were visited. */\r\n readonly count: number;\r\n /** Inclusive elapsed milliseconds across all of them. */\r\n readonly total: number;\r\n}\r\n\r\n/**\r\n * The bookkeeping an `EvalHooks` accumulates over a single evaluation.\r\n *\r\n * It is grouped behind one accessor on `EvalState` rather than spread across\r\n * several members, and it lives on the state rather than on the registry: an\r\n * `EvalHooks` is consumer-owned and may be handed to several evaluations, so\r\n * anything whose lifetime is one run belongs to the run.\r\n *\r\n * @internal Not part of the published API; `EvalHooks` is its only writer.\r\n */\r\nexport interface EvalHookBookkeeping {\r\n /** Nodes whose 'before' has fired but whose 'after' has not, outermost first. */\r\n readonly open: AnyNode[];\r\n /** Hook errors recorded under the 'collect' policy. */\r\n readonly errors: EvalHookError[];\r\n /**\r\n * Per-node-type timings, written by the timing hook when one is installed and\r\n * left empty otherwise.\r\n *\r\n * It lives here rather than on the handle `createTimingHook` returns for two\r\n * reasons. A registry may be shared across evaluations, so totals held on the\r\n * handle would bleed one run into the next - the same argument that moved the\r\n * error list here. And `trackTime` installs the hook from inside the\r\n * `EvalState` constructor, where no caller ever sees the handle: totals on it\r\n * would be unreachable, which is a dead option rather than a feature.\r\n */\r\n readonly timings: Map<AnyNodeTypes, EvalNodeTiming>;\r\n}\r\n\r\nconst DEFAULT_POLICY: EvalHookErrorPolicy = 'collect';\r\n\r\nconst POLICIES: readonly EvalHookErrorPolicy[] = ['collect', 'throw', 'ignore'];\r\n\r\n/**\r\n * The message carried by the error raised when a hook returns a promise.\r\n *\r\n * Hooks are synchronous by contract (§ 3.3): the walk is synchronous even under\r\n * `evaluateAsync`, so a returned promise is never awaited and whatever the hook\r\n * meant to do lands after the evaluation finished. The dispatcher reports it as\r\n * an error carrying this message, routed through the configured policy like any\r\n * other hook error - collected by default, and thrown into the visitor under\r\n * `'throw'`, which does fail the evaluation.\r\n *\r\n * Exported so a consumer inspecting `EvalState.hookErrors` can tell this\r\n * diagnostic apart from an error its own hook threw, without matching on\r\n * message text it would have to keep in sync by hand.\r\n */\r\nexport const ASYNC_HOOK_MESSAGE =\r\n 'async hook returned a promise; it will not be awaited';\r\n\r\n/**\r\n * Reads the error policy out of the evaluation options. `EvalOptions` is a union\r\n * and does not index directly, so the read goes through a cast - the same one\r\n * `before-visitor.ts` performs.\r\n */\r\nconst readPolicy = (options?: EvalOptions): EvalHookErrorPolicy => {\r\n const value = (options as Record<string, unknown>)?.['onHookError'];\r\n return POLICIES.includes(value as EvalHookErrorPolicy)\r\n ? (value as EvalHookErrorPolicy)\r\n : DEFAULT_POLICY;\r\n};\r\n\r\nconst isPromiseLike = (value: unknown): boolean =>\r\n !!value &&\r\n (typeof value === 'object' || typeof value === 'function') &&\r\n typeof (value as PromiseLike<unknown>).then === 'function';\r\n\r\n/**\r\n * A registry of node hooks, keyed by node type with wildcard support, and the\r\n * dispatcher that keeps `before` and `after` balanced when a visitor throws.\r\n *\r\n * It holds *registration* only. Everything whose lifetime is a single\r\n * evaluation - the open-node stack and the collected errors - lives on the\r\n * `EvalState` instead, because a consumer may hand one `EvalHooks` to several\r\n * evaluations and expect each to observe both.\r\n *\r\n * Hooks are synchronous by design: the walk in `evaluate` is synchronous even\r\n * under `evaluateAsync`, so there is no point at which a hook could be awaited.\r\n */\r\nexport class EvalHooks {\r\n private readonly _before = new Map<string, EvalNodeHook[]>();\r\n private readonly _after = new Map<string, EvalNodeHook[]>();\r\n private _read: EvalReadHook[] = [];\r\n private readonly _policy: EvalHookErrorPolicy;\r\n private _size = 0;\r\n private _active = false;\r\n\r\n /**\r\n * @param options The evaluation options; `onHookError` selects the error policy.\r\n */\r\n constructor(options?: EvalOptions) {\r\n this._policy = readPolicy(options);\r\n }\r\n\r\n /**\r\n * True while no hook is registered. Read on the hot path, so it is a counter\r\n * rather than a walk of the registries.\r\n */\r\n public get isEmpty(): boolean {\r\n return this._size === 0;\r\n }\r\n\r\n /**\r\n * The dispatch guard, behind `EvalState.hasHooks`.\r\n *\r\n * Unlike {@link isEmpty} this *latches*: it turns true on the first\r\n * registration and only `clear` turns it off again. The guard wraps the\r\n * open-node stack as well as the hooks themselves, so a value that changed\r\n * mid-walk would leave `enter` and `exit` unpaired - which is exactly what\r\n * one-shot and self-unsubscribing hooks would otherwise cause.\r\n *\r\n * Calling `clear` during a walk is therefore unsupported.\r\n */\r\n public get isActive(): boolean {\r\n return this._active;\r\n }\r\n\r\n /**\r\n * True while at least one read hook is registered.\r\n *\r\n * The second half of the read-emission guard: `st.hasHooks` says a registry\r\n * exists and has been used, this says a *read* hook is there to observe the\r\n * event. Without it a consumer that registered only 'before'/'after' hooks\r\n * would pay `getKey` per identifier and `readPath` plus an object literal per\r\n * member for events it can never see - which the timing hook turns from\r\n * theoretical into routine, since it latches `hasHooks` for a whole walk.\r\n *\r\n * **Non-latching, unlike {@link isActive}.** That getter latches because it\r\n * wraps the open-node stack, so a value changing mid-walk would leave `enter`\r\n * and `exit` unpaired. `dispatchRead` touches no bookkeeping, so a read guard\r\n * that flips mid-walk can only drop read events - never unbalance anything.\r\n * A one-shot or self-unsubscribing read hook is therefore safe here, and the\r\n * guard can report the current registration count rather than history.\r\n */\r\n public get hasReadHooks(): boolean {\r\n return this._read.length > 0;\r\n }\r\n\r\n /**\r\n * Registers a node hook.\r\n * @param phase Whether to fire before or after the visitor body.\r\n * @param type A concrete node type, or '*' for every node.\r\n * @param hook The hook to register.\r\n * @returns A function that removes this hook.\r\n */\r\n public on(phase: EvalHookPhase, type: AnyNodeTypes | '*', hook: EvalNodeHook): Unsubscribe {\r\n const registry = this.registry(phase);\r\n const hooks = registry.get(type);\r\n\r\n if (hooks) {\r\n hooks.push(hook);\r\n } else {\r\n registry.set(type, [hook]);\r\n }\r\n this._size++;\r\n this._active = true;\r\n\r\n let unsubscribed = false;\r\n return () => {\r\n if (unsubscribed) {\r\n return;\r\n }\r\n unsubscribed = true;\r\n this.off(phase, type, hook);\r\n };\r\n }\r\n\r\n /**\r\n * Registers a read hook, fired once per resolved context read.\r\n *\r\n * Read hooks are not keyed by node type: there are only two emission points\r\n * and a consumer filters on {@link EvalReadEvent.kind} if it cares.\r\n *\r\n * Registration latches {@link isActive} exactly as {@link on} does, because\r\n * the visitors reach their emission points through the same\r\n * `EvalState.hasHooks` guard.\r\n *\r\n * @param hook The hook to register.\r\n * @returns A function that removes this hook.\r\n */\r\n public onRead(hook: EvalReadHook): Unsubscribe {\r\n this._read.push(hook);\r\n this._size++;\r\n this._active = true;\r\n\r\n let unsubscribed = false;\r\n return () => {\r\n if (unsubscribed) {\r\n return;\r\n }\r\n unsubscribed = true;\r\n this.offRead(hook);\r\n };\r\n }\r\n\r\n /**\r\n * Removes one read hook, or every read hook when `hook` is omitted.\r\n */\r\n public offRead(hook?: EvalReadHook): void {\r\n if (hook === undefined) {\r\n this._size -= this._read.length;\r\n this._read = [];\r\n return;\r\n }\r\n\r\n const index = this._read.indexOf(hook);\r\n if (index < 0) {\r\n return;\r\n }\r\n\r\n this._read.splice(index, 1);\r\n this._size--;\r\n }\r\n\r\n /**\r\n * Removes one hook, or every hook registered for a key when `hook` is omitted.\r\n */\r\n public off(phase: EvalHookPhase, type: AnyNodeTypes | '*', hook?: EvalNodeHook): void {\r\n const registry = this.registry(phase);\r\n const hooks = registry.get(type);\r\n\r\n if (!hooks) {\r\n return;\r\n }\r\n\r\n if (hook === undefined) {\r\n registry.delete(type);\r\n this._size -= hooks.length;\r\n return;\r\n }\r\n\r\n const index = hooks.indexOf(hook);\r\n if (index < 0) {\r\n return;\r\n }\r\n\r\n hooks.splice(index, 1);\r\n this._size--;\r\n if (hooks.length === 0) {\r\n registry.delete(type);\r\n }\r\n }\r\n\r\n /**\r\n * Removes every hook from both phases and unlatches {@link isActive}.\r\n *\r\n * Per-run bookkeeping is untouched: the open-node stack and the collected\r\n * errors belong to the `EvalState`, not to this registry. Errors in\r\n * particular are a record of what already happened.\r\n */\r\n public clear(): void {\r\n this._before.clear();\r\n this._after.clear();\r\n this._read = [];\r\n this._size = 0;\r\n this._active = false;\r\n }\r\n\r\n /**\r\n * Fires the hooks registered for a node, keyed first and wildcard second.\r\n *\r\n * Bookkeeping runs before user code on both edges: 'before' pushes the node\r\n * onto the open-node stack and *then* emits, 'after' pops and *then* emits.\r\n * The shared rule is that hook code only ever runs once the stack already\r\n * tells the truth about this node, because `emit` can throw - under the\r\n * 'throw' policy a hook's error propagates out of it. Emitting first on the\r\n * 'before' edge would leave a node that some hooks had already been told\r\n * about missing from the stack, and therefore invisible to `unwindTo`.\r\n *\r\n * @param value The value the visitor pushed; meaningful on 'after' only.\r\n */\r\n public dispatch(phase: EvalHookPhase, node: AnyNode, state: EvalState, value?: unknown): void {\r\n if (phase === 'after') {\r\n this.exit(state, node);\r\n this.emit({ phase, node, state, value, completed: true }, false);\r\n return;\r\n }\r\n\r\n this.enter(node, state);\r\n this.emit({ phase, node, state, completed: true }, false);\r\n }\r\n\r\n /**\r\n * Fires the read hooks for one resolved context read.\r\n *\r\n * The event is built by the caller rather than assembled from positional\r\n * arguments here, so the visitors allocate nothing on the no-hooks path: the\r\n * whole construction sits inside their `st.hasHooks` guard.\r\n *\r\n * Touches no bookkeeping. A read is not a frame - it happens *within* a\r\n * node's before/after pair, so the open-node stack is none of its business.\r\n */\r\n public dispatchRead(event: EvalReadEvent): void {\r\n if (this._read.length === 0) {\r\n return;\r\n }\r\n // Iterated as a copy so a hook that unsubscribes itself does not shift the\r\n // list out from under the loop.\r\n for (const hook of this._read.slice()) {\r\n this.invokeRead(hook, event);\r\n }\r\n }\r\n\r\n /**\r\n * Records a node as open on the state. Called by the 'before' dispatcher\r\n * before its hooks fire.\r\n */\r\n public enter(node: AnyNode, state: EvalState): void {\r\n state.hookBookkeeping.open.push(node);\r\n }\r\n\r\n /**\r\n * Closes `node`, matching it by **identity** rather than by position. Called\r\n * by the 'after' dispatcher before its hooks fire.\r\n *\r\n * Three cases:\r\n *\r\n * 1. `node` is on top - pop it. The ordinary path, one reference comparison.\r\n * 2. `node` is open but not on top - some visitor between here and there\r\n * never closed itself. Flush those frames innermost-first as\r\n * `completed: false`, then pop `node`.\r\n * 3. `node` is not open at all - pop nothing and emit nothing.\r\n *\r\n * Case 3 is what keeps a stray `exit` from draining the stack: the naive\r\n * \"pop until you find it\" would walk to the bottom, synthesise an event for\r\n * every genuinely-open enclosing frame, and leave a later real failure with\r\n * nothing to unwind.\r\n *\r\n * Popping positionally instead would be correct only if every visitor\r\n * bracketed its body exactly. `await-expression.ts` does not - it catches a\r\n * child's synchronous throw and continues to its own `afterVisitor` - so a\r\n * positional pop closes the child's frame under the parent's name, drops the\r\n * child's `after` entirely, and leaks one frame onto the state for good.\r\n *\r\n * The synthesised events carry no `value` (the node never pushed one) and no\r\n * `error` (nothing threw; the frames are being closed because an enclosing\r\n * visitor moved on without them).\r\n *\r\n * They are emitted under the collect policy even when the consumer chose\r\n * 'throw'. That is required, not merely lenient: a rethrow here would escape\r\n * the flush loop before it finished popping, re-creating the leak this\r\n * identity check exists to prevent. A 'throw'-policy consumer sees these in\r\n * `state.hookErrors` instead.\r\n */\r\n public exit(state: EvalState, node: AnyNode): void {\r\n const open = state.hookBookkeeping.open;\r\n\r\n if (open.length > 0 && open[open.length - 1] === node) {\r\n open.pop();\r\n return;\r\n }\r\n\r\n // The innermost occurrence is the one being closed: a node can legitimately\r\n // be open twice, since an arrow-function body is re-walked on every call.\r\n const index = open.lastIndexOf(node);\r\n if (index < 0) {\r\n return;\r\n }\r\n\r\n while (open.length > index + 1) {\r\n const stranded = open.pop();\r\n if (!stranded) {\r\n break;\r\n }\r\n this.emit({ phase: 'after', node: stranded, state, completed: false }, true);\r\n }\r\n\r\n open.pop();\r\n }\r\n\r\n /**\r\n * How many nodes the state has open. Captured as a mark before a walk, since\r\n * `evaluate` is re-entered with the same state from an arrow-function body.\r\n *\r\n * This is a method rather than a getter because the stack it measures lives\r\n * on the state, not on this registry.\r\n */\r\n public depth(state: EvalState): number {\r\n return state.hookBookkeeping.open.length;\r\n }\r\n\r\n /**\r\n * Fires 'after' for every node the state has open above `mark`, innermost\r\n * first, marked incomplete. Invoked from the catch in `evaluate`, so that a\r\n * visitor which throws still leaves every 'before' matched by exactly one\r\n * 'after'.\r\n *\r\n * Unwinding to a mark rather than to the bottom is what keeps a nested\r\n * `evaluate` from draining the enclosing walk's open nodes when a host\r\n * function swallows the nested throw.\r\n *\r\n * Idempotent, so the sync and async entry points can both call it.\r\n *\r\n * A hook that throws here cannot stop the drain: while unwinding, the 'throw'\r\n * policy is downgraded to 'collect' - evaluation has already failed, and the\r\n * original error is the one worth propagating.\r\n */\r\n public unwindTo(mark: number, error: unknown, state: EvalState): void {\r\n const open = state.hookBookkeeping.open;\r\n\r\n while (open.length > mark) {\r\n const node = open.pop();\r\n if (!node) {\r\n break;\r\n }\r\n this.emit({ phase: 'after', node, state, completed: false, error }, true);\r\n }\r\n }\r\n\r\n /**\r\n * Drains the state's whole open-node stack. Equivalent to `unwindTo(0, ...)`,\r\n * for callers that own the entire walk.\r\n */\r\n public unwind(error: unknown, state: EvalState): void {\r\n this.unwindTo(0, error, state);\r\n }\r\n\r\n private registry(phase: EvalHookPhase): Map<string, EvalNodeHook[]> {\r\n return phase === 'before' ? this._before : this._after;\r\n }\r\n\r\n private emit(event: EvalNodeHookEvent, unwinding: boolean): void {\r\n const registry = this.registry(event.phase);\r\n if (registry.size === 0) {\r\n return;\r\n }\r\n this.invokeAll(registry.get(event.node.type), event, unwinding);\r\n this.invokeAll(registry.get('*'), event, unwinding);\r\n }\r\n\r\n /**\r\n * Iterates a copy so that a hook which unsubscribes itself does not shift the\r\n * list out from under the loop.\r\n */\r\n private invokeAll(hooks: EvalNodeHook[] | undefined, event: EvalNodeHookEvent, unwinding: boolean): void {\r\n if (!hooks || hooks.length === 0) {\r\n return;\r\n }\r\n for (const hook of hooks.slice()) {\r\n this.invoke(hook, event, unwinding);\r\n }\r\n }\r\n\r\n private invoke(hook: EvalNodeHook, event: EvalNodeHookEvent, unwinding: boolean): void {\r\n let result: unknown;\r\n\r\n try {\r\n result = hook(event);\r\n } catch (error) {\r\n this.handleError(event.state, event.phase, event.node.type, error, unwinding);\r\n return;\r\n }\r\n\r\n if (isPromiseLike(result)) {\r\n this.handleError(event.state, event.phase, event.node.type,\r\n new Error(ASYNC_HOOK_MESSAGE), unwinding);\r\n }\r\n }\r\n\r\n /**\r\n * The read counterpart of {@link invoke}. There is no unwinding equivalent\r\n * for reads - a read never opens a frame - so the policy always applies in\r\n * full.\r\n */\r\n private invokeRead(hook: EvalReadHook, event: EvalReadEvent): void {\r\n let result: unknown;\r\n\r\n try {\r\n result = hook(event);\r\n } catch (error) {\r\n this.handleError(event.state, 'read', event.node.type, error, false);\r\n return;\r\n }\r\n\r\n if (isPromiseLike(result)) {\r\n this.handleError(event.state, 'read', event.node.type,\r\n new Error(ASYNC_HOOK_MESSAGE), false);\r\n }\r\n }\r\n\r\n private handleError(state: EvalState,\r\n phase: EvalHookPhase | 'read',\r\n nodeType: AnyNodeTypes,\r\n error: unknown,\r\n unwinding: boolean): void {\r\n\r\n if (this._policy === 'ignore') {\r\n return;\r\n }\r\n if (this._policy === 'throw' && !unwinding) {\r\n throw error;\r\n }\r\n state.hookBookkeeping.errors.push({ phase, nodeType, error });\r\n }\r\n}\r\n","import type { AnyNodeTypes } from '../../../interfaces';\r\nimport type { EvalHooks, EvalNodeHookEvent, Unsubscribe } from '../eval-hooks';\r\nimport type { EvalState } from '../eval-state';\r\n\r\n/**\r\n * A timing hook, ready to install on a registry.\r\n *\r\n * It carries no totals of its own: they are written to the `EvalState` being\r\n * evaluated and read back as `EvalState.nodeTimings`. That is what lets the\r\n * `trackTime` option install one from inside the `EvalState` constructor, where\r\n * the caller never sees this handle - and it is what keeps two evaluations\r\n * through a shared registry from accumulating into each other.\r\n */\r\nexport interface EvalTimingHook {\r\n /**\r\n * Registers the 'before'/'after' pair on `hooks`.\r\n *\r\n * @param hooks The registry to register on.\r\n * @returns A function that removes both halves of the pair.\r\n */\r\n install(hooks: EvalHooks): Unsubscribe;\r\n}\r\n\r\n/**\r\n * Creates a timing hook that accumulates inclusive per-node-type totals.\r\n *\r\n * Replaces the `console.time` / `console.timeEnd` pair the old `trackTime`\r\n * emitted, which mismatched its labels and produced no readable figure. The\r\n * readings are `performance.now()`, and nothing is written to the console.\r\n *\r\n * ```ts\r\n * const state = evalService.createState(context);\r\n * const off = createTimingHook().install(state.hooks);\r\n * evalService.eval('a + b * c', state);\r\n * state.nodeTimings.get('BinaryExpression'); // { count: 2, total: 0.081 }\r\n * off();\r\n * ```\r\n *\r\n * Equivalent to passing `{ trackTime: true }`, which installs one of these on\r\n * the state's own registry.\r\n *\r\n * @returns A handle whose `install` registers the pair on a registry.\r\n */\r\nexport const createTimingHook = (): EvalTimingHook => {\r\n\r\n /**\r\n * Start times for the nodes this handle currently has open, per state.\r\n *\r\n * Keyed by state because one handle may be installed on a registry that\r\n * several evaluations dispatch through, and a shared stack would interleave\r\n * them. Weak, so a finished evaluation's state is collectable while the\r\n * consumer holds the handle. Per *handle* rather than module-level, so two\r\n * handles installed on one state cannot pop each other's readings.\r\n *\r\n * A stack works because `EvalHooks` guarantees exactly one 'after' *frame*\r\n * per 'before' frame, innermost first, on every exit path - including the\r\n * synthesised events `exit` flushes for stranded frames and the ones\r\n * `unwindTo` emits when a visitor throws. It has to be a stack rather than a\r\n * map keyed by node: an arrow-function body is re-walked on every call, so\r\n * the same node can be open more than once.\r\n *\r\n * The guarantee is about frames, not about hook *invocations*. Under the\r\n * 'throw' policy an earlier hook can abort `dispatch`'s emit loop after\r\n * `enter` has already run, so this push is skipped while the frame stays\r\n * open; the `unwindTo` that follows then pops an enclosing node's reading and\r\n * attributes it to the wrong type. Pops never outnumber pushes, so nothing\r\n * strands into a later run on the same state - and the evaluation has failed\r\n * regardless, which is why the totals are left as they fall.\r\n */\r\n const starts = new WeakMap<EvalState, number[]>();\r\n\r\n const stackFor = (state: EvalState): number[] => {\r\n const existing = starts.get(state);\r\n if (existing) {\r\n return existing;\r\n }\r\n const created: number[] = [];\r\n starts.set(state, created);\r\n return created;\r\n };\r\n\r\n const before = (event: EvalNodeHookEvent): void => {\r\n stackFor(event.state).push(performance.now());\r\n };\r\n\r\n const after = (event: EvalNodeHookEvent): void => {\r\n const started = starts.get(event.state)?.pop();\r\n if (started === undefined) {\r\n // No matching 'before'. Reachable when this handle was installed midway\r\n // through a walk, or when a throwing hook skipped the push above;\r\n // recording a total from an unknown start would be worse than skipping.\r\n return;\r\n }\r\n\r\n record(event.state, event.node.type as AnyNodeTypes, performance.now() - started);\r\n };\r\n\r\n return {\r\n install(hooks: EvalHooks): Unsubscribe {\r\n const offBefore = hooks.on('before', '*', before);\r\n const offAfter = hooks.on('after', '*', after);\r\n\r\n return () => {\r\n offBefore();\r\n offAfter();\r\n };\r\n }\r\n };\r\n};\r\n\r\nconst record = (state: EvalState, type: AnyNodeTypes, elapsed: number): void => {\r\n const timings = state.hookBookkeeping.timings;\r\n const current = timings.get(type);\r\n\r\n timings.set(type, current\r\n ? { count: current.count + 1, total: current.total + elapsed }\r\n : { count: 1, total: elapsed });\r\n};\r\n","import { EvalContext } from './eval-context';\r\nimport { EvalOptions } from './eval-options';\r\nimport { EvalResult } from './eval-result';\r\nimport { EvalHooks } from './eval-hooks';\r\nimport type { AnyNodeTypes } from '../../interfaces';\r\nimport type { EvalHookBookkeeping, EvalHookError, EvalNodeTiming } from './eval-hooks';\r\nimport { createTimingHook } from './hooks/timing-hook';\r\nimport { Context } from '../common';\r\n\r\n/**\r\n * Reads a caller-supplied hook registry out of the evaluation options.\r\n *\r\n * `EvalOptions` is a union and does not index directly, so the read goes\r\n * through a cast - the same one `before-visitor.ts` performs. The registry is\r\n * adopted as-is and never cloned: the caller holds the unsubscribe closures\r\n * `on` returned, and a copy would leave those closures editing a registry that\r\n * is no longer the one being dispatched.\r\n */\r\nconst adoptHooks = (options?: EvalOptions): EvalHooks | undefined => {\r\n const value = (options as Record<string, unknown>)?.['hooks'];\r\n return value instanceof EvalHooks ? value : undefined;\r\n};\r\n\r\n/**\r\n * Whether the caller asked for per-node timings. Same cast, same reason.\r\n */\r\nconst readTrackTime = (options?: EvalOptions): boolean =>\r\n !!(options as Record<string, unknown>)?.['trackTime'];\r\n\r\n/**\r\n * Represents the evaluation state, which includes the context, result, and options.\r\n */\r\nexport class EvalState {\r\n private _context: EvalContext | undefined;\r\n private _result: EvalResult;\r\n private _options: EvalOptions | undefined;\r\n private _isAsync: boolean | undefined;\r\n private _hooks: EvalHooks | undefined;\r\n private _hookBookkeeping: EvalHookBookkeeping | undefined;\r\n\r\n /**\r\n * Gets the evaluation context.\r\n */\r\n public get context(): EvalContext | undefined {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the evaluation result.\r\n */\r\n public get result(): EvalResult {\r\n return this._result;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions | undefined {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation is asynchronous.\r\n */\r\n public get isAsync(): boolean | undefined {\r\n return this._isAsync;\r\n }\r\n\r\n /**\r\n * Gets the hook registry for this evaluation, creating an empty one on first\r\n * access. A registry supplied through `options.hooks` is adopted instead.\r\n *\r\n * Merely reading this does not turn {@link hasHooks} on; registering does.\r\n */\r\n public get hooks(): EvalHooks {\r\n return (this._hooks ??= new EvalHooks(this._options));\r\n }\r\n\r\n /**\r\n * The dispatch guard read by `beforeVisitor` / `afterVisitor`. One field read\r\n * and no options lookup, so the no-hooks path stays cheap.\r\n */\r\n public get hasHooks(): boolean {\r\n return !!this._hooks && this._hooks.isActive;\r\n }\r\n\r\n /**\r\n * Errors raised by hooks during this evaluation and collected under the\r\n * 'collect' policy.\r\n *\r\n * They live here rather than on {@link hooks} because an `EvalHooks` may be\r\n * shared across evaluations, and an error describes one run.\r\n *\r\n * The array is the live one, so a reference taken before evaluating fills as\r\n * errors arrive. Returning a shared empty array until the first collection\r\n * would be cheaper by one allocation and wrong: the reference would silently\r\n * stop tracking the moment anything was collected.\r\n */\r\n public get hookErrors(): readonly EvalHookError[] {\r\n return this.hookBookkeeping.errors;\r\n }\r\n\r\n /**\r\n * Per-node-type timings for **this state**, keyed by node type. Empty unless\r\n * a timing hook was installed - by `options.trackTime`, or by the caller\r\n * through `createTimingHook().install(state.hooks)`.\r\n *\r\n * Accumulates for the life of the state, not per `evaluate` call: under the\r\n * `createState` + repeated `eval` style the counts are the running totals\r\n * across every run on this state, which is what makes them comparable. A\r\n * caller who wants per-run figures uses a fresh state, or drops these along\r\n * with the rest of the run record via {@link resetHookBookkeeping}.\r\n *\r\n * Here rather than on the handle `createTimingHook` returns for the same\r\n * reason {@link hookErrors} is: timings describe one run, and an `EvalHooks`\r\n * may be handed to several. It is also the only place a `trackTime` caller\r\n * could reach them, since that installation happens in this constructor and\r\n * hands the handle to nobody.\r\n *\r\n * Totals are inclusive of child nodes; see `EvalNodeTiming`.\r\n */\r\n public get nodeTimings(): ReadonlyMap<AnyNodeTypes, EvalNodeTiming> {\r\n return this.hookBookkeeping.timings;\r\n }\r\n\r\n /**\r\n * The per-run bookkeeping `EvalHooks` reads and writes: the open-node stack\r\n * and the collected errors, grouped behind a single accessor.\r\n *\r\n * The state owns this storage and `eval-hooks.ts` only type-imports the\r\n * state, which keeps the runtime import graph acyclic. Holding it in a\r\n * module-private `WeakMap` inside `eval-hooks.ts` was the alternative and was\r\n * rejected: `hookErrors` would then need a *runtime* import of that module\r\n * while it already imports this one, and the resulting cycle is a hazard in\r\n * the ng-packagr build.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public get hookBookkeeping(): EvalHookBookkeeping {\r\n return (this._hookBookkeeping ??= { open: [], errors: [], timings: new Map() });\r\n }\r\n\r\n /**\r\n * Drops every per-run record this state holds: the collected hook errors, the\r\n * open-node stack, and the accumulated timings.\r\n *\r\n * It resets the whole record rather than only the errors, which is why it is\r\n * not named for them. `EvalHooks.clear` cannot reach any of this - the\r\n * bookkeeping belongs to the state - so without this method nothing drains\r\n * the open-node stack at all. Frames left on it keep their AST nodes\r\n * reachable for as long as the state is, and `EvalService` holds its states\r\n * in a strong `Set`.\r\n *\r\n * The errors matter for the same reason under the state-first style:\r\n * `createState` plus repeated `eval` on one state accumulates them for the\r\n * life of that state, and a thrown value can close over consumer objects.\r\n *\r\n * The record is replaced rather than emptied in place, so a caller still\r\n * holding the array {@link hookErrors} handed out keeps its own contents and\r\n * simply stops tracking - the alternative would mutate a collection the\r\n * caller owns a reference to.\r\n *\r\n * Calling this mid-walk is unsupported for the same reason `EvalHooks.clear`\r\n * is: it abandons frames the dispatcher expects to close.\r\n */\r\n public resetHookBookkeeping(): void {\r\n this._hookBookkeeping = undefined;\r\n }\r\n\r\n /**\r\n * Represents the state of an evaluation.\r\n * @param context The evaluation context.\r\n * @param result The evaluation result.\r\n * @param options The evaluation options.\r\n * @param isAsync Indicates whether the evaluation is asynchronous.\r\n */\r\n constructor(context: EvalContext | undefined,\r\n result: EvalResult,\r\n options?: EvalOptions,\r\n isAsync?: boolean) {\r\n\r\n this._context = context;\r\n this._result = result;\r\n this._options = options;\r\n this._isAsync = isAsync;\r\n this._hooks = adoptHooks(options);\r\n\r\n // Options configure the registry this state owns, never an adopted one -\r\n // the same rule `onHookError` follows, and for the same reason: an adopted\r\n // `EvalHooks` belongs to the caller, and installing into it would leave a\r\n // hook firing on every later evaluation they run through it, with the\r\n // unsubscribe this call discards as the only way off. A caller who wants\r\n // both passes their own registry and installs the hook on it themselves.\r\n if (!this._hooks && readTrackTime(options)) {\r\n // Registering here rather than lazily means `isActive` has latched before\r\n // the walk starts, so every node dispatches for its whole duration. That\r\n // is what was asked for: per-node-type totals cannot be had without\r\n // visiting each node, and `EvalResult.duration` already covers the\r\n // cheaper walk-level question.\r\n createTimingHook().install(this.hooks);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalState from a given context, options, and async flag.\r\n *\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @param isAsync - A flag indicating whether the evaluation is asynchronous.\r\n * @returns The created EvalState instance.\r\n */\r\n static fromContext(context?: EvalContext | Context,\r\n options?: EvalOptions,\r\n isAsync?: boolean): EvalState {\r\n\r\n const ctx = EvalContext.fromContext(context, options);\r\n const result = new EvalResult(ctx);\r\n const state = new EvalState(ctx, result, options, isAsync);\r\n return state;\r\n }\r\n\r\n}\r\n","import { defaultOptions } from \"acorn\";\r\nimport { ParserOptions } from \"../../interfaces\";\r\n\r\nexport const defaultParserOptions: ParserOptions = {\r\n ...defaultOptions,\r\n ecmaVersion: 2020,\r\n extractExpressions: false,\r\n cacheSize: 100\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const pushVisitorResult = (node: AnyNode, st: EvalState, value: unknown) => {\r\n const result = st.result;\r\n result.stack.push(value);\r\n result.trace.add(node, value, st.result.expression);\r\n return value;\r\n}\r\n\r\nexport const popVisitorResult = (node: AnyNode, st: EvalState): unknown => {\r\n const result = st.result;\r\n const value = result.stack.pop();\r\n return value;\r\n}\r\n\r\nexport const pushVisitorResultAsync = (node: AnyNode, st: EvalState, value: Promise<unknown>) => {\r\n const result = st.result;\r\n result.stack.push(value);\r\n result.trace.add(node, value, st.result.expression);\r\n return value;\r\n}\r\n\r\nexport const popVisitorResultAsync = (node: AnyNode, st: EvalState): Promise<unknown> => {\r\n const result = st.result;\r\n const value = result.stack.pop() as Promise<unknown>;\r\n return value;\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Opens a node: records it as open and fires the registered 'before' hooks.\r\n *\r\n * Called at the top of every visitor body. The guard is a single boolean field\r\n * read - no options lookup - so an evaluation with no hooks pays almost\r\n * nothing, and it wraps the open-node bookkeeping as well as the hooks\r\n * themselves so `enter` and `exit` cannot become unpaired mid-walk.\r\n */\r\nexport const beforeVisitor = (node: AnyNode, st: EvalState): void => {\r\n\r\n if (!st.hasHooks) {\r\n return;\r\n }\r\n\r\n st.hooks.dispatch('before', node, st);\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Closes a node: pops it off the open-node stack and fires the registered\r\n * 'after' hooks.\r\n *\r\n * The event's `value` is read **positionally** - it is whatever sits on top of\r\n * the result stack right now, not something keyed to this node. Reading it here\r\n * is what makes the value available without changing any visitor's call\r\n * signature, and it is correct for every visitor that pushes its result\r\n * immediately before calling this. A visitor that reaches this without pushing\r\n * would report its *neighbour's* value, not `undefined`; the length check below\r\n * only guards the empty stack, since `Stack.peek` is non-destructive but does\r\n * not bounds-check.\r\n */\r\nexport const afterVisitor = (node: AnyNode, st: EvalState): void => {\r\n\r\n if (!st.hasHooks) {\r\n return;\r\n }\r\n\r\n const stack = st.result?.stack;\r\n const value = stack && stack.length > 0 ? stack.peek() : undefined;\r\n\r\n st.hooks.dispatch('after', node, st, value);\r\n}\r\n","import { WalkerCallback } from 'acorn-walk';\r\nimport * as acorn from 'acorn';\r\nimport { StackType } from './stack-type';\r\nimport { AnyNode } from 'acorn';\r\nimport { RegistryType } from './registry-type';\r\nimport { AnyNodeTypes } from './parser-types';\r\nimport { BaseRegistry, Registry } from '../public-api';\r\n\r\n/**\r\n * @deprecated Use `EvalHooks` and `EvalState` instead. Nothing in the library\r\n * implements this interface, and no code path reads its `beforeVisitors` /\r\n * `afterVisitors` entries; the evaluator's state type is `EvalState` and hooks\r\n * are registered through `EvalState.hooks`.\r\n *\r\n * **Its two hook entries are the last published trace of a signature no\r\n * function in the library has any more.** They are typed to return\r\n * `number | undefined` because the real `beforeVisitor` / `afterVisitor` once\r\n * returned a timing stub - a start timestamp handed back to the closing call.\r\n * That stub was deleted when those functions became hook dispatchers and their\r\n * return type widened to `void`, which is also what `EvalNodeHook` mandates, so\r\n * the shape recorded here is now contradicted by every hook the library\r\n * actually dispatches. A reader who finds these lines has no way to discover\r\n * that from the code, since there is no implementation left to compare against.\r\n *\r\n * Retained so this release stays purely additive; removal is a follow-up for\r\n * the next breaking version.\r\n */\r\nexport interface RecursiveVisitorState {\r\n scope: Registry<unknown, unknown>,\r\n result: RecursiveVisitorResult<unknown | undefined>,\r\n option: RecursiveVisitorOptions,\r\n beforeVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>,\r\n afterVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>,\r\n}\r\nexport interface RecursiveVisitorOptions {\r\n trackTime?: boolean;\r\n resultType?: 'stack' | 'registry';\r\n}\r\nexport interface RecursiveVisitorContext {\r\n placeholder?: unknown; // Placeholder for future context data\r\n}\r\n\r\nexport enum RecursiveVisitorResultType {\r\n Stack,\r\n Registry\r\n}\r\n\r\n/**\r\n * @deprecated Use `EvalResult` instead. This exists only as the `result` member\r\n * of the deprecated {@link RecursiveVisitorState}; the evaluator carries its\r\n * value stack and trace on `EvalResult`, which is what visitors actually push\r\n * to and what `EvalState.result` returns.\r\n *\r\n * Retained so this release stays purely additive; removal is a follow-up for\r\n * the next breaking version.\r\n */\r\nexport type RecursiveVisitorResult<TValue> =\r\n RecursiveVisitorStackResult<TValue> |\r\n RecursiveVisitorRegistryResult<TValue>\r\n\r\nexport interface RecursiveVisitorStackResult<TValue> {\r\n type: 'stack',\r\n stack: StackType<TValue>\r\n}\r\n\r\nexport interface RecursiveVisitorRegistryResult<TValue> {\r\n type: 'registry',\r\n registry: BaseRegistry<AnyNode, TValue>\r\n}\r\n\r\nexport type AggregateType = {\r\n Expression: acorn.Expression,\r\n Statement: acorn.Statement,\r\n Function: acorn.Function,\r\n Class: acorn.Class,\r\n Pattern: acorn.Pattern,\r\n ForInit: acorn.VariableDeclaration | acorn.Expression\r\n}\r\n\r\nexport type RecursiveVisitor<TState> = ( node: acorn.AnyNode, state: TState, callback: WalkerCallback<TState>) => void;\r\n\r\nexport type RecursiveAggregateVisitor<TState> = ( node: AggregateType, state: TState, callback: WalkerCallback<TState>) => void;\r\n\r\n","import { Identifier } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { Registry } from '../public-api';\r\nimport { equalIgnoreCase } from './utils';\r\n\r\nconst literals: Registry<string, unknown>= Registry.fromObject({\r\n 'undefined': undefined,\r\n 'null': null,\r\n 'true': true,\r\n 'false': false,\r\n}, { caseInsensitive: true });\r\n\r\n/**\r\n * Reports a resolved identifier read to the hook layer.\r\n *\r\n * The key is the one the context actually matched, so a case-insensitive\r\n * lookup reports the corrected spelling; `getKey` returns undefined for a name\r\n * the context does not hold - a literal-registry resolution, or a miss - and\r\n * the source name stands in. The path is always the source spelling, since it\r\n * is reconstructed statically.\r\n *\r\n * `scoped` marks a read of a name bound by a scope pushed *during this walk* -\r\n * an arrow-function parameter. It is asked of `EvalContext.hasInScopes`, which\r\n * tests for the binding rather than for its value: a parameter bound to\r\n * `undefined` is still a parameter, and reading the flag off the resolved value\r\n * would make it vary with the data rather than with the expression.\r\n *\r\n * It is deliberately *not* set for `priorScopes`: those hold caller-registered,\r\n * long-lived objects and are real dependencies, so the discriminator is\r\n * lifetime rather than `instanceof EvalScope`. The property is omitted rather\r\n * than set to false, so absent reads as \"not scoped\" the same way it does at\r\n * the member emission sites.\r\n *\r\n * The scope stack is empty for any expression without an arrow function, and\r\n * `Stack.asArray` allocates, so the common case is short-circuited on length.\r\n */\r\nconst emitRead = (node: Identifier, st: EvalState, value: unknown) => {\r\n const key = st.context?.getKey(node.name) ?? node.name;\r\n const scoped = !!st.context\r\n && st.context.scopes.length > 0\r\n && st.context.hasInScopes(node.name);\r\n\r\n st.hooks.dispatchRead({\r\n kind: 'identifier',\r\n node,\r\n state: st,\r\n key,\r\n target: st.context,\r\n path: node.name,\r\n value,\r\n ...(scoped ? { scoped: true } : {})\r\n });\r\n}\r\n\r\nexport const identifierVisitor = (node: Identifier, st: EvalState) => {\r\n\r\n if (st.options?.caseInsensitive) {\r\n return identifierVisitorCaseInsensitive(node, st);\r\n }\r\n\r\n beforeVisitor(node, st);\r\n\r\n const context = st.context;\r\n\r\n const isThis = node.name === 'this';\r\n\r\n const value = isThis\r\n ? st.context\r\n : context?.get(node.name);\r\n\r\n // `this` resolves to the context object itself rather than to a key within\r\n // it, so it is not a read: reporting it would have a dependency tracker\r\n // record the whole context and re-fire on every change to it.\r\n if (st.hasHooks && st.hooks.hasReadHooks && !isThis) {\r\n emitRead(node, st, value);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nconst identifierVisitorCaseInsensitive = (node: Identifier, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const context = st.context;\r\n\r\n const isThis = !!equalIgnoreCase(node.name, 'this');\r\n\r\n const value = isThis\r\n ? st.context\r\n : context?.get(node.name) ?? literals.get(node.name);\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks && !isThis) {\r\n emitRead(node, st, value);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { Literal } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const literalVisitor = (node: Literal, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const value = node.value;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { BinaryExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n// import { getCachedVisitorResult, setCachedVisitorResult } from './visitor-result-cache';\r\n\r\n/**\r\n * Converts value to primitive for comparison operations\r\n */\r\nconst toPrimitive = (value: unknown, hint?: 'string' | 'number'): string | number | boolean | null | undefined | symbol | bigint => {\r\n if (value === null || value === undefined) return value;\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || \r\n typeof value === 'symbol' || typeof value === 'bigint') return value;\r\n \r\n // For objects, call valueOf/toString based on hint\r\n if (typeof value === 'object') {\r\n if (hint === 'number') {\r\n const valueOf = (value as Record<string, unknown>).valueOf;\r\n if (typeof valueOf === 'function') {\r\n const result = valueOf.call(value);\r\n if (typeof result !== 'object') return result as string | number | boolean | null | undefined | symbol | bigint;\r\n }\r\n const toString = (value as Record<string, unknown>).toString;\r\n if (typeof toString === 'function') {\r\n return toString.call(value) as string;\r\n }\r\n } else {\r\n const toString = (value as Record<string, unknown>).toString;\r\n if (typeof toString === 'function') {\r\n const result = toString.call(value);\r\n if (typeof result === 'string') return result;\r\n }\r\n const valueOf = (value as Record<string, unknown>).valueOf;\r\n if (typeof valueOf === 'function') {\r\n const result = valueOf.call(value);\r\n if (typeof result !== 'object') return result as string | number | boolean | null | undefined | symbol | bigint;\r\n }\r\n }\r\n }\r\n \r\n return String(value);\r\n};\r\n\r\n/**\r\n * Safely evaluates binary operations with proper type coercion\r\n */\r\nconst evaluateBinaryOperation = (operator: string, left: unknown, right: unknown): unknown => {\r\n switch (operator) {\r\n case '+': {\r\n // Handle string concatenation and numeric addition according to JavaScript rules\r\n const leftPrim = toPrimitive(left);\r\n const rightPrim = toPrimitive(right);\r\n if (typeof leftPrim === 'string' || typeof rightPrim === 'string') {\r\n return String(leftPrim) + String(rightPrim);\r\n }\r\n return Number(leftPrim) + Number(rightPrim);\r\n }\r\n \r\n case '-':\r\n return Number(toPrimitive(left, 'number')) - Number(toPrimitive(right, 'number'));\r\n case '*':\r\n return Number(toPrimitive(left, 'number')) * Number(toPrimitive(right, 'number'));\r\n case '/':\r\n return Number(toPrimitive(left, 'number')) / Number(toPrimitive(right, 'number'));\r\n case '%':\r\n return Number(toPrimitive(left, 'number')) % Number(toPrimitive(right, 'number'));\r\n case '**':\r\n return Number(toPrimitive(left, 'number')) ** Number(toPrimitive(right, 'number'));\r\n \r\n // Bitwise operations - convert to 32-bit integers\r\n case '<<':\r\n return (Number(toPrimitive(left, 'number')) | 0) << (Number(toPrimitive(right, 'number')) | 0);\r\n case '>>':\r\n return (Number(toPrimitive(left, 'number')) | 0) >> (Number(toPrimitive(right, 'number')) | 0);\r\n case '>>>':\r\n return (Number(toPrimitive(left, 'number')) >>> 0) >>> (Number(toPrimitive(right, 'number')) | 0);\r\n case '&':\r\n return (Number(toPrimitive(left, 'number')) | 0) & (Number(toPrimitive(right, 'number')) | 0);\r\n case '^':\r\n return (Number(toPrimitive(left, 'number')) | 0) ^ (Number(toPrimitive(right, 'number')) | 0);\r\n case '|':\r\n return (Number(toPrimitive(left, 'number')) | 0) | (Number(toPrimitive(right, 'number')) | 0);\r\n \r\n // Comparison operations - follow JavaScript's abstract comparison rules\r\n case '==':\r\n return left == right;\r\n case '!=':\r\n return left != right;\r\n case '===':\r\n return left === right;\r\n case '!==':\r\n return left !== right;\r\n case '<': {\r\n const leftComp = toPrimitive(left, 'number');\r\n const rightComp = toPrimitive(right, 'number');\r\n // If both are strings, do string comparison\r\n if (typeof leftComp === 'string' && typeof rightComp === 'string') {\r\n return leftComp < rightComp;\r\n }\r\n return Number(leftComp) < Number(rightComp);\r\n }\r\n case '<=': {\r\n const leftLE = toPrimitive(left, 'number');\r\n const rightLE = toPrimitive(right, 'number');\r\n if (typeof leftLE === 'string' && typeof rightLE === 'string') {\r\n return leftLE <= rightLE;\r\n }\r\n return Number(leftLE) <= Number(rightLE);\r\n }\r\n case '>': {\r\n const leftGT = toPrimitive(left, 'number');\r\n const rightGT = toPrimitive(right, 'number');\r\n if (typeof leftGT === 'string' && typeof rightGT === 'string') {\r\n return leftGT > rightGT;\r\n }\r\n return Number(leftGT) > Number(rightGT);\r\n }\r\n case '>=': {\r\n const leftGE = toPrimitive(left, 'number');\r\n const rightGE = toPrimitive(right, 'number');\r\n if (typeof leftGE === 'string' && typeof rightGE === 'string') {\r\n return leftGE >= rightGE;\r\n }\r\n return Number(leftGE) >= Number(rightGE);\r\n }\r\n \r\n // Special operations\r\n case 'in': {\r\n if (typeof left === 'string' || typeof left === 'number' || typeof left === 'symbol') {\r\n if (right == null) {\r\n throw new Error(`Cannot use 'in' operator with null or undefined right operand`);\r\n }\r\n return left in (right as object);\r\n }\r\n throw new Error(`Invalid left operand for 'in' operator: ${typeof left}`);\r\n }\r\n \r\n case 'instanceof': {\r\n if (typeof right === 'function') {\r\n return left instanceof right;\r\n }\r\n throw new Error(`Right operand of 'instanceof' is not a constructor`);\r\n }\r\n \r\n case '??':\r\n return left ?? right;\r\n \r\n default:\r\n throw new Error(`Unsupported binary operator: ${operator}`);\r\n }\r\n};\r\n\r\n/**\r\n * Safely evaluates binary expressions with proper type handling\r\n */\r\nexport const binaryExpressionVisitor = (node: BinaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Disable visitor result caching for now due to context sensitivity issues\r\n // const cachedResult = getCachedVisitorResult(node, st.context);\r\n // if (cachedResult !== undefined) {\r\n // pushVisitorResult(node, st, cachedResult);\r\n // afterVisitor(node, st);\r\n // return;\r\n // }\r\n\r\n callback(node.left, st);\r\n const left = popVisitorResult(node, st);\r\n\r\n callback(node.right, st);\r\n const right = popVisitorResult(node, st);\r\n\r\n const value = evaluateBinaryOperation(node.operator, left, right);\r\n\r\n // Disable visitor result caching for now\r\n // setCachedVisitorResult(node, st.context, value);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","/**\r\n * Prototype Pollution Prevention Utilities\r\n *\r\n * This module provides safeguards against prototype pollution attacks\r\n * by controlling access to dangerous property names and ensuring safe\r\n * object operations.\r\n */\r\n\r\n/**\r\n * Set of property names that are dangerous for prototype pollution attacks\r\n */\r\nconst DANGEROUS_PROPERTY_NAMES = new Set([\r\n '__proto__',\r\n 'constructor',\r\n 'prototype',\r\n '__defineGetter__',\r\n '__defineSetter__',\r\n '__lookupGetter__',\r\n '__lookupSetter__',\r\n 'hasOwnProperty',\r\n 'isPrototypeOf',\r\n 'propertyIsEnumerable',\r\n 'toString',\r\n 'valueOf',\r\n 'toLocaleString'\r\n]);\r\n\r\n/**\r\n * Set of constructor names that should be blocked from modification\r\n */\r\nconst DANGEROUS_CONSTRUCTORS = new Set([\r\n 'Object',\r\n 'Function',\r\n 'Array',\r\n 'String',\r\n 'Number',\r\n 'Boolean',\r\n 'Date',\r\n 'RegExp',\r\n 'Error',\r\n 'Promise'\r\n]);\r\n\r\n/**\r\n * Checks if a property name is dangerous for prototype pollution\r\n * @param key The property name to check\r\n * @returns true if the property is dangerous, false otherwise\r\n */\r\nexport const isDangerousProperty = (key: unknown): boolean => {\r\n if (typeof key === 'string') {\r\n return DANGEROUS_PROPERTY_NAMES.has(key);\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Checks if an object is a dangerous constructor that shouldn't be modified\r\n * @param obj The object to check\r\n * @returns true if the object is a dangerous constructor, false otherwise\r\n */\r\nexport const isDangerousConstructor = (obj: unknown): boolean => {\r\n if (typeof obj === 'function' && obj.name) {\r\n return DANGEROUS_CONSTRUCTORS.has(obj.name);\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Safely sets a property on an object with prototype pollution protection\r\n * @param target The target object\r\n * @param key The property key\r\n * @param value The property value\r\n * @throws Error if the operation would cause prototype pollution\r\n */\r\nexport const safeSetProperty = (target: unknown, key: unknown, value: unknown): void => {\r\n if (!target || (typeof target !== 'object' && typeof target !== 'function')) {\r\n throw new Error(`Cannot set property on non-object: ${typeof target}`);\r\n }\r\n\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${String(key)}\" is blocked for security reasons`);\r\n }\r\n\r\n // Additional protection: don't allow setting properties on built-in prototypes\r\n if (isDangerousConstructor(target)) {\r\n throw new Error(`Modification of built-in constructor \"${(target as {name: string}).name}\" is blocked for security reasons`);\r\n }\r\n\r\n // Check if we're trying to modify prototype chain\r\n if (target === Object.prototype ||\r\n target === Function.prototype ||\r\n target === Array.prototype ||\r\n target === String.prototype ||\r\n target === Number.prototype ||\r\n target === Boolean.prototype) {\r\n throw new Error(`Modification of built-in prototype is blocked for security reasons`);\r\n }\r\n\r\n // Convert key to PropertyKey for safe operations\r\n let propertyKey: PropertyKey;\r\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\r\n propertyKey = key;\r\n } else {\r\n // For other types, try to convert to string\r\n propertyKey = String(key);\r\n }\r\n\r\n // Use Object.defineProperty for safer assignment\r\n const descriptor = {\r\n value,\r\n writable: true,\r\n enumerable: true,\r\n configurable: true\r\n };\r\n\r\n try {\r\n Object.defineProperty(target as object, propertyKey, descriptor);\r\n } catch (error) {\r\n throw new Error(`Failed to set property \"${String(key)}\": ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n};\r\n\r\n/**\r\n * Safely gets a property from an object with prototype pollution protection\r\n * @param target The target object\r\n * @param key The property key\r\n * @returns The property value or undefined\r\n */\r\nexport const safeGetProperty = (target: unknown, key: unknown): unknown => {\r\n if (!target || (typeof target !== 'object' && typeof target !== 'function')) {\r\n return undefined;\r\n }\r\n\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${String(key)}\" is blocked for security reasons`);\r\n }\r\n\r\n // Convert key to PropertyKey for safe operations\r\n let propertyKey: PropertyKey;\r\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\r\n propertyKey = key;\r\n } else {\r\n // For other types, try to convert to string\r\n propertyKey = String(key);\r\n }\r\n\r\n // Direct property access using bracket notation (safer than complex prototype walking)\r\n try {\r\n return (target as Record<PropertyKey, unknown>)[propertyKey];\r\n } catch {\r\n // If property access fails, return undefined\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Creates a safe object without dangerous prototype pollution vectors\r\n * @param entries Key-value pairs to populate the object\r\n * @returns A new safe object\r\n */\r\nexport const createSafeObject = (entries: Array<[unknown, unknown]> = []): Record<string, unknown> => {\r\n // Create object with normal prototype for compatibility, but validate contents\r\n const obj: Record<string, unknown> = {};\r\n\r\n for (const [key, value] of entries) {\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Cannot create object with dangerous property \"${String(key)}\"`);\r\n }\r\n\r\n // Safely set the property\r\n if (typeof key === 'string' || typeof key === 'number') {\r\n obj[key] = value;\r\n } else if (typeof key === 'symbol') {\r\n (obj as Record<symbol, unknown>)[key] = value;\r\n }\r\n }\r\n\r\n return obj;\r\n};\r\n\r\n/**\r\n * Validates that an object is safe from prototype pollution\r\n * @param obj The object to validate\r\n * @throws Error if the object contains dangerous properties\r\n */\r\nexport const validateSafeObject = (obj: unknown): void => {\r\n if (!obj || typeof obj !== 'object') {\r\n return;\r\n }\r\n\r\n const keys = Object.getOwnPropertyNames(obj);\r\n for (const key of keys) {\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Object contains dangerous property \"${key}\" that could lead to prototype pollution`);\r\n }\r\n }\r\n\r\n // Also check symbol properties\r\n const symbols = Object.getOwnPropertySymbols(obj);\r\n for (const symbol of symbols) {\r\n const description = symbol.description;\r\n if (description && isDangerousProperty(description)) {\r\n throw new Error(`Object contains dangerous symbol property \"${description}\" that could lead to prototype pollution`);\r\n }\r\n }\r\n};\r\n","/**\r\n * Property Lookup Cache\r\n * \r\n * Provides efficient caching for case-insensitive property lookups\r\n * to avoid repeated O(n) searches through object property lists.\r\n */\r\n\r\ninterface PropertyLookupCacheEntry {\r\n foundKey: string | null;\r\n lastAccessed: number;\r\n objectHash: string;\r\n}\r\n\r\n/**\r\n * Cache for property lookup results to optimize case-insensitive property access\r\n */\r\nclass PropertyLookupCache {\r\n private readonly _cache = new Map<string, PropertyLookupCacheEntry>();\r\n private readonly _maxSize: number;\r\n private readonly _expirationTime: number; // in milliseconds\r\n \r\n constructor(maxSize = 1000, expirationTimeMs = 5 * 60 * 1000) { // 5 minutes default\r\n this._maxSize = maxSize;\r\n this._expirationTime = expirationTimeMs;\r\n }\r\n\r\n /**\r\n * Generates a simple hash for an object based on its own property names\r\n */\r\n private generateObjectHash(obj: Record<PropertyKey, unknown>): string {\r\n try {\r\n const keys = Object.getOwnPropertyNames(obj);\r\n return keys.length.toString() + '_' + keys.slice(0, 5).join('_');\r\n } catch {\r\n return 'unknown_hash';\r\n }\r\n }\r\n\r\n /**\r\n * Generates a cache key for a property lookup\r\n */\r\n private generateCacheKey(objectHash: string, searchKey: string): string {\r\n return `${objectHash}:${searchKey.toLowerCase()}`;\r\n }\r\n\r\n /**\r\n * Checks if a cache entry is still valid\r\n */\r\n private isEntryValid(entry: PropertyLookupCacheEntry, objectHash: string): boolean {\r\n const now = Date.now();\r\n return (\r\n entry.objectHash === objectHash &&\r\n (now - entry.lastAccessed) < this._expirationTime\r\n );\r\n }\r\n\r\n /**\r\n * Cleans up expired entries and maintains cache size\r\n */\r\n private cleanup(): void {\r\n const now = Date.now();\r\n const entries = Array.from(this._cache.entries());\r\n \r\n // Remove expired entries\r\n for (const [key, entry] of entries) {\r\n if ((now - entry.lastAccessed) >= this._expirationTime) {\r\n this._cache.delete(key);\r\n }\r\n }\r\n \r\n // If still too large, remove oldest entries\r\n if (this._cache.size > this._maxSize) {\r\n const sortedEntries = Array.from(this._cache.entries())\r\n .sort(([, a], [, b]) => a.lastAccessed - b.lastAccessed);\r\n \r\n const entriesToRemove = sortedEntries.slice(0, this._cache.size - this._maxSize);\r\n for (const [key] of entriesToRemove) {\r\n this._cache.delete(key);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets a cached property lookup result\r\n */\r\n get(obj: Record<PropertyKey, unknown>, searchKey: string): string | null | undefined {\r\n const objectHash = this.generateObjectHash(obj);\r\n const cacheKey = this.generateCacheKey(objectHash, searchKey);\r\n \r\n const entry = this._cache.get(cacheKey);\r\n if (entry && this.isEntryValid(entry, objectHash)) {\r\n // Update access time\r\n entry.lastAccessed = Date.now();\r\n return entry.foundKey;\r\n }\r\n \r\n return undefined; // Cache miss\r\n }\r\n\r\n /**\r\n * Sets a cached property lookup result\r\n */\r\n set(obj: Record<PropertyKey, unknown>, searchKey: string, foundKey: string | null): void {\r\n // Perform cleanup periodically\r\n if (this._cache.size > this._maxSize * 0.8) {\r\n this.cleanup();\r\n }\r\n \r\n const objectHash = this.generateObjectHash(obj);\r\n const cacheKey = this.generateCacheKey(objectHash, searchKey);\r\n \r\n this._cache.set(cacheKey, {\r\n foundKey,\r\n lastAccessed: Date.now(),\r\n objectHash\r\n });\r\n }\r\n\r\n /**\r\n * Clears the entire cache\r\n */\r\n clear(): void {\r\n this._cache.clear();\r\n }\r\n\r\n /**\r\n * Gets current cache size\r\n */\r\n get size(): number {\r\n return this._cache.size;\r\n }\r\n}\r\n\r\n// Global property lookup cache instance\r\nconst propertyLookupCache = new PropertyLookupCache();\r\n\r\n/**\r\n * Performs optimized case-insensitive property lookup with caching\r\n */\r\nexport function getCachedCaseInsensitiveProperty(\r\n obj: Record<PropertyKey, unknown>,\r\n searchKey: string,\r\n equalIgnoreCase: (a: string, b: string) => boolean\r\n): string | null {\r\n // Try to get from cache first\r\n const cachedResult = propertyLookupCache.get(obj, searchKey);\r\n if (cachedResult !== undefined) {\r\n return cachedResult;\r\n }\r\n \r\n // Cache miss - perform actual lookup\r\n let foundKey: string | null = null;\r\n \r\n if (obj && typeof obj === 'object') {\r\n const ownKeys = Object.getOwnPropertyNames(obj);\r\n const matchingKey = ownKeys.find(k => equalIgnoreCase(k, searchKey));\r\n foundKey = matchingKey || null;\r\n }\r\n \r\n // Cache the result\r\n propertyLookupCache.set(obj, searchKey, foundKey);\r\n \r\n return foundKey;\r\n}\r\n\r\n/**\r\n * Clears the property lookup cache (for testing or memory management)\r\n */\r\nexport function clearPropertyLookupCache(): void {\r\n propertyLookupCache.clear();\r\n}\r\n\r\n/**\r\n * Gets current property lookup cache statistics\r\n */\r\nexport function getPropertyLookupCacheStats(): { size: number, maxSize: number } {\r\n return {\r\n size: propertyLookupCache.size,\r\n maxSize: 1000 // This should match the maxSize in constructor\r\n };\r\n}","import { MemberExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalScope, EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { safeGetProperty, isDangerousProperty } from './prototype-pollution-guard';\r\nimport { equalIgnoreCase } from './utils';\r\nimport { getCachedCaseInsensitiveProperty } from './property-lookup-cache';\r\n// import { getCachedVisitorResult, setCachedVisitorResult } from './visitor-result-cache';\r\n\r\n/**\r\n * Reconstructs the dotted source path of a member chain (`a.b.c`).\r\n *\r\n * Static only: a computed hop (`a[expr]`, `a[\"b\"]`) leaves the path\r\n * unreconstructible and yields undefined, and a consumer falls back to\r\n * `target` + `key` identity - which is exact either way. The parts are source\r\n * spellings, so under `caseInsensitive` the path is not corrected even though\r\n * the reported key is; optional markers are not represented either, so `a?.b`\r\n * reconstructs as `a.b`. A chain rooted at anything but an `Identifier` - a\r\n * `this`, a call, a `super` - yields undefined.\r\n *\r\n * Walks the chain once per member read, so every call site sits behind\r\n * `st.hasHooks && st.hooks.hasReadHooks`: a consumer that registered only node\r\n * hooks must not pay for a path it can never observe.\r\n */\r\nconst readPath = (node: MemberExpression): string | undefined => {\r\n const parts: string[] = [];\r\n let current: MemberExpression['object'] = node;\r\n\r\n while (current.type === 'MemberExpression') {\r\n if (current.computed || current.property.type !== 'Identifier') {\r\n return undefined;\r\n }\r\n parts.unshift(current.property.name);\r\n current = current.object;\r\n }\r\n\r\n if (current.type !== 'Identifier') {\r\n return undefined;\r\n }\r\n\r\n parts.unshift(current.name);\r\n return parts.join('.');\r\n}\r\n\r\nexport const memberExpressionVisitor = (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Disable visitor result caching for now due to context sensitivity issues\r\n // const cachedResult = getCachedVisitorResult(node, st.context);\r\n // if (cachedResult !== undefined) {\r\n // pushVisitorResult(node, st, cachedResult);\r\n // afterVisitor(node, st);\r\n // return;\r\n // }\r\n\r\n const [, , value] = evaluateMember(node, st, callback);\r\n\r\n // Disable visitor result caching for now\r\n // setCachedVisitorResult(node, st.context, value);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateMember = (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n // Get the object\r\n callback(node.object, st);\r\n const obj = popVisitorResult(node, st) as object;\r\n const object = (node.optional ? (obj || {}) : obj);\r\n\r\n // Get the property\r\n let key: string | number | symbol;\r\n if (!node.computed && node.property.type === 'Identifier') {\r\n // Dot notation: obj.prop\r\n key = node.property.name;\r\n } else if (node.property.type === 'Literal') {\r\n // Computed literal: obj[\"literal\"]\r\n key = node.property.value as string | number | symbol;\r\n } else {\r\n // Computed expression: obj[key], obj[expression]\r\n callback(node.property, st);\r\n key = popVisitorResult(node, st) as (string | number | symbol);\r\n }\r\n\r\n // Get the value with context-aware or prototype pollution protection\r\n if (object === st.context) {\r\n // For context objects, preserve case-insensitive behavior\r\n const contextKey = st.options?.caseInsensitive && typeof key === 'string'\r\n ? st.context.getKey(key)\r\n : key;\r\n const value = st.context.get(contextKey);\r\n const thisValue = st.context.getThis(contextKey);\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key: contextKey ?? key,\r\n target: st.context,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [thisValue ?? object, contextKey, value];\r\n } else if (object instanceof EvalScope) {\r\n // For scope objects, preserve original behavior (no getKey method)\r\n const value = object.get(key);\r\n const thisValue = object;\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key,\r\n target: object,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [thisValue ?? object, key, value];\r\n } else {\r\n // For regular objects, we need both case-insensitive lookup AND prototype pollution protection\r\n let value: unknown;\r\n\r\n // The key the lookup actually matched, reported to the read hooks. The\r\n // returned tuple keeps the original `key`; only the event is corrected.\r\n let resolvedKey: string | number | symbol = key;\r\n\r\n // Check if this is a primitive type (string, number, boolean) - these are safe for method access\r\n const isPrimitive = (typeof object === 'string' || typeof object === 'number' || typeof object === 'boolean');\r\n \r\n if (st.options?.caseInsensitive && typeof key === 'string') {\r\n // Use case-insensitive lookup but with prototype pollution protection\r\n // For primitives, skip dangerous property checks as their methods are safe\r\n if (!isPrimitive && isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${key}\" is blocked for security reasons`);\r\n }\r\n \r\n // Try case-insensitive lookup on own properties first\r\n const obj = object as Record<PropertyKey, unknown>;\r\n let foundKey: string | null | undefined = undefined;\r\n \r\n if (obj && typeof obj === 'object') {\r\n // Create wrapper function for cache compatibility\r\n const compareIgnoreCase = (a: string, b: string): boolean => {\r\n const result = equalIgnoreCase(a, b);\r\n return result === true;\r\n };\r\n \r\n // Use cached case-insensitive property lookup for own properties (optimization)\r\n const cachedFoundKey = getCachedCaseInsensitiveProperty(obj, key, compareIgnoreCase);\r\n if (cachedFoundKey !== undefined) {\r\n // Cache hit: cachedFoundKey is either the found key (string) or null (no match)\r\n foundKey = cachedFoundKey;\r\n }\r\n \r\n // If cache miss or not found in own properties, check if the original key exists (including prototype methods)\r\n if (cachedFoundKey === undefined || !foundKey) {\r\n try {\r\n // Test if property exists in prototype chain (this includes native methods like array.find)\r\n const testValue = obj[key];\r\n if (testValue !== undefined) {\r\n foundKey = key;\r\n } else {\r\n // Look for case variations in prototype methods for arrays, objects, etc.\r\n // This is more expensive but necessary for case-insensitive prototype method access\r\n const prototype = Object.getPrototypeOf(obj);\r\n if (prototype) {\r\n const prototypeKeys = Object.getOwnPropertyNames(prototype);\r\n foundKey = prototypeKeys.find(k => typeof k === 'string' && equalIgnoreCase(k, key));\r\n }\r\n }\r\n } catch {\r\n // If access fails, foundKey remains undefined\r\n }\r\n }\r\n \r\n // Check if the found key is dangerous (but only for non-primitives)\r\n if (!isPrimitive && foundKey && isDangerousProperty(foundKey)) {\r\n throw new Error(`Access to dangerous property \"${foundKey}\" is blocked for security reasons`);\r\n }\r\n }\r\n \r\n // Get the value using the found key or use safeGetProperty fallback for non-primitives\r\n if (isPrimitive) {\r\n // For primitives, direct access is safe\r\n value = foundKey ? obj[foundKey] : obj[key];\r\n } else {\r\n // For objects, use safe property access\r\n value = foundKey ? obj[foundKey] : safeGetProperty(object, key);\r\n }\r\n\r\n if (foundKey) {\r\n resolvedKey = foundKey;\r\n }\r\n } else {\r\n // Use safe property access for prototype pollution protection (but not for primitives)\r\n if (isPrimitive) {\r\n // For primitives, direct access is safe\r\n value = (object as Record<PropertyKey, unknown>)[key];\r\n } else {\r\n value = safeGetProperty(object, key);\r\n }\r\n }\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key: resolvedKey,\r\n target: object,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [object, key, value];\r\n }\r\n}\r\n","import { AnyNode, ArrayExpression, Expression, SpreadElement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const arrayExpressionVisitor = (node: ArrayExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const elements = evaluateArray(node, node.elements, st, callback);\r\n\r\n pushVisitorResult(node, st, elements);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateArray = (node: AnyNode,\r\n items: Array<Expression | SpreadElement | null>,\r\n st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n // Pre-allocate array with known length for better performance\r\n const itemCount = items.length;\r\n const elements: unknown[] = new Array(itemCount);\r\n let actualLength = 0;\r\n\r\n for (let i = 0; i < itemCount; i++) {\r\n const element = items[i];\r\n \r\n if (element === null || typeof element === 'undefined') {\r\n elements[actualLength++] = element;\r\n } else if (element.type === 'SpreadElement') {\r\n callback(element, st);\r\n const values = popVisitorResult(node, st) as unknown[];\r\n \r\n // Expand the array if needed for spread elements\r\n if (values && Array.isArray(values)) {\r\n for (const value of values) {\r\n elements[actualLength++] = value;\r\n }\r\n }\r\n } else {\r\n callback(element, st);\r\n const value = popVisitorResult(node, st);\r\n elements[actualLength++] = value;\r\n }\r\n }\r\n\r\n // Trim array to actual size if it changed due to spread elements\r\n if (actualLength !== itemCount) {\r\n elements.length = actualLength;\r\n }\r\n\r\n return elements;\r\n}\r\n","import { CallExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { evaluateArray } from './array-expression';\r\n\r\n/**\r\n * Security: List of dangerous functions that should not be callable\r\n */\r\nconst DANGEROUS_FUNCTIONS = new Set([\r\n 'Function',\r\n 'eval',\r\n 'setTimeout',\r\n 'setInterval',\r\n 'setImmediate',\r\n 'require',\r\n 'import',\r\n 'importScripts',\r\n 'XMLHttpRequest',\r\n 'fetch',\r\n 'WebSocket',\r\n 'Worker',\r\n 'SharedWorker',\r\n 'ServiceWorker',\r\n]);\r\n\r\n/**\r\n * Security: List of dangerous patterns in function code\r\n * Only the most dangerous patterns that could lead to code injection\r\n */\r\nconst DANGEROUS_PATTERNS = [\r\n /\\beval\\s*\\(/i,\r\n /\\bFunction\\s*\\(/, // Look for Function constructor (capital F only)\r\n /new\\s+Function\\s*\\(/i,\r\n /\\.__proto__\\b/,\r\n /\\.prototype\\s*\\.\\s*constructor\\b/,\r\n /\\bglobalThis\\b/,\r\n];\r\n\r\n/**\r\n * Security: Check if a function name is dangerous\r\n */\r\nconst isDangerousFunctionName = (fnName: string): boolean => {\r\n return DANGEROUS_FUNCTIONS.has(fnName);\r\n};\r\n\r\n/**\r\n * Security: Check if function code contains dangerous patterns\r\n * Only check user-defined functions, not native ones\r\n */\r\nconst hasDangerousPatterns = (fnString: string): boolean => {\r\n // If it's a native function ([native code]), allow it\r\n if (fnString.includes('[native code]')) {\r\n return false;\r\n }\r\n\r\n // For user-defined functions, only check for truly dangerous patterns\r\n // that could lead to code injection or security bypass\r\n const result = DANGEROUS_PATTERNS.some(pattern => pattern.test(fnString));\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Security: Check if a function is safe to call\r\n */\r\nconst isFunctionSafe = (fn: unknown, fnName?: string): boolean => {\r\n if (typeof fn !== 'function') {\r\n return false;\r\n }\r\n\r\n // Check if it's a dangerous function by name\r\n if (fnName && isDangerousFunctionName(fnName)) {\r\n return false;\r\n }\r\n\r\n // Special check for Function constructor\r\n if (fn === Function) {\r\n return false;\r\n }\r\n\r\n try {\r\n // Check function string for dangerous patterns\r\n const fnString = fn.toString();\r\n if (hasDangerousPatterns(fnString)) {\r\n return false;\r\n }\r\n } catch {\r\n // If we can't get the function string, be cautious\r\n return false;\r\n }\r\n\r\n return true;\r\n};\r\n\r\n/**\r\n * Safely calls a function with proper error handling and security checks\r\n */\r\nconst safeCall = (\r\n caller: unknown,\r\n thisArg: unknown,\r\n args: unknown[],\r\n optional = false,\r\n fnName?: string\r\n): unknown => {\r\n if (!caller) {\r\n if (optional) {\r\n return undefined;\r\n }\r\n throw new Error(`Cannot call undefined or null function`);\r\n }\r\n\r\n if (typeof caller !== 'function') {\r\n throw new Error(`Value is not a function: ${typeof caller}`);\r\n }\r\n\r\n if (!isFunctionSafe(caller, fnName)) {\r\n throw new Error(`Function call blocked for security reasons: ${fnName || 'anonymous'}`);\r\n }\r\n\r\n try {\r\n return (caller as (...args: unknown[]) => unknown).apply(thisArg, args);\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(`Function call error: ${error.message}`);\r\n }\r\n throw error;\r\n }\r\n};\r\n\r\n/**\r\n * Enhanced call expression visitor with security checks\r\n */\r\nexport const callExpressionVisitor = (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const args = evaluateArray(node, node.arguments, st, callback);\r\n\r\n if (node.callee.type === 'MemberExpression') {\r\n const [object, propertyName, fn] = evaluateMember(node.callee, st, callback);\r\n const functionName = typeof propertyName === 'string' ? propertyName : undefined;\r\n const value = safeCall(fn, object, args, node.callee.optional, functionName);\r\n pushVisitorResult(node, st, value);\r\n } else {\r\n callback(node.callee, st);\r\n const caller = popVisitorResult(node, st);\r\n\r\n // Try to get function name for security checks\r\n let functionName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n functionName = node.callee.name;\r\n }\r\n\r\n const value = safeCall(caller, st.context, args, node.optional, functionName);\r\n pushVisitorResult(node, st, value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateCall = (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n callback(node.callee, st);\r\n const caller = popVisitorResult(node, st);\r\n\r\n const args = node.arguments.map((argument) => {\r\n callback(argument, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n // Get function name for security checks\r\n let functionName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n functionName = node.callee.name;\r\n }\r\n\r\n const value = safeCall(caller, st.context, args, false, functionName);\r\n return value;\r\n}\r\n","import { ImportExpression } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\n/**\r\n * ImportExpression visitor - blocks all dynamic imports for security\r\n */\r\nexport const importExpressionVisitor = (node: ImportExpression, st: EvalState) => {\r\n beforeVisitor(node, st);\r\n\r\n // Block all dynamic imports for security reasons\r\n throw new Error('Function call blocked for security reasons: import');\r\n\r\n afterVisitor(node, st);\r\n};","import { AwaitExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\n// Default timeout for await expressions (30 seconds)\r\nconst DEFAULT_AWAIT_TIMEOUT = 30000;\r\n\r\n/**\r\n * Creates a timeout promise that rejects after the specified timeout\r\n */\r\nconst createTimeoutPromise = (timeout: number): Promise<never> => {\r\n return new Promise<never>((_, reject) => {\r\n setTimeout(() => {\r\n reject(new Error(`Await expression timed out after ${timeout}ms`));\r\n }, timeout);\r\n });\r\n};\r\n\r\n/**\r\n * Safely wraps a value in a promise if it's not already a promise\r\n */\r\nconst ensurePromise = (value: unknown): Promise<unknown> => {\r\n if (value && typeof value === 'object' && 'then' in value) {\r\n return value as Promise<unknown>;\r\n }\r\n return Promise.resolve(value);\r\n};\r\n\r\nexport const awaitVisitor = (node: AwaitExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const promise = new Promise<unknown | undefined>((resolve, reject) => {\r\n try {\r\n callback(node.argument, st);\r\n\r\n const value = popVisitorResult(node, st);\r\n\r\n // Convert value to promise if it's not already one\r\n const valuePromise = ensurePromise(value);\r\n\r\n // Get timeout from context or use default\r\n const contextObj = st.context?.original as Record<string, unknown>;\r\n const timeout = (contextObj && typeof contextObj['__awaitTimeout'] === 'number' \r\n ? contextObj['__awaitTimeout'] \r\n : DEFAULT_AWAIT_TIMEOUT);\r\n\r\n // Race between the actual promise and timeout\r\n Promise.race([\r\n valuePromise,\r\n createTimeoutPromise(timeout)\r\n ])\r\n .then(resolve)\r\n .catch((error) => {\r\n // Enhance error information with context\r\n const enhancedError = error instanceof Error \r\n ? error \r\n : new Error(`Await expression failed: ${String(error)}`);\r\n \r\n // Add source location information if available\r\n if (node.start !== undefined && node.end !== undefined) {\r\n enhancedError.message += ` at position ${node.start}-${node.end}`;\r\n }\r\n \r\n reject(enhancedError);\r\n });\r\n\r\n } catch (synchronousError) {\r\n // Handle synchronous errors immediately\r\n const enhancedError = synchronousError instanceof Error \r\n ? synchronousError \r\n : new Error(`Await expression failed synchronously: ${String(synchronousError)}`);\r\n \r\n reject(enhancedError);\r\n }\r\n });\r\n\r\n pushVisitorResult(node, st, promise);\r\n\r\n afterVisitor(node, st);\r\n\r\n}\r\n\r\n","import { ConditionalExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const conditionalExpressionVisitor = (node: ConditionalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.test, st);\r\n\r\n const test = popVisitorResult(node, st) as boolean;\r\n\r\n if (test) {\r\n callback(node.consequent, st);\r\n } else {\r\n callback(node.alternate, st);\r\n }\r\n\r\n const value = popVisitorResult(node, st) as number;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { UnaryExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const unaryExpressionVisitor = (node: UnaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.argument, st);\r\n\r\n const argument = popVisitorResult(node, st) as number;\r\n\r\n const value =\r\n node.operator === '-' ? -argument :\r\n node.operator === '+' ? +argument :\r\n node.operator === '~' ? ~argument :\r\n node.operator === '!' ? !argument :\r\n node.operator === 'typeof' ? typeof argument :\r\n node.operator === 'void' ? void argument :\r\n // node.operator === 'delete' ? delete argument :\r\n undefined;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { LogicalExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const logicalExpressionVisitor = (node: LogicalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.left, st);\r\n const left = popVisitorResult(node, st);\r\n\r\n // For && operator: if left is falsy, return left (don't evaluate right)\r\n if (node.operator === '&&' && !left) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // For || operator: if left is truthy, return left (don't evaluate right)\r\n if (node.operator === '||' && left) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // For ?? operator: if left is not null/undefined, return left (don't evaluate right)\r\n if (node.operator === '??' && left !== null && left !== undefined) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // Evaluate right operand\r\n callback(node.right, st);\r\n const right = popVisitorResult(node, st);\r\n\r\n // Return the appropriate value based on operator\r\n let value: unknown;\r\n switch (node.operator) {\r\n case '&&':\r\n value = left && right;\r\n break;\r\n case '||':\r\n value = left || right;\r\n break;\r\n case '??':\r\n value = left ?? right;\r\n break;\r\n default:\r\n throw new Error(`Unsupported logical operator: ${node.operator}`);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n afterVisitor(node, st);\r\n}\r\n","import { ThisExpression } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const thisExpressionVisitor = (node: ThisExpression, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const value = st.context;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { NewExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateArray } from './array-expression';\r\n\r\n/**\r\n * Security: List of dangerous constructors that should not be instantiated\r\n */\r\nconst DANGEROUS_CONSTRUCTORS = new Set([\r\n 'Function',\r\n 'GeneratorFunction',\r\n 'AsyncFunction',\r\n 'AsyncGeneratorFunction',\r\n 'XMLHttpRequest',\r\n 'WebSocket',\r\n 'Worker',\r\n 'SharedWorker',\r\n 'ServiceWorker',\r\n 'Proxy',\r\n]);\r\n\r\n/**\r\n * Security: Check if a constructor is safe to use\r\n */\r\nconst isConstructorSafe = (constructor: unknown, constructorName?: string): boolean => {\r\n if (typeof constructor !== 'function') {\r\n return false;\r\n }\r\n\r\n // Check if it's a dangerous constructor by name\r\n if (constructorName && DANGEROUS_CONSTRUCTORS.has(constructorName)) {\r\n return false;\r\n }\r\n\r\n // Special check for Function constructor and its variants\r\n if (constructor === Function ||\r\n constructor === (async function(){ /* async function constructor test */ }).constructor ||\r\n constructor === (function*(){ /* generator function constructor test */ }).constructor ||\r\n constructor === (async function*(){ /* async generator function constructor test */ }).constructor) {\r\n return false;\r\n }\r\n\r\n try {\r\n // Check constructor string for dangerous patterns\r\n const constructorString = constructor.toString();\r\n if (constructorString.includes('eval') ||\r\n constructorString.includes('Function(') ||\r\n constructorString.includes('constructor(')) {\r\n return false;\r\n }\r\n } catch {\r\n // If we can't get the constructor string, be cautious\r\n return false;\r\n }\r\n\r\n return true;\r\n};\r\n\r\n/**\r\n * Safely creates a new instance with proper security checks\r\n */\r\nconst safeNew = (constructor: unknown, args: unknown[], constructorName?: string): unknown => {\r\n if (!constructor) {\r\n throw new Error('Cannot instantiate undefined or null constructor');\r\n }\r\n\r\n if (typeof constructor !== 'function') {\r\n throw new Error(`Value is not a constructor: ${typeof constructor}`);\r\n }\r\n\r\n if (!isConstructorSafe(constructor, constructorName)) {\r\n throw new Error(`Constructor blocked for security reasons: ${constructorName || 'anonymous'}`);\r\n }\r\n\r\n try {\r\n return Reflect.construct(constructor as (...a: unknown[]) => unknown, args);\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(`Constructor error: ${error.message}`);\r\n }\r\n throw error;\r\n }\r\n};\r\n\r\nexport const newExpressionVisitor = (node: NewExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const args = evaluateArray(node, node.arguments, st, callback);\r\n\r\n callback(node.callee, st);\r\n\r\n const constructor = popVisitorResult(node, st);\r\n\r\n // Try to get constructor name for security checks\r\n let constructorName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n constructorName = node.callee.name;\r\n }\r\n\r\n const value = safeNew(constructor, args, constructorName);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n// Legacy function - now with security checks\r\nexport const newFunc = (constructor: (...a: unknown[]) => unknown, ...args: unknown[]) => {\r\n return safeNew(constructor, args);\r\n}\r\n","import { TemplateLiteral } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const templateLiteralVisitor = (node: TemplateLiteral, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const expressions = node.expressions.map((expression) => {\r\n callback(expression, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n const value = node.quasis.reduce((accumulator, templateElement, index) => {\r\n accumulator += templateElement.value.cooked;\r\n if (!templateElement.tail) {\r\n accumulator += expressions[index] ?? '';\r\n }\r\n return accumulator;\r\n }, '');\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n","import { TaggedTemplateExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const taggedTemplateExpressionVisitor = (node: TaggedTemplateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.tag, st);\r\n const tag = popVisitorResult(node, st) as (...args: unknown[]) => unknown;\r\n\r\n const quasiExpressions = node.quasi.expressions.map((expression) => {\r\n callback(expression, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n const quasi = node.quasi.quasis.map((templateElement) => {\r\n return templateElement.value.cooked;\r\n });\r\n\r\n const value = tag.apply(st.context, [quasi, ...quasiExpressions]);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { ObjectExpression, Property } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { createSafeObject, validateSafeObject } from './prototype-pollution-guard';\r\n\r\ntype KeyValuePair = {key: unknown; value: unknown};\r\n\r\nexport const objectExpressionVisitor = (node: ObjectExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Pre-allocate entries array for better performance\r\n const propertyCount = node.properties.length;\r\n const entries: Array<[unknown, unknown]> = [];\r\n \r\n for (let i = 0; i < propertyCount; i++) {\r\n const property = node.properties[i];\r\n \r\n if (property.type === 'SpreadElement') {\r\n callback(property.argument, st);\r\n const value = popVisitorResult(property, st) as object;\r\n \r\n // Validate spread object for safety\r\n try {\r\n validateSafeObject(value);\r\n } catch (error) {\r\n throw new Error(`Spread operation blocked: ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n \r\n // Use Object.entries() once and cache the result\r\n const spreadEntries = Object.entries(value);\r\n for (let j = 0; j < spreadEntries.length; j++) {\r\n const [key, val] = spreadEntries[j];\r\n entries.push([key, val]);\r\n }\r\n } else {\r\n const pair = evalProperty(property, st, callback);\r\n entries.push([pair.key, pair.value]);\r\n }\r\n }\r\n\r\n // Create safe object with prototype pollution protection\r\n try {\r\n const obj = createSafeObject(entries);\r\n pushVisitorResult(node, st, obj);\r\n } catch (error) {\r\n throw new Error(`Object creation blocked: ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nconst evalProperty = (property: Property, st: EvalState, callback: walk.WalkerCallback<EvalState>): KeyValuePair => {\r\n // if (property.shorthand) {\r\n // callback(property.value, st);\r\n // const value = popVisitorResult(property, st);\r\n // return { key: value, value };\r\n // } else\r\n if (property.computed) {\r\n callback(property.key, st);\r\n const key = popVisitorResult(property, st);\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else if (property.key.type === 'Identifier') {\r\n const key = property.key.name;\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else if (property.key.type === 'Literal') {\r\n const key = property.key.value;\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else {\r\n throw new Error(`Unsupported property key type: ${property.key.type}`);\r\n }\r\n}\r\n","import {\r\n arrayExpressionVisitor, arrowFunctionExpressionVisitor, assignmentExpressionVisitor, awaitVisitor, binaryExpressionVisitor,\r\n callExpressionVisitor,conditionalExpressionVisitor, importExpressionVisitor,\r\n identifierVisitor, literalVisitor, logicalExpressionVisitor,\r\n memberExpressionVisitor, newExpressionVisitor, objectExpressionVisitor,\r\n taggedTemplateExpressionVisitor, templateLiteralVisitor,\r\n thisExpressionVisitor, unaryExpressionVisitor, updateExpressionVisitor\r\n} from '../../internal/visitors';\r\n\r\nimport { EvalState } from '../classes/eval';\r\n\r\nimport * as walk from 'acorn-walk';\r\n\r\n\r\n\r\n/**\r\n * Returns the default visitors for the recursive traversal of an abstract syntax tree.\r\n * @returns The default visitors object.\r\n */\r\nexport const getDefaultVisitors = () => {\r\n\r\n const visitors: walk.RecursiveVisitors<EvalState> = {};\r\n\r\n visitors['BinaryExpression'] = binaryExpressionVisitor;\r\n visitors['Identifier'] = identifierVisitor;\r\n visitors['Literal'] = literalVisitor;\r\n visitors['CallExpression'] = callExpressionVisitor;\r\n visitors['ImportExpression'] = importExpressionVisitor;\r\n visitors['AwaitExpression'] = awaitVisitor;\r\n visitors['ConditionalExpression'] = conditionalExpressionVisitor;\r\n visitors['MemberExpression'] = memberExpressionVisitor;\r\n visitors['ArrayExpression'] = arrayExpressionVisitor;\r\n visitors['UnaryExpression'] = unaryExpressionVisitor;\r\n visitors['LogicalExpression'] = logicalExpressionVisitor;\r\n visitors['ThisExpression'] = thisExpressionVisitor;\r\n visitors['NewExpression'] = newExpressionVisitor;\r\n visitors['TemplateLiteral'] = templateLiteralVisitor;\r\n visitors['TaggedTemplateExpression'] = taggedTemplateExpressionVisitor;\r\n visitors['ObjectExpression'] = objectExpressionVisitor;\r\n visitors['AssignmentExpression'] = assignmentExpressionVisitor;\r\n visitors['UpdateExpression'] = updateExpressionVisitor;\r\n visitors['ArrowFunctionExpression'] = arrowFunctionExpressionVisitor;\r\n\r\n return visitors;\r\n}\r\n","import { AssignmentExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { safeSetProperty } from './prototype-pollution-guard';\r\n\r\nconst assignmentOperators = {\r\n '=': (left: number, value: number) => { return left = value; },\r\n '+=': (left: number, value: number) => { return left += value; },\r\n '-=': (left: number, value: number) => { return left -= value; },\r\n '*=': (left: number, value: number) => { return left *= value; },\r\n '/=': (left: number, value: number) => { return left /= value; },\r\n '%=': (left: number, value: number) => { return left %= value; },\r\n '**=': (left: number, value: number) => { return left **= value; },\r\n '<<=': (left: number, value: number) => { return left <<= value; },\r\n '>>=': (left: number, value: number) => { return left >>= value; },\r\n '>>>=': (left: number, value: number) => { return left >>>= value; },\r\n '&=': (left: number, value: number) => { return left &= value; },\r\n '^=': (left: number, value: number) => { return left ^= value; },\r\n '|=': (left: number, value: number) => { return left |= value; },\r\n '&&=': (left: number, value: number) => { return left &&= value; },\r\n '||=': (left: number, value: number) => { return left ||= value; },\r\n '??=': (left: number, value: number) => { return left ??= value; },\r\n};\r\n\r\n\r\nexport const assignmentExpressionVisitor = (node: AssignmentExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.left, st);\r\n\r\n const left = popVisitorResult(node, st) as number;\r\n\r\n callback(node.right, st);\r\n\r\n const right = popVisitorResult(node, st) as number;\r\n\r\n const func = assignmentOperators[node.operator];\r\n\r\n if (!func) {\r\n throw new Error(`Unsupported assignment operator: ${node.operator}`);\r\n } else if (!st.context) {\r\n throw new Error(`Context is not set.`);\r\n } else if (node.left.type === 'Identifier') {\r\n const key = st.options?.caseInsensitive\r\n ? st.context.getKey(node.left.name)\r\n : node.left.name;\r\n const value = func(left, right);\r\n st.context.set(key, value);\r\n pushVisitorResult(node, st, value);\r\n } else if (node.left.type === 'MemberExpression') {\r\n const [object, key, ] = evaluateMember(node.left, st, callback);\r\n const value = func(left, right);\r\n \r\n // Use safe property assignment to prevent prototype pollution\r\n safeSetProperty(object, key, value);\r\n \r\n pushVisitorResult(node, st, value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n","import { UpdateExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { safeSetProperty } from './prototype-pollution-guard';\r\n\r\nconst updateOperators = {\r\n '++': (value: number) => { return value + 1; },\r\n '--': (value: number) => { return value - 1; },\r\n};\r\n\r\nexport const updateExpressionVisitor = (node: UpdateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n if (!st.context) {\r\n throw new Error(`Context is not set.`);\r\n } else if (node.argument.type === 'Identifier') {\r\n const key = st.options?.caseInsensitive\r\n ? st.context.getKey(node.argument.name)\r\n : node.argument.name;\r\n const value = st.context?.get(key);\r\n const newValue = updateOperators[node.operator](value as number);\r\n st.context?.set(key, newValue);\r\n pushVisitorResult(node, st, node.prefix ? newValue : value);\r\n } else if (node.argument.type === 'MemberExpression') {\r\n const [object, property, value] = evaluateMember(node.argument, st, callback);\r\n const newValue = updateOperators[node.operator](value as number);\r\n \r\n // Use safe property assignment to prevent prototype pollution\r\n safeSetProperty(object, property, newValue);\r\n \r\n pushVisitorResult(node, st, node.prefix ? newValue : value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { AnyNode, Expression, ModuleDeclaration,\r\n Program, Statement, parse as _parse } from \"acorn\";\r\nimport { ParserOptions } from \"../interfaces\";\r\nimport * as acorn from 'acorn';\r\n\r\n/**\r\n* @description\r\n* Parses expression and returns ES6/ES2020 AST.\r\n* @param expr expression to parse\r\n* @param options parser options\r\n*/\r\nexport const parse = (expr: string, options: ParserOptions)\r\n : Program | AnyNode | undefined => {\r\n options = {ecmaVersion: 2020, ...options};\r\n const acornOptions: acorn.Options = {ecmaVersion: 2020, ...options};\r\n const program: Program = _parse(expr, acornOptions);\r\n if (!options.extractExpressions) {\r\n return program;\r\n }\r\n return extractExpression(program);\r\n}\r\n\r\n/**\r\n* @description\r\n* Walks through the AST and extracts first expression.\r\n* @param expr expression to parse\r\n*/\r\nexport const extractExpression = (program: Program)\r\n : Expression | undefined => {\r\n\r\n if (program.body.length === 1) {\r\n const expression: Statement | ModuleDeclaration = program.body[0];\r\n if (expression.type === 'ExpressionStatement') {\r\n return expression.expression as Expression;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n","import { EvalState } from '../classes/eval';\r\nimport * as walk from 'acorn-walk';\r\nimport { getDefaultVisitors, popVisitorResult } from '../visitors';\r\nimport { AnyNode } from 'acorn';\r\n\r\n/**\r\n * Evaluates the given node and returns the result.\r\n *\r\n * @param node The node to evaluate.\r\n * @param state The evaluation state.\r\n * @returns The result of the evaluation.\r\n */\r\nexport const evaluate = (node: AnyNode | undefined, state: EvalState)\r\n : unknown | undefined => {\r\n\r\n if (node) {\r\n\r\n state.result.start();\r\n\r\n // Captured inside the `if (node)` block on purpose: callers reach the early\r\n // return above with a bare state that has no hooks to read. Do not hoist.\r\n const mark = state.hasHooks ? state.hooks.depth(state) : 0;\r\n\r\n try {\r\n const visitors: walk.RecursiveVisitors<EvalState> = getDefaultVisitors();\r\n\r\n walk.recursive(node, state, visitors);\r\n\r\n const value = popVisitorResult(node, state)\r\n\r\n state.result.stop();\r\n\r\n state.result.setSuccess(value);\r\n\r\n return value;\r\n } catch (error) {\r\n state.result.stop();\r\n // A visitor that throws skips its afterVisitor, so close whatever this\r\n // walk left open. Unwinding to the mark rather than to the bottom is what\r\n // stops a nested evaluate - the arrow-function body runs on this same\r\n // state - from draining the enclosing walk's open nodes.\r\n if (state.hasHooks) {\r\n state.hooks.unwindTo(mark, error, state);\r\n }\r\n state.result.setFailure(error);\r\n throw error;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Converts a rejection value to a proper Error object\r\n */\r\nconst ensureError = (rejection: unknown): Error => {\r\n if (rejection instanceof Error) {\r\n return rejection;\r\n }\r\n \r\n if (typeof rejection === 'string') {\r\n return new Error(rejection);\r\n }\r\n \r\n if (rejection === null) {\r\n return new Error('Promise rejected with null');\r\n }\r\n \r\n if (rejection === undefined) {\r\n return new Error('Promise rejected with undefined');\r\n }\r\n \r\n if (typeof rejection === 'object') {\r\n return new Error(`Promise rejected with object: ${JSON.stringify(rejection)}`);\r\n }\r\n \r\n return new Error(`Promise rejected with value: ${String(rejection)}`);\r\n};\r\n\r\n/**\r\n * Recursively awaits all promises in a value structure\r\n */\r\nconst awaitAllPromises = async (value: unknown): Promise<unknown> => {\r\n if (!value || typeof value !== 'object') {\r\n return value;\r\n }\r\n \r\n // If it's a promise, await it and handle rejections\r\n if ('then' in value) {\r\n try {\r\n return await (value as Promise<unknown>);\r\n } catch (rejection) {\r\n throw ensureError(rejection);\r\n }\r\n }\r\n \r\n // If it's an array, recursively await all elements\r\n if (Array.isArray(value)) {\r\n return Promise.all(value.map(item => awaitAllPromises(item)));\r\n }\r\n \r\n // If it's an object, recursively await all properties\r\n if (value.constructor === Object) {\r\n const result: Record<string, unknown> = {};\r\n const promises = Object.entries(value).map(async ([key, val]) => {\r\n result[key] = await awaitAllPromises(val);\r\n });\r\n await Promise.all(promises);\r\n return result;\r\n }\r\n \r\n return value;\r\n};\r\n\r\n/**\r\n * Asynchronously evaluates the given abstract syntax tree (AST) using the provided evaluation state.\r\n * @param ast The abstract syntax tree to evaluate.\r\n * @param state The evaluation state.\r\n * @returns A promise that resolves to the evaluated value or undefined.\r\n */\r\nexport const evaluateAsync = async (ast: AnyNode | undefined, state: EvalState)\r\n : Promise<unknown | undefined> => {\r\n\r\n if (!ast) {\r\n return undefined;\r\n }\r\n\r\n state.result.start();\r\n\r\n // Captured after the `!ast` early return above, for the same reason the sync\r\n // entry point captures inside its `if (node)` block. Do not hoist.\r\n const mark = state.hasHooks ? state.hooks.depth(state) : 0;\r\n\r\n try {\r\n const visitors: walk.RecursiveVisitors<EvalState> = getDefaultVisitors();\r\n\r\n walk.recursive(ast, state, visitors);\r\n\r\n let value = popVisitorResult(ast, state);\r\n\r\n // Enhanced promise handling - recursively await all promises\r\n try {\r\n value = await awaitAllPromises(value);\r\n } catch (promiseError) {\r\n // Ensure proper error handling for promise rejections\r\n const error = ensureError(promiseError);\r\n state.result.stop();\r\n state.result.setFailure(error);\r\n throw error;\r\n }\r\n\r\n state.result.stop();\r\n state.result.setSuccess(value);\r\n \r\n return value;\r\n } catch (error) {\r\n state.result.stop();\r\n // The walk here is synchronous too, so it strands open nodes on a throw\r\n // exactly as the sync entry point does. This catch also receives the\r\n // rethrow from the awaitAllPromises handler above; in that case the walk\r\n // had already closed every node it opened, the depth is back at the mark,\r\n // and unwindTo correctly synthesises nothing.\r\n if (state.hasHooks) {\r\n state.hooks.unwindTo(mark, error, state);\r\n }\r\n state.result.setFailure(error);\r\n throw error;\r\n }\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\nimport { evaluate, evaluateAsync } from './evaluate';\r\n\r\nexport type stateCallback = (state: EvalState) => unknown;\r\nexport type stateCallbackAsync = (state: EvalState) => Promise<unknown | undefined>;\r\n\r\n/**\r\n * Compiles the given node and returns a function that can be used to evaluate it.\r\n *\r\n * @param node The node to compile.\r\n * @returns A function that takes an `EvalState` and returns the result of evaluating the node.\r\n */\r\nexport const compile = (node: AnyNode | undefined): stateCallback => {\r\n\r\n return evaluate.bind(null, node);\r\n}\r\n\r\n/**\r\n * Compiles the given node asynchronously.\r\n *\r\n * @param node - The node to compile.\r\n * @returns A function that takes an `EvalState` object and returns a `Promise` that resolves to the compiled result.\r\n */\r\nexport const compileAsync = (node: AnyNode | undefined): stateCallbackAsync => {\r\n\r\n return evaluateAsync.bind(null, node);\r\n}\r\n\r\n/**\r\n * Calls the provided function with the given state and returns the result.\r\n *\r\n * @param fn The function to be called.\r\n * @param state The state to be passed to the function.\r\n * @returns The result of calling the function.\r\n */\r\nexport const call = (fn: stateCallback, state: EvalState): unknown | undefined => {\r\n const value = fn(state);\r\n return value;\r\n}\r\n\r\n/**\r\n * Calls an asynchronous function with the given state and returns a promise that resolves to the result.\r\n * @param fn The asynchronous function to call.\r\n * @param state The state to pass to the function.\r\n * @returns A promise that resolves to the result of the function.\r\n */\r\nexport const callAsync = (fn: stateCallbackAsync, state: EvalState): Promise<unknown | undefined> => {\r\n const promise = fn(state);\r\n return promise;\r\n}\r\n","import * as walk from 'acorn-walk';\r\nimport { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../interfaces';\r\n\r\n/**\r\n * Finds all nodes of a specific type in the given AST.\r\n *\r\n * @param ast The AST to search in.\r\n * @param searchType The type of nodes to search for.\r\n * @returns An array of nodes of the specified type if found, otherwise undefined.\r\n */\r\nexport const extract = (node: AnyNode | undefined,\r\n searchType: AnyNodeTypes): AnyNode[] | undefined => {\r\n if (node) {\r\n\r\n const state: AnyNode[] = [];\r\n\r\n const visitors: walk.SimpleVisitors<AnyNode[]> = {\r\n [searchType]: (node: AnyNode,) => { state.push(node); return; }\r\n };\r\n\r\n walk.simple(node, visitors);\r\n\r\n return state.length > 0 ? state : undefined;\r\n }\r\n return undefined;\r\n}\r\n\r\n","import { ArrowFunctionExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { evaluate } from '../functions';\r\nimport { evaluatePatterns } from '.';\r\n\r\nexport const arrowFunctionExpressionVisitor = (node: ArrowFunctionExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const fn = (...arrowArgs: unknown[]) => {\r\n const newContext = evaluatePatterns(node.params, st, callback, arrowArgs);\r\n st.context?.push(newContext);\r\n const value = evaluate(node.body, st);\r\n st.context?.pop();\r\n return value;\r\n }\r\n\r\n pushVisitorResult(node, st, fn);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n\r\n","import { ArrayPattern, Identifier, MemberExpression,\r\n ObjectPattern, Pattern, RestElement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { EvalState } from '../classes/eval';\r\nimport { popVisitorResult } from '.';\r\nimport { BaseContext } from '../classes/common';\r\n\r\n\r\n// based on evalArrowContext\r\n// https://github.com/6utt3rfly/jse-eval/blob/main/index.ts\r\n\r\nexport const evaluatePatterns = (patterns: Pattern[], st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown[]) => {\r\n\r\n let context: BaseContext = {};\r\n\r\n patterns.map((pattern, i) => {\r\n switch (pattern.type) {\r\n case 'Identifier': {\r\n const object = evaluateIdentifier(pattern, st, args[i]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'MemberExpression': {\r\n const object = evaluateMemberExpression(pattern, st, callback, args[i]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'ObjectPattern': {\r\n const object = evaluateObjectPattern(pattern, st, callback, args[i]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'ArrayPattern': {\r\n const object = evaluateArrayPattern(pattern, st, callback, args[i] as unknown[]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'RestElement': {\r\n const object = evaluateRestElement(pattern, st, callback, args.slice(i));\r\n context = {...context, ...object};\r\n }\r\n break;\r\n // case 'AssignmentPattern': {\r\n // const object = evaluateAssignmentPattern(pattern, st, callback, args[i]);\r\n // context = {...context, ...object};\r\n // }\r\n // break;\r\n }\r\n });\r\n\r\n return context;\r\n}\r\n\r\nexport const evaluatePattern = (pattern: Pattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown): BaseContext => {\r\n\r\n switch (pattern.type) {\r\n case 'Identifier':\r\n return evaluateIdentifier(pattern, st, arg);\r\n case 'MemberExpression':\r\n return evaluateMemberExpression(pattern, st, callback, arg);\r\n case 'ObjectPattern':\r\n return evaluateObjectPattern(pattern, st, callback, arg as unknown[]);\r\n case 'ArrayPattern':\r\n return evaluateArrayPattern(pattern, st, callback, arg as unknown[]);\r\n case 'RestElement':\r\n return evaluateRestElement(pattern, st, callback, arg);\r\n // case 'AssignmentPattern':\r\n // return evaluateAssignmentPattern(pattern, st, callback, arg);\r\n }\r\n\r\n return {} as BaseContext;\r\n}\r\n\r\nconst evaluateIdentifier = (pattern: Identifier, st: EvalState, arg: unknown) => {\r\n const object = {} as BaseContext;\r\n object[pattern.name] = arg;\r\n return object;\r\n}\r\n\r\nconst evaluateMemberExpression = (pattern: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown): BaseContext => {\r\n\r\n if (pattern.type === 'MemberExpression') {\r\n console.log(pattern, st, callback, arg);\r\n throw new Error('evaluateMemberExpression is not implemented.');\r\n }\r\n\r\n return {} as BaseContext;\r\n}\r\n\r\nconst evaluateObjectPattern = (pattern: ObjectPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown) => {\r\n\r\n let context: BaseContext = {};\r\n\r\n pattern.properties.map((pattern) => {\r\n switch (pattern.type) {\r\n case 'Property': {\r\n let key: string | number;\r\n if (pattern.key.type === 'Identifier') {\r\n key = pattern.key.name;\r\n } else if (pattern.key.type === 'Literal') {\r\n key = pattern.key.value as string | number;\r\n } else {\r\n callback(pattern.key, st);\r\n key = popVisitorResult(pattern, st) as string | number;\r\n if (typeof key !== 'string' && typeof key !== 'number')\r\n throw new Error(`Unsupported property key type: ${pattern.key.type}`);\r\n }\r\n\r\n const ctx = arg as BaseContext;\r\n st.context?.push(ctx);\r\n callback(pattern.value, st);\r\n const value = popVisitorResult(pattern, st) as BaseContext;\r\n st.context?.pop();\r\n\r\n const pair = {} as BaseContext;\r\n pair[key] = value;\r\n\r\n context = {...context, ...pair};\r\n }\r\n break;\r\n case 'RestElement': {\r\n const object = evaluateRestElement(pattern, st, callback, arg);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n }\r\n });\r\n\r\n return context;\r\n}\r\n\r\nconst evaluateArrayPattern = (pattern: ArrayPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown[]) => {\r\n const patterns = pattern.elements.filter(s => !!s) as Pattern[];\r\n const object = evaluatePatterns(patterns, st, callback, args);\r\n return object;\r\n}\r\n\r\nconst evaluateRestElement = (pattern: RestElement, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown) => {\r\n const argument = pattern.argument;\r\n const object = evaluatePattern(argument, st, callback, args);\r\n return object;\r\n}\r\n\r\n// const evaluateAssignmentPattern = (pattern: AssignmentPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown) => {\r\n// const left = evaluatePattern(pattern.left, st, callback, args);\r\n// callback(pattern.right, st);\r\n// const value = popVisitorResult(pattern, st);\r\n// const object = {...left};\r\n// return object;\r\n// }\r\n","import { equalIgnoreCase } from \"../../visitors\";\r\nimport { Context, Registry, getContextValue } from \"../common\";\r\n\r\nexport interface EvalScopeOptions {\r\n global?: boolean;\r\n caseInsensitive?: boolean;\r\n namespace?: string;\r\n thisArg?: unknown;\r\n}\r\n\r\nconst defaultEvalScopeOptions: EvalScopeOptions = {\r\n global: false,\r\n caseInsensitive: false,\r\n namespace: undefined,\r\n thisArg: undefined\r\n};\r\n\r\n/**\r\n * Represents an evaluation scope.\r\n */\r\nexport class EvalScope {\r\n\r\n type = 'EvalScope';\r\n\r\n private _context!: Context;\r\n private _options!: EvalScopeOptions;\r\n\r\n /**\r\n * Gets the context of the evaluation scope.\r\n * @returns The context object.\r\n */\r\n public get context(): Context {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the options for evaluating the scope.\r\n * @returns The evaluation options.\r\n */\r\n public get options(): EvalScopeOptions {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalScope.\r\n * @param context - The context of the evaluation scope.\r\n * @param options - The options for evaluating the scope.\r\n */\r\n constructor(\r\n context?: Context,\r\n options?: EvalScopeOptions\r\n ) {\r\n this._context = context ?? {};\r\n this._options = {...defaultEvalScopeOptions,...options ?? {}};\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalScope from the given context and options.\r\n *\r\n * @param context - The context object.\r\n * @param options - The options object.\r\n * @returns An instance of EvalScope.\r\n */\r\n public static fromObject(\r\n context?: Context,\r\n options?: EvalScopeOptions): EvalScope {\r\n\r\n return new EvalScope(context, options);\r\n }\r\n\r\n /**\r\n * Gets the value of the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value of the specified key, or undefined if the key is not found.\r\n */\r\n public get(key: unknown): unknown | undefined {\r\n const { caseInsensitive, namespace, global } = this._options;\r\n const { context } = this;\r\n\r\n if (typeof key === 'string' && namespace) {\r\n const found = caseInsensitive\r\n ? equalIgnoreCase(key, namespace)\r\n : key === namespace;\r\n if (found) {\r\n return this.context;\r\n }\r\n }\r\n\r\n if (global) {\r\n const value = getContextValue(context, key);\r\n return value;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Sets the value of the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: string, value: unknown): void {\r\n const { context } = this;\r\n if (context && context instanceof Registry) {\r\n const registry = context as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (context && context instanceof Object) {\r\n const obj = context as Record<string, unknown>;\r\n obj[key as string | number] = value;\r\n }\r\n }\r\n}\r\n","import type { EvalHooks, EvalReadEvent, Unsubscribe } from '../eval-hooks';\r\n\r\n/**\r\n * Collects the context reads an evaluation made, as a set of dotted paths.\r\n *\r\n * This is Phase 3's input: install it, evaluate, and read {@link dependencies}\r\n * back in the same synchronous turn - which is what wrapping a `computed()`\r\n * needs. Hooks are synchronous by design, so that ordering always holds.\r\n */\r\nexport interface EvalDependencyTracker {\r\n /**\r\n * Registers the read hook on `hooks`.\r\n *\r\n * @param hooks The registry to register on.\r\n * @returns A function that removes it.\r\n */\r\n install(hooks: EvalHooks): Unsubscribe;\r\n\r\n /**\r\n * The dotted paths this tracker considers dependencies, filtered per the\r\n * rules on {@link createDependencyTracker}. Live: it fills as reads arrive.\r\n */\r\n readonly dependencies: ReadonlySet<string>;\r\n\r\n /**\r\n * Every read seen, unfiltered and in emission order - including the scope\r\n * bindings, method references and computed members {@link dependencies}\r\n * drops. A consumer that wants to key on `target` identity rather than on\r\n * path strings works from here.\r\n */\r\n readonly reads: EvalReadEvent[];\r\n\r\n /** Empties {@link dependencies}, {@link reads} and the scope-binding names. */\r\n reset(): void;\r\n}\r\n\r\n/** The first segment of a dotted path: `a.b.c` -> `a`. */\r\nconst rootOf = (path: string): string => {\r\n const dot = path.indexOf('.');\r\n return dot < 0 ? path : path.slice(0, dot);\r\n};\r\n\r\n/**\r\n * Creates a dependency tracker.\r\n *\r\n * `reads` keeps everything. `dependencies` is the filtered view, and three\r\n * rules do the filtering:\r\n *\r\n * 1. **Scope bindings are not dependencies.** A read flagged `scoped` resolved\r\n * from a scope pushed during the walk - an arrow-function parameter. Only\r\n * the walker can tell one from a real context read, which is why the flag\r\n * exists; a consumer using this tracker inherits the filtering for free.\r\n * 2. **Nor is anything reached *through* one.** `item` being a binding makes\r\n * `item.name` one too, and that read carries no flag of its own: `scoped` is\r\n * set at identifier resolution, and the member hop resolves against the\r\n * bound object rather than against a scope. So the bound names are\r\n * remembered and any path rooted at one is dropped.\r\n * 3. **A method reached through a member hop is a call target, not data.**\r\n * `list.map` in `list.map(item => item.name)` resolves to\r\n * `Array.prototype.map`; recording it would put a built-in in the dependency\r\n * set, while `list` - already recorded - is the thing whose change actually\r\n * matters. Bare identifiers are exempt, function-valued or not: a\r\n * context-level callable was named directly rather than reached through an\r\n * object, and there is no already-recorded object standing in for it.\r\n *\r\n * Two limits, both consequences of keying on path strings:\r\n *\r\n * - **A computed member contributes nothing.** `obj[expr]` has no\r\n * reconstructible path, and its resolved key alone is not a usable key\r\n * without one. It is in `reads` with an exact `key` and `target`, for a\r\n * consumer willing to key on identity.\r\n * - **Names collide.** Rule 2 keys on the *name*, so once `item` has been an\r\n * arrow parameter anywhere in the expression, a genuine `item.x` elsewhere in\r\n * it is dropped too. Path strings from different arrow bodies collide the\r\n * same way. § 9 hands the identity-versus-paths question to Phase 3; this is\r\n * the paths half of it.\r\n *\r\n * ```ts\r\n * const tracker = createDependencyTracker();\r\n * const state = evalService.createState({ a: { b: 1 }, c: 2 });\r\n * const off = tracker.install(state.hooks);\r\n *\r\n * evalService.eval('a.b + c', state);\r\n * tracker.dependencies; // Set { 'a', 'a.b', 'c' }\r\n *\r\n * tracker.reset();\r\n * off();\r\n * ```\r\n *\r\n * @returns A tracker; nothing is collected until {@link EvalDependencyTracker.install}\r\n * is called.\r\n */\r\nexport const createDependencyTracker = (): EvalDependencyTracker => {\r\n const dependencies = new Set<string>();\r\n const reads: EvalReadEvent[] = [];\r\n const bindings = new Set<string>();\r\n\r\n const record = (event: EvalReadEvent): void => {\r\n reads.push(event);\r\n\r\n const path = event.path;\r\n\r\n if (event.scoped) {\r\n // Rule 1, and the source of rule 2's name set.\r\n if (path !== undefined) {\r\n bindings.add(path);\r\n }\r\n return;\r\n }\r\n\r\n if (path === undefined) {\r\n return;\r\n }\r\n\r\n if (bindings.has(rootOf(path))) {\r\n return; // rule 2\r\n }\r\n\r\n if (event.kind === 'member' && typeof event.value === 'function') {\r\n return; // rule 3\r\n }\r\n\r\n dependencies.add(path);\r\n };\r\n\r\n return {\r\n install(hooks: EvalHooks): Unsubscribe {\r\n return hooks.onRead(record);\r\n },\r\n\r\n dependencies,\r\n reads,\r\n\r\n reset(): void {\r\n dependencies.clear();\r\n reads.length = 0;\r\n bindings.clear();\r\n }\r\n };\r\n};\r\n","import { AnyNode } from \"acorn\";\r\nimport { ParserOptions } from \"../../internal/interfaces\";\r\nimport { ParserService } from \"./parser.service\";\r\nimport { EvalContext, EvalOptions, EvalState } from \"../../internal/classes/eval\";\r\nimport { Context } from \"../../internal/public-api\";\r\n\r\n/**\r\n * Base class for evaluation.\r\n */\r\nexport abstract class BaseEval {\r\n private _parserOptions!: ParserOptions;\r\n\r\n constructor(\r\n protected parserService: ParserService\r\n ) {}\r\n\r\n /**\r\n * Gets the parser options.\r\n */\r\n protected get parserOptions(): ParserOptions {\r\n return this._parserOptions;\r\n }\r\n\r\n /**\r\n * Sets the parser options.\r\n * @param value The parser options to set.\r\n */\r\n protected set parserOptions(value: ParserOptions) {\r\n this._parserOptions = value;\r\n }\r\n\r\n /**\r\n * Parses the given expression into an abstract syntax tree (AST).\r\n * @param expression - The expression to parse.\r\n * @returns The parsed AST.\r\n */\r\n protected parse(expression: string | AnyNode | undefined): AnyNode | undefined {\r\n if (!expression) {\r\n return undefined;\r\n } else if (typeof expression === 'string') {\r\n const ast = this.parserService.parse(expression, this.parserOptions);\r\n return ast;\r\n } else {\r\n return expression as AnyNode;\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalState.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns The created EvalState instance.\r\n */\r\n createState(context?: EvalContext | Context,\r\n options?: EvalOptions): EvalState {\r\n const state = EvalState.fromContext(context, options);\r\n return state;\r\n }\r\n}\r\n","import { Injectable, OnDestroy } from '@angular/core';\r\nimport { CacheType, ParserOptions } from '../../internal/interfaces';\r\nimport { Cache } from '../../internal/classes/common';\r\nimport { Expression, Program,\r\n version as acornVersion, AnyNode } from 'acorn';\r\nimport { parse as _parse } from '../../internal/functions';\r\nimport { defaultParserOptions } from '../../internal/classes/eval';\r\n\r\n\r\n/**\r\n * @description\r\n * Service for parsing expressions and returning ES6/ES2020 AST.\r\n * Implements OnDestroy for proper memory cleanup.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ParserService implements OnDestroy {\r\n\r\n private _parserOptions!: ParserOptions;\r\n private _cache?: CacheType<Program | AnyNode | Expression | undefined>;\r\n private _cacheCleanupInterval?: ReturnType<typeof setInterval>;\r\n private _isDestroyed = false;\r\n\r\n /**\r\n * Gets the parser options.\r\n */\r\n get parserOptions(): ParserOptions {\r\n return this._parserOptions;\r\n }\r\n\r\n /**\r\n * Sets the parser options.\r\n * @param value The parser options to set.\r\n */\r\n set parserOptions(value: ParserOptions) {\r\n this._parserOptions = value;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the ParserService class.\r\n */\r\n constructor() {\r\n this.parserOptions = {\r\n ...defaultParserOptions,\r\n extractExpressions: true\r\n };\r\n if (this.parserOptions.cacheSize) {\r\n this._cache = new Cache<AnyNode>(this.parserOptions.cacheSize);\r\n \r\n // Set up periodic cache cleanup to prevent memory leaks\r\n this.setupCacheCleanup();\r\n }\r\n }\r\n\r\n /**\r\n * Setup periodic cache cleanup to prevent memory leaks\r\n */\r\n private setupCacheCleanup(): void {\r\n if (this._cache && typeof setInterval !== 'undefined') {\r\n // Clean up cache every 5 minutes to prevent unbounded growth\r\n this._cacheCleanupInterval = setInterval(() => {\r\n if (!this._isDestroyed && this._cache) {\r\n // Keep cache size within bounds by clearing if it gets too large\r\n if (this._cache.size > this._cache.maxCacheSize * 0.8) {\r\n this._cache.clear();\r\n console.debug('Parser cache cleared to prevent memory leaks');\r\n }\r\n }\r\n }, 5 * 60 * 1000); // 5 minutes\r\n }\r\n }\r\n\r\n /**\r\n * Clean up resources to prevent memory leaks\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n \r\n if (this._cacheCleanupInterval) {\r\n clearInterval(this._cacheCleanupInterval);\r\n this._cacheCleanupInterval = undefined;\r\n }\r\n \r\n if (this._cache) {\r\n this._cache.clear();\r\n this._cache = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * @description\r\n * Returns acorn version.\r\n */\r\n get version(): string {\r\n return acornVersion;\r\n }\r\n\r\n /**\r\n * Gets the parser options.\r\n * @returns The parser options.\r\n */\r\n get options(): ParserOptions {\r\n return this.parserOptions;\r\n }\r\n\r\n /**\r\n * @description\r\n * Parses expression and returns ES6/ES2023 AST.\r\n * @param expr expression to parse\r\n * @param options optional parser options\r\n * @returns The parsed AST (Abstract Syntax Tree).\r\n */\r\n public parse(expr: string, options?: ParserOptions)\r\n : Program | AnyNode | Expression | undefined {\r\n if (this._isDestroyed) {\r\n throw new Error('ParserService has been destroyed and cannot be used');\r\n }\r\n \r\n if (expr) {\r\n try {\r\n const parserOptions = { ...this.parserOptions, ...options };\r\n const isCache = this.parserOptions.cacheSize && this._cache;\r\n const ast = isCache\r\n ? this.fromCacheOrParse(expr, parserOptions)\r\n : _parse(expr, parserOptions);\r\n return ast;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n //#region Private methods\r\n private fromCacheOrParse(expr: string, options: ParserOptions) {\r\n if (this._cache) {\r\n const hashKey = this._cache.getHashKey('', expr);\r\n let ast = this._cache.get(hashKey);\r\n if (!ast) {\r\n ast = _parse(expr, options);\r\n this._cache.set(hashKey, ast);\r\n }\r\n return ast;\r\n }\r\n return undefined;\r\n }\r\n //#endregion\r\n}\r\n","import { Injectable, OnDestroy, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { AnyNode } from 'acorn';\r\nimport { Context, Registry } from '../../internal/classes/common';\r\nimport { EvalContext, EvalOptions, EvalState, defaultParserOptions } from '../../internal/classes/eval';\r\nimport { evaluate, evaluateAsync } from '../../internal/functions';\r\n\r\n/**\r\n * Service for evaluating and parsing expressions with proper memory management.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class EvalService extends BaseEval implements OnDestroy {\r\n private _isDestroyed = false;\r\n private _activeContexts = new Set<Context>();\r\n private _activeStates = new Set<EvalState>();\r\n\r\n protected override parserService = inject(ParserService);\r\n\r\n /**\r\n * Constructs a new instance of the EvalService class.\r\n */\r\n constructor() {\r\n super(inject(ParserService));\r\n this.parserOptions = defaultParserOptions;\r\n }\r\n\r\n /**\r\n * Override createState to track active contexts and states for cleanup\r\n */\r\n override createState(context?: EvalContext | Context, options?: EvalOptions): EvalState {\r\n if (this._isDestroyed) {\r\n throw new Error('EvalService has been destroyed and cannot be used');\r\n }\r\n \r\n const state = super.createState(context, options);\r\n \r\n // Track active states for cleanup\r\n this._activeStates.add(state);\r\n \r\n // Track active contexts\r\n if (context && typeof context === 'object') {\r\n // Check if it's a Registry-based context (has type property)\r\n if ('type' in context) {\r\n this._activeContexts.add(context as Registry<unknown, unknown>);\r\n }\r\n // For EvalContext, check if it has a nested context using bracket notation\r\n if ('context' in context) {\r\n const nestedContext = (context as Record<string, unknown>)['context'];\r\n if (nestedContext && typeof nestedContext === 'object' && 'type' in nestedContext) {\r\n this._activeContexts.add(nestedContext as Registry<unknown, unknown>);\r\n }\r\n }\r\n }\r\n \r\n return state;\r\n }\r\n\r\n /**\r\n * Clean up resources to prevent memory leaks\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n \r\n // Clean up all active states\r\n for (const state of this._activeStates) {\r\n try {\r\n // Clear the stack in the result\r\n if (state.result?.stack) {\r\n state.result.stack.clear();\r\n }\r\n // Clear context if it has a clear method\r\n if (state.context && typeof state.context === 'object' && 'clear' in state.context && typeof state.context.clear === 'function') {\r\n (state.context as unknown as { clear(): void }).clear();\r\n }\r\n // Drop hook registrations so a long-lived closure cannot pin a\r\n // destroyed state. This matters most for a registry the caller passed\r\n // through `options.hooks` and still holds: one that outlives the\r\n // service keeps every state its closures captured reachable. A\r\n // state-owned registry would die with its state regardless.\r\n //\r\n // Guarded on `hasHooks` rather than reading `state.hooks`, because that\r\n // getter builds a registry on first access - allocating inside the\r\n // method whose job is releasing memory. The guard is exact for this\r\n // purpose: it is false only when no hook is registered, and clearing an\r\n // empty registry does nothing.\r\n if (state.hasHooks) {\r\n state.hooks.clear();\r\n }\r\n // Bookkeeping lives on the state and `clear` cannot reach it, so the\r\n // open-node stack and collected errors need dropping separately.\r\n state.resetHookBookkeeping();\r\n } catch (error) {\r\n console.warn('Error cleaning up EvalState:', error);\r\n }\r\n }\r\n this._activeStates.clear();\r\n \r\n // Clean up all active contexts\r\n for (const context of this._activeContexts) {\r\n try {\r\n if (context && typeof context.clear === 'function') {\r\n context.clear();\r\n }\r\n } catch (error) {\r\n console.warn('Error cleaning up Context:', error);\r\n }\r\n }\r\n this._activeContexts.clear();\r\n }\r\n\r\n /**\r\n * Evaluates the given expression.\r\n * @param expression The expression to evaluate.\r\n * @param context The evaluation context.\r\n * @param options The evaluation options.\r\n * @returns The result of the evaluation.\r\n */\r\n simpleEval(expression: string | AnyNode | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions\r\n ): unknown | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n const state = this.createState(context, options);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const value = evaluate(ast, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Evaluates an expression using the provided state.\r\n *\r\n * @param expression - The expression to evaluate.\r\n * @param state - The state object containing variables and functions used in the evaluation.\r\n * @returns The result of the evaluation.\r\n * @throws If an error occurs during evaluation.\r\n */\r\n eval(expression: string | AnyNode | undefined,\r\n state: EvalState\r\n ): unknown | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const value = evaluate(ast, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Asynchronously evaluates the given expression.\r\n * @param expression The expression to evaluate.\r\n * @param context The evaluation context.\r\n * @param options The evaluation options.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n */\r\n simpleEvalAsync(expression: string | AnyNode | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions\r\n ): Promise<unknown | undefined> {\r\n try {\r\n const ast = this.parse(expression);\r\n const state = this.createState(context, options);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const promise = evaluateAsync(ast, state);\r\n return promise;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Asynchronously evaluates an expression using the provided state.\r\n *\r\n * @param expression - The expression to evaluate. Can be a string or an AST node.\r\n * @param state - The evaluation state.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n * @throws If an error occurs during evaluation.\r\n */\r\n evalAsync(expression: string | AnyNode | undefined,\r\n state: EvalState\r\n ): Promise<unknown | undefined> {\r\n try {\r\n const ast = this.parse(expression);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const promise = evaluateAsync(ast, state);\r\n return promise;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\n\r\n","import { Injectable, OnDestroy, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { EvalService } from './eval.service';\r\nimport { EvalContext, EvalOptions, EvalState, defaultParserOptions } from '../../internal/classes/eval';\r\nimport { Context } from '../../internal/classes/common';\r\nimport { AnyNode } from 'acorn';\r\nimport { call as _call, callAsync as _callAsync,\r\n compile as _compile, compileAsync as _compileAsync,\r\n stateCallback, stateCallbackAsync } from '../../internal/functions';\r\n\r\n/**\r\n * Interface for cached compilation result\r\n */\r\ninterface CachedCompilation {\r\n sync?: stateCallback;\r\n async?: stateCallbackAsync;\r\n timestamp: number;\r\n accessCount: number;\r\n}\r\n\r\n/**\r\n * CompilerService class that extends BaseEval.\r\n * Provides methods for compiling and evaluating expressions with performance caching.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CompilerService extends BaseEval implements OnDestroy {\r\n \r\n // Compilation cache with LRU eviction\r\n private readonly _compilationCache = new Map<string, CachedCompilation>();\r\n private readonly _maxCacheSize = 200;\r\n private readonly _cacheTTL = 10 * 60 * 1000; // 10 minutes\r\n private readonly _accessOrder = new Set<string>();\r\n private _cacheCleanupInterval?: ReturnType<typeof setInterval>;\r\n private _isDestroyed = false;\r\n\r\n protected override parserService = inject(ParserService);\r\n protected evalService = inject(EvalService);\r\n\r\n constructor() {\r\n super(inject(ParserService));\r\n this.parserOptions = defaultParserOptions;\r\n this.setupCacheCleanup();\r\n }\r\n\r\n /**\r\n * OnDestroy lifecycle hook for cleanup\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n if (this._cacheCleanupInterval) {\r\n clearInterval(this._cacheCleanupInterval);\r\n }\r\n this._compilationCache.clear();\r\n this._accessOrder.clear();\r\n }\r\n\r\n /**\r\n * Setup periodic cache cleanup to prevent memory leaks and stale entries\r\n */\r\n private setupCacheCleanup(): void {\r\n if (typeof setInterval !== 'undefined') {\r\n this._cacheCleanupInterval = setInterval(() => {\r\n if (!this._isDestroyed) {\r\n this.cleanupCache();\r\n }\r\n }, 5 * 60 * 1000); // Clean every 5 minutes\r\n }\r\n }\r\n\r\n /**\r\n * Clean expired entries and enforce cache size limits\r\n */\r\n private cleanupCache(): void {\r\n const now = performance.now();\r\n const toDelete: string[] = [];\r\n \r\n // Remove expired entries\r\n for (const [key, cached] of this._compilationCache) {\r\n if (now - cached.timestamp > this._cacheTTL) {\r\n toDelete.push(key);\r\n }\r\n }\r\n \r\n // Remove expired entries\r\n toDelete.forEach(key => {\r\n this._compilationCache.delete(key);\r\n this._accessOrder.delete(key);\r\n });\r\n \r\n // Enforce cache size limit using LRU\r\n while (this._compilationCache.size > this._maxCacheSize) {\r\n const oldestKey = Array.from(this._accessOrder)[0];\r\n if (oldestKey) {\r\n this._compilationCache.delete(oldestKey);\r\n this._accessOrder.delete(oldestKey);\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Generate cache key for expression\r\n */\r\n private generateCacheKey(expression: string | AnyNode | undefined): string {\r\n if (typeof expression === 'string') {\r\n return `str:${expression}`;\r\n } else if (expression && typeof expression === 'object') {\r\n // Use a simplified hash for AST nodes to avoid deep serialization overhead\r\n return `ast:${expression.type}:${JSON.stringify({\r\n type: expression.type,\r\n start: expression.start,\r\n end: expression.end\r\n })}:${expression.toString()}`;\r\n }\r\n return 'undefined';\r\n }\r\n\r\n /**\r\n * Update access order for LRU cache\r\n */\r\n private updateAccessOrder(key: string): void {\r\n this._accessOrder.delete(key);\r\n this._accessOrder.add(key);\r\n }\r\n\r\n /**\r\n * Compiles the given expression into a state callback function with caching.\r\n * @param expression - The expression to compile.\r\n * @returns The compiled state callback function.\r\n * @throws Error if there is an error during compilation.\r\n */\r\n compile(expression: string | AnyNode | undefined): stateCallback | undefined {\r\n try {\r\n const cacheKey = this.generateCacheKey(expression);\r\n \r\n // Check cache first\r\n const cached = this._compilationCache.get(cacheKey);\r\n if (cached?.sync) {\r\n // Update access order for LRU\r\n this.updateAccessOrder(cacheKey);\r\n cached.accessCount++;\r\n \r\n // Check if entry is still fresh\r\n const age = performance.now() - cached.timestamp;\r\n if (age < this._cacheTTL) {\r\n return cached.sync;\r\n }\r\n }\r\n \r\n // Compile fresh\r\n const ast = this.parse(expression);\r\n const fn = _compile(ast);\r\n \r\n if (fn) {\r\n // Cache the result\r\n const existingCache = this._compilationCache.get(cacheKey) || {\r\n timestamp: performance.now(),\r\n accessCount: 0\r\n };\r\n \r\n existingCache.sync = fn;\r\n existingCache.timestamp = performance.now();\r\n existingCache.accessCount++;\r\n \r\n this._compilationCache.set(cacheKey, existingCache);\r\n this.updateAccessOrder(cacheKey);\r\n \r\n // Cleanup if cache is getting too large\r\n if (this._compilationCache.size > this._maxCacheSize * 1.2) {\r\n this.cleanupCache();\r\n }\r\n }\r\n \r\n return fn;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in compile');\r\n }\r\n }\r\n\r\n /**\r\n * Calls the given state callback function with the specified context and options.\r\n * @param fn - The state callback function to call.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns The result of the evaluation.\r\n * @throws Error if there is an error during the evaluation.\r\n */\r\n simpleCall(fn: stateCallback | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions) {\r\n if (fn) {\r\n try {\r\n const state = this.createState(context, options);\r\n const value = _call(fn, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw new Error('call');\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /**\r\n * Calls the provided function with the given state.\r\n *\r\n * @param fn - The function to be called.\r\n * @param state - The state to be passed to the function.\r\n * @returns The value returned by the function.\r\n * @throws If an error occurs during the function call.\r\n */\r\n call(fn: stateCallback | undefined,\r\n state: EvalState) {\r\n if (fn) {\r\n try {\r\n const value = _call(fn, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw new Error('call');\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compiles the given expression into an asynchronous state callback function with caching.\r\n * @param expression - The expression to compile.\r\n * @returns The compiled asynchronous state callback function.\r\n * @throws Error if there is an error during compilation.\r\n */\r\n compileAsync(expression: string | AnyNode | undefined): stateCallbackAsync | undefined {\r\n try {\r\n const cacheKey = this.generateCacheKey(expression);\r\n \r\n // Check cache first\r\n const cached = this._compilationCache.get(cacheKey);\r\n if (cached?.async) {\r\n // Update access order for LRU\r\n this.updateAccessOrder(cacheKey);\r\n cached.accessCount++;\r\n \r\n // Check if entry is still fresh\r\n const age = performance.now() - cached.timestamp;\r\n if (age < this._cacheTTL) {\r\n return cached.async;\r\n }\r\n }\r\n \r\n // Compile fresh\r\n const ast = this.parse(expression);\r\n const fn = _compileAsync(ast);\r\n \r\n if (fn) {\r\n // Cache the result\r\n const existingCache = this._compilationCache.get(cacheKey) || {\r\n timestamp: performance.now(),\r\n accessCount: 0\r\n };\r\n \r\n existingCache.async = fn;\r\n existingCache.timestamp = performance.now();\r\n existingCache.accessCount++;\r\n \r\n this._compilationCache.set(cacheKey, existingCache);\r\n this.updateAccessOrder(cacheKey);\r\n \r\n // Cleanup if cache is getting too large\r\n if (this._compilationCache.size > this._maxCacheSize * 1.2) {\r\n this.cleanupCache();\r\n }\r\n }\r\n \r\n return fn;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in compileAsync');\r\n }\r\n }\r\n\r\n /**\r\n * Calls the given asynchronous state callback function with the specified context and options.\r\n * @param fn - The asynchronous state callback function to call.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n * @throws Error if there is an error during the evaluation.\r\n */\r\n async simpleCallAsync(fn: stateCallbackAsync | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions) {\r\n if (fn) {\r\n try {\r\n const state = this.createState(context, options);\r\n const promise = _callAsync(fn, state);\r\n const value = await promise;\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in callAsync');\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /**\r\n * Calls the provided asynchronous function with the given state.\r\n *\r\n * @param fn - The asynchronous function to call.\r\n * @param state - The state to pass to the function.\r\n * @returns A promise that resolves to the value returned by the function.\r\n * @throws If an error occurs during the function call.\r\n */\r\n async callAsync(fn: stateCallbackAsync | undefined,\r\n state: EvalState) {\r\n if (fn) {\r\n try {\r\n const promise = _callAsync(fn, state);\r\n const value = await promise;\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in callAsync');\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../../internal/interfaces';\r\nimport { extract } from '../../internal/functions';\r\nimport { defaultParserOptions } from '../../internal/classes/eval';\r\n\r\n/**\r\n * Service responsible for discovering nodes in an abstract syntax tree (AST).\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class DiscoveryService extends BaseEval {\r\n\r\n protected override parserService = inject(ParserService);\r\n\r\n /**\r\n * Creates a new instance of the DiscoveryService class.\r\n */\r\n constructor() {\r\n super(inject(ParserService));\r\n\r\n this.parserOptions = {\r\n ...defaultParserOptions,\r\n cacheSize: undefined\r\n };\r\n }\r\n\r\n /**\r\n * Finds all nodes in the AST that match the given expression and search type.\r\n * @param expression The expression to search for. Can be a string or an AST node.\r\n * @param searchType The type of nodes to search for.\r\n * @param options Optional parser options.\r\n * @returns An array of nodes that match the search criteria, or undefined if no nodes are found.\r\n * @throws If an error occurs during the search process.\r\n */\r\n extract(expression: string | AnyNode | undefined,\r\n searchType: AnyNodeTypes): AnyNode[] | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n const value = extract(ast, searchType);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["DANGEROUS_CONSTRUCTORS","_parse","acornVersion","_compile","_call","_compileAsync","_callAsync"],"mappings":";;;;;;AAEA;;AAEG;MACU,YAAY,CAAA;AAYvB;;;AAGG;AACH,IAAA,WAAA,CAAY,OAA8C,EAAA;AAfzC,QAAA,IAAA,CAAA,SAAS,GAAsB,IAAI,GAAG,EAAE;QAEzD,IAAA,CAAA,IAAI,GAAqB,cAAc;AAEvC;;AAEG;AACH,QAAA,IAAA,CAAA,OAAO,GAAsC;AAC3C,YAAA,eAAe,EAAE;SA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,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cAFf,MAAM,EAAA,CAAA,CAAA;;2FAEP,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAH5B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
1
+ {"version":3,"file":"zvenigora-ng-eval-core.mjs","sources":["../../../../modules/eval-core/src/lib/internal/classes/common/base-registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/case-insensitive-registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/registry.ts","../../../../modules/eval-core/src/lib/internal/classes/common/queue.ts","../../../../modules/eval-core/src/lib/internal/classes/common/stack.ts","../../../../modules/eval-core/src/lib/internal/classes/common/cache.ts","../../../../modules/eval-core/src/lib/internal/visitors/utils.ts","../../../../modules/eval-core/src/lib/internal/classes/common/context.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-context.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-trace.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-result.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-hooks.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/hooks/timing-hook.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-state.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/parser-options.ts","../../../../modules/eval-core/src/lib/internal/visitors/visitor-result.ts","../../../../modules/eval-core/src/lib/internal/visitors/before-visitor.ts","../../../../modules/eval-core/src/lib/internal/visitors/after-visitor.ts","../../../../modules/eval-core/src/lib/internal/interfaces/recursive-visitors.ts","../../../../modules/eval-core/src/lib/internal/visitors/identifier.ts","../../../../modules/eval-core/src/lib/internal/visitors/literal.ts","../../../../modules/eval-core/src/lib/internal/visitors/binary-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/prototype-pollution-guard.ts","../../../../modules/eval-core/src/lib/internal/visitors/property-lookup-cache.ts","../../../../modules/eval-core/src/lib/internal/visitors/member-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/array-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/call-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/import-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/await-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/conditional-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/unary-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/logical-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/this-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/new-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/template-literal.ts","../../../../modules/eval-core/src/lib/internal/visitors/tagged-template-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/object-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/recursive-visitors.ts","../../../../modules/eval-core/src/lib/internal/visitors/pattern.ts","../../../../modules/eval-core/src/lib/internal/visitors/variable-declaration.ts","../../../../modules/eval-core/src/lib/internal/visitors/assignment-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/update-expression.ts","../../../../modules/eval-core/src/lib/internal/functions/parse.ts","../../../../modules/eval-core/src/lib/internal/functions/evaluate.ts","../../../../modules/eval-core/src/lib/internal/functions/compile.ts","../../../../modules/eval-core/src/lib/internal/functions/extract.ts","../../../../modules/eval-core/src/lib/internal/visitors/arrow-function-expression.ts","../../../../modules/eval-core/src/lib/internal/visitors/dispatch-statement.ts","../../../../modules/eval-core/src/lib/internal/visitors/program.ts","../../../../modules/eval-core/src/lib/internal/visitors/expression-statement.ts","../../../../modules/eval-core/src/lib/internal/visitors/empty-statement.ts","../../../../modules/eval-core/src/lib/internal/visitors/block-statement.ts","../../../../modules/eval-core/src/lib/internal/visitors/if-statement.ts","../../../../modules/eval-core/src/lib/internal/visitors/for-statement.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/eval-scope.ts","../../../../modules/eval-core/src/lib/internal/classes/eval/hooks/dependency-tracker.ts","../../../../modules/eval-core/src/lib/actual/services/base-eval.ts","../../../../modules/eval-core/src/lib/actual/services/parser.service.ts","../../../../modules/eval-core/src/lib/actual/services/eval.service.ts","../../../../modules/eval-core/src/lib/actual/services/compiler.service.ts","../../../../modules/eval-core/src/lib/actual/services/discovery.service.ts","../../../../modules/eval-core/src/zvenigora-ng-eval-core.ts"],"sourcesContent":["import { RegistryEntries, RegistryType } from \"../../interfaces\";\r\n\r\n/**\r\n * Represents a registry that stores key-value pairs.\r\n */\r\nexport class BaseRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n private readonly _registry: Map<TKey, TValue> = new Map();\r\n\r\n type: Readonly<string> = 'BaseRegistry';\r\n\r\n /**\r\n * Options for the base registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new Registry instance.\r\n * @param entries - Optional array of key-value pairs to initialize the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null) {\r\n if (entries && Array.isArray(entries)) {\r\n for (const [key, value] of entries) {\r\n this.set(key, value);\r\n }\r\n } else if (entries && typeof entries === 'object') {\r\n for (const [key, value] of Object.entries(entries)) {\r\n this.set(key as TKey, value as TValue);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new Registry instance from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new Registry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): BaseRegistry<TKey, TValue> {\r\n const registry = new BaseRegistry<TKey, TValue>();\r\n for (const [key, value] of Object.entries(object)) {\r\n registry.set(key as TKey, value as TValue);\r\n }\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist.\r\n */\r\n public get(key: TKey): TValue | undefined{\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key to check.\r\n * @returns True if the registry contains the key, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key to delete.\r\n * @returns True if the key-value pair was deleted, false if the key does not exist.\r\n */\r\n public delete(key: TKey): boolean {\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this._registry.keys();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this._registry.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries();\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n * @param thisArg - Optional value to use as `this` when executing the callback function.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [TKey, TValue].\r\n */\r\n public [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries();\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n}\r\n","import { RegistryEntries, RegistryType } from \"../../interfaces\";\r\n\r\n// some code here:\r\n// https://stackoverflow.com/questions/50019920/javascript-map-key-value-pairs-case-insensitive-search\r\n\r\n/**\r\n * Represents a case-insensitive registry that maps keys to values.\r\n */\r\nexport class CaseInsensitiveRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n\r\n private readonly registry: Map<TKey, TValue> = new Map();\r\n private keysMap = new Map<TKey, TKey>();\r\n\r\n type: Readonly<string> = 'CaseInsensitiveRegistry';\r\n\r\n /**\r\n * Options for the registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: true\r\n };\r\n\r\n /**\r\n * Creates a new instance of CaseInsensitiveRegistry.\r\n * @param entries - Optional initial entries to populate the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null) {\r\n if (entries && Array.isArray(entries)) {\r\n for (const [key, value] of entries) {\r\n this.set(key, value);\r\n }\r\n } else if (entries && typeof entries === 'object') {\r\n for (const [key, value] of Object.entries(entries)) {\r\n this.set(key as TKey, value as TValue);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new CaseInsensitiveRegistry from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new CaseInsensitiveRegistry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): CaseInsensitiveRegistry<TKey, TValue> {\r\n const registry = new CaseInsensitiveRegistry<TKey, TValue>();\r\n for (const [key, value] of Object.entries(object)) {\r\n registry.set(key as TKey, value as TValue);\r\n }\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\n public get(key: TKey): TValue | undefined {\r\n return this.registry.get(this.getKey(key));\r\n }\r\n\r\n /**\r\n * Sets a key-value pair in the registry.\r\n * @param key - The key.\r\n * @param value - The value.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n const newKey = this.getKey(key);\r\n this.registry.set(newKey, value);\r\n this.keysMap.set(newKey, key);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key.\r\n * @returns True if the key is found, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this.registry.has(this.getKey(key));\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key.\r\n * @returns True if the key-value pair is deleted, false if the key is not found.\r\n */\r\n public delete(key: TKey): boolean {\r\n const newKey = this.getKey(key);\r\n this.keysMap.delete(newKey);\r\n return this.registry.delete(newKey);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this.registry.clear();\r\n this.keysMap.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this.registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this.keysMap.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this.registry.values();\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n const keys = this.keysMap.values();\r\n const values = this.registry.values();\r\n const entries = new Array<[TKey, TValue]> ;\r\n for (let i = 0; i < this.registry.size; i++) {\r\n const keyResult = keys.next();\r\n const valueResult = values.next();\r\n if (!keyResult.done && !valueResult.done) {\r\n entries.push([keyResult.value, valueResult.value]);\r\n }\r\n }\r\n return entries.values();\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void {\r\n this.registry.forEach(callbackfn);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [string, unknown].\r\n */\r\n [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this.registry[Symbol.iterator]();\r\n }\r\n\r\n private getKey(key: TKey): TKey {\r\n const keyLowerCase = typeof key === 'string'\r\n ? key.toLowerCase() as unknown as TKey\r\n : key;\r\n return keyLowerCase;\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n\r\n}\r\n","/**\r\n * Represents a generic registry that stores key-value pairs.\r\n * @template TKey The type of the keys in the registry.\r\n * @template TValue The type of the values in the registry.\r\n */\r\nimport { RegistryEntries, RegistryType } from \"../../interfaces\";\r\nimport { BaseRegistry } from \"./base-registry\";\r\nimport { CaseInsensitiveRegistry } from \"./case-insensitive-registry\";\r\n\r\nexport class Registry<TKey, TValue> implements RegistryType<TKey, TValue> {\r\n private readonly _registry: CaseInsensitiveRegistry<TKey, TValue> | BaseRegistry<TKey, TValue>;\r\n\r\n type: Readonly<string> = 'Registry';\r\n\r\n /**\r\n * Options for the registry.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new Registry instance.\r\n * @param entries - Optional array of key-value pairs to initialize the registry.\r\n */\r\n constructor(entries?: RegistryEntries<TKey, TValue> | null,\r\n options: Record<string, unknown> = { caseInsensitive: false }) {\r\n this.options = options;\r\n const caseInsensitive = typeof options?.['caseInsensitive'] === 'boolean' ? options['caseInsensitive'] : false;\r\n this._registry = caseInsensitive\r\n ? new CaseInsensitiveRegistry<TKey, TValue>(entries)\r\n : new BaseRegistry<TKey, TValue>(entries)\r\n }\r\n\r\n /**\r\n * Creates a new Registry instance from an object.\r\n * @param object - The object containing key-value pairs.\r\n * @returns A new Registry instance.\r\n */\r\n public static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>,\r\n options: Record<string, unknown> = { caseInsensitive: false }): Registry<TKey, TValue> {\r\n\r\n const entries = Object.entries(object) as [TKey, TValue][];\r\n const registry = new Registry<TKey, TValue>(entries, options);\r\n\r\n return registry;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist.\r\n */\r\n public get(key: TKey): TValue | undefined{\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: TKey, value: TValue): void {\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the registry contains the specified key.\r\n * @param key - The key to check.\r\n * @returns True if the registry contains the key, false otherwise.\r\n */\r\n public has(key: TKey): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the key-value pair associated with the specified key.\r\n * @param key - The key to delete.\r\n * @returns True if the key-value pair was deleted, false if the key does not exist.\r\n */\r\n public delete(key: TKey): boolean {\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears all key-value pairs from the registry.\r\n */\r\n public clear(): void {\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the registry.\r\n */\r\n public get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the registry.\r\n */\r\n public get keys(): IterableIterator<TKey> {\r\n return this._registry.keys;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the registry.\r\n */\r\n public get values(): IterableIterator<TValue> {\r\n return this._registry.values;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the key-value pairs in the registry.\r\n */\r\n public get entries(): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the registry.\r\n * @param callbackfn - The function to execute for each key-value pair.\r\n * @param thisArg - Optional value to use as `this` when executing the callback function.\r\n */\r\n public forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries of the registry.\r\n * @returns An iterator that yields key-value pairs of type [TKey, TValue].\r\n */\r\n public [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Converts a BaseRegistry instance to an object.\r\n * @param registry The BaseRegistry instance to convert.\r\n * @returns An object representing the key-value pairs in the registry.\r\n */\r\n public toObject(): Record<string | number | symbol, TValue> {\r\n\r\n const object = Object.fromEntries(this.entries);\r\n\r\n return object as Record<string | number | symbol, TValue>;\r\n }\r\n}\r\n","import { QueueType } from '../../interfaces';\r\n\r\n/**\r\n * Represents a generic queue data structure.\r\n * @template T The type of elements stored in the queue.\r\n */\r\nexport class Queue<T> implements QueueType<T> {\r\n\r\n /**\r\n * Creates a new instance of the Queue class.\r\n * @param _queue Optional initial array of elements.\r\n */\r\n public constructor(\r\n private readonly _queue: T[] = []\r\n ) {}\r\n\r\n /**\r\n * Gets the number of elements in the queue.\r\n */\r\n public get length(): number {\r\n return this._queue.length;\r\n }\r\n\r\n /**\r\n * Removes and returns the first element in the queue.\r\n * @returns The first element in the queue, or undefined if the queue is empty.\r\n */\r\n public dequeue(): T | undefined {\r\n return this._queue.shift();\r\n }\r\n\r\n /**\r\n * Adds an element to the end of the queue.\r\n * @param value The element to add to the queue.\r\n * @returns The new length of the queue.\r\n */\r\n public enqueue(value: T): number {\r\n return this._queue.push(value);\r\n }\r\n\r\n /**\r\n * Returns the first element in the queue without removing it.\r\n * @returns The first element in the queue.\r\n */\r\n public peek(): T {\r\n return this._queue[0];\r\n }\r\n}\r\n","import { StackType } from '../../interfaces';\r\n\r\n/**\r\n * Represents a stack data structure with proper memory management.\r\n * @template T The type of elements in the stack.\r\n */\r\nexport class Stack<T> implements StackType<T> {\r\n private _disposed = false;\r\n\r\n /**\r\n * Creates a new instance of the Stack class.\r\n * @param _stack An optional array to initialize the stack.\r\n */\r\n public constructor(\r\n private _stack: T[] = []\r\n ) {}\r\n\r\n /**\r\n * Check if the stack has been disposed\r\n */\r\n private checkDisposed(): void {\r\n if (this._disposed) {\r\n throw new Error('Stack has been disposed and cannot be used');\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of elements in the stack.\r\n */\r\n public get length(): number {\r\n this.checkDisposed();\r\n return this._stack.length;\r\n }\r\n\r\n /**\r\n * Returns the top element of the stack without removing it.\r\n * @returns The top element of the stack.\r\n */\r\n public peek(): T {\r\n this.checkDisposed();\r\n return this._stack[this._stack.length - 1];\r\n }\r\n\r\n /**\r\n * Removes and returns the top element of the stack.\r\n * @returns The top element of the stack, or undefined if the stack is empty.\r\n */\r\n public pop(): T | undefined{\r\n this.checkDisposed();\r\n return this._stack.pop();\r\n }\r\n\r\n /**\r\n * Adds an element to the top of the stack.\r\n * @param value The element to be added to the stack.\r\n * @returns The new length of the stack.\r\n */\r\n public push(value: T): number {\r\n this.checkDisposed();\r\n return this._stack.push(value);\r\n }\r\n\r\n /**\r\n * Swaps the positions of the top two elements in the stack.\r\n */\r\n public swap(): void {\r\n this.checkDisposed();\r\n const length = this._stack.length;\r\n const temp = this._stack[length - 1];\r\n this._stack[length - 1] = this._stack[length - 2];\r\n this._stack[length - 2] = temp;\r\n }\r\n\r\n /**\r\n * Returns the elements of the stack as an array in reverse order.\r\n *\r\n * @returns An array containing the elements of the stack in reverse order.\r\n */\r\n public asArray(): T[] {\r\n this.checkDisposed();\r\n return [...this._stack].reverse();\r\n }\r\n\r\n /**\r\n * Clears all elements from the stack\r\n */\r\n public clear(): void {\r\n this.checkDisposed();\r\n // Clear all references to help with garbage collection\r\n if (this._stack) {\r\n this._stack.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Properly dispose of the stack and clean up memory\r\n */\r\n public dispose(): void {\r\n if (!this._disposed) {\r\n this._disposed = true;\r\n \r\n // Clear the stack array and nullify reference\r\n if (this._stack) {\r\n this._stack.length = 0;\r\n (this as unknown as { _stack?: T[] })._stack = undefined;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Check if the stack has been disposed\r\n */\r\n public isDisposed(): boolean {\r\n return this._disposed;\r\n }\r\n}\r\n","import { sha256 } from 'js-sha256';\r\nimport { RegistryType, CacheType } from '../../interfaces';\r\nimport { BaseRegistry } from './base-registry';\r\n\r\n/**\r\n * Represents a cache implementation that stores key-value pairs.\r\n * @template TValue The type of values stored in the cache.\r\n */\r\nexport class Cache<TValue> implements CacheType<TValue> {\r\n /**\r\n * The registry that stores the key-value pairs.\r\n */\r\n private readonly _registry: RegistryType<string, TValue>;\r\n /**\r\n * The queue that keeps track of the keys in the cache.\r\n */\r\n private readonly _keyQueue: string[];\r\n\r\n type: Readonly<string> = 'Cache';\r\n\r\n /**\r\n * Options for the cache.\r\n */\r\n options: Readonly<Record<string, unknown>> = {\r\n caseInsensitive: false\r\n };\r\n\r\n /**\r\n * Creates a new instance of the Cache class.\r\n * @param _maxCacheSize The maximum size of the cache.\r\n */\r\n constructor(\r\n private readonly _maxCacheSize: number,\r\n ) {\r\n this._registry = new BaseRegistry<string, TValue>();\r\n this._keyQueue = [];\r\n }\r\n\r\n /**\r\n * Gets the maximum size of the cache.\r\n */\r\n get maxCacheSize(): number {\r\n return this._maxCacheSize;\r\n }\r\n\r\n /**\r\n * Generates a hash key based on the given namespace and value.\r\n * @param namespace The namespace for the key.\r\n * @param value The value for the key.\r\n * @returns The generated hash key.\r\n */\r\n getHashKey(namespace: string, value: string): string {\r\n const key = sha256(`${namespace}:${value}`);\r\n return key;\r\n }\r\n\r\n /**\r\n * Gets the value associated with the specified key.\r\n * @param key The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key does not exist in the cache.\r\n */\r\n get(key: string): TValue | undefined {\r\n return this._registry.get(key);\r\n }\r\n\r\n /**\r\n * Sets the value for the specified key in the cache.\r\n * @param key The key to set the value for.\r\n * @param value The value to set.\r\n */\r\n set(key: string, value: TValue): void {\r\n const index = this._keyQueue.indexOf(key);\r\n if (index === -1) {\r\n this._keyQueue.push(key);\r\n }\r\n while(this._keyQueue.length > this._maxCacheSize) {\r\n const removeKey = this._keyQueue.shift();\r\n if (removeKey) {\r\n this._registry.delete(removeKey);\r\n }\r\n }\r\n\r\n this._registry.set(key, value);\r\n }\r\n\r\n /**\r\n * Checks if the cache contains the specified key.\r\n * @param key The key to check.\r\n * @returns True if the cache contains the key, false otherwise.\r\n */\r\n has(key: string): boolean {\r\n return this._registry.has(key);\r\n }\r\n\r\n /**\r\n * Deletes the value associated with the specified key from the cache.\r\n * @param key The key to delete.\r\n * @returns True if the value was successfully deleted, false otherwise.\r\n */\r\n delete(key: string): boolean {\r\n const index = this._keyQueue.indexOf(key);\r\n if (index > -1) {\r\n this._keyQueue.splice(index, 1);\r\n }\r\n return this._registry.delete(key);\r\n }\r\n\r\n /**\r\n * Clears the cache, removing all key-value pairs.\r\n */\r\n clear(): void {\r\n this._keyQueue.length = 0;\r\n this._registry.clear();\r\n }\r\n\r\n /**\r\n * Gets the number of key-value pairs in the cache.\r\n */\r\n get size(): number {\r\n return this._registry.size;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the keys in the cache.\r\n */\r\n get keys(): IterableIterator<string> {\r\n return this._registry.keys;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the values in the cache.\r\n */\r\n get values(): IterableIterator<TValue> {\r\n return this._registry.values;\r\n }\r\n\r\n /**\r\n * Gets an iterator for the entries (key-value pairs) in the cache.\r\n */\r\n get entries(): IterableIterator<[string, TValue]> {\r\n return this._registry.entries;\r\n }\r\n\r\n /**\r\n * Executes a provided function once for each key-value pair in the cache.\r\n * @param callbackfn The function to execute for each key-value pair.\r\n * @param thisArg The value to use as `this` when executing the callback function.\r\n */\r\n forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: TValue): void {\r\n this._registry.forEach(callbackfn, thisArg);\r\n }\r\n\r\n /**\r\n * Returns an iterator for the entries (key-value pairs) in the cache.\r\n */\r\n [Symbol.iterator](): IterableIterator<[string, TValue]> {\r\n return this._registry[Symbol.iterator]();\r\n }\r\n}\r\n","import { BaseContext } from \"../classes/common/context\";\r\n\r\n/**\r\n * Retrieves the key-value pair from an object based on the provided key.\r\n * @param obj - The object to search for the key-value pair.\r\n * @param key - The key to search for in the object.\r\n * @param caseInsesitive - Specifies whether the key comparison should be case-insensitive.\r\n * @returns The key-value pair as an array, or undefined if the key is not found.\r\n */\r\nexport const getKeyValue = (obj: BaseContext,\r\n key: string | number | symbol,\r\n caseInsesitive: boolean): [string | number | symbol, unknown] | undefined => {\r\n\r\n if (!caseInsesitive || typeof key !== 'string') {\r\n const value = obj[key];\r\n return [key, value];\r\n }\r\n\r\n if (typeof key === 'string') {\r\n let currentObj = obj;\r\n do {\r\n const keys: string[] = Object.getOwnPropertyNames(currentObj);\r\n if (Array.isArray(keys)) {\r\n const foundKey = keys.find(k => equalIgnoreCase(key, k));\r\n if (foundKey) {\r\n const value = currentObj[foundKey];\r\n return [foundKey, value];\r\n }\r\n }\r\n } while ((currentObj = Object.getPrototypeOf(currentObj)));\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Compares two values for equality, ignoring case sensitivity.\r\n * @param a - The first value to compare.\r\n * @param b - The second value to compare.\r\n * @returns `true` if the values are equal, `false` otherwise.\r\n */\r\nexport const equalIgnoreCase = (a: string | number | symbol, b: string | number | symbol) => {\r\n if (typeof a === 'number' || typeof b === 'number') {\r\n return a === b;\r\n } else if (typeof a === 'symbol' || typeof b === 'symbol') {\r\n return a === b;\r\n } else if (typeof a === 'string' || typeof b === 'string') {\r\n return a.localeCompare(b, 'en', { sensitivity: 'base' }) === 0;\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Retrieves the value from an object, ignoring the case of the key.\r\n * @param obj - The object to retrieve the value from.\r\n * @param key - The key to search for, ignoring the case.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\nexport const getValueIgnoreCase = (obj: BaseContext,\r\n key: string | number | symbol): unknown | undefined => {\r\n const pair = getKeyValue(obj, key, true);\r\n if (pair) {\r\n return pair[1];\r\n }\r\n return undefined;\r\n}\r\n","import { equalIgnoreCase, getKeyValue } from '../../visitors/utils';\r\nimport { Registry } from '../common';\r\nimport { EvalOptions } from '../eval';\r\n\r\nexport type BaseContext = Record<string | number | symbol, unknown>;\r\n\r\nexport type Context = Registry<unknown, unknown> | BaseContext;\r\n\r\nexport function isRegistryContext (context?: Context): boolean {\r\n const value = ['Registry', 'CaseInsensitiveRegistry', 'BaseRegistry'].includes(context?.type as string);\r\n return value;\r\n}\r\n\r\n/**\r\n * Converts a context object to a Context instance.\r\n * @param context - The context object to convert.\r\n * @param options - Optional evaluation options.\r\n * @returns The converted Context instance.\r\n */\r\nexport const fromContext = (context?: Context, options?: EvalOptions): Context => {\r\n const caseInsensitive = options?.caseInsensitive;\r\n if (!context) {\r\n return {} as Record<string | number | symbol, unknown>;\r\n } else if (context instanceof Registry) {\r\n return context;\r\n } else if (caseInsensitive && context instanceof Object) {\r\n return Registry.fromObject(context as Record<string | number | symbol, unknown>, options) as Context;\r\n } else {\r\n return context;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the value associated with the specified key from the given context.\r\n * If the context is an instance of Registry, it uses the `get` method to retrieve the value.\r\n * If the context is an object, it accesses the value using the key as a property name.\r\n * If the context is neither an instance of Registry nor an object, it returns undefined.\r\n *\r\n * @param context The context from which to retrieve the value.\r\n * @param key The key associated with the value to retrieve.\r\n * @returns The value associated with the specified key, or undefined if not found.\r\n */\r\nexport const getContextValue = (context?: Context, key?: unknown): unknown => {\r\n if (context instanceof Registry) {\r\n return context.get(key);\r\n } else if (context instanceof Object) {\r\n return context[key as string | number | symbol];\r\n } else {\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Sets a value in the given context object.\r\n * If the context is an instance of Registry, the value is set using the key.\r\n * If the context is a plain object, the value is set using the key as a property name.\r\n * @param context - The context object.\r\n * @param key - The key or property name.\r\n * @param value - The value to be set.\r\n */\r\nexport const setContextValue = (context: Context, key: unknown, value: unknown): void => {\r\n if (context instanceof Registry) {\r\n const registry = context as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (context instanceof Object) {\r\n const object = context as Record<string, unknown>;\r\n object[key as string | number] = value;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the key from the given context object.\r\n * If the context is an instance of Registry, it searches for the key in a case-insensitive manner if specified.\r\n * If the context is an instance of Object, it uses the getKeyValue function to retrieve the key-value pair.\r\n * @param context - The context object.\r\n * @param key - The key to retrieve.\r\n * @param caseInsensitive - Specifies whether the search should be case-insensitive (only applicable for Registry instances).\r\n * @returns The retrieved key, or undefined if the key is not found.\r\n */\r\nexport const getContextKey = (context: Context,\r\n key: string | number | symbol,\r\n caseInsensitive: boolean): string | number | symbol | undefined => {\r\n\r\n if (context instanceof Registry) {\r\n const keys = [...context.keys]; // : (string | number | symbol)[]\r\n const foundKey = caseInsensitive && typeof key === 'string'\r\n ? keys.find(k => equalIgnoreCase(key as string, k as string))\r\n : keys.find(k => k === key);\r\n if (foundKey) {\r\n return foundKey as string | number | symbol;\r\n }\r\n } else if (context instanceof Object) {\r\n const pair = getKeyValue(context as BaseContext,\r\n key as string | number | symbol, caseInsensitive);\r\n\r\n if (pair) {\r\n return pair[0] as string | number | symbol;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n","import { Context, Registry, Stack, fromContext } from '../common';\r\nimport { getContextKey, getContextValue, setContextValue } from '../common/context';\r\nimport { EvalLookup } from './eval-lookup';\r\nimport { EvalOptions } from './eval-options';\r\nimport { EvalScope } from './eval-scope';\r\n\r\n/**\r\n * Whether a context holds a key at all, regardless of the value bound to it.\r\n *\r\n * There is no `getContextValue` counterpart for this: that helper cannot\r\n * distinguish an absent key from one bound to `undefined`, and `getContextKey`\r\n * with `caseInsensitive: false` reports every key as present for a plain\r\n * object. Own properties only - the scopes this is used on are object literals\r\n * built by `evaluatePatterns`, and inherited names are not bindings.\r\n */\r\nconst hasContextKey = (context: Context, key: unknown): boolean => {\r\n if (context instanceof Registry) {\r\n return context.has(key);\r\n }\r\n return context instanceof Object\r\n && Object.prototype.hasOwnProperty.call(context, key as PropertyKey);\r\n};\r\n\r\n/**\r\n * Represents the evaluation context for the code execution.\r\n */\r\nexport class EvalContext {\r\n\r\n type = 'EvalContext';\r\n\r\n private _original: Readonly<Context>;\r\n private _priorScopes: EvalScope[];\r\n private _scopes: Stack<Context>;\r\n private _lookups: EvalLookup[];\r\n private _options: Readonly<EvalOptions>;\r\n\r\n /**\r\n * Gets the original registry.\r\n */\r\n public get original(): Context {\r\n return this._original;\r\n }\r\n\r\n /**\r\n * Gets the scopes registry.\r\n */\r\n public get priorScopes(): EvalScope[] {\r\n return this._priorScopes;\r\n }\r\n\r\n /**\r\n * Gets the scopes registry.\r\n */\r\n public get scopes(): Readonly<Stack<Context>> {\r\n return this._scopes;\r\n }\r\n\r\n /**\r\n * Gets the lookups registry.\r\n */\r\n public get lookups(): EvalLookup[] {\r\n return this._lookups;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalContext.\r\n * @param original - The original registry or an object to create a registry from.\r\n * @param options - The evaluation options.\r\n */\r\n constructor(\r\n original: Context,\r\n options: EvalOptions\r\n ) {\r\n this._original = original;\r\n this._priorScopes = [];\r\n this._scopes = new Stack<Context>();\r\n this._options = options;\r\n this._lookups = [];\r\n }\r\n\r\n /**\r\n * Converts the given context to an instance of EvalContext.\r\n * @param context - The context to convert.\r\n * @param options - The evaluation options.\r\n * @returns The converted EvalContext instance.\r\n */\r\n public static fromContext(context?: EvalContext | Context | undefined,\r\n options?: EvalOptions): EvalContext {\r\n\r\n if (context instanceof EvalContext) {\r\n return context;\r\n }\r\n\r\n const ctx = fromContext(context ?? {}, options);\r\n return new EvalContext(ctx, options ?? {});\r\n }\r\n\r\n /**\r\n * Gets the value associated with the specified key from the evaluation context.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if not found.\r\n */\r\n public get(key: unknown): unknown | undefined {\r\n\r\n // Presence, not value: a scope that *binds* the key answers, even when the\r\n // value bound is `undefined`. See {@link scopeHolding} for why the two are\r\n // not the same question, and what reading the value instead let through.\r\n const scope = this.scopeHolding(key);\r\n if (scope) {\r\n return getContextValue(scope, key);\r\n }\r\n\r\n if (this._original) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n\r\n for (const scope of this._priorScopes) {\r\n const value = scope.get(key);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n\r\n for (const lookup of this._lookups) {\r\n const value = lookup(key, this, this._options);\r\n if (value !== undefined) {\r\n return value;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Step 1 of {@link get}'s resolution order on its own: the scopes pushed\r\n * during this evaluation, innermost first.\r\n *\r\n * {@link get} calls this rather than inlining the loop, so that the read\r\n * hooks' `scoped` flag and the resolution it describes are the *same*\r\n * implementation. A second copy of the order would drift - `getKey` already\r\n * shows what that looks like when it does.\r\n *\r\n * A binding whose value is `undefined` is **found** here, and no longer reads\r\n * as absent - see {@link scopeHolding}.\r\n *\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value bound by the innermost scope holding the key, or\r\n * undefined when no pushed scope holds it. The two cases are no longer\r\n * distinguishable from the return value alone; ask {@link hasInScopes}.\r\n */\r\n public getFromScopes(key: unknown): unknown | undefined {\r\n\r\n const scope = this.scopeHolding(key);\r\n return scope ? getContextValue(scope, key) : undefined;\r\n }\r\n\r\n /**\r\n * The innermost pushed scope that **binds** `key`, or undefined when none\r\n * does. The single pass behind {@link get}'s step 1, {@link getFromScopes}\r\n * and {@link hasInScopes}, so the three cannot disagree about what the scope\r\n * stack holds.\r\n *\r\n * **Binding, not value, and that is the whole point.** Reading the value and\r\n * treating `undefined` as absent - which is what this used to do - has two\r\n * consequences that look unrelated and are the same bug:\r\n *\r\n * - `let x;` could not shadow. A scope binding `x` to `undefined` fell\r\n * through to the caller's context, so a declared-but-unset name read\r\n * whatever the consumer happened to have under it.\r\n * - **A plain-object scope answered for every `Object.prototype` name.**\r\n * `getContextValue` reads a plain record as `scope[key]`, which walks the\r\n * prototype chain, so an *empty* scope resolved `toString`, `constructor`,\r\n * `valueOf` and friends to the prototype's own members - shadowing\r\n * `original`, `priorScopes` and `lookups`, all four of which come later in\r\n * {@link get}'s order. Empty as a binding surface is not empty as a lookup\r\n * surface. `hasContextKey` is own-properties-only, which closes it.\r\n *\r\n * The second was invisible while only `arrow-function-expression.ts` and\r\n * `pattern.ts` pushed scopes, because a walk that pushed none could not hit\r\n * it; a program-level scope on every evaluation made it reachable from every\r\n * expression, which is how it was found.\r\n *\r\n * It also removes an asymmetry between the two scope shapes: `fromContext`\r\n * copies a plain record into a `Registry` when `caseInsensitive` is set, and\r\n * a `Registry` is Map-backed, so the prototype names leaked on the\r\n * case-sensitive path and not on the case-insensitive one. Both now ask the\r\n * same own-key question.\r\n *\r\n * **Public since Phase 2 step 3, and the reason is the write sites.**\r\n * `assignment-expression.ts` and `update-expression.ts` need the *scope* and\r\n * not a yes/no: `const` kinds are recorded against the scope object on\r\n * `EvalState`, so a write has to know which scope it is about to land in\r\n * before it can decide whether the binding is reassignable. Publishing the\r\n * single pass is what keeps that question answered by the same code as\r\n * {@link get}'s step 1. The alternative was a second copy of the\r\n * innermost-scope walk at each write site, which is the defect\r\n * `docs/backlog.md` A4 and A10 already describe - two copies of one\r\n * resolution order, drifting - reproduced on purpose.\r\n *\r\n * @param key - The key to look for.\r\n * @returns The innermost scope binding the key, or undefined.\r\n */\r\n public scopeHolding(key: unknown): Context | undefined {\r\n\r\n for (const scope of this._scopes.asArray()) {\r\n if (hasContextKey(scope, key)) {\r\n return scope;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Whether any scope pushed during this evaluation *binds* the key - the\r\n * question the read hooks' `scoped` flag asks.\r\n *\r\n * Deliberately about binding rather than about value. It no longer parts\r\n * company with {@link getFromScopes} over it: both go through\r\n * {@link scopeHolding}, and `get` resolves a scope binding whatever its\r\n * value, which is the divergence this docblock used to record as deliberate.\r\n * Reading the flag off the value would make it depend on the *data* - the\r\n * same arrow function over `[{ name: 'a' }]` and over `[undefined]` would\r\n * report different bindings, and a dependency tracker's output would vary\r\n * between two recomputes of one expression. That is the failure this flag\r\n * exists to prevent, so presence is the correct predicate.\r\n *\r\n * Both queries iterate the same stack in the same direction, so neither is a\r\n * second copy of the four-step resolution order; they answer two different\r\n * questions about its first step.\r\n *\r\n * @param key - The key to look for.\r\n * @returns True when a pushed scope holds the key, whatever its value.\r\n */\r\n public hasInScopes(key: unknown): boolean {\r\n\r\n return this.scopeHolding(key) !== undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the `this` value of the specified key from the evaluation context.\r\n * The value is searched in the original context, prior scopes, and lookup functions.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The `this` value associated with the key, or undefined if not found.\r\n */\r\n public getThis(key: unknown): unknown | undefined {\r\n if (this._original) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return this._original;\r\n }\r\n }\r\n for (const scope of this._priorScopes) {\r\n const value = getContextValue(this._original, key);\r\n if (value !== undefined) {\r\n return scope;\r\n }\r\n }\r\n for (const lookup of this._lookups) {\r\n const value = lookup(key, this, this._options);\r\n if (value !== undefined) {\r\n return lookup;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Retrieves the value associated with the specified key from the evaluation context.\r\n *\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value associated with the key, or undefined if the key is not found.\r\n */\r\n public getKey(key: string | number | symbol): string | number | symbol | undefined {\r\n\r\n const caseInsensitive = !!this._options.caseInsensitive;\r\n\r\n for (const scope of this._scopes.asArray()) {\r\n const foundKey = getContextKey(scope, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n if (this._original) {\r\n const foundKey = getContextKey(this._original, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n for (const scope of this._priorScopes) {\r\n const foundKey = getContextKey(scope.context, key, caseInsensitive);\r\n if (foundKey !== undefined) {\r\n return foundKey;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Sets a key-value pair in the context.\r\n * If the original context is a Registry, the key-value pair is set using the Registry's set method.\r\n * If the original context is an Object, the key-value pair is set directly on the object.\r\n * @param key - The key of the pair.\r\n * @param value - The value of the pair.\r\n */\r\n public set(key: unknown, value: unknown): void {\r\n if (this._original && this._original instanceof Registry) {\r\n const registry = this._original as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (this._original && this._original instanceof Object) {\r\n const obj = this._original as Record<string, unknown>;\r\n obj[key as string | number] = value;\r\n }\r\n }\r\n\r\n /**\r\n * Assigns to the innermost pushed scope that **binds** `key`, and reports\r\n * whether one did.\r\n *\r\n * The scope-aware half of the write path: `assignment-expression.ts` and\r\n * `update-expression.ts` try this first and fall back to {@link set}. Before\r\n * Phase 2 they only had {@link set}, which writes `_original` and consults no\r\n * scope at all - so `(x => (x = 99))(1)` wrote `99` into the *caller's*\r\n * object and left the arrow's parameter scope untouched.\r\n *\r\n * **Binding-presence, not scope-presence, and the fallback is load-bearing.**\r\n * `eval-signals` enforces a read-only policy by subclassing this class and\r\n * overriding {@link set} to throw, so every write that reaches the consumer's\r\n * data goes through the one method it overrides. An implementation that wrote\r\n * the innermost scope unconditionally - or created the binding when it was\r\n * absent - would route such a write around that override and silently disable\r\n * the policy of a published library, with every suite still green. Returning\r\n * false when nothing binds the key is what keeps {@link set} reachable.\r\n *\r\n * What it deliberately relaxes: a write to a binding the expression itself\r\n * created - an arrow parameter, or a `let` - no longer reaches {@link set},\r\n * because it mutates nothing the caller owns.\r\n *\r\n * The write dispatches through `setContextValue` rather than through the\r\n * prototype-pollution guard's `safeSetProperty`, and the difference is not\r\n * cosmetic: {@link push} normalises a plain record into a `Registry` when\r\n * `caseInsensitive` is set, and `Object.defineProperty` on a `Registry` would\r\n * define a property on the instance while inserting nothing into its map. No\r\n * guard is lost - this method only ever writes a key some scope already\r\n * *binds*, and a binding can only have been created through the guarded\r\n * declaration path, which rejects every blocklisted name.\r\n *\r\n * @param key - The key to assign to.\r\n * @param value - The value to assign.\r\n * @returns True when a pushed scope bound the key and received the write.\r\n */\r\n public setInScope(key: unknown, value: unknown): boolean {\r\n\r\n const scope = this.scopeHolding(key);\r\n if (!scope) {\r\n return false;\r\n }\r\n\r\n setContextValue(scope, key, value);\r\n return true;\r\n }\r\n\r\n /**\r\n * Pushes a context to the scope stack.\r\n * @param context - The context to push.\r\n * @param options - The evaluation options.\r\n */\r\n public push(context: Context, options?: EvalOptions): void {\r\n const ctx = fromContext(context, options);\r\n this._scopes.push(ctx);\r\n }\r\n\r\n /**\r\n * Pops a context from the scope stack.\r\n */\r\n public pop(): void {\r\n this._scopes.pop();\r\n }\r\n\r\n\r\n /**\r\n * Converts the EvalContext instance to an object representation.\r\n * If the original value is an instance of Registry, it converts it to an object using the toObject method of the registry.\r\n * If the original value is an object, it returns the original object.\r\n * @returns The object representation of the EvalContext instance.\r\n */\r\n public toObject(): Record<string | number | symbol, unknown> | undefined{\r\n\r\n if (this._original && this._original instanceof Registry) {\r\n const registry = this._original as Registry<unknown, unknown>;\r\n const object = registry.toObject();\r\n return object;\r\n } else if (this._original && this._original instanceof Object) {\r\n const obj = this._original as Record<string, unknown>;\r\n return obj;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n}\r\n","import { AnyNode } from \"acorn\";\r\n\r\nexport interface EvalTraceItem {\r\n start?: number;\r\n end?: number;\r\n type: string;\r\n expression?: string;\r\n value: unknown;\r\n}\r\n\r\n/**\r\n * Represents a trace of evaluation for a specific code execution.\r\n */\r\nexport class EvalTrace extends Array<EvalTraceItem> {\r\n\r\n /**\r\n * Adds a new trace item to the evaluation trace.\r\n * @param node - The AST node associated with the trace item.\r\n * @param value - The value of the evaluated expression.\r\n * @param expression - The expression being evaluated.\r\n */\r\n add(node: AnyNode, value?: unknown, expression?: string) {\r\n const item: EvalTraceItem = {\r\n type: node.type,\r\n value\r\n };\r\n if (expression) {\r\n item.expression = expression.substring(node.start, node.end);\r\n }\r\n this.push(item);\r\n }\r\n}\r\n","import { Stack } from \"../common\";\r\nimport { EvalContext } from \"./eval-context\";\r\nimport { EvalOptions } from \"./eval-options\";\r\nimport { EvalTrace } from \"./eval-trace\";\r\n\r\ntype UnknownValue = unknown | Promise<unknown>;\r\n\r\n/**\r\n * Represents the result of an evaluation.\r\n */\r\nexport class EvalResult {\r\n\r\n private _stack: Stack<UnknownValue>;\r\n private _value?: UnknownValue;\r\n private _error?: unknown;\r\n private _errorMessage?: string;\r\n private _isError?: boolean;\r\n private _isSuccess?: boolean;\r\n private _isUndefined?: boolean;\r\n private _trace: EvalTrace;\r\n private _context: EvalContext;\r\n private _startDate?: number;\r\n private _endDate?: number;\r\n private _expression?: string;\r\n\r\n /**\r\n * Gets the stack of evaluated values.\r\n */\r\n public get stack(): Stack<UnknownValue> {\r\n return this._stack;\r\n }\r\n\r\n /**\r\n * Gets the evaluated value.\r\n */\r\n public get value(): UnknownValue | undefined {\r\n return this._value;\r\n }\r\n\r\n /**\r\n * Gets the error that occurred during evaluation.\r\n */\r\n public get error(): unknown | undefined {\r\n return this._error;\r\n }\r\n\r\n /**\r\n * Gets the error message associated with the evaluation error.\r\n */\r\n public get errorMessage(): string | undefined {\r\n return this._errorMessage;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation resulted in an error.\r\n */\r\n public get isError(): boolean | undefined {\r\n return this._isError;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation was successful.\r\n */\r\n public get isSuccess(): boolean | undefined {\r\n return this._isSuccess;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluated value is undefined.\r\n */\r\n public get isUndefined(): boolean | undefined {\r\n return this._isUndefined;\r\n }\r\n\r\n /**\r\n * Gets the trace of evaluated values.\r\n */\r\n public get trace(): EvalTrace {\r\n return this._trace;\r\n }\r\n\r\n /**\r\n * Gets the evaluation context.\r\n */\r\n public get context(): EvalContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions {\r\n return this._context.options;\r\n }\r\n\r\n /**\r\n * Gets the duration of the evaluation result.\r\n * @returns The duration in milliseconds.\r\n */\r\n public get duration(): number | undefined {\r\n if (!this._startDate || !this._endDate) {\r\n return undefined;\r\n }\r\n return this._endDate - this._startDate;\r\n }\r\n\r\n /**\r\n * Gets the expression associated with the evaluation result.\r\n * @returns The expression as a string, or undefined if no expression is associated.\r\n */\r\n public get expression(): string | undefined {\r\n return this._expression;\r\n }\r\n\r\n /**\r\n * Sets the expression for the evaluation result.\r\n *\r\n * @param value - The expression to be set.\r\n */\r\n public set expression(value: string | undefined) {\r\n this._expression = value;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalResult.\r\n * @param trace The trace of evaluated values.\r\n * @param context The evaluation context.\r\n */\r\n constructor(context: EvalContext) {\r\n\r\n this._stack = new Stack<UnknownValue>();\r\n this._trace = new EvalTrace();\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Starts the evaluation process.\r\n */\r\n public start(): void {\r\n this._startDate = performance.now();\r\n }\r\n\r\n /**\r\n * Stops the evaluation and records the end date.\r\n */\r\n public stop(): number | undefined {\r\n this._endDate = performance.now();\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Sets the success value of the evaluation result.\r\n *\r\n * @param value The value to set as the success value.\r\n * @returns void\r\n */\r\n public setSuccess(value: UnknownValue): void {\r\n this._value = value;\r\n this._isSuccess = true;\r\n this._isError = false;\r\n this._isUndefined = false;\r\n }\r\n\r\n /**\r\n * Sets the failure state of the evaluation result.\r\n * @param error The error object associated with the failure.\r\n */\r\n public setFailure(error: unknown): void {\r\n this._error = error;\r\n if (error instanceof Error) {\r\n this._errorMessage = error.message;\r\n }\r\n this._isSuccess = false;\r\n this._isError = true;\r\n this._isUndefined = false;\r\n }\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../../interfaces';\r\nimport { EvalOptions } from './eval-options';\r\nimport type { EvalState } from './eval-state';\r\n\r\n/**\r\n * The two points at which a visitor brackets its body.\r\n */\r\nexport type EvalHookPhase = 'before' | 'after';\r\n\r\n/**\r\n * Payload handed to a node hook.\r\n */\r\nexport interface EvalNodeHookEvent {\r\n readonly phase: EvalHookPhase;\r\n readonly node: AnyNode;\r\n readonly state: EvalState;\r\n /** Value pushed by the visitor; only present on 'after'. */\r\n readonly value?: unknown;\r\n /** False when this 'after' event was synthesised rather than dispatched by a visitor. */\r\n readonly completed: boolean;\r\n /**\r\n * The error that aborted evaluation.\r\n *\r\n * Present only on events synthesised by `unwindTo`, where evaluation really\r\n * did fail. Frames closed by `exit` - because an enclosing visitor moved on\r\n * without them - also carry `completed: false`, but no error: nothing threw,\r\n * and the evaluation may well succeed. Test for the property rather than\r\n * assuming `completed: false` implies one.\r\n */\r\n readonly error?: unknown;\r\n}\r\n\r\n/**\r\n * A node hook. Hooks are observers: they are called for their side effects and\r\n * their return value is discarded. A hook that returns a promise is *not*\r\n * awaited - see {@link ASYNC_HOOK_MESSAGE}.\r\n */\r\nexport type EvalNodeHook = (event: EvalNodeHookEvent) => void;\r\n\r\n/**\r\n * Which resolution produced a read event.\r\n */\r\nexport type EvalReadKind = 'identifier' | 'member';\r\n\r\n/**\r\n * Payload handed to a read hook: one resolved context read.\r\n *\r\n * Node hooks cannot report *which key* an expression read - the AST node alone\r\n * is not enough once case correction and computed members are in play - so this\r\n * is the event a dependency tracker actually needs.\r\n */\r\nexport interface EvalReadEvent {\r\n readonly kind: EvalReadKind;\r\n readonly node: AnyNode;\r\n readonly state: EvalState;\r\n /** The key as resolved against the context (case-corrected when caseInsensitive). */\r\n readonly key: string | number | symbol;\r\n /** The object the key was read from - the context, an EvalScope, or a plain object. */\r\n readonly target: unknown;\r\n /**\r\n * Dotted path when statically reconstructible (`a.b.c`), else undefined.\r\n *\r\n * Reconstructed from the source spelling, so it is *not* case-corrected even\r\n * when {@link key} is. Computed members (`obj[expr]`) yield undefined; their\r\n * `key` is still exact.\r\n */\r\n readonly path?: string;\r\n readonly value: unknown;\r\n /**\r\n * True when the key resolved from a scope pushed *during this evaluation* -\r\n * `EvalContext.scopes`, the stack `arrow-function-expression.ts` pushes and\r\n * pops around a call. Such a read is an arrow-function parameter binding,\r\n * not a dependency, and a tracker should skip it.\r\n *\r\n * The definition is **lifetime, not type**: caller-registered `priorScopes`\r\n * are `EvalScope` instances holding long-lived objects and are real\r\n * dependencies, so they are never flagged. Absent reads as \"not scoped\",\r\n * which is right for every member emission site.\r\n */\r\n readonly scoped?: boolean;\r\n}\r\n\r\n/**\r\n * A read hook. Like a node hook it is an observer: its return value is\r\n * discarded and a returned promise is not awaited.\r\n */\r\nexport type EvalReadHook = (event: EvalReadEvent) => void;\r\n\r\n/**\r\n * Removes the hook that returned it. Calling it more than once is a no-op.\r\n */\r\nexport type Unsubscribe = () => void;\r\n\r\n/**\r\n * What to do with an error raised by a hook.\r\n *\r\n * - `collect` (default) - wrap it, append it to `state.hookErrors`, keep evaluating.\r\n * - `throw` - rethrow it into the visitor, failing the evaluation.\r\n * - `ignore` - swallow it silently.\r\n */\r\nexport type EvalHookErrorPolicy = 'collect' | 'throw' | 'ignore';\r\n\r\n/**\r\n * An error raised by a hook, recorded under the 'collect' policy.\r\n *\r\n * `phase` is `'read'` for an error raised by a read hook: a read is neither of\r\n * the two node phases, and reporting one as 'before' or 'after' would mislead a\r\n * consumer reading the log.\r\n */\r\nexport interface EvalHookError {\r\n readonly phase: EvalHookPhase | 'read';\r\n readonly nodeType: AnyNodeTypes;\r\n readonly error: unknown;\r\n}\r\n\r\n/**\r\n * How long one node type took over an evaluation, accumulated by the timing\r\n * hook and read back as `EvalState.nodeTimings`.\r\n *\r\n * `total` is *inclusive*: a node's children are counted in its own elapsed\r\n * time, so the totals of nested types overlap and summing them exceeds the\r\n * walk's duration. Per-type comparison is what this supports; a breakdown that\r\n * adds up is not.\r\n */\r\nexport interface EvalNodeTiming {\r\n /** How many nodes of this type were visited. */\r\n readonly count: number;\r\n /** Inclusive elapsed milliseconds across all of them. */\r\n readonly total: number;\r\n}\r\n\r\n/**\r\n * The bookkeeping an `EvalHooks` accumulates over a single evaluation.\r\n *\r\n * It is grouped behind one accessor on `EvalState` rather than spread across\r\n * several members, and it lives on the state rather than on the registry: an\r\n * `EvalHooks` is consumer-owned and may be handed to several evaluations, so\r\n * anything whose lifetime is one run belongs to the run.\r\n *\r\n * @internal Not part of the published API; `EvalHooks` is its only writer.\r\n */\r\nexport interface EvalHookBookkeeping {\r\n /** Nodes whose 'before' has fired but whose 'after' has not, outermost first. */\r\n readonly open: AnyNode[];\r\n /** Hook errors recorded under the 'collect' policy. */\r\n readonly errors: EvalHookError[];\r\n /**\r\n * Per-node-type timings, written by the timing hook when one is installed and\r\n * left empty otherwise.\r\n *\r\n * It lives here rather than on the handle `createTimingHook` returns for two\r\n * reasons. A registry may be shared across evaluations, so totals held on the\r\n * handle would bleed one run into the next - the same argument that moved the\r\n * error list here. And `trackTime` installs the hook from inside the\r\n * `EvalState` constructor, where no caller ever sees the handle: totals on it\r\n * would be unreachable, which is a dead option rather than a feature.\r\n */\r\n readonly timings: Map<AnyNodeTypes, EvalNodeTiming>;\r\n /**\r\n * One entry per `evaluate` call currently on the JavaScript stack: the\r\n * {@link open} depth that call found when it started, innermost last.\r\n *\r\n * `evaluate` already captured this as a local to hand to\r\n * {@link EvalHooks.unwindTo}; it lives here as well because {@link\r\n * EvalHooks.exit} needs it too and is called from a visitor, which has no\r\n * route to that local. Without it `exit` cannot tell \"absent from this walk\"\r\n * from \"absent from the stack\" and closes frames belonging to an enclosing\r\n * walk.\r\n *\r\n * Pushed and popped only under `state.hasHooks`, so an evaluation with no\r\n * hooks pays nothing for it. An empty stack therefore reads as base 0 -\r\n * unbounded, which is the right answer for a walk that began before any hook\r\n * existed and so pushed no base.\r\n *\r\n * This is **not** `EvalState.walkDepth`, and the two cannot be merged: that\r\n * counter is unguarded because § 3.4's iteration budget must refill on the\r\n * outermost entry whether or not hooks are registered, while these bases are\r\n * hook bookkeeping and are absent on the default path by design. A later\r\n * phase reading \"two counters\" should read this paragraph first.\r\n */\r\n readonly walkBases: number[];\r\n}\r\n\r\nconst DEFAULT_POLICY: EvalHookErrorPolicy = 'collect';\r\n\r\nconst POLICIES: readonly EvalHookErrorPolicy[] = ['collect', 'throw', 'ignore'];\r\n\r\n/**\r\n * The message carried by the error raised when a hook returns a promise.\r\n *\r\n * Hooks are synchronous by contract (§ 3.3): the walk is synchronous even under\r\n * `evaluateAsync`, so a returned promise is never awaited and whatever the hook\r\n * meant to do lands after the evaluation finished. The dispatcher reports it as\r\n * an error carrying this message, routed through the configured policy like any\r\n * other hook error - collected by default, and thrown into the visitor under\r\n * `'throw'`, which does fail the evaluation.\r\n *\r\n * Exported so a consumer inspecting `EvalState.hookErrors` can tell this\r\n * diagnostic apart from an error its own hook threw, without matching on\r\n * message text it would have to keep in sync by hand.\r\n */\r\nexport const ASYNC_HOOK_MESSAGE =\r\n 'async hook returned a promise; it will not be awaited';\r\n\r\n/**\r\n * The completion value of a statement that produced nothing.\r\n *\r\n * JavaScript's completion-value semantics keep the last **non-empty** value, and\r\n * empty is not the same as `undefined`: `{ 'a'; noop() }` is `undefined` because\r\n * the call genuinely produced one, while `{ 'a'; ; }` is `'a'` because the empty\r\n * statement produced nothing at all. A statement visitor that produced no value\r\n * therefore pushes this rather than `undefined`, and an enclosing block keeps the\r\n * last value that is not this.\r\n *\r\n * It never reaches an evaluation's return value: `evaluate` and `evaluateAsync`\r\n * convert it to `undefined` at the walk boundary, immediately after popping the\r\n * result. It **is** reachable in a hook event, because `afterVisitor` reads the\r\n * value positionally off the top of the result stack - so an 'after' hook on a\r\n * statement that produced nothing observes this sentinel. Hiding it there is not\r\n * available: the alternatives are calling `afterVisitor` before the push, which\r\n * reports the neighbour's value, or normalising inside `afterVisitor`, which puts\r\n * a per-node cost on the hot path for a case only statements produce.\r\n *\r\n * Exported for that reason, on the precedent of {@link ASYNC_HOOK_MESSAGE}: a\r\n * consumer whose hook receives it can recognise it by identity rather than by\r\n * guessing at a value it would have to keep in sync by hand.\r\n */\r\nexport const EMPTY_COMPLETION: unique symbol = Symbol('eval-core:empty-completion');\r\n\r\n/**\r\n * Reads the error policy out of the evaluation options. `EvalOptions` is a union\r\n * and does not index directly, so the read goes through a cast - the same one\r\n * `before-visitor.ts` performs.\r\n */\r\nconst readPolicy = (options?: EvalOptions): EvalHookErrorPolicy => {\r\n const value = (options as Record<string, unknown>)?.['onHookError'];\r\n return POLICIES.includes(value as EvalHookErrorPolicy)\r\n ? (value as EvalHookErrorPolicy)\r\n : DEFAULT_POLICY;\r\n};\r\n\r\nconst isPromiseLike = (value: unknown): boolean =>\r\n !!value &&\r\n (typeof value === 'object' || typeof value === 'function') &&\r\n typeof (value as PromiseLike<unknown>).then === 'function';\r\n\r\n/**\r\n * A registry of node hooks, keyed by node type with wildcard support, and the\r\n * dispatcher that keeps `before` and `after` balanced when a visitor throws.\r\n *\r\n * It holds *registration* only. Everything whose lifetime is a single\r\n * evaluation - the open-node stack and the collected errors - lives on the\r\n * `EvalState` instead, because a consumer may hand one `EvalHooks` to several\r\n * evaluations and expect each to observe both.\r\n *\r\n * Hooks are synchronous by design: the walk in `evaluate` is synchronous even\r\n * under `evaluateAsync`, so there is no point at which a hook could be awaited.\r\n */\r\nexport class EvalHooks {\r\n private readonly _before = new Map<string, EvalNodeHook[]>();\r\n private readonly _after = new Map<string, EvalNodeHook[]>();\r\n private _read: EvalReadHook[] = [];\r\n private readonly _policy: EvalHookErrorPolicy;\r\n private _size = 0;\r\n private _active = false;\r\n\r\n /**\r\n * @param options The evaluation options; `onHookError` selects the error policy.\r\n */\r\n constructor(options?: EvalOptions) {\r\n this._policy = readPolicy(options);\r\n }\r\n\r\n /**\r\n * True while no hook is registered. Read on the hot path, so it is a counter\r\n * rather than a walk of the registries.\r\n */\r\n public get isEmpty(): boolean {\r\n return this._size === 0;\r\n }\r\n\r\n /**\r\n * The dispatch guard, behind `EvalState.hasHooks`.\r\n *\r\n * Unlike {@link isEmpty} this *latches*: it turns true on the first\r\n * registration and only `clear` turns it off again. The guard wraps the\r\n * open-node stack as well as the hooks themselves, so a value that changed\r\n * mid-walk would leave `enter` and `exit` unpaired - which is exactly what\r\n * one-shot and self-unsubscribing hooks would otherwise cause.\r\n *\r\n * Calling `clear` during a walk is therefore unsupported.\r\n */\r\n public get isActive(): boolean {\r\n return this._active;\r\n }\r\n\r\n /**\r\n * True while at least one read hook is registered.\r\n *\r\n * The second half of the read-emission guard: `st.hasHooks` says a registry\r\n * exists and has been used, this says a *read* hook is there to observe the\r\n * event. Without it a consumer that registered only 'before'/'after' hooks\r\n * would pay `getKey` per identifier and `readPath` plus an object literal per\r\n * member for events it can never see - which the timing hook turns from\r\n * theoretical into routine, since it latches `hasHooks` for a whole walk.\r\n *\r\n * **Non-latching, unlike {@link isActive}.** That getter latches because it\r\n * wraps the open-node stack, so a value changing mid-walk would leave `enter`\r\n * and `exit` unpaired. `dispatchRead` touches no bookkeeping, so a read guard\r\n * that flips mid-walk can only drop read events - never unbalance anything.\r\n * A one-shot or self-unsubscribing read hook is therefore safe here, and the\r\n * guard can report the current registration count rather than history.\r\n */\r\n public get hasReadHooks(): boolean {\r\n return this._read.length > 0;\r\n }\r\n\r\n /**\r\n * Registers a node hook.\r\n * @param phase Whether to fire before or after the visitor body.\r\n * @param type A concrete node type, or '*' for every node.\r\n * @param hook The hook to register.\r\n * @returns A function that removes this hook.\r\n */\r\n public on(phase: EvalHookPhase, type: AnyNodeTypes | '*', hook: EvalNodeHook): Unsubscribe {\r\n const registry = this.registry(phase);\r\n const hooks = registry.get(type);\r\n\r\n if (hooks) {\r\n hooks.push(hook);\r\n } else {\r\n registry.set(type, [hook]);\r\n }\r\n this._size++;\r\n this._active = true;\r\n\r\n let unsubscribed = false;\r\n return () => {\r\n if (unsubscribed) {\r\n return;\r\n }\r\n unsubscribed = true;\r\n this.off(phase, type, hook);\r\n };\r\n }\r\n\r\n /**\r\n * Registers a read hook, fired once per resolved context read.\r\n *\r\n * Read hooks are not keyed by node type: there are only two emission points\r\n * and a consumer filters on {@link EvalReadEvent.kind} if it cares.\r\n *\r\n * Registration latches {@link isActive} exactly as {@link on} does, because\r\n * the visitors reach their emission points through the same\r\n * `EvalState.hasHooks` guard.\r\n *\r\n * @param hook The hook to register.\r\n * @returns A function that removes this hook.\r\n */\r\n public onRead(hook: EvalReadHook): Unsubscribe {\r\n this._read.push(hook);\r\n this._size++;\r\n this._active = true;\r\n\r\n let unsubscribed = false;\r\n return () => {\r\n if (unsubscribed) {\r\n return;\r\n }\r\n unsubscribed = true;\r\n this.offRead(hook);\r\n };\r\n }\r\n\r\n /**\r\n * Removes one read hook, or every read hook when `hook` is omitted.\r\n */\r\n public offRead(hook?: EvalReadHook): void {\r\n if (hook === undefined) {\r\n this._size -= this._read.length;\r\n this._read = [];\r\n return;\r\n }\r\n\r\n const index = this._read.indexOf(hook);\r\n if (index < 0) {\r\n return;\r\n }\r\n\r\n this._read.splice(index, 1);\r\n this._size--;\r\n }\r\n\r\n /**\r\n * Removes one hook, or every hook registered for a key when `hook` is omitted.\r\n */\r\n public off(phase: EvalHookPhase, type: AnyNodeTypes | '*', hook?: EvalNodeHook): void {\r\n const registry = this.registry(phase);\r\n const hooks = registry.get(type);\r\n\r\n if (!hooks) {\r\n return;\r\n }\r\n\r\n if (hook === undefined) {\r\n registry.delete(type);\r\n this._size -= hooks.length;\r\n return;\r\n }\r\n\r\n const index = hooks.indexOf(hook);\r\n if (index < 0) {\r\n return;\r\n }\r\n\r\n hooks.splice(index, 1);\r\n this._size--;\r\n if (hooks.length === 0) {\r\n registry.delete(type);\r\n }\r\n }\r\n\r\n /**\r\n * Removes every hook from both phases and unlatches {@link isActive}.\r\n *\r\n * Per-run bookkeeping is untouched: the open-node stack and the collected\r\n * errors belong to the `EvalState`, not to this registry. Errors in\r\n * particular are a record of what already happened.\r\n */\r\n public clear(): void {\r\n this._before.clear();\r\n this._after.clear();\r\n this._read = [];\r\n this._size = 0;\r\n this._active = false;\r\n }\r\n\r\n /**\r\n * Fires the hooks registered for a node, keyed first and wildcard second.\r\n *\r\n * Bookkeeping runs before user code on both edges: 'before' pushes the node\r\n * onto the open-node stack and *then* emits, 'after' pops and *then* emits.\r\n * The shared rule is that hook code only ever runs once the stack already\r\n * tells the truth about this node, because `emit` can throw - under the\r\n * 'throw' policy a hook's error propagates out of it. Emitting first on the\r\n * 'before' edge would leave a node that some hooks had already been told\r\n * about missing from the stack, and therefore invisible to `unwindTo`.\r\n *\r\n * @param value The value the visitor pushed; meaningful on 'after' only.\r\n */\r\n public dispatch(phase: EvalHookPhase, node: AnyNode, state: EvalState, value?: unknown): void {\r\n if (phase === 'after') {\r\n this.exit(state, node);\r\n this.emit({ phase, node, state, value, completed: true }, false);\r\n return;\r\n }\r\n\r\n this.enter(node, state);\r\n this.emit({ phase, node, state, completed: true }, false);\r\n }\r\n\r\n /**\r\n * Fires the read hooks for one resolved context read.\r\n *\r\n * The event is built by the caller rather than assembled from positional\r\n * arguments here, so the visitors allocate nothing on the no-hooks path: the\r\n * whole construction sits inside their `st.hasHooks` guard.\r\n *\r\n * Touches no bookkeeping. A read is not a frame - it happens *within* a\r\n * node's before/after pair, so the open-node stack is none of its business.\r\n */\r\n public dispatchRead(event: EvalReadEvent): void {\r\n if (this._read.length === 0) {\r\n return;\r\n }\r\n // Iterated as a copy so a hook that unsubscribes itself does not shift the\r\n // list out from under the loop.\r\n for (const hook of this._read.slice()) {\r\n this.invokeRead(hook, event);\r\n }\r\n }\r\n\r\n /**\r\n * Records a node as open on the state. Called by the 'before' dispatcher\r\n * before its hooks fire.\r\n */\r\n public enter(node: AnyNode, state: EvalState): void {\r\n state.hookBookkeeping.open.push(node);\r\n }\r\n\r\n /**\r\n * Closes `node`, matching it by **identity** rather than by position. Called\r\n * by the 'after' dispatcher before its hooks fire.\r\n *\r\n * Three cases:\r\n *\r\n * 1. `node` is on top - pop it. The ordinary path, one reference comparison.\r\n * 2. `node` is open but not on top - some visitor between here and there\r\n * never closed itself. Flush those frames innermost-first as\r\n * `completed: false`, then pop `node`.\r\n * 3. `node` is not open at all - pop nothing and emit nothing.\r\n *\r\n * Case 3 is what keeps a stray `exit` from draining the stack: the naive\r\n * \"pop until you find it\" would walk to the bottom, synthesise an event for\r\n * every genuinely-open enclosing frame, and leave a later real failure with\r\n * nothing to unwind.\r\n *\r\n * **\"Open\" means open in *this* walk.** Both routes below are bounded by the\r\n * current walk base ({@link EvalHookBookkeeping.walkBases}), so a node open\r\n * only in an enclosing walk falls into case 3 by either route - which is the\r\n * behaviour case 3 already specifies for \"not open at all\". `evaluate` is\r\n * re-entered with the same state from an arrow-function body, so without the\r\n * bound a nested walk closing a node it never opened would flush the\r\n * enclosing walk's frames under `completed: false` events a consumer reads as\r\n * ordinary completions, and leave that walk's own `unwindTo(mark)` with\r\n * nothing left to unwind.\r\n *\r\n * The bound is needed on the **identity fast path** as much as on the scan:\r\n * when a nested walk has opened nothing yet, the top of the stack *is* the\r\n * enclosing walk's node, so the cheap route crosses the boundary without ever\r\n * reaching the scan.\r\n *\r\n * Popping positionally instead would be correct only if every visitor\r\n * bracketed its body exactly. `await-expression.ts` does not - it catches a\r\n * child's synchronous throw and continues to its own `afterVisitor` - so a\r\n * positional pop closes the child's frame under the parent's name, drops the\r\n * child's `after` entirely, and leaks one frame onto the state for good.\r\n *\r\n * The synthesised events carry no `value` (the node never pushed one) and no\r\n * `error` (nothing threw; the frames are being closed because an enclosing\r\n * visitor moved on without them).\r\n *\r\n * They are emitted under the collect policy even when the consumer chose\r\n * 'throw'. That is required, not merely lenient: a rethrow here would escape\r\n * the flush loop before it finished popping, re-creating the leak this\r\n * identity check exists to prevent. A 'throw'-policy consumer sees these in\r\n * `state.hookErrors` instead.\r\n */\r\n public exit(state: EvalState, node: AnyNode): void {\r\n const open = state.hookBookkeeping.open;\r\n const base = this.walkBase(state);\r\n\r\n if (open.length > base && open[open.length - 1] === node) {\r\n open.pop();\r\n return;\r\n }\r\n\r\n // The innermost occurrence is the one being closed: a node can legitimately\r\n // be open twice, since an arrow-function body is re-walked on every call.\r\n // `lastIndexOf` returns -1 when the node is absent, which the same\r\n // comparison rejects - \"below this walk's base\" and \"not open at all\" are\r\n // the same case here.\r\n const index = open.lastIndexOf(node);\r\n if (index < base) {\r\n return;\r\n }\r\n\r\n while (open.length > index + 1) {\r\n const stranded = open.pop();\r\n if (!stranded) {\r\n break;\r\n }\r\n this.emit({ phase: 'after', node: stranded, state, completed: false }, true);\r\n }\r\n\r\n open.pop();\r\n }\r\n\r\n /**\r\n * How many nodes the state has open. Captured as a mark before a walk, since\r\n * `evaluate` is re-entered with the same state from an arrow-function body.\r\n *\r\n * This is a method rather than a getter because the stack it measures lives\r\n * on the state, not on this registry.\r\n */\r\n public depth(state: EvalState): number {\r\n return state.hookBookkeeping.open.length;\r\n }\r\n\r\n /**\r\n * Records that a walk is starting at the state's current open depth, and\r\n * returns that depth. Called by `evaluate` / `evaluateAsync` on entry, under\r\n * their `hasHooks` guard, and paired with {@link popWalkBase} in a `finally`.\r\n *\r\n * The returned value is the same mark those entry points hand to\r\n * {@link unwindTo}, so they capture it once rather than reading the depth\r\n * twice.\r\n */\r\n public pushWalkBase(state: EvalState): number {\r\n const bookkeeping = state.hookBookkeeping;\r\n const base = bookkeeping.open.length;\r\n bookkeeping.walkBases.push(base);\r\n return base;\r\n }\r\n\r\n /**\r\n * Drops the innermost walk base. Called from the `finally` of the `evaluate`\r\n * that pushed it, so an entry point whose walk threw still restores the\r\n * enclosing walk's bound.\r\n */\r\n public popWalkBase(state: EvalState): void {\r\n state.hookBookkeeping.walkBases.pop();\r\n }\r\n\r\n /**\r\n * The open depth the innermost walk in progress started at, and the floor\r\n * {@link exit} will not reach below.\r\n *\r\n * Zero when no base has been pushed, which leaves `exit` behaving exactly as\r\n * it did before the bound existed - the correct answer for a walk that began\r\n * before any hook was registered, since it pushed no base.\r\n */\r\n public walkBase(state: EvalState): number {\r\n const bases = state.hookBookkeeping.walkBases;\r\n return bases.length > 0 ? bases[bases.length - 1] : 0;\r\n }\r\n\r\n /**\r\n * Fires 'after' for every node the state has open above `mark`, innermost\r\n * first, marked incomplete. Invoked from the catch in `evaluate`, so that a\r\n * visitor which throws still leaves every 'before' matched by exactly one\r\n * 'after'.\r\n *\r\n * Unwinding to a mark rather than to the bottom is what keeps a nested\r\n * `evaluate` from draining the enclosing walk's open nodes when a host\r\n * function swallows the nested throw.\r\n *\r\n * Idempotent, so the sync and async entry points can both call it.\r\n *\r\n * A hook that throws here cannot stop the drain: while unwinding, the 'throw'\r\n * policy is downgraded to 'collect' - evaluation has already failed, and the\r\n * original error is the one worth propagating.\r\n */\r\n public unwindTo(mark: number, error: unknown, state: EvalState): void {\r\n const open = state.hookBookkeeping.open;\r\n\r\n while (open.length > mark) {\r\n const node = open.pop();\r\n if (!node) {\r\n break;\r\n }\r\n this.emit({ phase: 'after', node, state, completed: false, error }, true);\r\n }\r\n }\r\n\r\n /**\r\n * Drains the state's whole open-node stack. Equivalent to `unwindTo(0, ...)`,\r\n * for callers that own the entire walk.\r\n */\r\n public unwind(error: unknown, state: EvalState): void {\r\n this.unwindTo(0, error, state);\r\n }\r\n\r\n private registry(phase: EvalHookPhase): Map<string, EvalNodeHook[]> {\r\n return phase === 'before' ? this._before : this._after;\r\n }\r\n\r\n private emit(event: EvalNodeHookEvent, unwinding: boolean): void {\r\n const registry = this.registry(event.phase);\r\n if (registry.size === 0) {\r\n return;\r\n }\r\n this.invokeAll(registry.get(event.node.type), event, unwinding);\r\n this.invokeAll(registry.get('*'), event, unwinding);\r\n }\r\n\r\n /**\r\n * Iterates a copy so that a hook which unsubscribes itself does not shift the\r\n * list out from under the loop.\r\n */\r\n private invokeAll(hooks: EvalNodeHook[] | undefined, event: EvalNodeHookEvent, unwinding: boolean): void {\r\n if (!hooks || hooks.length === 0) {\r\n return;\r\n }\r\n for (const hook of hooks.slice()) {\r\n this.invoke(hook, event, unwinding);\r\n }\r\n }\r\n\r\n private invoke(hook: EvalNodeHook, event: EvalNodeHookEvent, unwinding: boolean): void {\r\n let result: unknown;\r\n\r\n try {\r\n result = hook(event);\r\n } catch (error) {\r\n this.handleError(event.state, event.phase, event.node.type, error, unwinding);\r\n return;\r\n }\r\n\r\n if (isPromiseLike(result)) {\r\n this.handleError(event.state, event.phase, event.node.type,\r\n new Error(ASYNC_HOOK_MESSAGE), unwinding);\r\n }\r\n }\r\n\r\n /**\r\n * The read counterpart of {@link invoke}. There is no unwinding equivalent\r\n * for reads - a read never opens a frame - so the policy always applies in\r\n * full.\r\n */\r\n private invokeRead(hook: EvalReadHook, event: EvalReadEvent): void {\r\n let result: unknown;\r\n\r\n try {\r\n result = hook(event);\r\n } catch (error) {\r\n this.handleError(event.state, 'read', event.node.type, error, false);\r\n return;\r\n }\r\n\r\n if (isPromiseLike(result)) {\r\n this.handleError(event.state, 'read', event.node.type,\r\n new Error(ASYNC_HOOK_MESSAGE), false);\r\n }\r\n }\r\n\r\n private handleError(state: EvalState,\r\n phase: EvalHookPhase | 'read',\r\n nodeType: AnyNodeTypes,\r\n error: unknown,\r\n unwinding: boolean): void {\r\n\r\n if (this._policy === 'ignore') {\r\n return;\r\n }\r\n if (this._policy === 'throw' && !unwinding) {\r\n throw error;\r\n }\r\n state.hookBookkeeping.errors.push({ phase, nodeType, error });\r\n }\r\n}\r\n","import type { AnyNodeTypes } from '../../../interfaces';\r\nimport type { EvalHooks, EvalNodeHookEvent, Unsubscribe } from '../eval-hooks';\r\nimport type { EvalState } from '../eval-state';\r\n\r\n/**\r\n * A timing hook, ready to install on a registry.\r\n *\r\n * It carries no totals of its own: they are written to the `EvalState` being\r\n * evaluated and read back as `EvalState.nodeTimings`. That is what lets the\r\n * `trackTime` option install one from inside the `EvalState` constructor, where\r\n * the caller never sees this handle - and it is what keeps two evaluations\r\n * through a shared registry from accumulating into each other.\r\n */\r\nexport interface EvalTimingHook {\r\n /**\r\n * Registers the 'before'/'after' pair on `hooks`.\r\n *\r\n * @param hooks The registry to register on.\r\n * @returns A function that removes both halves of the pair.\r\n */\r\n install(hooks: EvalHooks): Unsubscribe;\r\n}\r\n\r\n/**\r\n * Creates a timing hook that accumulates inclusive per-node-type totals.\r\n *\r\n * Replaces the `console.time` / `console.timeEnd` pair the old `trackTime`\r\n * emitted, which mismatched its labels and produced no readable figure. The\r\n * readings are `performance.now()`, and nothing is written to the console.\r\n *\r\n * ```ts\r\n * const state = evalService.createState(context);\r\n * const off = createTimingHook().install(state.hooks);\r\n * evalService.eval('a + b * c', state);\r\n * state.nodeTimings.get('BinaryExpression'); // { count: 2, total: 0.081 }\r\n * off();\r\n * ```\r\n *\r\n * Equivalent to passing `{ trackTime: true }`, which installs one of these on\r\n * the state's own registry.\r\n *\r\n * @returns A handle whose `install` registers the pair on a registry.\r\n */\r\nexport const createTimingHook = (): EvalTimingHook => {\r\n\r\n /**\r\n * Start times for the nodes this handle currently has open, per state.\r\n *\r\n * Keyed by state because one handle may be installed on a registry that\r\n * several evaluations dispatch through, and a shared stack would interleave\r\n * them. Weak, so a finished evaluation's state is collectable while the\r\n * consumer holds the handle. Per *handle* rather than module-level, so two\r\n * handles installed on one state cannot pop each other's readings.\r\n *\r\n * A stack works because `EvalHooks` guarantees exactly one 'after' *frame*\r\n * per 'before' frame, innermost first, on every exit path - including the\r\n * synthesised events `exit` flushes for stranded frames and the ones\r\n * `unwindTo` emits when a visitor throws. It has to be a stack rather than a\r\n * map keyed by node: an arrow-function body is re-walked on every call, so\r\n * the same node can be open more than once.\r\n *\r\n * The guarantee is about frames, not about hook *invocations*. Under the\r\n * 'throw' policy an earlier hook can abort `dispatch`'s emit loop after\r\n * `enter` has already run, so this push is skipped while the frame stays\r\n * open; the `unwindTo` that follows then pops an enclosing node's reading and\r\n * attributes it to the wrong type. Pops never outnumber pushes, so nothing\r\n * strands into a later run on the same state - and the evaluation has failed\r\n * regardless, which is why the totals are left as they fall.\r\n */\r\n const starts = new WeakMap<EvalState, number[]>();\r\n\r\n const stackFor = (state: EvalState): number[] => {\r\n const existing = starts.get(state);\r\n if (existing) {\r\n return existing;\r\n }\r\n const created: number[] = [];\r\n starts.set(state, created);\r\n return created;\r\n };\r\n\r\n const before = (event: EvalNodeHookEvent): void => {\r\n stackFor(event.state).push(performance.now());\r\n };\r\n\r\n const after = (event: EvalNodeHookEvent): void => {\r\n const started = starts.get(event.state)?.pop();\r\n if (started === undefined) {\r\n // No matching 'before'. Reachable when this handle was installed midway\r\n // through a walk, or when a throwing hook skipped the push above;\r\n // recording a total from an unknown start would be worse than skipping.\r\n return;\r\n }\r\n\r\n record(event.state, event.node.type as AnyNodeTypes, performance.now() - started);\r\n };\r\n\r\n return {\r\n install(hooks: EvalHooks): Unsubscribe {\r\n const offBefore = hooks.on('before', '*', before);\r\n const offAfter = hooks.on('after', '*', after);\r\n\r\n return () => {\r\n offBefore();\r\n offAfter();\r\n };\r\n }\r\n };\r\n};\r\n\r\nconst record = (state: EvalState, type: AnyNodeTypes, elapsed: number): void => {\r\n const timings = state.hookBookkeeping.timings;\r\n const current = timings.get(type);\r\n\r\n timings.set(type, current\r\n ? { count: current.count + 1, total: current.total + elapsed }\r\n : { count: 1, total: elapsed });\r\n};\r\n","import { EvalContext } from './eval-context';\r\nimport { EvalOptions } from './eval-options';\r\nimport { EvalResult } from './eval-result';\r\nimport { EvalHooks } from './eval-hooks';\r\nimport type { AnyNodeTypes } from '../../interfaces';\r\nimport type { EvalHookBookkeeping, EvalHookError, EvalNodeTiming } from './eval-hooks';\r\nimport { createTimingHook } from './hooks/timing-hook';\r\nimport { Context } from '../common';\r\n\r\n/**\r\n * Reads a caller-supplied hook registry out of the evaluation options.\r\n *\r\n * `EvalOptions` is a union and does not index directly, so the read goes\r\n * through a cast - the same one `before-visitor.ts` performs. The registry is\r\n * adopted as-is and never cloned: the caller holds the unsubscribe closures\r\n * `on` returned, and a copy would leave those closures editing a registry that\r\n * is no longer the one being dispatched.\r\n */\r\nconst adoptHooks = (options?: EvalOptions): EvalHooks | undefined => {\r\n const value = (options as Record<string, unknown>)?.['hooks'];\r\n return value instanceof EvalHooks ? value : undefined;\r\n};\r\n\r\n/**\r\n * Whether the caller asked for per-node timings. Same cast, same reason.\r\n */\r\nconst readTrackTime = (options?: EvalOptions): boolean =>\r\n !!(options as Record<string, unknown>)?.['trackTime'];\r\n\r\n/**\r\n * The iteration budget one evaluation gets when the caller names no other.\r\n *\r\n * Sized in the Phase 2 plan's § 3.4 rather than picked: a loop iteration is\r\n * roughly three walks at the measured ~1.4 M simple walks per second, so\r\n * ~2 microseconds, and 100,000 of them is ~0.2 s before the throw. Short enough\r\n * that a Jest spec fails fast rather than timing out at five seconds, and short\r\n * enough that a browser tab stutters rather than freezes - and far above any\r\n * expression a rule author writes by hand.\r\n */\r\nconst DEFAULT_MAX_ITERATIONS = 100000;\r\n\r\n/**\r\n * The iteration budget the options ask for, or the default.\r\n *\r\n * Same cast as the two readers above, same reason. A non-numeric or negative\r\n * value falls back rather than throwing: options are a permissive record that\r\n * nothing validates, and the budget exists to bound a runaway loop, so a\r\n * malformed one must not become a *smaller* bound than the default by accident.\r\n * `0` is honoured - a caller forbidding loops entirely is a coherent thing to\r\n * ask for - and `Infinity` opts out, which is why the test is not\r\n * `Number.isFinite`.\r\n */\r\nconst readMaxIterations = (options?: EvalOptions): number => {\r\n const value = (options as Record<string, unknown>)?.['maxIterations'];\r\n return typeof value === 'number' && !Number.isNaN(value) && value >= 0\r\n ? value\r\n : DEFAULT_MAX_ITERATIONS;\r\n};\r\n\r\n/**\r\n * Represents the evaluation state, which includes the context, result, and options.\r\n */\r\nexport class EvalState {\r\n private _context: EvalContext | undefined;\r\n private _result: EvalResult;\r\n private _options: EvalOptions | undefined;\r\n private _isAsync: boolean | undefined;\r\n private _hooks: EvalHooks | undefined;\r\n private _hookBookkeeping: EvalHookBookkeeping | undefined;\r\n private _walkDepth = 0;\r\n private _iterationBudget = DEFAULT_MAX_ITERATIONS;\r\n private _iterationsRemaining = DEFAULT_MAX_ITERATIONS;\r\n private _constBindings: WeakMap<Context, Set<unknown>> | undefined;\r\n\r\n /**\r\n * Gets the evaluation context.\r\n */\r\n public get context(): EvalContext | undefined {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the evaluation result.\r\n */\r\n public get result(): EvalResult {\r\n return this._result;\r\n }\r\n\r\n /**\r\n * Gets the evaluation options.\r\n */\r\n public get options(): EvalOptions | undefined {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Gets whether the evaluation is asynchronous.\r\n */\r\n public get isAsync(): boolean | undefined {\r\n return this._isAsync;\r\n }\r\n\r\n /**\r\n * Gets the hook registry for this evaluation, creating an empty one on first\r\n * access. A registry supplied through `options.hooks` is adopted instead.\r\n *\r\n * Merely reading this does not turn {@link hasHooks} on; registering does.\r\n */\r\n public get hooks(): EvalHooks {\r\n return (this._hooks ??= new EvalHooks(this._options));\r\n }\r\n\r\n /**\r\n * The dispatch guard read by `beforeVisitor` / `afterVisitor`. One field read\r\n * and no options lookup, so the no-hooks path stays cheap.\r\n */\r\n public get hasHooks(): boolean {\r\n return !!this._hooks && this._hooks.isActive;\r\n }\r\n\r\n /**\r\n * Errors raised by hooks during this evaluation and collected under the\r\n * 'collect' policy.\r\n *\r\n * They live here rather than on {@link hooks} because an `EvalHooks` may be\r\n * shared across evaluations, and an error describes one run.\r\n *\r\n * The array is the live one, so a reference taken before evaluating fills as\r\n * errors arrive. Returning a shared empty array until the first collection\r\n * would be cheaper by one allocation and wrong: the reference would silently\r\n * stop tracking the moment anything was collected.\r\n */\r\n public get hookErrors(): readonly EvalHookError[] {\r\n return this.hookBookkeeping.errors;\r\n }\r\n\r\n /**\r\n * Per-node-type timings for **this state**, keyed by node type. Empty unless\r\n * a timing hook was installed - by `options.trackTime`, or by the caller\r\n * through `createTimingHook().install(state.hooks)`.\r\n *\r\n * Accumulates for the life of the state, not per `evaluate` call: under the\r\n * `createState` + repeated `eval` style the counts are the running totals\r\n * across every run on this state, which is what makes them comparable. A\r\n * caller who wants per-run figures uses a fresh state, or drops these along\r\n * with the rest of the run record via {@link resetHookBookkeeping}.\r\n *\r\n * Here rather than on the handle `createTimingHook` returns for the same\r\n * reason {@link hookErrors} is: timings describe one run, and an `EvalHooks`\r\n * may be handed to several. It is also the only place a `trackTime` caller\r\n * could reach them, since that installation happens in this constructor and\r\n * hands the handle to nobody.\r\n *\r\n * Totals are inclusive of child nodes; see `EvalNodeTiming`.\r\n */\r\n public get nodeTimings(): ReadonlyMap<AnyNodeTypes, EvalNodeTiming> {\r\n return this.hookBookkeeping.timings;\r\n }\r\n\r\n /**\r\n * The per-run bookkeeping `EvalHooks` reads and writes: the open-node stack\r\n * and the collected errors, grouped behind a single accessor.\r\n *\r\n * The state owns this storage and `eval-hooks.ts` only type-imports the\r\n * state, which keeps the runtime import graph acyclic. Holding it in a\r\n * module-private `WeakMap` inside `eval-hooks.ts` was the alternative and was\r\n * rejected: `hookErrors` would then need a *runtime* import of that module\r\n * while it already imports this one, and the resulting cycle is a hazard in\r\n * the ng-packagr build.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public get hookBookkeeping(): EvalHookBookkeeping {\r\n return (this._hookBookkeeping ??=\r\n { open: [], errors: [], timings: new Map(), walkBases: [] });\r\n }\r\n\r\n /**\r\n * How many `evaluate` / `evaluateAsync` calls on this state are currently on\r\n * the JavaScript stack: 0 between evaluations, 1 during an ordinary walk, and\r\n * more while a nested walk runs - an arrow-function body is re-entrant\r\n * `evaluate` on this same state.\r\n *\r\n * Maintained by {@link enterWalk} / {@link exitWalk}, which the entry points\r\n * pair around their walk, the exit in a `finally` so a throw still restores\r\n * the count.\r\n *\r\n * **Deliberately not merged with `EvalHookBookkeeping.walkBases`**, which\r\n * tracks the same nesting one level down. That stack is pushed only under\r\n * {@link hasHooks}, because bounding `EvalHooks.exit` is meaningless with no\r\n * hooks to dispatch; this counter must be maintained unconditionally, because\r\n * § 3.4's iteration budget refills on the outermost entry and a loop is\r\n * bounded whether or not anyone is listening. One field cannot be both\r\n * guarded and unguarded, so there are two.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public get walkDepth(): number {\r\n return this._walkDepth;\r\n }\r\n\r\n /**\r\n * Records that a walk is starting on this state and returns the new depth, so\r\n * a caller can recognise the outermost entry as `=== 1` without a second\r\n * read.\r\n *\r\n * **Refills {@link iterationsRemaining} on the outermost entry**, which is\r\n * what makes § 3.4's budget per-`evaluate` rather than per-state. It happens\r\n * here rather than at the entry points so that both of them - and any later\r\n * one - get it without a second copy of the 0 -> 1 test; the depth this\r\n * method already owns is the only thing the decision needs.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public enterWalk(): number {\r\n\r\n const depth = ++this._walkDepth;\r\n\r\n // § 3.4's refill, and the 0 -> 1 test is the whole of it. A nested walk -\r\n // an arrow-function body, which re-enters `evaluate` on this same state -\r\n // shares whatever the enclosing walk has left, so an escaped closure cannot\r\n // buy itself a fresh budget by being called again. The options are re-read\r\n // per outermost walk rather than in the constructor because they are a\r\n // mutable record the caller keeps a reference to.\r\n if (depth === 1) {\r\n this._iterationBudget = readMaxIterations(this._options);\r\n this._iterationsRemaining = this._iterationBudget;\r\n }\r\n\r\n return depth;\r\n }\r\n\r\n /**\r\n * Records that a walk has finished. Called from the entry point's `finally`.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public exitWalk(): void {\r\n this._walkDepth--;\r\n }\r\n\r\n /**\r\n * How many loop iterations this evaluation may still run.\r\n *\r\n * Refilled by {@link enterWalk} on the outermost entry from\r\n * `options.maxIterations`, defaulting to 100,000, and spent one at a time by\r\n * {@link chargeIteration}. `Infinity` when the caller opted out.\r\n *\r\n * Readable mainly so a spec can assert what a walk charged: nothing in the\r\n * library reads it except {@link chargeIteration}, and no expression without a\r\n * `for` in it moves it.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public get iterationsRemaining(): number {\r\n return this._iterationsRemaining;\r\n }\r\n\r\n /**\r\n * Charges one loop iteration against the budget, throwing when it is spent.\r\n *\r\n * Called from `for-statement.ts`'s iteration loop and **nowhere else**, which\r\n * is § 3.4's cost argument in its literal form: the no-loop path does not\r\n * execute a cheaper version of this check, it does not reach the call site at\r\n * all. The rejected alternative - a per-node fuel counter in `beforeVisitor` -\r\n * would have been on the hot path of every evaluation in the library, to bound\r\n * a recursion depth this phase does not introduce.\r\n *\r\n * The message names the **configured** budget rather than the default, since a\r\n * caller who set `maxIterations` needs to recognise their own number in it.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public chargeIteration(): void {\r\n\r\n if (this._iterationsRemaining <= 0) {\r\n throw new Error(\r\n `Iteration budget exhausted after ${this._iterationBudget} iterations`);\r\n }\r\n\r\n this._iterationsRemaining--;\r\n }\r\n\r\n /**\r\n * Records that `key` was declared `const` in `scope`, so a later write to it\r\n * can be rejected.\r\n *\r\n * **Keyed by the scope *object*, and beside the scope rather than in it.** A\r\n * metadata key written onto the scope record would itself be resolvable as a\r\n * binding name - `getContextValue` reads the same surface a declaration binds\r\n * into - so `let __kind` would be readable from an expression. A `WeakMap`\r\n * hanging off the state has neither problem, and it is checked at the write\r\n * site only, so reads pay nothing.\r\n *\r\n * **The scope passed here must be the one on the stack**, not the record a\r\n * visitor built to push: `EvalContext.push` routes through `fromContext`,\r\n * which *copies* a plain record into a `Registry` when `caseInsensitive` is\r\n * set. Keying on the pre-push record would file every `const` under an object\r\n * the write site can never produce, and `caseInsensitive` alone would lose\r\n * const-ness silently. `EvalContext.scopeHolding` returns the stack's object,\r\n * which is what both sides use.\r\n *\r\n * The entries die with the scopes: scope objects are created per block entry\r\n * and dropped when the block exits, so nothing here outlives the walk even\r\n * though the state may.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public declareConst(scope: Context, key: unknown): void {\r\n const bindings = (this._constBindings ??= new WeakMap<Context, Set<unknown>>());\r\n const keys = bindings.get(scope);\r\n if (keys) {\r\n keys.add(key);\r\n } else {\r\n bindings.set(scope, new Set([key]));\r\n }\r\n }\r\n\r\n /**\r\n * Whether `key` was declared `const` in `scope`.\r\n *\r\n * Asked by `assignment-expression.ts` and `update-expression.ts` of the scope\r\n * the write is about to land in, so an inner `let` of a name an outer scope\r\n * declared `const` stays writable - the kind belongs to the binding, not to\r\n * the name.\r\n *\r\n * @internal Not part of the published API.\r\n */\r\n public isConstBinding(scope: Context, key: unknown): boolean {\r\n return !!this._constBindings?.get(scope)?.has(key);\r\n }\r\n\r\n /**\r\n * Drops every per-run record this state holds: the collected hook errors, the\r\n * open-node stack, the accumulated timings, and the walk bases bounding\r\n * `EvalHooks.exit`.\r\n *\r\n * It resets the whole record rather than only the errors, which is why it is\r\n * not named for them. `EvalHooks.clear` cannot reach any of this - the\r\n * bookkeeping belongs to the state - so without this method nothing drains\r\n * the open-node stack at all. Frames left on it keep their AST nodes\r\n * reachable for as long as the state is, and `EvalService` holds its states\r\n * in a strong `Set`.\r\n *\r\n * The errors matter for the same reason under the state-first style:\r\n * `createState` plus repeated `eval` on one state accumulates them for the\r\n * life of that state, and a thrown value can close over consumer objects.\r\n *\r\n * The record is replaced rather than emptied in place, so a caller still\r\n * holding the array {@link hookErrors} handed out keeps its own contents and\r\n * simply stops tracking - the alternative would mutate a collection the\r\n * caller owns a reference to.\r\n *\r\n * Calling this mid-walk is unsupported for the same reason `EvalHooks.clear`\r\n * is: it abandons frames the dispatcher expects to close.\r\n */\r\n public resetHookBookkeeping(): void {\r\n this._hookBookkeeping = undefined;\r\n }\r\n\r\n /**\r\n * Represents the state of an evaluation.\r\n * @param context The evaluation context.\r\n * @param result The evaluation result.\r\n * @param options The evaluation options.\r\n * @param isAsync Indicates whether the evaluation is asynchronous.\r\n */\r\n constructor(context: EvalContext | undefined,\r\n result: EvalResult,\r\n options?: EvalOptions,\r\n isAsync?: boolean) {\r\n\r\n this._context = context;\r\n this._result = result;\r\n this._options = options;\r\n this._isAsync = isAsync;\r\n this._hooks = adoptHooks(options);\r\n\r\n // Options configure the registry this state owns, never an adopted one -\r\n // the same rule `onHookError` follows, and for the same reason: an adopted\r\n // `EvalHooks` belongs to the caller, and installing into it would leave a\r\n // hook firing on every later evaluation they run through it, with the\r\n // unsubscribe this call discards as the only way off. A caller who wants\r\n // both passes their own registry and installs the hook on it themselves.\r\n if (!this._hooks && readTrackTime(options)) {\r\n // Registering here rather than lazily means `isActive` has latched before\r\n // the walk starts, so every node dispatches for its whole duration. That\r\n // is what was asked for: per-node-type totals cannot be had without\r\n // visiting each node, and `EvalResult.duration` already covers the\r\n // cheaper walk-level question.\r\n createTimingHook().install(this.hooks);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalState from a given context, options, and async flag.\r\n *\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @param isAsync - A flag indicating whether the evaluation is asynchronous.\r\n * @returns The created EvalState instance.\r\n */\r\n static fromContext(context?: EvalContext | Context,\r\n options?: EvalOptions,\r\n isAsync?: boolean): EvalState {\r\n\r\n const ctx = EvalContext.fromContext(context, options);\r\n const result = new EvalResult(ctx);\r\n const state = new EvalState(ctx, result, options, isAsync);\r\n return state;\r\n }\r\n\r\n}\r\n","import { defaultOptions } from \"acorn\";\r\nimport { ParserOptions } from \"../../interfaces\";\r\n\r\nexport const defaultParserOptions: ParserOptions = {\r\n ...defaultOptions,\r\n ecmaVersion: 2020,\r\n extractExpressions: false,\r\n cacheSize: 100\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const pushVisitorResult = (node: AnyNode, st: EvalState, value: unknown) => {\r\n const result = st.result;\r\n result.stack.push(value);\r\n result.trace.add(node, value, st.result.expression);\r\n return value;\r\n}\r\n\r\nexport const popVisitorResult = (node: AnyNode, st: EvalState): unknown => {\r\n const result = st.result;\r\n const value = result.stack.pop();\r\n return value;\r\n}\r\n\r\nexport const pushVisitorResultAsync = (node: AnyNode, st: EvalState, value: Promise<unknown>) => {\r\n const result = st.result;\r\n result.stack.push(value);\r\n result.trace.add(node, value, st.result.expression);\r\n return value;\r\n}\r\n\r\nexport const popVisitorResultAsync = (node: AnyNode, st: EvalState): Promise<unknown> => {\r\n const result = st.result;\r\n const value = result.stack.pop() as Promise<unknown>;\r\n return value;\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Opens a node: records it as open and fires the registered 'before' hooks.\r\n *\r\n * Called at the top of every visitor body. The guard is a single boolean field\r\n * read - no options lookup - so an evaluation with no hooks pays almost\r\n * nothing, and it wraps the open-node bookkeeping as well as the hooks\r\n * themselves so `enter` and `exit` cannot become unpaired mid-walk.\r\n */\r\nexport const beforeVisitor = (node: AnyNode, st: EvalState): void => {\r\n\r\n if (!st.hasHooks) {\r\n return;\r\n }\r\n\r\n st.hooks.dispatch('before', node, st);\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Closes a node: pops it off the open-node stack and fires the registered\r\n * 'after' hooks.\r\n *\r\n * The event's `value` is read **positionally** - it is whatever sits on top of\r\n * the result stack right now, not something keyed to this node. Reading it here\r\n * is what makes the value available without changing any visitor's call\r\n * signature, and it is correct for every visitor that pushes its result\r\n * immediately before calling this. A visitor that reaches this without pushing\r\n * would report its *neighbour's* value, not `undefined`; the length check below\r\n * only guards the empty stack, since `Stack.peek` is non-destructive but does\r\n * not bounds-check.\r\n */\r\nexport const afterVisitor = (node: AnyNode, st: EvalState): void => {\r\n\r\n if (!st.hasHooks) {\r\n return;\r\n }\r\n\r\n const stack = st.result?.stack;\r\n const value = stack && stack.length > 0 ? stack.peek() : undefined;\r\n\r\n st.hooks.dispatch('after', node, st, value);\r\n}\r\n","import { WalkerCallback } from 'acorn-walk';\r\nimport * as acorn from 'acorn';\r\nimport { StackType } from './stack-type';\r\nimport { AnyNode } from 'acorn';\r\nimport { RegistryType } from './registry-type';\r\nimport { AnyNodeTypes } from './parser-types';\r\nimport { BaseRegistry, Registry } from '../public-api';\r\n\r\n/**\r\n * @deprecated Use `EvalHooks` and `EvalState` instead. Nothing in the library\r\n * implements this interface, and no code path reads its `beforeVisitors` /\r\n * `afterVisitors` entries; the evaluator's state type is `EvalState` and hooks\r\n * are registered through `EvalState.hooks`.\r\n *\r\n * **Its two hook entries are the last published trace of a signature no\r\n * function in the library has any more.** They are typed to return\r\n * `number | undefined` because the real `beforeVisitor` / `afterVisitor` once\r\n * returned a timing stub - a start timestamp handed back to the closing call.\r\n * That stub was deleted when those functions became hook dispatchers and their\r\n * return type widened to `void`, which is also what `EvalNodeHook` mandates, so\r\n * the shape recorded here is now contradicted by every hook the library\r\n * actually dispatches. A reader who finds these lines has no way to discover\r\n * that from the code, since there is no implementation left to compare against.\r\n *\r\n * Retained so this release stays purely additive; removal is a follow-up for\r\n * the next breaking version.\r\n */\r\nexport interface RecursiveVisitorState {\r\n scope: Registry<unknown, unknown>,\r\n result: RecursiveVisitorResult<unknown | undefined>,\r\n option: RecursiveVisitorOptions,\r\n beforeVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>,\r\n afterVisitors?: RegistryType<AnyNodeTypes, (node: AnyNode, st: RecursiveVisitorState) => number | undefined>,\r\n}\r\nexport interface RecursiveVisitorOptions {\r\n trackTime?: boolean;\r\n resultType?: 'stack' | 'registry';\r\n}\r\nexport interface RecursiveVisitorContext {\r\n placeholder?: unknown; // Placeholder for future context data\r\n}\r\n\r\nexport enum RecursiveVisitorResultType {\r\n Stack,\r\n Registry\r\n}\r\n\r\n/**\r\n * @deprecated Use `EvalResult` instead. This exists only as the `result` member\r\n * of the deprecated {@link RecursiveVisitorState}; the evaluator carries its\r\n * value stack and trace on `EvalResult`, which is what visitors actually push\r\n * to and what `EvalState.result` returns.\r\n *\r\n * Retained so this release stays purely additive; removal is a follow-up for\r\n * the next breaking version.\r\n */\r\nexport type RecursiveVisitorResult<TValue> =\r\n RecursiveVisitorStackResult<TValue> |\r\n RecursiveVisitorRegistryResult<TValue>\r\n\r\nexport interface RecursiveVisitorStackResult<TValue> {\r\n type: 'stack',\r\n stack: StackType<TValue>\r\n}\r\n\r\nexport interface RecursiveVisitorRegistryResult<TValue> {\r\n type: 'registry',\r\n registry: BaseRegistry<AnyNode, TValue>\r\n}\r\n\r\nexport type AggregateType = {\r\n Expression: acorn.Expression,\r\n Statement: acorn.Statement,\r\n Function: acorn.Function,\r\n Class: acorn.Class,\r\n Pattern: acorn.Pattern,\r\n ForInit: acorn.VariableDeclaration | acorn.Expression\r\n}\r\n\r\nexport type RecursiveVisitor<TState> = ( node: acorn.AnyNode, state: TState, callback: WalkerCallback<TState>) => void;\r\n\r\nexport type RecursiveAggregateVisitor<TState> = ( node: AggregateType, state: TState, callback: WalkerCallback<TState>) => void;\r\n\r\n","import { Identifier } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { Registry } from '../public-api';\r\nimport { equalIgnoreCase } from './utils';\r\n\r\nconst literals: Registry<string, unknown>= Registry.fromObject({\r\n 'undefined': undefined,\r\n 'null': null,\r\n 'true': true,\r\n 'false': false,\r\n}, { caseInsensitive: true });\r\n\r\n/**\r\n * Reports a resolved identifier read to the hook layer.\r\n *\r\n * The key is the one the context actually matched, so a case-insensitive\r\n * lookup reports the corrected spelling; `getKey` returns undefined for a name\r\n * the context does not hold - a literal-registry resolution, or a miss - and\r\n * the source name stands in. The path is always the source spelling, since it\r\n * is reconstructed statically.\r\n *\r\n * `scoped` marks a read of a name bound by a scope pushed *during this walk* -\r\n * an arrow-function parameter. It is asked of `EvalContext.hasInScopes`, which\r\n * tests for the binding rather than for its value: a parameter bound to\r\n * `undefined` is still a parameter, and reading the flag off the resolved value\r\n * would make it vary with the data rather than with the expression.\r\n *\r\n * It is deliberately *not* set for `priorScopes`: those hold caller-registered,\r\n * long-lived objects and are real dependencies, so the discriminator is\r\n * lifetime rather than `instanceof EvalScope`. The property is omitted rather\r\n * than set to false, so absent reads as \"not scoped\" the same way it does at\r\n * the member emission sites.\r\n *\r\n * The scope stack is empty for any expression without an arrow function, and\r\n * `Stack.asArray` allocates, so the common case is short-circuited on length.\r\n */\r\nconst emitRead = (node: Identifier, st: EvalState, value: unknown) => {\r\n const key = st.context?.getKey(node.name) ?? node.name;\r\n const scoped = !!st.context\r\n && st.context.scopes.length > 0\r\n && st.context.hasInScopes(node.name);\r\n\r\n st.hooks.dispatchRead({\r\n kind: 'identifier',\r\n node,\r\n state: st,\r\n key,\r\n target: st.context,\r\n path: node.name,\r\n value,\r\n ...(scoped ? { scoped: true } : {})\r\n });\r\n}\r\n\r\nexport const identifierVisitor = (node: Identifier, st: EvalState) => {\r\n\r\n if (st.options?.caseInsensitive) {\r\n return identifierVisitorCaseInsensitive(node, st);\r\n }\r\n\r\n beforeVisitor(node, st);\r\n\r\n const context = st.context;\r\n\r\n const isThis = node.name === 'this';\r\n\r\n const value = isThis\r\n ? st.context\r\n : context?.get(node.name);\r\n\r\n // `this` resolves to the context object itself rather than to a key within\r\n // it, so it is not a read: reporting it would have a dependency tracker\r\n // record the whole context and re-fire on every change to it.\r\n if (st.hasHooks && st.hooks.hasReadHooks && !isThis) {\r\n emitRead(node, st, value);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nconst identifierVisitorCaseInsensitive = (node: Identifier, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const context = st.context;\r\n\r\n const isThis = !!equalIgnoreCase(node.name, 'this');\r\n\r\n const value = isThis\r\n ? st.context\r\n : context?.get(node.name) ?? literals.get(node.name);\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks && !isThis) {\r\n emitRead(node, st, value);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { Literal } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const literalVisitor = (node: Literal, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const value = node.value;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { BinaryExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n// import { getCachedVisitorResult, setCachedVisitorResult } from './visitor-result-cache';\r\n\r\n/**\r\n * Converts value to primitive for comparison operations\r\n */\r\nconst toPrimitive = (value: unknown, hint?: 'string' | 'number'): string | number | boolean | null | undefined | symbol | bigint => {\r\n if (value === null || value === undefined) return value;\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || \r\n typeof value === 'symbol' || typeof value === 'bigint') return value;\r\n \r\n // For objects, call valueOf/toString based on hint\r\n if (typeof value === 'object') {\r\n if (hint === 'number') {\r\n const valueOf = (value as Record<string, unknown>).valueOf;\r\n if (typeof valueOf === 'function') {\r\n const result = valueOf.call(value);\r\n if (typeof result !== 'object') return result as string | number | boolean | null | undefined | symbol | bigint;\r\n }\r\n const toString = (value as Record<string, unknown>).toString;\r\n if (typeof toString === 'function') {\r\n return toString.call(value) as string;\r\n }\r\n } else {\r\n const toString = (value as Record<string, unknown>).toString;\r\n if (typeof toString === 'function') {\r\n const result = toString.call(value);\r\n if (typeof result === 'string') return result;\r\n }\r\n const valueOf = (value as Record<string, unknown>).valueOf;\r\n if (typeof valueOf === 'function') {\r\n const result = valueOf.call(value);\r\n if (typeof result !== 'object') return result as string | number | boolean | null | undefined | symbol | bigint;\r\n }\r\n }\r\n }\r\n \r\n return String(value);\r\n};\r\n\r\n/**\r\n * Safely evaluates binary operations with proper type coercion\r\n */\r\nconst evaluateBinaryOperation = (operator: string, left: unknown, right: unknown): unknown => {\r\n switch (operator) {\r\n case '+': {\r\n // Handle string concatenation and numeric addition according to JavaScript rules\r\n const leftPrim = toPrimitive(left);\r\n const rightPrim = toPrimitive(right);\r\n if (typeof leftPrim === 'string' || typeof rightPrim === 'string') {\r\n return String(leftPrim) + String(rightPrim);\r\n }\r\n return Number(leftPrim) + Number(rightPrim);\r\n }\r\n \r\n case '-':\r\n return Number(toPrimitive(left, 'number')) - Number(toPrimitive(right, 'number'));\r\n case '*':\r\n return Number(toPrimitive(left, 'number')) * Number(toPrimitive(right, 'number'));\r\n case '/':\r\n return Number(toPrimitive(left, 'number')) / Number(toPrimitive(right, 'number'));\r\n case '%':\r\n return Number(toPrimitive(left, 'number')) % Number(toPrimitive(right, 'number'));\r\n case '**':\r\n return Number(toPrimitive(left, 'number')) ** Number(toPrimitive(right, 'number'));\r\n \r\n // Bitwise operations - convert to 32-bit integers\r\n case '<<':\r\n return (Number(toPrimitive(left, 'number')) | 0) << (Number(toPrimitive(right, 'number')) | 0);\r\n case '>>':\r\n return (Number(toPrimitive(left, 'number')) | 0) >> (Number(toPrimitive(right, 'number')) | 0);\r\n case '>>>':\r\n return (Number(toPrimitive(left, 'number')) >>> 0) >>> (Number(toPrimitive(right, 'number')) | 0);\r\n case '&':\r\n return (Number(toPrimitive(left, 'number')) | 0) & (Number(toPrimitive(right, 'number')) | 0);\r\n case '^':\r\n return (Number(toPrimitive(left, 'number')) | 0) ^ (Number(toPrimitive(right, 'number')) | 0);\r\n case '|':\r\n return (Number(toPrimitive(left, 'number')) | 0) | (Number(toPrimitive(right, 'number')) | 0);\r\n \r\n // Comparison operations - follow JavaScript's abstract comparison rules\r\n case '==':\r\n return left == right;\r\n case '!=':\r\n return left != right;\r\n case '===':\r\n return left === right;\r\n case '!==':\r\n return left !== right;\r\n case '<': {\r\n const leftComp = toPrimitive(left, 'number');\r\n const rightComp = toPrimitive(right, 'number');\r\n // If both are strings, do string comparison\r\n if (typeof leftComp === 'string' && typeof rightComp === 'string') {\r\n return leftComp < rightComp;\r\n }\r\n return Number(leftComp) < Number(rightComp);\r\n }\r\n case '<=': {\r\n const leftLE = toPrimitive(left, 'number');\r\n const rightLE = toPrimitive(right, 'number');\r\n if (typeof leftLE === 'string' && typeof rightLE === 'string') {\r\n return leftLE <= rightLE;\r\n }\r\n return Number(leftLE) <= Number(rightLE);\r\n }\r\n case '>': {\r\n const leftGT = toPrimitive(left, 'number');\r\n const rightGT = toPrimitive(right, 'number');\r\n if (typeof leftGT === 'string' && typeof rightGT === 'string') {\r\n return leftGT > rightGT;\r\n }\r\n return Number(leftGT) > Number(rightGT);\r\n }\r\n case '>=': {\r\n const leftGE = toPrimitive(left, 'number');\r\n const rightGE = toPrimitive(right, 'number');\r\n if (typeof leftGE === 'string' && typeof rightGE === 'string') {\r\n return leftGE >= rightGE;\r\n }\r\n return Number(leftGE) >= Number(rightGE);\r\n }\r\n \r\n // Special operations\r\n case 'in': {\r\n if (typeof left === 'string' || typeof left === 'number' || typeof left === 'symbol') {\r\n if (right == null) {\r\n throw new Error(`Cannot use 'in' operator with null or undefined right operand`);\r\n }\r\n return left in (right as object);\r\n }\r\n throw new Error(`Invalid left operand for 'in' operator: ${typeof left}`);\r\n }\r\n \r\n case 'instanceof': {\r\n if (typeof right === 'function') {\r\n return left instanceof right;\r\n }\r\n throw new Error(`Right operand of 'instanceof' is not a constructor`);\r\n }\r\n \r\n case '??':\r\n return left ?? right;\r\n \r\n default:\r\n throw new Error(`Unsupported binary operator: ${operator}`);\r\n }\r\n};\r\n\r\n/**\r\n * Safely evaluates binary expressions with proper type handling\r\n */\r\nexport const binaryExpressionVisitor = (node: BinaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Disable visitor result caching for now due to context sensitivity issues\r\n // const cachedResult = getCachedVisitorResult(node, st.context);\r\n // if (cachedResult !== undefined) {\r\n // pushVisitorResult(node, st, cachedResult);\r\n // afterVisitor(node, st);\r\n // return;\r\n // }\r\n\r\n callback(node.left, st);\r\n const left = popVisitorResult(node, st);\r\n\r\n callback(node.right, st);\r\n const right = popVisitorResult(node, st);\r\n\r\n const value = evaluateBinaryOperation(node.operator, left, right);\r\n\r\n // Disable visitor result caching for now\r\n // setCachedVisitorResult(node, st.context, value);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","/**\r\n * Prototype Pollution Prevention Utilities\r\n *\r\n * This module provides safeguards against prototype pollution attacks\r\n * by controlling access to dangerous property names and ensuring safe\r\n * object operations.\r\n */\r\n\r\n/**\r\n * Set of property names that are dangerous for prototype pollution attacks\r\n */\r\nconst DANGEROUS_PROPERTY_NAMES = new Set([\r\n '__proto__',\r\n 'constructor',\r\n 'prototype',\r\n '__defineGetter__',\r\n '__defineSetter__',\r\n '__lookupGetter__',\r\n '__lookupSetter__',\r\n 'hasOwnProperty',\r\n 'isPrototypeOf',\r\n 'propertyIsEnumerable',\r\n 'toString',\r\n 'valueOf',\r\n 'toLocaleString'\r\n]);\r\n\r\n/**\r\n * Set of constructor names that should be blocked from modification\r\n */\r\nconst DANGEROUS_CONSTRUCTORS = new Set([\r\n 'Object',\r\n 'Function',\r\n 'Array',\r\n 'String',\r\n 'Number',\r\n 'Boolean',\r\n 'Date',\r\n 'RegExp',\r\n 'Error',\r\n 'Promise'\r\n]);\r\n\r\n/**\r\n * Checks if a property name is dangerous for prototype pollution\r\n * @param key The property name to check\r\n * @returns true if the property is dangerous, false otherwise\r\n */\r\nexport const isDangerousProperty = (key: unknown): boolean => {\r\n if (typeof key === 'string') {\r\n return DANGEROUS_PROPERTY_NAMES.has(key);\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Checks if an object is a dangerous constructor that shouldn't be modified\r\n * @param obj The object to check\r\n * @returns true if the object is a dangerous constructor, false otherwise\r\n */\r\nexport const isDangerousConstructor = (obj: unknown): boolean => {\r\n if (typeof obj === 'function' && obj.name) {\r\n return DANGEROUS_CONSTRUCTORS.has(obj.name);\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Safely sets a property on an object with prototype pollution protection\r\n * @param target The target object\r\n * @param key The property key\r\n * @param value The property value\r\n * @throws Error if the operation would cause prototype pollution\r\n */\r\nexport const safeSetProperty = (target: unknown, key: unknown, value: unknown): void => {\r\n if (!target || (typeof target !== 'object' && typeof target !== 'function')) {\r\n throw new Error(`Cannot set property on non-object: ${typeof target}`);\r\n }\r\n\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${String(key)}\" is blocked for security reasons`);\r\n }\r\n\r\n // Additional protection: don't allow setting properties on built-in prototypes\r\n if (isDangerousConstructor(target)) {\r\n throw new Error(`Modification of built-in constructor \"${(target as {name: string}).name}\" is blocked for security reasons`);\r\n }\r\n\r\n // Check if we're trying to modify prototype chain\r\n if (target === Object.prototype ||\r\n target === Function.prototype ||\r\n target === Array.prototype ||\r\n target === String.prototype ||\r\n target === Number.prototype ||\r\n target === Boolean.prototype) {\r\n throw new Error(`Modification of built-in prototype is blocked for security reasons`);\r\n }\r\n\r\n // Convert key to PropertyKey for safe operations\r\n let propertyKey: PropertyKey;\r\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\r\n propertyKey = key;\r\n } else {\r\n // For other types, try to convert to string\r\n propertyKey = String(key);\r\n }\r\n\r\n // Use Object.defineProperty for safer assignment\r\n const descriptor = {\r\n value,\r\n writable: true,\r\n enumerable: true,\r\n configurable: true\r\n };\r\n\r\n try {\r\n Object.defineProperty(target as object, propertyKey, descriptor);\r\n } catch (error) {\r\n throw new Error(`Failed to set property \"${String(key)}\": ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n};\r\n\r\n/**\r\n * Safely gets a property from an object with prototype pollution protection\r\n * @param target The target object\r\n * @param key The property key\r\n * @returns The property value or undefined\r\n */\r\nexport const safeGetProperty = (target: unknown, key: unknown): unknown => {\r\n if (!target || (typeof target !== 'object' && typeof target !== 'function')) {\r\n return undefined;\r\n }\r\n\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${String(key)}\" is blocked for security reasons`);\r\n }\r\n\r\n // Convert key to PropertyKey for safe operations\r\n let propertyKey: PropertyKey;\r\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\r\n propertyKey = key;\r\n } else {\r\n // For other types, try to convert to string\r\n propertyKey = String(key);\r\n }\r\n\r\n // Direct property access using bracket notation (safer than complex prototype walking)\r\n try {\r\n return (target as Record<PropertyKey, unknown>)[propertyKey];\r\n } catch {\r\n // If property access fails, return undefined\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Creates a safe object without dangerous prototype pollution vectors\r\n * @param entries Key-value pairs to populate the object\r\n * @returns A new safe object\r\n */\r\nexport const createSafeObject = (entries: Array<[unknown, unknown]> = []): Record<string, unknown> => {\r\n // Create object with normal prototype for compatibility, but validate contents\r\n const obj: Record<string, unknown> = {};\r\n\r\n for (const [key, value] of entries) {\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Cannot create object with dangerous property \"${String(key)}\"`);\r\n }\r\n\r\n // Safely set the property\r\n if (typeof key === 'string' || typeof key === 'number') {\r\n obj[key] = value;\r\n } else if (typeof key === 'symbol') {\r\n (obj as Record<symbol, unknown>)[key] = value;\r\n }\r\n }\r\n\r\n return obj;\r\n};\r\n\r\n/**\r\n * Validates that an object is safe from prototype pollution\r\n * @param obj The object to validate\r\n * @throws Error if the object contains dangerous properties\r\n */\r\nexport const validateSafeObject = (obj: unknown): void => {\r\n if (!obj || typeof obj !== 'object') {\r\n return;\r\n }\r\n\r\n const keys = Object.getOwnPropertyNames(obj);\r\n for (const key of keys) {\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Object contains dangerous property \"${key}\" that could lead to prototype pollution`);\r\n }\r\n }\r\n\r\n // Also check symbol properties\r\n const symbols = Object.getOwnPropertySymbols(obj);\r\n for (const symbol of symbols) {\r\n const description = symbol.description;\r\n if (description && isDangerousProperty(description)) {\r\n throw new Error(`Object contains dangerous symbol property \"${description}\" that could lead to prototype pollution`);\r\n }\r\n }\r\n};\r\n","/**\r\n * Property Lookup Cache\r\n * \r\n * Provides efficient caching for case-insensitive property lookups\r\n * to avoid repeated O(n) searches through object property lists.\r\n */\r\n\r\ninterface PropertyLookupCacheEntry {\r\n foundKey: string | null;\r\n lastAccessed: number;\r\n objectHash: string;\r\n}\r\n\r\n/**\r\n * Cache for property lookup results to optimize case-insensitive property access\r\n */\r\nclass PropertyLookupCache {\r\n private readonly _cache = new Map<string, PropertyLookupCacheEntry>();\r\n private readonly _maxSize: number;\r\n private readonly _expirationTime: number; // in milliseconds\r\n \r\n constructor(maxSize = 1000, expirationTimeMs = 5 * 60 * 1000) { // 5 minutes default\r\n this._maxSize = maxSize;\r\n this._expirationTime = expirationTimeMs;\r\n }\r\n\r\n /**\r\n * Generates a simple hash for an object based on its own property names\r\n */\r\n private generateObjectHash(obj: Record<PropertyKey, unknown>): string {\r\n try {\r\n const keys = Object.getOwnPropertyNames(obj);\r\n return keys.length.toString() + '_' + keys.slice(0, 5).join('_');\r\n } catch {\r\n return 'unknown_hash';\r\n }\r\n }\r\n\r\n /**\r\n * Generates a cache key for a property lookup\r\n */\r\n private generateCacheKey(objectHash: string, searchKey: string): string {\r\n return `${objectHash}:${searchKey.toLowerCase()}`;\r\n }\r\n\r\n /**\r\n * Checks if a cache entry is still valid\r\n */\r\n private isEntryValid(entry: PropertyLookupCacheEntry, objectHash: string): boolean {\r\n const now = Date.now();\r\n return (\r\n entry.objectHash === objectHash &&\r\n (now - entry.lastAccessed) < this._expirationTime\r\n );\r\n }\r\n\r\n /**\r\n * Cleans up expired entries and maintains cache size\r\n */\r\n private cleanup(): void {\r\n const now = Date.now();\r\n const entries = Array.from(this._cache.entries());\r\n \r\n // Remove expired entries\r\n for (const [key, entry] of entries) {\r\n if ((now - entry.lastAccessed) >= this._expirationTime) {\r\n this._cache.delete(key);\r\n }\r\n }\r\n \r\n // If still too large, remove oldest entries\r\n if (this._cache.size > this._maxSize) {\r\n const sortedEntries = Array.from(this._cache.entries())\r\n .sort(([, a], [, b]) => a.lastAccessed - b.lastAccessed);\r\n \r\n const entriesToRemove = sortedEntries.slice(0, this._cache.size - this._maxSize);\r\n for (const [key] of entriesToRemove) {\r\n this._cache.delete(key);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets a cached property lookup result\r\n */\r\n get(obj: Record<PropertyKey, unknown>, searchKey: string): string | null | undefined {\r\n const objectHash = this.generateObjectHash(obj);\r\n const cacheKey = this.generateCacheKey(objectHash, searchKey);\r\n \r\n const entry = this._cache.get(cacheKey);\r\n if (entry && this.isEntryValid(entry, objectHash)) {\r\n // Update access time\r\n entry.lastAccessed = Date.now();\r\n return entry.foundKey;\r\n }\r\n \r\n return undefined; // Cache miss\r\n }\r\n\r\n /**\r\n * Sets a cached property lookup result\r\n */\r\n set(obj: Record<PropertyKey, unknown>, searchKey: string, foundKey: string | null): void {\r\n // Perform cleanup periodically\r\n if (this._cache.size > this._maxSize * 0.8) {\r\n this.cleanup();\r\n }\r\n \r\n const objectHash = this.generateObjectHash(obj);\r\n const cacheKey = this.generateCacheKey(objectHash, searchKey);\r\n \r\n this._cache.set(cacheKey, {\r\n foundKey,\r\n lastAccessed: Date.now(),\r\n objectHash\r\n });\r\n }\r\n\r\n /**\r\n * Clears the entire cache\r\n */\r\n clear(): void {\r\n this._cache.clear();\r\n }\r\n\r\n /**\r\n * Gets current cache size\r\n */\r\n get size(): number {\r\n return this._cache.size;\r\n }\r\n}\r\n\r\n// Global property lookup cache instance\r\nconst propertyLookupCache = new PropertyLookupCache();\r\n\r\n/**\r\n * Performs optimized case-insensitive property lookup with caching\r\n */\r\nexport function getCachedCaseInsensitiveProperty(\r\n obj: Record<PropertyKey, unknown>,\r\n searchKey: string,\r\n equalIgnoreCase: (a: string, b: string) => boolean\r\n): string | null {\r\n // Try to get from cache first\r\n const cachedResult = propertyLookupCache.get(obj, searchKey);\r\n if (cachedResult !== undefined) {\r\n return cachedResult;\r\n }\r\n \r\n // Cache miss - perform actual lookup\r\n let foundKey: string | null = null;\r\n \r\n if (obj && typeof obj === 'object') {\r\n const ownKeys = Object.getOwnPropertyNames(obj);\r\n const matchingKey = ownKeys.find(k => equalIgnoreCase(k, searchKey));\r\n foundKey = matchingKey || null;\r\n }\r\n \r\n // Cache the result\r\n propertyLookupCache.set(obj, searchKey, foundKey);\r\n \r\n return foundKey;\r\n}\r\n\r\n/**\r\n * Clears the property lookup cache (for testing or memory management)\r\n */\r\nexport function clearPropertyLookupCache(): void {\r\n propertyLookupCache.clear();\r\n}\r\n\r\n/**\r\n * Gets current property lookup cache statistics\r\n */\r\nexport function getPropertyLookupCacheStats(): { size: number, maxSize: number } {\r\n return {\r\n size: propertyLookupCache.size,\r\n maxSize: 1000 // This should match the maxSize in constructor\r\n };\r\n}","import { MemberExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalScope, EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { safeGetProperty, isDangerousProperty } from './prototype-pollution-guard';\r\nimport { equalIgnoreCase } from './utils';\r\nimport { getCachedCaseInsensitiveProperty } from './property-lookup-cache';\r\n// import { getCachedVisitorResult, setCachedVisitorResult } from './visitor-result-cache';\r\n\r\n/**\r\n * Reconstructs the dotted source path of a member chain (`a.b.c`).\r\n *\r\n * Static only: a computed hop (`a[expr]`, `a[\"b\"]`) leaves the path\r\n * unreconstructible and yields undefined, and a consumer falls back to\r\n * `target` + `key` identity - which is exact either way. The parts are source\r\n * spellings, so under `caseInsensitive` the path is not corrected even though\r\n * the reported key is; optional markers are not represented either, so `a?.b`\r\n * reconstructs as `a.b`. A chain rooted at anything but an `Identifier` - a\r\n * `this`, a call, a `super` - yields undefined.\r\n *\r\n * Walks the chain once per member read, so every call site sits behind\r\n * `st.hasHooks && st.hooks.hasReadHooks`: a consumer that registered only node\r\n * hooks must not pay for a path it can never observe.\r\n */\r\nconst readPath = (node: MemberExpression): string | undefined => {\r\n const parts: string[] = [];\r\n let current: MemberExpression['object'] = node;\r\n\r\n while (current.type === 'MemberExpression') {\r\n if (current.computed || current.property.type !== 'Identifier') {\r\n return undefined;\r\n }\r\n parts.unshift(current.property.name);\r\n current = current.object;\r\n }\r\n\r\n if (current.type !== 'Identifier') {\r\n return undefined;\r\n }\r\n\r\n parts.unshift(current.name);\r\n return parts.join('.');\r\n}\r\n\r\nexport const memberExpressionVisitor = (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Disable visitor result caching for now due to context sensitivity issues\r\n // const cachedResult = getCachedVisitorResult(node, st.context);\r\n // if (cachedResult !== undefined) {\r\n // pushVisitorResult(node, st, cachedResult);\r\n // afterVisitor(node, st);\r\n // return;\r\n // }\r\n\r\n const [, , value] = evaluateMember(node, st, callback);\r\n\r\n // Disable visitor result caching for now\r\n // setCachedVisitorResult(node, st.context, value);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateMember = (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n // Get the object\r\n callback(node.object, st);\r\n const obj = popVisitorResult(node, st) as object;\r\n const object = (node.optional ? (obj || {}) : obj);\r\n\r\n // Get the property\r\n let key: string | number | symbol;\r\n if (!node.computed && node.property.type === 'Identifier') {\r\n // Dot notation: obj.prop\r\n key = node.property.name;\r\n } else if (node.property.type === 'Literal') {\r\n // Computed literal: obj[\"literal\"]\r\n key = node.property.value as string | number | symbol;\r\n } else {\r\n // Computed expression: obj[key], obj[expression]\r\n callback(node.property, st);\r\n key = popVisitorResult(node, st) as (string | number | symbol);\r\n }\r\n\r\n // Get the value with context-aware or prototype pollution protection\r\n if (object === st.context) {\r\n // For context objects, preserve case-insensitive behavior\r\n const contextKey = st.options?.caseInsensitive && typeof key === 'string'\r\n ? st.context.getKey(key)\r\n : key;\r\n const value = st.context.get(contextKey);\r\n const thisValue = st.context.getThis(contextKey);\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key: contextKey ?? key,\r\n target: st.context,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [thisValue ?? object, contextKey, value];\r\n } else if (object instanceof EvalScope) {\r\n // For scope objects, preserve original behavior (no getKey method)\r\n const value = object.get(key);\r\n const thisValue = object;\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key,\r\n target: object,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [thisValue ?? object, key, value];\r\n } else {\r\n // For regular objects, we need both case-insensitive lookup AND prototype pollution protection\r\n let value: unknown;\r\n\r\n // The key the lookup actually matched, reported to the read hooks. The\r\n // returned tuple keeps the original `key`; only the event is corrected.\r\n let resolvedKey: string | number | symbol = key;\r\n\r\n // Check if this is a primitive type (string, number, boolean) - these are safe for method access\r\n const isPrimitive = (typeof object === 'string' || typeof object === 'number' || typeof object === 'boolean');\r\n \r\n if (st.options?.caseInsensitive && typeof key === 'string') {\r\n // Use case-insensitive lookup but with prototype pollution protection\r\n // For primitives, skip dangerous property checks as their methods are safe\r\n if (!isPrimitive && isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${key}\" is blocked for security reasons`);\r\n }\r\n \r\n // Try case-insensitive lookup on own properties first\r\n const obj = object as Record<PropertyKey, unknown>;\r\n let foundKey: string | null | undefined = undefined;\r\n \r\n if (obj && typeof obj === 'object') {\r\n // Create wrapper function for cache compatibility\r\n const compareIgnoreCase = (a: string, b: string): boolean => {\r\n const result = equalIgnoreCase(a, b);\r\n return result === true;\r\n };\r\n \r\n // Use cached case-insensitive property lookup for own properties (optimization)\r\n const cachedFoundKey = getCachedCaseInsensitiveProperty(obj, key, compareIgnoreCase);\r\n if (cachedFoundKey !== undefined) {\r\n // Cache hit: cachedFoundKey is either the found key (string) or null (no match)\r\n foundKey = cachedFoundKey;\r\n }\r\n \r\n // If cache miss or not found in own properties, check if the original key exists (including prototype methods)\r\n if (cachedFoundKey === undefined || !foundKey) {\r\n try {\r\n // Test if property exists in prototype chain (this includes native methods like array.find)\r\n const testValue = obj[key];\r\n if (testValue !== undefined) {\r\n foundKey = key;\r\n } else {\r\n // Look for case variations in prototype methods for arrays, objects, etc.\r\n // This is more expensive but necessary for case-insensitive prototype method access\r\n const prototype = Object.getPrototypeOf(obj);\r\n if (prototype) {\r\n const prototypeKeys = Object.getOwnPropertyNames(prototype);\r\n foundKey = prototypeKeys.find(k => typeof k === 'string' && equalIgnoreCase(k, key));\r\n }\r\n }\r\n } catch {\r\n // If access fails, foundKey remains undefined\r\n }\r\n }\r\n \r\n // Check if the found key is dangerous (but only for non-primitives)\r\n if (!isPrimitive && foundKey && isDangerousProperty(foundKey)) {\r\n throw new Error(`Access to dangerous property \"${foundKey}\" is blocked for security reasons`);\r\n }\r\n }\r\n \r\n // Get the value using the found key or use safeGetProperty fallback for non-primitives\r\n if (isPrimitive) {\r\n // For primitives, direct access is safe\r\n value = foundKey ? obj[foundKey] : obj[key];\r\n } else {\r\n // For objects, use safe property access\r\n value = foundKey ? obj[foundKey] : safeGetProperty(object, key);\r\n }\r\n\r\n if (foundKey) {\r\n resolvedKey = foundKey;\r\n }\r\n } else {\r\n // Use safe property access for prototype pollution protection (but not for primitives)\r\n if (isPrimitive) {\r\n // For primitives, direct access is safe\r\n value = (object as Record<PropertyKey, unknown>)[key];\r\n } else {\r\n value = safeGetProperty(object, key);\r\n }\r\n }\r\n\r\n if (st.hasHooks && st.hooks.hasReadHooks) {\r\n st.hooks.dispatchRead({\r\n kind: 'member',\r\n node,\r\n state: st,\r\n key: resolvedKey,\r\n target: object,\r\n path: readPath(node),\r\n value\r\n });\r\n }\r\n\r\n return [object, key, value];\r\n }\r\n}\r\n","import { AnyNode, ArrayExpression, Expression, SpreadElement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const arrayExpressionVisitor = (node: ArrayExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const elements = evaluateArray(node, node.elements, st, callback);\r\n\r\n pushVisitorResult(node, st, elements);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateArray = (node: AnyNode,\r\n items: Array<Expression | SpreadElement | null>,\r\n st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n // Pre-allocate array with known length for better performance\r\n const itemCount = items.length;\r\n const elements: unknown[] = new Array(itemCount);\r\n let actualLength = 0;\r\n\r\n for (let i = 0; i < itemCount; i++) {\r\n const element = items[i];\r\n \r\n if (element === null || typeof element === 'undefined') {\r\n elements[actualLength++] = element;\r\n } else if (element.type === 'SpreadElement') {\r\n callback(element, st);\r\n const values = popVisitorResult(node, st) as unknown[];\r\n \r\n // Expand the array if needed for spread elements\r\n if (values && Array.isArray(values)) {\r\n for (const value of values) {\r\n elements[actualLength++] = value;\r\n }\r\n }\r\n } else {\r\n callback(element, st);\r\n const value = popVisitorResult(node, st);\r\n elements[actualLength++] = value;\r\n }\r\n }\r\n\r\n // Trim array to actual size if it changed due to spread elements\r\n if (actualLength !== itemCount) {\r\n elements.length = actualLength;\r\n }\r\n\r\n return elements;\r\n}\r\n","import { CallExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { evaluateArray } from './array-expression';\r\n\r\n/**\r\n * Security: List of dangerous functions that should not be callable\r\n */\r\nconst DANGEROUS_FUNCTIONS = new Set([\r\n 'Function',\r\n 'eval',\r\n 'setTimeout',\r\n 'setInterval',\r\n 'setImmediate',\r\n 'require',\r\n 'import',\r\n 'importScripts',\r\n 'XMLHttpRequest',\r\n 'fetch',\r\n 'WebSocket',\r\n 'Worker',\r\n 'SharedWorker',\r\n 'ServiceWorker',\r\n]);\r\n\r\n/**\r\n * Security: List of dangerous patterns in function code\r\n * Only the most dangerous patterns that could lead to code injection\r\n */\r\nconst DANGEROUS_PATTERNS = [\r\n /\\beval\\s*\\(/i,\r\n /\\bFunction\\s*\\(/, // Look for Function constructor (capital F only)\r\n /new\\s+Function\\s*\\(/i,\r\n /\\.__proto__\\b/,\r\n /\\.prototype\\s*\\.\\s*constructor\\b/,\r\n /\\bglobalThis\\b/,\r\n];\r\n\r\n/**\r\n * Security: Check if a function name is dangerous\r\n */\r\nconst isDangerousFunctionName = (fnName: string): boolean => {\r\n return DANGEROUS_FUNCTIONS.has(fnName);\r\n};\r\n\r\n/**\r\n * Security: Check if function code contains dangerous patterns\r\n * Only check user-defined functions, not native ones\r\n */\r\nconst hasDangerousPatterns = (fnString: string): boolean => {\r\n // If it's a native function ([native code]), allow it\r\n if (fnString.includes('[native code]')) {\r\n return false;\r\n }\r\n\r\n // For user-defined functions, only check for truly dangerous patterns\r\n // that could lead to code injection or security bypass\r\n const result = DANGEROUS_PATTERNS.some(pattern => pattern.test(fnString));\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Security: Check if a function is safe to call\r\n */\r\nconst isFunctionSafe = (fn: unknown, fnName?: string): boolean => {\r\n if (typeof fn !== 'function') {\r\n return false;\r\n }\r\n\r\n // Check if it's a dangerous function by name\r\n if (fnName && isDangerousFunctionName(fnName)) {\r\n return false;\r\n }\r\n\r\n // Special check for Function constructor\r\n if (fn === Function) {\r\n return false;\r\n }\r\n\r\n try {\r\n // Check function string for dangerous patterns\r\n const fnString = fn.toString();\r\n if (hasDangerousPatterns(fnString)) {\r\n return false;\r\n }\r\n } catch {\r\n // If we can't get the function string, be cautious\r\n return false;\r\n }\r\n\r\n return true;\r\n};\r\n\r\n/**\r\n * Safely calls a function with proper error handling and security checks\r\n */\r\nconst safeCall = (\r\n caller: unknown,\r\n thisArg: unknown,\r\n args: unknown[],\r\n optional = false,\r\n fnName?: string\r\n): unknown => {\r\n if (!caller) {\r\n if (optional) {\r\n return undefined;\r\n }\r\n throw new Error(`Cannot call undefined or null function`);\r\n }\r\n\r\n if (typeof caller !== 'function') {\r\n throw new Error(`Value is not a function: ${typeof caller}`);\r\n }\r\n\r\n if (!isFunctionSafe(caller, fnName)) {\r\n throw new Error(`Function call blocked for security reasons: ${fnName || 'anonymous'}`);\r\n }\r\n\r\n try {\r\n return (caller as (...args: unknown[]) => unknown).apply(thisArg, args);\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(`Function call error: ${error.message}`);\r\n }\r\n throw error;\r\n }\r\n};\r\n\r\n/**\r\n * Enhanced call expression visitor with security checks\r\n */\r\nexport const callExpressionVisitor = (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const args = evaluateArray(node, node.arguments, st, callback);\r\n\r\n if (node.callee.type === 'MemberExpression') {\r\n const [object, propertyName, fn] = evaluateMember(node.callee, st, callback);\r\n const functionName = typeof propertyName === 'string' ? propertyName : undefined;\r\n const value = safeCall(fn, object, args, node.callee.optional, functionName);\r\n pushVisitorResult(node, st, value);\r\n } else {\r\n callback(node.callee, st);\r\n const caller = popVisitorResult(node, st);\r\n\r\n // Try to get function name for security checks\r\n let functionName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n functionName = node.callee.name;\r\n }\r\n\r\n const value = safeCall(caller, st.context, args, node.optional, functionName);\r\n pushVisitorResult(node, st, value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nexport const evaluateCall = (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n callback(node.callee, st);\r\n const caller = popVisitorResult(node, st);\r\n\r\n const args = node.arguments.map((argument) => {\r\n callback(argument, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n // Get function name for security checks\r\n let functionName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n functionName = node.callee.name;\r\n }\r\n\r\n const value = safeCall(caller, st.context, args, false, functionName);\r\n return value;\r\n}\r\n","import { ImportExpression } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\n/**\r\n * ImportExpression visitor - blocks all dynamic imports for security\r\n */\r\nexport const importExpressionVisitor = (node: ImportExpression, st: EvalState) => {\r\n beforeVisitor(node, st);\r\n\r\n // Block all dynamic imports for security reasons\r\n throw new Error('Function call blocked for security reasons: import');\r\n\r\n afterVisitor(node, st);\r\n};","import { AwaitExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\n// Default timeout for await expressions (30 seconds)\r\nconst DEFAULT_AWAIT_TIMEOUT = 30000;\r\n\r\n/**\r\n * Creates a timeout promise that rejects after the specified timeout\r\n */\r\nconst createTimeoutPromise = (timeout: number): Promise<never> => {\r\n return new Promise<never>((_, reject) => {\r\n setTimeout(() => {\r\n reject(new Error(`Await expression timed out after ${timeout}ms`));\r\n }, timeout);\r\n });\r\n};\r\n\r\n/**\r\n * Safely wraps a value in a promise if it's not already a promise\r\n */\r\nconst ensurePromise = (value: unknown): Promise<unknown> => {\r\n if (value && typeof value === 'object' && 'then' in value) {\r\n return value as Promise<unknown>;\r\n }\r\n return Promise.resolve(value);\r\n};\r\n\r\nexport const awaitVisitor = (node: AwaitExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const promise = new Promise<unknown | undefined>((resolve, reject) => {\r\n try {\r\n callback(node.argument, st);\r\n\r\n const value = popVisitorResult(node, st);\r\n\r\n // Convert value to promise if it's not already one\r\n const valuePromise = ensurePromise(value);\r\n\r\n // Get timeout from context or use default\r\n const contextObj = st.context?.original as Record<string, unknown>;\r\n const timeout = (contextObj && typeof contextObj['__awaitTimeout'] === 'number' \r\n ? contextObj['__awaitTimeout'] \r\n : DEFAULT_AWAIT_TIMEOUT);\r\n\r\n // Race between the actual promise and timeout\r\n Promise.race([\r\n valuePromise,\r\n createTimeoutPromise(timeout)\r\n ])\r\n .then(resolve)\r\n .catch((error) => {\r\n // Enhance error information with context\r\n const enhancedError = error instanceof Error \r\n ? error \r\n : new Error(`Await expression failed: ${String(error)}`);\r\n \r\n // Add source location information if available\r\n if (node.start !== undefined && node.end !== undefined) {\r\n enhancedError.message += ` at position ${node.start}-${node.end}`;\r\n }\r\n \r\n reject(enhancedError);\r\n });\r\n\r\n } catch (synchronousError) {\r\n // Handle synchronous errors immediately\r\n const enhancedError = synchronousError instanceof Error \r\n ? synchronousError \r\n : new Error(`Await expression failed synchronously: ${String(synchronousError)}`);\r\n \r\n reject(enhancedError);\r\n }\r\n });\r\n\r\n pushVisitorResult(node, st, promise);\r\n\r\n afterVisitor(node, st);\r\n\r\n}\r\n\r\n","import { ConditionalExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const conditionalExpressionVisitor = (node: ConditionalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.test, st);\r\n\r\n const test = popVisitorResult(node, st) as boolean;\r\n\r\n if (test) {\r\n callback(node.consequent, st);\r\n } else {\r\n callback(node.alternate, st);\r\n }\r\n\r\n const value = popVisitorResult(node, st) as number;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { UnaryExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const unaryExpressionVisitor = (node: UnaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.argument, st);\r\n\r\n const argument = popVisitorResult(node, st) as number;\r\n\r\n const value =\r\n node.operator === '-' ? -argument :\r\n node.operator === '+' ? +argument :\r\n node.operator === '~' ? ~argument :\r\n node.operator === '!' ? !argument :\r\n node.operator === 'typeof' ? typeof argument :\r\n node.operator === 'void' ? void argument :\r\n // node.operator === 'delete' ? delete argument :\r\n undefined;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { LogicalExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const logicalExpressionVisitor = (node: LogicalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.left, st);\r\n const left = popVisitorResult(node, st);\r\n\r\n // For && operator: if left is falsy, return left (don't evaluate right)\r\n if (node.operator === '&&' && !left) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // For || operator: if left is truthy, return left (don't evaluate right)\r\n if (node.operator === '||' && left) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // For ?? operator: if left is not null/undefined, return left (don't evaluate right)\r\n if (node.operator === '??' && left !== null && left !== undefined) {\r\n pushVisitorResult(node, st, left);\r\n afterVisitor(node, st);\r\n return;\r\n }\r\n\r\n // Evaluate right operand\r\n callback(node.right, st);\r\n const right = popVisitorResult(node, st);\r\n\r\n // Return the appropriate value based on operator\r\n let value: unknown;\r\n switch (node.operator) {\r\n case '&&':\r\n value = left && right;\r\n break;\r\n case '||':\r\n value = left || right;\r\n break;\r\n case '??':\r\n value = left ?? right;\r\n break;\r\n default:\r\n throw new Error(`Unsupported logical operator: ${node.operator}`);\r\n }\r\n\r\n pushVisitorResult(node, st, value);\r\n afterVisitor(node, st);\r\n}\r\n","import { ThisExpression } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\n\r\nexport const thisExpressionVisitor = (node: ThisExpression, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const value = st.context;\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { NewExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateArray } from './array-expression';\r\n\r\n/**\r\n * Security: List of dangerous constructors that should not be instantiated\r\n */\r\nconst DANGEROUS_CONSTRUCTORS = new Set([\r\n 'Function',\r\n 'GeneratorFunction',\r\n 'AsyncFunction',\r\n 'AsyncGeneratorFunction',\r\n 'XMLHttpRequest',\r\n 'WebSocket',\r\n 'Worker',\r\n 'SharedWorker',\r\n 'ServiceWorker',\r\n 'Proxy',\r\n]);\r\n\r\n/**\r\n * Security: Check if a constructor is safe to use\r\n */\r\nconst isConstructorSafe = (constructor: unknown, constructorName?: string): boolean => {\r\n if (typeof constructor !== 'function') {\r\n return false;\r\n }\r\n\r\n // Check if it's a dangerous constructor by name\r\n if (constructorName && DANGEROUS_CONSTRUCTORS.has(constructorName)) {\r\n return false;\r\n }\r\n\r\n // Special check for Function constructor and its variants\r\n if (constructor === Function ||\r\n constructor === (async function(){ /* async function constructor test */ }).constructor ||\r\n constructor === (function*(){ /* generator function constructor test */ }).constructor ||\r\n constructor === (async function*(){ /* async generator function constructor test */ }).constructor) {\r\n return false;\r\n }\r\n\r\n try {\r\n // Check constructor string for dangerous patterns\r\n const constructorString = constructor.toString();\r\n if (constructorString.includes('eval') ||\r\n constructorString.includes('Function(') ||\r\n constructorString.includes('constructor(')) {\r\n return false;\r\n }\r\n } catch {\r\n // If we can't get the constructor string, be cautious\r\n return false;\r\n }\r\n\r\n return true;\r\n};\r\n\r\n/**\r\n * Safely creates a new instance with proper security checks\r\n */\r\nconst safeNew = (constructor: unknown, args: unknown[], constructorName?: string): unknown => {\r\n if (!constructor) {\r\n throw new Error('Cannot instantiate undefined or null constructor');\r\n }\r\n\r\n if (typeof constructor !== 'function') {\r\n throw new Error(`Value is not a constructor: ${typeof constructor}`);\r\n }\r\n\r\n if (!isConstructorSafe(constructor, constructorName)) {\r\n throw new Error(`Constructor blocked for security reasons: ${constructorName || 'anonymous'}`);\r\n }\r\n\r\n try {\r\n return Reflect.construct(constructor as (...a: unknown[]) => unknown, args);\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(`Constructor error: ${error.message}`);\r\n }\r\n throw error;\r\n }\r\n};\r\n\r\nexport const newExpressionVisitor = (node: NewExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const args = evaluateArray(node, node.arguments, st, callback);\r\n\r\n callback(node.callee, st);\r\n\r\n const constructor = popVisitorResult(node, st);\r\n\r\n // Try to get constructor name for security checks\r\n let constructorName: string | undefined;\r\n if (node.callee.type === 'Identifier') {\r\n constructorName = node.callee.name;\r\n }\r\n\r\n const value = safeNew(constructor, args, constructorName);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n// Legacy function - now with security checks\r\nexport const newFunc = (constructor: (...a: unknown[]) => unknown, ...args: unknown[]) => {\r\n return safeNew(constructor, args);\r\n}\r\n","import { TemplateLiteral } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const templateLiteralVisitor = (node: TemplateLiteral, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const expressions = node.expressions.map((expression) => {\r\n callback(expression, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n const value = node.quasis.reduce((accumulator, templateElement, index) => {\r\n accumulator += templateElement.value.cooked;\r\n if (!templateElement.tail) {\r\n accumulator += expressions[index] ?? '';\r\n }\r\n return accumulator;\r\n }, '');\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n","import { TaggedTemplateExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { popVisitorResult, pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\nexport const taggedTemplateExpressionVisitor = (node: TaggedTemplateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.tag, st);\r\n const tag = popVisitorResult(node, st) as (...args: unknown[]) => unknown;\r\n\r\n const quasiExpressions = node.quasi.expressions.map((expression) => {\r\n callback(expression, st);\r\n const value = popVisitorResult(node, st);\r\n return value;\r\n });\r\n\r\n const quasi = node.quasi.quasis.map((templateElement) => {\r\n return templateElement.value.cooked;\r\n });\r\n\r\n const value = tag.apply(st.context, [quasi, ...quasiExpressions]);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { ObjectExpression, Property } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { createSafeObject, validateSafeObject } from './prototype-pollution-guard';\r\n\r\ntype KeyValuePair = {key: unknown; value: unknown};\r\n\r\nexport const objectExpressionVisitor = (node: ObjectExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n // Pre-allocate entries array for better performance\r\n const propertyCount = node.properties.length;\r\n const entries: Array<[unknown, unknown]> = [];\r\n \r\n for (let i = 0; i < propertyCount; i++) {\r\n const property = node.properties[i];\r\n \r\n if (property.type === 'SpreadElement') {\r\n callback(property.argument, st);\r\n const value = popVisitorResult(property, st) as object;\r\n \r\n // Validate spread object for safety\r\n try {\r\n validateSafeObject(value);\r\n } catch (error) {\r\n throw new Error(`Spread operation blocked: ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n \r\n // Use Object.entries() once and cache the result\r\n const spreadEntries = Object.entries(value);\r\n for (let j = 0; j < spreadEntries.length; j++) {\r\n const [key, val] = spreadEntries[j];\r\n entries.push([key, val]);\r\n }\r\n } else {\r\n const pair = evalProperty(property, st, callback);\r\n entries.push([pair.key, pair.value]);\r\n }\r\n }\r\n\r\n // Create safe object with prototype pollution protection\r\n try {\r\n const obj = createSafeObject(entries);\r\n pushVisitorResult(node, st, obj);\r\n } catch (error) {\r\n throw new Error(`Object creation blocked: ${error instanceof Error ? error.message : String(error)}`);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\nconst evalProperty = (property: Property, st: EvalState, callback: walk.WalkerCallback<EvalState>): KeyValuePair => {\r\n // if (property.shorthand) {\r\n // callback(property.value, st);\r\n // const value = popVisitorResult(property, st);\r\n // return { key: value, value };\r\n // } else\r\n if (property.computed) {\r\n callback(property.key, st);\r\n const key = popVisitorResult(property, st);\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else if (property.key.type === 'Identifier') {\r\n const key = property.key.name;\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else if (property.key.type === 'Literal') {\r\n const key = property.key.value;\r\n callback(property.value, st);\r\n const value = popVisitorResult(property, st);\r\n return { key, value };\r\n } else {\r\n throw new Error(`Unsupported property key type: ${property.key.type}`);\r\n }\r\n}\r\n","import {\r\n arrayExpressionVisitor, arrowFunctionExpressionVisitor, assignmentExpressionVisitor, awaitVisitor, binaryExpressionVisitor,\r\n callExpressionVisitor,conditionalExpressionVisitor, importExpressionVisitor,\r\n blockStatementVisitor, emptyStatementVisitor, expressionStatementVisitor,\r\n forStatementVisitor, ifStatementVisitor,\r\n identifierVisitor, literalVisitor, logicalExpressionVisitor,\r\n memberExpressionVisitor, newExpressionVisitor, objectExpressionVisitor,\r\n programVisitor, variableDeclarationVisitor,\r\n taggedTemplateExpressionVisitor, templateLiteralVisitor,\r\n thisExpressionVisitor, unaryExpressionVisitor, updateExpressionVisitor\r\n} from '../../internal/visitors';\r\n\r\nimport { EvalState } from '../classes/eval';\r\n\r\nimport * as walk from 'acorn-walk';\r\n\r\n\r\n\r\n/**\r\n * Returns the default visitors for the recursive traversal of an abstract syntax tree.\r\n * @returns The default visitors object.\r\n */\r\nexport const getDefaultVisitors = () => {\r\n\r\n const visitors: walk.RecursiveVisitors<EvalState> = {};\r\n\r\n visitors['BinaryExpression'] = binaryExpressionVisitor;\r\n visitors['Identifier'] = identifierVisitor;\r\n visitors['Literal'] = literalVisitor;\r\n visitors['CallExpression'] = callExpressionVisitor;\r\n visitors['ImportExpression'] = importExpressionVisitor;\r\n visitors['AwaitExpression'] = awaitVisitor;\r\n visitors['ConditionalExpression'] = conditionalExpressionVisitor;\r\n visitors['MemberExpression'] = memberExpressionVisitor;\r\n visitors['ArrayExpression'] = arrayExpressionVisitor;\r\n visitors['UnaryExpression'] = unaryExpressionVisitor;\r\n visitors['LogicalExpression'] = logicalExpressionVisitor;\r\n visitors['ThisExpression'] = thisExpressionVisitor;\r\n visitors['NewExpression'] = newExpressionVisitor;\r\n visitors['TemplateLiteral'] = templateLiteralVisitor;\r\n visitors['TaggedTemplateExpression'] = taggedTemplateExpressionVisitor;\r\n visitors['ObjectExpression'] = objectExpressionVisitor;\r\n visitors['AssignmentExpression'] = assignmentExpressionVisitor;\r\n visitors['UpdateExpression'] = updateExpressionVisitor;\r\n visitors['ArrowFunctionExpression'] = arrowFunctionExpressionVisitor;\r\n\r\n // The statement family. `Program` is the root of every walk that arrives\r\n // through `EvalService`, whose parser options leave `extractExpressions` off.\r\n visitors['Program'] = programVisitor;\r\n visitors['ExpressionStatement'] = expressionStatementVisitor;\r\n visitors['EmptyStatement'] = emptyStatementVisitor;\r\n visitors['BlockStatement'] = blockStatementVisitor;\r\n visitors['VariableDeclaration'] = variableDeclarationVisitor;\r\n visitors['IfStatement'] = ifStatementVisitor;\r\n visitors['ForStatement'] = forStatementVisitor;\r\n\r\n return visitors;\r\n}\r\n","import { ArrayPattern, Identifier, MemberExpression,\r\n ObjectPattern, Pattern, RestElement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { EvalState } from '../classes/eval';\r\nimport { popVisitorResult } from '.';\r\nimport { BaseContext } from '../classes/common';\r\nimport { safeSetProperty } from './prototype-pollution-guard';\r\n\r\n\r\n// based on evalArrowContext\r\n// https://github.com/6utt3rfly/jse-eval/blob/main/index.ts\r\n\r\n/**\r\n * The one answer this module gives to a binding target it does not implement.\r\n *\r\n * Both entry points used to fall out of their `switch` and return an empty\r\n * context - `evaluatePatterns` past a `case`-less type, `evaluatePattern` past\r\n * the `return {}` at the end - so `let { a = 1 } = o` and `((a = 1) => a)(x)`\r\n * bound nothing, threw nothing, and left the caller to read the miss as a\r\n * value. That is the shape `docs/backlog.md` A2 records three instances of in\r\n * the two write visitors, and Phase 2 requires a throwing `default:` in every\r\n * new statement dispatcher; a phase that promises not to add a fourth member of\r\n * that family cannot leave this one open either.\r\n *\r\n * `AssignmentPattern` is the reachable case - it is commented out below - and\r\n * the message names the node type so a consumer can tell which form was\r\n * rejected.\r\n */\r\nconst unsupportedBindingTarget = (type: string): never => {\r\n throw new Error(`${type} is not supported as a binding target.`);\r\n}\r\n\r\nexport const evaluatePatterns = (patterns: Pattern[], st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown[]) => {\r\n\r\n let context: BaseContext = {};\r\n\r\n patterns.map((pattern, i) => {\r\n switch (pattern.type) {\r\n case 'Identifier': {\r\n const object = evaluateIdentifier(pattern, st, args[i]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'MemberExpression': {\r\n const object = evaluateMemberExpression(pattern);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'ObjectPattern': {\r\n const object = evaluateObjectPattern(pattern, st, callback, args[i]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'ArrayPattern': {\r\n const object = evaluateArrayPattern(pattern, st, callback, args[i] as unknown[]);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n case 'RestElement': {\r\n const object = evaluateRestElement(pattern, st, callback, args.slice(i));\r\n context = {...context, ...object};\r\n }\r\n break;\r\n // case 'AssignmentPattern': {\r\n // const object = evaluateAssignmentPattern(pattern, st, callback, args[i]);\r\n // context = {...context, ...object};\r\n // }\r\n // break;\r\n default:\r\n unsupportedBindingTarget(pattern.type);\r\n }\r\n });\r\n\r\n return context;\r\n}\r\n\r\nexport const evaluatePattern = (pattern: Pattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown): BaseContext => {\r\n\r\n switch (pattern.type) {\r\n case 'Identifier':\r\n return evaluateIdentifier(pattern, st, arg);\r\n case 'MemberExpression':\r\n return evaluateMemberExpression(pattern);\r\n case 'ObjectPattern':\r\n return evaluateObjectPattern(pattern, st, callback, arg as unknown[]);\r\n case 'ArrayPattern':\r\n return evaluateArrayPattern(pattern, st, callback, arg as unknown[]);\r\n case 'RestElement':\r\n return evaluateRestElement(pattern, st, callback, arg);\r\n // case 'AssignmentPattern':\r\n // return evaluateAssignmentPattern(pattern, st, callback, arg);\r\n }\r\n\r\n return unsupportedBindingTarget(pattern.type);\r\n}\r\n\r\n// The binding write goes through the prototype-pollution guard, for the reason\r\n// the other three guarded visitors do: on a plain record `__proto__` is a\r\n// setter, so `let __proto__ = { … }` and `({ __proto__ }) => …` would replace\r\n// this object's prototype instead of naming a binding. Declarations are a new\r\n// way to reach this line - before Phase 2 only an arrow parameter did - so the\r\n// surface widened and the guard is what keeps the blocklist covering it.\r\nconst evaluateIdentifier = (pattern: Identifier, st: EvalState, arg: unknown) => {\r\n const object = {} as BaseContext;\r\n safeSetProperty(object, pattern.name, arg);\r\n return object;\r\n}\r\n\r\n// Module-private, and down to the one parameter it reads: deleting the log\r\n// below left `st`, `callback` and `arg` unused, and the two call sites are both\r\n// in this file.\r\nconst evaluateMemberExpression = (pattern: MemberExpression): BaseContext => {\r\n\r\n if (pattern.type === 'MemberExpression') {\r\n // The node type is the only part of this a caller could act on. What stood\r\n // here before was `console.log(pattern, st, callback, arg)` - `st` being the\r\n // whole EvalState, i.e. the caller's entire evaluation context dumped to the\r\n // console of any application whose user wrote that pattern. Unreachable\r\n // today because acorn rejects a MemberExpression binding target in a\r\n // parameter list, and deleted ahead of the work that widens what reaches\r\n // here. See docs/backlog.md B2.\r\n throw new Error(`${pattern.type} is not supported as a binding target.`);\r\n }\r\n\r\n return {} as BaseContext;\r\n}\r\n\r\nconst evaluateObjectPattern = (pattern: ObjectPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown) => {\r\n\r\n let context: BaseContext = {};\r\n\r\n pattern.properties.map((pattern) => {\r\n switch (pattern.type) {\r\n case 'Property': {\r\n let key: string | number;\r\n if (pattern.key.type === 'Identifier') {\r\n key = pattern.key.name;\r\n } else if (pattern.key.type === 'Literal') {\r\n key = pattern.key.value as string | number;\r\n } else {\r\n callback(pattern.key, st);\r\n key = popVisitorResult(pattern, st) as string | number;\r\n if (typeof key !== 'string' && typeof key !== 'number')\r\n throw new Error(`Unsupported property key type: ${pattern.key.type}`);\r\n }\r\n\r\n // **Where `let { a = 1 } = o` actually lands**, which is not where\r\n // it was expected to. A default in an object pattern is parsed as\r\n // `Property.value` of type `AssignmentPattern` - so it is handed to\r\n // `callback` below and walked as an *expression*, and reaches neither\r\n // of this module's two `switch` defaults. Rejecting it there would\r\n // have left the object form of the very example that names the\r\n // divergence still binding silently; the array form\r\n // (`let [a = 1] = arr`) and the parameter form (`(a = 1) => a`) do go\r\n // through `evaluatePatterns`, and are covered there.\r\n if (pattern.value.type === 'AssignmentPattern') {\r\n unsupportedBindingTarget(pattern.value.type);\r\n }\r\n\r\n const ctx = arg as BaseContext;\r\n\r\n // `finally`, for the reason given at the other push site in\r\n // arrow-function-expression.ts: the scope stack is on EvalContext,\r\n // which outlives this walk, so a scope left behind here shadows a\r\n // source key on every later evaluation against the same context.\r\n // The `try` opens after the push, never around it.\r\n st.context?.push(ctx);\r\n let value: BaseContext;\r\n try {\r\n callback(pattern.value, st);\r\n value = popVisitorResult(pattern, st) as BaseContext;\r\n } finally {\r\n st.context?.pop();\r\n }\r\n\r\n // Guarded for the same reason `evaluateIdentifier` is: the key comes\r\n // from the *pattern*, so `let { __proto__: p } = o` names `__proto__`\r\n // here and a raw assignment would set this record's prototype.\r\n const pair = {} as BaseContext;\r\n safeSetProperty(pair, key, value);\r\n\r\n context = {...context, ...pair};\r\n }\r\n break;\r\n case 'RestElement': {\r\n const object = evaluateRestElement(pattern, st, callback, arg);\r\n context = {...context, ...object};\r\n }\r\n break;\r\n }\r\n });\r\n\r\n return context;\r\n}\r\n\r\nconst evaluateArrayPattern = (pattern: ArrayPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown[]) => {\r\n const patterns = pattern.elements.filter(s => !!s) as Pattern[];\r\n const object = evaluatePatterns(patterns, st, callback, args);\r\n return object;\r\n}\r\n\r\nconst evaluateRestElement = (pattern: RestElement, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown) => {\r\n const argument = pattern.argument;\r\n const object = evaluatePattern(argument, st, callback, args);\r\n return object;\r\n}\r\n\r\n// const evaluateAssignmentPattern = (pattern: AssignmentPattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown) => {\r\n// const left = evaluatePattern(pattern.left, st, callback, args);\r\n// callback(pattern.right, st);\r\n// const value = popVisitorResult(pattern, st);\r\n// const object = {...left};\r\n// return object;\r\n// }\r\n","import { VariableDeclaration, VariableDeclarator } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { evaluatePattern } from './pattern';\r\nimport { isDangerousProperty } from './prototype-pollution-guard';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\nimport { Context } from '../classes/common';\r\n// Direct, not through the `common` barrel, which does not re-export it -\r\n// `eval-context.ts` reaches for the same helper the same way.\r\nimport { setContextValue } from '../classes/common/context';\r\n\r\n/**\r\n * The scope a declaration binds into: the innermost one on the stack.\r\n *\r\n * Read back from the stack rather than kept as a reference by whoever pushed\r\n * it, and that is the load-bearing half. `EvalContext.push` routes through\r\n * `fromContext`, which **copies** a plain record into a `Registry` when\r\n * `caseInsensitive` is set - so the object a visitor handed to `push` is not\r\n * always the object on the stack, and a binding written through the pre-push\r\n * record would be written into something nothing ever reads. It is also the\r\n * object `EvalState.declareConst` keys on, so both sides have to agree about\r\n * which one it is.\r\n *\r\n * Every route into a declaration pushes one first - `Program` for the top level,\r\n * `BlockStatement` for a block - so the absent case means the caller walked a\r\n * bare declaration node. Throwing is the answer rather than falling back to\r\n * `EvalContext.set`, which would write the caller's own context object: a `let`\r\n * that mutates the consumer's data is the behaviour this step exists to remove,\r\n * and doing it on an unsupported entry path would be the one place it survived.\r\n */\r\nconst bindingScope = (st: EvalState): Context => {\r\n\r\n const scope = st.context && st.context.scopes.length > 0\r\n ? st.context.scopes.peek()\r\n : undefined;\r\n\r\n if (!scope) {\r\n throw new Error('A variable declaration requires an enclosing scope.');\r\n }\r\n\r\n return scope;\r\n}\r\n\r\n/**\r\n * Binds one declarator's names into `scope`.\r\n *\r\n * The names come from `evaluatePattern`, which is the binder arrow-function\r\n * parameters already use - `Identifier` for the plain form, and the\r\n * `ObjectPattern` / `ArrayPattern` / `RestElement` forms for the destructuring\r\n * ones. Reusing it is what makes `let [p, q] = arr` work without a second\r\n * pattern implementation, and what makes a form it does not implement throw\r\n * (`AssignmentPattern`, i.e. `let { a = 1 } = o`) rather than bind nothing.\r\n *\r\n * The keys are re-checked against the pollution blocklist even though\r\n * `evaluatePattern` already wrote them through `safeSetProperty`. One line for\r\n * a guard that cannot be reasoned away from this call site: the record arrives\r\n * as a `BaseContext`, and the binder's own coverage of it is a property of\r\n * `pattern.ts` rather than of this module's contract with it.\r\n *\r\n * The write itself dispatches through `setContextValue`, not through\r\n * `safeSetProperty`. `safeSetProperty` finishes with `Object.defineProperty`,\r\n * which suits the plain records `pattern.ts` builds and **not** a scope: a\r\n * `caseInsensitive` scope is a Map-backed `Registry`, and defining a property\r\n * on the instance inserts nothing into its map. The binding would be written\r\n * and then not found, silently, for that option only.\r\n */\r\nconst bindDeclarator = (declarator: VariableDeclarator,\r\n value: unknown,\r\n kind: string,\r\n scope: Context,\r\n st: EvalState,\r\n callback: walk.WalkerCallback<EvalState>): void => {\r\n\r\n const bindings = evaluatePattern(declarator.id, st, callback, value);\r\n\r\n for (const key of Object.keys(bindings)) {\r\n if (isDangerousProperty(key)) {\r\n throw new Error(`Access to dangerous property \"${key}\" is blocked for security reasons`);\r\n }\r\n\r\n setContextValue(scope, key, bindings[key]);\r\n\r\n if (kind === 'const') {\r\n st.declareConst(scope, key);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Evaluates a variable declaration: `let` and `const`, in the plain and\r\n * destructuring forms.\r\n *\r\n * Pushes {@link EMPTY_COMPLETION} on every exit path - a declaration produces no\r\n * completion value in JavaScript, and the sentinel rather than `undefined` is\r\n * what keeps `let x = 1` from winning over an earlier statement's value inside a\r\n * block. Pops one value per declarator that has an initialiser, and none for one\r\n * that does not, which is the arithmetic § 3.1's table states for this visitor.\r\n *\r\n * **No hoisting.** A binding exists from the point its declaration is reached,\r\n * so a read before it resolves the enclosing context rather than raising a\r\n * temporal-dead-zone error. An uninitialised `let` binds `undefined` and still\r\n * *shadows*, because `EvalContext.get` resolves a pushed scope by presence\r\n * rather than by value.\r\n *\r\n * **`var` is rejected here, not by the statement dispatcher.** The dispatcher\r\n * switches on node *type*, and `var x = 1` is a `VariableDeclaration` exactly as\r\n * `let x = 1` is - so registering this visitor is what stopped `var` reaching the\r\n * throwing `default:`. Function-scoped hoisting is a second scoping model beside\r\n * block scoping and is out of scope for this phase, so the rejection had to move\r\n * rather than disappear.\r\n *\r\n * No scope is pushed here: a declaration binds into the scope its enclosing\r\n * statement list already pushed, so there is no `try`/`finally` to pair and\r\n * nothing this visitor can leave behind on `EvalContext`.\r\n */\r\nexport const variableDeclarationVisitor = (node: VariableDeclaration, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n // Above `beforeVisitor`, deliberately. Four paths through this visitor throw,\r\n // and three of them have to throw from inside the bracket - they need the\r\n // walk to have started. This one reads `node.kind` and nothing else, so\r\n // rejecting before the hook dispatch keeps the most reachable of the four\r\n // from opening a frame it never closes. The others are covered the way every\r\n // throwing visitor in this library is: `evaluate`'s `catch` unwinds the open\r\n // nodes to its walk base.\r\n if (node.kind !== 'let' && node.kind !== 'const') {\r\n throw new Error(`Unsupported variable declaration kind: ${node.kind}`);\r\n }\r\n\r\n beforeVisitor(node, st);\r\n\r\n const scope = bindingScope(st);\r\n\r\n for (const declarator of node.declarations) {\r\n\r\n let value: unknown = undefined;\r\n\r\n if (declarator.init) {\r\n callback(declarator.init, st);\r\n value = popVisitorResult(node, st);\r\n }\r\n\r\n bindDeclarator(declarator, value, node.kind, scope, st, callback);\r\n }\r\n\r\n pushVisitorResult(node, st, EMPTY_COMPLETION);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n/**\r\n * Assigns to `key`, preferring a binding the evaluation itself created.\r\n *\r\n * The shared write path for `assignment-expression.ts` and\r\n * `update-expression.ts`. It lives in this module rather than one of its own on\r\n * the precedent `dispatchStatement` set in `program.ts`: the `const` kinds it\r\n * enforces are recorded here, and two importers is not yet a utility module. A\r\n * third is when it earns one.\r\n *\r\n * Order matters, and both steps are one lookup:\r\n *\r\n * 1. `scopeHolding` finds the innermost pushed scope that **binds** the key, or\r\n * nothing. This is the same pass `EvalContext.get` resolves through, which is\r\n * why it is asked of the context rather than re-walked here.\r\n * 2. A `const` in that scope is rejected before anything is written.\r\n * 3. Otherwise `setInScope` writes it - and when no scope bound the key at all,\r\n * `set` does, which is the fallback `eval-signals` overrides to enforce its\r\n * read-only policy. Routing around it would disable that policy silently.\r\n *\r\n * **The scope is resolved twice - here, and again inside `setInScope` - and that\r\n * is a cost, not a free abstraction.** `scopeHolding` goes through\r\n * `Stack.asArray()`, which copies and reverses, so each pass allocates. An\r\n * identifier write therefore costs two short scans plus two small arrays where\r\n * the pre-Phase-2 `set` cost none.\r\n *\r\n * Kept because `setInScope` is the single place that knows how to write a scope\r\n * - a `Registry` under `caseInsensitive`, a plain record otherwise - and\r\n * writing directly from here would put that dispatch in two modules, which is\r\n * the one mistake in this area that is silent when made wrong. The honest\r\n * alternative is to let `setInScope` take an already-resolved scope; that widens\r\n * a signature this phase has published and is step 5's call, not this step's,\r\n * because step 5 is where the cost multiplies: `for (let i = 0; i < n; i++)`\r\n * runs this path once per iteration, on top of the `get` in the test and the\r\n * `get` in the update. Recorded in the plan's step 5 rather than left here.\r\n */\r\nexport const assignToBinding = (st: EvalState, key: unknown, value: unknown, name: string): void => {\r\n\r\n if (!st.context) {\r\n throw new Error(`Context is not set.`);\r\n }\r\n\r\n const scope = st.context.scopeHolding(key);\r\n\r\n if (!scope) {\r\n st.context.set(key, value);\r\n return;\r\n }\r\n\r\n if (st.isConstBinding(scope, key)) {\r\n throw new Error(`Assignment to constant variable \"${name}\".`);\r\n }\r\n\r\n st.context.setInScope(key, value);\r\n}\r\n","import { AssignmentExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { safeSetProperty } from './prototype-pollution-guard';\r\nimport { assignToBinding } from './variable-declaration';\r\n\r\nconst assignmentOperators = {\r\n '=': (left: number, value: number) => { return left = value; },\r\n '+=': (left: number, value: number) => { return left += value; },\r\n '-=': (left: number, value: number) => { return left -= value; },\r\n '*=': (left: number, value: number) => { return left *= value; },\r\n '/=': (left: number, value: number) => { return left /= value; },\r\n '%=': (left: number, value: number) => { return left %= value; },\r\n '**=': (left: number, value: number) => { return left **= value; },\r\n '<<=': (left: number, value: number) => { return left <<= value; },\r\n '>>=': (left: number, value: number) => { return left >>= value; },\r\n '>>>=': (left: number, value: number) => { return left >>>= value; },\r\n '&=': (left: number, value: number) => { return left &= value; },\r\n '^=': (left: number, value: number) => { return left ^= value; },\r\n '|=': (left: number, value: number) => { return left |= value; },\r\n '&&=': (left: number, value: number) => { return left &&= value; },\r\n '||=': (left: number, value: number) => { return left ||= value; },\r\n '??=': (left: number, value: number) => { return left ??= value; },\r\n};\r\n\r\n\r\nexport const assignmentExpressionVisitor = (node: AssignmentExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.left, st);\r\n\r\n const left = popVisitorResult(node, st) as number;\r\n\r\n callback(node.right, st);\r\n\r\n const right = popVisitorResult(node, st) as number;\r\n\r\n const func = assignmentOperators[node.operator];\r\n\r\n if (!func) {\r\n throw new Error(`Unsupported assignment operator: ${node.operator}`);\r\n } else if (!st.context) {\r\n throw new Error(`Context is not set.`);\r\n } else if (node.left.type === 'Identifier') {\r\n const key = st.options?.caseInsensitive\r\n ? st.context.getKey(node.left.name)\r\n : node.left.name;\r\n const value = func(left, right);\r\n // Scope first, the caller's object second. Before Phase 2 this was\r\n // `st.context.set(key, value)`, which consults no scope at all - so\r\n // `(x => (x = 99))(1)` wrote `99` into the caller's own object and left the\r\n // arrow's parameter untouched. See `assignToBinding` for why the fallback\r\n // to `set` is load-bearing rather than tidy.\r\n assignToBinding(st, key, value, node.left.name);\r\n pushVisitorResult(node, st, value);\r\n } else if (node.left.type === 'MemberExpression') {\r\n const [object, key, ] = evaluateMember(node.left, st, callback);\r\n const value = func(left, right);\r\n \r\n // Use safe property assignment to prevent prototype pollution\r\n safeSetProperty(object, key, value);\r\n \r\n pushVisitorResult(node, st, value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n","import { UpdateExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { evaluateMember } from './member-expression';\r\nimport { safeSetProperty } from './prototype-pollution-guard';\r\nimport { assignToBinding } from './variable-declaration';\r\n\r\nconst updateOperators = {\r\n '++': (value: number) => { return value + 1; },\r\n '--': (value: number) => { return value - 1; },\r\n};\r\n\r\nexport const updateExpressionVisitor = (node: UpdateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n if (!st.context) {\r\n throw new Error(`Context is not set.`);\r\n } else if (node.argument.type === 'Identifier') {\r\n const key = st.options?.caseInsensitive\r\n ? st.context.getKey(node.argument.name)\r\n : node.argument.name;\r\n const value = st.context?.get(key);\r\n const newValue = updateOperators[node.operator](value as number);\r\n // The same redirection as `assignment-expression.ts`, and the site that\r\n // matters for `for (let i = 0; …; i++)`: without it every loop counter this\r\n // library runs would be written into the consumer's context object, and\r\n // left there.\r\n assignToBinding(st, key, newValue, node.argument.name);\r\n pushVisitorResult(node, st, node.prefix ? newValue : value);\r\n } else if (node.argument.type === 'MemberExpression') {\r\n const [object, property, value] = evaluateMember(node.argument, st, callback);\r\n const newValue = updateOperators[node.operator](value as number);\r\n \r\n // Use safe property assignment to prevent prototype pollution\r\n safeSetProperty(object, property, newValue);\r\n \r\n pushVisitorResult(node, st, node.prefix ? newValue : value);\r\n }\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { AnyNode, Expression, ModuleDeclaration,\r\n Program, Statement, parse as _parse } from \"acorn\";\r\nimport { ParserOptions } from \"../interfaces\";\r\nimport * as acorn from 'acorn';\r\n\r\n/**\r\n* @description\r\n* Parses expression and returns ES6/ES2020 AST.\r\n* @param expr expression to parse\r\n* @param options parser options\r\n*/\r\nexport const parse = (expr: string, options: ParserOptions)\r\n : Program | AnyNode | undefined => {\r\n options = {ecmaVersion: 2020, ...options};\r\n const acornOptions: acorn.Options = {ecmaVersion: 2020, ...options};\r\n const program: Program = _parse(expr, acornOptions);\r\n if (!options.extractExpressions) {\r\n return program;\r\n }\r\n return extractExpression(program);\r\n}\r\n\r\n/**\r\n* @description\r\n* Walks through the AST and extracts first expression.\r\n* @param expr expression to parse\r\n*/\r\nexport const extractExpression = (program: Program)\r\n : Expression | undefined => {\r\n\r\n if (program.body.length === 1) {\r\n const expression: Statement | ModuleDeclaration = program.body[0];\r\n if (expression.type === 'ExpressionStatement') {\r\n return expression.expression as Expression;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n","import { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\nimport * as walk from 'acorn-walk';\r\nimport { getDefaultVisitors, popVisitorResult } from '../visitors';\r\nimport { AnyNode } from 'acorn';\r\n\r\n/**\r\n * Applies § 3.1's rule 4: the empty-completion sentinel never leaves an\r\n * evaluation's return value.\r\n *\r\n * It is converted here, at the walk boundary, rather than in the `Program`\r\n * visitor. `arrow-function-expression.ts` calls `evaluate` on a\r\n * `BlockStatement` for a block-bodied arrow, so a conversion sited in `Program`\r\n * would let `x => { }` hand the sentinel straight to a consumer. Converting\r\n * where the walk ends covers both entry points by construction.\r\n */\r\nconst completionValue = (value: unknown): unknown =>\r\n value === EMPTY_COMPLETION ? undefined : value;\r\n\r\n/**\r\n * The merged visitor table every walk dispatches through: this library's\r\n * visitors laid over `acorn-walk`'s base walker, built once.\r\n *\r\n * **`walk.recursive` merges per call, and the merge is not cheap.** Handed a\r\n * `funcs` object it calls `walk.make(funcs, base)`, which allocates an object\r\n * and copies every entry onto it - once per `evaluate`, not once per node.\r\n * Measured on the built bundle, walking a single `Literal`, which visits one\r\n * node and so is almost entirely this fixed cost:\r\n *\r\n * | visitor entries | per-call merge | merged once |\r\n * | --------------- | -------------- | ----------- |\r\n * | 19 (before statements) | 0.422 us | - |\r\n * | 22 (with statements) | 1.045 us | 0.226 us |\r\n *\r\n * Three more entries more than doubled it, which is a cliff rather than a\r\n * slope - the copy crosses a threshold where the engine stops treating the\r\n * result as a fast-property object. Merging once removes the whole class of\r\n * problem: it is faster than the pre-statement baseline, and it stops the\r\n * remaining statement visitors of this phase from making it worse again.\r\n *\r\n * `{}` is still passed as `funcs` at the call sites so that `make` has nothing\r\n * to copy; the per-walk object is then an empty `Object.create(DEFAULT_VISITORS)`\r\n * and every lookup is a prototype hit.\r\n *\r\n * Frozen, and lazily built, for two different reasons:\r\n *\r\n * - **Frozen** because this table is shared by every walk in the process -\r\n * `EvalService` is `providedIn: 'root'` - so a visitor that wrote to it would\r\n * reach every later evaluation, including other consumers'. Nothing writes to\r\n * it today; freezing is what keeps that true, turning a silent cross-walk\r\n * mutation into a throw. `getDefaultVisitors()` still returns a **fresh,\r\n * mutable** object to anyone who calls it, so no caller loses anything.\r\n * - **Lazily** because a module-level `const` deadlocks the flattened bundle:\r\n * `arrow-function-expression.ts` imports `evaluate`, so this module is\r\n * initialised first and `getDefaultVisitors()` at module scope reads that\r\n * visitor before its binding exists. Measured, not guessed - the built\r\n * package threw `Cannot access 'arrowFunctionExpressionVisitor' before\r\n * initialization` on import.\r\n */\r\nlet defaultVisitors: walk.RecursiveVisitors<EvalState> | undefined;\r\n\r\nconst mergedVisitors = (): walk.RecursiveVisitors<EvalState> =>\r\n (defaultVisitors ??= Object.freeze(walk.make<EvalState>(getDefaultVisitors())));\r\n\r\n/**\r\n * Evaluates the given node and returns the result.\r\n *\r\n * @param node The node to evaluate.\r\n * @param state The evaluation state.\r\n * @returns The result of the evaluation.\r\n */\r\nexport const evaluate = (node: AnyNode | undefined, state: EvalState)\r\n : unknown | undefined => {\r\n\r\n if (node) {\r\n\r\n state.result.start();\r\n\r\n // Captured inside the `if (node)` block on purpose: callers reach the early\r\n // return above with a bare state that has no hooks to read. Do not hoist.\r\n //\r\n // The mark is recorded on the state as well as held here, so that\r\n // `EvalHooks.exit` - called from a visitor, which has no route to this\r\n // local - can tell a node open in this walk from one open only in an\r\n // enclosing walk. Pushed under the same guard the mark is read under, and\r\n // the local `hooked` keeps the pair symmetric if a hook is registered\r\n // mid-walk.\r\n const hooked = state.hasHooks;\r\n const mark = hooked ? state.hooks.pushWalkBase(state) : 0;\r\n\r\n // Unguarded, unlike the walk base above: the iteration budget refills on\r\n // the outermost entry whether or not hooks are registered. See\r\n // `EvalState.walkDepth` on why these are two fields and not one.\r\n state.enterWalk();\r\n\r\n try {\r\n walk.recursive(node, state, {}, mergedVisitors());\r\n\r\n const value = completionValue(popVisitorResult(node, state))\r\n\r\n state.result.stop();\r\n\r\n state.result.setSuccess(value);\r\n\r\n return value;\r\n } catch (error) {\r\n state.result.stop();\r\n // A visitor that throws skips its afterVisitor, so close whatever this\r\n // walk left open. Unwinding to the mark rather than to the bottom is what\r\n // stops a nested evaluate - the arrow-function body runs on this same\r\n // state - from draining the enclosing walk's open nodes.\r\n // Reads `state.hasHooks` rather than the `hooked` local captured above,\r\n // and the difference is deliberate but narrow: if a hook was registered\r\n // *during* this walk then `hooked` is false, no base was pushed, `mark`\r\n // is 0, and this unwinds the whole stack - including an enclosing walk's\r\n // frames, which is the boundary crossing the walk base exists to stop.\r\n // Left as it was rather than tightened here, because narrowing it would\r\n // change what a mid-walk registration observes on an already-published\r\n // path, which is not this step's to decide.\r\n if (state.hasHooks) {\r\n state.hooks.unwindTo(mark, error, state);\r\n }\r\n state.result.setFailure(error);\r\n throw error;\r\n } finally {\r\n // Both in a `finally`: a walk that threw still has to restore the\r\n // enclosing walk's bound and depth, or every later evaluation on this\r\n // state carries this one's nesting.\r\n state.exitWalk();\r\n if (hooked) {\r\n state.hooks.popWalkBase(state);\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Converts a rejection value to a proper Error object\r\n */\r\nconst ensureError = (rejection: unknown): Error => {\r\n if (rejection instanceof Error) {\r\n return rejection;\r\n }\r\n \r\n if (typeof rejection === 'string') {\r\n return new Error(rejection);\r\n }\r\n \r\n if (rejection === null) {\r\n return new Error('Promise rejected with null');\r\n }\r\n \r\n if (rejection === undefined) {\r\n return new Error('Promise rejected with undefined');\r\n }\r\n \r\n if (typeof rejection === 'object') {\r\n return new Error(`Promise rejected with object: ${JSON.stringify(rejection)}`);\r\n }\r\n \r\n return new Error(`Promise rejected with value: ${String(rejection)}`);\r\n};\r\n\r\n/**\r\n * Recursively awaits all promises in a value structure\r\n */\r\nconst awaitAllPromises = async (value: unknown): Promise<unknown> => {\r\n if (!value || typeof value !== 'object') {\r\n return value;\r\n }\r\n \r\n // If it's a promise, await it and handle rejections\r\n if ('then' in value) {\r\n try {\r\n return await (value as Promise<unknown>);\r\n } catch (rejection) {\r\n throw ensureError(rejection);\r\n }\r\n }\r\n \r\n // If it's an array, recursively await all elements\r\n if (Array.isArray(value)) {\r\n return Promise.all(value.map(item => awaitAllPromises(item)));\r\n }\r\n \r\n // If it's an object, recursively await all properties\r\n if (value.constructor === Object) {\r\n const result: Record<string, unknown> = {};\r\n const promises = Object.entries(value).map(async ([key, val]) => {\r\n result[key] = await awaitAllPromises(val);\r\n });\r\n await Promise.all(promises);\r\n return result;\r\n }\r\n \r\n return value;\r\n};\r\n\r\n/**\r\n * Asynchronously evaluates the given abstract syntax tree (AST) using the provided evaluation state.\r\n * @param ast The abstract syntax tree to evaluate.\r\n * @param state The evaluation state.\r\n * @returns A promise that resolves to the evaluated value or undefined.\r\n */\r\nexport const evaluateAsync = async (ast: AnyNode | undefined, state: EvalState)\r\n : Promise<unknown | undefined> => {\r\n\r\n if (!ast) {\r\n return undefined;\r\n }\r\n\r\n state.result.start();\r\n\r\n // Captured after the `!ast` early return above, for the same reason the sync\r\n // entry point captures inside its `if (node)` block. Do not hoist.\r\n const hooked = state.hasHooks;\r\n const mark = hooked ? state.hooks.pushWalkBase(state) : 0;\r\n\r\n state.enterWalk();\r\n\r\n try {\r\n let value: unknown;\r\n\r\n // The walk bookkeeping is released here rather than in a `finally` on the\r\n // outer try, because the walk ends here: everything below this block is\r\n // promise resolution on an already-finished traversal. Holding the walk\r\n // base and the depth across the `await` would leave an independent\r\n // evaluation that interleaved on this state looking like a nested walk -\r\n // and § 3.4's budget refills only on the outermost entry.\r\n try {\r\n walk.recursive(ast, state, {}, mergedVisitors());\r\n\r\n value = completionValue(popVisitorResult(ast, state));\r\n } finally {\r\n state.exitWalk();\r\n if (hooked) {\r\n state.hooks.popWalkBase(state);\r\n }\r\n }\r\n\r\n // Enhanced promise handling - recursively await all promises\r\n try {\r\n value = await awaitAllPromises(value);\r\n } catch (promiseError) {\r\n // Ensure proper error handling for promise rejections\r\n const error = ensureError(promiseError);\r\n state.result.stop();\r\n state.result.setFailure(error);\r\n throw error;\r\n }\r\n\r\n state.result.stop();\r\n state.result.setSuccess(value);\r\n \r\n return value;\r\n } catch (error) {\r\n state.result.stop();\r\n // The walk here is synchronous too, so it strands open nodes on a throw\r\n // exactly as the sync entry point does. This catch also receives the\r\n // rethrow from the awaitAllPromises handler above; in that case the walk\r\n // had already closed every node it opened, the depth is back at the mark,\r\n // and unwindTo correctly synthesises nothing.\r\n if (state.hasHooks) {\r\n state.hooks.unwindTo(mark, error, state);\r\n }\r\n state.result.setFailure(error);\r\n throw error;\r\n }\r\n}\r\n","import { AnyNode } from 'acorn';\r\nimport { EvalState } from '../classes/eval';\r\nimport { evaluate, evaluateAsync } from './evaluate';\r\n\r\nexport type stateCallback = (state: EvalState) => unknown;\r\nexport type stateCallbackAsync = (state: EvalState) => Promise<unknown | undefined>;\r\n\r\n/**\r\n * Compiles the given node and returns a function that can be used to evaluate it.\r\n *\r\n * @param node The node to compile.\r\n * @returns A function that takes an `EvalState` and returns the result of evaluating the node.\r\n */\r\nexport const compile = (node: AnyNode | undefined): stateCallback => {\r\n\r\n return evaluate.bind(null, node);\r\n}\r\n\r\n/**\r\n * Compiles the given node asynchronously.\r\n *\r\n * @param node - The node to compile.\r\n * @returns A function that takes an `EvalState` object and returns a `Promise` that resolves to the compiled result.\r\n */\r\nexport const compileAsync = (node: AnyNode | undefined): stateCallbackAsync => {\r\n\r\n return evaluateAsync.bind(null, node);\r\n}\r\n\r\n/**\r\n * Calls the provided function with the given state and returns the result.\r\n *\r\n * @param fn The function to be called.\r\n * @param state The state to be passed to the function.\r\n * @returns The result of calling the function.\r\n */\r\nexport const call = (fn: stateCallback, state: EvalState): unknown | undefined => {\r\n const value = fn(state);\r\n return value;\r\n}\r\n\r\n/**\r\n * Calls an asynchronous function with the given state and returns a promise that resolves to the result.\r\n * @param fn The asynchronous function to call.\r\n * @param state The state to pass to the function.\r\n * @returns A promise that resolves to the result of the function.\r\n */\r\nexport const callAsync = (fn: stateCallbackAsync, state: EvalState): Promise<unknown | undefined> => {\r\n const promise = fn(state);\r\n return promise;\r\n}\r\n","import * as walk from 'acorn-walk';\r\nimport { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../interfaces';\r\n\r\n/**\r\n * Finds all nodes of a specific type in the given AST.\r\n *\r\n * @param ast The AST to search in.\r\n * @param searchType The type of nodes to search for.\r\n * @returns An array of nodes of the specified type if found, otherwise undefined.\r\n */\r\nexport const extract = (node: AnyNode | undefined,\r\n searchType: AnyNodeTypes): AnyNode[] | undefined => {\r\n if (node) {\r\n\r\n const state: AnyNode[] = [];\r\n\r\n const visitors: walk.SimpleVisitors<AnyNode[]> = {\r\n [searchType]: (node: AnyNode,) => { state.push(node); return; }\r\n };\r\n\r\n walk.simple(node, visitors);\r\n\r\n return state.length > 0 ? state : undefined;\r\n }\r\n return undefined;\r\n}\r\n\r\n","import { ArrowFunctionExpression } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { EvalState } from '../classes/eval';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { evaluate } from '../functions';\r\nimport { evaluatePatterns } from '.';\r\n\r\nexport const arrowFunctionExpressionVisitor = (node: ArrowFunctionExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n const fn = (...arrowArgs: unknown[]) => {\r\n const newContext = evaluatePatterns(node.params, st, callback, arrowArgs);\r\n\r\n // The scope stack lives on EvalContext, not on the per-walk EvalState, and\r\n // one EvalContext can back any number of evaluations - so a scope this\r\n // closure fails to pop outlives the walk and is read first by every later\r\n // evaluation on the same context. The body is re-entrant `evaluate`, which\r\n // rethrows, so the pop needs `finally`.\r\n //\r\n // The `try` opens *after* the push, never around it. `push` is optionally\r\n // chained: bringing it inside would pair a `finally` pop with a push that\r\n // the same optional chain had skipped, and would swallow a throw from\r\n // evaluatePatterns into a pop as well.\r\n st.context?.push(newContext);\r\n try {\r\n return evaluate(node.body, st);\r\n } finally {\r\n st.context?.pop();\r\n }\r\n }\r\n\r\n pushVisitorResult(node, st, fn);\r\n\r\n afterVisitor(node, st);\r\n}\r\n\r\n\r\n","import { ModuleDeclaration, Statement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Walks one statement and returns its completion value.\r\n *\r\n * The statement dispatcher for the whole family, and the single place § 3.1's\r\n * rule 2 - one `popVisitorResult` per `callback` - is discharged for every\r\n * caller. Four visitors import it: `Program` and `BlockStatement` walk a\r\n * statement list, `IfStatement` a branch, and `ForStatement` an `init` and a\r\n * body.\r\n *\r\n * **It is explicit, and its `default` throws.** A node type this library does\r\n * not implement raises rather than falling through to `acorn-walk`'s base\r\n * walker, which would visit the subtree as an expression and strand whatever it\r\n * pushed - `while (false) { 1 }` used to evaluate to `1` that way. Three\r\n * visitors in this library already push nothing on one path of an `if`/`else if`\r\n * chain over node types (`docs/backlog.md` A2); a `switch` whose `default`\r\n * throws is how this family gains no fourth member.\r\n *\r\n * **Why this module exists.** It lived in `program.ts` for steps 1 to 5, on the\r\n * rule that a shared helper earns its own file at its *third* importer -\r\n * otherwise a visitor module has quietly become a utility module that also\r\n * happens to export a visitor. `if-statement.ts` met that condition in step 4,\r\n * which recorded it MET AND DEFERRED rather than unmet: no step's file list\r\n * admitted creating a module and rewriting three imports, and step 4 was not the\r\n * place to widen its own scope. The plan named step 6 as the date so that\r\n * `ForStatement` would not arrive in step 5 as a *fourth* importer against a\r\n * rule that had declined to fire twice. This is that move. The rejection surface\r\n * did not change with it - a pure relocation, gated by the existing suite.\r\n *\r\n * @returns the statement's completion value, which is `EMPTY_COMPLETION`\r\n * (`../classes/eval`) for a statement that produced nothing. The sentinel is not\r\n * imported here: this module never compares against it, and an import kept only\r\n * for a doc link is an unused binding the lint config rejects.\r\n */\r\nexport const dispatchStatement = (\r\n statement: Statement | ModuleDeclaration,\r\n st: EvalState,\r\n callback: walk.WalkerCallback<EvalState>\r\n): unknown => {\r\n\r\n switch (statement.type) {\r\n // `VariableDeclaration` covers `var` as well, and cannot not: this `switch`\r\n // reads the node *type*, and `var x = 1` is a `VariableDeclaration` exactly\r\n // as `let x = 1` is. Listing it here is therefore what stopped `var`\r\n // reaching the `default:` below; the rejection moved into the visitor,\r\n // which can read `kind`.\r\n //\r\n // `ForStatement` is the classic three-part form *only*. `ForOfStatement`,\r\n // `ForInStatement`, `WhileStatement` and `DoWhileStatement` are distinct\r\n // node types and stay out of the phase (§ 2), so they reach the `default`\r\n // below unchanged - unlike `var`, which shares a type with `let` and had to\r\n // be rejected one level down.\r\n case 'ExpressionStatement':\r\n case 'EmptyStatement':\r\n case 'BlockStatement':\r\n case 'VariableDeclaration':\r\n case 'IfStatement':\r\n case 'ForStatement':\r\n callback(statement, st);\r\n return popVisitorResult(statement, st);\r\n default:\r\n throw new Error(`Unsupported statement type: ${statement.type}`);\r\n }\r\n}\r\n","import { Program } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { dispatchStatement } from './dispatch-statement';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates a program: the root node of every walk that reaches this library\r\n * through `EvalService`, since its parser options leave `extractExpressions`\r\n * off and so hand `evaluate` the whole `Program`.\r\n *\r\n * Keeps the last **non-empty** completion value, per JavaScript's\r\n * completion-value semantics, and pushes exactly one value however many\r\n * statements the body holds. A program whose statements all produced nothing -\r\n * `;`, or a source that is only whitespace - pushes {@link EMPTY_COMPLETION},\r\n * which the walk boundary in `evaluate` converts to `undefined`. The conversion\r\n * is deliberately not done here: `arrow-function-expression.ts` calls\r\n * `evaluate` on a `BlockStatement` for a block-bodied arrow, so a `Program`-side\r\n * conversion would leave that entry point handing the sentinel to a consumer.\r\n *\r\n * **The program-level scope is required.** It is the only scope a top-level\r\n * `let` can bind into; without it a declaration would have nowhere to go but\r\n * `EvalContext.set`, which writes the caller's own context object - and is the\r\n * method `eval-signals` overrides to enforce its read-only policy. `get`\r\n * searches `scopes` first and falls through on a miss, so an empty program\r\n * scope costs no outer resolution.\r\n *\r\n * The pop is in a `finally` because the scope stack lives on `EvalContext`, not\r\n * on the per-walk `EvalState`, and one context can back any number of\r\n * evaluations: a scope this visitor failed to pop would outlive the walk and be\r\n * read first by every later evaluation on that context. The `try` opens *after*\r\n * the push, never around it - `push` is optionally chained, so bringing it\r\n * inside would pair a `finally` pop with a push the same optional chain had\r\n * skipped.\r\n */\r\nexport const programVisitor = (node: Program, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n let completion: unknown = EMPTY_COMPLETION;\r\n\r\n st.context?.push({}, st.options);\r\n try {\r\n for (const statement of node.body) {\r\n const value = dispatchStatement(statement, st, callback);\r\n if (value !== EMPTY_COMPLETION) {\r\n completion = value;\r\n }\r\n }\r\n } finally {\r\n st.context?.pop();\r\n }\r\n\r\n pushVisitorResult(node, st, completion);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { ExpressionStatement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates an expression statement: its completion value is its expression's.\r\n *\r\n * A pass-through, and registered rather than left to `acorn-walk`'s base walker\r\n * for two reasons. The base walker fires no hooks, so a statement would be\r\n * invisible to a consumer watching the walk; and § 3.1's rule that every\r\n * statement visitor pushes exactly one value would have an exception whose only\r\n * justification is that this one happens to be cheap.\r\n */\r\nexport const expressionStatementVisitor = (node: ExpressionStatement, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.expression, st);\r\n\r\n const value = popVisitorResult(node, st);\r\n\r\n pushVisitorResult(node, st, value);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { EmptyStatement } from 'acorn';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates an empty statement: it produces nothing, so it pushes\r\n * {@link EMPTY_COMPLETION} and an enclosing statement list keeps whatever\r\n * preceded it.\r\n *\r\n * One line of behaviour, and it exists because the statement dispatcher's\r\n * `default` throws: without it `a;;b` and `if (x) ;` would start raising\r\n * \"unsupported statement type\", which is a divergence from JavaScript nobody\r\n * chose.\r\n */\r\nexport const emptyStatementVisitor = (node: EmptyStatement, st: EvalState) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n pushVisitorResult(node, st, EMPTY_COMPLETION);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { BlockStatement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult } from './visitor-result';\r\nimport { dispatchStatement } from './dispatch-statement';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates a block statement: a scope, a statement list, and one completion\r\n * value.\r\n *\r\n * Keeps the last **non-empty** completion value, per JavaScript's\r\n * completion-value semantics, and pushes exactly one value however many\r\n * statements the body holds. A block whose statements all produced nothing -\r\n * `{ }`, or `{ ; }` - pushes {@link EMPTY_COMPLETION} for its enclosing\r\n * statement list to skip over. The sentinel is converted to `undefined` at the\r\n * walk boundary in `evaluate`, which is why this visitor may return it to a\r\n * caller that is itself a walk root: `arrow-function-expression.ts` calls\r\n * `evaluate` on this node for a block-bodied arrow, so `x => { }` reaches a\r\n * consumer through the same conversion a `Program` does.\r\n *\r\n * **The block scope is unobservable in this step, and is pushed anyway.**\r\n * Nothing binds into it until `VariableDeclaration` lands, and an empty scope\r\n * shadows nothing now that `EvalContext.get` resolves a scope by presence\r\n * rather than by value. Pushing it here rather than with the first binding\r\n * keeps the scope arithmetic in one place: the depth a nested block reports is\r\n * a property of the block, not of whether its body happened to declare\r\n * anything.\r\n *\r\n * `st.options` is passed to `push` because `fromContext` copies a plain record\r\n * into a `Registry` when `caseInsensitive` is set. Omitting them would make a\r\n * block's bindings case-**sensitive** inside an otherwise case-insensitive\r\n * evaluation - a silent wrong answer rather than an error, and one no assertion\r\n * in this step can reach, since a scope nothing binds into resolves nothing\r\n * either way.\r\n *\r\n * The pop is in a `finally` because the scope stack lives on `EvalContext`, not\r\n * on the per-walk `EvalState`, and one context can back any number of\r\n * evaluations: a scope this visitor failed to pop would outlive the walk and be\r\n * read first by every later evaluation on that context. The `try` opens *after*\r\n * the push, never around it - `push` is optionally chained, so bringing it\r\n * inside would pair a `finally` pop with a push the same optional chain had\r\n * skipped.\r\n */\r\nexport const blockStatementVisitor = (node: BlockStatement, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n let completion: unknown = EMPTY_COMPLETION;\r\n\r\n st.context?.push({}, st.options);\r\n try {\r\n for (const statement of node.body) {\r\n const value = dispatchStatement(statement, st, callback);\r\n if (value !== EMPTY_COMPLETION) {\r\n completion = value;\r\n }\r\n }\r\n } finally {\r\n st.context?.pop();\r\n }\r\n\r\n pushVisitorResult(node, st, completion);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { IfStatement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { dispatchStatement } from './dispatch-statement';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates an `if` statement: one test, and **exactly one branch or neither**.\r\n *\r\n * The behavioural fix in the plan's § 1.1 table. `acorn-walk`'s base walker\r\n * visits both branches regardless of the test, so `if (a) { 1 } else { 2 }` with\r\n * `a` true measured `2` - the `else` value was pushed last and won - and any\r\n * call or assignment in the untaken branch had already run. The value was the\r\n * smaller half of that: a visitor that walked both branches and then *selected*\r\n * by the test would return `1` and still run them both, which is why the specs\r\n * assert on an uncalled `jest.fn` and an unwritten source key beside the value.\r\n *\r\n * Completion value, per § 3.1: the branch's own, unchanged. A taken branch that\r\n * produced nothing propagates {@link EMPTY_COMPLETION} - `if (true) { }` pushes\r\n * the sentinel exactly as `if (false) { 1 }` does, by two different routes - and\r\n * a branch that genuinely produced `undefined` pushes that, so an enclosing\r\n * statement list keeps it over an earlier value. Mapping either onto the other\r\n * here would collapse the distinction the sentinel exists for.\r\n *\r\n * Arithmetic: pops 1 for the test, plus 1 for the branch when one runs; pushes\r\n * exactly 1 on both exit paths.\r\n *\r\n * **The branches go through `dispatchStatement`, not a raw `callback`.** A\r\n * branch is a `Statement`, and a raw callback would hand a type this library\r\n * does not implement to the base walker, which walks it as an expression and\r\n * strands whatever it pushed. That is the silent fall-through family § 1.7\r\n * names and § 3.1 promises to add no member to.\r\n *\r\n * **The margin is narrower than it first looks, and the specs say so where an\r\n * earlier draft of this docblock did not.** Every registered statement type -\r\n * `BlockStatement`, `ExpressionStatement`, `IfStatement` itself for an\r\n * `else if` chain, `VariableDeclaration` - is reached by a raw `callback` just\r\n * as well, because `acorn-walk` finds the registered visitor before it reaches\r\n * its base walker. So neither `if (a) { while (false) { 1 } }` nor an `else if`\r\n * chain discriminates: the block re-dispatches, and the chain arrives back here\r\n * either way. The one position that does is a **bare** branch body of an\r\n * unregistered type - `if (a) function f() { }` - where nothing stands between\r\n * this visitor and the base walker. Measured: swapping in a raw callback reddens\r\n * that case alone.\r\n *\r\n * It is still the right call, for the reason `dispatch-statement.ts` gives rather\r\n * than for a reason the suite can show: rule 2's single `callback`/`pop` pair\r\n * lives in one place, so the guarantee holds for whatever bare statement type a\r\n * later phase registers without this visitor being revisited.\r\n *\r\n * This visitor was `dispatchStatement`'s **third** importer, which is the\r\n * condition for giving it a module of its own. **Step 6 made that move**: the\r\n * dispatcher now lives in `dispatch-statement.ts`, with the rule and its history\r\n * in that module's docblock.\r\n *\r\n * **It pushes no scope, and there is no `try`/`finally` to pair.** Four routes a\r\n * binding could arrive by, all closed: a block body gets its scope from\r\n * `blockStatementVisitor`; `if (a) let x = 1` does not parse, since a lexical\r\n * declaration is not a legal bare statement body; `if (a) var x = 1` does parse,\r\n * reaches the dispatcher as a `VariableDeclaration`, and is rejected on `kind`\r\n * inside `variableDeclarationVisitor`; and `if (a) function f() { }` parses\r\n * under Annex B and is rejected by `dispatchStatement`'s throwing `default`.\r\n *\r\n * **The fourth is closed by the dispatcher and not by anything here**, which is\r\n * the one a later phase can reopen: a phase that registers `FunctionDeclaration`\r\n * gives this visitor a bare binding form with no enclosing block, and the\r\n * no-scope argument has to be re-made rather than inherited. `if (a) label: var\r\n * x = 1` is the same family. As of this step this visitor touches `EvalContext`\r\n * not at all, and the balance its specs assert on a reused context is the\r\n * enclosing visitors' to keep.\r\n */\r\nexport const ifStatementVisitor = (node: IfStatement, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n callback(node.test, st);\r\n\r\n const test = popVisitorResult(node, st);\r\n\r\n let completion: unknown = EMPTY_COMPLETION;\r\n\r\n if (test) {\r\n completion = dispatchStatement(node.consequent, st, callback);\r\n } else if (node.alternate) {\r\n completion = dispatchStatement(node.alternate, st, callback);\r\n }\r\n\r\n pushVisitorResult(node, st, completion);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { ForStatement } from 'acorn';\r\nimport * as walk from 'acorn-walk';\r\nimport { beforeVisitor } from './before-visitor';\r\nimport { afterVisitor } from './after-visitor';\r\nimport { pushVisitorResult, popVisitorResult } from './visitor-result';\r\nimport { dispatchStatement } from './dispatch-statement';\r\nimport { EMPTY_COMPLETION, EvalState } from '../classes/eval';\r\n\r\n/**\r\n * Evaluates a classic three-part `for` statement.\r\n *\r\n * § 1.1's row measured **`NaN`** with three stranded values before Phase 2: the\r\n * base walker handed the declarator's `id` to `identifierVisitor`, so `i`\r\n * resolved against the context rather than binding, and `i < 3` compared\r\n * `undefined`. Since step 1 the row throws from `dispatchStatement`'s `default`;\r\n * this visitor is what returns `2`.\r\n *\r\n * `for…of`, `for…in`, `while` and `do…while` stay out of the phase (§ 2) and\r\n * keep throwing - they are separate node types and reach the dispatcher's\r\n * `default` unchanged.\r\n *\r\n * **One scope for the loop, not one per iteration.** A draft of the plan\r\n * specified a fresh scope per iteration, seeded from the head and copied back\r\n * after `update`, on the reasoning that this is what makes a closure capture its\r\n * own iteration's binding. It makes **no observable difference here**: the\r\n * closure `arrow-function-expression.ts` builds captures `st`, not a scope\r\n * chain, and resolves its free variables against `st.context` *as it is when the\r\n * closure is called* - by which time this loop has popped everything it pushed.\r\n * So the per-iteration design would have allocated a scope and copied bindings\r\n * twice per iteration to buy a property no spec can assert (§ 3.6.5). Giving\r\n * closures a captured scope chain is real work in\r\n * `arrow-function-expression.ts` and is what a later phase would have to do\r\n * first.\r\n *\r\n * **`init` has two node shapes and they take two routes.** `for (let i = 0; …)`\r\n * parses `init` as a `VariableDeclaration`, which is a `Statement` and goes\r\n * through `dispatchStatement`; `for (i = 0; …)` parses it as an `Expression` and\r\n * takes a raw `callback`. Both pop exactly one - the declaration's `EMPTY`, or\r\n * the expression's value - so § 3.1's arithmetic is identical for the two and\r\n * the split is invisible to it. What depends on the split is the throwing\r\n * `default`: only the `dispatchStatement` route has one, so an `init` that is a\r\n * statement type this library does not implement is rejected rather than handed\r\n * to the base walker. `body` is a `Statement` and dispatches for the same\r\n * reason; `test` and `update` are expressions and do not.\r\n *\r\n * Arithmetic (§ 3.1): pops 1 for `init` when present, then per iteration 1 for\r\n * `test` (when present), 1 for `body` and 1 for `update` (when present) - one\r\n * per `callback` or `dispatchStatement`, as rule 2 requires. Pushes exactly one\r\n * value on every exit path: the last **non-empty** body value, or\r\n * {@link EMPTY_COMPLETION} when the loop ran zero iterations or every iteration\r\n * produced nothing. An absent `test` is `true`.\r\n *\r\n * **The budget is the only terminator for `for (;;)`** - with no `break`,\r\n * `continue` or `return` in this phase (§ 2) there is no other way out, and a\r\n * runaway loop that silently returned a partial value is the failure § 3.4\r\n * exists to prevent. `chargeIteration` throws when the budget is spent; it is\r\n * called from this loop and nowhere else in the library, which is why an\r\n * expression with no `for` in it pays nothing for the bound.\r\n *\r\n * The pop is in a `finally` because the scope stack lives on `EvalContext`, not\r\n * on the per-walk `EvalState`, and one context can back any number of\r\n * evaluations: a scope this visitor failed to pop would outlive the walk and be\r\n * read first by every later evaluation on that context. This is the visitor with\r\n * the **highest push multiplicity** in the family and the shape of A9's own\r\n * precondition argument - a `for` body throwing on iteration 3 - so every exit\r\n * path matters: `init`, `test`, `body` and `update` can each throw, the\r\n * dispatcher can reject the body, and the budget can end the loop from inside\r\n * the `try`. The `try` opens *after* the push, never around it - `push` is\r\n * optionally chained, so bringing it inside would pair a `finally` pop with a\r\n * push the same optional chain had skipped.\r\n */\r\nexport const forStatementVisitor = (node: ForStatement, st: EvalState, callback: walk.WalkerCallback<EvalState>) => {\r\n\r\n beforeVisitor(node, st);\r\n\r\n let completion: unknown = EMPTY_COMPLETION;\r\n\r\n st.context?.push({}, st.options);\r\n try {\r\n\r\n if (node.init) {\r\n if (node.init.type === 'VariableDeclaration') {\r\n dispatchStatement(node.init, st, callback);\r\n } else {\r\n callback(node.init, st);\r\n popVisitorResult(node, st);\r\n }\r\n }\r\n\r\n for (;;) {\r\n\r\n if (node.test) {\r\n callback(node.test, st);\r\n if (!popVisitorResult(node, st)) {\r\n break;\r\n }\r\n }\r\n\r\n // Charged once the test has admitted the iteration, so a loop that runs\r\n // `n` bodies charges `n` - which is what `iterationsRemaining` is asserted\r\n // against - and a loop whose test is false at the top charges nothing.\r\n st.chargeIteration();\r\n\r\n const value = dispatchStatement(node.body, st, callback);\r\n if (value !== EMPTY_COMPLETION) {\r\n completion = value;\r\n }\r\n\r\n if (node.update) {\r\n callback(node.update, st);\r\n popVisitorResult(node, st);\r\n }\r\n }\r\n\r\n } finally {\r\n st.context?.pop();\r\n }\r\n\r\n pushVisitorResult(node, st, completion);\r\n\r\n afterVisitor(node, st);\r\n}\r\n","import { equalIgnoreCase } from \"../../visitors\";\r\nimport { Context, Registry, getContextValue } from \"../common\";\r\n\r\nexport interface EvalScopeOptions {\r\n global?: boolean;\r\n caseInsensitive?: boolean;\r\n namespace?: string;\r\n thisArg?: unknown;\r\n}\r\n\r\nconst defaultEvalScopeOptions: EvalScopeOptions = {\r\n global: false,\r\n caseInsensitive: false,\r\n namespace: undefined,\r\n thisArg: undefined\r\n};\r\n\r\n/**\r\n * Represents an evaluation scope.\r\n */\r\nexport class EvalScope {\r\n\r\n type = 'EvalScope';\r\n\r\n private _context!: Context;\r\n private _options!: EvalScopeOptions;\r\n\r\n /**\r\n * Gets the context of the evaluation scope.\r\n * @returns The context object.\r\n */\r\n public get context(): Context {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Gets the options for evaluating the scope.\r\n * @returns The evaluation options.\r\n */\r\n public get options(): EvalScopeOptions {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Creates a new instance of EvalScope.\r\n * @param context - The context of the evaluation scope.\r\n * @param options - The options for evaluating the scope.\r\n */\r\n constructor(\r\n context?: Context,\r\n options?: EvalScopeOptions\r\n ) {\r\n this._context = context ?? {};\r\n this._options = {...defaultEvalScopeOptions,...options ?? {}};\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalScope from the given context and options.\r\n *\r\n * @param context - The context object.\r\n * @param options - The options object.\r\n * @returns An instance of EvalScope.\r\n */\r\n public static fromObject(\r\n context?: Context,\r\n options?: EvalScopeOptions): EvalScope {\r\n\r\n return new EvalScope(context, options);\r\n }\r\n\r\n /**\r\n * Gets the value of the specified key.\r\n * @param key - The key to retrieve the value for.\r\n * @returns The value of the specified key, or undefined if the key is not found.\r\n */\r\n public get(key: unknown): unknown | undefined {\r\n const { caseInsensitive, namespace, global } = this._options;\r\n const { context } = this;\r\n\r\n if (typeof key === 'string' && namespace) {\r\n const found = caseInsensitive\r\n ? equalIgnoreCase(key, namespace)\r\n : key === namespace;\r\n if (found) {\r\n return this.context;\r\n }\r\n }\r\n\r\n if (global) {\r\n const value = getContextValue(context, key);\r\n return value;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Sets the value of the specified key.\r\n * @param key - The key to set the value for.\r\n * @param value - The value to set.\r\n */\r\n public set(key: string, value: unknown): void {\r\n const { context } = this;\r\n if (context && context instanceof Registry) {\r\n const registry = context as Registry<unknown, unknown>;\r\n registry.set(key, value);\r\n } else if (context && context instanceof Object) {\r\n const obj = context as Record<string, unknown>;\r\n obj[key as string | number] = value;\r\n }\r\n }\r\n}\r\n","import type { EvalHooks, EvalReadEvent, Unsubscribe } from '../eval-hooks';\r\n\r\n/**\r\n * Collects the context reads an evaluation made, as a set of dotted paths.\r\n *\r\n * This is Phase 3's input: install it, evaluate, and read {@link dependencies}\r\n * back in the same synchronous turn - which is what wrapping a `computed()`\r\n * needs. Hooks are synchronous by design, so that ordering always holds.\r\n */\r\nexport interface EvalDependencyTracker {\r\n /**\r\n * Registers the read hook on `hooks`.\r\n *\r\n * @param hooks The registry to register on.\r\n * @returns A function that removes it.\r\n */\r\n install(hooks: EvalHooks): Unsubscribe;\r\n\r\n /**\r\n * The dotted paths this tracker considers dependencies, filtered per the\r\n * rules on {@link createDependencyTracker}. Live: it fills as reads arrive.\r\n */\r\n readonly dependencies: ReadonlySet<string>;\r\n\r\n /**\r\n * Every read seen, unfiltered and in emission order - including the scope\r\n * bindings, method references and computed members {@link dependencies}\r\n * drops. A consumer that wants to key on `target` identity rather than on\r\n * path strings works from here.\r\n */\r\n readonly reads: EvalReadEvent[];\r\n\r\n /** Empties {@link dependencies}, {@link reads} and the scope-binding names. */\r\n reset(): void;\r\n}\r\n\r\n/** The first segment of a dotted path: `a.b.c` -> `a`. */\r\nconst rootOf = (path: string): string => {\r\n const dot = path.indexOf('.');\r\n return dot < 0 ? path : path.slice(0, dot);\r\n};\r\n\r\n/**\r\n * Creates a dependency tracker.\r\n *\r\n * `reads` keeps everything. `dependencies` is the filtered view, and three\r\n * rules do the filtering:\r\n *\r\n * 1. **Scope bindings are not dependencies.** A read flagged `scoped` resolved\r\n * from a scope pushed during the walk - an arrow-function parameter. Only\r\n * the walker can tell one from a real context read, which is why the flag\r\n * exists; a consumer using this tracker inherits the filtering for free.\r\n * 2. **Nor is anything reached *through* one.** `item` being a binding makes\r\n * `item.name` one too, and that read carries no flag of its own: `scoped` is\r\n * set at identifier resolution, and the member hop resolves against the\r\n * bound object rather than against a scope. So the bound names are\r\n * remembered and any path rooted at one is dropped.\r\n * 3. **A method reached through a member hop is a call target, not data.**\r\n * `list.map` in `list.map(item => item.name)` resolves to\r\n * `Array.prototype.map`; recording it would put a built-in in the dependency\r\n * set, while `list` - already recorded - is the thing whose change actually\r\n * matters. Bare identifiers are exempt, function-valued or not: a\r\n * context-level callable was named directly rather than reached through an\r\n * object, and there is no already-recorded object standing in for it.\r\n *\r\n * Two limits, both consequences of keying on path strings:\r\n *\r\n * - **A computed member contributes nothing.** `obj[expr]` has no\r\n * reconstructible path, and its resolved key alone is not a usable key\r\n * without one. It is in `reads` with an exact `key` and `target`, for a\r\n * consumer willing to key on identity.\r\n * - **Names collide.** Rule 2 keys on the *name*, so once `item` has been an\r\n * arrow parameter anywhere in the expression, a genuine `item.x` elsewhere in\r\n * it is dropped too. Path strings from different arrow bodies collide the\r\n * same way. § 9 hands the identity-versus-paths question to Phase 3; this is\r\n * the paths half of it.\r\n *\r\n * ```ts\r\n * const tracker = createDependencyTracker();\r\n * const state = evalService.createState({ a: { b: 1 }, c: 2 });\r\n * const off = tracker.install(state.hooks);\r\n *\r\n * evalService.eval('a.b + c', state);\r\n * tracker.dependencies; // Set { 'a', 'a.b', 'c' }\r\n *\r\n * tracker.reset();\r\n * off();\r\n * ```\r\n *\r\n * @returns A tracker; nothing is collected until {@link EvalDependencyTracker.install}\r\n * is called.\r\n */\r\nexport const createDependencyTracker = (): EvalDependencyTracker => {\r\n const dependencies = new Set<string>();\r\n const reads: EvalReadEvent[] = [];\r\n const bindings = new Set<string>();\r\n\r\n const record = (event: EvalReadEvent): void => {\r\n reads.push(event);\r\n\r\n const path = event.path;\r\n\r\n if (event.scoped) {\r\n // Rule 1, and the source of rule 2's name set.\r\n if (path !== undefined) {\r\n bindings.add(path);\r\n }\r\n return;\r\n }\r\n\r\n if (path === undefined) {\r\n return;\r\n }\r\n\r\n if (bindings.has(rootOf(path))) {\r\n return; // rule 2\r\n }\r\n\r\n if (event.kind === 'member' && typeof event.value === 'function') {\r\n return; // rule 3\r\n }\r\n\r\n dependencies.add(path);\r\n };\r\n\r\n return {\r\n install(hooks: EvalHooks): Unsubscribe {\r\n return hooks.onRead(record);\r\n },\r\n\r\n dependencies,\r\n reads,\r\n\r\n reset(): void {\r\n dependencies.clear();\r\n reads.length = 0;\r\n bindings.clear();\r\n }\r\n };\r\n};\r\n","import { AnyNode } from \"acorn\";\r\nimport { ParserOptions } from \"../../internal/interfaces\";\r\nimport { ParserService } from \"./parser.service\";\r\nimport { EvalContext, EvalOptions, EvalState } from \"../../internal/classes/eval\";\r\nimport { Context } from \"../../internal/public-api\";\r\n\r\n/**\r\n * Base class for evaluation.\r\n */\r\nexport abstract class BaseEval {\r\n private _parserOptions!: ParserOptions;\r\n\r\n constructor(\r\n protected parserService: ParserService\r\n ) {}\r\n\r\n /**\r\n * Gets the parser options.\r\n */\r\n protected get parserOptions(): ParserOptions {\r\n return this._parserOptions;\r\n }\r\n\r\n /**\r\n * Sets the parser options.\r\n * @param value The parser options to set.\r\n */\r\n protected set parserOptions(value: ParserOptions) {\r\n this._parserOptions = value;\r\n }\r\n\r\n /**\r\n * Parses the given expression into an abstract syntax tree (AST).\r\n * @param expression - The expression to parse.\r\n * @returns The parsed AST.\r\n */\r\n protected parse(expression: string | AnyNode | undefined): AnyNode | undefined {\r\n if (!expression) {\r\n return undefined;\r\n } else if (typeof expression === 'string') {\r\n const ast = this.parserService.parse(expression, this.parserOptions);\r\n return ast;\r\n } else {\r\n return expression as AnyNode;\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of EvalState.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns The created EvalState instance.\r\n */\r\n createState(context?: EvalContext | Context,\r\n options?: EvalOptions): EvalState {\r\n const state = EvalState.fromContext(context, options);\r\n return state;\r\n }\r\n}\r\n","import { Injectable, OnDestroy } from '@angular/core';\r\nimport { CacheType, ParserOptions } from '../../internal/interfaces';\r\nimport { Cache } from '../../internal/classes/common';\r\nimport { Expression, Program,\r\n version as acornVersion, AnyNode } from 'acorn';\r\nimport { parse as _parse } from '../../internal/functions';\r\nimport { defaultParserOptions } from '../../internal/classes/eval';\r\n\r\n\r\n/**\r\n * @description\r\n * Service for parsing expressions and returning ES6/ES2020 AST.\r\n * Implements OnDestroy for proper memory cleanup.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ParserService implements OnDestroy {\r\n\r\n private _parserOptions!: ParserOptions;\r\n private _cache?: CacheType<Program | AnyNode | Expression | undefined>;\r\n private _cacheCleanupInterval?: ReturnType<typeof setInterval>;\r\n private _isDestroyed = false;\r\n\r\n /**\r\n * Gets the parser options.\r\n */\r\n get parserOptions(): ParserOptions {\r\n return this._parserOptions;\r\n }\r\n\r\n /**\r\n * Sets the parser options.\r\n * @param value The parser options to set.\r\n */\r\n set parserOptions(value: ParserOptions) {\r\n this._parserOptions = value;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the ParserService class.\r\n */\r\n constructor() {\r\n this.parserOptions = {\r\n ...defaultParserOptions,\r\n extractExpressions: true\r\n };\r\n if (this.parserOptions.cacheSize) {\r\n this._cache = new Cache<AnyNode>(this.parserOptions.cacheSize);\r\n \r\n // Set up periodic cache cleanup to prevent memory leaks\r\n this.setupCacheCleanup();\r\n }\r\n }\r\n\r\n /**\r\n * Setup periodic cache cleanup to prevent memory leaks\r\n */\r\n private setupCacheCleanup(): void {\r\n if (this._cache && typeof setInterval !== 'undefined') {\r\n // Clean up cache every 5 minutes to prevent unbounded growth\r\n this._cacheCleanupInterval = setInterval(() => {\r\n if (!this._isDestroyed && this._cache) {\r\n // Keep cache size within bounds by clearing if it gets too large\r\n if (this._cache.size > this._cache.maxCacheSize * 0.8) {\r\n this._cache.clear();\r\n console.debug('Parser cache cleared to prevent memory leaks');\r\n }\r\n }\r\n }, 5 * 60 * 1000); // 5 minutes\r\n }\r\n }\r\n\r\n /**\r\n * Clean up resources to prevent memory leaks\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n \r\n if (this._cacheCleanupInterval) {\r\n clearInterval(this._cacheCleanupInterval);\r\n this._cacheCleanupInterval = undefined;\r\n }\r\n \r\n if (this._cache) {\r\n this._cache.clear();\r\n this._cache = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * @description\r\n * Returns acorn version.\r\n */\r\n get version(): string {\r\n return acornVersion;\r\n }\r\n\r\n /**\r\n * Gets the parser options.\r\n * @returns The parser options.\r\n */\r\n get options(): ParserOptions {\r\n return this.parserOptions;\r\n }\r\n\r\n /**\r\n * @description\r\n * Parses expression and returns ES6/ES2023 AST.\r\n * @param expr expression to parse\r\n * @param options optional parser options\r\n * @returns The parsed AST (Abstract Syntax Tree).\r\n */\r\n public parse(expr: string, options?: ParserOptions)\r\n : Program | AnyNode | Expression | undefined {\r\n if (this._isDestroyed) {\r\n throw new Error('ParserService has been destroyed and cannot be used');\r\n }\r\n \r\n if (expr) {\r\n try {\r\n const parserOptions = { ...this.parserOptions, ...options };\r\n const isCache = this.parserOptions.cacheSize && this._cache;\r\n const ast = isCache\r\n ? this.fromCacheOrParse(expr, parserOptions)\r\n : _parse(expr, parserOptions);\r\n return ast;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n //#region Private methods\r\n private fromCacheOrParse(expr: string, options: ParserOptions) {\r\n if (this._cache) {\r\n const hashKey = this._cache.getHashKey('', expr);\r\n let ast = this._cache.get(hashKey);\r\n if (!ast) {\r\n ast = _parse(expr, options);\r\n this._cache.set(hashKey, ast);\r\n }\r\n return ast;\r\n }\r\n return undefined;\r\n }\r\n //#endregion\r\n}\r\n","import { Injectable, OnDestroy, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { AnyNode } from 'acorn';\r\nimport { Context, Registry } from '../../internal/classes/common';\r\nimport { EvalContext, EvalOptions, EvalState, defaultParserOptions } from '../../internal/classes/eval';\r\nimport { evaluate, evaluateAsync } from '../../internal/functions';\r\n\r\n/**\r\n * Service for evaluating and parsing expressions with proper memory management.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class EvalService extends BaseEval implements OnDestroy {\r\n private _isDestroyed = false;\r\n private _activeContexts = new Set<Context>();\r\n private _activeStates = new Set<EvalState>();\r\n\r\n protected override parserService = inject(ParserService);\r\n\r\n /**\r\n * Constructs a new instance of the EvalService class.\r\n */\r\n constructor() {\r\n super(inject(ParserService));\r\n this.parserOptions = defaultParserOptions;\r\n }\r\n\r\n /**\r\n * Override createState to track active contexts and states for cleanup\r\n */\r\n override createState(context?: EvalContext | Context, options?: EvalOptions): EvalState {\r\n if (this._isDestroyed) {\r\n throw new Error('EvalService has been destroyed and cannot be used');\r\n }\r\n \r\n const state = super.createState(context, options);\r\n \r\n // Track active states for cleanup\r\n this._activeStates.add(state);\r\n \r\n // Track active contexts\r\n if (context && typeof context === 'object') {\r\n // Check if it's a Registry-based context (has type property)\r\n if ('type' in context) {\r\n this._activeContexts.add(context as Registry<unknown, unknown>);\r\n }\r\n // For EvalContext, check if it has a nested context using bracket notation\r\n if ('context' in context) {\r\n const nestedContext = (context as Record<string, unknown>)['context'];\r\n if (nestedContext && typeof nestedContext === 'object' && 'type' in nestedContext) {\r\n this._activeContexts.add(nestedContext as Registry<unknown, unknown>);\r\n }\r\n }\r\n }\r\n \r\n return state;\r\n }\r\n\r\n /**\r\n * Clean up resources to prevent memory leaks\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n \r\n // Clean up all active states\r\n for (const state of this._activeStates) {\r\n try {\r\n // Clear the stack in the result\r\n if (state.result?.stack) {\r\n state.result.stack.clear();\r\n }\r\n // Clear context if it has a clear method\r\n if (state.context && typeof state.context === 'object' && 'clear' in state.context && typeof state.context.clear === 'function') {\r\n (state.context as unknown as { clear(): void }).clear();\r\n }\r\n // Drop hook registrations so a long-lived closure cannot pin a\r\n // destroyed state. This matters most for a registry the caller passed\r\n // through `options.hooks` and still holds: one that outlives the\r\n // service keeps every state its closures captured reachable. A\r\n // state-owned registry would die with its state regardless.\r\n //\r\n // Guarded on `hasHooks` rather than reading `state.hooks`, because that\r\n // getter builds a registry on first access - allocating inside the\r\n // method whose job is releasing memory. The guard is exact for this\r\n // purpose: it is false only when no hook is registered, and clearing an\r\n // empty registry does nothing.\r\n if (state.hasHooks) {\r\n state.hooks.clear();\r\n }\r\n // Bookkeeping lives on the state and `clear` cannot reach it, so the\r\n // open-node stack and collected errors need dropping separately.\r\n state.resetHookBookkeeping();\r\n } catch (error) {\r\n console.warn('Error cleaning up EvalState:', error);\r\n }\r\n }\r\n this._activeStates.clear();\r\n \r\n // Clean up all active contexts\r\n for (const context of this._activeContexts) {\r\n try {\r\n if (context && typeof context.clear === 'function') {\r\n context.clear();\r\n }\r\n } catch (error) {\r\n console.warn('Error cleaning up Context:', error);\r\n }\r\n }\r\n this._activeContexts.clear();\r\n }\r\n\r\n /**\r\n * Evaluates the given expression.\r\n * @param expression The expression to evaluate.\r\n * @param context The evaluation context.\r\n * @param options The evaluation options.\r\n * @returns The result of the evaluation.\r\n */\r\n simpleEval(expression: string | AnyNode | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions\r\n ): unknown | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n const state = this.createState(context, options);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const value = evaluate(ast, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Evaluates an expression using the provided state.\r\n *\r\n * @param expression - The expression to evaluate.\r\n * @param state - The state object containing variables and functions used in the evaluation.\r\n * @returns The result of the evaluation.\r\n * @throws If an error occurs during evaluation.\r\n */\r\n eval(expression: string | AnyNode | undefined,\r\n state: EvalState\r\n ): unknown | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const value = evaluate(ast, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Asynchronously evaluates the given expression.\r\n * @param expression The expression to evaluate.\r\n * @param context The evaluation context.\r\n * @param options The evaluation options.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n */\r\n simpleEvalAsync(expression: string | AnyNode | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions\r\n ): Promise<unknown | undefined> {\r\n try {\r\n const ast = this.parse(expression);\r\n const state = this.createState(context, options);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const promise = evaluateAsync(ast, state);\r\n return promise;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Asynchronously evaluates an expression using the provided state.\r\n *\r\n * @param expression - The expression to evaluate. Can be a string or an AST node.\r\n * @param state - The evaluation state.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n * @throws If an error occurs during evaluation.\r\n */\r\n evalAsync(expression: string | AnyNode | undefined,\r\n state: EvalState\r\n ): Promise<unknown | undefined> {\r\n try {\r\n const ast = this.parse(expression);\r\n if (state?.result && typeof expression === 'string') {\r\n state.result.expression = expression;\r\n }\r\n const promise = evaluateAsync(ast, state);\r\n return promise;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\n\r\n","import { Injectable, OnDestroy, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { EvalService } from './eval.service';\r\nimport { EvalContext, EvalOptions, EvalState, defaultParserOptions } from '../../internal/classes/eval';\r\nimport { Context } from '../../internal/classes/common';\r\nimport { AnyNode } from 'acorn';\r\nimport { call as _call, callAsync as _callAsync,\r\n compile as _compile, compileAsync as _compileAsync,\r\n stateCallback, stateCallbackAsync } from '../../internal/functions';\r\n\r\n/**\r\n * Interface for cached compilation result\r\n */\r\ninterface CachedCompilation {\r\n sync?: stateCallback;\r\n async?: stateCallbackAsync;\r\n timestamp: number;\r\n accessCount: number;\r\n}\r\n\r\n/**\r\n * CompilerService class that extends BaseEval.\r\n * Provides methods for compiling and evaluating expressions with performance caching.\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CompilerService extends BaseEval implements OnDestroy {\r\n \r\n // Compilation cache with LRU eviction\r\n private readonly _compilationCache = new Map<string, CachedCompilation>();\r\n private readonly _maxCacheSize = 200;\r\n private readonly _cacheTTL = 10 * 60 * 1000; // 10 minutes\r\n private readonly _accessOrder = new Set<string>();\r\n private _cacheCleanupInterval?: ReturnType<typeof setInterval>;\r\n private _isDestroyed = false;\r\n\r\n protected override parserService = inject(ParserService);\r\n protected evalService = inject(EvalService);\r\n\r\n constructor() {\r\n super(inject(ParserService));\r\n this.parserOptions = defaultParserOptions;\r\n this.setupCacheCleanup();\r\n }\r\n\r\n /**\r\n * OnDestroy lifecycle hook for cleanup\r\n */\r\n ngOnDestroy(): void {\r\n this._isDestroyed = true;\r\n if (this._cacheCleanupInterval) {\r\n clearInterval(this._cacheCleanupInterval);\r\n }\r\n this._compilationCache.clear();\r\n this._accessOrder.clear();\r\n }\r\n\r\n /**\r\n * Setup periodic cache cleanup to prevent memory leaks and stale entries\r\n */\r\n private setupCacheCleanup(): void {\r\n if (typeof setInterval !== 'undefined') {\r\n this._cacheCleanupInterval = setInterval(() => {\r\n if (!this._isDestroyed) {\r\n this.cleanupCache();\r\n }\r\n }, 5 * 60 * 1000); // Clean every 5 minutes\r\n }\r\n }\r\n\r\n /**\r\n * Clean expired entries and enforce cache size limits\r\n */\r\n private cleanupCache(): void {\r\n const now = performance.now();\r\n const toDelete: string[] = [];\r\n \r\n // Remove expired entries\r\n for (const [key, cached] of this._compilationCache) {\r\n if (now - cached.timestamp > this._cacheTTL) {\r\n toDelete.push(key);\r\n }\r\n }\r\n \r\n // Remove expired entries\r\n toDelete.forEach(key => {\r\n this._compilationCache.delete(key);\r\n this._accessOrder.delete(key);\r\n });\r\n \r\n // Enforce cache size limit using LRU\r\n while (this._compilationCache.size > this._maxCacheSize) {\r\n const oldestKey = Array.from(this._accessOrder)[0];\r\n if (oldestKey) {\r\n this._compilationCache.delete(oldestKey);\r\n this._accessOrder.delete(oldestKey);\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Generate cache key for expression\r\n */\r\n private generateCacheKey(expression: string | AnyNode | undefined): string {\r\n if (typeof expression === 'string') {\r\n return `str:${expression}`;\r\n } else if (expression && typeof expression === 'object') {\r\n // Use a simplified hash for AST nodes to avoid deep serialization overhead\r\n return `ast:${expression.type}:${JSON.stringify({\r\n type: expression.type,\r\n start: expression.start,\r\n end: expression.end\r\n })}:${expression.toString()}`;\r\n }\r\n return 'undefined';\r\n }\r\n\r\n /**\r\n * Update access order for LRU cache\r\n */\r\n private updateAccessOrder(key: string): void {\r\n this._accessOrder.delete(key);\r\n this._accessOrder.add(key);\r\n }\r\n\r\n /**\r\n * Compiles the given expression into a state callback function with caching.\r\n * @param expression - The expression to compile.\r\n * @returns The compiled state callback function.\r\n * @throws Error if there is an error during compilation.\r\n */\r\n compile(expression: string | AnyNode | undefined): stateCallback | undefined {\r\n try {\r\n const cacheKey = this.generateCacheKey(expression);\r\n \r\n // Check cache first\r\n const cached = this._compilationCache.get(cacheKey);\r\n if (cached?.sync) {\r\n // Update access order for LRU\r\n this.updateAccessOrder(cacheKey);\r\n cached.accessCount++;\r\n \r\n // Check if entry is still fresh\r\n const age = performance.now() - cached.timestamp;\r\n if (age < this._cacheTTL) {\r\n return cached.sync;\r\n }\r\n }\r\n \r\n // Compile fresh\r\n const ast = this.parse(expression);\r\n const fn = _compile(ast);\r\n \r\n if (fn) {\r\n // Cache the result\r\n const existingCache = this._compilationCache.get(cacheKey) || {\r\n timestamp: performance.now(),\r\n accessCount: 0\r\n };\r\n \r\n existingCache.sync = fn;\r\n existingCache.timestamp = performance.now();\r\n existingCache.accessCount++;\r\n \r\n this._compilationCache.set(cacheKey, existingCache);\r\n this.updateAccessOrder(cacheKey);\r\n \r\n // Cleanup if cache is getting too large\r\n if (this._compilationCache.size > this._maxCacheSize * 1.2) {\r\n this.cleanupCache();\r\n }\r\n }\r\n \r\n return fn;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in compile');\r\n }\r\n }\r\n\r\n /**\r\n * Calls the given state callback function with the specified context and options.\r\n * @param fn - The state callback function to call.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns The result of the evaluation.\r\n * @throws Error if there is an error during the evaluation.\r\n */\r\n simpleCall(fn: stateCallback | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions) {\r\n if (fn) {\r\n try {\r\n const state = this.createState(context, options);\r\n const value = _call(fn, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw new Error('call');\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /**\r\n * Calls the provided function with the given state.\r\n *\r\n * @param fn - The function to be called.\r\n * @param state - The state to be passed to the function.\r\n * @returns The value returned by the function.\r\n * @throws If an error occurs during the function call.\r\n */\r\n call(fn: stateCallback | undefined,\r\n state: EvalState) {\r\n if (fn) {\r\n try {\r\n const value = _call(fn, state);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw new Error('call');\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Compiles the given expression into an asynchronous state callback function with caching.\r\n * @param expression - The expression to compile.\r\n * @returns The compiled asynchronous state callback function.\r\n * @throws Error if there is an error during compilation.\r\n */\r\n compileAsync(expression: string | AnyNode | undefined): stateCallbackAsync | undefined {\r\n try {\r\n const cacheKey = this.generateCacheKey(expression);\r\n \r\n // Check cache first\r\n const cached = this._compilationCache.get(cacheKey);\r\n if (cached?.async) {\r\n // Update access order for LRU\r\n this.updateAccessOrder(cacheKey);\r\n cached.accessCount++;\r\n \r\n // Check if entry is still fresh\r\n const age = performance.now() - cached.timestamp;\r\n if (age < this._cacheTTL) {\r\n return cached.async;\r\n }\r\n }\r\n \r\n // Compile fresh\r\n const ast = this.parse(expression);\r\n const fn = _compileAsync(ast);\r\n \r\n if (fn) {\r\n // Cache the result\r\n const existingCache = this._compilationCache.get(cacheKey) || {\r\n timestamp: performance.now(),\r\n accessCount: 0\r\n };\r\n \r\n existingCache.async = fn;\r\n existingCache.timestamp = performance.now();\r\n existingCache.accessCount++;\r\n \r\n this._compilationCache.set(cacheKey, existingCache);\r\n this.updateAccessOrder(cacheKey);\r\n \r\n // Cleanup if cache is getting too large\r\n if (this._compilationCache.size > this._maxCacheSize * 1.2) {\r\n this.cleanupCache();\r\n }\r\n }\r\n \r\n return fn;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in compileAsync');\r\n }\r\n }\r\n\r\n /**\r\n * Calls the given asynchronous state callback function with the specified context and options.\r\n * @param fn - The asynchronous state callback function to call.\r\n * @param context - The evaluation context or context object.\r\n * @param options - The evaluation options.\r\n * @returns A promise that resolves to the result of the evaluation.\r\n * @throws Error if there is an error during the evaluation.\r\n */\r\n async simpleCallAsync(fn: stateCallbackAsync | undefined,\r\n context?: EvalContext | Context,\r\n options?: EvalOptions) {\r\n if (fn) {\r\n try {\r\n const state = this.createState(context, options);\r\n const promise = _callAsync(fn, state);\r\n const value = await promise;\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in callAsync');\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /**\r\n * Calls the provided asynchronous function with the given state.\r\n *\r\n * @param fn - The asynchronous function to call.\r\n * @param state - The state to pass to the function.\r\n * @returns A promise that resolves to the value returned by the function.\r\n * @throws If an error occurs during the function call.\r\n */\r\n async callAsync(fn: stateCallbackAsync | undefined,\r\n state: EvalState) {\r\n if (fn) {\r\n try {\r\n const promise = _callAsync(fn, state);\r\n const value = await promise;\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n }\r\n throw new Error('error in callAsync');\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { BaseEval } from './base-eval';\r\nimport { ParserService } from './parser.service';\r\nimport { AnyNode } from 'acorn';\r\nimport { AnyNodeTypes } from '../../internal/interfaces';\r\nimport { extract } from '../../internal/functions';\r\nimport { defaultParserOptions } from '../../internal/classes/eval';\r\n\r\n/**\r\n * Service responsible for discovering nodes in an abstract syntax tree (AST).\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class DiscoveryService extends BaseEval {\r\n\r\n protected override parserService = inject(ParserService);\r\n\r\n /**\r\n * Creates a new instance of the DiscoveryService class.\r\n */\r\n constructor() {\r\n super(inject(ParserService));\r\n\r\n this.parserOptions = {\r\n ...defaultParserOptions,\r\n cacheSize: undefined\r\n };\r\n }\r\n\r\n /**\r\n * Finds all nodes in the AST that match the given expression and search type.\r\n * @param expression The expression to search for. Can be a string or an AST node.\r\n * @param searchType The type of nodes to search for.\r\n * @param options Optional parser options.\r\n * @returns An array of nodes that match the search criteria, or undefined if no nodes are found.\r\n * @throws If an error occurs during the search process.\r\n */\r\n extract(expression: string | AnyNode | undefined,\r\n searchType: AnyNodeTypes): AnyNode[] | undefined {\r\n try {\r\n const ast = this.parse(expression);\r\n const value = extract(ast, searchType);\r\n return value;\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n throw new Error(error.message);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["DANGEROUS_CONSTRUCTORS","_parse","acornVersion","_compile","_call","_compileAsync","_callAsync"],"mappings":";;;;;;AAEA;;AAEG;MACU,YAAY,CAAA;AAYvB;;;AAGG;AACH,IAAA,WAAA,CAAY,OAA8C,EAAA;AAfzC,QAAA,IAAA,CAAA,SAAS,GAAsB,IAAI,GA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