@routier/core 0.4.0 → 0.5.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 +0,0 @@
1
- {"version":3,"file":"capabilities/index.js","sources":["webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/./src/utilities/strings.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/capabilities/Capability.ts","webpack://@routier/core/./src/capabilities/performance/PerformanceTracker.ts","webpack://@routier/core/./src/capabilities/tracing/CallTraceManager.ts","webpack://@routier/core/./src/capabilities/PerformanceCapability.ts","webpack://@routier/core/./src/capabilities/TracingCapability.ts","webpack://@routier/core/./src/capabilities/index.ts"],"sourcesContent":["/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n // `test` is deliberately absent. It used to be here, which meant no test suite anywhere\n // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test\n // needs the output.\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n return 'silent';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","export const hash = (value: string, seed: number = 0) => {\n // From Stack Overflow\n // https://stackoverflow.com/a/52171480/3329760\n let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;\n\n for (let i = 0, ch: number; i < value.length; i++) {\n ch = value.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n}\n\n/**\n * Fast string hash optimized for comparisons.\n * Uses djb2 algorithm - very fast and good distribution for short to medium strings.\n * Same input always produces same output (deterministic).\n * \n * @param value - The string to hash\n * @param seed - Optional seed value (default: 5381)\n * @returns A positive 32-bit integer hash value\n * \n * @example\n * ```ts\n * fastHash(\"test\") === fastHash(\"test\") // true\n * fastHash(\"test\") !== fastHash(\"test2\") // true\n * ```\n */\nexport const fastHash = (value: string, seed: number = 5381): number => {\n let hash = seed;\n for (let i = 0; i < value.length; i++) {\n hash = ((hash << 5) + hash) + value.charCodeAt(i);\n }\n return hash >>> 0; // Convert to unsigned 32-bit integer\n}\n\n/**\n * Converts any value to a readable string representation.\n * Handles primitives, objects, arrays, classes, dates, errors, and functions.\n * Supports depth limiting to prevent infinite recursion on circular references.\n * \n * @param obj - The value to stringify\n * @param maxDepth - Maximum depth for nested objects (default: 3)\n * @param currentDepth - Current recursion depth (default: 0)\n * @returns String representation of the value\n * \n * @example\n * ```ts\n * stringifyObject({ name: \"test\", count: 5 }) // '{ name: \"test\", count: 5 }'\n * stringifyObject([1, 2, 3]) // '[1, 2, 3]'\n * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'\n * ```\n */\nexport function stringifyObject(obj: unknown, maxDepth: number = 3, currentDepth: number = 0): string {\n if (obj === null) return 'null';\n if (obj === undefined) return 'undefined';\n\n const type = typeof obj;\n\n switch (type) {\n case 'string':\n return `\"${obj}\"`;\n case 'number':\n case 'boolean':\n return String(obj);\n case 'function':\n return `[Function: ${getFunctionName(obj as Function)}]`;\n case 'object':\n if (currentDepth >= maxDepth) {\n return '[Max Depth Reached]';\n }\n return stringifyObjectValue(obj, maxDepth, currentDepth);\n default:\n return `[${type}]`;\n }\n}\n\nfunction getFunctionName(fn: Function): string {\n const name = fn.name;\n return name || 'anonymous';\n}\n\nfunction getObjectProperties(obj: any): Record<string, any> {\n const properties: Record<string, any> = {};\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n properties[key] = obj[key];\n }\n }\n\n return properties;\n}\n\nfunction stringifyObjectValue(obj: any, maxDepth: number, currentDepth: number): string {\n if (obj === null) return 'null';\n\n if (obj instanceof Date) {\n return `Date(${obj.toISOString()})`;\n }\n\n if (obj instanceof Error) {\n return `Error(${obj.message})`;\n }\n\n if (obj instanceof RegExp) {\n return obj.toString();\n }\n\n if (Array.isArray(obj)) {\n return stringifyArray(obj, maxDepth, currentDepth);\n }\n\n if (obj.constructor && obj.constructor.name !== 'Object') {\n return stringifyClassInstance(obj, maxDepth, currentDepth);\n }\n\n return stringifyPlainObject(obj, maxDepth, currentDepth);\n}\n\nfunction stringifyArray(arr: any[], maxDepth: number, currentDepth: number): string {\n if (arr.length === 0) return '[]';\n\n const items = arr.slice(0, 5).map(item =>\n stringifyObject(item, maxDepth, currentDepth + 1)\n );\n\n const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';\n return `[${items.join(', ')}${suffix}]`;\n}\n\nfunction stringifyClassInstance(obj: any, maxDepth: number, currentDepth: number): string {\n const className = obj.constructor.name;\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return `${className} {}`;\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `${className} { ${props.join(', ')}${suffix} }`;\n}\n\nfunction stringifyPlainObject(obj: any, maxDepth: number, currentDepth: number): string {\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return '{}';\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `{ ${props.join(', ')}${suffix} }`;\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { MethodInfo, MethodInfoMetadata } from \"./types\";\n\nexport abstract class Capability {\n\n protected excludedNames = new Set<string>([\n \"Array\",\n \"Set\",\n \"Map\",\n \"AbortController\",\n \"AbortSignal\",\n \"SchemaString\",\n \"SchemaNumber\",\n \"SchemaArray\",\n \"SchemaBoolean\",\n \"SchemaDate\",\n \"SchemaObject\",\n \"SchemaDefault\",\n \"SchemaDeserialize\",\n \"SchemaDistinct\",\n \"SchemaSearchable\",\n \"SchemaFrom\",\n \"SchemaIdentity\",\n \"SchemaIndex\",\n \"SchemaKey\",\n \"SchemaNullable\",\n \"SchemaOptional\",\n \"SchemaReadonly\",\n \"SchemaSerialize\",\n \"SchemaTracked\",\n \"SchemaComputed\",\n \"SchemaFunction\",\n \"SchemaBase\",\n \"SchemaDefinition\"\n ]);\n\n protected isValidObject(obj: unknown): obj is object {\n return typeof obj === \"object\" && obj !== null;\n }\n\n protected isCallableMethod(descriptor: PropertyDescriptor | undefined, key: string | symbol): boolean {\n return (\n descriptor?.value &&\n typeof descriptor.value === 'function' &&\n key !== 'constructor' &&\n key !== 'undefined'\n );\n }\n\n\n private canExplore(descriptor: PropertyDescriptor) {\n if (typeof descriptor.value !== \"object\") {\n return false;\n }\n\n if (descriptor.value == null) {\n return false\n }\n\n const name = this.getName(descriptor.value);\n\n if (name == null) {\n return true;\n }\n\n return this.excludedNames.has(name) === false\n }\n\n private getName(value: object) {\n if (value.constructor != null) {\n return value.constructor.name;\n }\n\n return null;\n }\n\n private getPath(info: MethodInfoMetadata, propertyName: string | symbol) {\n\n let parent = info.parent;\n const path = [info.propertyName, propertyName];\n\n while (parent != null) {\n\n path.unshift(parent.propertyName);\n parent = parent.parent;\n }\n\n return path.join(\".\");\n }\n\n protected explore(instance: unknown, onDiscover: (info: MethodInfoMetadata, methodInfo: MethodInfo) => void): void {\n if (!this.isValidObject(instance)) {\n return;\n }\n\n const explore: MethodInfoMetadata[] = [{ instance, propertyName: this.getName(instance) }];\n const visited = new Set<object>();\n\n for (let i = 0; i < explore.length; i++) {\n\n const info = explore[i];\n const item = info.instance;\n\n if (visited.has(item)) {\n continue;\n }\n\n const allKeys = [\n ...Object.getOwnPropertyNames(item),\n ...Object.getOwnPropertySymbols(item),\n ];\n\n for (const key of allKeys) {\n\n const descriptor = Object.getOwnPropertyDescriptor(item, key);\n\n const isCallable = this.isCallableMethod(descriptor, key);\n\n onDiscover(info, {\n name: key,\n isCallable\n });\n\n if (this.canExplore(descriptor) === false) {\n continue;\n }\n\n const path = this.getPath(info, key);\n explore.push({ instance: descriptor.value, parent: info, propertyName: key, path });\n }\n\n visited.add(item);\n }\n }\n\n abstract apply(instance: unknown): void;\n}","import { PerformanceMetrics } from \"../types\";\n\nexport class PerformanceTracker {\n private methodTimings = new Map<string, { startTime: number; nextMethodStartTime?: number }>();\n private operationStartTimes = new Map<string, number>();\n\n startMethodTiming(operationId: string, methodPath: string): number {\n const startTime = performance.now();\n const key = `${operationId}:${methodPath}`;\n\n // Track operation start time for delta calculations\n if (!this.operationStartTimes.has(operationId)) {\n this.operationStartTimes.set(operationId, startTime);\n }\n\n this.methodTimings.set(key, { startTime });\n return startTime;\n }\n\n recordNextMethodStart(operationId: string, methodPath: string): void {\n const key = `${operationId}:${methodPath}`;\n const timing = this.methodTimings.get(key);\n if (timing) {\n timing.nextMethodStartTime = performance.now();\n }\n }\n\n endMethodTiming(operationId: string, methodPath: string): PerformanceMetrics {\n const endTime = performance.now();\n const key = `${operationId}:${methodPath}`;\n const timing = this.methodTimings.get(key);\n\n if (!timing) {\n return { startTime: endTime };\n }\n\n const duration = endTime - timing.startTime;\n const timeToNextCall = timing.nextMethodStartTime ?\n timing.nextMethodStartTime - timing.startTime : undefined;\n\n // Clean up\n this.methodTimings.delete(key);\n\n return {\n startTime: timing.startTime,\n endTime,\n duration,\n nextMethodStartTime: timing.nextMethodStartTime,\n timeToNextCall\n };\n }\n\n formatDuration(milliseconds: number): string {\n if (milliseconds < 1) {\n return `${(milliseconds * 1000).toFixed(1)}μs`;\n } else if (milliseconds < 1000) {\n return `${milliseconds.toFixed(2)}ms`;\n } else {\n return `${(milliseconds / 1000).toFixed(2)}s`;\n }\n }\n\n getDeltaFromOperationStart(operationId: string, currentTime: number): number {\n const operationStartTime = this.operationStartTimes.get(operationId);\n return operationStartTime ? currentTime - operationStartTime : 0;\n }\n\n cleanupOperation(operationId: string): void {\n this.operationStartTimes.delete(operationId);\n }\n}","import { uuid } from \"../../utilities\";\n\nexport class CallTraceManager {\n private activeOperationId: string | null = null;\n private activeCallStack: string[] = [];\n\n startNewOperation(): string {\n const operationId = uuid(8);\n this.activeOperationId = operationId;\n this.activeCallStack = [];\n return operationId;\n }\n\n isNewOperation(): boolean {\n return this.activeOperationId === null;\n }\n\n getActiveOperationId(): string {\n if (!this.activeOperationId) {\n throw new Error('No active operation context');\n }\n return this.activeOperationId;\n }\n\n addMethodToTrace(methodPath: string): string[] {\n if (this.isNewOperation()) {\n this.activeCallStack = [methodPath];\n } else {\n this.activeCallStack.push(methodPath);\n }\n return [...this.activeCallStack];\n }\n\n removeMethodFromTrace(): void {\n if (!this.isNewOperation()) {\n this.activeCallStack.pop();\n }\n }\n\n endOperation(): void {\n this.activeOperationId = null;\n this.activeCallStack = [];\n }\n\n formatMethodPaths(methodPaths: string[]): string[] {\n return methodPaths.map(path => path.replace(/ → /g, '.'));\n }\n\n getCurrentTrace(): string[] {\n return [...this.activeCallStack];\n }\n}","import { stringifyObject } from \"../utilities\";\nimport { Capability } from \"./Capability\";\nimport { PerformanceTracker } from \"./performance/PerformanceTracker\";\nimport { CallTraceManager } from \"./tracing/CallTraceManager\";\nimport { MethodInfoMetadata, MethodInfo } from \"./types\";\nimport { logger } from '../utilities';\n\nexport type PerformanceCapabilityOptions = {\n filter: (methodName: string | symbol, methodInfo: MethodInfo, metadata: MethodInfoMetadata) => boolean\n}\n\nexport class PerformanceCapability extends Capability {\n\n private callTraceManager: CallTraceManager;\n private performanceTracker: PerformanceTracker;\n private filter: (methodName: string | symbol, methodInfo: MethodInfo, metadata: MethodInfoMetadata) => boolean;\n private childDurations: Map<string, number[]> = new Map();\n\n constructor(options?: PerformanceCapabilityOptions) {\n super();\n this.filter = options?.filter ?? (() => true)\n this.callTraceManager = new CallTraceManager();\n this.performanceTracker = new PerformanceTracker();\n }\n\n override apply(instance: unknown): void {\n\n this.explore(instance, (meta, info) => {\n\n if (info.isCallable) {\n const originalMethod = meta.instance[info.name].bind(meta.instance);\n\n meta.instance[info.name] = (...args: any[]) => {\n\n const path = `${meta.path!}.${String(info.name)}()`;\n\n if (this.filter(path, info, meta) === false) {\n return originalMethod(...args);\n }\n\n const isNewOperation = this.callTraceManager.isNewOperation();\n let operationId: string;\n let callTrace: string[];\n let depth: number;\n\n if (isNewOperation) {\n operationId = this.callTraceManager.startNewOperation();\n this.childDurations.set(operationId, []);\n callTrace = this.callTraceManager.addMethodToTrace(path);\n depth = callTrace.length - 1;\n const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);\n\n this.performanceTracker.startMethodTiming(operationId, path);\n\n logger.log(`\\n${'═'.repeat(60)}`);\n logger.log(`▶ ORIGIN [${operationId}] ${path}`);\n if (args.length > 0) {\n logger.log(` Args:`, stringifyObject(args, 4, 0));\n }\n logger.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);\n } else {\n operationId = this.callTraceManager.getActiveOperationId();\n callTrace = this.callTraceManager.addMethodToTrace(path);\n depth = callTrace.length - 1;\n const indent = ' '.repeat(Math.min(depth, 4));\n\n // Track children for this child method too\n const childMethodKey = `${operationId}:${path}`;\n this.childDurations.set(childMethodKey, []);\n\n this.performanceTracker.startMethodTiming(operationId, path);\n\n logger.log(`${indent}└─ CHILD [${operationId}] ${path}`);\n if (args.length > 0) {\n logger.log(`${indent} Args:`, stringifyObject(args, 4, 0));\n }\n }\n\n try {\n return originalMethod(...args);\n } finally {\n const metrics = this.performanceTracker.endMethodTiming(operationId, path);\n const duration = metrics.duration ?? 0;\n const formattedDuration = this.performanceTracker.formatDuration(duration);\n\n if (isNewOperation) {\n const childDurations = this.childDurations.get(operationId) ?? [];\n const totalChildTime = childDurations.reduce((sum, d) => sum + d, 0);\n const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);\n const overhead = duration - totalChildTime;\n const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));\n\n logger.log(`\\n${'═'.repeat(60)}`);\n logger.log(`◀ COMPLETE [${operationId}] ${path}`);\n logger.log(` Total Duration: ${formattedDuration}`);\n if (childDurations.length > 0) {\n logger.log(` Children Duration: ${formattedTotalChildTime} (${childDurations.length} calls)`);\n logger.log(` Overhead: ${formattedOverhead}`);\n }\n logger.log(`${'═'.repeat(60)}\\n`);\n\n this.childDurations.delete(operationId);\n this.performanceTracker.cleanupOperation(operationId);\n this.callTraceManager.endOperation();\n } else {\n const indent = ' '.repeat(Math.min(depth, 4));\n const childMethodKey = `${operationId}:${path}`;\n const childDurations = this.childDurations.get(childMethodKey) ?? [];\n const totalChildTime = childDurations.reduce((sum, d) => sum + d, 0);\n const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);\n const overhead = duration - totalChildTime;\n const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));\n\n logger.log(`${indent} ✓ ${formattedDuration}`);\n if (childDurations.length > 0) {\n logger.log(`${indent} Children: ${formattedTotalChildTime} (${childDurations.length} calls), Overhead: ${formattedOverhead}`);\n }\n\n // Clean up child method tracking\n this.childDurations.delete(childMethodKey);\n\n // Find the parent method and add this duration to its children list\n // The parent is the method one level up in the call trace\n const currentTrace = this.callTraceManager.getCurrentTrace();\n if (currentTrace.length > 1) {\n // Parent is the second-to-last item in the trace (before we remove current)\n const parentPath = currentTrace[currentTrace.length - 2];\n\n // Check if parent is the root operation (trace length 2 means root + this child)\n if (currentTrace.length === 2) {\n // Direct child of root - add to root's children list\n const rootChildDurations = this.childDurations.get(operationId);\n if (rootChildDurations) {\n rootChildDurations.push(duration);\n }\n } else {\n // Nested child - add to parent method's children list\n const parentMethodKey = `${operationId}:${parentPath}`;\n const parentChildDurations = this.childDurations.get(parentMethodKey);\n if (parentChildDurations) {\n parentChildDurations.push(duration);\n }\n }\n }\n }\n\n this.callTraceManager.removeMethodFromTrace();\n }\n }\n }\n });\n }\n}","import { Capability } from \"./Capability\";\nimport { CallTraceManager } from \"./tracing/CallTraceManager\";\nimport { stringifyObject } from \"../utilities/strings\";\nimport { MethodInfo, MethodInfoMetadata } from \"./types\";\n\nexport type TracingCapabilityOptions = {\n filter: (methodName: string | symbol, methodInfo: MethodInfo, metadata: MethodInfoMetadata) => boolean\n}\n\nexport class TracingCapability extends Capability {\n\n private callTraceManager: CallTraceManager;\n private filter: (methodName: string | symbol, methodInfo: MethodInfo, metadata: MethodInfoMetadata) => boolean;\n\n constructor(options?: TracingCapabilityOptions) {\n super();\n this.filter = options?.filter ?? (() => true);\n this.callTraceManager = new CallTraceManager();\n }\n\n override apply(instance: unknown): void {\n\n this.explore(instance, (meta, info) => {\n\n if (info.isCallable) {\n\n const originalMethod = meta.instance[info.name].bind(meta.instance);\n\n meta.instance[info.name] = (...args: any[]) => {\n\n const path = `${meta.path!}.${String(info.name)}()`;\n\n if (this.filter(path, info, meta) === false) {\n return originalMethod(...args);\n }\n\n const isNewOperation = this.callTraceManager.isNewOperation();\n let operationId: string;\n\n if (isNewOperation) {\n operationId = this.callTraceManager.startNewOperation();\n const callTrace = this.callTraceManager.addMethodToTrace(path);\n const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);\n\n console.log(`\\n${'═'.repeat(60)}`);\n console.log(`▶ ORIGIN [${operationId}] ${path}`);\n if (args.length > 0) {\n console.log(` Args:`, stringifyObject(args, 4, 0));\n }\n console.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);\n } else {\n operationId = this.callTraceManager.getActiveOperationId();\n const callTrace = this.callTraceManager.addMethodToTrace(path);\n\n const indent = ' '.repeat(Math.min(callTrace.length - 1, 4));\n console.log(`${indent}└─ CHILD [${operationId}] ${path}`);\n if (args.length > 0) {\n console.log(`${indent} Args:`, stringifyObject(args, 4, 0));\n }\n }\n\n try {\n return originalMethod(...args);\n } finally {\n this.callTraceManager.removeMethodFromTrace();\n\n if (isNewOperation) {\n this.callTraceManager.endOperation();\n }\n }\n }\n }\n\n });\n }\n}","export { Capability } from './Capability';\nexport { PerformanceCapability } from './PerformanceCapability';\nexport { TracingCapability } from './TracingCapability';\nexport * from './types';"],"names":["LOG_LEVELS","RANK","isLogLevel","value","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","Error","getLogLevel","resetLogLevel","isLogLevelEnabled","at","emit","method","args","console","logger","hash","seed","h1","h2","i","ch","Math","fastHash","stringifyObject","obj","maxDepth","currentDepth","undefined","type","String","getFunctionName","stringifyObjectValue","fn","name","getObjectProperties","properties","key","Date","RegExp","Array","stringifyArray","stringifyClassInstance","stringifyPlainObject","arr","items","item","suffix","className","Object","props","isPrimitive","depth","uuid","length","chars","charLength","result","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","r","Capability","Set","descriptor","info","propertyName","parent","path","instance","onDiscover","explore","visited","allKeys","isCallable","PerformanceTracker","Map","operationId","methodPath","startTime","performance","timing","endTime","duration","timeToNextCall","milliseconds","currentTime","operationStartTime","CallTraceManager","methodPaths","PerformanceCapability","options","meta","originalMethod","isNewOperation","callTrace","formattedCallTrace","indent","childMethodKey","metrics","formattedDuration","childDurations","totalChildTime","sum","d","formattedTotalChildTime","overhead","formattedOverhead","currentTrace","parentPath","rootChildDurations","parentMethodKey","parentChildDurations","TracingCapability"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GAED,4EAA4E,GACrE,MAAMA,aAAa;IAAC;IAAU;IAAS;IAAQ;IAAQ;CAAQ,CAAU;AAIhF,uDAAuD,GACvD,MAAMC,OAAiC;IACnC,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;AACX;AAEA,MAAMC,aAAa,CAACC,QAChB,OAAOA,UAAU,YAAaH,WAAiC,QAAQ,CAACG;AAE5E;;;;;;;CAOC,GACD,MAAMC,eAAe;IACjB,IAAI,OAAOC,eAAe,aAAa;QACnC,MAAMC,IAAID;QAEV,IAAIH,WAAWI,EAAE,qBAAqB,GAAG;YACrC,OAAOA,EAAE,qBAAqB;QAClC;QAEA,oFAAoF;QACpF,4DAA4D;QAC5D,IAAIA,EAAE,iBAAiB,KAAK,MAAM,OAAO;QACzC,IAAIA,EAAE,iBAAiB,KAAK,OAAO,OAAO;IAC9C;IAEA,wFAAwF;IACxF,wFAAwF;IACxF,qFAAqF;IACrF,8FAA8F;IAC9F,6FAA6F;IAC7F,iFAAiF;IACjF,0DAA0D;IAC1D,IAAI,OAAOC,YAAY,eAAeA,QAAQ,GAAG,IAAI,MAAM;QACvD,IAAIL,WAAWK,QAAQ,GAAG,CAAC,iBAAiB,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BACN,IAAI,CAAC,gBAAgB,CAAC,qBAAqB;wBAE3C,IAAIyF,gBAAgB;4BAChB,IAAI,CAAC,gBAAgB,CAAC,YAAY;wBACtC;oBACJ;gBACJ;YACJ;QAEJ;IACJ;AACJ;;;AC3E0C;AACsB;AACR;AAChC"}
@@ -1,11 +0,0 @@
1
- import { PerformanceMetrics } from "../types";
2
- export declare class PerformanceTracker {
3
- private methodTimings;
4
- private operationStartTimes;
5
- startMethodTiming(operationId: string, methodPath: string): number;
6
- recordNextMethodStart(operationId: string, methodPath: string): void;
7
- endMethodTiming(operationId: string, methodPath: string): PerformanceMetrics;
8
- formatDuration(milliseconds: number): string;
9
- getDeltaFromOperationStart(operationId: string, currentTime: number): number;
10
- cleanupOperation(operationId: string): void;
11
- }
@@ -1,12 +0,0 @@
1
- export declare class CallTraceManager {
2
- private activeOperationId;
3
- private activeCallStack;
4
- startNewOperation(): string;
5
- isNewOperation(): boolean;
6
- getActiveOperationId(): string;
7
- addMethodToTrace(methodPath: string): string[];
8
- removeMethodFromTrace(): void;
9
- endOperation(): void;
10
- formatMethodPaths(methodPaths: string[]): string[];
11
- getCurrentTrace(): string[];
12
- }
@@ -1,17 +0,0 @@
1
- export type MethodInfoMetadata = {
2
- parent?: MethodInfoMetadata;
3
- instance: Record<string | symbol, any>;
4
- propertyName: string | symbol;
5
- path?: string;
6
- };
7
- export type MethodInfo = {
8
- name: string | symbol;
9
- isCallable: boolean;
10
- };
11
- export interface PerformanceMetrics {
12
- readonly startTime: number;
13
- readonly endTime?: number;
14
- readonly duration?: number;
15
- readonly nextMethodStartTime?: number;
16
- readonly timeToNextCall?: number;
17
- }